|
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: CNcdRequestConfigurationData implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdrequestconfigurationdata.h" |
|
20 #include "ncdrequestconstants.h" |
|
21 #include "ncdprotocolutils.h" |
|
22 #include "ncdprotocolwords.h" |
|
23 #include "ncd_cp_cookie.h" |
|
24 #include "ncd_cp_detail.h" |
|
25 #include "catalogsutils.h" |
|
26 |
|
27 #include "catalogsdebug.h" |
|
28 |
|
29 void CloseStringArray( |
|
30 RArray< TXmlEngString >& aArray ) |
|
31 { |
|
32 TInt count = aArray.Count(); |
|
33 for( TInt i = 0; i < count; i++ ) |
|
34 { |
|
35 aArray[ i ].Free(); |
|
36 } |
|
37 aArray.Close(); |
|
38 } |
|
39 |
|
40 |
|
41 |
|
42 TXmlEngElement GetDetailsElementL( |
|
43 RXmlEngDocument& aDocument, |
|
44 const MNcdConfigurationProtocolDetail& aDetails, |
|
45 const TXmlEngString& aPrefix ) |
|
46 { |
|
47 DLTRACEIN(("")); |
|
48 TXmlEngElement detail = NcdProtocolUtils::NewElementL( |
|
49 aDocument, KTagDetail, aPrefix ); |
|
50 |
|
51 if ( aDetails.GroupId() != KNullDesC ) |
|
52 NcdProtocolUtils::NewAttributeL( detail, KAttrGroupId, |
|
53 aDetails.GroupId() ); |
|
54 |
|
55 if ( aDetails.Label() != KNullDesC ) |
|
56 NcdProtocolUtils::NewAttributeL( detail, KAttrLabel, |
|
57 aDetails.Label() ); |
|
58 |
|
59 if ( aDetails.Id() != KNullDesC ) |
|
60 NcdProtocolUtils::NewAttributeL( detail, KAttrId, |
|
61 aDetails.Id() ); |
|
62 |
|
63 if ( aDetails.Value() != KNullDesC ) |
|
64 NcdProtocolUtils::NewAttributeL( detail, KAttrValue, |
|
65 aDetails.Value() ); |
|
66 |
|
67 for ( TInt j = 0; j < aDetails.Contents().Count(); ++j ) |
|
68 { |
|
69 MNcdConfigurationProtocolContent* cont = aDetails.Contents()[j]; |
|
70 TXmlEngElement content = NcdProtocolUtils::NewElementL( |
|
71 aDocument, detail, KTagContent ); |
|
72 NcdProtocolUtils::NewAttributeL( content, KAttrKey, cont->Key() ); |
|
73 NcdProtocolUtils::NewAttributeL( content, KAttrValue, cont->Value() ); |
|
74 } |
|
75 |
|
76 for ( TInt j = 0; j < aDetails.Details().Count(); ++j ) |
|
77 { |
|
78 // get elements recursively |
|
79 TXmlEngElement child = GetDetailsElementL( aDocument, |
|
80 *(aDetails.Details()[j]), aPrefix ); |
|
81 detail.AppendChildL(child); |
|
82 } |
|
83 /* |
|
84 for ( TInt j = 0; j < aDetails.xmlFragment.Count(); ++j ) |
|
85 { |
|
86 TNcdRequestCustomXmlFragment xmlFrag = aDetails.xmlFragment[j]; |
|
87 TXmlEngElement xmlFragment = detail.AddNewElementL( |
|
88 NcdProtocolUtils::DesToStringL( KTagXmlFragment ) ); |
|
89 } |
|
90 */ |
|
91 DLTRACEOUT(("")); |
|
92 return detail; |
|
93 } |
|
94 |
|
95 |
|
96 /** |
|
97 * Software-element for client-elements |
|
98 */ |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CNcdRequestConfigurationSoftware* CNcdRequestConfigurationSoftware::NewLC() |
|
104 { |
|
105 CNcdRequestConfigurationSoftware* self = new(ELeave) |
|
106 CNcdRequestConfigurationSoftware; |
|
107 CleanupStack::PushL( self ); |
|
108 return self; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 CNcdRequestConfigurationSoftware::~CNcdRequestConfigurationSoftware() |
|
116 { |
|
117 iSoftware.type.Free(); |
|
118 iSoftware.version.Free(); |
|
119 iSoftware.uid.Free(); |
|
120 iSoftware.id.Free(); |
|
121 iSoftware.ssid.Free(); |
|
122 iSoftware.language.Free(); |
|
123 CloseStringArray( iSoftware.capabilities ); |
|
124 iSoftware.details.ResetAndDestroy(); |
|
125 |
|
126 } |
|
127 |
|
128 void CNcdRequestConfigurationSoftware::SetSoftwareTypeL( |
|
129 const TDesC& aType ) |
|
130 { |
|
131 iSoftware.type.SetL(aType); |
|
132 } |
|
133 |
|
134 void CNcdRequestConfigurationSoftware::SetSoftwareVersionL( |
|
135 const TDesC& aVersion ) |
|
136 { |
|
137 DLTRACEIN(("")); |
|
138 iSoftware.version.SetL(aVersion); |
|
139 DLTRACEOUT(("")); |
|
140 } |
|
141 |
|
142 void CNcdRequestConfigurationSoftware::SetSoftwareIdsL( |
|
143 const TDesC& aUid, const TDesC& aId, const TDesC8& aSsid ) |
|
144 { |
|
145 if (aUid != KNullDesC) |
|
146 iSoftware.uid.SetL(aUid); |
|
147 if (aId != KNullDesC) |
|
148 iSoftware.id.SetL(aId); |
|
149 if (aSsid != KNullDesC8) |
|
150 iSoftware.ssid.SetL(aSsid); |
|
151 } |
|
152 |
|
153 void CNcdRequestConfigurationSoftware::SetSoftwareLanguageL( |
|
154 const TDesC& aLanguage ) |
|
155 { |
|
156 iSoftware.language.SetL(aLanguage); |
|
157 } |
|
158 |
|
159 |
|
160 void CNcdRequestConfigurationSoftware::AddSoftwareCapabilityL( |
|
161 const TDesC& aCapability ) |
|
162 { |
|
163 TXmlEngString capability; |
|
164 capability.SetL(aCapability); |
|
165 if ( iSoftware.capabilities.Append(capability) != KErrNone ) |
|
166 { |
|
167 capability.Free(); |
|
168 } |
|
169 } |
|
170 |
|
171 void CNcdRequestConfigurationSoftware::AddSoftwareDetailsL( |
|
172 MNcdConfigurationProtocolDetail* aDetail) |
|
173 { |
|
174 iSoftware.details.AppendL(aDetail); |
|
175 } |
|
176 |
|
177 |
|
178 TXmlEngElement CNcdRequestConfigurationSoftware::GetSoftwareConfigurationElementL( |
|
179 RXmlEngDocument& aDocument, const TXmlEngString& aPrefix ) |
|
180 { |
|
181 DLTRACEIN(("")); |
|
182 TXmlEngElement software = NcdProtocolUtils::NewElementL( aDocument, |
|
183 KTagSoftware, aPrefix ); |
|
184 |
|
185 // software/@version, required |
|
186 NcdProtocolUtils::NewAttributeL(software, KAttrVersion, iSoftware.version); |
|
187 |
|
188 NcdProtocolUtils::NewAttributeL(software, KAttrType, iSoftware.type); |
|
189 |
|
190 if (iSoftware.uid.NotNull()) |
|
191 NcdProtocolUtils::NewAttributeL(software, KAttrUid, iSoftware.uid); |
|
192 |
|
193 if (iSoftware.id.NotNull()) |
|
194 NcdProtocolUtils::NewAttributeL(software, KAttrId, iSoftware.id); |
|
195 |
|
196 if (iSoftware.ssid.NotNull()) |
|
197 NcdProtocolUtils::NewAttributeL(software, KAttrSsid, iSoftware.ssid); |
|
198 |
|
199 if ( iSoftware.language.NotNull() ) |
|
200 { |
|
201 TXmlEngElement language = NcdProtocolUtils::NewElementL( aDocument, |
|
202 software, KTagLanguage, aPrefix ); |
|
203 #ifndef RD_XML_ENGINE_API_CHANGE |
|
204 language.SetTextL( iSoftware.language ); |
|
205 #else |
|
206 language.SetTextL( iSoftware.language.PtrC8() ); |
|
207 #endif |
|
208 } |
|
209 |
|
210 |
|
211 if ( iSoftware.capabilities.Count() > 0 ) |
|
212 { |
|
213 TXmlEngElement capabilities = NcdProtocolUtils::NewElementL( |
|
214 aDocument, software, KTagCapabilities, aPrefix ); |
|
215 |
|
216 for (TInt i = 0; i < iSoftware.capabilities.Count(); ++i) |
|
217 { |
|
218 TXmlEngElement capability = NcdProtocolUtils::NewElementL( |
|
219 aDocument, capabilities, KTagCapability, aPrefix ); |
|
220 |
|
221 #ifndef RD_XML_ENGINE_API_CHANGE |
|
222 capability.SetTextL( iSoftware.capabilities[i] ); |
|
223 #else |
|
224 capability.SetTextL( iSoftware.capabilities[i].PtrC8() ); |
|
225 #endif |
|
226 } |
|
227 } |
|
228 |
|
229 // details |
|
230 if ( iSoftware.details.Count() > 0 ) |
|
231 { |
|
232 TXmlEngElement details = |
|
233 NcdProtocolUtils::NewElementL( aDocument, software, |
|
234 KTagDetails, aPrefix ); |
|
235 |
|
236 for ( TInt i = 0; i < iSoftware.details.Count(); ++i ) |
|
237 { |
|
238 MNcdConfigurationProtocolDetail* det = iSoftware.details[i]; |
|
239 details.AppendChildL( GetDetailsElementL( aDocument, |
|
240 *det, aPrefix ) ); |
|
241 } |
|
242 } |
|
243 |
|
244 DLTRACEOUT(("")); |
|
245 return software; |
|
246 } |
|
247 |
|
248 |
|
249 /** |
|
250 * Hardware-element for client-elements |
|
251 */ |
|
252 |
|
253 CNcdRequestConfigurationHardware* CNcdRequestConfigurationHardware::NewL() |
|
254 { |
|
255 CNcdRequestConfigurationHardware* self = new(ELeave) |
|
256 CNcdRequestConfigurationHardware; |
|
257 return self; |
|
258 } |
|
259 |
|
260 |
|
261 CNcdRequestConfigurationHardware::~CNcdRequestConfigurationHardware() |
|
262 { |
|
263 // Clean iHardware |
|
264 iHardware.uaProfileUri.Free(); |
|
265 iHardware.identification.Free(); |
|
266 iHardware.manufacturer.Free(); |
|
267 iHardware.model.Free(); |
|
268 iHardware.language.Free(); |
|
269 iHardware.platform.Free(); |
|
270 iHardware.firmwareVersion.Free(); |
|
271 iHardware.displays.ResetAndDestroy(); |
|
272 iHardware.details.ResetAndDestroy(); |
|
273 |
|
274 } |
|
275 |
|
276 |
|
277 void CNcdRequestConfigurationHardware::SetHardwareUaProfileUriL( |
|
278 const TDesC& aUaProfileUri ) |
|
279 { |
|
280 iHardware.uaProfileUri.SetL(aUaProfileUri); |
|
281 } |
|
282 |
|
283 void CNcdRequestConfigurationHardware::SetHardwareIdentificationL( |
|
284 const TDesC& aIdentification ) |
|
285 { |
|
286 iHardware.identification.SetL(aIdentification); |
|
287 } |
|
288 |
|
289 void CNcdRequestConfigurationHardware::SetHardwareManufacturerL( |
|
290 const TDesC& aManufacturer ) |
|
291 { |
|
292 iHardware.manufacturer.SetL(aManufacturer); |
|
293 } |
|
294 |
|
295 void CNcdRequestConfigurationHardware::SetHardwareModelL( |
|
296 const TDesC& aModel ) |
|
297 { |
|
298 iHardware.model.SetL(aModel); |
|
299 } |
|
300 |
|
301 void CNcdRequestConfigurationHardware::SetHardwareLanguageL( |
|
302 const TDesC& aLanguage ) |
|
303 { |
|
304 iHardware.language.SetL(aLanguage); |
|
305 } |
|
306 |
|
307 void CNcdRequestConfigurationHardware::SetHardwarePlatformL( |
|
308 const TDesC& aPlatform ) |
|
309 { |
|
310 iHardware.platform.SetL(aPlatform); |
|
311 } |
|
312 |
|
313 void CNcdRequestConfigurationHardware::SetHardwareFirmwareL( |
|
314 const TDesC& aFirmwareVersion ) |
|
315 { |
|
316 iHardware.firmwareVersion.SetL(aFirmwareVersion); |
|
317 } |
|
318 |
|
319 void CNcdRequestConfigurationHardware::AddHardwareDisplayL( |
|
320 TInt aColors, TInt aHeight, TInt aWidth ) |
|
321 { |
|
322 CNcdConfigurationDisplay* disp = new (ELeave) CNcdConfigurationDisplay; |
|
323 disp->iColors = aColors; |
|
324 disp->iHeight = aHeight; |
|
325 disp->iWidth = aWidth; |
|
326 if ( iHardware.displays.Append(disp) != KErrNone ) |
|
327 { |
|
328 delete disp; |
|
329 } |
|
330 } |
|
331 |
|
332 |
|
333 void CNcdRequestConfigurationHardware::AddHardwareDetailsL( |
|
334 MNcdConfigurationProtocolDetail* aDetail ) |
|
335 { |
|
336 iHardware.details.AppendL(aDetail); |
|
337 } |
|
338 |
|
339 |
|
340 TXmlEngElement CNcdRequestConfigurationHardware::GetHardwareConfigurationElementL( |
|
341 RXmlEngDocument& aDocument, const TXmlEngString& aPrefix ) |
|
342 { |
|
343 DLTRACEIN(("")); |
|
344 TXmlEngElement hardware = NcdProtocolUtils::NewElementL( aDocument, |
|
345 KTagHardware, aPrefix ); |
|
346 |
|
347 if (iHardware.uaProfileUri.NotNull()) |
|
348 { |
|
349 TXmlEngElement uaProfileUri = NcdProtocolUtils::NewElementL( |
|
350 aDocument, hardware, KTagUaProfileUri, aPrefix ); |
|
351 |
|
352 #ifndef RD_XML_ENGINE_API_CHANGE |
|
353 uaProfileUri.SetTextL(iHardware.uaProfileUri); |
|
354 #else |
|
355 uaProfileUri.SetTextL( iHardware.uaProfileUri.PtrC8() ); |
|
356 #endif |
|
357 } |
|
358 |
|
359 if (iHardware.identification.NotNull()) |
|
360 { |
|
361 TXmlEngElement identification = NcdProtocolUtils::NewElementL( |
|
362 aDocument, hardware, KTagIdentification, aPrefix ); |
|
363 |
|
364 #ifndef RD_XML_ENGINE_API_CHANGE |
|
365 identification.SetTextL(iHardware.identification); |
|
366 #else |
|
367 identification.SetTextL( iHardware.identification.PtrC8() ); |
|
368 #endif |
|
369 } |
|
370 |
|
371 if (iHardware.manufacturer.NotNull()) |
|
372 { |
|
373 TXmlEngElement manufacturer = NcdProtocolUtils::NewElementL( |
|
374 aDocument, hardware, KTagManufacturer, aPrefix ); |
|
375 #ifndef RD_XML_ENGINE_API_CHANGE |
|
376 manufacturer.SetTextL(iHardware.manufacturer); |
|
377 #else |
|
378 manufacturer.SetTextL( iHardware.manufacturer.PtrC8() ); |
|
379 #endif |
|
380 } |
|
381 |
|
382 if (iHardware.model.NotNull()) |
|
383 { |
|
384 TXmlEngElement model = NcdProtocolUtils::NewElementL( |
|
385 aDocument, hardware, KTagModel, aPrefix ); |
|
386 #ifndef RD_XML_ENGINE_API_CHANGE |
|
387 model.SetTextL(iHardware.model); |
|
388 #else |
|
389 model.SetTextL( iHardware.model.PtrC8() ); |
|
390 #endif |
|
391 } |
|
392 |
|
393 if (iHardware.language.NotNull()) |
|
394 { |
|
395 TXmlEngElement language = NcdProtocolUtils::NewElementL( |
|
396 aDocument, hardware, KTagLanguage, aPrefix ); |
|
397 #ifndef RD_XML_ENGINE_API_CHANGE |
|
398 language.SetTextL(iHardware.language); |
|
399 #else |
|
400 language.SetTextL( iHardware.language.PtrC8() ); |
|
401 #endif |
|
402 } |
|
403 |
|
404 if (iHardware.platform.NotNull()) |
|
405 { |
|
406 TXmlEngElement platform = NcdProtocolUtils::NewElementL( |
|
407 aDocument, hardware, KTagPlatform, aPrefix ); |
|
408 |
|
409 #ifndef RD_XML_ENGINE_API_CHANGE |
|
410 platform.SetTextL(iHardware.platform); |
|
411 #else |
|
412 platform.SetTextL( iHardware.platform.PtrC8() ); |
|
413 #endif |
|
414 } |
|
415 |
|
416 if (iHardware.firmwareVersion.NotNull()) |
|
417 { |
|
418 TXmlEngElement firmwareVersion = NcdProtocolUtils::NewElementL( |
|
419 aDocument, hardware, KTagFirmwareVersion, aPrefix ); |
|
420 #ifndef RD_XML_ENGINE_API_CHANGE |
|
421 firmwareVersion.SetTextL(iHardware.firmwareVersion); |
|
422 #else |
|
423 firmwareVersion.SetTextL( iHardware.firmwareVersion.PtrC8() ); |
|
424 #endif |
|
425 } |
|
426 |
|
427 for (TInt i = 0; i < iHardware.displays.Count(); ++i) |
|
428 { |
|
429 CNcdConfigurationDisplay* disp = iHardware.displays[i]; |
|
430 TXmlEngElement display = NcdProtocolUtils::NewElementL( |
|
431 aDocument, hardware, KTagDisplay, aPrefix ); |
|
432 NcdProtocolUtils::NewAttributeL( display, KAttrWidth, disp->iWidth ); |
|
433 NcdProtocolUtils::NewAttributeL( display, KAttrHeight, disp->iHeight ); |
|
434 NcdProtocolUtils::NewAttributeL( display, KAttrColors, disp->iColors ); |
|
435 } |
|
436 |
|
437 // details |
|
438 if ( iHardware.details.Count() > 0 ) |
|
439 { |
|
440 TXmlEngElement details = NcdProtocolUtils::NewElementL( |
|
441 aDocument, hardware, KTagDetails, aPrefix ); |
|
442 |
|
443 for ( TInt i = 0; i < iHardware.details.Count(); ++i ) |
|
444 { |
|
445 MNcdConfigurationProtocolDetail* det = iHardware.details[i]; |
|
446 details.AppendChildL( GetDetailsElementL( aDocument, |
|
447 *det, aPrefix ) ); |
|
448 } |
|
449 } |
|
450 |
|
451 if (hardware.HasChildNodes()) |
|
452 { |
|
453 DLTRACEOUT(("")); |
|
454 return hardware; |
|
455 } |
|
456 DLTRACEOUT(("return null")); |
|
457 return NULL; |
|
458 } |
|
459 |
|
460 |
|
461 |
|
462 /** |
|
463 * Client-element for configuration requests |
|
464 */ |
|
465 CNcdRequestConfigurationClient* CNcdRequestConfigurationClient::NewLC() |
|
466 { |
|
467 CNcdRequestConfigurationClient* self = new(ELeave) |
|
468 CNcdRequestConfigurationClient; |
|
469 CleanupStack::PushL( self ); |
|
470 self->ConstructL(); |
|
471 return self; |
|
472 } |
|
473 |
|
474 |
|
475 CNcdRequestConfigurationClient::~CNcdRequestConfigurationClient() |
|
476 { |
|
477 iSoftwares.ResetAndDestroy(); |
|
478 delete iHardware; |
|
479 } |
|
480 |
|
481 |
|
482 void CNcdRequestConfigurationClient::AddSoftwareL( |
|
483 CNcdRequestConfigurationSoftware* aSoftware ) |
|
484 { |
|
485 iSoftwares.AppendL( aSoftware ); |
|
486 } |
|
487 |
|
488 TInt CNcdRequestConfigurationClient::SoftwareCount() const |
|
489 { |
|
490 return iSoftwares.Count(); |
|
491 } |
|
492 |
|
493 |
|
494 CNcdRequestConfigurationSoftware& |
|
495 CNcdRequestConfigurationClient::Software( TInt aIndex ) |
|
496 { |
|
497 return *(iSoftwares[ aIndex ]); |
|
498 } |
|
499 |
|
500 |
|
501 CNcdRequestConfigurationHardware& CNcdRequestConfigurationClient::Hardware() |
|
502 { |
|
503 DASSERT( iHardware ); |
|
504 return *iHardware; |
|
505 } |
|
506 |
|
507 |
|
508 CNcdRequestConfigurationClient::CNcdRequestConfigurationClient() |
|
509 { |
|
510 } |
|
511 |
|
512 |
|
513 void CNcdRequestConfigurationClient::ConstructL() |
|
514 { |
|
515 iHardware = CNcdRequestConfigurationHardware::NewL(); |
|
516 } |
|
517 |
|
518 |
|
519 // --------------------------------------------------------------------------- |
|
520 // CNcdRequestConfigurationData |
|
521 // --------------------------------------------------------------------------- |
|
522 // |
|
523 |
|
524 CNcdRequestConfigurationData* CNcdRequestConfigurationData::NewLC() |
|
525 { |
|
526 CNcdRequestConfigurationData* self = |
|
527 new (ELeave) CNcdRequestConfigurationData(); |
|
528 CleanupStack::PushL(self); |
|
529 |
|
530 return self; |
|
531 } |
|
532 |
|
533 |
|
534 CNcdRequestConfigurationData::CNcdRequestConfigurationData() |
|
535 { |
|
536 } |
|
537 |
|
538 |
|
539 CNcdRequestConfigurationData::~CNcdRequestConfigurationData() |
|
540 { |
|
541 DLTRACEIN(("")); |
|
542 /* |
|
543 * @ TXmlEngString members need to be Freed! |
|
544 */ |
|
545 |
|
546 iQueryResponseId.Free(); |
|
547 iPrefix.Free(); |
|
548 |
|
549 iCookies.ResetAndDestroy(); |
|
550 ResetAndCloseArray( iQueryResponses ); |
|
551 |
|
552 // Clean iNetwork |
|
553 iNetwork.mcc.Free(); |
|
554 iNetwork.mnc.Free(); |
|
555 iNetwork.currentMcc.Free(); |
|
556 iNetwork.currentMnc.Free(); |
|
557 iNetwork.gid1.Free(); |
|
558 iNetwork.gid2.Free(); |
|
559 iNetwork.smsc.Free(); |
|
560 iNetwork.imsi.Free(); |
|
561 iNetwork.msisdn.Free(); |
|
562 iNetwork.cellId.Free(); |
|
563 iNetwork.serviceProviderName.Free(); |
|
564 iNetwork.operatorName.Free(); |
|
565 iNetwork.details.ResetAndDestroy(); |
|
566 |
|
567 iClients.ResetAndDestroy(); |
|
568 DLTRACEOUT(("")); |
|
569 } |
|
570 |
|
571 |
|
572 void CNcdRequestConfigurationData::SetNamespacePrefixL( |
|
573 const TDesC8& aPrefix) |
|
574 { |
|
575 if ( aPrefix == KNullDesC8 ) |
|
576 { |
|
577 iPrefix.Free(); |
|
578 iPrefix = TXmlEngString(); |
|
579 } |
|
580 else |
|
581 { |
|
582 iPrefix.SetL(aPrefix); |
|
583 } |
|
584 } |
|
585 |
|
586 void CNcdRequestConfigurationData::AddCookieL( |
|
587 MNcdConfigurationProtocolCookie* aCookie) |
|
588 { |
|
589 DLTRACEIN(("")); |
|
590 iCookies.AppendL(aCookie); |
|
591 } |
|
592 |
|
593 void CNcdRequestConfigurationData::AddQueryResponseL( |
|
594 TNcdConfigurationQueryResponse aQueryResponse) |
|
595 { |
|
596 iQueryResponses.AppendL(aQueryResponse); |
|
597 } |
|
598 |
|
599 |
|
600 void CNcdRequestConfigurationData::AddClientL( |
|
601 CNcdRequestConfigurationClient* aClient ) |
|
602 { |
|
603 DLTRACEIN(("")); |
|
604 iClients.AppendL( aClient ); |
|
605 } |
|
606 |
|
607 TXmlEngElement CNcdRequestConfigurationData::GetConfigurationElementL( |
|
608 RXmlEngDocument& aDocument) |
|
609 { |
|
610 DLTRACEIN(("")); |
|
611 TXmlEngElement configRoot = NcdProtocolUtils::NewElementL( aDocument, KTagConfiguration ); |
|
612 |
|
613 TXmlEngElement network = GetNetworkConfigurationElementL( aDocument ); |
|
614 if (network.NotNull()) |
|
615 configRoot.AppendChildL(network); |
|
616 |
|
617 DLTRACE(("Add %d client-infos", iClients.Count() )); |
|
618 for ( TInt i = 0; i < iClients.Count(); ++i ) |
|
619 { |
|
620 TXmlEngElement client = GetClientConfigurationElementL( aDocument, i ); |
|
621 if ( client.NotNull() ) |
|
622 configRoot.AppendChildL( client ); |
|
623 } |
|
624 |
|
625 if (configRoot.HasChildNodes()) |
|
626 { |
|
627 DLTRACEOUT(("")); |
|
628 return configRoot; |
|
629 } |
|
630 DLTRACEOUT(("return null")); |
|
631 return NULL; |
|
632 } |
|
633 |
|
634 |
|
635 TXmlEngElement CNcdRequestConfigurationData::GetCookiesElementL( |
|
636 RXmlEngDocument& aDocument) |
|
637 { |
|
638 DLTRACEIN(("")); |
|
639 if (iCookies.Count() == 0) |
|
640 { |
|
641 DLTRACEOUT(("no cookies")); |
|
642 return NULL; |
|
643 } |
|
644 |
|
645 TXmlEngElement cookies = NcdProtocolUtils::NewElementL( aDocument, KTagCookies, iPrefix ); |
|
646 |
|
647 for (TInt i = 0; i < iCookies.Count(); ++i) |
|
648 { |
|
649 MNcdConfigurationProtocolCookie* cookie = iCookies[i]; |
|
650 TXmlEngElement cookieElem = |
|
651 NcdProtocolUtils::NewElementL( aDocument, cookies, KTagCookie, iPrefix ); |
|
652 |
|
653 NcdProtocolUtils::NewAttributeL( cookieElem, KAttrKey, |
|
654 cookie->Key() ); |
|
655 |
|
656 // These are not supposed to be sent to the server |
|
657 /* |
|
658 NcdProtocolUtils::NewAttributeL( cookieElem, KAttrType, |
|
659 cookie->Type() ); |
|
660 NcdProtocolUtils::NewAttributeL( cookieElem, KAttrExpirationDelta, cookie->ExpirationDelta() ); |
|
661 NcdProtocolUtils::NewAttributeL( cookieElem, KAttrScope, |
|
662 cookie->Scope() ); |
|
663 */ |
|
664 |
|
665 // Add cookie values |
|
666 for ( TInt j = 0; j < cookie->ValueCount(); ++j ) |
|
667 { |
|
668 TXmlEngElement value = |
|
669 NcdProtocolUtils::NewElementL( aDocument, cookieElem, KTagValue, iPrefix ); |
|
670 #ifndef RD_XML_ENGINE_API_CHANGE |
|
671 value.SetTextL( cookie->Value(j) ); |
|
672 #else |
|
673 HBufC8* tempBuf = NcdProtocolUtils::ConvertUnicodeToUtf8L( cookie->Value(j) ); |
|
674 CleanupStack::PushL( tempBuf ); |
|
675 value.SetTextL( *tempBuf ); |
|
676 CleanupStack::PopAndDestroy( tempBuf ); |
|
677 #endif |
|
678 } |
|
679 } |
|
680 |
|
681 DLTRACEOUT(("")); |
|
682 return cookies; |
|
683 } |
|
684 |
|
685 |
|
686 TXmlEngElement CNcdRequestConfigurationData::GetQueryResponseElementL( |
|
687 RXmlEngDocument& aDocument) |
|
688 { |
|
689 DLTRACEIN(("")); |
|
690 if (iQueryResponses.Count() == 0) |
|
691 { |
|
692 DLTRACEOUT(("return null")); |
|
693 return NULL; |
|
694 } |
|
695 |
|
696 TXmlEngElement queryResponse = NcdProtocolUtils::NewElementL( aDocument, KTagQueryResponse, iPrefix ); |
|
697 NcdProtocolUtils::NewAttributeL( queryResponse, KAttrId, |
|
698 iQueryResponseId ); |
|
699 |
|
700 for (TInt i = 0; i < iQueryResponses.Count(); ++i) |
|
701 { |
|
702 TNcdConfigurationQueryResponse resp = iQueryResponses[i]; |
|
703 TXmlEngElement response = NcdProtocolUtils::NewElementL( aDocument, queryResponse, KTagResponse, iPrefix ); |
|
704 NcdProtocolUtils::NewAttributeL( response, KAttrId, resp.id); |
|
705 TXmlEngElement value = NcdProtocolUtils::NewElementL( aDocument, response, KTagValue, iPrefix ); |
|
706 #ifndef RD_XML_ENGINE_API_CHANGE |
|
707 value.SetTextL(resp.semantics); |
|
708 #else |
|
709 value.SetTextL( resp.semantics.PtrC8() ); |
|
710 #endif |
|
711 } |
|
712 |
|
713 DLTRACEOUT(("")); |
|
714 return queryResponse; |
|
715 } |
|
716 |
|
717 TXmlEngElement CNcdRequestConfigurationData::GetNetworkConfigurationElementL( |
|
718 RXmlEngDocument& aDocument) |
|
719 { |
|
720 DLTRACEIN(( "" )); |
|
721 TXmlEngElement network = NcdProtocolUtils::NewElementL( aDocument, KTagNetwork ); |
|
722 |
|
723 // network configuration |
|
724 if ( iNetwork.mcc.NotNull() ) |
|
725 NcdProtocolUtils::NewAttributeL( network, KAttrMcc, iNetwork.mcc ); |
|
726 |
|
727 if ( iNetwork.mnc.NotNull() ) |
|
728 NcdProtocolUtils::NewAttributeL( network, KAttrMnc, iNetwork.mnc ); |
|
729 |
|
730 if ( iNetwork.currentMcc.NotNull() ) |
|
731 NcdProtocolUtils::NewAttributeL( network, KAttrCurrentMcc, iNetwork.currentMcc ); |
|
732 |
|
733 if ( iNetwork.currentMnc.NotNull() ) |
|
734 NcdProtocolUtils::NewAttributeL( network, KAttrCurrentMnc, iNetwork.currentMnc ); |
|
735 |
|
736 if ( iNetwork.gid1.NotNull() ) |
|
737 NcdProtocolUtils::NewAttributeL( network, KAttrGid1, iNetwork.gid1 ); |
|
738 |
|
739 if ( iNetwork.gid2.NotNull() ) |
|
740 NcdProtocolUtils::NewAttributeL( network, KAttrGid2, iNetwork.gid2 ); |
|
741 |
|
742 if ( iNetwork.smsc.NotNull() ) |
|
743 NcdProtocolUtils::NewAttributeL( network, KAttrSmsc, iNetwork.smsc ); |
|
744 |
|
745 if ( iNetwork.imsi.NotNull() ) |
|
746 NcdProtocolUtils::NewAttributeL( network, KAttrImsi, iNetwork.imsi ); |
|
747 |
|
748 if ( iNetwork.serviceProviderName.NotNull() ) |
|
749 { |
|
750 TXmlEngElement serviceProviderName = |
|
751 NcdProtocolUtils::NewElementL( aDocument, network, KTagServiceProviderName, iPrefix ); |
|
752 #ifndef RD_XML_ENGINE_API_CHANGE |
|
753 serviceProviderName.SetTextL( iNetwork.serviceProviderName ); |
|
754 #else |
|
755 serviceProviderName.SetTextL( iNetwork.serviceProviderName.PtrC8() ); |
|
756 #endif |
|
757 } |
|
758 |
|
759 if ( iNetwork.operatorName.NotNull() ) |
|
760 { |
|
761 TXmlEngElement operatorName = |
|
762 NcdProtocolUtils::NewElementL( aDocument, network, KTagOperatorName, iPrefix ); |
|
763 #ifndef RD_XML_ENGINE_API_CHANGE |
|
764 operatorName.SetTextL( iNetwork.operatorName ); |
|
765 #else |
|
766 operatorName.SetTextL( iNetwork.operatorName.PtrC8() ); |
|
767 #endif |
|
768 } |
|
769 |
|
770 if ( iNetwork.details.Count() > 0 ) |
|
771 { |
|
772 TXmlEngElement details = |
|
773 NcdProtocolUtils::NewElementL( aDocument, network, KTagDetails, iPrefix ); |
|
774 |
|
775 for ( TInt i = 0; i < iNetwork.details.Count(); ++i ) |
|
776 { |
|
777 MNcdConfigurationProtocolDetail* det = iNetwork.details[i]; |
|
778 details.AppendChildL( GetDetailsElementL( aDocument, |
|
779 *det, iPrefix ) ); |
|
780 } |
|
781 } |
|
782 |
|
783 if (network.HasChildNodes()) |
|
784 { |
|
785 DLTRACEOUT(( "" )); |
|
786 return network; |
|
787 } |
|
788 DLTRACEOUT(( "return null" )); |
|
789 return NULL; |
|
790 } |
|
791 |
|
792 |
|
793 TInt CNcdRequestConfigurationData::ClientConfigurationCount() const |
|
794 { |
|
795 return iClients.Count(); |
|
796 } |
|
797 |
|
798 |
|
799 TXmlEngElement CNcdRequestConfigurationData::GetClientConfigurationElementL( |
|
800 RXmlEngDocument& aDocument, TInt aIndex ) |
|
801 { |
|
802 DLTRACEIN(("")); |
|
803 // client, required |
|
804 TXmlEngElement client = NcdProtocolUtils::NewElementL( aDocument, KTagClient ); |
|
805 |
|
806 CNcdRequestConfigurationClient& confClient( *iClients[aIndex] ); |
|
807 |
|
808 DLTRACE(("Adding %d software-elements", confClient.SoftwareCount() )); |
|
809 |
|
810 for ( TInt i = 0; i < confClient.SoftwareCount(); ++i ) |
|
811 { |
|
812 TXmlEngElement software = confClient.Software( |
|
813 i ).GetSoftwareConfigurationElementL( aDocument, iPrefix ); |
|
814 client.AppendChildL(software); |
|
815 } |
|
816 |
|
817 DLTRACE(("Adding hardware element")); |
|
818 TXmlEngElement hardware = |
|
819 confClient.Hardware().GetHardwareConfigurationElementL( aDocument, |
|
820 iPrefix ); |
|
821 |
|
822 if (hardware.NotNull()) |
|
823 client.AppendChildL(hardware); |
|
824 |
|
825 if (client.HasChildNodes()) |
|
826 { |
|
827 DLTRACEOUT(("")); |
|
828 return client; |
|
829 } |
|
830 DLTRACEOUT(("return null")); |
|
831 return NULL; |
|
832 } |
|
833 |
|
834 |
|
835 |
|
836 void CNcdRequestConfigurationData::SetNetworkMccL( |
|
837 const TDesC& aMcc, const TDesC& aCurrentMcc ) |
|
838 { |
|
839 if (aMcc != KNullDesC) |
|
840 iNetwork.mcc.SetL(aMcc); |
|
841 if (aCurrentMcc != KNullDesC) |
|
842 iNetwork.currentMcc.SetL(aCurrentMcc); |
|
843 } |
|
844 |
|
845 void CNcdRequestConfigurationData::SetNetworkMncL( |
|
846 const TDesC& aMnc, const TDesC& aCurrentMnc ) |
|
847 { |
|
848 if (aMnc != KNullDesC) |
|
849 iNetwork.mnc.SetL(aMnc); |
|
850 if (aCurrentMnc != KNullDesC) |
|
851 iNetwork.currentMnc.SetL(aCurrentMnc); |
|
852 } |
|
853 |
|
854 void CNcdRequestConfigurationData::SetNetworkGidL( |
|
855 const TDesC& aGid1, const TDesC& aGid2 ) |
|
856 { |
|
857 if (aGid1 != KNullDesC) |
|
858 iNetwork.gid1.SetL(aGid1); |
|
859 if (aGid2 != KNullDesC) |
|
860 iNetwork.gid2.SetL(aGid2); |
|
861 } |
|
862 |
|
863 void CNcdRequestConfigurationData::SetNetworkSmscL( |
|
864 const TDesC& aSmsc ) |
|
865 { |
|
866 iNetwork.smsc.SetL(aSmsc); |
|
867 } |
|
868 |
|
869 void CNcdRequestConfigurationData::SetNetworkImsiL( |
|
870 const TDesC& aImsi ) |
|
871 { |
|
872 iNetwork.imsi.SetL(aImsi); |
|
873 } |
|
874 |
|
875 void CNcdRequestConfigurationData::SetNetworkMsisdnL( |
|
876 const TDesC& aMsisdn ) |
|
877 { |
|
878 iNetwork.msisdn.SetL(aMsisdn); |
|
879 } |
|
880 |
|
881 void CNcdRequestConfigurationData::SetNetworkCellIdL( |
|
882 const TDesC& aCellId ) |
|
883 { |
|
884 iNetwork.cellId.SetL(aCellId); |
|
885 } |
|
886 |
|
887 void CNcdRequestConfigurationData::SetNetworkProviderL( |
|
888 const TDesC& aServiceProviderName ) |
|
889 { |
|
890 iNetwork.serviceProviderName.SetL(aServiceProviderName); |
|
891 } |
|
892 |
|
893 void CNcdRequestConfigurationData::SetNetworkOperatorL( |
|
894 const TDesC& aOperatorName ) |
|
895 { |
|
896 iNetwork.operatorName.SetL(aOperatorName); |
|
897 } |
|
898 |
|
899 void CNcdRequestConfigurationData::AddNetworkDetailsL( |
|
900 MNcdConfigurationProtocolDetail* aDetail ) |
|
901 { |
|
902 iNetwork.details.AppendL(aDetail); |
|
903 } |
|
904 |
|
905 |