featuremgmt/featuremgr/src/serverexe/featmgrstartup.cpp
changeset 14 15018f1726c7
equal deleted inserted replaced
1:c084286672be 14:15018f1726c7
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include "featmgrserver.h"
       
    17 #include "featmgrdebug.h"
       
    18 #include "featmgrconfiguration.h"
       
    19 
       
    20 // -----------------------------------------------------------------------------
       
    21 // Function that starts the FeatMgrServer.
       
    22 // -----------------------------------------------------------------------------
       
    23 //
       
    24 static void RunServerL()
       
    25     {
       
    26     FUNC_LOG
       
    27 
       
    28     // Naming the server thread after the startup helps to debug panics
       
    29     User::LeaveIfError( User::RenameProcess( KServerProcessName ) );
       
    30     
       
    31     User::LeaveIfError( User::RenameThread( KServerProcessName ) );
       
    32      
       
    33     // Create and install the active scheduler we need
       
    34     CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
       
    35     CleanupStack::PushL( scheduler );
       
    36     
       
    37     CActiveScheduler::Install( scheduler );
       
    38     
       
    39     // Now we are ready to instantiate the actual CServer2 instance
       
    40     CFeatMgrServer* server = CFeatMgrServer::NewLC( KServerCActivePriority );
       
    41 
       
    42 	// Initialisation complete, now signal the client
       
    43 	RProcess::Rendezvous(KErrNone);
       
    44 
       
    45     INFO_LOG( "RunServerL() - Starting scheduler..." );
       
    46 
       
    47 	// Ready to run
       
    48 	CActiveScheduler::Start();
       
    49 
       
    50     INFO_LOG( "RunServerL() - Scheduler stopped" );
       
    51 
       
    52 	// Cleanup the server and scheduler
       
    53 	CleanupStack::PopAndDestroy( server );
       
    54 	CleanupStack::PopAndDestroy( scheduler );
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // Main function
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 TInt E32Main()
       
    62     {
       
    63     FUNC_LOG
       
    64 
       
    65 	__UHEAP_MARK;
       
    66 
       
    67 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    68 	TInt ret = KErrNoMemory;
       
    69 
       
    70 	if ( cleanup )
       
    71 		{
       
    72 		TRAP( ret, RunServerL() );
       
    73 		delete cleanup;
       
    74 		}
       
    75 
       
    76 	__UHEAP_MARKEND;
       
    77 
       
    78 	return ret;
       
    79     }