sysstatemgmt/systemstarter/src/start.cpp
changeset 0 4e1aa6a622a0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysstatemgmt/systemstarter/src/start.cpp	Tue Feb 02 00:53:00 2010 +0200
@@ -0,0 +1,63 @@
+// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:
+//
+
+#include "SysStart.h"
+
+LOCAL_C void StartSystemL();
+
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK; // mark heap state
+
+	CTrapCleanup* theTrapCleanup=CTrapCleanup::New();
+	
+	if (!theTrapCleanup)
+		{
+		return KErrNoMemory;
+		}
+	else
+		{		
+		TRAPD(error, StartSystemL());
+    
+    	delete theTrapCleanup;
+		__UHEAP_MARKEND; // check no memory leak
+
+		return(error);
+		}
+	}
+
+LOCAL_C void StartSystemL()
+	{
+	if(!User::CreatorHasCapability(ECapabilityPowerMgmt))
+		{
+		User::Leave(KErrPermissionDenied); // ensure creator is trusted
+		}
+
+	__UHEAP_MARK;
+
+	CActiveScheduler* theScheduler = new (ELeave) CActiveScheduler();
+	CleanupStack::PushL(theScheduler);
+	CActiveScheduler::Install(theScheduler);
+
+	CSystemStarter* starter = CSystemStarter::NewLC();
+
+	starter->Start();
+	CActiveScheduler::Start();
+
+	CleanupStack::PopAndDestroy(starter);
+	CleanupStack::PopAndDestroy(theScheduler);
+	
+	__UHEAP_MARKEND;
+	}