|
1 /* |
|
2 * Copyright (c) 2006 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 "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: Class CCatalogsAccessPointSettings implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "catalogsaccesspointsettings.h" |
|
20 #include "catalogsutils.h" |
|
21 |
|
22 |
|
23 CCatalogsAccessPointSettings* CCatalogsAccessPointSettings::NewL() |
|
24 { |
|
25 CCatalogsAccessPointSettings* self = NewLC(); |
|
26 CleanupStack::Pop(); |
|
27 return self; |
|
28 } |
|
29 |
|
30 CCatalogsAccessPointSettings* CCatalogsAccessPointSettings::NewLC() |
|
31 { |
|
32 CCatalogsAccessPointSettings* self = |
|
33 new (ELeave) CCatalogsAccessPointSettings; |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CCatalogsAccessPointSettings::CCatalogsAccessPointSettings() |
|
40 { |
|
41 } |
|
42 |
|
43 void CCatalogsAccessPointSettings::ConstructL() |
|
44 { |
|
45 iLongTextData = new (ELeave) CDesC16ArrayFlat(2); |
|
46 iText16Data = new (ELeave) CDesC16ArrayFlat(2); |
|
47 iText8Data = new (ELeave) CDesC8ArrayFlat(2); |
|
48 } |
|
49 |
|
50 CCatalogsAccessPointSettings::~CCatalogsAccessPointSettings() |
|
51 { |
|
52 delete iLongTextData; |
|
53 delete iText16Data; |
|
54 delete iText8Data; |
|
55 iLongTextMembers.Close(); |
|
56 iText16Members.Close(); |
|
57 iText8Members.Close(); |
|
58 iUintMembers.Close(); |
|
59 iBoolMembers.Close(); |
|
60 iUintData.Close(); |
|
61 iBoolData.Close(); |
|
62 } |
|
63 |
|
64 void CCatalogsAccessPointSettings::SetLongTextParameterL( |
|
65 const TApMember& aKey, const TDesC& aValue) |
|
66 { |
|
67 TInt index = iLongTextMembers.Find(aKey); |
|
68 |
|
69 if (index == KErrNotFound) |
|
70 { |
|
71 // new parameter |
|
72 iLongTextMembers.AppendL(aKey); |
|
73 iLongTextData->AppendL(aValue); |
|
74 } |
|
75 else |
|
76 { |
|
77 // parameter exists already, change the value |
|
78 iLongTextData->Delete(index); |
|
79 iLongTextData->InsertL(index, aValue); |
|
80 } |
|
81 } |
|
82 |
|
83 void CCatalogsAccessPointSettings::SetText16ParameterL( |
|
84 const TApMember& aKey, const TDesC16& aValue) |
|
85 { |
|
86 TInt index = iText16Members.Find(aKey); |
|
87 |
|
88 if (index == KErrNotFound) |
|
89 { |
|
90 // new parameter |
|
91 iText16Members.AppendL(aKey); |
|
92 iText16Data->AppendL(aValue); |
|
93 } |
|
94 else |
|
95 { |
|
96 // parameter exists already, change the value |
|
97 iText16Data->Delete(index); |
|
98 iText16Data->InsertL(index, aValue); |
|
99 } |
|
100 } |
|
101 |
|
102 void CCatalogsAccessPointSettings::SetText8ParameterL( |
|
103 const TApMember& aKey, const TDesC8& aValue) |
|
104 { |
|
105 TInt index = iText8Members.Find(aKey); |
|
106 |
|
107 if (index == KErrNotFound) |
|
108 { |
|
109 // new parameter |
|
110 iText8Members.AppendL(aKey); |
|
111 iText8Data->AppendL(aValue); |
|
112 } |
|
113 else |
|
114 { |
|
115 // parameter exists already, change the value |
|
116 iText8Data->Delete(index); |
|
117 iText8Data->InsertL(index, aValue); |
|
118 } |
|
119 } |
|
120 |
|
121 void CCatalogsAccessPointSettings::SetUintParameterL( |
|
122 const TApMember& aKey, const TUint32& aValue) |
|
123 { |
|
124 TInt index = iUintMembers.Find(aKey); |
|
125 if (index == KErrNotFound) |
|
126 { |
|
127 // new parameter |
|
128 iUintMembers.AppendL(aKey); |
|
129 iUintData.AppendL(aValue); |
|
130 } |
|
131 else |
|
132 { |
|
133 // replace existing data |
|
134 iUintData.Remove(index); |
|
135 iUintData.InsertL(aValue, index); |
|
136 } |
|
137 } |
|
138 |
|
139 |
|
140 void CCatalogsAccessPointSettings::SetBoolParameterL( |
|
141 const TApMember& aKey, const TBool& aValue) |
|
142 { |
|
143 TInt index = iBoolMembers.Find(aKey); |
|
144 if (index == KErrNotFound) |
|
145 { |
|
146 // new parameter |
|
147 iBoolMembers.AppendL(aKey); |
|
148 iBoolData.AppendL(aValue); |
|
149 } |
|
150 else |
|
151 { |
|
152 // replace existing value |
|
153 iBoolData.Remove(index); |
|
154 iBoolData.InsertL(aValue, index); |
|
155 } |
|
156 } |
|
157 |
|
158 TInt CCatalogsAccessPointSettings::LongTextParameterCount() const |
|
159 { |
|
160 return iLongTextMembers.Count(); |
|
161 } |
|
162 |
|
163 TInt CCatalogsAccessPointSettings::Text16ParameterCount() const |
|
164 { |
|
165 return iText16Members.Count(); |
|
166 } |
|
167 |
|
168 TInt CCatalogsAccessPointSettings::Text8ParameterCount() const |
|
169 { |
|
170 return iText8Members.Count(); |
|
171 } |
|
172 |
|
173 TInt CCatalogsAccessPointSettings::UintParameterCount() const |
|
174 { |
|
175 return iUintMembers.Count(); |
|
176 } |
|
177 |
|
178 TInt CCatalogsAccessPointSettings::BoolParameterCount() const |
|
179 { |
|
180 return iBoolMembers.Count(); |
|
181 } |
|
182 |
|
183 void CCatalogsAccessPointSettings::LongTextParameter( |
|
184 TInt aIndex, TApMember& aKey, TPtrC& aValue) const |
|
185 { |
|
186 aKey = iLongTextMembers[aIndex]; |
|
187 aValue.Set((*iLongTextData)[aIndex]); |
|
188 } |
|
189 |
|
190 void CCatalogsAccessPointSettings::Text16Parameter( |
|
191 TInt aIndex, TApMember& aKey, TPtrC16& aValue) const |
|
192 { |
|
193 aKey = iText16Members[aIndex]; |
|
194 aValue.Set((*iText16Data)[aIndex]); |
|
195 } |
|
196 |
|
197 void CCatalogsAccessPointSettings::Text8Parameter( |
|
198 TInt aIndex, TApMember& aKey, TPtrC8& aValue) const |
|
199 { |
|
200 aKey = iText8Members[aIndex]; |
|
201 aValue.Set((*iText8Data)[aIndex]); |
|
202 } |
|
203 |
|
204 void CCatalogsAccessPointSettings::UintParameter( |
|
205 TInt aIndex, TApMember& aKey, TUint32& aValue) const |
|
206 { |
|
207 aKey = iUintMembers[aIndex]; |
|
208 aValue = iUintData[aIndex]; |
|
209 } |
|
210 |
|
211 void CCatalogsAccessPointSettings::BoolParameter( |
|
212 TInt aIndex, TApMember& aKey, TBool& aValue) const |
|
213 { |
|
214 aKey = iBoolMembers[aIndex]; |
|
215 aValue = iBoolData[aIndex]; |
|
216 } |
|
217 |
|
218 void CCatalogsAccessPointSettings::ExternalizeL(RWriteStream& aStream) |
|
219 { |
|
220 DLTRACEIN(("")); |
|
221 |
|
222 // write long text parameters |
|
223 TInt longTextCount = LongTextParameterCount(); |
|
224 aStream.WriteInt32L(longTextCount); |
|
225 for (TInt i = 0; i < longTextCount; i++) |
|
226 { |
|
227 aStream.WriteInt32L(iLongTextMembers[i]); |
|
228 ExternalizeDesL((*iLongTextData)[i], aStream); |
|
229 } |
|
230 |
|
231 // write 16-bit text parameters |
|
232 TInt text16Count = Text16ParameterCount(); |
|
233 aStream.WriteInt32L(text16Count); |
|
234 for (TInt i = 0; i < text16Count; i++) |
|
235 { |
|
236 aStream.WriteInt32L(iText16Members[i]); |
|
237 ExternalizeDesL((*iText16Data)[i], aStream); |
|
238 } |
|
239 |
|
240 // write 8-bit text parameters |
|
241 TInt text8Count = Text8ParameterCount(); |
|
242 aStream.WriteInt32L(text8Count); |
|
243 for (TInt i = 0; i < text8Count; i++) |
|
244 { |
|
245 aStream.WriteInt32L(iText8Members[i]); |
|
246 ExternalizeDesL((*iText8Data)[i], aStream); |
|
247 } |
|
248 |
|
249 // write uint parameters |
|
250 TInt uintCount = UintParameterCount(); |
|
251 aStream.WriteInt32L(uintCount); |
|
252 for (TInt i = 0; i < uintCount; i++) |
|
253 { |
|
254 aStream.WriteInt32L(iUintMembers[i]); |
|
255 aStream.WriteUint32L(iUintData[i]); |
|
256 } |
|
257 |
|
258 // write bool parameter |
|
259 TInt boolCount = BoolParameterCount(); |
|
260 aStream.WriteInt32L(boolCount); |
|
261 for (TInt i = 0; i < boolCount; i++) |
|
262 { |
|
263 aStream.WriteInt32L(iBoolMembers[i]); |
|
264 aStream.WriteInt8L(iBoolData[i]); |
|
265 } |
|
266 |
|
267 DLTRACEOUT(("")); |
|
268 } |
|
269 |
|
270 void CCatalogsAccessPointSettings::InternalizeL(RReadStream& aStream) |
|
271 { |
|
272 // read long text parameters |
|
273 TInt longTextCount = aStream.ReadInt32L(); |
|
274 iLongTextMembers.ReserveL(longTextCount); |
|
275 for (TInt i = 0; i < longTextCount; i++) |
|
276 { |
|
277 iLongTextMembers.AppendL((TApMember)aStream.ReadInt32L()); |
|
278 HBufC* buf = NULL; |
|
279 InternalizeDesL(buf, aStream); |
|
280 CleanupStack::PushL(buf); |
|
281 iLongTextData->AppendL(*buf); |
|
282 CleanupStack::PopAndDestroy(buf); |
|
283 } |
|
284 |
|
285 // read 16-bit text parameters |
|
286 TInt text16Count = aStream.ReadInt32L(); |
|
287 iText16Members.ReserveL(text16Count); |
|
288 for (TInt i = 0; i < text16Count; i++) |
|
289 { |
|
290 iText16Members.AppendL((TApMember)aStream.ReadInt32L()); |
|
291 HBufC16* buf = NULL; |
|
292 InternalizeDesL(buf, aStream); |
|
293 CleanupStack::PushL( buf ); |
|
294 iText16Data->AppendL(*buf); |
|
295 CleanupStack::PopAndDestroy( buf ); |
|
296 } |
|
297 |
|
298 // read 8-bit text parameters |
|
299 TInt text8Count = aStream.ReadInt32L(); |
|
300 iText8Members.ReserveL(text8Count); |
|
301 for (TInt i = 0; i < text8Count; i++) |
|
302 { |
|
303 iText8Members.AppendL((TApMember)aStream.ReadInt32L()); |
|
304 HBufC8* buf = NULL; |
|
305 InternalizeDesL(buf, aStream); |
|
306 CleanupStack::PushL( buf ); |
|
307 iText8Data->AppendL(*buf); |
|
308 CleanupStack::PopAndDestroy( buf ); |
|
309 } |
|
310 |
|
311 // read uint parameters |
|
312 TInt uintCount = aStream.ReadInt32L(); |
|
313 iUintMembers.ReserveL(uintCount); |
|
314 iUintData.ReserveL(uintCount); |
|
315 for (TInt i = 0; i < uintCount; i++) |
|
316 { |
|
317 iUintMembers.AppendL((TApMember)aStream.ReadInt32L()); |
|
318 iUintData.AppendL(aStream.ReadUint32L()); |
|
319 } |
|
320 |
|
321 // read bool parameters |
|
322 TInt boolCount = aStream.ReadInt32L(); |
|
323 iBoolMembers.ReserveL(boolCount); |
|
324 iBoolData.ReserveL(boolCount); |
|
325 for (TInt i = 0; i < boolCount; i++) |
|
326 { |
|
327 iBoolMembers.AppendL((TApMember)aStream.ReadInt32L()); |
|
328 iBoolData.AppendL(aStream.ReadInt8L()); |
|
329 } |
|
330 } |