localconnectivityservice/locod/src/locodmain.cpp
branchRCL_3
changeset 20 4a793f564d72
parent 19 0aa8cc770c8a
child 21 74aa6861c87d
equal deleted inserted replaced
19:0aa8cc770c8a 20:4a793f564d72
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Global functions for Local Connectivity Daemon.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "locodaemon.h"
       
    20 #include "debug.h"
       
    21 
       
    22 _LIT( KLocodName, "LocalConnectivityDaemon" );
       
    23 
       
    24 static void StartDaemonL();
       
    25 
       
    26 // ======== LOCAL FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // E32Main.
       
    30 // Entry-point for LCD.
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 TInt E32Main()
       
    34     {
       
    35     TInt ret;
       
    36     User::RenameThread( KLocodName );
       
    37 
       
    38     __UHEAP_MARK;
       
    39     
       
    40     // create clean-up stack
       
    41     CTrapCleanup* cleanup = CTrapCleanup::New();
       
    42     TRAP( ret, StartDaemonL() );
       
    43     delete cleanup; // destroy clean-up stack
       
    44     __UHEAP_MARKEND;
       
    45 
       
    46     return ret;
       
    47     }
       
    48 
       
    49 // ----------------------------------------------------------------------------
       
    50 // StartDaemonL().
       
    51 // Constructs and installs the active scheduler, constructs Daemon object.
       
    52 // ----------------------------------------------------------------------------
       
    53 //
       
    54 static void StartDaemonL()
       
    55     {
       
    56     TRACE_FUNC
       
    57     
       
    58     // Construct and install the active scheduler
       
    59     CActiveScheduler *myScheduler = new ( ELeave ) CActiveScheduler();
       
    60 
       
    61     // Push onto the cleanup stack
       
    62     CleanupStack::PushL( myScheduler );
       
    63 
       
    64     // Install as the active scheduler
       
    65     CActiveScheduler::Install( myScheduler );
       
    66 
       
    67     CLocoDaemon* daemon = NULL;
       
    68     daemon = CLocoDaemon::NewLC();
       
    69     CActiveScheduler::Start();
       
    70 
       
    71     CleanupStack::PopAndDestroy( daemon );
       
    72     CleanupStack::PopAndDestroy( myScheduler );
       
    73     }
       
    74