Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/dummy__backup__statepolicy_8cpp-source.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/dummy__backup__statepolicy_8cpp-source.html Fri Jan 22 18:26:19 2010 +0000
@@ -0,0 +1,155 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+<title>TB10.1 Example Applications: examples/AppFramework/ssmanager/policies/sysstates/dummy_backup_statepolicy.cpp Source File</title>
+<link href="doxygen.css" rel="stylesheet" type="text/css">
+<link href="tabs.css" rel="stylesheet" type="text/css">
+</head><body>
+<!-- Generated by Doxygen 1.5.3 -->
+<h1>examples/AppFramework/ssmanager/policies/sysstates/dummy_backup_statepolicy.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span>
+<a name="l00002"></a>00002 <span class="comment">// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).</span>
+<a name="l00003"></a>00003 <span class="comment">// All rights reserved.</span>
+<a name="l00004"></a>00004 <span class="comment">// This component and the accompanying materials are made available</span>
+<a name="l00005"></a>00005 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span>
+<a name="l00006"></a>00006 <span class="comment">// which accompanies this distribution, and is available</span>
+<a name="l00007"></a>00007 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span>
+<a name="l00008"></a>00008 <span class="comment">//</span>
+<a name="l00009"></a>00009 <span class="comment">// Initial Contributors:</span>
+<a name="l00010"></a>00010 <span class="comment">// Nokia Corporation - initial contribution.</span>
+<a name="l00011"></a>00011 <span class="comment">//</span>
+<a name="l00012"></a>00012 <span class="comment">// Contributors:</span>
+<a name="l00013"></a>00013 <span class="comment">//</span>
+<a name="l00014"></a>00014 <span class="comment">// Description: A dummy back up state policy is provided to demonstrate the utility</span>
+<a name="l00015"></a>00015 <span class="comment">// of System State Manager framework.</span>
+<a name="l00016"></a>00016 <span class="comment">//</span>
+<a name="l00017"></a>00017
+<a name="l00032"></a>00032 <span class="preprocessor">#include <ssm/ssmcommandlist.h></span>
+<a name="l00033"></a>00033 <span class="preprocessor">#include <ssm/ssmcommandlistresourcereader.h></span>
+<a name="l00034"></a>00034 <span class="preprocessor">#include <ssm/ssmsubstates.hrh></span>
+<a name="l00035"></a>00035 <span class="preprocessor">#include "dummy_backup_statepolicy.h"</span>
+<a name="l00036"></a>00036
+<a name="l00040"></a>00040 _LIT(KCommandListPath, <span class="stringliteral">"z:\\private\\2000d75b\\ssmaeg\\state_dummy_backup\\"</span>);
+<a name="l00041"></a>00041
+<a name="l00045"></a>00045 _LIT(KExamplePolicyPanic,<span class="stringliteral">"Dummy Back up State Policy"</span>);
+<a name="l00046"></a>00046
+<a name="l00052"></a>00052 EXPORT_C MSsmStatePolicy* CSsmDummyBackUpStatePolicy::NewL()
+<a name="l00053"></a>00053 {
+<a name="l00054"></a>00054 CSsmDummyBackUpStatePolicy* <span class="keyword">self</span> = <span class="keyword">new</span> (ELeave) CSsmDummyBackUpStatePolicy;
+<a name="l00055"></a>00055 CleanupStack::PushL(<span class="keyword">self</span>);
+<a name="l00056"></a>00056 <span class="keyword">self</span>->ConstructL();
+<a name="l00057"></a>00057 CleanupStack::Pop(<span class="keyword">self</span>);
+<a name="l00058"></a>00058 <span class="keywordflow">return</span> <span class="keyword">self</span>;
+<a name="l00059"></a>00059 }
+<a name="l00060"></a>00060
+<a name="l00064"></a>00064 CSsmDummyBackUpStatePolicy::CSsmDummyBackUpStatePolicy()
+<a name="l00065"></a>00065 {
+<a name="l00066"></a>00066 }
+<a name="l00067"></a>00067
+<a name="l00071"></a>00071 CSsmDummyBackUpStatePolicy::~CSsmDummyBackUpStatePolicy()
+<a name="l00072"></a>00072 {
+<a name="l00073"></a>00073 <span class="keyword">delete</span> iCommandListResourceReader;
+<a name="l00074"></a>00074 iFs.Close();
+<a name="l00075"></a>00075 iCurrentlySupportedTransitions.Close();
+<a name="l00076"></a>00076 }
+<a name="l00077"></a>00077
+<a name="l00083"></a>00083 <span class="keywordtype">void</span> CSsmDummyBackUpStatePolicy::ConstructL()
+<a name="l00084"></a>00084 {
+<a name="l00085"></a>00085 User::LeaveIfError(iFs.Connect());
+<a name="l00086"></a>00086
+<a name="l00087"></a>00087 <span class="comment">// Add supported transitions from Backup 'ESsmBackupSubState'</span>
+<a name="l00088"></a>00088 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmShutdown, KSsmAnySubState));
+<a name="l00089"></a>00089 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmFail, KSsmAnySubState));
+<a name="l00090"></a>00090 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmShutdown, ESsmShutdownSubStateCritical));
+<a name="l00091"></a>00091 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmNormal, KSsmAnySubState));
+<a name="l00092"></a>00092 iCurrentlySupportedTransitions.AppendL(TSsmState(ESsmRestore, ESsmRestoreSubState));
+<a name="l00093"></a>00093 <span class="comment">// create resource reader</span>
+<a name="l00094"></a>00094 iCommandListResourceReader = CSsmCommandListResourceReader::NewL(iFs, KCommandListPath(), *<span class="keyword">this</span>);
+<a name="l00095"></a>00095 }
+<a name="l00096"></a>00096
+<a name="l00105"></a>00105 <span class="keywordtype">void</span> CSsmDummyBackUpStatePolicy::Initialize(TRequestStatus& aStatus)
+<a name="l00106"></a>00106 {
+<a name="l00107"></a>00107 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
+<a name="l00108"></a>00108 <span class="comment">// initialise command list resource reader.</span>
+<a name="l00109"></a>00109 iCommandListResourceReader->Initialise(aStatus);
+<a name="l00110"></a>00110 }
+<a name="l00111"></a>00111
+<a name="l00119"></a>00119 <span class="keywordtype">void</span> CSsmDummyBackUpStatePolicy::InitializeCancel()
+<a name="l00120"></a>00120 {
+<a name="l00121"></a>00121 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
+<a name="l00122"></a>00122 iCommandListResourceReader->InitialiseCancel();
+<a name="l00123"></a>00123 }
+<a name="l00124"></a>00124
+<a name="l00130"></a>00130 <span class="keywordtype">void</span> CSsmDummyBackUpStatePolicy::Release()
+<a name="l00131"></a>00131 {
+<a name="l00132"></a>00132 <span class="keyword">delete</span> <span class="keyword">this</span>;
+<a name="l00133"></a>00133 }
+<a name="l00134"></a>00134
+<a name="l00153"></a>00153 MSsmStatePolicy::TResponse CSsmDummyBackUpStatePolicy::TransitionAllowed(<span class="keyword">const</span> TSsmStateTransition& aRequest, TSsmStateTransition <span class="keyword">const</span>* aCurrent, TSsmStateTransition <span class="keyword">const</span>* aQueued, <span class="keyword">const</span> RMessagePtr2& aMessage)
+<a name="l00154"></a>00154 {
+<a name="l00155"></a>00155 TResponse response = ENotAllowed;
+<a name="l00156"></a>00156 <span class="keywordflow">if</span> (!aMessage.HasCapability(ECapabilityPowerMgmt))
+<a name="l00157"></a>00157 {
+<a name="l00158"></a>00158 <span class="keywordflow">return</span> response;
+<a name="l00159"></a>00159 }
+<a name="l00160"></a>00160
+<a name="l00161"></a>00161 <span class="comment">//Check if the requested transition is supported from current state</span>
+<a name="l00162"></a>00162 <span class="keywordflow">if</span> (TransitionSupported(aRequest.State()))
+<a name="l00163"></a>00163 {
+<a name="l00164"></a>00164 <span class="keywordflow">if</span>((NULL == aCurrent) && (NULL == aQueued))
+<a name="l00165"></a>00165 {
+<a name="l00166"></a>00166 <span class="comment">// SsmServer is idle</span>
+<a name="l00167"></a>00167 response = EDefinitelyAllowed;
+<a name="l00168"></a>00168 }
+<a name="l00169"></a>00169 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(aRequest.State().MainState() == ESsmFail || aRequest.State().MainState() == ESsmShutdown)
+<a name="l00170"></a>00170 {
+<a name="l00171"></a>00171 <span class="comment">// Going into failed state will override anything currently ongoing or queued</span>
+<a name="l00172"></a>00172 response = EReplaceCurrentClearQueue;
+<a name="l00173"></a>00173 }
+<a name="l00174"></a>00174 }
+<a name="l00175"></a>00175 <span class="keywordflow">return</span> response;
+<a name="l00176"></a>00176 }
+<a name="l00186"></a>00186 <span class="keywordtype">void</span> CSsmDummyBackUpStatePolicy::PrepareCommandList(TSsmState aState, TInt <span class="comment">/*aReason*/</span>, TRequestStatus& aStatus)
+<a name="l00187"></a>00187 {
+<a name="l00188"></a>00188 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
+<a name="l00189"></a>00189 <span class="comment">//Let's start from the beginning if no specific sub state is selected</span>
+<a name="l00190"></a>00190 <span class="keyword">const</span> TUint16 substate = aState.SubState();
+<a name="l00191"></a>00191 <span class="comment">//Build the command list from a resource for this substate</span>
+<a name="l00192"></a>00192 iCommandListResourceReader->PrepareCommandList(substate, aState, aStatus);
+<a name="l00193"></a>00193 }
+<a name="l00194"></a>00194
+<a name="l00200"></a>00200 <span class="keywordtype">void</span> CSsmDummyBackUpStatePolicy::PrepareCommandListCancel()
+<a name="l00201"></a>00201 {
+<a name="l00202"></a>00202 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
+<a name="l00203"></a>00203 iCommandListResourceReader->PrepareCommandListCancel();
+<a name="l00204"></a>00204 }
+<a name="l00205"></a>00205
+<a name="l00212"></a>00212 CSsmCommandList* CSsmDummyBackUpStatePolicy::CommandList()
+<a name="l00213"></a>00213 {
+<a name="l00214"></a>00214 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader));
+<a name="l00215"></a>00215 <span class="keywordflow">return</span> iCommandListResourceReader->GetCommandList();
+<a name="l00216"></a>00216 }
+<a name="l00217"></a>00217
+<a name="l00229"></a>00229 TBool CSsmDummyBackUpStatePolicy::GetNextState(TSsmState <span class="comment">/*aCurrentTransition*/</span>, TInt <span class="comment">/*aReason*/</span>, TInt <span class="comment">/*aError*/</span>, TInt <span class="comment">/*aSeverity*/</span>, TSsmState& <span class="comment">/*aNextState*/</span>)
+<a name="l00230"></a>00230 {
+<a name="l00231"></a>00231 <span class="keywordflow">return</span> EFalse;
+<a name="l00232"></a>00232 }
+<a name="l00233"></a>00233
+<a name="l00244"></a>00244 TBool CSsmDummyBackUpStatePolicy::ConditionalCommandAllowedL(CResourceFile& <span class="comment">/*aResourceFile*/</span>, TInt <span class="comment">/*aResourceId*/</span>)
+<a name="l00245"></a>00245 {
+<a name="l00246"></a>00246 <span class="keywordflow">return</span> EFalse; <span class="comment">//command list doesn't contains commands which have conditions and hence returning EFalse </span>
+<a name="l00247"></a>00247 }
+<a name="l00248"></a>00248
+<a name="l00249"></a>00249 <span class="comment">/*</span>
+<a name="l00250"></a>00250 <span class="comment">Helper function to check whether a requested transition is supported or not.</span>
+<a name="l00251"></a>00251 <span class="comment">@param aRequestedState Requested transition</span>
+<a name="l00252"></a>00252 <span class="comment">@return ETrue if transition is supported</span>
+<a name="l00253"></a>00253 <span class="comment"> EFalse if transition is not supported</span>
+<a name="l00254"></a>00254 <span class="comment">*/</span>
+<a name="l00255"></a>00255 TBool CSsmDummyBackUpStatePolicy::TransitionSupported(<span class="keyword">const</span> TSsmState& aRequestedState)<span class="keyword"> const</span>
+<a name="l00256"></a>00256 <span class="keyword"> </span>{
+<a name="l00257"></a>00257 <span class="keywordflow">return</span> (iCurrentlySupportedTransitions.Find(aRequestedState) > KErrNotFound);
+<a name="l00258"></a>00258 }
+</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 21 10:32:54 2010 for TB10.1 Example Applications by
+<a href="http://www.doxygen.org/index.html">
+<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
+</body>
+</html>