00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <barsread2.h>
00024 #include <e32debug.h>
00025 #include <ssm/ssmcmd.hrh>
00026 #include <ssm/ssmsubstates.hrh>
00027
00028 #include <ssm/ssmstatetransition.h>
00029 #include <ssm/ssmcommandlistresourcereader.h>
00030
00031 #include "gsastatepolicynormal.h"
00032
00036 _LIT(KPanicGsaNormalState, "NormalStatePolicy");
00037
00043 EXPORT_C MSsmStatePolicy* CEgGsaStatePolicyNormal::NewL()
00044 {
00045 CEgGsaStatePolicyNormal* self = new (ELeave) CEgGsaStatePolicyNormal;
00046 CleanupStack::PushL(self);
00047 self->ConstructL();
00048 CleanupStack::Pop(self);
00049 return self;
00050 }
00051
00055 CEgGsaStatePolicyNormal::CEgGsaStatePolicyNormal()
00056 {
00057 }
00058
00062 CEgGsaStatePolicyNormal::~CEgGsaStatePolicyNormal()
00063 {
00064 delete iCommandListResourceReader;
00065 iCurrentlySupportedTransitions.Close();
00066 iFs.Close();
00067 }
00068
00074 void CEgGsaStatePolicyNormal::ConstructL()
00075 {
00076 User::LeaveIfError(iFs.Connect());
00077
00078
00079 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmShutdown, KSsmAnySubState));
00080 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmFail, KSsmAnySubState));
00081 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmShutdown, ESsmShutdownSubStateCritical));
00082 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmBackup, ESsmBackupSubState));
00083 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmRestore, ESsmRestoreSubState));
00084
00085
00086
00087
00088
00089 _LIT(KCommandListPath, "z:\\private\\2000D75B\\normal\\");
00090
00091
00092 iCommandListResourceReader = CSsmCommandListResourceReader::NewL(iFs, KCommandListPath(), *this);
00093 }
00094
00103 void CEgGsaStatePolicyNormal::Initialize(TRequestStatus& aStatus)
00104 {
00105 __ASSERT_DEBUG(iCommandListResourceReader, User::Panic(KPanicGsaNormalState, EInvalidResourceReader));
00106
00107
00108 iCommandListResourceReader->Initialise(aStatus);
00109 }
00110
00116 void CEgGsaStatePolicyNormal::InitializeCancel()
00117 {
00118 __ASSERT_DEBUG(iCommandListResourceReader, User::Panic(KPanicGsaNormalState, EInvalidResourceReader));
00119 iCommandListResourceReader->InitialiseCancel();
00120 }
00121
00127 void CEgGsaStatePolicyNormal::Release()
00128 {
00129 delete this;
00130 }
00131
00149 MSsmStatePolicy::TResponse CEgGsaStatePolicyNormal::TransitionAllowed(const TSsmStateTransition& aRequest, TSsmStateTransition const* aCurrent,
00150 TSsmStateTransition const* aQueued, const RMessagePtr2& aMessage)
00151 {
00152 TResponse response = ENotAllowed;
00153 if (!aMessage.HasCapability(ECapabilityPowerMgmt))
00154 {
00155 return response;
00156 }
00157
00158
00159 if (TransitionSupported(aRequest.State()))
00160 {
00161 if((NULL == aCurrent) && (NULL == aQueued))
00162 {
00163
00164 response = EDefinitelyAllowed;
00165 }
00166 else if(aRequest.State().MainState() == ESsmFail)
00167 {
00168
00169 response = EReplaceCurrentClearQueue;
00170 }
00171 }
00172 TSsmStateName name = aRequest.State().Name();
00173 return response;
00174 }
00175
00187 void CEgGsaStatePolicyNormal::PrepareCommandList(TSsmState aState, TInt , TRequestStatus& aStatus)
00188 {
00189 __ASSERT_DEBUG( iCommandListResourceReader , User::Panic(KPanicGsaNormalState, EInvalidResourceReader));
00190
00191
00192 const TUint16 substate = aState.SubState();
00193 const TSsmState state(aState.MainState(), (substate==KSsmAnySubState) ? ESsmNormalSubState : substate);
00194 const TInt commandListId = state.SubState();
00195
00196
00197 iCommandListResourceReader->PrepareCommandList(commandListId, state, aStatus);
00198 }
00199
00205 void CEgGsaStatePolicyNormal::PrepareCommandListCancel()
00206 {
00207 iCommandListResourceReader->PrepareCommandListCancel();
00208 }
00209
00216 CSsmCommandList* CEgGsaStatePolicyNormal::CommandList()
00217 {
00218 __ASSERT_DEBUG( iCommandListResourceReader , User::Panic(KPanicGsaNormalState, EInvalidResourceReader));
00219
00220 return iCommandListResourceReader->GetCommandList();
00221 }
00222
00235 TBool CEgGsaStatePolicyNormal::GetNextState(TSsmState aCurrentTransition, TInt , TInt aError, TInt , TSsmState& aNextState)
00236 {
00237 __ASSERT_ALWAYS(aCurrentTransition.MainState() == ESsmNormal, User::Panic(KPanicGsaNormalState, EInvalidNormalState));
00238 if (KErrNone != aError)
00239 {
00240 aNextState = TSsmState(ESsmFail, KSsmAnySubState);
00241 TSsmStateName name = aNextState.Name();
00242 return ETrue;
00243 }
00244
00245 return EFalse;
00246 }
00247
00258 TBool CEgGsaStatePolicyNormal::ConditionalCommandAllowedL(CResourceFile& , TInt )
00259 {
00260
00261 User::Panic(KPanicGsaNormalState, EConditionalInfoNotImplemented);
00262 return EFalse;
00263 }
00264
00265
00266
00267
00268
00269
00270
00271 TBool CEgGsaStatePolicyNormal::TransitionSupported(const TSsmState& aRequestedState) const
00272 {
00273 return (iCurrentlySupportedTransitions.Find(aRequestedState) > KErrNotFound);
00274 }