|
1 /* |
|
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <f32file.h> |
|
20 #include <usif/sif/sifcommon.h> |
|
21 #include <s32mem.h> |
|
22 #include <scs/cleanuputils.h> |
|
23 #include <scs/streamingarray.h> |
|
24 #include "sifcommon_internal.h" |
|
25 |
|
26 using namespace Usif; |
|
27 |
|
28 /** |
|
29 The COpaqueNamedParams and CComponentInfo containers implement the deferred internalization |
|
30 logic. This mechanism is necessary because these containers may be passed through IPC between |
|
31 the SIF client and server. Hence, they must be externalized and internalized on both sides. |
|
32 However, The SIF client doesn't implement an active object and therefore it cannot internalize |
|
33 parameters returned by the SIF server. This de-serialization is done by the deferred internalization |
|
34 logic when the user accesses them first time. |
|
35 Hence, all the get methods, for example Name(), GetIntByName(), StringByNameL(), call the |
|
36 InternalizeFromExternalBufferL() method which calls ConstInternalizeL() in order to unpack |
|
37 the data recived from the SIF server if there is any. ConstInternalizeL() is a const method despite |
|
38 the fact it modifies class'es members. This is done to keep the get methods const as expected by |
|
39 the users. |
|
40 */ |
|
41 |
|
42 // ########################################################################################## |
|
43 |
|
44 namespace |
|
45 { |
|
46 TInt PackCapabilitySet(const TCapabilitySet& aCapSet) |
|
47 { |
|
48 TInt caps=0; |
|
49 for (TInt c=0; c<ECapability_Limit; ++c) |
|
50 { |
|
51 if (aCapSet.HasCapability(TCapability(c))) |
|
52 { |
|
53 caps += (1<<c); |
|
54 } |
|
55 } |
|
56 return caps; |
|
57 } |
|
58 |
|
59 void UnpackCapabilitySet(TInt aPackedCapSet, TCapabilitySet& aCapSet) |
|
60 { |
|
61 for (TInt c=0; c<ECapability_Limit; ++c) |
|
62 { |
|
63 const TInt cap = 1<<c; |
|
64 if (aPackedCapSet&cap) |
|
65 { |
|
66 aCapSet.AddCapability(TCapability(c)); |
|
67 } |
|
68 } |
|
69 } |
|
70 } |
|
71 |
|
72 // ########################################################################################## |
|
73 |
|
74 EXPORT_C TSecurityContext::TSecurityContext(const RMessage2& aMessage): iMsg(aMessage) |
|
75 { |
|
76 } |
|
77 |
|
78 EXPORT_C TBool TSecurityContext::HasCapability(TCapability aCapability) const |
|
79 { |
|
80 return iMsg.HasCapability(aCapability); |
|
81 } |
|
82 |
|
83 EXPORT_C void TSecurityContext::HasCapabilityL(TCapability aCapability) const |
|
84 { |
|
85 iMsg.HasCapabilityL(aCapability); |
|
86 } |
|
87 |
|
88 EXPORT_C TSecureId TSecurityContext::SecureId() const |
|
89 { |
|
90 return iMsg.SecureId(); |
|
91 } |
|
92 |
|
93 // ########################################################################################## |
|
94 |
|
95 CComponentInfo::CApplicationInfo::CApplicationInfo() |
|
96 { |
|
97 } |
|
98 |
|
99 EXPORT_C CComponentInfo::CApplicationInfo::~CApplicationInfo() |
|
100 { |
|
101 delete iName; |
|
102 delete iGroupName; |
|
103 delete iIconFileName; |
|
104 } |
|
105 |
|
106 EXPORT_C CComponentInfo::CApplicationInfo* CComponentInfo::CApplicationInfo::NewLC(const TUid& aAppUid, const TDesC& aName, const TDesC& aGroupName, const TDesC& aIconFileName) |
|
107 { |
|
108 _LIT(emptyString,""); |
|
109 // Leave if aName, aGroupName or aIconFileName exceeds KMaxDescriptorLength |
|
110 if ((&aName != NULL && aName.Length() > KMaxDescriptorLength) || |
|
111 (&aGroupName != NULL && aGroupName.Length() > KMaxDescriptorLength) || |
|
112 (&aIconFileName != NULL && aIconFileName.Length() > KMaxDescriptorLength)) |
|
113 { |
|
114 User::Leave(KErrOverflow); |
|
115 } |
|
116 |
|
117 CComponentInfo::CApplicationInfo* self = new (ELeave) CComponentInfo::CApplicationInfo(); |
|
118 CleanupStack::PushL(self); |
|
119 |
|
120 self->iAppUid = aAppUid; |
|
121 if(&aName == NULL) |
|
122 { |
|
123 self->iName = emptyString().AllocL(); |
|
124 } |
|
125 else |
|
126 { |
|
127 self->iName = aName.AllocL(); |
|
128 } |
|
129 |
|
130 if(&aGroupName == NULL) |
|
131 { |
|
132 self->iGroupName = emptyString().AllocL(); |
|
133 } |
|
134 else |
|
135 { |
|
136 self->iGroupName = aGroupName.AllocL(); |
|
137 } |
|
138 |
|
139 if(&aIconFileName == NULL) |
|
140 { |
|
141 self->iIconFileName = emptyString().AllocL(); |
|
142 } |
|
143 else |
|
144 { |
|
145 self->iIconFileName = aIconFileName.AllocL(); |
|
146 } |
|
147 |
|
148 return self; |
|
149 } |
|
150 |
|
151 EXPORT_C const TUid& CComponentInfo::CApplicationInfo::AppUid() const |
|
152 { |
|
153 return iAppUid; |
|
154 } |
|
155 |
|
156 EXPORT_C const TDesC& CComponentInfo::CApplicationInfo::Name() const |
|
157 { |
|
158 return *iName; |
|
159 } |
|
160 |
|
161 EXPORT_C const TDesC& CComponentInfo::CApplicationInfo::GroupName() const |
|
162 { |
|
163 return *iGroupName; |
|
164 } |
|
165 |
|
166 EXPORT_C const TDesC& CComponentInfo::CApplicationInfo::IconFileName() const |
|
167 { |
|
168 return *iIconFileName; |
|
169 } |
|
170 |
|
171 CComponentInfo::CApplicationInfo* CComponentInfo::CApplicationInfo::NewL(RReadStream& aStream) |
|
172 { |
|
173 CApplicationInfo* self = new (ELeave) CApplicationInfo(); |
|
174 CleanupStack::PushL(self); |
|
175 |
|
176 self->iAppUid = TUid::Uid(aStream.ReadInt32L()); |
|
177 self->iName = HBufC::NewL(aStream, KMaxDescriptorLength); |
|
178 self->iGroupName = HBufC::NewL(aStream, KMaxDescriptorLength); |
|
179 self->iIconFileName = HBufC::NewL(aStream, KMaxDescriptorLength); |
|
180 |
|
181 CleanupStack::Pop(self); |
|
182 return self; |
|
183 } |
|
184 |
|
185 void CComponentInfo::CApplicationInfo::ExternalizeL(RWriteStream& aStream) const |
|
186 { |
|
187 aStream.WriteInt32L(iAppUid.iUid); |
|
188 aStream << *iName; |
|
189 aStream << *iGroupName; |
|
190 aStream << *iIconFileName; |
|
191 } |
|
192 |
|
193 // ########################################################################################## |
|
194 |
|
195 CComponentInfo::CNode::CNode() : iAuthenticity(ENotAuthenticated) |
|
196 { |
|
197 iUserGrantableCaps.SetEmpty(); |
|
198 } |
|
199 |
|
200 EXPORT_C CComponentInfo::CNode::~CNode() |
|
201 { |
|
202 delete iSoftwareTypeName; |
|
203 delete iComponentName; |
|
204 delete iGlobalComponentId; |
|
205 delete iVersion; |
|
206 delete iVendor; |
|
207 |
|
208 iApplications.Close(); |
|
209 iChildren.Close(); |
|
210 } |
|
211 |
|
212 EXPORT_C CComponentInfo::CNode* CComponentInfo::CNode::NewLC(const TDesC& aSoftwareTypeName, const TDesC& aComponentName, |
|
213 const TDesC& aVersion, const TDesC& aVendor, TScomoState aScomoState, |
|
214 TInstallStatus aInstallStatus, TComponentId aComponentId, |
|
215 const TDesC& aGlobalComponentId, TAuthenticity aAuthenticity, |
|
216 const TCapabilitySet& aUserGrantableCaps, TInt aMaxInstalledSize, |
|
217 TBool aHasExe, TBool aIsDriveSelectionRequired, |
|
218 RPointerArray<CApplicationInfo>* aApplications, RPointerArray<CNode>* aChildren) |
|
219 { |
|
220 // We leave if aSoftwareTypeName, aComponentName, aVersion, aVendor or aGlobalComponentId exceeds KMaxDescriptorLength |
|
221 if (aSoftwareTypeName.Length() > KMaxDescriptorLength || |
|
222 aComponentName.Length() > KMaxDescriptorLength || |
|
223 aVersion.Length() > KMaxDescriptorLength || |
|
224 aVendor.Length() > KMaxDescriptorLength || |
|
225 aGlobalComponentId.Length() > KMaxDescriptorLength) |
|
226 { |
|
227 User::Leave(KErrOverflow); |
|
228 } |
|
229 |
|
230 |
|
231 // Since the max heap buffer length is 2K, which is more than (num of parameters * KMaxDescriptorLength), we just assert this condition |
|
232 __ASSERT_ALWAYS(aSoftwareTypeName.Length() + aComponentName.Length() + aVersion.Length() + aVendor.Length() + |
|
233 aGlobalComponentId.Length() <= KMaxHeapBufLength, User::Leave(KErrOverflow)); |
|
234 |
|
235 // Create an instance of CNode |
|
236 CNode* self = new (ELeave) CNode(); |
|
237 CleanupStack::PushL(self); |
|
238 |
|
239 // Copy Software Type Name, Component Name, Version, aVendor, aGlobalComponentId |
|
240 self->iSoftwareTypeName = aSoftwareTypeName.AllocL(); |
|
241 self->iComponentName = aComponentName.AllocL(); |
|
242 self->iVersion = aVersion.AllocL(); |
|
243 self->iVendor = aVendor.AllocL(); |
|
244 self->iGlobalComponentId = aGlobalComponentId.AllocL(); |
|
245 |
|
246 // Others |
|
247 self->iScomoState = aScomoState; |
|
248 self->iInstallStatus = aInstallStatus; |
|
249 self->iComponentId = aComponentId; |
|
250 self->iAuthenticity = aAuthenticity; |
|
251 self->iUserGrantableCaps = aUserGrantableCaps; |
|
252 self->iMaxInstalledSize = aMaxInstalledSize; |
|
253 self->iHasExe = aHasExe; |
|
254 self->iIsDriveSelectionRequired = aIsDriveSelectionRequired; |
|
255 |
|
256 if(aApplications != NULL) |
|
257 { |
|
258 for (TInt i=aApplications->Count()-1; i>=0; --i) |
|
259 { |
|
260 self->iApplications.InsertL((*aApplications)[i], 0); |
|
261 aApplications->Remove(i); |
|
262 } |
|
263 } |
|
264 |
|
265 // Embedded Components |
|
266 if(aChildren != NULL) |
|
267 { |
|
268 for (TInt i=aChildren->Count()-1; i>=0; --i) |
|
269 { |
|
270 self->iChildren.InsertL((*aChildren)[i], 0); |
|
271 aChildren->Remove(i); |
|
272 } |
|
273 } |
|
274 |
|
275 return self; |
|
276 } |
|
277 |
|
278 EXPORT_C void CComponentInfo::CNode::AddChildL(CComponentInfo::CNode* aChild) |
|
279 { |
|
280 if (aChild == NULL) |
|
281 { |
|
282 User::Leave(KErrArgument); |
|
283 } |
|
284 |
|
285 iChildren.AppendL(aChild); |
|
286 } |
|
287 |
|
288 CComponentInfo::CNode* CComponentInfo::CNode::NewL(RReadStream& aStream) |
|
289 { |
|
290 // Create an instance of CNode |
|
291 CNode* self = new (ELeave) CNode(); |
|
292 CleanupStack::PushL(self); |
|
293 |
|
294 self->iSoftwareTypeName = HBufC::NewL(aStream, KMaxDescriptorLength); |
|
295 self->iComponentName = HBufC::NewL(aStream, KMaxDescriptorLength); |
|
296 self->iVersion = HBufC::NewL(aStream, KMaxDescriptorLength); |
|
297 self->iVendor = HBufC::NewL(aStream, KMaxDescriptorLength); |
|
298 self->iGlobalComponentId = HBufC::NewL(aStream, KMaxDescriptorLength); |
|
299 self->iScomoState = static_cast<TScomoState>(aStream.ReadInt32L()); |
|
300 self->iInstallStatus = static_cast<TInstallStatus>(aStream.ReadInt32L()); |
|
301 self->iComponentId = aStream.ReadInt32L(); |
|
302 self->iAuthenticity = static_cast<TAuthenticity>(aStream.ReadInt32L()); |
|
303 UnpackCapabilitySet(aStream.ReadInt32L(), self->iUserGrantableCaps); |
|
304 self->iMaxInstalledSize = aStream.ReadInt32L(); |
|
305 self->iHasExe = aStream.ReadInt32L(); |
|
306 self->iIsDriveSelectionRequired = aStream.ReadInt32L(); |
|
307 |
|
308 const TInt numApplications = aStream.ReadInt32L(); |
|
309 for (TInt i=0; i<numApplications; ++i) |
|
310 { |
|
311 CApplicationInfo* app = CApplicationInfo::NewL(aStream); |
|
312 CleanupStack::PushL(app); |
|
313 self->iApplications.AppendL(app); |
|
314 CleanupStack::Pop(app); |
|
315 } |
|
316 |
|
317 const TInt numChildren = aStream.ReadInt32L(); |
|
318 for (TInt i=0; i<numChildren; ++i) |
|
319 { |
|
320 CNode* node = CNode::NewL(aStream); |
|
321 CleanupStack::PushL(node); |
|
322 self->iChildren.AppendL(node); |
|
323 CleanupStack::Pop(node); |
|
324 } |
|
325 |
|
326 CleanupStack::Pop(self); |
|
327 return self; |
|
328 } |
|
329 |
|
330 void CComponentInfo::CNode::ExternalizeL(RWriteStream& aStream) const |
|
331 { |
|
332 ASSERT (iSoftwareTypeName!=NULL && iComponentName!=NULL && iVersion!=NULL && iVendor!=NULL && iGlobalComponentId!=NULL); |
|
333 |
|
334 aStream << *iSoftwareTypeName; |
|
335 aStream << *iComponentName; |
|
336 aStream << *iVersion; |
|
337 aStream << *iVendor; |
|
338 aStream << *iGlobalComponentId; |
|
339 |
|
340 aStream.WriteInt32L(iScomoState); |
|
341 aStream.WriteInt32L(iInstallStatus); |
|
342 aStream.WriteInt32L(iComponentId); |
|
343 aStream.WriteInt32L(static_cast<TInt>(iAuthenticity)); |
|
344 aStream.WriteInt32L(PackCapabilitySet(iUserGrantableCaps)); |
|
345 aStream.WriteInt32L(iMaxInstalledSize); |
|
346 aStream.WriteInt32L(iHasExe); |
|
347 aStream.WriteInt32L(iIsDriveSelectionRequired); |
|
348 |
|
349 const TInt numApplications = iApplications.Count(); |
|
350 aStream.WriteInt32L(numApplications); |
|
351 for (TInt i=0; i<numApplications; ++i) |
|
352 { |
|
353 iApplications[i]->ExternalizeL(aStream); |
|
354 } |
|
355 |
|
356 const TInt numChildren = iChildren.Count(); |
|
357 aStream.WriteInt32L(numChildren); |
|
358 for (TInt i=0; i<numChildren; ++i) |
|
359 { |
|
360 iChildren[i]->ExternalizeL(aStream); |
|
361 } |
|
362 } |
|
363 |
|
364 EXPORT_C const TDesC& CComponentInfo::CNode::SoftwareTypeName() const |
|
365 { |
|
366 return *iSoftwareTypeName; |
|
367 } |
|
368 |
|
369 EXPORT_C const TDesC& CComponentInfo::CNode::ComponentName() const |
|
370 { |
|
371 return *iComponentName; |
|
372 } |
|
373 |
|
374 EXPORT_C const TDesC& CComponentInfo::CNode::Version() const |
|
375 { |
|
376 return *iVersion; |
|
377 } |
|
378 |
|
379 EXPORT_C const TDesC& CComponentInfo::CNode::Vendor() const |
|
380 { |
|
381 return *iVendor; |
|
382 } |
|
383 |
|
384 EXPORT_C TScomoState CComponentInfo::CNode::ScomoState() const |
|
385 { |
|
386 return iScomoState; |
|
387 } |
|
388 |
|
389 EXPORT_C TInstallStatus CComponentInfo::CNode::InstallStatus() const |
|
390 { |
|
391 return iInstallStatus; |
|
392 } |
|
393 |
|
394 EXPORT_C TComponentId CComponentInfo::CNode::ComponentId() const |
|
395 { |
|
396 return iComponentId; |
|
397 } |
|
398 |
|
399 EXPORT_C const TDesC& CComponentInfo::CNode::GlobalComponentId() const |
|
400 { |
|
401 return *iGlobalComponentId; |
|
402 } |
|
403 |
|
404 EXPORT_C TAuthenticity CComponentInfo::CNode::Authenticity() const |
|
405 { |
|
406 return iAuthenticity; |
|
407 } |
|
408 |
|
409 EXPORT_C const TCapabilitySet& CComponentInfo::CNode::UserGrantableCaps() const |
|
410 { |
|
411 return iUserGrantableCaps; |
|
412 } |
|
413 |
|
414 EXPORT_C TInt CComponentInfo::CNode::MaxInstalledSize() const |
|
415 { |
|
416 return iMaxInstalledSize; |
|
417 } |
|
418 |
|
419 EXPORT_C TBool CComponentInfo::CNode::HasExecutable() const |
|
420 { |
|
421 return iHasExe; |
|
422 } |
|
423 |
|
424 EXPORT_C TBool CComponentInfo::CNode::DriveSeletionRequired() const |
|
425 { |
|
426 return iIsDriveSelectionRequired; |
|
427 } |
|
428 |
|
429 EXPORT_C const RPointerArray<CComponentInfo::CApplicationInfo>& CComponentInfo::CNode::Applications() const |
|
430 { |
|
431 return iApplications; |
|
432 } |
|
433 |
|
434 EXPORT_C const RPointerArray<CComponentInfo::CNode>& CComponentInfo::CNode::Children() const |
|
435 { |
|
436 return iChildren; |
|
437 } |
|
438 |
|
439 // ########################################################################################## |
|
440 |
|
441 CComponentInfo::CComponentInfo() : iExternalBufferPtr(NULL, 0, 0) |
|
442 { |
|
443 } |
|
444 |
|
445 EXPORT_C CComponentInfo::~CComponentInfo() |
|
446 { |
|
447 delete iRootNode; |
|
448 |
|
449 CleanupExternalBuffer(); |
|
450 } |
|
451 |
|
452 EXPORT_C CComponentInfo* CComponentInfo::NewL() |
|
453 { |
|
454 return new (ELeave) CComponentInfo; |
|
455 } |
|
456 |
|
457 EXPORT_C CComponentInfo* CComponentInfo::NewLC() |
|
458 { |
|
459 CComponentInfo* self = new (ELeave) CComponentInfo; |
|
460 CleanupStack::PushL(self); |
|
461 return self; |
|
462 } |
|
463 |
|
464 EXPORT_C const CComponentInfo::CNode& CComponentInfo::RootNodeL() const |
|
465 { |
|
466 InternalizeFromExternalBufferL(); |
|
467 |
|
468 if (iRootNode == NULL) |
|
469 { |
|
470 User::Leave(KErrNotFound); |
|
471 } |
|
472 |
|
473 return *iRootNode; |
|
474 } |
|
475 |
|
476 EXPORT_C void CComponentInfo::SetRootNodeL(CNode* aRootNode) |
|
477 { |
|
478 InternalizeFromExternalBufferL(); |
|
479 |
|
480 if (aRootNode == NULL) |
|
481 { |
|
482 User::Leave(KErrArgument); |
|
483 } |
|
484 |
|
485 delete iRootNode; |
|
486 iRootNode = aRootNode; |
|
487 } |
|
488 |
|
489 EXPORT_C void CComponentInfo::SetRootNodeAsChildL(CNode& aParentNode) |
|
490 { |
|
491 InternalizeFromExternalBufferL(); |
|
492 |
|
493 if (iRootNode == NULL) |
|
494 { |
|
495 User::Leave(KErrNotFound); |
|
496 } |
|
497 |
|
498 aParentNode.AddChildL(iRootNode); |
|
499 iRootNode = NULL; |
|
500 } |
|
501 |
|
502 EXPORT_C void CComponentInfo::ExternalizeL(RWriteStream& aStream) const |
|
503 { |
|
504 InternalizeFromExternalBufferL(); |
|
505 |
|
506 aStream.WriteInt8L(iRootNode != NULL); |
|
507 |
|
508 if (iRootNode != NULL) |
|
509 { |
|
510 iRootNode->ExternalizeL(aStream); |
|
511 } |
|
512 } |
|
513 |
|
514 void CComponentInfo::ConstInternalizeL(RReadStream& aStream) const |
|
515 { |
|
516 CNode*& rootNode = const_cast<CNode*&>(iRootNode); |
|
517 delete rootNode; |
|
518 rootNode = NULL; |
|
519 |
|
520 if (aStream.ReadInt8L() != 0) |
|
521 { |
|
522 rootNode = CNode::NewL(aStream); |
|
523 } |
|
524 } |
|
525 |
|
526 void CComponentInfo::CleanupExternalBuffer() const |
|
527 { |
|
528 delete iExternalBuffer; |
|
529 iExternalBuffer = NULL; |
|
530 iDeferredInternalization = EFalse; |
|
531 } |
|
532 |
|
533 void CComponentInfo::InternalizeFromExternalBufferL() const |
|
534 { |
|
535 if (iDeferredInternalization) |
|
536 { |
|
537 iDeferredInternalization = EFalse; |
|
538 |
|
539 RDesReadStream rs(*iExternalBuffer); |
|
540 CleanupClosePushL(rs); |
|
541 ConstInternalizeL(rs); |
|
542 CleanupStack::PopAndDestroy(&rs); |
|
543 |
|
544 CleanupExternalBuffer(); |
|
545 } |
|
546 } |
|
547 |
|
548 EXPORT_C void CComponentInfo::PrepareForIpcL(TIpcArgs& aIpcArgs, TInt aIndex) |
|
549 { |
|
550 delete iExternalBuffer; |
|
551 iExternalBuffer = NULL; |
|
552 |
|
553 iExternalBuffer = HBufC8::NewL(KMaxComponentInfoStreamedSize); |
|
554 iExternalBufferPtr.Set(iExternalBuffer->Des()); |
|
555 |
|
556 aIpcArgs.Set(aIndex, &iExternalBufferPtr); |
|
557 |
|
558 iDeferredInternalization = ETrue; |
|
559 } |
|
560 |
|
561 // ########################################################################################## |
|
562 |
|
563 COpaqueNamedParams::COpaqueNamedParams() |
|
564 : iExternalBuffer(NULL), iExternalBufferPtr(NULL, 0, 0), iDeferredInternalization(EFalse), iExternalizedSize(2*sizeof(TInt)) |
|
565 { |
|
566 } |
|
567 |
|
568 EXPORT_C COpaqueNamedParams::~COpaqueNamedParams() |
|
569 { |
|
570 Cleanup(); |
|
571 iParams.Close(); |
|
572 CleanupExternalBuffer(); |
|
573 } |
|
574 |
|
575 EXPORT_C COpaqueNamedParams* COpaqueNamedParams::NewL() |
|
576 { |
|
577 return new (ELeave) COpaqueNamedParams; |
|
578 } |
|
579 |
|
580 EXPORT_C COpaqueNamedParams* COpaqueNamedParams::NewLC() |
|
581 { |
|
582 COpaqueNamedParams* self = new (ELeave) COpaqueNamedParams; |
|
583 CleanupStack::PushL(self); |
|
584 return self; |
|
585 } |
|
586 |
|
587 void COpaqueNamedParams::VerifyExternalizedSizeForNewParamArrayL(TInt aNameSize, TInt aValueSize) const |
|
588 { |
|
589 const TInt load = 2*sizeof(TInt) + aNameSize + aValueSize; |
|
590 if (aNameSize > KMaxOpaqueParamsDescriptorSize || iExternalizedSize + load > KMaxOpaqueParamsExternalizedSize) |
|
591 { |
|
592 User::Leave(KErrOverflow); |
|
593 } |
|
594 iExternalizedSize += load; |
|
595 } |
|
596 |
|
597 void COpaqueNamedParams::VerifyExternalizedSizeForExistingParamArrayL(TInt aOldValueSize, TInt aNewValueSize) const |
|
598 { |
|
599 const TInt diff = aNewValueSize - aOldValueSize; |
|
600 if (iExternalizedSize + diff > KMaxOpaqueParamsExternalizedSize) |
|
601 { |
|
602 User::Leave(KErrOverflow); |
|
603 } |
|
604 iExternalizedSize += diff; |
|
605 } |
|
606 |
|
607 EXPORT_C void COpaqueNamedParams::AddStringL(const TDesC& aName, const TDesC& aValue) |
|
608 { |
|
609 CStringItem* stringItem = CStringItem::NewL(aName, aValue); |
|
610 CleanupStack::PushL(stringItem); |
|
611 |
|
612 AddOpaqueParamL(stringItem); |
|
613 CleanupStack::Pop(stringItem); |
|
614 } |
|
615 |
|
616 EXPORT_C void COpaqueNamedParams::AddStringArrayL(const TDesC& aName, const RPointerArray<HBufC>& aValueArray) |
|
617 { |
|
618 CStringArrayItem* stringArray = CStringArrayItem::NewL(aName, aValueArray); |
|
619 CleanupStack::PushL(stringArray); |
|
620 |
|
621 AddOpaqueParamL(stringArray); |
|
622 CleanupStack::Pop(stringArray); |
|
623 } |
|
624 |
|
625 EXPORT_C void COpaqueNamedParams::AddIntL(const TDesC& aName, TInt aValue) |
|
626 { |
|
627 CIntegerItem* integer = CIntegerItem::NewL(aName, aValue); |
|
628 CleanupStack::PushL(integer); |
|
629 |
|
630 AddOpaqueParamL(integer); |
|
631 CleanupStack::Pop(integer); |
|
632 } |
|
633 |
|
634 EXPORT_C void COpaqueNamedParams::AddIntArrayL(const TDesC& aName, const RArray<TInt>& aValueArray) |
|
635 { |
|
636 CIntegerArrayItem* integerArray = CIntegerArrayItem::NewL(aName, aValueArray); |
|
637 CleanupStack::PushL(integerArray); |
|
638 |
|
639 AddOpaqueParamL(integerArray); |
|
640 CleanupStack::Pop(integerArray); |
|
641 } |
|
642 |
|
643 void COpaqueNamedParams::AddOpaqueParamL(MOpaqueParam* aItemBase) |
|
644 { |
|
645 const TInt count = iParams.Count(); |
|
646 |
|
647 for (TInt i=0; i<count; ++i) |
|
648 { |
|
649 if (iParams[i]->Name().CompareF(aItemBase->Name()) == 0) |
|
650 { |
|
651 VerifyExternalizedSizeForExistingParamArrayL(iParams[i]->ValueSize(), aItemBase->ValueSize()); |
|
652 |
|
653 delete iParams[i]; |
|
654 iParams[i] = aItemBase; |
|
655 return; |
|
656 } |
|
657 } |
|
658 |
|
659 VerifyExternalizedSizeForNewParamArrayL(aItemBase->Name().Size(), aItemBase->ValueSize()); |
|
660 iParams.AppendL(aItemBase); |
|
661 } |
|
662 |
|
663 EXPORT_C void COpaqueNamedParams::GetNamesL(RPointerArray<HBufC>& aNames) const |
|
664 { |
|
665 InternalizeFromExternalBufferL(); |
|
666 |
|
667 const TInt len = iParams.Count(); |
|
668 for (TInt i=0; i<len; ++i) |
|
669 { |
|
670 HBufC* name = iParams[i]->Name().AllocLC(); |
|
671 aNames.AppendL(name); |
|
672 CleanupStack::Pop(name); |
|
673 } |
|
674 } |
|
675 |
|
676 EXPORT_C void COpaqueNamedParams::ExternalizeL(RWriteStream& aStream) const |
|
677 { |
|
678 InternalizeFromExternalBufferL(); |
|
679 |
|
680 TInt count = iParams.Count(); |
|
681 aStream.WriteInt32L(count); |
|
682 for (TInt i=0; i<count; ++i) |
|
683 { |
|
684 aStream.WriteInt32L(iParams[i]->Type()); |
|
685 iParams[i]->ExternalizeL(aStream); |
|
686 } |
|
687 |
|
688 aStream.WriteInt32L(iExternalizedSize); |
|
689 } |
|
690 |
|
691 EXPORT_C void COpaqueNamedParams::InternalizeL(RReadStream& aStream) |
|
692 { |
|
693 ConstInternalizeL(aStream); |
|
694 } |
|
695 |
|
696 void COpaqueNamedParams::ConstInternalizeL(RReadStream& aStream) const |
|
697 { |
|
698 ConstCleanup(); |
|
699 RPointerArray<MOpaqueParam>& refParams = const_cast<RPointerArray<MOpaqueParam>& >(iParams); |
|
700 |
|
701 TInt count = aStream.ReadInt32L(); |
|
702 for (TInt i=0; i<count; ++i) |
|
703 { |
|
704 MOpaqueParam::TType type = static_cast<MOpaqueParam::TType>(aStream.ReadInt32L()); |
|
705 MOpaqueParam* param(0); |
|
706 switch(type) |
|
707 { |
|
708 case MOpaqueParam::EString: |
|
709 param = CStringItem::NewL(aStream); |
|
710 break; |
|
711 |
|
712 case MOpaqueParam::EStringArray: |
|
713 param = CStringArrayItem::NewL(aStream); |
|
714 break; |
|
715 |
|
716 case MOpaqueParam::EInteger: |
|
717 param = CIntegerItem::NewL(aStream); |
|
718 break; |
|
719 |
|
720 case MOpaqueParam::EIntegerArray: |
|
721 param = CIntegerArrayItem::NewL(aStream); |
|
722 break; |
|
723 |
|
724 default: |
|
725 User::Leave(KErrCorrupt); |
|
726 } |
|
727 CleanupStack::PushL(param); |
|
728 refParams.AppendL(param); |
|
729 CleanupStack::Pop(param); |
|
730 } |
|
731 |
|
732 iExternalizedSize = aStream.ReadInt32L(); |
|
733 } |
|
734 |
|
735 EXPORT_C void COpaqueNamedParams::PrepareArgumentsForIpcL(TIpcArgs& aIpcArgs, TInt aIndex) const |
|
736 { |
|
737 delete iExternalBuffer; |
|
738 iExternalBuffer = NULL; |
|
739 iExternalBuffer = HBufC8::NewL(iExternalizedSize); |
|
740 iExternalBufferPtr.Set(iExternalBuffer->Des()); |
|
741 |
|
742 RDesWriteStream ws(iExternalBufferPtr); |
|
743 CleanupClosePushL(ws); |
|
744 ExternalizeL(ws); |
|
745 ws.CommitL(); |
|
746 CleanupStack::PopAndDestroy(&ws); |
|
747 |
|
748 aIpcArgs.Set(aIndex, &iExternalBufferPtr); |
|
749 } |
|
750 |
|
751 EXPORT_C void COpaqueNamedParams::PrepareResultsForIpcL(TIpcArgs& aIpcArgs, TInt aIndex) |
|
752 { |
|
753 delete iExternalBuffer; |
|
754 iExternalBuffer = NULL; |
|
755 iExternalBuffer = HBufC8::NewL(KMaxOpaqueParamsExternalizedSize); |
|
756 iExternalBufferPtr.Set(iExternalBuffer->Des()); |
|
757 |
|
758 RDesWriteStream ws(iExternalBufferPtr); |
|
759 CleanupClosePushL(ws); |
|
760 ws.WriteInt32L(0); // Write the initial count of results, so that the object will be valid even if no results are added |
|
761 CleanupStack::PopAndDestroy(&ws); |
|
762 |
|
763 aIpcArgs.Set(aIndex, &iExternalBufferPtr); |
|
764 |
|
765 iDeferredInternalization = ETrue; |
|
766 } |
|
767 |
|
768 void COpaqueNamedParams::InternalizeFromExternalBufferL() const |
|
769 { |
|
770 if (iDeferredInternalization) |
|
771 { |
|
772 iDeferredInternalization = EFalse; |
|
773 |
|
774 RDesReadStream rs(*iExternalBuffer); |
|
775 CleanupClosePushL(rs); |
|
776 ConstInternalizeL(rs); |
|
777 CleanupStack::PopAndDestroy(&rs); |
|
778 |
|
779 CleanupExternalBuffer(); |
|
780 } |
|
781 } |
|
782 |
|
783 EXPORT_C const TDesC& COpaqueNamedParams::StringByNameL(const TDesC& aName) const |
|
784 { |
|
785 InternalizeFromExternalBufferL(); |
|
786 |
|
787 const TInt count = iParams.Count(); |
|
788 for (TInt i=0; i<count; ++i) |
|
789 { |
|
790 if (iParams[i]->Type() == MOpaqueParam::EString && iParams[i]->Name().CompareF(aName) == 0) |
|
791 { |
|
792 CStringItem* string = static_cast<CStringItem*>(iParams[i]); |
|
793 return string->StringValue(); |
|
794 } |
|
795 } |
|
796 |
|
797 return KNullDesC; |
|
798 } |
|
799 |
|
800 EXPORT_C const RPointerArray<HBufC>& COpaqueNamedParams::StringArrayByNameL(const TDesC& aName) const |
|
801 { |
|
802 InternalizeFromExternalBufferL(); |
|
803 |
|
804 const TInt count = iParams.Count(); |
|
805 TInt i; |
|
806 for (i=0; i<count; ++i) |
|
807 { |
|
808 if (iParams[i]->Type() == MOpaqueParam::EStringArray && iParams[i]->Name().CompareF(aName) == 0) |
|
809 { |
|
810 break; |
|
811 } |
|
812 } |
|
813 |
|
814 if(i == count) |
|
815 { |
|
816 User::Leave(KErrNotFound); |
|
817 } |
|
818 CStringArrayItem* stringArray = static_cast<CStringArrayItem*>(iParams[i]); |
|
819 return stringArray->StringArrayValue(); |
|
820 } |
|
821 |
|
822 EXPORT_C TBool COpaqueNamedParams::GetIntByNameL(const TDesC& aName, TInt& aValue) const |
|
823 { |
|
824 InternalizeFromExternalBufferL(); |
|
825 |
|
826 const TInt count = iParams.Count(); |
|
827 for (TInt i=0; i<count; ++i) |
|
828 { |
|
829 if (iParams[i]->Type() == MOpaqueParam::EInteger && iParams[i]->Name().CompareF(aName) == 0) |
|
830 { |
|
831 CIntegerItem* integer = static_cast<CIntegerItem*>(iParams[i]); |
|
832 aValue = integer->IntegerValue(); |
|
833 return ETrue; |
|
834 } |
|
835 } |
|
836 |
|
837 return EFalse; |
|
838 } |
|
839 |
|
840 EXPORT_C TInt COpaqueNamedParams::IntByNameL(const TDesC& aName) const |
|
841 { |
|
842 InternalizeFromExternalBufferL(); |
|
843 |
|
844 TInt val; |
|
845 if (!GetIntByNameL(aName, val)) |
|
846 { |
|
847 User::Leave(KErrNotFound); |
|
848 } |
|
849 return val; |
|
850 } |
|
851 |
|
852 EXPORT_C const RArray<TInt>& COpaqueNamedParams::IntArrayByNameL(const TDesC& aName) const |
|
853 { |
|
854 InternalizeFromExternalBufferL(); |
|
855 |
|
856 const TInt count = iParams.Count(); |
|
857 TInt i; |
|
858 for (i=0; i<count; ++i) |
|
859 { |
|
860 if (iParams[i]->Type() == MOpaqueParam::EIntegerArray && iParams[i]->Name().CompareF(aName) == 0) |
|
861 { |
|
862 break; |
|
863 } |
|
864 } |
|
865 |
|
866 if(i == count) |
|
867 { |
|
868 User::Leave(KErrNotFound); |
|
869 } |
|
870 CIntegerArrayItem* integerArray = static_cast<CIntegerArrayItem*>(iParams[i]); |
|
871 return integerArray->IntegerArrayValue(); |
|
872 } |
|
873 |
|
874 EXPORT_C TInt COpaqueNamedParams::CountL() const |
|
875 { |
|
876 InternalizeFromExternalBufferL(); |
|
877 return iParams.Count(); |
|
878 } |
|
879 |
|
880 EXPORT_C void COpaqueNamedParams::Cleanup() |
|
881 { |
|
882 ConstCleanup(); |
|
883 } |
|
884 |
|
885 void COpaqueNamedParams::ConstCleanup() const |
|
886 { |
|
887 // Cleanup internal params |
|
888 iExternalizedSize = 2*sizeof(TInt); |
|
889 |
|
890 RPointerArray<MOpaqueParam>& refParams = const_cast<RPointerArray<MOpaqueParam>&>(iParams); |
|
891 refParams.ResetAndDestroy(); |
|
892 } |
|
893 |
|
894 void COpaqueNamedParams::CleanupExternalBuffer() const |
|
895 { |
|
896 delete iExternalBuffer; |
|
897 iExternalBuffer = NULL; |
|
898 iDeferredInternalization = EFalse; |
|
899 } |
|
900 |
|
901 |
|
902 /* |
|
903 * SifCommon internal classes |
|
904 */ |
|
905 |
|
906 |
|
907 CItemBase::CItemBase(TType aType): |
|
908 iType(aType) |
|
909 { |
|
910 |
|
911 } |
|
912 |
|
913 CItemBase::TType CItemBase::Type() const |
|
914 { |
|
915 return iType; |
|
916 } |
|
917 |
|
918 void CItemBase::SetNameL(const TDesC& aName) |
|
919 { |
|
920 delete iName; |
|
921 iName = aName.AllocL(); |
|
922 } |
|
923 |
|
924 |
|
925 CItemBase::~CItemBase() |
|
926 { |
|
927 delete iName; |
|
928 } |
|
929 |
|
930 const HBufC& CItemBase::Name() const |
|
931 { |
|
932 return *iName; |
|
933 } |
|
934 |
|
935 void CItemBase::SetValueSize(TInt aSize) |
|
936 { |
|
937 iSize = aSize; |
|
938 } |
|
939 |
|
940 TInt CItemBase::ValueSize() const |
|
941 { |
|
942 return iSize; |
|
943 } |
|
944 |
|
945 void CItemBase::VerifyExternalizedSizeForParamL(TUint aValueSize) const |
|
946 { |
|
947 if(aValueSize > KMaxOpaqueParamsDescriptorSize) |
|
948 { |
|
949 User::Leave(KErrOverflow); |
|
950 } |
|
951 } |
|
952 |
|
953 void CItemBase::ExternalizeL(RWriteStream& aStream) const |
|
954 { |
|
955 aStream << Name(); |
|
956 aStream.WriteInt32L(iSize); |
|
957 } |
|
958 |
|
959 void CItemBase::InternalizeL (RReadStream& aStream) |
|
960 { |
|
961 delete iName; |
|
962 iName = HBufC::NewL(aStream, KMaxOpaqueParamsDescriptorSize); |
|
963 iSize = aStream.ReadInt32L(); |
|
964 } |
|
965 |
|
966 /* |
|
967 * CStringItem |
|
968 */ |
|
969 CStringItem::CStringItem(): |
|
970 CItemBase(EString) |
|
971 { |
|
972 |
|
973 } |
|
974 |
|
975 CStringItem* CStringItem::NewL(const TDesC& aName, const TDesC& aValue) |
|
976 { |
|
977 CStringItem* self = new(ELeave)CStringItem(); |
|
978 CleanupStack::PushL(self); |
|
979 self->ConstructL(aName, aValue); |
|
980 CleanupStack::Pop(self); |
|
981 return self; |
|
982 } |
|
983 |
|
984 CStringItem* CStringItem::NewL(RReadStream& aStream) |
|
985 { |
|
986 CStringItem *self = new(ELeave)CStringItem(); |
|
987 CleanupStack::PushL(self); |
|
988 self->InternalizeL(aStream); |
|
989 CleanupStack::Pop(self); |
|
990 return self; |
|
991 } |
|
992 |
|
993 void CStringItem::ConstructL(const TDesC& aName, const TDesC& aValue) |
|
994 { |
|
995 VerifyExternalizedSizeForParamL(aValue.Size()); |
|
996 SetNameL(aName); |
|
997 iString = aValue.AllocL(); |
|
998 SetValueSize(iString->Size()); |
|
999 } |
|
1000 |
|
1001 CStringItem::~CStringItem() |
|
1002 { |
|
1003 delete iString; |
|
1004 } |
|
1005 |
|
1006 void CStringItem::ExternalizeL(RWriteStream& aStream) const |
|
1007 { |
|
1008 CItemBase::ExternalizeL(aStream); |
|
1009 aStream << *iString; |
|
1010 } |
|
1011 |
|
1012 void CStringItem::InternalizeL(RReadStream& aStream) |
|
1013 { |
|
1014 CItemBase::InternalizeL(aStream); |
|
1015 DeleteObjectZ(iString); |
|
1016 iString = HBufC::NewL(aStream, KMaxOpaqueParamsDescriptorSize); |
|
1017 } |
|
1018 |
|
1019 const TDesC& CStringItem::StringValue() const |
|
1020 { |
|
1021 return *iString; |
|
1022 } |
|
1023 |
|
1024 const HBufC& CStringItem::Name() const |
|
1025 { |
|
1026 return CItemBase::Name(); |
|
1027 } |
|
1028 |
|
1029 MOpaqueParam::TType CStringItem::Type() const |
|
1030 { |
|
1031 return CItemBase::Type(); |
|
1032 } |
|
1033 |
|
1034 TInt CStringItem::ValueSize() const |
|
1035 { |
|
1036 return CItemBase::ValueSize(); |
|
1037 } |
|
1038 /* |
|
1039 * CStringArrayItem |
|
1040 */ |
|
1041 |
|
1042 CStringArrayItem::CStringArrayItem(): |
|
1043 CItemBase(EStringArray) |
|
1044 { |
|
1045 |
|
1046 } |
|
1047 |
|
1048 CStringArrayItem* CStringArrayItem::NewL(const TDesC& aName, const RPointerArray<HBufC>& aValueArray) |
|
1049 { |
|
1050 CStringArrayItem* self = new(ELeave)CStringArrayItem(); |
|
1051 CleanupStack::PushL(self); |
|
1052 self->ConstructL(aName, aValueArray); |
|
1053 CleanupStack::Pop(self); |
|
1054 return self; |
|
1055 } |
|
1056 |
|
1057 CStringArrayItem* CStringArrayItem::NewL(RReadStream& aStream) |
|
1058 { |
|
1059 CStringArrayItem *self = new(ELeave)CStringArrayItem(); |
|
1060 CleanupStack::PushL(self); |
|
1061 self->InternalizeL(aStream); |
|
1062 CleanupStack::Pop(self); |
|
1063 return self; |
|
1064 } |
|
1065 |
|
1066 void CStringArrayItem::ConstructL(const TDesC& aName, const RPointerArray<HBufC>& aValueArray) |
|
1067 { |
|
1068 SetNameL(aName); |
|
1069 for(TInt i=0; i< aValueArray.Count(); ++i) |
|
1070 { |
|
1071 VerifyExternalizedSizeForParamL(aValueArray[i]->Size()); |
|
1072 HBufC* value = aValueArray[i]->AllocLC(); |
|
1073 iStringArray.AppendL(value); |
|
1074 SetValueSize(ValueSize()+ value->Size()); |
|
1075 CleanupStack::Pop(); |
|
1076 } |
|
1077 } |
|
1078 |
|
1079 void CStringArrayItem::ExternalizeL(RWriteStream& aStream) const |
|
1080 { |
|
1081 CItemBase::ExternalizeL(aStream); |
|
1082 ExternalizePointersArrayL(iStringArray, aStream); |
|
1083 } |
|
1084 |
|
1085 void CStringArrayItem::InternalizeL(RReadStream& aStream) |
|
1086 { |
|
1087 CItemBase::InternalizeL(aStream); |
|
1088 iStringArray.ResetAndDestroy(); |
|
1089 InternalizePointersArrayL(iStringArray, aStream); |
|
1090 } |
|
1091 |
|
1092 const RPointerArray<HBufC>& CStringArrayItem:: StringArrayValue() const |
|
1093 { |
|
1094 return iStringArray; |
|
1095 } |
|
1096 |
|
1097 const HBufC& CStringArrayItem::Name() const |
|
1098 { |
|
1099 return CItemBase::Name(); |
|
1100 } |
|
1101 |
|
1102 MOpaqueParam::TType CStringArrayItem::Type() const |
|
1103 { |
|
1104 return CItemBase::Type(); |
|
1105 } |
|
1106 |
|
1107 TInt CStringArrayItem::ValueSize() const |
|
1108 { |
|
1109 return CItemBase::ValueSize(); |
|
1110 } |
|
1111 |
|
1112 CStringArrayItem::~CStringArrayItem() |
|
1113 { |
|
1114 iStringArray.ResetAndDestroy(); |
|
1115 } |
|
1116 |
|
1117 /* |
|
1118 * CIntegerItem |
|
1119 */ |
|
1120 |
|
1121 CIntegerItem::CIntegerItem(TInt aValue): |
|
1122 CItemBase(EInteger), |
|
1123 iInteger(aValue) |
|
1124 { |
|
1125 |
|
1126 } |
|
1127 |
|
1128 CIntegerItem* CIntegerItem::NewL(const TDesC& aName, TInt aValue) |
|
1129 { |
|
1130 CIntegerItem* self = new(ELeave)CIntegerItem(aValue); |
|
1131 CleanupStack::PushL(self); |
|
1132 self->ConstructL(aName); |
|
1133 CleanupStack::Pop(self); |
|
1134 return self; |
|
1135 } |
|
1136 |
|
1137 CIntegerItem* CIntegerItem::NewL(RReadStream& aStream) |
|
1138 { |
|
1139 CIntegerItem *self = new(ELeave)CIntegerItem(0); |
|
1140 CleanupStack::PushL(self); |
|
1141 self->InternalizeL(aStream); |
|
1142 CleanupStack::Pop(self); |
|
1143 return self; |
|
1144 } |
|
1145 |
|
1146 void CIntegerItem::ConstructL(const TDesC& aName) |
|
1147 { |
|
1148 SetNameL(aName); |
|
1149 SetValueSize(sizeof(TInt)); |
|
1150 } |
|
1151 |
|
1152 void CIntegerItem::ExternalizeL(RWriteStream& aStream) const |
|
1153 { |
|
1154 CItemBase::ExternalizeL(aStream); |
|
1155 aStream.WriteInt32L(iInteger); |
|
1156 } |
|
1157 |
|
1158 void CIntegerItem::InternalizeL(RReadStream& aStream) |
|
1159 { |
|
1160 CItemBase::InternalizeL(aStream); |
|
1161 iInteger = aStream.ReadInt32L(); |
|
1162 } |
|
1163 |
|
1164 TInt CIntegerItem::IntegerValue() const |
|
1165 { |
|
1166 return iInteger; |
|
1167 } |
|
1168 |
|
1169 const HBufC& CIntegerItem::Name() const |
|
1170 { |
|
1171 return CItemBase::Name(); |
|
1172 } |
|
1173 |
|
1174 MOpaqueParam::TType CIntegerItem::Type() const |
|
1175 { |
|
1176 return CItemBase::Type(); |
|
1177 } |
|
1178 |
|
1179 TInt CIntegerItem::ValueSize() const |
|
1180 { |
|
1181 return CItemBase::ValueSize(); |
|
1182 } |
|
1183 |
|
1184 CIntegerItem::~CIntegerItem() |
|
1185 { |
|
1186 } |
|
1187 |
|
1188 /* |
|
1189 * CIntegerArrayItem |
|
1190 */ |
|
1191 |
|
1192 CIntegerArrayItem::CIntegerArrayItem(): |
|
1193 CItemBase(EIntegerArray) |
|
1194 { |
|
1195 |
|
1196 } |
|
1197 |
|
1198 CIntegerArrayItem* CIntegerArrayItem::NewL(const TDesC& aName, const RArray<TInt>& aValueArray) |
|
1199 { |
|
1200 CIntegerArrayItem* self = new(ELeave)CIntegerArrayItem(); |
|
1201 CleanupStack::PushL(self); |
|
1202 self->ConstructL(aName, aValueArray); |
|
1203 CleanupStack::Pop(self); |
|
1204 return self; |
|
1205 } |
|
1206 |
|
1207 CIntegerArrayItem* CIntegerArrayItem::NewL(RReadStream& aStream) |
|
1208 { |
|
1209 CIntegerArrayItem *self = new(ELeave)CIntegerArrayItem(); |
|
1210 CleanupStack::PushL(self); |
|
1211 self->InternalizeL(aStream); |
|
1212 CleanupStack::Pop(self); |
|
1213 return self; |
|
1214 } |
|
1215 |
|
1216 |
|
1217 void CIntegerArrayItem::ConstructL(const TDesC& aName, const RArray<TInt>& aValueArray) |
|
1218 { |
|
1219 SetNameL(aName); |
|
1220 |
|
1221 for(TInt i=0; i<aValueArray.Count(); ++i) |
|
1222 { |
|
1223 iIntegerArray.AppendL(aValueArray[i]); |
|
1224 SetValueSize(ValueSize()+sizeof(TInt)); |
|
1225 } |
|
1226 } |
|
1227 |
|
1228 void CIntegerArrayItem::ExternalizeL(RWriteStream& aStream) const |
|
1229 { |
|
1230 CItemBase::ExternalizeL(aStream); |
|
1231 ExternalizeFixedLengthArrayL(iIntegerArray, aStream); |
|
1232 } |
|
1233 |
|
1234 void CIntegerArrayItem::InternalizeL(RReadStream& aStream) |
|
1235 { |
|
1236 CItemBase::InternalizeL(aStream); |
|
1237 iIntegerArray.Reset(); |
|
1238 InternalizeFixedLengthArrayL(iIntegerArray, aStream); |
|
1239 } |
|
1240 |
|
1241 const RArray<TInt>& CIntegerArrayItem::IntegerArrayValue() const |
|
1242 { |
|
1243 return iIntegerArray; |
|
1244 } |
|
1245 |
|
1246 const HBufC& CIntegerArrayItem::Name() const |
|
1247 { |
|
1248 return CItemBase::Name(); |
|
1249 } |
|
1250 |
|
1251 MOpaqueParam::TType CIntegerArrayItem::Type() const |
|
1252 { |
|
1253 return CItemBase::Type(); |
|
1254 } |
|
1255 |
|
1256 TInt CIntegerArrayItem::ValueSize() const |
|
1257 { |
|
1258 return CItemBase::ValueSize(); |
|
1259 } |
|
1260 |
|
1261 CIntegerArrayItem::~CIntegerArrayItem() |
|
1262 { |
|
1263 iIntegerArray.Close(); |
|
1264 } |