Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/dummy__restore__statepolicy_8cpp_source.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>TB9.2 Example Applications: examples/AppFramework/ssmanager/policies/sysstates/dummy_restore_statepolicy.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.2 -->
<h1>examples/AppFramework/ssmanager/policies/sysstates/dummy_restore_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 restore state policy is provided with the system state manager</span>
<a name="l00015"></a>00015 <span class="comment">// example code which demonstrates the various utilities of SSM 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/ssmpublishsystemstateinfo.h></span>
<a name="l00034"></a>00034 <span class="preprocessor">#include <ssm/ssmcommandfactory.h></span>
<a name="l00035"></a>00035 <span class="preprocessor">#include <ssm/ssmstartupproperties.h></span>
<a name="l00036"></a>00036 <span class="preprocessor">#include "dummy_restore_statepolicy.h"</span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038
<a name="l00044"></a>00044 EXPORT_C MSsmStatePolicy* CSsmDummyRestoreStatePolicy::NewL()
<a name="l00045"></a>00045 {
<a name="l00046"></a>00046 CSsmDummyRestoreStatePolicy* <span class="keyword">self</span> = <span class="keyword">new</span> (ELeave) CSsmDummyRestoreStatePolicy;
<a name="l00047"></a>00047 CleanupStack::PushL(<span class="keyword">self</span>);
<a name="l00048"></a>00048 CleanupStack::Pop(<span class="keyword">self</span>);
<a name="l00049"></a>00049 <span class="keywordflow">return</span> <span class="keyword">self</span>;
<a name="l00050"></a>00050 }
<a name="l00051"></a>00051
<a name="l00055"></a>00055 CSsmDummyRestoreStatePolicy::CSsmDummyRestoreStatePolicy()
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057 }
<a name="l00058"></a>00058
<a name="l00062"></a>00062 CSsmDummyRestoreStatePolicy::~CSsmDummyRestoreStatePolicy()
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064 <span class="keyword">delete</span> iCommandList;
<a name="l00065"></a>00065 }
<a name="l00066"></a>00066
<a name="l00070"></a>00070 <span class="keywordtype">void</span> CSsmDummyRestoreStatePolicy::Initialize(TRequestStatus& aStatus)
<a name="l00071"></a>00071 {
<a name="l00072"></a>00072 TRequestStatus* rs = &aStatus;
<a name="l00073"></a>00073 User::RequestComplete(rs, KErrNone);
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075
<a name="l00079"></a>00079 <span class="keywordtype">void</span> CSsmDummyRestoreStatePolicy::InitializeCancel()
<a name="l00080"></a>00080 {
<a name="l00081"></a>00081 }
<a name="l00082"></a>00082
<a name="l00088"></a>00088 <span class="keywordtype">void</span> CSsmDummyRestoreStatePolicy::Release()
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090 <span class="keyword">delete</span> <span class="keyword">this</span>;
<a name="l00091"></a>00091 }
<a name="l00092"></a>00092
<a name="l00106"></a>00106 MSsmStatePolicy::TResponse CSsmDummyRestoreStatePolicy::TransitionAllowed(<span class="keyword">const</span> TSsmStateTransition& <span class="comment">/*aRequest*/</span>, TSsmStateTransition <span class="keyword">const</span>* <span class="comment">/*aCurrent*/</span>, TSsmStateTransition <span class="keyword">const</span>* <span class="comment">/*aQueued*/</span>, <span class="keyword">const</span> RMessagePtr2& <span class="comment">/*aMessage*/</span>)
<a name="l00107"></a>00107 {
<a name="l00108"></a>00108 <span class="keywordflow">return</span> EDefinitelyAllowed;
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110
<a name="l00119"></a>00119 <span class="keywordtype">void</span> CSsmDummyRestoreStatePolicy::PrepareCommandList(TSsmState aState, TInt <span class="comment">/*aReason*/</span>, TRequestStatus& aStatus)
<a name="l00120"></a>00120 {
<a name="l00121"></a>00121 TRAPD(err, doPrepareCommandListL(aState));
<a name="l00122"></a>00122 TRequestStatus* rs = &aStatus;
<a name="l00123"></a>00123 User::RequestComplete(rs, err);
<a name="l00124"></a>00124 }
<a name="l00125"></a>00125
<a name="l00126"></a>00126 <span class="keywordtype">void</span> CSsmDummyRestoreStatePolicy::doPrepareCommandListL(TSsmState aState)
<a name="l00127"></a>00127 {
<a name="l00128"></a>00128 <span class="comment">// Reset the command list</span>
<a name="l00129"></a>00129 <span class="keyword">delete</span> iCommandList;
<a name="l00130"></a>00130 iCommandList = NULL;
<a name="l00131"></a>00131 iCommandList = CSsmCommandList::NewL();
<a name="l00132"></a>00132 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KProcessName, <span class="stringliteral">"dummybackup.exe"</span>);
<a name="l00133"></a>00133 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KNullDesc, <span class="stringliteral">""</span>);
<a name="l00134"></a>00134 <span class="comment">// Start a process from your command list.</span>
<a name="l00135"></a>00135 CSsmStartupProperties* startupProperties = CSsmStartupProperties::NewL(KProcessName,KNullDesc);
<a name="l00136"></a>00136 CleanupStack::PushL(startupProperties);
<a name="l00137"></a>00137 TSsmPublishSystemStateInfo info;
<a name="l00138"></a>00138 TInt16 retries =0;<span class="comment">//Number of retries for this System State is given as '0'</span>
<a name="l00139"></a>00139 info.Set(aState, ETraverseParentsFirst, retries);
<a name="l00140"></a>00140 <span class="comment">// Create a command to publish Restore System State.</span>
<a name="l00141"></a>00141 MSsmCommand* cmd1 = SsmCommandFactory::ConstructPublishSystemStateCommandLC(ECmdCriticalSeverity, ESsmWaitForSignal, info);
<a name="l00142"></a>00142 <span class="comment">// Construct a command which will start a process</span>
<a name="l00143"></a>00143 MSsmCommand* cmd2 = SsmCommandFactory::ConstructStartProcessCommandLC(ECmdCriticalSeverity,startupProperties);
<a name="l00144"></a>00144 iCommandList->AppendL(cmd1);
<a name="l00145"></a>00145 iCommandList->AppendL(cmd2);
<a name="l00146"></a>00146 CleanupStack::Pop(2); <span class="comment">// Pops the above cmd1 and cmd2 from the stack.</span>
<a name="l00147"></a>00147 CleanupStack::PopAndDestroy(startupProperties);
<a name="l00148"></a>00148 }
<a name="l00149"></a>00149
<a name="l00155"></a>00155 <span class="keywordtype">void</span> CSsmDummyRestoreStatePolicy::PrepareCommandListCancel()
<a name="l00156"></a>00156 {
<a name="l00157"></a>00157 <span class="keyword">delete</span> iCommandList;
<a name="l00158"></a>00158 iCommandList = NULL;
<a name="l00159"></a>00159 }
<a name="l00160"></a>00160
<a name="l00166"></a>00166 CSsmCommandList* CSsmDummyRestoreStatePolicy::CommandList()
<a name="l00167"></a>00167 {
<a name="l00168"></a>00168 CSsmCommandList* list = iCommandList;
<a name="l00169"></a>00169 iCommandList = NULL;
<a name="l00170"></a>00170 <span class="keywordflow">return</span> list;
<a name="l00171"></a>00171 }
<a name="l00172"></a>00172
<a name="l00184"></a>00184 TBool CSsmDummyRestoreStatePolicy::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="l00185"></a>00185 {
<a name="l00186"></a>00186 <span class="keywordflow">return</span> EFalse;
<a name="l00187"></a>00187 }
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2 </small></address>
</body>
</html>