|
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 #include <e32property.h> |
|
19 |
|
20 #include "cmdpublishswp.h" |
|
21 #include "ssmdebug.h" |
|
22 #include "ssmpanic.h" |
|
23 #include "ssmcommandparameters.h" |
|
24 |
|
25 /** |
|
26 Used to create an instance of CCmdPublishSwp class from a read stream. |
|
27 CSsmCommandList::InternalizeL() uses this method to construct a command from stream. |
|
28 |
|
29 @param aReadStream Read stream containing data through which object can be created |
|
30 @return A pointer to an object of type CCmdPublishSwp. |
|
31 */ |
|
32 CCmdPublishSwp* CCmdPublishSwp::NewL(RReadStream& aReadStream) |
|
33 { |
|
34 CCmdPublishSwp* self = new (ELeave) CCmdPublishSwp(); |
|
35 CleanupStack::PushL(self); |
|
36 self->ConstructL(aReadStream); |
|
37 CleanupStack::Pop(self); |
|
38 return self; |
|
39 } |
|
40 |
|
41 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
42 /** |
|
43 Used to create an instance of CCmdPublishSwp class from given parameters. |
|
44 This method is used by SsmCommandFactory to create a command. |
|
45 |
|
46 @param aSeverity The severity 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 CCmdPublishSwp |
|
50 */ |
|
51 CCmdPublishSwp* CCmdPublishSwp::NewL(TCmdErrorSeverity aSeverity, TSsmExecutionBehaviour aExecutionBehaviour, const TSsmSwp& aSwpInfo, const TUint16 aPriority) |
|
52 { |
|
53 CCmdPublishSwp* self = new (ELeave) CCmdPublishSwp(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 CCmdPublishSwp 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 aSwpInfo System wide property settings |
|
67 @return A pointer to an object of type CCmdPublishSwp |
|
68 */ |
|
69 CCmdPublishSwp* CCmdPublishSwp::NewL(TCmdErrorSeverity aSeverity, TSsmExecutionBehaviour aExecutionBehaviour, const TSsmSwp& aSwpInfo) |
|
70 { |
|
71 CCmdPublishSwp* self = new (ELeave) CCmdPublishSwp(aSeverity, aExecutionBehaviour, aSwpInfo); |
|
72 CleanupStack::PushL(self); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop(self); |
|
75 return self; |
|
76 |
|
77 } |
|
78 |
|
79 /** |
|
80 Used to create an instance of CCmdPublishSwp class from resource. |
|
81 |
|
82 @param aCommandParameters Object data from a resource file |
|
83 @return A pointer to an object of type CCmdPublishSwp. |
|
84 */ |
|
85 CCmdPublishSwp* CCmdPublishSwp::NewL(TSsmCommandParameters& aCommandParameters) |
|
86 { |
|
87 CCmdPublishSwp* self = new (ELeave) CCmdPublishSwp(); |
|
88 CleanupStack::PushL(self); |
|
89 self->ConstructL(aCommandParameters); |
|
90 CleanupStack::Pop(self); |
|
91 return self; |
|
92 } |
|
93 /** |
|
94 Used to create an instance of CCmdPublishSwp class from CCmdPublishSwp object |
|
95 Must be used only by CLE |
|
96 @param aCmdPublishSwp CCmdPublishSwp reference |
|
97 @return A pointer to an object of type CCmdPublishSwp. |
|
98 */ |
|
99 CCmdPublishSwp* CCmdPublishSwp::NewLC(const CCmdPublishSwp& aCmdPublishSwp) |
|
100 { |
|
101 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
102 CCmdPublishSwp* self = new (ELeave) CCmdPublishSwp(aCmdPublishSwp.Severity(),aCmdPublishSwp.ExecutionBehaviour(), |
|
103 aCmdPublishSwp.SsmSwpInfo(),aCmdPublishSwp.Priority()); |
|
104 #else |
|
105 CCmdPublishSwp* self = new (ELeave) CCmdPublishSwp(aCmdPublishSwp.Severity(),aCmdPublishSwp.ExecutionBehaviour(), |
|
106 aCmdPublishSwp.SsmSwpInfo()); |
|
107 #endif |
|
108 CleanupStack::PushL(self); |
|
109 self->ConstructL(aCmdPublishSwp); |
|
110 return self; |
|
111 } |
|
112 |
|
113 void CCmdPublishSwp::ConstructL(const CCmdPublishSwp& aCmdPublishSwp) |
|
114 { |
|
115 iConditionalResourceId = aCmdPublishSwp.ConditionalInformation(); |
|
116 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
117 if (iConditionalResourceId != 0) |
|
118 { |
|
119 SetCommandResourceFileNameL(aCmdPublishSwp.GetCommandResourceFileName()); |
|
120 } |
|
121 #endif |
|
122 } |
|
123 |
|
124 /** |
|
125 Destructor |
|
126 */ |
|
127 CCmdPublishSwp::~CCmdPublishSwp() |
|
128 { |
|
129 Cancel(); |
|
130 } |
|
131 |
|
132 /** |
|
133 Initialises the BIC's active object and initiates the command |
|
134 |
|
135 @param aStatus the TRequestStatus of the active object calling this BIC |
|
136 */ |
|
137 void CCmdPublishSwp::Execute(TRequestStatus& aStatus) |
|
138 { |
|
139 aStatus = KRequestPending; |
|
140 iExecuteRequest = &aStatus; |
|
141 |
|
142 if (iExecutionBehaviour != ESsmWaitForSignal) |
|
143 { |
|
144 // complete the command request and initiate execution of next command |
|
145 CompleteExecuteRequest(KErrNone); |
|
146 } |
|
147 |
|
148 CompleteRequest(iStatus, KErrNone); |
|
149 SetActive(); |
|
150 } |
|
151 |
|
152 /** |
|
153 Releases resources associated with this BIC |
|
154 */ |
|
155 void CCmdPublishSwp::Release() |
|
156 { |
|
157 delete this; |
|
158 } |
|
159 |
|
160 /** |
|
161 Initiates a Cancel on the object. |
|
162 */ |
|
163 void CCmdPublishSwp::ExecuteCancel() |
|
164 { |
|
165 //cancel the outstanding request |
|
166 Cancel(); |
|
167 //and complete the request with KErrCancel |
|
168 CompleteDeferredExecuteRequest(KErrCancel); |
|
169 } |
|
170 |
|
171 /** |
|
172 Returns the Type of the BIC |
|
173 |
|
174 @return The Type of the BIC |
|
175 */ |
|
176 TSsmCommandType CCmdPublishSwp::Type() const |
|
177 { |
|
178 return (ESsmCmdPublishSwp); |
|
179 } |
|
180 |
|
181 /** |
|
182 Returns the Version of the BIC |
|
183 |
|
184 @return The maximum supported version of the BIC |
|
185 */ |
|
186 TInt CCmdPublishSwp::MaxSupportedVersion() |
|
187 { |
|
188 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
189 return (static_cast<TInt>(ECmdPublishSwpVersionWithPriority)); |
|
190 #else |
|
191 return (static_cast<TInt>(ECmdPublishSwpInitialVersion)); |
|
192 #endif |
|
193 } |
|
194 |
|
195 /** |
|
196 Configures the BIC using data contained in a ReadStream |
|
197 |
|
198 @param aReadStream A read stream containing BIC data |
|
199 */ |
|
200 void CCmdPublishSwp::InternalizeL(RReadStream& aReadStream) |
|
201 { |
|
202 iSeverity = static_cast<TCmdErrorSeverity>(aReadStream.ReadInt16L()); |
|
203 iExecutionBehaviour = static_cast<TSsmExecutionBehaviour>(aReadStream.ReadUint8L()); |
|
204 const TUint key = aReadStream.ReadUint32L(); |
|
205 const TInt value = aReadStream.ReadInt32L(); |
|
206 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
207 iPriority = aReadStream.ReadUint16L(); |
|
208 #endif |
|
209 TSsmSwp swpInfo(key, value); |
|
210 iSwpInfo = swpInfo; |
|
211 } |
|
212 |
|
213 /** |
|
214 Externalises the configuration of the BIC |
|
215 |
|
216 @param aWriteStream A write stream to write BIC data to |
|
217 */ |
|
218 void CCmdPublishSwp::ExternalizeL(RWriteStream& aWriteStream) const |
|
219 { |
|
220 aWriteStream.WriteInt16L(iSeverity); |
|
221 aWriteStream.WriteUint8L(iExecutionBehaviour); |
|
222 aWriteStream.WriteUint32L(iSwpInfo.Key()); |
|
223 aWriteStream.WriteInt32L(iSwpInfo.Value()); |
|
224 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
225 aWriteStream.WriteUint16L(iPriority); |
|
226 #endif |
|
227 } |
|
228 |
|
229 /** |
|
230 Completes the tasks of the BIC |
|
231 */ |
|
232 void CCmdPublishSwp::RunL() |
|
233 { |
|
234 TInt err = RProperty::Set(RProcess().SecureId(), iSwpInfo.Key(), iSwpInfo.Value()); |
|
235 DEBUGPRINT4A("SWP %d set with value %d with error %d", iSwpInfo.Key(), iSwpInfo.Value(), err); |
|
236 CompleteDeferredExecuteRequest(err); |
|
237 } |
|
238 |
|
239 /** |
|
240 Called to handle any cleanup if RunL leaves |
|
241 |
|
242 @param aError The error to finish with |
|
243 @return KErrNone |
|
244 */ |
|
245 TInt CCmdPublishSwp::RunError(TInt aError) |
|
246 { |
|
247 CompleteDeferredExecuteRequest(aError); |
|
248 return KErrNone; |
|
249 } |
|
250 |
|
251 /** |
|
252 Called during cancellation of the active BIC |
|
253 */ |
|
254 void CCmdPublishSwp::DoCancel() |
|
255 { |
|
256 } |
|
257 |
|
258 /** |
|
259 default constructor. |
|
260 */ |
|
261 CCmdPublishSwp::CCmdPublishSwp() |
|
262 : iSwpInfo(0,0) |
|
263 { |
|
264 } |
|
265 |
|
266 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
267 /** |
|
268 Overloaded constructor. |
|
269 @param aSeverity The severity of the command |
|
270 @param aSwpInfo System wide property settings |
|
271 @param aPriority The priority of the command in the list |
|
272 */ |
|
273 CCmdPublishSwp::CCmdPublishSwp(TCmdErrorSeverity aSeverity, TSsmExecutionBehaviour aExecutionBehaviour, const TSsmSwp& aSwpInfo, const TUint16 aPriority) |
|
274 : CSsmDeferrableCommand(aSeverity, aExecutionBehaviour, aPriority), iSwpInfo(aSwpInfo) |
|
275 { |
|
276 } |
|
277 #endif |
|
278 |
|
279 /** |
|
280 Overloaded constructor. |
|
281 @param aSeverity The severity of the command |
|
282 @param aSwpInfo System wide property settings |
|
283 */ |
|
284 CCmdPublishSwp::CCmdPublishSwp(TCmdErrorSeverity aSeverity, TSsmExecutionBehaviour aExecutionBehaviour, const TSsmSwp& aSwpInfo) |
|
285 : CSsmDeferrableCommand(aSeverity, aExecutionBehaviour), iSwpInfo(aSwpInfo) |
|
286 { |
|
287 } |
|
288 |
|
289 /** |
|
290 Constructs an object from resource file. |
|
291 @param aCommandParameters Object data from a resource file |
|
292 */ |
|
293 void CCmdPublishSwp::ConstructL(TSsmCommandParameters& aCommandParameters) |
|
294 { |
|
295 RResourceReader& reader = aCommandParameters.MainReader(); |
|
296 const TSsmCommandType type = static_cast<TSsmCommandType>(reader.ReadInt16L()); |
|
297 SSMLOGLEAVEIFFALSE(type == Type(), KErrNotSupported); |
|
298 const TInt version = reader.ReadInt16L(); |
|
299 SSMLOGLEAVEIFFALSE(__COMPARE_VERSION(version, CCmdPublishSwp::MaxSupportedVersion()), KErrNotSupported); |
|
300 iSeverity = static_cast<TCmdErrorSeverity>(reader.ReadInt16L()); |
|
301 iExecutionBehaviour = static_cast<TSsmExecutionBehaviour>(reader.ReadUint8L()); |
|
302 iSwpInfo = aCommandParameters.SwpL(); |
|
303 #ifdef SYMBIAN_SSM_FLEXIBLE_MERGE |
|
304 iPriority = (version > ECmdPublishSwpInitialVersion) ? reader.ReadUint16L() : KDefaultCommandPriority; |
|
305 #endif |
|
306 ValidateL(); |
|
307 } |
|
308 |
|
309 /** |
|
310 Constructs the object through read stream. |
|
311 @param aReadStream A read stream containing BIC data |
|
312 */ |
|
313 void CCmdPublishSwp::ConstructL(RReadStream& aReadStream) |
|
314 { |
|
315 InternalizeL(aReadStream); |
|
316 ValidateL(); |
|
317 } |
|
318 |
|
319 /** |
|
320 validates the data |
|
321 */ |
|
322 void CCmdPublishSwp::ConstructL() |
|
323 { |
|
324 ValidateL(); |
|
325 } |
|
326 |
|
327 |