|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <s32strm.h> |
|
17 #include <barsread2.h> |
|
18 |
|
19 #include "cmdreqswpchange.h" |
|
20 #include "ssmdebug.h" |
|
21 #include "ssmpanic.h" |
|
22 #include "ssmcommandparameters.h" |
|
23 |
|
24 /** |
|
25 Used to create an instance of CCmdReqSwpChange class from a read stream. |
|
26 CSsmCommandList::InternalizeL() uses this method to construct a command from stream. |
|
27 |
|
28 @param aReadStream Read stream containing data through which object can be created |
|
29 @return A pointer to an object of type CCmdReqSwpChange. |
|
30 */ |
|
31 CCmdReqSwpChange* CCmdReqSwpChange::NewL(RReadStream& aReadStream) |
|
32 { |
|
33 CCmdReqSwpChange* self = new (ELeave) CCmdReqSwpChange(); |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(aReadStream); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
41 /** |
|
42 Used to create an instance of CCmdReqSwpChange class from given parameters. |
|
43 This method is used by SsmCommandFactory to create a command. |
|
44 |
|
45 @param aSeverity The severity of the command |
|
46 @param aExecutionBehaviour The execution behaviour of the command |
|
47 @param aSwpInfo System wide property settings |
|
48 @param aPriority The priority of the command in the list |
|
49 @return A pointer to an object of type CCmdReqSwpChange. |
|
50 */ |
|
51 CCmdReqSwpChange* CCmdReqSwpChange::NewL(TCmdErrorSeverity aSeverity, TSsmExecutionBehaviour aExecutionBehaviour, const TSsmSwp& aSwpInfo, const TUint16 aPriority) |
|
52 { |
|
53 CCmdReqSwpChange* self = new (ELeave) CCmdReqSwpChange(aSeverity, aExecutionBehaviour, aSwpInfo, aPriority); |
|
54 CleanupStack::PushL(self); |
|
55 self->ConstructL(); |
|
56 CleanupStack::Pop(self); |
|
57 return self; |
|
58 } |
|
59 #endif |
|
60 |
|
61 /** |
|
62 Used to create an instance of CCmdReqSwpChange class from given parameters. |
|
63 This method is used by SsmCommandFactory to create a command. |
|
64 |
|
65 @param aSeverity The severity of the command |
|
66 @param aExecutionBehaviour The execution behaviour of the command |
|
67 @param aSwpInfo System wide property settings |
|
68 @return A pointer to an object of type CCmdReqSwpChange. |
|
69 */ |
|
70 CCmdReqSwpChange* CCmdReqSwpChange::NewL(TCmdErrorSeverity aSeverity, TSsmExecutionBehaviour aExecutionBehaviour, const TSsmSwp& aSwpInfo) |
|
71 { |
|
72 CCmdReqSwpChange* self = new (ELeave) CCmdReqSwpChange(aSeverity, aExecutionBehaviour, aSwpInfo); |
|
73 CleanupStack::PushL(self); |
|
74 self->ConstructL(); |
|
75 CleanupStack::Pop(self); |
|
76 return self; |
|
77 } |
|
78 |
|
79 /** |
|
80 Used to create an instance of CCmdReqSwpChange class from resource. |
|
81 |
|
82 @param aCommandParameters Object data from a resource file |
|
83 @return A pointer to an object of type CCmdReqSwpChange. |
|
84 */ |
|
85 CCmdReqSwpChange* CCmdReqSwpChange::NewL(TSsmCommandParameters& aCommandParameters) |
|
86 { |
|
87 CCmdReqSwpChange* self = new (ELeave) CCmdReqSwpChange(); |
|
88 CleanupStack::PushL(self); |
|
89 self->ConstructL(aCommandParameters); |
|
90 CleanupStack::Pop(self); |
|
91 return self; |
|
92 } |
|
93 |
|
94 /** |
|
95 Used to create an instance of CCmdReqSwpChange class from CCmdReqSwpChange object |
|
96 Must be used only by CLE |
|
97 @param aCmdReqSwpChange CCmdReqSwpChange reference |
|
98 @return A pointer to an object of type CCmdReqSwpChange. |
|
99 */ |
|
100 CCmdReqSwpChange* CCmdReqSwpChange::NewLC(const CCmdReqSwpChange& aCmdReqSwpChange) |
|
101 { |
|
102 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
103 CCmdReqSwpChange* self = new (ELeave) CCmdReqSwpChange(aCmdReqSwpChange.Severity(),aCmdReqSwpChange.ExecutionBehaviour(), |
|
104 aCmdReqSwpChange.SsmSwpInfo(),aCmdReqSwpChange.Priority()); |
|
105 #else |
|
106 CCmdReqSwpChange* self = new (ELeave) CCmdReqSwpChange(aCmdReqSwpChange.Severity(),aCmdReqSwpChange.ExecutionBehaviour(), |
|
107 aCmdReqSwpChange.SsmSwpInfo()); |
|
108 #endif |
|
109 CleanupStack::PushL(self); |
|
110 self->ConstructL(aCmdReqSwpChange); |
|
111 return self; |
|
112 } |
|
113 |
|
114 void CCmdReqSwpChange::ConstructL(const CCmdReqSwpChange& aCmdReqSwpChange) |
|
115 { |
|
116 iConditionalResourceId = aCmdReqSwpChange.ConditionalInformation(); |
|
117 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
118 if (iConditionalResourceId != 0) |
|
119 { |
|
120 SetCommandResourceFileNameL(aCmdReqSwpChange.GetCommandResourceFileName()); |
|
121 } |
|
122 #endif |
|
123 } |
|
124 |
|
125 /** |
|
126 Destructor |
|
127 */ |
|
128 CCmdReqSwpChange::~CCmdReqSwpChange() |
|
129 { |
|
130 Cancel(); |
|
131 iSsmStateManager.Close(); |
|
132 } |
|
133 |
|
134 /** |
|
135 Initialises the BIC's active object and initiates the command |
|
136 |
|
137 @param aStatus the TRequestStatus of the active object calling this BIC |
|
138 */ |
|
139 void CCmdReqSwpChange::Execute( TRequestStatus& aStatus ) |
|
140 { |
|
141 aStatus = KRequestPending; |
|
142 iExecuteRequest = &aStatus; |
|
143 |
|
144 TInt err = iSsmStateManager.Connect(); |
|
145 if(err == KErrNone) |
|
146 { |
|
147 iSsmStateManager.RequestSwpChange(iSwpInfo, iStatus); |
|
148 } |
|
149 else |
|
150 { |
|
151 // pass the error connecting to RunL |
|
152 iStatus = KRequestPending; |
|
153 TRequestStatus* statusPtr = &iStatus; |
|
154 User::RequestComplete(statusPtr, err); |
|
155 } |
|
156 |
|
157 if (iExecutionBehaviour != ESsmWaitForSignal) |
|
158 { |
|
159 // complete the command request and initiate execution of next command |
|
160 CompleteExecuteRequest(KErrNone); |
|
161 } |
|
162 SetActive(); |
|
163 } |
|
164 |
|
165 /** |
|
166 Releases resources associated with this BIC |
|
167 */ |
|
168 void CCmdReqSwpChange::Release() |
|
169 { |
|
170 delete this; |
|
171 } |
|
172 |
|
173 /** |
|
174 Initiates a Cancel on the object. |
|
175 */ |
|
176 void CCmdReqSwpChange::ExecuteCancel() |
|
177 { |
|
178 //cancel the outstanding request |
|
179 Cancel(); |
|
180 //and complete the request with KErrCancel |
|
181 CompleteDeferredExecuteRequest(KErrCancel); |
|
182 } |
|
183 |
|
184 /** |
|
185 Returns the Type of the BIC |
|
186 @return The Type of the BIC |
|
187 */ |
|
188 TSsmCommandType CCmdReqSwpChange::Type() const |
|
189 { |
|
190 return (ESsmCmdReqSwProperty); |
|
191 } |
|
192 |
|
193 /** |
|
194 Returns the Version of the BIC |
|
195 @return The maximum supported version of the BIC |
|
196 */ |
|
197 TInt CCmdReqSwpChange::MaxSupportedVersion() |
|
198 { |
|
199 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
200 return (static_cast<TInt>(ECmdReqSwPropertyVersionWithPriority)); |
|
201 #else |
|
202 return (static_cast<TInt>(ECmdReqSwPropertyInitialVersion)); |
|
203 #endif |
|
204 } |
|
205 |
|
206 /** |
|
207 Configures the BIC using data contained in a ReadStream |
|
208 @param aReadStream A read stream containing BIC data |
|
209 */ |
|
210 void CCmdReqSwpChange::InternalizeL(RReadStream& aReadStream) |
|
211 { |
|
212 iSeverity = static_cast<TCmdErrorSeverity>(aReadStream.ReadInt16L()); |
|
213 iExecutionBehaviour = static_cast<TSsmExecutionBehaviour>(aReadStream.ReadUint8L()); |
|
214 const TUint key = aReadStream.ReadUint32L(); |
|
215 const TInt value = aReadStream.ReadInt32L(); |
|
216 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
217 iPriority = aReadStream.ReadUint16L(); |
|
218 #endif |
|
219 TSsmSwp swpinfo(key, value); |
|
220 |
|
221 iSwpInfo = swpinfo; |
|
222 } |
|
223 |
|
224 /** |
|
225 Externalises the configuration of the BIC |
|
226 @param aWriteStream A write stream to write BIC data to |
|
227 */ |
|
228 void CCmdReqSwpChange::ExternalizeL(RWriteStream& aWriteStream) const |
|
229 { |
|
230 aWriteStream.WriteInt16L(iSeverity); |
|
231 aWriteStream.WriteUint8L(iExecutionBehaviour); |
|
232 aWriteStream.WriteUint32L(iSwpInfo.Key()); |
|
233 aWriteStream.WriteInt32L(iSwpInfo.Value()); |
|
234 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
235 aWriteStream.WriteUint16L(iPriority); |
|
236 #endif |
|
237 } |
|
238 |
|
239 /** |
|
240 Completes the tasks of the BIC |
|
241 */ |
|
242 void CCmdReqSwpChange::RunL() |
|
243 { |
|
244 CompleteDeferredExecuteRequest(iStatus.Int()); |
|
245 } |
|
246 |
|
247 /** |
|
248 Called during cancellation of the active BIC |
|
249 */ |
|
250 void CCmdReqSwpChange::DoCancel() |
|
251 { |
|
252 iSsmStateManager.RequestSwpChangeCancel(); |
|
253 } |
|
254 |
|
255 /** |
|
256 default constructor. |
|
257 */ |
|
258 CCmdReqSwpChange::CCmdReqSwpChange() |
|
259 : iSwpInfo(0,0) |
|
260 { |
|
261 } |
|
262 |
|
263 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
264 /** |
|
265 Overloaded constructor. |
|
266 @param aSeverity The severity of the command |
|
267 @param aExecutionBehaviour The execution behaviour of the command |
|
268 @param aSwpInfo System wide property settings |
|
269 @param aPriority The priority of the command in the list |
|
270 */ |
|
271 CCmdReqSwpChange::CCmdReqSwpChange(TCmdErrorSeverity aSeverity, TSsmExecutionBehaviour aExecutionBehaviour, TSsmSwp aSwpInfo, const TUint16 aPriority) |
|
272 : CSsmDeferrableCommand(aSeverity, aExecutionBehaviour, aPriority), iSwpInfo(aSwpInfo) |
|
273 { |
|
274 } |
|
275 #endif |
|
276 |
|
277 /** |
|
278 Overloaded constructor. |
|
279 @param aSeverity The severity of the command |
|
280 @param aExecutionBehaviour The execution behaviour of the command |
|
281 @param aSwpInfo System wide property settings |
|
282 */ |
|
283 CCmdReqSwpChange::CCmdReqSwpChange(TCmdErrorSeverity aSeverity, TSsmExecutionBehaviour aExecutionBehaviour, TSsmSwp aSwpInfo) |
|
284 : CSsmDeferrableCommand(aSeverity, aExecutionBehaviour), iSwpInfo(aSwpInfo) |
|
285 { |
|
286 |
|
287 } |
|
288 |
|
289 /** |
|
290 Connect to RSsmStateManager and validate the commands data. |
|
291 */ |
|
292 void CCmdReqSwpChange::ConstructL() |
|
293 { |
|
294 ValidateL(); |
|
295 } |
|
296 |
|
297 /** |
|
298 Constructs the object through read stream. |
|
299 @param aReadStream A read stream containing BIC data |
|
300 */ |
|
301 void CCmdReqSwpChange::ConstructL(RReadStream& aReadStream) |
|
302 { |
|
303 InternalizeL(aReadStream); |
|
304 ConstructL(); // connect to RSsmStateManager and validate the data |
|
305 } |
|
306 |
|
307 /** |
|
308 Constructs an object from resource file. |
|
309 @param aCommandParameters Object data from a resource file |
|
310 */ |
|
311 void CCmdReqSwpChange::ConstructL(TSsmCommandParameters& aCommandParameters) |
|
312 { |
|
313 RResourceReader& reader = aCommandParameters.MainReader(); |
|
314 const TSsmCommandType type = static_cast<TSsmCommandType>(reader.ReadInt16L()); |
|
315 SSMLOGLEAVEIFFALSE(type == Type(), KErrNotSupported); |
|
316 const TInt version = reader.ReadInt16L(); |
|
317 SSMLOGLEAVEIFFALSE(__COMPARE_VERSION(version, CCmdReqSwpChange::MaxSupportedVersion()), KErrNotSupported); |
|
318 iSeverity = static_cast<TCmdErrorSeverity>(reader.ReadInt16L()); |
|
319 iExecutionBehaviour = static_cast<TSsmExecutionBehaviour>(reader.ReadUint8L()); |
|
320 const TUint key = reader.ReadUint32L(); |
|
321 const TInt value = reader.ReadInt32L(); |
|
322 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
323 iPriority = (version > ECmdReqSwPropertyInitialVersion) ? reader.ReadUint16L() : KDefaultCommandPriority; |
|
324 #endif |
|
325 TSsmSwp swpInfo(key, value); |
|
326 iSwpInfo = swpInfo; |
|
327 |
|
328 ConstructL(); // connect to RSsmStateManager and validate the data |
|
329 } |
|
330 |