00001 // 00002 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 00003 // All rights reserved. 00004 // This component and the accompanying materials are made available 00005 // under the terms of "Eclipse Public License v1.0" 00006 // which accompanies this distribution, and is available 00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00008 // 00009 // Initial Contributors: 00010 // Nokia Corporation - initial contribution. 00011 // 00012 // Contributors: 00013 // 00014 // Description: A dummy restore state policy is provided with the system state manager 00015 // example code which demonstrates the various utilities of SSM framework. 00016 // 00017 00032 #include <ssm/ssmcommandlist.h> 00033 #include <ssm/ssmpublishsystemstateinfo.h> 00034 #include <ssm/ssmcommandfactory.h> 00035 #include <ssm/ssmstartupproperties.h> 00036 #include "dummy_restore_statepolicy.h" 00037 00038 00044 EXPORT_C MSsmStatePolicy* CSsmDummyRestoreStatePolicy::NewL() 00045 { 00046 CSsmDummyRestoreStatePolicy* self = new (ELeave) CSsmDummyRestoreStatePolicy; 00047 CleanupStack::PushL(self); 00048 CleanupStack::Pop(self); 00049 return self; 00050 } 00051 00055 CSsmDummyRestoreStatePolicy::CSsmDummyRestoreStatePolicy() 00056 { 00057 } 00058 00062 CSsmDummyRestoreStatePolicy::~CSsmDummyRestoreStatePolicy() 00063 { 00064 delete iCommandList; 00065 } 00066 00070 void CSsmDummyRestoreStatePolicy::Initialize(TRequestStatus& aStatus) 00071 { 00072 TRequestStatus* rs = &aStatus; 00073 User::RequestComplete(rs, KErrNone); 00074 } 00075 00079 void CSsmDummyRestoreStatePolicy::InitializeCancel() 00080 { 00081 } 00082 00088 void CSsmDummyRestoreStatePolicy::Release() 00089 { 00090 delete this; 00091 } 00092 00106 MSsmStatePolicy::TResponse CSsmDummyRestoreStatePolicy::TransitionAllowed(const TSsmStateTransition& /*aRequest*/, TSsmStateTransition const* /*aCurrent*/, TSsmStateTransition const* /*aQueued*/, const RMessagePtr2& /*aMessage*/) 00107 { 00108 return EDefinitelyAllowed; 00109 } 00110 00119 void CSsmDummyRestoreStatePolicy::PrepareCommandList(TSsmState aState, TInt /*aReason*/, TRequestStatus& aStatus) 00120 { 00121 TRAPD(err, doPrepareCommandListL(aState)); 00122 TRequestStatus* rs = &aStatus; 00123 User::RequestComplete(rs, err); 00124 } 00125 00126 void CSsmDummyRestoreStatePolicy::doPrepareCommandListL(TSsmState aState) 00127 { 00128 // Reset the command list 00129 delete iCommandList; 00130 iCommandList = NULL; 00131 iCommandList = CSsmCommandList::NewL(); 00132 _LIT(KProcessName, "dummybackup.exe"); 00133 _LIT(KNullDesc, ""); 00134 // Start a process from your command list. 00135 CSsmStartupProperties* startupProperties = CSsmStartupProperties::NewL(KProcessName,KNullDesc); 00136 CleanupStack::PushL(startupProperties); 00137 TSsmPublishSystemStateInfo info; 00138 TInt16 retries =0;//Number of retries for this System State is given as '0' 00139 info.Set(aState, ETraverseParentsFirst, retries); 00140 // Create a command to publish Restore System State. 00141 MSsmCommand* cmd1 = SsmCommandFactory::ConstructPublishSystemStateCommandLC(ECmdCriticalSeverity, ESsmWaitForSignal, info); 00142 // Construct a command which will start a process 00143 MSsmCommand* cmd2 = SsmCommandFactory::ConstructStartProcessCommandLC(ECmdCriticalSeverity,startupProperties); 00144 iCommandList->AppendL(cmd1); 00145 iCommandList->AppendL(cmd2); 00146 CleanupStack::Pop(2); // Pops the above cmd1 and cmd2 from the stack. 00147 CleanupStack::PopAndDestroy(startupProperties); 00148 } 00149 00155 void CSsmDummyRestoreStatePolicy::PrepareCommandListCancel() 00156 { 00157 delete iCommandList; 00158 iCommandList = NULL; 00159 } 00160 00166 CSsmCommandList* CSsmDummyRestoreStatePolicy::CommandList() 00167 { 00168 CSsmCommandList* list = iCommandList; 00169 iCommandList = NULL; 00170 return list; 00171 } 00172 00184 TBool CSsmDummyRestoreStatePolicy::GetNextState(TSsmState /*aCurrentTransition*/, TInt /*aReason*/, TInt /*aError*/, TInt /*aSeverity*/, TSsmState& /*aNextState*/) 00185 { 00186 return EFalse; 00187 }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.