|
1 /* |
|
2 * Copyright (c) 2007-2009 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 "upsnotifierutil.h" |
|
20 |
|
21 using namespace UserPromptService; |
|
22 |
|
23 EXPORT_C CPromptData* CPromptData::NewL() |
|
24 /** |
|
25 Factory function that creates a new, blank CPromptData object. |
|
26 @return A pointer to the new CPromptData object. |
|
27 */ |
|
28 { |
|
29 CPromptData* self = new(ELeave) CPromptData(); |
|
30 return self; |
|
31 } |
|
32 |
|
33 CPromptData::CPromptData() |
|
34 /** |
|
35 Constructor |
|
36 */ |
|
37 { |
|
38 } |
|
39 |
|
40 CPromptData::~CPromptData() |
|
41 /** |
|
42 Destructor |
|
43 */ |
|
44 { |
|
45 Reset(); |
|
46 } |
|
47 |
|
48 void CPromptData::Reset() |
|
49 /** |
|
50 Frees all internal memory in-case the object is internalised multiple times. |
|
51 */ |
|
52 { |
|
53 iClientName.Close(); |
|
54 iVendorName.Close(); |
|
55 iClientSid.iId = 0; |
|
56 iServerSid.iId = 0; |
|
57 iServiceId.iUid = 0; |
|
58 iDestination.Close(); |
|
59 iOpaqueData.Close(); |
|
60 iDescriptions.ResetAndDestroy(); |
|
61 } |
|
62 |
|
63 EXPORT_C void CPromptData::InternalizeL(RReadStream& aStream) |
|
64 /** |
|
65 Internalizes the prompt data from the specified stream/ |
|
66 @param aStream The read stream |
|
67 */ |
|
68 { |
|
69 Reset(); |
|
70 iClientName.CreateL(aStream, KMaskDesLength16); |
|
71 iVendorName.CreateL(aStream, KMaskDesLength16); |
|
72 aStream >> iClientSid.iId; |
|
73 aStream >> iServerSid.iId; |
|
74 aStream >> iServiceId.iUid; |
|
75 iDestination.CreateL(aStream, KMaskDesLength16); |
|
76 iOpaqueData.CreateL(aStream, KMaskDesLength8); |
|
77 |
|
78 TInt32 count = aStream.ReadUint32L(); |
|
79 |
|
80 for (TInt i = 0; i < count; ++i) |
|
81 { |
|
82 TInt32 l = aStream.ReadInt32L(); |
|
83 HBufC* d = HBufC::NewMaxLC(l); |
|
84 TPtr wptr = d->Des(); |
|
85 aStream.ReadL(wptr, l); |
|
86 iDescriptions.AppendL(d); |
|
87 CleanupStack::Pop(d); |
|
88 } |
|
89 aStream >> iOptions; |
|
90 aStream >> iFlags; |
|
91 } |
|
92 |
|
93 EXPORT_C void CPromptData::ExternalizeL(RWriteStream& aStream) const |
|
94 /** |
|
95 Externalizes the prompt data to the specified stream. |
|
96 @param aStream The write stream. |
|
97 */ |
|
98 { |
|
99 aStream << iClientName; |
|
100 aStream << iVendorName; |
|
101 aStream << iClientSid.iId; |
|
102 aStream << iServerSid.iId; |
|
103 aStream << iServiceId.iUid; |
|
104 aStream << iDestination; |
|
105 aStream << iOpaqueData; |
|
106 TInt count = iDescriptions.Count(); |
|
107 aStream.WriteUint32L(count); |
|
108 |
|
109 for (TInt i = 0; i < count; ++i) |
|
110 { |
|
111 aStream.WriteInt32L(iDescriptions[i]->Length()); |
|
112 aStream.WriteL(*iDescriptions[i]); |
|
113 } |
|
114 aStream << iOptions; |
|
115 aStream << iFlags; |
|
116 } |