sysstatemgmt/systemstarter/src/SysStart.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 #include <e32uid.h>
       
    19 #include <e32property.h>
       
    20 #include <domainmanager.h>
       
    21 
       
    22 #include "StartupState.h"
       
    23 #include "StartupStateInfo.h"
       
    24 #include "SysStartDebug.h"
       
    25 
       
    26 #include "sysstartpanic.h"
       
    27 #include "resourcefilereader2.h"
       
    28  	
       
    29 //
       
    30 // Standard Symbian factory functions/destructor
       
    31 //
       
    32 
       
    33 CSystemStarter* CSystemStarter::NewL()
       
    34 	{
       
    35 	CSystemStarter* self = NewLC();
       
    36 	CleanupStack::Pop(self);
       
    37 	return self;
       
    38 	}
       
    39 
       
    40 CSystemStarter* CSystemStarter::NewLC()
       
    41 	{
       
    42 	CSystemStarter* self = new (ELeave) CSystemStarter;
       
    43 	CleanupStack::PushL(self);
       
    44 	return self;
       
    45 	}
       
    46 
       
    47 CSystemStarter::~CSystemStarter()
       
    48 	{
       
    49 	Cancel();
       
    50 	}
       
    51 
       
    52 //
       
    53 // Public member functions
       
    54 //
       
    55 
       
    56 void CSystemStarter::Start()
       
    57 	{
       
    58 	// We need an active request so that we can actually start the active
       
    59 	// scheduler, hence this roundabout way of kicking things off...
       
    60 	RequestNotify();
       
    61 	}
       
    62 
       
    63 //
       
    64 // Member function overrides (CActive)
       
    65 //
       
    66 
       
    67 void CSystemStarter::RunL()
       
    68 	{
       
    69 	TInt bootMode = 0;
       
    70 	TInt err = RProperty::Get(KUidSystemCategory, KSystemStartupModeKey, bootMode);
       
    71 	DEBUGPRINT4(_L("SysStart: key=%d bootMode=%d error = %d"), KSystemStartupModeKey, bootMode, err);
       
    72 	if(KErrNone != err)
       
    73 		{
       
    74         PanicNow(KPanicSysStart, EPropertyRetrieveError);
       
    75         }
       
    76         
       
    77     // Domain manager has already been started by the boot starter...
       
    78     err = RDmDomainManager::AddDomainHierarchy(KDmHierarchyIdStartup);
       
    79 	if(KErrNone != err && KErrAlreadyExists !=err)
       
    80 		{
       
    81         PanicNow(KPanicSysStart, EAddDomainHierarchyError);
       
    82         }
       
    83     
       
    84 	RDmDomainManager::WaitForInitialization();
       
    85 
       
    86 	RFs fs;
       
    87 	User::LeaveIfError(fs.Connect());
       
    88 	CleanupClosePushL(fs);
       
    89 
       
    90 	CResourceFileReader* resourceReader = CResourceFileReader::NewLC(bootMode, fs); // bootMode is stored for later chekcing.
       
    91 	const MStartupStateInfo* info = resourceReader->GetStateInfoL();
       
    92 
       
    93 	__UHEAP_MARK;
       
    94 	while (info)
       
    95 		{
       
    96 		CStartupState* state = CStartupState::NewLC(*info);
       
    97 		state->Start();
       
    98 		CleanupStack::PopAndDestroy(state);
       
    99 		delete info;
       
   100 		info = resourceReader->GetStateInfoL();
       
   101 		}
       
   102 	__UHEAP_MARKEND;
       
   103 	
       
   104 	CleanupStack::PopAndDestroy(resourceReader);
       
   105 	CleanupStack::PopAndDestroy(); // fs
       
   106 	
       
   107 	CActiveScheduler::Stop();
       
   108 	}
       
   109 
       
   110 	
       
   111 TInt CSystemStarter::RunError(TInt /*aError*/)
       
   112 	{
       
   113 	return KErrNone;
       
   114 	}
       
   115 
       
   116 void CSystemStarter::DoCancel()
       
   117 	{
       
   118 	TRequestStatus* status = &iStatus;
       
   119 	User::RequestComplete(status, KErrCancel);
       
   120 	}
       
   121 
       
   122 //
       
   123 // Private member functions
       
   124 //
       
   125 
       
   126 CSystemStarter::CSystemStarter() :
       
   127 	CActive(EPriorityStandard)
       
   128 	{
       
   129 	CActiveScheduler::Add(this);
       
   130 	}
       
   131 
       
   132 void CSystemStarter::RequestNotify()
       
   133 	{
       
   134 	TRequestStatus* status = &iStatus;
       
   135 	User::RequestComplete(status, KErrNone);
       
   136 	SetActive();
       
   137 	}