00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00032 #include <ssm/ssmcommandlist.h>
00033 #include <ssm/ssmcommandlistresourcereader.h>
00034 #include <ssm/ssmsubstates.hrh>
00035 #include "dummy_backup_statepolicy.h"
00036
00040 _LIT(KCommandListPath, "z:\\private\\2000d75b\\ssmaeg\\state_dummy_backup\\");
00041
00045 _LIT(KExamplePolicyPanic,"Dummy Back up State Policy");
00046
00052 EXPORT_C MSsmStatePolicy* CSsmDummyBackUpStatePolicy::NewL()
00053 {
00054 CSsmDummyBackUpStatePolicy* self = new (ELeave) CSsmDummyBackUpStatePolicy;
00055 CleanupStack::PushL(self);
00056 self->ConstructL();
00057 CleanupStack::Pop(self);
00058 return self;
00059 }
00060
00064 CSsmDummyBackUpStatePolicy::CSsmDummyBackUpStatePolicy()
00065 {
00066 }
00067
00071 CSsmDummyBackUpStatePolicy::~CSsmDummyBackUpStatePolicy()
00072 {
00073 delete iCommandListResourceReader;
00074 iFs.Close();
00075 iCurrentlySupportedTransitions.Close();
00076 }
00077
00083 void CSsmDummyBackUpStatePolicy::ConstructL()
00084 {
00085 User::LeaveIfError(iFs.Connect());
00086
00087
00088 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmShutdown, KSsmAnySubState));
00089 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmFail, KSsmAnySubState));
00090 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmShutdown, ESsmShutdownSubStateCritical));
00091 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmNormal, KSsmAnySubState));
00092 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmRestore, ESsmRestoreSubState));
00093
00094 iCommandListResourceReader = CSsmCommandListResourceReader::NewL(iFs, KCommandListPath(), *this);
00095 }
00096
00105 void CSsmDummyBackUpStatePolicy::Initialize(TRequestStatus& aStatus)
00106 {
00107 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
00108
00109 iCommandListResourceReader->Initialise(aStatus);
00110 }
00111
00119 void CSsmDummyBackUpStatePolicy::InitializeCancel()
00120 {
00121 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
00122 iCommandListResourceReader->InitialiseCancel();
00123 }
00124
00130 void CSsmDummyBackUpStatePolicy::Release()
00131 {
00132 delete this;
00133 }
00134
00153 MSsmStatePolicy::TResponse CSsmDummyBackUpStatePolicy::TransitionAllowed(const TSsmStateTransition& aRequest, TSsmStateTransition const* aCurrent, TSsmStateTransition const* aQueued, const RMessagePtr2& aMessage)
00154 {
00155 TResponse response = ENotAllowed;
00156 if (!aMessage.HasCapability(ECapabilityPowerMgmt))
00157 {
00158 return response;
00159 }
00160
00161
00162 if (TransitionSupported(aRequest.State()))
00163 {
00164 if((NULL == aCurrent) && (NULL == aQueued))
00165 {
00166
00167 response = EDefinitelyAllowed;
00168 }
00169 else if(aRequest.State().MainState() == ESsmFail || aRequest.State().MainState() == ESsmShutdown)
00170 {
00171
00172 response = EReplaceCurrentClearQueue;
00173 }
00174 }
00175 return response;
00176 }
00186 void CSsmDummyBackUpStatePolicy::PrepareCommandList(TSsmState aState, TInt , TRequestStatus& aStatus)
00187 {
00188 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
00189
00190 const TUint16 substate = aState.SubState();
00191
00192 iCommandListResourceReader->PrepareCommandList(substate, aState, aStatus);
00193 }
00194
00200 void CSsmDummyBackUpStatePolicy::PrepareCommandListCancel()
00201 {
00202 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
00203 iCommandListResourceReader->PrepareCommandListCancel();
00204 }
00205
00212 CSsmCommandList* CSsmDummyBackUpStatePolicy::CommandList()
00213 {
00214 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
00215 return iCommandListResourceReader->GetCommandList();
00216 }
00217
00229 TBool CSsmDummyBackUpStatePolicy::GetNextState(TSsmState , TInt , TInt , TInt , TSsmState& )
00230 {
00231 return EFalse;
00232 }
00233
00244 TBool CSsmDummyBackUpStatePolicy::ConditionalCommandAllowedL(CResourceFile& , TInt )
00245 {
00246 return EFalse;
00247 }
00248
00249
00250
00251
00252
00253
00254
00255 TBool CSsmDummyBackUpStatePolicy::TransitionSupported(const TSsmState& aRequestedState) const
00256 {
00257 return (iCurrentlySupportedTransitions.Find(aRequestedState) > KErrNotFound);
00258 }