|
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
2 <html xmlns="http://www.w3.org/1999/xhtml"> |
|
3 <head> |
|
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
|
5 <title>TB9.2 Example Applications: examples/AppFramework/ssmanager/src/ssmanager.cpp Source File</title> |
|
6 <link href="tabs.css" rel="stylesheet" type="text/css"/> |
|
7 <link href="doxygen.css" rel="stylesheet" type="text/css"/> |
|
8 </head> |
|
9 <body> |
|
10 <!-- Generated by Doxygen 1.6.2 --> |
|
11 <h1>examples/AppFramework/ssmanager/src/ssmanager.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span> |
|
12 <a name="l00002"></a>00002 <span class="comment">// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).</span> |
|
13 <a name="l00003"></a>00003 <span class="comment">// All rights reserved.</span> |
|
14 <a name="l00004"></a>00004 <span class="comment">// This component and the accompanying materials are made available</span> |
|
15 <a name="l00005"></a>00005 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span> |
|
16 <a name="l00006"></a>00006 <span class="comment">// which accompanies this distribution, and is available</span> |
|
17 <a name="l00007"></a>00007 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span> |
|
18 <a name="l00008"></a>00008 <span class="comment">//</span> |
|
19 <a name="l00009"></a>00009 <span class="comment">// Initial Contributors:</span> |
|
20 <a name="l00010"></a>00010 <span class="comment">// Nokia Corporation - initial contribution.</span> |
|
21 <a name="l00011"></a>00011 <span class="comment">//</span> |
|
22 <a name="l00012"></a>00012 <span class="comment">// Contributors:</span> |
|
23 <a name="l00013"></a>00013 <span class="comment">//</span> |
|
24 <a name="l00014"></a>00014 <span class="comment">// Description: This example is used to demonstrate the utilities of System state </span> |
|
25 <a name="l00015"></a>00015 <span class="comment">// Manager framework.</span> |
|
26 <a name="l00016"></a>00016 <span class="comment">// </span> |
|
27 <a name="l00017"></a>00017 |
|
28 <a name="l00028"></a>00028 <span class="preprocessor">#include "ssmanager.h"</span> |
|
29 <a name="l00029"></a>00029 <span class="preprocessor">#include "dummy_diskstatus_swppolicy.hrh"</span> |
|
30 <a name="l00030"></a>00030 <span class="preprocessor">#include <ssm/ssmsubstates.hrh></span> |
|
31 <a name="l00031"></a>00031 <span class="preprocessor">#include <ssm/ssmstate.h></span> |
|
32 <a name="l00032"></a>00032 <span class="preprocessor">#include <ssm/ssmstateawaresession.h></span> |
|
33 <a name="l00033"></a>00033 <span class="preprocessor">#include <ssm/ssmdomaindefs.h></span> |
|
34 <a name="l00034"></a>00034 |
|
35 <a name="l00035"></a>00035 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtExampleCode,<span class="stringliteral">"System State Manager Example"</span>); |
|
36 <a name="l00036"></a>00036 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtError,<span class="stringliteral">"error is %d\n"</span>); |
|
37 <a name="l00037"></a>00037 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtFormat,<span class="stringliteral">"*****************************\n"</span>); |
|
38 <a name="l00038"></a>00038 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtFormat1,<span class="stringliteral">".............\n"</span>); |
|
39 <a name="l00039"></a>00039 |
|
40 <a name="l00040"></a>00040 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtSwpInfo,<span class="stringliteral">"\nKey of the SwP is %d \n \nValue of the SwP is %d \n\n"</span>); |
|
41 <a name="l00041"></a>00041 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtSasResult,<span class="stringliteral">"\nState aware session connected with [%d]"</span>); |
|
42 <a name="l00042"></a>00042 |
|
43 <a name="l00043"></a>00043 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtState,<span class="stringliteral">"\nValue of new state :"</span>); |
|
44 <a name="l00044"></a>00044 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtReqNotificationChgofState,<span class="stringliteral">"\nRequest Notification for any change of state\n"</span>); |
|
45 <a name="l00045"></a>00045 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtStateValues,<span class="stringliteral">"\n Main state: %04x \n SubState: %04x \n"</span>); |
|
46 <a name="l00046"></a>00046 |
|
47 <a name="l00047"></a>00047 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtStateChangeResult,<span class="stringliteral">"\nState transition completed with : %d\n"</span>); |
|
48 <a name="l00048"></a>00048 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtSwpChangeResult,<span class="stringliteral">"\nSwP transition completed with : %d\n"</span>); |
|
49 <a name="l00049"></a>00049 |
|
50 <a name="l00050"></a>00050 <span class="keyword">const</span> TUint KFiveSecDelay = 500000; |
|
51 <a name="l00051"></a>00051 |
|
52 <a name="l00052"></a>00052 <span class="keyword">static</span> TInt StopScheduler(TAny* <span class="comment">/*aAny*/</span>) |
|
53 <a name="l00053"></a>00053 { |
|
54 <a name="l00054"></a>00054 CActiveScheduler::Stop(); |
|
55 <a name="l00055"></a>00055 <span class="keywordflow">return</span> KErrNone; |
|
56 <a name="l00056"></a>00056 } |
|
57 <a name="l00057"></a>00057 |
|
58 <a name="l00058"></a>00058 <a class="code" href="class_c_sys_state_manager_example.html">CSysStateManagerExample</a>* CSysStateManagerExample::NewLC() |
|
59 <a name="l00059"></a>00059 { |
|
60 <a name="l00060"></a>00060 <a class="code" href="class_c_sys_state_manager_example.html">CSysStateManagerExample</a>* <span class="keyword">self</span>=<span class="keyword">new</span>(ELeave)<a class="code" href="class_c_sys_state_manager_example.html">CSysStateManagerExample</a>(); |
|
61 <a name="l00061"></a>00061 CleanupStack::PushL(<span class="keyword">self</span>); |
|
62 <a name="l00062"></a>00062 <span class="keywordflow">return</span> <span class="keyword">self</span>; |
|
63 <a name="l00063"></a>00063 } |
|
64 <a name="l00064"></a>00064 |
|
65 <a name="l00065"></a>00065 CSysStateManagerExample::CSysStateManagerExample() |
|
66 <a name="l00066"></a>00066 { |
|
67 <a name="l00067"></a>00067 |
|
68 <a name="l00068"></a>00068 } |
|
69 <a name="l00069"></a>00069 |
|
70 <a name="l00073"></a><a class="code" href="class_c_sys_state_manager_example.html#a944fe05cd6a679bca6011802bc3dba33">00073</a> <a class="code" href="class_c_sys_state_manager_example.html#a944fe05cd6a679bca6011802bc3dba33">CSysStateManagerExample::~CSysStateManagerExample</a>() |
|
71 <a name="l00074"></a>00074 { |
|
72 <a name="l00075"></a>00075 iSsmStateManager.Close(); |
|
73 <a name="l00076"></a>00076 <span class="keyword">delete</span> iConsole; <span class="comment">// delete iConsole.</span> |
|
74 <a name="l00077"></a>00077 } |
|
75 <a name="l00078"></a>00078 |
|
76 <a name="l00082"></a><a class="code" href="class_c_sys_state_manager_example.html#a0c096e8f81f4c40a24bd43d9962f274e">00082</a> <span class="keywordtype">void</span> <a class="code" href="class_c_sys_state_manager_example.html#a0c096e8f81f4c40a24bd43d9962f274e">CSysStateManagerExample::SwpChanged</a>(TSsmSwp <span class="comment">/*aSwp*/</span>) |
|
77 <a name="l00083"></a>00083 { |
|
78 <a name="l00084"></a>00084 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtUserNotifiedSwPChange,<span class="stringliteral">"Notification received of a change in the SwP value.\n"</span>); |
|
79 <a name="l00085"></a>00085 iConsole->Printf(KTxtUserNotifiedSwPChange); |
|
80 <a name="l00086"></a>00086 } |
|
81 <a name="l00087"></a>00087 |
|
82 <a name="l00091"></a><a class="code" href="class_c_sys_state_manager_example.html#a1c585579a816b7e0f8393267a7a7a97a">00091</a> <span class="keywordtype">void</span> <a class="code" href="class_c_sys_state_manager_example.html#a1c585579a816b7e0f8393267a7a7a97a">CSysStateManagerExample::RequestSwpChange</a>() |
|
83 <a name="l00092"></a>00092 { |
|
84 <a name="l00097"></a>00097 TSsmSwp swp(EExampleSwPKey, ESwpValueJustPublishSwP); |
|
85 <a name="l00098"></a>00098 <span class="comment">// Request a Swp change</span> |
|
86 <a name="l00099"></a>00099 TRequestStatus status; |
|
87 <a name="l00100"></a>00100 iSsmStateManager.RequestSwpChange(swp, status); |
|
88 <a name="l00101"></a>00101 User::WaitForRequest(status); |
|
89 <a name="l00102"></a>00102 iConsole->Printf(KTxtSwpChangeResult,status.Int()); |
|
90 <a name="l00103"></a>00103 iConsole->Printf(KTxtSwpInfo,swp.Key(),swp.Value()); |
|
91 <a name="l00104"></a>00104 } |
|
92 <a name="l00105"></a>00105 |
|
93 <a name="l00109"></a><a class="code" href="class_c_sys_state_manager_example.html#a6b5511414b63e07e00fbff5af8808cad">00109</a> <span class="keywordtype">void</span> <a class="code" href="class_c_sys_state_manager_example.html#a6b5511414b63e07e00fbff5af8808cad">CSysStateManagerExample::RequestSsChange</a>() |
|
94 <a name="l00110"></a>00110 { |
|
95 <a name="l00111"></a>00111 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtNormalToRestore,<span class="stringliteral">"\nRequesting a System state change from Normal to Restore\n"</span>); |
|
96 <a name="l00112"></a>00112 TInt reason =0; <span class="comment">//Various reasons for state transition can be stated, the value is taken as '0'</span> |
|
97 <a name="l00113"></a>00113 TSsmStateTransition state(ESsmRestore, ESsmRestoreSubState, reason); |
|
98 <a name="l00114"></a>00114 iConsole->Printf(KTxtNormalToRestore); |
|
99 <a name="l00115"></a>00115 TRequestStatus status; |
|
100 <a name="l00116"></a>00116 iSsmStateManager.RequestStateTransition(state,status); |
|
101 <a name="l00117"></a>00117 User::WaitForRequest(status); |
|
102 <a name="l00118"></a>00118 User::After(KFiveSecDelay); <span class="comment">//Wait for 0.5sec to allow transitions to fully complete</span> |
|
103 <a name="l00119"></a>00119 iConsole->Printf(KTxtStateChangeResult,status.Int()); |
|
104 <a name="l00120"></a>00120 <span class="comment">//This session helps you to get the details of the current state of the device</span> |
|
105 <a name="l00121"></a>00121 RSsmStateAwareSession stateAwareSession; |
|
106 <a name="l00122"></a>00122 <span class="comment">/*</span> |
|
107 <a name="l00123"></a>00123 <span class="comment"> 'KSM2UiServicesDomain3' is the domain id for the third domain in the UI </span> |
|
108 <a name="l00124"></a>00124 <span class="comment"> Service level of the Startup Domain Hierarchy.</span> |
|
109 <a name="l00125"></a>00125 <span class="comment"> */</span> |
|
110 <a name="l00126"></a>00126 TInt ret = stateAwareSession.Connect(KSM2UiServicesDomain3); |
|
111 <a name="l00127"></a>00127 <span class="keywordflow">if</span>(ret!=KErrNone) |
|
112 <a name="l00128"></a>00128 { |
|
113 <a name="l00129"></a>00129 iConsole->Printf(KTxtSasResult,ret); |
|
114 <a name="l00130"></a>00130 } |
|
115 <a name="l00131"></a>00131 <span class="keywordflow">else</span> |
|
116 <a name="l00132"></a>00132 { |
|
117 <a name="l00133"></a>00133 TSsmState current = stateAwareSession.State(); |
|
118 <a name="l00134"></a>00134 TSsmStateName name = current.Name(); |
|
119 <a name="l00135"></a>00135 iConsole->Printf(KTxtState); |
|
120 <a name="l00136"></a>00136 iConsole->Printf(name); |
|
121 <a name="l00137"></a>00137 iConsole->Printf(KTxtStateValues,current.MainState(),current.SubState()); |
|
122 <a name="l00138"></a>00138 stateAwareSession.Close(); |
|
123 <a name="l00139"></a>00139 } |
|
124 <a name="l00140"></a>00140 } |
|
125 <a name="l00141"></a>00141 |
|
126 <a name="l00146"></a><a class="code" href="class_c_sys_state_manager_example.html#a7c3ee7dd5826eb98097e2c2ef43ed980">00146</a> <span class="keywordtype">void</span> <a class="code" href="class_c_sys_state_manager_example.html#a7c3ee7dd5826eb98097e2c2ef43ed980">CSysStateManagerExample::RequestSwpChangeWithNotificationL</a>() |
|
127 <a name="l00147"></a>00147 { |
|
128 <a name="l00148"></a>00148 CActiveScheduler* sched = <span class="keyword">new</span>(ELeave) CActiveScheduler; |
|
129 <a name="l00149"></a>00149 CleanupStack::PushL(sched); |
|
130 <a name="l00150"></a>00150 CActiveScheduler::Install(sched); |
|
131 <a name="l00155"></a>00155 CSsmSystemWideProperty* cProp = CSsmSystemWideProperty::NewLC(EExampleSwPKey); |
|
132 <a name="l00156"></a>00156 |
|
133 <a name="l00157"></a>00157 <span class="comment">// Subscribe to changes in dummy disk status Swp</span> |
|
134 <a name="l00158"></a>00158 cProp->AddSubscriberL(*<span class="keyword">this</span>); |
|
135 <a name="l00159"></a>00159 |
|
136 <a name="l00160"></a>00160 <span class="comment">// Request Swp changes</span> |
|
137 <a name="l00161"></a>00161 TSsmSwp swp(EExampleSwPKey,ESwpValueJustPublishSwP); |
|
138 <a name="l00162"></a>00162 TRequestStatus status; |
|
139 <a name="l00163"></a>00163 iSsmStateManager.RequestSwpChange(swp, status); |
|
140 <a name="l00164"></a>00164 User::WaitForRequest(status); |
|
141 <a name="l00165"></a>00165 iConsole->Printf(KTxtSwpChangeResult,status.Int()); |
|
142 <a name="l00166"></a>00166 iConsole->Printf(KTxtSwpInfo,swp.Key(),swp.Value()); |
|
143 <a name="l00167"></a>00167 |
|
144 <a name="l00168"></a>00168 <span class="comment">// Request Swp changes</span> |
|
145 <a name="l00169"></a>00169 swp.Set(EExampleSwPKey,ESwpValueForBackup); |
|
146 <a name="l00170"></a>00170 iSsmStateManager.RequestSwpChange(swp, status); |
|
147 <a name="l00171"></a>00171 User::WaitForRequest(status); |
|
148 <a name="l00172"></a>00172 iConsole->Printf(KTxtSwpChangeResult,status.Int()); |
|
149 <a name="l00173"></a>00173 iConsole->Printf(KTxtSwpInfo,swp.Key(),swp.Value()); |
|
150 <a name="l00174"></a>00174 CAsyncCallBack* stopper = <span class="keyword">new</span>(ELeave) CAsyncCallBack(CActive::EPriorityIdle); |
|
151 <a name="l00175"></a>00175 CleanupStack::PushL(stopper); |
|
152 <a name="l00176"></a>00176 TCallBack stopSchedulerCallback(StopScheduler, <span class="keyword">this</span>); |
|
153 <a name="l00177"></a>00177 stopper->Set(stopSchedulerCallback); |
|
154 <a name="l00178"></a>00178 |
|
155 <a name="l00179"></a>00179 <span class="comment">// This callback will not run until the Swp change is finished, because it has idle priority. </span> |
|
156 <a name="l00180"></a>00180 stopper->CallBack(); |
|
157 <a name="l00181"></a>00181 <span class="comment">// Causes CSsmSystemWideProperty::RunL to run, as cProp is subscribing on 'Dummy Disk Status' changes</span> |
|
158 <a name="l00182"></a>00182 sched->Start(); |
|
159 <a name="l00183"></a>00183 CleanupStack::PopAndDestroy(3, sched); <span class="comment">// Pop and Destroy sched, cprop and stopper.</span> |
|
160 <a name="l00184"></a>00184 } |
|
161 <a name="l00185"></a>00185 |
|
162 <a name="l00190"></a><a class="code" href="class_c_sys_state_manager_example.html#a3e70c77631e8cd6092de93f51cab49ad">00190</a> <span class="keywordtype">void</span> <a class="code" href="class_c_sys_state_manager_example.html#a3e70c77631e8cd6092de93f51cab49ad">CSysStateManagerExample::RequestSsChangeWithNotification</a>() |
|
163 <a name="l00191"></a>00191 { |
|
164 <a name="l00192"></a>00192 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtStateChangeNotificationSuccess,<span class="stringliteral">"\nNotification of the state transition received\n"</span>); |
|
165 <a name="l00193"></a>00193 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtStateChangeNotificationFailure,<span class="stringliteral">"\nNotification of the state transition failed\n"</span>); |
|
166 <a name="l00194"></a>00194 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtNormalToBackup,<span class="stringliteral">"\nRequest a System State change from Normal to Back up\n"</span>); |
|
167 <a name="l00195"></a>00195 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtAlreadyInThisState,<span class="stringliteral">"\nSystem state is already in Backup\n"</span>); |
|
168 <a name="l00196"></a>00196 |
|
169 <a name="l00197"></a>00197 <span class="comment">// This session helps you to get the details of the current state of the device</span> |
|
170 <a name="l00198"></a>00198 RSsmStateAwareSession stateAwareSession; |
|
171 <a name="l00199"></a>00199 |
|
172 <a name="l00200"></a>00200 <span class="comment">/*</span> |
|
173 <a name="l00201"></a>00201 <span class="comment"> 'KSM2UiServicesDomain3' is the domain id for the third domain in the UI </span> |
|
174 <a name="l00202"></a>00202 <span class="comment"> Service level of the Startup Domain Hierarchy.</span> |
|
175 <a name="l00203"></a>00203 <span class="comment"> */</span> |
|
176 <a name="l00204"></a>00204 TInt err = stateAwareSession.Connect(KSM2UiServicesDomain3); |
|
177 <a name="l00205"></a>00205 iConsole->Printf(KTxtSasResult,err); |
|
178 <a name="l00206"></a>00206 TSsmState current = stateAwareSession.State(); |
|
179 <a name="l00207"></a>00207 TSsmStateName name = current.Name(); |
|
180 <a name="l00208"></a>00208 |
|
181 <a name="l00209"></a>00209 <span class="keywordflow">if</span>(current.MainState()!= ESsmBackup) |
|
182 <a name="l00210"></a>00210 { |
|
183 <a name="l00211"></a>00211 TSsmStateTransition state1(ESsmBackup,ESsmBackupSubState, 0); |
|
184 <a name="l00212"></a>00212 iConsole->Printf(KTxtNormalToBackup); |
|
185 <a name="l00213"></a>00213 TRequestStatus status1,status2; |
|
186 <a name="l00214"></a>00214 iConsole->Printf(KTxtReqNotificationChgofState); |
|
187 <a name="l00215"></a>00215 stateAwareSession.RequestStateNotification(status1); |
|
188 <a name="l00216"></a>00216 iSsmStateManager.RequestStateTransition(state1,status2); |
|
189 <a name="l00217"></a>00217 User::WaitForRequest(status2); |
|
190 <a name="l00218"></a>00218 User::After(KFiveSecDelay); <span class="comment">// Wait for 0.5 sec to allow transitions to fully complete</span> |
|
191 <a name="l00219"></a>00219 <span class="keywordflow">if</span>(status2.Int() == KErrNone) |
|
192 <a name="l00220"></a>00220 { |
|
193 <a name="l00221"></a>00221 iConsole->Printf(KTxtStateChangeResult,status2.Int()); |
|
194 <a name="l00222"></a>00222 current = stateAwareSession.State(); |
|
195 <a name="l00223"></a>00223 name = current.Name(); |
|
196 <a name="l00224"></a>00224 } |
|
197 <a name="l00225"></a>00225 <span class="keywordflow">else</span> |
|
198 <a name="l00226"></a>00226 { |
|
199 <a name="l00227"></a>00227 iConsole->Printf(KTxtStateChangeResult,status2.Int()); |
|
200 <a name="l00228"></a>00228 } |
|
201 <a name="l00229"></a>00229 iConsole->Printf(KTxtState); |
|
202 <a name="l00230"></a>00230 iConsole->Printf(name); |
|
203 <a name="l00231"></a>00231 iConsole->Printf(KTxtStateValues,current.MainState(),current.SubState()); |
|
204 <a name="l00232"></a>00232 User::WaitForRequest(status1); <span class="comment">//status1 of the Notification request waits for status2 to complete</span> |
|
205 <a name="l00233"></a>00233 <span class="keywordflow">if</span>(status1.Int() == KErrNone) |
|
206 <a name="l00234"></a>00234 { |
|
207 <a name="l00235"></a>00235 iConsole->Printf(KTxtStateChangeNotificationSuccess); |
|
208 <a name="l00236"></a>00236 } |
|
209 <a name="l00237"></a>00237 <span class="keywordflow">else</span> |
|
210 <a name="l00238"></a>00238 { |
|
211 <a name="l00239"></a>00239 iConsole->Printf(KTxtStateChangeNotificationFailure); |
|
212 <a name="l00240"></a>00240 } |
|
213 <a name="l00241"></a>00241 } |
|
214 <a name="l00242"></a>00242 <span class="keywordflow">else</span> |
|
215 <a name="l00243"></a>00243 { |
|
216 <a name="l00244"></a>00244 iConsole->Printf(KTxtAlreadyInThisState); |
|
217 <a name="l00245"></a>00245 } |
|
218 <a name="l00246"></a>00246 stateAwareSession.Close(); |
|
219 <a name="l00247"></a>00247 } |
|
220 <a name="l00248"></a>00248 |
|
221 <a name="l00249"></a>00249 <span class="keywordtype">void</span> CSysStateManagerExample::SSManagerL() |
|
222 <a name="l00250"></a>00250 { |
|
223 <a name="l00251"></a>00251 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextPressAnyKey,<span class="stringliteral">" [press any key]"</span>); |
|
224 <a name="l00252"></a>00252 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTextPressAnyKeyToExit,<span class="stringliteral">" [press any key to exit]"</span>); |
|
225 <a name="l00253"></a>00253 |
|
226 <a name="l00254"></a>00254 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtSwp,<span class="stringliteral">"Swp means SystemWide Property.\nDisk status, Battery information are few examples of System wide properties.\n"</span>); |
|
227 <a name="l00255"></a>00255 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtSs,<span class="stringliteral">"\n SS means System State.\n Ex:Backup,Restore, Start-up, Shutdown are few examples of System states.\n"</span>); |
|
228 <a name="l00256"></a>00256 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtExampleDemo,<span class="stringliteral">"\n The example helps the user in understanding, how to define new System states and System wide properties.It also helps him in exercising the various features of SSM framework.\n"</span>); |
|
229 <a name="l00257"></a>00257 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtSSM, <span class="stringliteral">"Exercise the features of System State Manager\n"</span>); |
|
230 <a name="l00258"></a>00258 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtConnect,<span class="stringliteral">"Connecting to System State Manager.........\n"</span>); |
|
231 <a name="l00259"></a>00259 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtSuccess,<span class="stringliteral">"Connection is successful.........\n"</span>); |
|
232 <a name="l00260"></a>00260 |
|
233 <a name="l00261"></a>00261 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtReqChangeInSwp,<span class="stringliteral">"1) request a change to a Swp, without notification\n"</span>); |
|
234 <a name="l00262"></a>00262 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtReqChangeInSs,<span class="stringliteral">"2) request a change to a system state, without notification\n"</span>); |
|
235 <a name="l00263"></a>00263 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtNotifyChangeInSwp,<span class="stringliteral">"3) request a change to a Swp, with notification\n"</span>); |
|
236 <a name="l00264"></a>00264 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtNotifyChangeInSs,<span class="stringliteral">"4) request a change to a system state, with notification\n"</span>); |
|
237 <a name="l00265"></a>00265 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtOptionNotSupported,<span class="stringliteral">"this option is not supported\n"</span>); |
|
238 <a name="l00266"></a>00266 |
|
239 <a name="l00267"></a>00267 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtPressESC,<span class="stringliteral">"Press ESC to stop using the System State Information utility\n"</span>); |
|
240 <a name="l00268"></a>00268 <a class="code" href="secureclientandserver_8h.html#a5eadd4429627d82193b37536d4faa03a">_LIT</a>(KTxtContinue,<span class="stringliteral">"Choose any option 1 - 4 to continue\n"</span>); |
|
241 <a name="l00269"></a>00269 |
|
242 <a name="l00270"></a>00270 iConsole= Console::NewL(KTxtExampleCode,TSize(KConsFullScreen,KConsFullScreen)); |
|
243 <a name="l00271"></a>00271 iConsole->Printf(KTxtFormat); |
|
244 <a name="l00272"></a>00272 iConsole->Printf(KTxtSwp); |
|
245 <a name="l00273"></a>00273 iConsole->Printf(KTxtSs); |
|
246 <a name="l00274"></a>00274 iConsole->Printf(KTxtExampleDemo); |
|
247 <a name="l00275"></a>00275 iConsole->Printf(KTxtFormat); |
|
248 <a name="l00276"></a>00276 iConsole->Printf(KTxtSSM); |
|
249 <a name="l00277"></a>00277 iConsole->Printf(KTxtConnect); |
|
250 <a name="l00278"></a>00278 iConsole->Printf(KTxtFormat1); |
|
251 <a name="l00279"></a>00279 TInt connect = iSsmStateManager.Connect(); |
|
252 <a name="l00280"></a>00280 <span class="keywordflow">if</span>(connect==KErrNone) |
|
253 <a name="l00281"></a>00281 { |
|
254 <a name="l00282"></a>00282 iConsole->Printf(KTxtSuccess); |
|
255 <a name="l00283"></a>00283 iConsole->Printf(KTxtFormat); |
|
256 <a name="l00284"></a>00284 iConsole->Printf(KTextPressAnyKey); |
|
257 <a name="l00285"></a>00285 iConsole->Getch(); <span class="comment">// Get and ignore character.</span> |
|
258 <a name="l00286"></a>00286 iConsole->ClearScreen(); |
|
259 <a name="l00287"></a>00287 iConsole->Printf(KTxtReqChangeInSwp); |
|
260 <a name="l00288"></a>00288 iConsole->Printf(KTxtReqChangeInSs); |
|
261 <a name="l00289"></a>00289 iConsole->Printf(KTxtNotifyChangeInSwp); |
|
262 <a name="l00290"></a>00290 iConsole->Printf(KTxtNotifyChangeInSs); |
|
263 <a name="l00291"></a>00291 iConsole->Printf(KTxtContinue); |
|
264 <a name="l00292"></a>00292 TChar tchar = iConsole->Getch(); |
|
265 <a name="l00293"></a>00293 <span class="comment">//make a choice</span> |
|
266 <a name="l00294"></a>00294 <span class="keywordflow">while</span> (tchar != EKeyEscape) |
|
267 <a name="l00295"></a>00295 { |
|
268 <a name="l00296"></a>00296 <span class="keywordflow">switch</span>(tchar) |
|
269 <a name="l00297"></a>00297 { |
|
270 <a name="l00298"></a>00298 <span class="keywordflow">case</span> <span class="charliteral">'1'</span>: |
|
271 <a name="l00299"></a>00299 { |
|
272 <a name="l00300"></a>00300 <a class="code" href="class_c_sys_state_manager_example.html#a1c585579a816b7e0f8393267a7a7a97a">RequestSwpChange</a>(); |
|
273 <a name="l00301"></a>00301 <span class="keywordflow">break</span>; |
|
274 <a name="l00302"></a>00302 } |
|
275 <a name="l00303"></a>00303 <span class="keywordflow">case</span> <span class="charliteral">'2'</span>: |
|
276 <a name="l00304"></a>00304 { |
|
277 <a name="l00305"></a>00305 <a class="code" href="class_c_sys_state_manager_example.html#a6b5511414b63e07e00fbff5af8808cad">RequestSsChange</a>(); |
|
278 <a name="l00306"></a>00306 <span class="keywordflow">break</span>; |
|
279 <a name="l00307"></a>00307 } |
|
280 <a name="l00308"></a>00308 <span class="keywordflow">case</span> <span class="charliteral">'3'</span>: |
|
281 <a name="l00309"></a>00309 { |
|
282 <a name="l00310"></a>00310 <a class="code" href="class_c_sys_state_manager_example.html#a7c3ee7dd5826eb98097e2c2ef43ed980">RequestSwpChangeWithNotificationL</a>(); |
|
283 <a name="l00311"></a>00311 <span class="keywordflow">break</span>; |
|
284 <a name="l00312"></a>00312 } |
|
285 <a name="l00313"></a>00313 <span class="keywordflow">case</span> <span class="charliteral">'4'</span>: |
|
286 <a name="l00314"></a>00314 { |
|
287 <a name="l00315"></a>00315 <a class="code" href="class_c_sys_state_manager_example.html#a3e70c77631e8cd6092de93f51cab49ad">RequestSsChangeWithNotification</a>(); |
|
288 <a name="l00316"></a>00316 <span class="keywordflow">break</span>; |
|
289 <a name="l00317"></a>00317 } |
|
290 <a name="l00318"></a>00318 <span class="keywordflow">default</span>: |
|
291 <a name="l00319"></a>00319 { |
|
292 <a name="l00320"></a>00320 iConsole->Printf(KTxtOptionNotSupported); |
|
293 <a name="l00321"></a>00321 <span class="keywordflow">break</span>; |
|
294 <a name="l00322"></a>00322 } |
|
295 <a name="l00323"></a>00323 } |
|
296 <a name="l00324"></a>00324 iConsole->Printf(KTextPressAnyKey); |
|
297 <a name="l00325"></a>00325 iConsole->Getch(); <span class="comment">// Get and ignore character.</span> |
|
298 <a name="l00326"></a>00326 iConsole->ClearScreen(); |
|
299 <a name="l00327"></a>00327 iConsole->Printf(KTxtPressESC); |
|
300 <a name="l00328"></a>00328 iConsole->Printf(KTxtContinue); |
|
301 <a name="l00329"></a>00329 iConsole->Printf(KTxtReqChangeInSwp); |
|
302 <a name="l00330"></a>00330 iConsole->Printf(KTxtReqChangeInSs); |
|
303 <a name="l00331"></a>00331 iConsole->Printf(KTxtNotifyChangeInSwp); |
|
304 <a name="l00332"></a>00332 iConsole->Printf(KTxtNotifyChangeInSs); |
|
305 <a name="l00333"></a>00333 tchar = iConsole->Getch(); |
|
306 <a name="l00334"></a>00334 } |
|
307 <a name="l00335"></a>00335 } |
|
308 <a name="l00336"></a>00336 <span class="keywordflow">else</span> |
|
309 <a name="l00337"></a>00337 { |
|
310 <a name="l00338"></a>00338 iConsole->Printf(KTxtError,connect); |
|
311 <a name="l00339"></a>00339 } |
|
312 <a name="l00340"></a>00340 iConsole->Printf(KTextPressAnyKeyToExit); |
|
313 <a name="l00341"></a>00341 iConsole->Getch(); <span class="comment">// Get and ignore character.</span> |
|
314 <a name="l00342"></a>00342 } |
|
315 <a name="l00343"></a>00343 |
|
316 <a name="l00344"></a>00344 <span class="keyword">static</span> <span class="keywordtype">void</span> doExampleL() |
|
317 <a name="l00345"></a>00345 { |
|
318 <a name="l00346"></a>00346 <a class="code" href="class_c_sys_state_manager_example.html">CSysStateManagerExample</a>* ssManager = CSysStateManagerExample::NewLC(); |
|
319 <a name="l00347"></a>00347 ssManager->SSManagerL(); |
|
320 <a name="l00348"></a>00348 CleanupStack::PopAndDestroy(ssManager); |
|
321 <a name="l00349"></a>00349 } |
|
322 <a name="l00350"></a>00350 |
|
323 <a name="l00351"></a>00351 <span class="keyword">extern</span> TInt E32Main() |
|
324 <a name="l00352"></a>00352 { |
|
325 <a name="l00353"></a>00353 __UHEAP_MARK; |
|
326 <a name="l00354"></a>00354 CTrapCleanup* cleanup=CTrapCleanup::New(); <span class="comment">// Get clean-up stack.</span> |
|
327 <a name="l00355"></a>00355 <span class="keywordflow">if</span>(cleanup!=NULL) |
|
328 <a name="l00356"></a>00356 { |
|
329 <a name="l00357"></a>00357 TRAPD (error,doExampleL()); |
|
330 <a name="l00358"></a>00358 __ASSERT_ALWAYS(!error,User::Panic(KTxtExampleCode,error)); |
|
331 <a name="l00359"></a>00359 } |
|
332 <a name="l00360"></a>00360 <span class="keyword">delete</span> cleanup; <span class="comment">// Delete clean-up stack.</span> |
|
333 <a name="l00361"></a>00361 __UHEAP_MARKEND; |
|
334 <a name="l00362"></a>00362 <span class="keywordflow">return</span> KErrNone; <span class="comment">// And return.</span> |
|
335 <a name="l00363"></a>00363 } |
|
336 </pre></div></div> |
|
337 <hr size="1"/><address style="text-align: right;"><small>Generated by |
|
338 <a href="http://www.doxygen.org/index.html"> |
|
339 <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2 </small></address> |
|
340 </body> |
|
341 </html> |