testexecmdw/tef/tef/wrapperutils/src/sysstartplugin.cpp
branchRCL_3
changeset 3 9397a16b6eb8
parent 1 6edeef394eb7
equal deleted inserted replaced
1:6edeef394eb7 3:9397a16b6eb8
     1 /*
       
     2 * Copyright (c) 2005-2009 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <e32std.h>
       
    21 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT
       
    22 #include <ssm/ssmstate.h>
       
    23 #include <ssm/ssmsubstates.hrh>
       
    24 #include <ssm/ssmdomaindefs.h>
       
    25 #include <test/sysstartplugin.h>
       
    26 
       
    27 CSysStartPlugin::CSysStartPlugin()
       
    28 #else
       
    29 #include <startup.hrh>
       
    30 #include <startupdomaindefs.h>
       
    31 #include <test/sysstartplugin.h>
       
    32 
       
    33 CSysStartPlugin::CSysStartPlugin() : CDmDomain(KDmHierarchyIdStartup, KAppServicesDomain3)
       
    34 #endif
       
    35 	{
       
    36 	
       
    37 	}
       
    38 
       
    39 /**
       
    40  * Destructor
       
    41  * Frees the resources located in second-phase constructor
       
    42  */
       
    43 CSysStartPlugin::~CSysStartPlugin()
       
    44 	{
       
    45 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT
       
    46 	if (iStateAwareSession)
       
    47 		{
       
    48 		delete iStateAwareSession;
       
    49 		}
       
    50 #endif
       
    51 	}
       
    52 
       
    53 /**
       
    54  * Creates, and returns a pointer to CSysStartPlugin object, leave on failure
       
    55  * @param aName - Path and name of the ini file to be parsed
       
    56  * @return A pointer to the CSysStartPlugin object
       
    57  */
       
    58 CSysStartPlugin* CSysStartPlugin::NewL()
       
    59 	{
       
    60 	CSysStartPlugin* self = new(ELeave) CSysStartPlugin();
       
    61 	CleanupStack::PushL(self);
       
    62 	self->ConstructL();
       
    63 	CleanupStack::Pop();
       
    64 	return self;
       
    65 	}
       
    66 
       
    67 void CSysStartPlugin::ConstructL()
       
    68 	{
       
    69 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT
       
    70 	iStateAwareSession = CSsmStateAwareSession::NewL(KSM2AppServicesDomain3);
       
    71 	iStateAwareSession->AddSubscriberL(*this);
       
    72 	}
       
    73 
       
    74 void CSysStartPlugin::StateChanged(TSsmState aSsmState)
       
    75 	{
       
    76 	//if (ESsmNormal==aSsmState.MainState() && ESsmNormalSubState==aSsmState.SubState())
       
    77 	if (aSsmState.Int() >= ESsmStartupSubStateNonCritical)
       
    78 		{
       
    79 		CActiveScheduler::Stop();
       
    80 		}
       
    81 #else
       
    82 	CDmDomain::ConstructL();
       
    83 #endif
       
    84 	}
       
    85 
       
    86 void CSysStartPlugin::WaitForSystemStartL()
       
    87 	{
       
    88 #ifdef SYMBIAN_SYSTEM_STATE_MANAGEMENT
       
    89 	TSsmState state = iStateAwareSession->State();
       
    90 	if (state.Int() < ESsmStartupSubStateNonCritical)
       
    91 		{
       
    92 		CActiveScheduler::Start();
       
    93 		}
       
    94 	}
       
    95 #else
       
    96 	TDmDomainState state = GetState();
       
    97 	if (state < EStartupStateNonCritical)
       
    98 		{
       
    99 		RequestTransitionNotification();
       
   100 		CActiveScheduler::Start();
       
   101 		}
       
   102 	}
       
   103 	
       
   104 void CSysStartPlugin::RunL()
       
   105 	{
       
   106 	TDmDomainState state = GetState();
       
   107 	if (state >= EStartupStateNonCritical)
       
   108 		{
       
   109 		CActiveScheduler::Stop();
       
   110 		}
       
   111 	else
       
   112 		{
       
   113 		RequestTransitionNotification();
       
   114 		}
       
   115 	}
       
   116 	
       
   117 #endif