upnpsharing/upnpcontentserver/src/upnpcontentserver.cpp
author samhuttu
Mon, 01 Nov 2010 12:37:49 +0200
branchnew development branch with rendering state machine and other goodies
changeset 38 5360b7ddc251
parent 32 3785f754ee62
permissions -rw-r--r--
New development branch with e.g. rendering state machine and a simple Qt example application using it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
     1
/*
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
     2
* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies).
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
     3
* All rights reserved.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
     4
* This component and the accompanying materials are made available
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
     6
* which accompanies this distribution, and is available
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
     8
*
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
     9
* Initial Contributors:
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    10
* Nokia Corporation - initial contribution.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    11
*
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    12
* Contributors:
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    13
*
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    14
* Description:      CUpnpContentServer class implamentation
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    15
 *
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    16
*/
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    17
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    18
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    19
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    20
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    21
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    22
#include <e32debug.h>
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    23
#include <w32std.h>
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    24
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    25
#include "upnpcontentserver.h"
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    26
#include "upnpcontentserversession.h"
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    27
#include "upnpcontentserverdefs.h"
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    28
#include "upnpcontentserverhandler.h"
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    29
#include "upnpperiodic.h"
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    30
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    31
_LIT( KComponentLogfile, "contentserver.txt");
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    32
#include "upnplog.h"
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    33
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    34
// CONSTANTS
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    35
_LIT( KUpnpContentServerString, "Upnp content server");
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    36
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    37
using namespace UpnpContentServer;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    38
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    39
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    40
// Server's policy
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    41
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    42
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    43
//Total number of ranges
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    44
static const TUint KContentServerRangeCount = 1;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    45
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    46
//Definition of the ranges of IPC numbers
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    47
static const TInt contentServerRanges[KContentServerRangeCount] =
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    48
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    49
        0
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    50
        };
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    51
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    52
//Policy to implement for each of the above ranges
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    53
static const TUint8 contentServerElementsIndex[KContentServerRangeCount] =
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    54
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    55
        0, //applies to 0th range
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    56
        };
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    57
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    58
//Specific capability checks
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    59
static const CPolicyServer::TPolicyElement contentServerElements[] =
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    60
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    61
        {_INIT_SECURITY_POLICY_C3(ECapabilityReadUserData,
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    62
                                  ECapabilityWriteUserData,
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    63
                                  ECapabilityNetworkServices),
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    64
                                  CPolicyServer::EFailClient}
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    65
                                  //policy "0",
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    66
                                  //fail call if all capabilities not present
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    67
        };
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    68
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    69
//Package all the above together into a policy
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    70
static const CPolicyServer::TPolicy KUpnpContentServerPolicy =
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    71
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    72
        CPolicyServer::EAlwaysPass, //all connect attempts should pass
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    73
        KContentServerRangeCount,
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    74
        contentServerRanges,
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    75
        contentServerElementsIndex,
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    76
        contentServerElements
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    77
        };
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    78
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    79
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    80
// E32Main
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    81
// main function called by E32
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    82
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    83
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    84
GLDEF_C TInt E32Main()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    85
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    86
    TRAPD( ret, CUpnpContentServer::LaunchServerL() );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    87
    return ret;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    88
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    89
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    90
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    91
// CUpnpContentServer::LaunchServer
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    92
// Initializes the process and creates an instance of CUpnpContentServer.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    93
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    94
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    95
TInt CUpnpContentServer::LaunchServerL()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    96
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    97
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    98
    // Check server not already started
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
    99
    TFindServer findHostServer( KUpnpContentServer );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   100
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   101
    TInt err( KErrNone );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   102
    TFullName name;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   103
    if ( findHostServer.Next(name) == KErrNone )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   104
        { // found server already
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   105
        __LOG1( "Error: %d", __LINE__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   106
        err = KErrGeneral;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   107
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   108
    if ( !err )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   109
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   110
        User::RenameThread( KUpnpContentServer );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   111
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   112
        // Create cleanup stack.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   113
        CTrapCleanup* cleanup = CTrapCleanup::New();
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   114
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   115
        // Construct and install active scheduler.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   116
        CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   117
        CActiveScheduler::Install( scheduler );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   118
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   119
        // Construct server.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   120
        CUpnpContentServer* server = NULL;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   121
        TRAPD( err, server = CUpnpContentServer::NewL() );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   122
        if ( err )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   123
            {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   124
            __LOG1( "Error: %d", err );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   125
            }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   126
        RProcess::Rendezvous( err );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   127
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   128
        __LOG("CUpnpContentServer::LaunchServer, Start CActiveScheduler");
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   129
        // Start handling requests.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   130
        CActiveScheduler::Start();
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   131
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   132
        delete server;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   133
        __LOG("CUpnpContentServer::LaunchServer, Server deleted.");
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   134
        delete scheduler;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   135
        delete cleanup;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   136
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   137
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   138
    return err;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   139
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   140
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   141
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   142
// CUpnpContentServer::NewL
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   143
// 2-phased constructor.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   144
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   145
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   146
CUpnpContentServer* CUpnpContentServer::NewL()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   147
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   148
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   149
    CUpnpContentServer* self = new (ELeave) CUpnpContentServer();
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   150
    CleanupStack::PushL(self);
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   151
    self->ConstructL();
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   152
    self->StartL( KUpnpContentServer );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   153
    CleanupStack::Pop(); // self
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   154
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   155
    return self;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   156
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   157
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   158
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   159
// CUpnpContentServer::CUpnpContentServer()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   160
// C++ constructor.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   161
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   162
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   163
CUpnpContentServer::CUpnpContentServer()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   164
    : CPolicyServer( EPriorityStandard, KUpnpContentServerPolicy,
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   165
                     ESharableSessions )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   166
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   167
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   168
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   169
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   170
// CUpnpContentServer::ConstructL
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   171
// 2nd phase constructor.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   172
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   173
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   174
void CUpnpContentServer::ConstructL()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   175
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   176
    iHandler = CUpnpContentServerHandler::NewL( this );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   177
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   178
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   179
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   180
// CUpnpContentServer::~CUpnpContentServer()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   181
// C++ destructor.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   182
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   183
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   184
CUpnpContentServer::~CUpnpContentServer()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   185
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   186
    delete iHandler;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   187
    delete iContainerIndex;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   188
    delete iConMon;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   189
    delete iIdle;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   190
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   191
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   192
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   193
// CUpnpContentServer::Handler
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   194
// Returns pointer to CUpnpContentServerHandler
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   195
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   196
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   197
CUpnpContentServerHandler* CUpnpContentServer::Handler() const
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   198
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   199
    return iHandler;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   200
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   201
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   202
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   203
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   204
// CUpnpContentServer::NewContainerL
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   205
// Deletes  objcet container
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   206
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   207
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   208
void CUpnpContentServer::RemoveSession( )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   209
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   210
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   211
    iSessionCount--;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   212
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   213
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   214
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   215
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   216
// CUpnpContentServer::NewContainerL
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   217
// Deletes  objcet container
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   218
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   219
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   220
void CUpnpContentServer::AddSession()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   221
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   222
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   223
    iSessionCount++;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   224
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   225
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   226
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   227
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   228
// CUpnpContentServer::CanStop
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   229
// ( other items are commented in header )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   230
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   231
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   232
TBool CUpnpContentServer::CanStop() const
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   233
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   234
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   235
    TBool ret( EFalse );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   236
    if ( iSessionCount < 1 && !iConMon )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   237
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   238
        ret = ETrue;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   239
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   240
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   241
    return ret;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   242
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   243
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   244
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   245
// CUpnpContentServer::Stop
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   246
// ( other items are commented in header )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   247
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   248
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   249
void CUpnpContentServer::Stop()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   250
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   251
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   252
    if ( iIdle )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   253
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   254
        iIdle->Cancel();
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   255
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   256
    else
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   257
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   258
        TRAPD( err, iIdle = CUPnPPeriodic::NewL( CActive::EPriorityIdle ) );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   259
        __ASSERT( err == KErrNone, __FILE__, __LINE__  );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   260
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   261
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   262
    iIdle->Start( KShutdownTimeout, 
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   263
                  KShutdownTimeout, 
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   264
                  TCallBack( Shutdown, this ) );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   265
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   266
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   267
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   268
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   269
// CUpnpContentServer::Shutdown
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   270
// ( other items are commented in header )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   271
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   272
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   273
TInt CUpnpContentServer::Shutdown( TAny* aPtr )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   274
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   275
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   276
    CUpnpContentServer* server = static_cast<CUpnpContentServer*>(aPtr);
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   277
    delete server->iIdle;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   278
    server->iIdle = NULL;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   279
    CActiveScheduler::Stop();
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   280
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   281
    return KErrNone;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   282
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   283
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   284
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   285
// CUpnpContentServer::RequestConnectionLostL
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   286
// ( other items are commented in header )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   287
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   288
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   289
TInt CUpnpContentServer::RequestConnectionLostL(
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   290
    const TInt aIapId )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   291
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   292
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   293
    TInt err( KErrNone );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   294
    if ( !iConMon )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   295
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   296
        iConMon = CUPnPConnectionMonitor::NewL( aIapId );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   297
        iConMon->SetObserver( *this );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   298
        iActiveIapId = aIapId;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   299
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   300
    else if ( iActiveIapId != aIapId )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   301
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   302
        err = KErrInUse;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   303
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   304
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   305
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   306
    return err;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   307
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   308
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   309
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   310
// CUpnpContentServer::CancelConnectionLostL
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   311
// ( other items are commented in header )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   312
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   313
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   314
void CUpnpContentServer::CancelConnectionLostL()
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   315
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   316
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   317
    // Stop connection monitoring
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   318
    delete iConMon;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   319
    iConMon = NULL;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   320
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   321
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   322
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   323
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   324
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   325
// CUpnpContentServer::ConnectionLost
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   326
// ( other items are commented in header )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   327
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   328
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   329
void CUpnpContentServer::ConnectionLost( TBool /*aUserOriented*/ )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   330
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   331
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   332
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   333
    TRAP_IGNORE( iHandler->ConnectionLostL() );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   334
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   335
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   336
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   337
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   338
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   339
// CUpnpContentServer::RunError
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   340
// ( other items are commented in header )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   341
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   342
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   343
TInt CUpnpContentServer::RunError( TInt aError )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   344
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   345
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   346
    if ( aError )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   347
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   348
        __LOG1( "Error: %d", aError );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   349
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   350
    if ( aError == KErrBadDescriptor )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   351
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   352
        Message().Panic( KUpnpContentServerString, aError );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   353
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   354
    else
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   355
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   356
        Message().Complete( aError );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   357
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   358
    ReStart();
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   359
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   360
    return KErrNone;
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   361
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   362
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   363
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   364
// CUpnpContentServer::NewSessionL
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   365
// from CServer2, creates a new session.
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   366
// --------------------------------------------------------------------------
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   367
//
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   368
CSession2* CUpnpContentServer::NewSessionL(
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   369
    const TVersion& aVersion,
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   370
    const RMessage2& /*aMessage*/ ) const
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   371
    {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   372
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   373
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   374
    if ( iIdle )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   375
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   376
        iIdle->Cancel();
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   377
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   378
    
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   379
    TVersion v( KUpnpContentServerVersionMajor,
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   380
                KUpnpContentServerVersionMinor,
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   381
                0 );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   382
    if( !User::QueryVersionSupported(v,aVersion) )
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   383
        {
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   384
        User::Leave(KErrNotSupported);
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   385
        }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   386
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   387
    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   388
    return CUpnpContentServerSession::NewL( (CUpnpContentServer*)this );
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   389
    }
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   390
5360b7ddc251 New development branch with e.g. rendering state machine and a simple Qt example application using it.
samhuttu
parents: 32
diff changeset
   391
// End of file