|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Parser for the WirelessVillage OTA settings. |
|
16 * Supports only wbxml. |
|
17 * |
|
18 */ |
|
19 |
|
20 #include <e32std.h> |
|
21 #include <xmlelemt.h> |
|
22 #include <cnode.h> |
|
23 #include "wvsettings.h" |
|
24 #include "wvsettingsdef.h" |
|
25 |
|
26 // CONSTANTS |
|
27 const TInt KMaxStringSize = 200; |
|
28 const TInt KElemAndEndTokenLength = 2; |
|
29 const TInt KEndTokenLength = 1; |
|
30 // --------------------------------------------------------- |
|
31 // CWVSettingsParser::CWVSettingsParser() |
|
32 // --------------------------------------------------------- |
|
33 // |
|
34 CWVSettingsParser::CWVSettingsParser(): |
|
35 iListEmpty(ETrue), |
|
36 iOTAVersion(EFalse), |
|
37 iPassword(EFalse), |
|
38 iPreferredProtocol(EFalse), |
|
39 iProxyAddress(EFalse), |
|
40 iProxyPort(EFalse), |
|
41 iProxyUser(EFalse), |
|
42 iProxyPassword(EFalse), |
|
43 iRefName(EFalse), |
|
44 iSAP4WaySupportedSms(EFalse), |
|
45 iSAP4WaySupportedHttp(EFalse), |
|
46 iSAPMobileNumber(EFalse), |
|
47 iSAPURI(EFalse), |
|
48 iSettingsName(EFalse), |
|
49 iSMSCMobileNumber(EFalse), |
|
50 iUserID(EFalse), |
|
51 iSupportedVersions(EFalse), |
|
52 iCommon(EFalse), |
|
53 iSms(EFalse), |
|
54 iHttp(EFalse), |
|
55 iProxy(EFalse) |
|
56 { |
|
57 iDatabufferSize = 0; |
|
58 iParsedBytes = 0; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------- |
|
62 // CWVSettingsParser::NewL() |
|
63 // --------------------------------------------------------- |
|
64 // |
|
65 EXPORT_C CWVSettingsParser* CWVSettingsParser::NewL() |
|
66 { |
|
67 CWVSettingsParser* self = new (ELeave) CWVSettingsParser (); |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL( ); |
|
70 CleanupStack::Pop(); |
|
71 return self; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CWVSettingsParser::ConstructL() |
|
76 // --------------------------------------------------------- |
|
77 // |
|
78 void CWVSettingsParser::ConstructL() |
|
79 { |
|
80 iWVSupportedVersions = new (ELeave) CArrayPtrFlat<HBufC>(1); |
|
81 iRootElement = CXmlElement::NewL (&KWVSettings, NULL); |
|
82 iWVOTAVersion = HBufC::NewL(KMaxStringSize); |
|
83 iWVPassword = HBufC::NewL (KMaxStringSize); |
|
84 iWVPreferredProtocol = HBufC::NewL (KMaxStringSize); |
|
85 iWVProxyAddress = HBufC::NewL (KMaxStringSize); |
|
86 iWVProxyPort = HBufC::NewL (KMaxStringSize); |
|
87 iWVProxyUser = HBufC::NewL (KMaxStringSize); |
|
88 iWVRefName = HBufC::NewL (KMaxStringSize); |
|
89 iWVSAPFourWaySupported1 = HBufC::NewL (KMaxStringSize); |
|
90 iWVSAPFourWaySupported2 = HBufC::NewL (KMaxStringSize); |
|
91 iWVSAPMobileNumber = HBufC::NewL (KMaxStringSize); |
|
92 iWVSAPURI = HBufC::NewL (KMaxStringSize); |
|
93 iWVSettingsName = HBufC::NewL (KMaxStringSize); |
|
94 iWVSMSCMobileNumber = HBufC::NewL (KMaxStringSize); |
|
95 iWVUserID = HBufC::NewL (KMaxStringSize); |
|
96 iWVProxyPassword = HBufC::NewL (KMaxStringSize); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------- |
|
100 // CWVSettingsParser::~CWVSettingsParser() |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 CWVSettingsParser::~CWVSettingsParser() |
|
104 { |
|
105 delete iRootElement; |
|
106 delete iWVSettingsName; |
|
107 delete iWVOTAVersion; |
|
108 delete iWVPassword; |
|
109 delete iWVPreferredProtocol; |
|
110 delete iWVProxyAddress; |
|
111 delete iWVProxyPort; |
|
112 delete iWVProxyUser; |
|
113 delete iWVRefName; |
|
114 delete iWVSAPFourWaySupported1; |
|
115 delete iWVSAPFourWaySupported2; |
|
116 delete iWVSAPMobileNumber; |
|
117 delete iWVSAPURI; |
|
118 delete iWVSMSCMobileNumber; |
|
119 if (iWVSupportedVersions != NULL) |
|
120 { |
|
121 iWVSupportedVersions->ResetAndDestroy (); |
|
122 delete iWVSupportedVersions; |
|
123 } |
|
124 delete iWVUserID; |
|
125 delete iWVProxyPassword; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------- |
|
129 // CWVSettingsParser::ParseL |
|
130 // --------------------------------------------------------- |
|
131 // |
|
132 EXPORT_C TBool CWVSettingsParser::ParseL(TDesC8& aDataBuffer) |
|
133 { |
|
134 DoParseL (aDataBuffer); |
|
135 CreateXmlElementTreeL (); |
|
136 TBool errNotFound = Validate (); |
|
137 return errNotFound; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------- |
|
141 // CWVSettingsParser::CreateXmlElementTreeL |
|
142 // --------------------------------------------------------- |
|
143 // |
|
144 void CWVSettingsParser::CreateXmlElementTreeL () |
|
145 { |
|
146 /* used for the CleanupStack */ |
|
147 TInt nbrOfElements = 0; |
|
148 /* Create all elements and set the data */ |
|
149 if (iOTAVersion) |
|
150 { |
|
151 CXmlElement* WVOTAVersion = CXmlElement::NewL (&KWVOTAVersion, iRootElement); |
|
152 CleanupStack::PushL(WVOTAVersion); |
|
153 WVOTAVersion->SetTextL(*iWVOTAVersion); |
|
154 iRootElement->AppendChildL (WVOTAVersion); |
|
155 nbrOfElements++; |
|
156 } |
|
157 if (iCommon) |
|
158 { |
|
159 CXmlElement* WVCommon = CXmlElement::NewL (&KWVCommon, iRootElement); |
|
160 CleanupStack::PushL(WVCommon); |
|
161 if (iSettingsName) |
|
162 { |
|
163 CXmlElement* WVSettingsName = CXmlElement::NewL (&KWVSettingsName, WVCommon); |
|
164 CleanupStack::PushL(WVSettingsName); |
|
165 WVSettingsName->SetTextL(*iWVSettingsName); |
|
166 WVCommon->AppendChildL (WVSettingsName); |
|
167 nbrOfElements++; |
|
168 } |
|
169 if (iRefName) |
|
170 { |
|
171 CXmlElement* WVRefName = CXmlElement::NewL (&KWVRefName, WVCommon); |
|
172 CleanupStack::PushL(WVRefName); |
|
173 WVRefName->SetTextL(*iWVRefName); |
|
174 WVCommon->AppendChildL (WVRefName); |
|
175 nbrOfElements++; |
|
176 } |
|
177 if (iSupportedVersions) |
|
178 { |
|
179 CXmlElement* WVSupportedVersion; |
|
180 TInt nbrOfVersions = iWVSupportedVersions->Count(); |
|
181 for (TInt i = 0; i < nbrOfVersions; i++) |
|
182 { |
|
183 WVSupportedVersion = CXmlElement::NewL (&KWVSupportedVersion, WVCommon); |
|
184 CleanupStack::PushL(WVSupportedVersion); |
|
185 WVSupportedVersion->SetTextL(*iWVSupportedVersions->At(i)); |
|
186 WVCommon->AppendChildL (WVSupportedVersion); |
|
187 nbrOfElements++; |
|
188 } |
|
189 } |
|
190 if (iUserID) |
|
191 { |
|
192 CXmlElement* WVUserID = CXmlElement::NewL (&KWVUserID, WVCommon); |
|
193 CleanupStack::PushL(WVUserID); |
|
194 WVUserID->SetTextL(*iWVUserID); |
|
195 WVCommon->AppendChildL (WVUserID); |
|
196 nbrOfElements++; |
|
197 } |
|
198 if (iPassword) |
|
199 { |
|
200 CXmlElement* WVPassword = CXmlElement::NewL (&KWVPassword, WVCommon); |
|
201 CleanupStack::PushL(WVPassword); |
|
202 WVPassword->SetTextL(*iWVPassword); |
|
203 WVCommon->AppendChildL (WVPassword); |
|
204 nbrOfElements++; |
|
205 } |
|
206 if (iPreferredProtocol) |
|
207 { |
|
208 CXmlElement* WVPreferredProtocol = CXmlElement::NewL (&KWVPreferredProtocol, WVCommon); |
|
209 CleanupStack::PushL(WVPreferredProtocol); |
|
210 WVPreferredProtocol->SetTextL(*iWVPreferredProtocol); |
|
211 WVCommon->AppendChildL (WVPreferredProtocol); |
|
212 nbrOfElements++; |
|
213 } |
|
214 iRootElement->AppendChildL (WVCommon); |
|
215 nbrOfElements++; |
|
216 } //WVCommon |
|
217 if (iSms) |
|
218 { |
|
219 CXmlElement* WVSMS = CXmlElement::NewL (&KWVSMS, iRootElement); |
|
220 CleanupStack::PushL(WVSMS); |
|
221 if (iSAPMobileNumber) |
|
222 { |
|
223 CXmlElement* WVSAPMobileNumber = CXmlElement::NewL (&KWVSAPMobileNumber, WVSMS); |
|
224 CleanupStack::PushL(WVSAPMobileNumber); |
|
225 WVSAPMobileNumber->SetTextL(*iWVSAPMobileNumber); |
|
226 WVSMS->AppendChildL (WVSAPMobileNumber); |
|
227 nbrOfElements++; |
|
228 } |
|
229 if (iSAP4WaySupportedSms) |
|
230 { |
|
231 CXmlElement* WVSAPFourWaySupported1 = CXmlElement::NewL (&KWVSAPFourWaySupported, WVSMS); |
|
232 CleanupStack::PushL(WVSAPFourWaySupported1); |
|
233 WVSAPFourWaySupported1->SetTextL(*iWVSAPFourWaySupported1); |
|
234 WVSMS->AppendChildL (WVSAPFourWaySupported1); |
|
235 nbrOfElements++; |
|
236 } |
|
237 if (iSMSCMobileNumber) |
|
238 { |
|
239 CXmlElement* WVSMSCMobileNumber = CXmlElement::NewL (&KWVSMSCMobileNumber, WVSMS); |
|
240 CleanupStack::PushL(WVSMSCMobileNumber); |
|
241 WVSMSCMobileNumber->SetTextL(*iWVSMSCMobileNumber); |
|
242 WVSMS->AppendChildL (WVSMSCMobileNumber); |
|
243 nbrOfElements++; |
|
244 } |
|
245 iRootElement->AppendChildL (WVSMS); |
|
246 nbrOfElements++; |
|
247 } // WVSMS |
|
248 if (iHttp) |
|
249 { |
|
250 CXmlElement* WVHTTP = CXmlElement::NewL (&KWVHTTP, iRootElement); |
|
251 CleanupStack::PushL(WVHTTP); |
|
252 if ( iSAPURI) |
|
253 { |
|
254 CXmlElement* WVSAPURI = CXmlElement::NewL (&KWVSAPURI, WVHTTP); |
|
255 CleanupStack::PushL(WVSAPURI); |
|
256 WVSAPURI->SetTextL(*iWVSAPURI); |
|
257 WVHTTP->AppendChildL (WVSAPURI); |
|
258 nbrOfElements++; |
|
259 } |
|
260 if (iSAP4WaySupportedHttp) |
|
261 { |
|
262 CXmlElement* WVSAPFourWaySupported2 = CXmlElement::NewL (&KWVSAPFourWaySupported, WVHTTP); |
|
263 CleanupStack::PushL(WVSAPFourWaySupported2); |
|
264 WVSAPFourWaySupported2->SetTextL(*iWVSAPFourWaySupported2); |
|
265 WVHTTP->AppendChildL (WVSAPFourWaySupported2); |
|
266 nbrOfElements++; |
|
267 } |
|
268 if (iProxy) |
|
269 { |
|
270 CXmlElement* WVProxy = CXmlElement::NewL (&KWVProxy, WVHTTP); |
|
271 CleanupStack::PushL(WVProxy); |
|
272 if ( iProxyAddress) |
|
273 { |
|
274 CXmlElement* WVProxyAddress = CXmlElement::NewL (&KWVProxyAddress, WVProxy); |
|
275 CleanupStack::PushL(WVProxyAddress); |
|
276 WVProxyAddress->SetTextL(*iWVProxyAddress); |
|
277 WVProxy->AppendChildL (WVProxyAddress); |
|
278 nbrOfElements++; |
|
279 } |
|
280 if (iProxyPort) |
|
281 { |
|
282 CXmlElement* WVProxyPort = CXmlElement::NewL (&KWVProxyPort, WVProxy); |
|
283 CleanupStack::PushL(WVProxyPort); |
|
284 WVProxyPort->SetTextL(*iWVProxyPort); |
|
285 WVProxy->AppendChildL (WVProxyPort); |
|
286 nbrOfElements++; |
|
287 } |
|
288 if (iProxyUser) |
|
289 { |
|
290 CXmlElement* WVProxyUser = CXmlElement::NewL (&KWVProxyUser, WVProxy); |
|
291 CleanupStack::PushL(WVProxyUser); |
|
292 WVProxyUser->SetTextL(*iWVProxyUser); |
|
293 WVProxy->AppendChildL (WVProxyUser); |
|
294 nbrOfElements++; |
|
295 } |
|
296 if (iProxyPassword) |
|
297 { |
|
298 CXmlElement* WVProxyPassword = CXmlElement::NewL (&KWVProxyPassword, WVProxy); |
|
299 CleanupStack::PushL(WVProxyPassword); |
|
300 WVProxyPassword->SetTextL(*iWVProxyPassword); |
|
301 WVProxy->AppendChildL (WVProxyPassword); |
|
302 nbrOfElements++; |
|
303 } |
|
304 WVHTTP->AppendChildL (WVProxy); |
|
305 nbrOfElements++; |
|
306 } // WVProxy |
|
307 iRootElement->AppendChildL (WVHTTP); |
|
308 nbrOfElements++; |
|
309 } // WVHTTP |
|
310 //for testing |
|
311 //iRootElement->WriteIntoFileL(); |
|
312 CleanupStack::Pop(nbrOfElements); // elements |
|
313 } |
|
314 |
|
315 // --------------------------------------------------------- |
|
316 // CWVSettingsParser::Root () |
|
317 // --------------------------------------------------------- |
|
318 // |
|
319 EXPORT_C CXmlElement* CWVSettingsParser::Root () |
|
320 { |
|
321 return iRootElement; |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------- |
|
325 // CWVSettingsParser::DoParseL |
|
326 // --------------------------------------------------------- |
|
327 // |
|
328 void CWVSettingsParser::DoParseL(TDesC8& aDataBuffer) |
|
329 { |
|
330 TBool done = EFalse; |
|
331 TUint8* dataPtr = (TUint8*) aDataBuffer.Ptr(); |
|
332 |
|
333 iDatabufferSize = aDataBuffer.Size(); |
|
334 |
|
335 if (iDatabufferSize > 0) |
|
336 { |
|
337 // save the buffer's start point |
|
338 TUint8* startPtr = dataPtr; |
|
339 //version, public id, charset |
|
340 dataPtr = dataPtr+3; |
|
341 //string table |
|
342 dataPtr++; |
|
343 |
|
344 // this is used for 4waySupported |
|
345 TBool sms = EFalse; |
|
346 while(!done) |
|
347 { |
|
348 switch (*dataPtr) |
|
349 { |
|
350 case (KWV_TAG_CONTENT + K_WVSETTINGS): |
|
351 dataPtr++; |
|
352 break; |
|
353 case (KWV_TAG_CONTENT + K_WVOTAVERSION): |
|
354 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVOTAVersion); |
|
355 iOTAVersion = ETrue; |
|
356 break; |
|
357 case (KWV_TAG_CONTENT + K_WVCOMMON): |
|
358 dataPtr++; |
|
359 iCommon = ETrue; |
|
360 break; |
|
361 case(KWV_TAG_CONTENT + K_WVSETTINGSNAME): |
|
362 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVSettingsName); |
|
363 iSettingsName = ETrue; |
|
364 break; |
|
365 case(KWV_TAG_CONTENT + K_WVREFNAME): |
|
366 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVRefName); |
|
367 iRefName = ETrue; |
|
368 break; |
|
369 case (KWV_TAG_CONTENT + K_WVSUPPORTEDVERSION): |
|
370 dataPtr = dataPtr + ReadSupportedVersionsL(dataPtr); |
|
371 iSupportedVersions = ETrue; |
|
372 break; |
|
373 case (KWV_TAG_CONTENT + K_WVUSERID): |
|
374 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVUserID); |
|
375 iUserID = ETrue; |
|
376 break; |
|
377 case (KWV_TAG_CONTENT + K_WVPASSWORD): |
|
378 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVPassword); |
|
379 iPassword = ETrue; |
|
380 break; |
|
381 case (KWV_TAG_CONTENT + K_WVPREFERREDPROTOCOL): |
|
382 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVPreferredProtocol); |
|
383 iPreferredProtocol = ETrue; |
|
384 break; |
|
385 case (KWV_TAG_CONTENT + K_WVSMS): |
|
386 dataPtr++; |
|
387 sms = ETrue; |
|
388 iSms = ETrue; |
|
389 break; |
|
390 case (KWV_TAG_CONTENT + K_WVSAPMOBILENUMBER): |
|
391 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVSAPMobileNumber); |
|
392 iSAPMobileNumber = ETrue; |
|
393 break; |
|
394 case (KWV_TAG_CONTENT + K_WVSAPFOURWAYSUPPORTED): |
|
395 // NOTE This assumes that if msg has WVSMS element, it comes always before WVHTTP element |
|
396 // anyhow the specs say that... |
|
397 // ...The elements in the WV settings must be sent in a same order as the |
|
398 // content models of these DTD elements define them |
|
399 if (sms) |
|
400 { |
|
401 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVSAPFourWaySupported1); |
|
402 sms = EFalse; |
|
403 iSAP4WaySupportedSms = ETrue; |
|
404 } |
|
405 else |
|
406 { |
|
407 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVSAPFourWaySupported2); |
|
408 iSAP4WaySupportedHttp = ETrue; |
|
409 } |
|
410 break; |
|
411 case (KWV_TAG_CONTENT + K_WVSMSMOBILENUMBER): |
|
412 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVSMSCMobileNumber); |
|
413 iSMSCMobileNumber = ETrue; |
|
414 break; |
|
415 case (KWV_TAG_CONTENT + K_WVHTTP): |
|
416 dataPtr++; |
|
417 iHttp = ETrue; |
|
418 break; |
|
419 case (KWV_TAG_CONTENT + K_WVSAPURI): |
|
420 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVSAPURI); |
|
421 iSAPURI = ETrue; |
|
422 break; |
|
423 case (KWV_TAG_CONTENT + K_WVPROXY): |
|
424 dataPtr++; |
|
425 iProxy = ETrue; |
|
426 break; |
|
427 case (KWV_TAG_CONTENT + K_WVPROXYADDRESS): |
|
428 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVProxyAddress); |
|
429 iProxyAddress = ETrue; |
|
430 break; |
|
431 case (KWV_TAG_CONTENT + K_WVPROXYPORT): |
|
432 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVProxyPort); |
|
433 iProxyPort = ETrue; |
|
434 break; |
|
435 case (KWV_TAG_CONTENT + K_WVPROXYUSER): |
|
436 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVProxyUser); |
|
437 iProxyUser = ETrue; |
|
438 break; |
|
439 case (KWV_TAG_CONTENT + K_WVPROXYPASSWORD): |
|
440 dataPtr = dataPtr + ReadElementWithContentL(dataPtr, iWVProxyPassword); |
|
441 iProxyPassword = ETrue; |
|
442 break; |
|
443 |
|
444 case K_WVOTAVERSION: |
|
445 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVOTAVersion); |
|
446 iOTAVersion = ETrue; |
|
447 break; |
|
448 case K_WVCOMMON: |
|
449 dataPtr+=KElemAndEndTokenLength; |
|
450 iCommon = ETrue; |
|
451 break; |
|
452 case K_WVSETTINGSNAME: |
|
453 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVSettingsName); |
|
454 iSettingsName = ETrue; |
|
455 break; |
|
456 case K_WVREFNAME: |
|
457 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVRefName); |
|
458 iRefName = ETrue; |
|
459 break; |
|
460 case K_WVSUPPORTEDVERSION: |
|
461 dataPtr+=KElemAndEndTokenLength; |
|
462 iSupportedVersions = ETrue; |
|
463 break; |
|
464 case K_WVUSERID: |
|
465 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVUserID); |
|
466 iUserID = ETrue; |
|
467 break; |
|
468 case K_WVPASSWORD: |
|
469 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVPassword); |
|
470 iPassword = ETrue; |
|
471 break; |
|
472 case K_WVPREFERREDPROTOCOL: |
|
473 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVPreferredProtocol); |
|
474 iPreferredProtocol = ETrue; |
|
475 break; |
|
476 case K_WVSMS: |
|
477 dataPtr+=KElemAndEndTokenLength; |
|
478 iSms = ETrue; |
|
479 break; |
|
480 case K_WVSAPMOBILENUMBER: |
|
481 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVSAPMobileNumber); |
|
482 iSAPMobileNumber = ETrue; |
|
483 break; |
|
484 case K_WVSAPFOURWAYSUPPORTED: |
|
485 if (sms) |
|
486 { |
|
487 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVSAPFourWaySupported1); |
|
488 sms = EFalse; |
|
489 iSAP4WaySupportedSms = ETrue; |
|
490 } |
|
491 else |
|
492 { |
|
493 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVSAPFourWaySupported2); |
|
494 iSAP4WaySupportedHttp = ETrue; |
|
495 } |
|
496 break; |
|
497 case K_WVSMSMOBILENUMBER: |
|
498 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVSMSCMobileNumber); |
|
499 iSMSCMobileNumber = ETrue; |
|
500 break; |
|
501 case K_WVHTTP: |
|
502 dataPtr+=KElemAndEndTokenLength; |
|
503 iHttp = ETrue; |
|
504 break; |
|
505 case K_WVSAPURI: |
|
506 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVSAPURI); |
|
507 iSAPURI = ETrue; |
|
508 break; |
|
509 case K_WVPROXY: |
|
510 dataPtr+=KElemAndEndTokenLength; |
|
511 iProxy = ETrue; |
|
512 break; |
|
513 case K_WVPROXYADDRESS: |
|
514 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVProxyAddress); |
|
515 iProxyAddress = ETrue; |
|
516 break; |
|
517 case K_WVPROXYPORT: |
|
518 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVProxyPort); |
|
519 iProxyPort = ETrue; |
|
520 break; |
|
521 case K_WVPROXYUSER: |
|
522 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVProxyUser); |
|
523 iProxyUser = ETrue; |
|
524 break; |
|
525 case K_WVPROXYPASSWORD: |
|
526 dataPtr = dataPtr + ReadEmptyElement (dataPtr, iWVProxyPassword); |
|
527 iProxyPassword = ETrue; |
|
528 break; |
|
529 case KWV_END_TAG: |
|
530 dataPtr++; // end tag |
|
531 break; |
|
532 default: |
|
533 dataPtr++; |
|
534 break; |
|
535 }//switch |
|
536 iParsedBytes = dataPtr - startPtr; |
|
537 if ( iParsedBytes >= iDatabufferSize) |
|
538 done = ETrue; |
|
539 }//while |
|
540 } // databuffer |
|
541 |
|
542 } |
|
543 |
|
544 // --------------------------------------------------------- |
|
545 // CWVSettingsParser::ReadElementWithContentL |
|
546 // --------------------------------------------------------- |
|
547 // |
|
548 TInt CWVSettingsParser::ReadElementWithContentL(TUint8* aPtr, HBufC* aDataBuffer) |
|
549 { |
|
550 TInt count = 0; |
|
551 TInt inlineStr = 0; |
|
552 // remove the element tag |
|
553 aPtr++; |
|
554 //next should be inline string token 0x03 |
|
555 if (*aPtr == KWV_STR_I){ |
|
556 aPtr++; |
|
557 inlineStr++; |
|
558 } |
|
559 // find the end tag |
|
560 TUint8* start = aPtr; |
|
561 while ( *start != KWV_END_TAG && ((iParsedBytes + inlineStr + count) < iDatabufferSize)) |
|
562 { |
|
563 count++; |
|
564 start++; |
|
565 } |
|
566 TInt size = 0; |
|
567 if (count > KMaxStringSize) |
|
568 size = KMaxStringSize; |
|
569 else if (count == 0) |
|
570 size = 0; |
|
571 else |
|
572 size = count-1; |
|
573 aDataBuffer->ReAllocL(size); |
|
574 TPtr16 dataPtr = aDataBuffer->Des(); |
|
575 for (TInt i = 0; i < size; i++) |
|
576 { |
|
577 dataPtr.Append(*aPtr); |
|
578 aPtr++; |
|
579 } |
|
580 return count + inlineStr + KElemAndEndTokenLength; |
|
581 } |
|
582 |
|
583 // --------------------------------------------------------- |
|
584 // CWVSettingsParser::ReadSupportedVersionsL |
|
585 // --------------------------------------------------------- |
|
586 // |
|
587 TInt CWVSettingsParser::ReadSupportedVersionsL(TUint8* aPtr) |
|
588 { |
|
589 TInt count = 0; |
|
590 TInt inlineStr = 0; |
|
591 // remove the element tag |
|
592 aPtr++; |
|
593 //next should be inline string token 0x03 |
|
594 if (*aPtr == KWV_STR_I){ |
|
595 aPtr++; |
|
596 inlineStr++; |
|
597 } |
|
598 // find the end tag |
|
599 TUint8* start = aPtr; |
|
600 while ( *start != KWV_END_TAG && ((iParsedBytes + inlineStr + count) < iDatabufferSize)) |
|
601 { |
|
602 count++; |
|
603 start++; |
|
604 } |
|
605 TInt size = 0; |
|
606 if (count > KMaxStringSize) |
|
607 size = KMaxStringSize; |
|
608 else if (count == 0) |
|
609 size = 0; |
|
610 else |
|
611 size = count-1; |
|
612 HBufC* version = HBufC::NewL(size); |
|
613 CleanupStack::PushL(version); |
|
614 TPtr16 dataPtr = version->Des(); |
|
615 for (TInt i = 0; i < size ; i++) |
|
616 { |
|
617 dataPtr.Append(*aPtr); |
|
618 aPtr++; |
|
619 } |
|
620 if(iListEmpty) |
|
621 { |
|
622 iWVSupportedVersions->AppendL(version); |
|
623 iListEmpty = EFalse; |
|
624 } |
|
625 else |
|
626 { |
|
627 TInt index = iWVSupportedVersions->Count(); |
|
628 iWVSupportedVersions->InsertL(index, version); |
|
629 } |
|
630 CleanupStack::Pop(); |
|
631 return count + inlineStr + KElemAndEndTokenLength; |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------- |
|
635 // CWVSettingsParser::ReadEmptyElement |
|
636 // --------------------------------------------------------- |
|
637 // |
|
638 TInt CWVSettingsParser::ReadEmptyElement(TUint8* aPtr, HBufC* dataBuffer) |
|
639 { |
|
640 TInt count = 0; |
|
641 TUint8* start = aPtr; |
|
642 |
|
643 while ( *start != KWV_END_TAG && ((iParsedBytes + count) <= iDatabufferSize)) |
|
644 { |
|
645 count++; |
|
646 start++; |
|
647 } |
|
648 if (dataBuffer) |
|
649 dataBuffer = NULL; |
|
650 |
|
651 return count + KEndTokenLength; // also the element tag |
|
652 } |
|
653 |
|
654 // --------------------------------------------------------- |
|
655 // CWVSettingsParser::Validate () |
|
656 // --------------------------------------------------------- |
|
657 // |
|
658 TBool CWVSettingsParser::Validate () |
|
659 { |
|
660 TBool errNotFound = ETrue; |
|
661 // mandatory in wvsettings |
|
662 if (!iOTAVersion) |
|
663 errNotFound = EFalse; |
|
664 // mandatory in wvsettings |
|
665 if (!iCommon) |
|
666 errNotFound = EFalse; |
|
667 else |
|
668 { |
|
669 // mandatory in wvcommon |
|
670 if (!iSettingsName) |
|
671 errNotFound = EFalse; |
|
672 // mandatory in wvcommon |
|
673 if (!iSupportedVersions) |
|
674 errNotFound = EFalse; |
|
675 } |
|
676 if (iSms) |
|
677 { |
|
678 // mandatory in wvsms |
|
679 if (!iSAPMobileNumber) |
|
680 errNotFound = EFalse; |
|
681 // mandatory in wvsms |
|
682 if (!iSAP4WaySupportedSms) |
|
683 errNotFound = EFalse; |
|
684 if (!iSMSCMobileNumber) |
|
685 // mandatory in wvsms |
|
686 errNotFound = EFalse; |
|
687 } |
|
688 if (iHttp) |
|
689 { |
|
690 // mandatory in wvhttp |
|
691 if (!iSAPURI) |
|
692 errNotFound = EFalse; |
|
693 // mandatory in wvhttp |
|
694 if (!iSAP4WaySupportedHttp) |
|
695 errNotFound = EFalse; |
|
696 // optional in wvhttp |
|
697 if (iProxy) |
|
698 { |
|
699 // mandatory in wvproxy |
|
700 if (!iProxyAddress) |
|
701 errNotFound = EFalse; |
|
702 } |
|
703 } |
|
704 return errNotFound; |
|
705 } |