sysstatemgmt/systemstarter/src/start.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2005-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 "SysStart.h"
       
    17 
       
    18 LOCAL_C void StartSystemL();
       
    19 
       
    20 GLDEF_C TInt E32Main()
       
    21 	{
       
    22 	__UHEAP_MARK; // mark heap state
       
    23 
       
    24 	CTrapCleanup* theTrapCleanup=CTrapCleanup::New();
       
    25 	
       
    26 	if (!theTrapCleanup)
       
    27 		{
       
    28 		return KErrNoMemory;
       
    29 		}
       
    30 	else
       
    31 		{		
       
    32 		TRAPD(error, StartSystemL());
       
    33     
       
    34     	delete theTrapCleanup;
       
    35 		__UHEAP_MARKEND; // check no memory leak
       
    36 
       
    37 		return(error);
       
    38 		}
       
    39 	}
       
    40 
       
    41 LOCAL_C void StartSystemL()
       
    42 	{
       
    43 	if(!User::CreatorHasCapability(ECapabilityPowerMgmt))
       
    44 		{
       
    45 		User::Leave(KErrPermissionDenied); // ensure creator is trusted
       
    46 		}
       
    47 
       
    48 	__UHEAP_MARK;
       
    49 
       
    50 	CActiveScheduler* theScheduler = new (ELeave) CActiveScheduler();
       
    51 	CleanupStack::PushL(theScheduler);
       
    52 	CActiveScheduler::Install(theScheduler);
       
    53 
       
    54 	CSystemStarter* starter = CSystemStarter::NewLC();
       
    55 
       
    56 	starter->Start();
       
    57 	CActiveScheduler::Start();
       
    58 
       
    59 	CleanupStack::PopAndDestroy(starter);
       
    60 	CleanupStack::PopAndDestroy(theScheduler);
       
    61 	
       
    62 	__UHEAP_MARKEND;
       
    63 	}