|
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: Implementation of CDmAdRtNodeData. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <utf.h> |
|
21 |
|
22 #include "DmAdRtNodeData.h" |
|
23 #include "dmadddf.h" |
|
24 #include "dmadutil.h" |
|
25 #include "vpnlogger.h" |
|
26 |
|
27 CDmAdRtNodeData* CDmAdRtNodeData::NewL(const TDesC8& aUri, MDmAdCallBack* aCallBack) |
|
28 { |
|
29 TRACE("CDmAdRtNodeData::NewL"); |
|
30 |
|
31 CDmAdRtNodeData *self = new (ELeave) CDmAdRtNodeData(); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(aUri, aCallBack); |
|
34 CleanupStack::Pop(); // self |
|
35 return self; |
|
36 } |
|
37 |
|
38 void CDmAdRtNodeData::ConstructL(const TDesC8& aUri, MDmAdCallBack* aCallBack) |
|
39 { |
|
40 TRACE("CDmAdRtNodeData::ConstructL"); |
|
41 |
|
42 iUriType = UriTypeL(aUri); |
|
43 |
|
44 switch (iUriType) |
|
45 { |
|
46 case EDmAdUriTypeVpnAp: |
|
47 u.iVpnAp = CDmAdVpnApData::NewL(aCallBack); |
|
48 break; |
|
49 case EDmAdUriTypePolicy: |
|
50 u.iPolicy = CDmAdPolicyData::NewL(); |
|
51 break; |
|
52 default: |
|
53 DEBUG_LOG(_L("Unknown URI type")); |
|
54 User::Leave(KErrGeneral); |
|
55 break; |
|
56 } |
|
57 } |
|
58 |
|
59 CDmAdRtNodeData::CDmAdRtNodeData() |
|
60 { |
|
61 TRACE("CDmAdRtNodeData::CDmAdRtNodeData"); |
|
62 } |
|
63 |
|
64 CDmAdRtNodeData::~CDmAdRtNodeData() |
|
65 { |
|
66 TRACE("CDmAdRtNodeData::~CDmAdRtNodeData"); |
|
67 |
|
68 switch (iUriType) |
|
69 { |
|
70 case EDmAdUriTypeVpnAp: |
|
71 delete u.iVpnAp; |
|
72 break; |
|
73 case EDmAdUriTypePolicy: |
|
74 delete u.iPolicy; |
|
75 break; |
|
76 default: |
|
77 DEBUG_LOG(_L("Unknown URI type")); |
|
78 User::Invariant(); |
|
79 break; |
|
80 } |
|
81 } |
|
82 |
|
83 //-------------------------------------------------------------------------- |
|
84 |
|
85 TDmAdUriType CDmAdRtNodeData::UriType(void) const |
|
86 { |
|
87 TRACE("CDmAdRtNodeData::UriType"); |
|
88 return iUriType; |
|
89 } |
|
90 |
|
91 TDmAdUriType CDmAdRtNodeData::UriTypeL(const TDesC8& aUri) |
|
92 { |
|
93 TRACE("CDmAdRtNodeData::UriTypeL"); |
|
94 |
|
95 TDmAdUriType ret = EDmAdUriTypeVpnAp; |
|
96 CArrayFix<TPtrC8>* uriSegList; |
|
97 TDmAdUtil::ParseUriLC(aUri, uriSegList); |
|
98 |
|
99 if (uriSegList->Count() < 2) |
|
100 { |
|
101 DEBUG_LOG(_L("Uri seg count < 2")); |
|
102 User::Leave(KErrGeneral); |
|
103 } |
|
104 |
|
105 if (uriSegList->At(0).Compare(KDmAdNodeNokiaIpSecVpn) == 0) |
|
106 { |
|
107 if (uriSegList->At(1).Compare(KDmAdNodePolicy) == 0) |
|
108 { |
|
109 ret = EDmAdUriTypePolicy; |
|
110 } |
|
111 else if (uriSegList->At(1).Compare(KDmAdNodeAp) == 0) |
|
112 { |
|
113 ret = EDmAdUriTypeVpnAp; |
|
114 } |
|
115 else |
|
116 { |
|
117 DEBUG_LOG(_L("Unknown URI element")); |
|
118 User::Leave(KErrGeneral); |
|
119 } |
|
120 } |
|
121 else |
|
122 { |
|
123 DEBUG_LOG(_L("Unknown URI element")); |
|
124 User::Leave(KErrGeneral); |
|
125 } |
|
126 |
|
127 CleanupStack::PopAndDestroy(); // uriSegList |
|
128 return ret; |
|
129 } |
|
130 |
|
131 //-------------------------------------------------------------------------- |
|
132 |
|
133 void CDmAdRtNodeData::UpdateLeafDataL(const TDesC8& aUri, const TDesC8& aObject) |
|
134 { |
|
135 TRACE("CDmAdRtNodeData::UpdateLeafDataL"); |
|
136 |
|
137 switch (iUriType) |
|
138 { |
|
139 case EDmAdUriTypeVpnAp: |
|
140 UpdateLeafDataVpnApL(aUri, aObject); |
|
141 break; |
|
142 case EDmAdUriTypePolicy: |
|
143 UpdateLeafDataPolicyL(aUri, aObject); |
|
144 break; |
|
145 default: |
|
146 DEBUG_LOG(_L("Unknown URI type")); |
|
147 User::Leave(KErrGeneral); |
|
148 break; |
|
149 } |
|
150 } |
|
151 |
|
152 void CDmAdRtNodeData::UpdateLeafDataVpnApL(const TDesC8& aUri, const TDesC8& aObject) |
|
153 { |
|
154 TRACE("CDmAdRtNodeData::UpdateLeafDataVpnApL"); |
|
155 |
|
156 TPtrC8 lastSeg = TDmAdUtil::LastUriSeg(aUri); |
|
157 if (lastSeg.Compare(KDmAdLeafName) == 0) |
|
158 { |
|
159 u.iVpnAp->SetNameL(aObject); |
|
160 } |
|
161 else if (lastSeg.Compare(KDmAdLeafId) == 0) |
|
162 { |
|
163 HBufC* policyRef = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aObject); |
|
164 CleanupStack::PushL(policyRef); |
|
165 u.iVpnAp->SetPolicyRefIdL(*policyRef); |
|
166 CleanupStack::PopAndDestroy(policyRef); |
|
167 } |
|
168 else if (lastSeg.Compare(KDmAdLeafConRef) == 0) |
|
169 { |
|
170 u.iVpnAp->SetConRefL(aObject); |
|
171 } |
|
172 else |
|
173 { |
|
174 DEBUG_LOG(_L("Node not found")); |
|
175 User::Leave(KErrNotFound); |
|
176 } |
|
177 } |
|
178 |
|
179 void CDmAdRtNodeData::UpdateLeafDataPolicyL(const TDesC8& aUri, const TDesC8& aObject) |
|
180 { |
|
181 TRACE("CDmAdRtNodeData::UpdateLeafDataPolicyL"); |
|
182 |
|
183 TPtrC8 lastSeg = TDmAdUtil::LastUriSeg(aUri); |
|
184 if (lastSeg.Compare(KDmAdLeafName) == 0) |
|
185 { |
|
186 u.iPolicy->SetNameL(aObject); |
|
187 } |
|
188 else if (lastSeg.Compare(KDmAdLeafId) == 0) |
|
189 { |
|
190 u.iPolicy->SetIdL(aObject); |
|
191 } |
|
192 else if (lastSeg.Compare(KDmAdLeafVersion) == 0) |
|
193 { |
|
194 u.iPolicy->SetVersionL(aObject); |
|
195 } |
|
196 else if (lastSeg.Compare(KDmAdLeafDescription) == 0) |
|
197 { |
|
198 u.iPolicy->SetDescriptionL(aObject); |
|
199 } |
|
200 else if (lastSeg.Compare(KDmAdLeafIssuer) == 0) |
|
201 { |
|
202 u.iPolicy->SetIssuerL(aObject); |
|
203 } |
|
204 else if (lastSeg.Compare(KDmAdLeafContact) == 0) |
|
205 { |
|
206 u.iPolicy->SetContactL(aObject); |
|
207 } |
|
208 else if (lastSeg.Compare(KDmAdLeafContent) == 0) |
|
209 { |
|
210 u.iPolicy->SetContentL(aObject); |
|
211 } |
|
212 else |
|
213 { |
|
214 DEBUG_LOG(_L("Node not found")); |
|
215 User::Leave(KErrNotFound); |
|
216 } |
|
217 } |
|
218 |
|
219 void CDmAdRtNodeData::FetchLeafObjectLC(const TDesC8& aUri, const TDesC8& aLuid, CBufBase*& aObject) |
|
220 { |
|
221 switch (iUriType) |
|
222 { |
|
223 case EDmAdUriTypeVpnAp: |
|
224 FetchLeafObjectVpnApLC(aUri, aLuid, aObject); |
|
225 break; |
|
226 case EDmAdUriTypePolicy: |
|
227 FetchLeafObjectPolicyLC(aUri, aLuid, aObject); |
|
228 break; |
|
229 default: |
|
230 DEBUG_LOG(_L("Unknown URI type")); |
|
231 User::Leave(KErrGeneral); |
|
232 break; |
|
233 } |
|
234 } |
|
235 |
|
236 void CDmAdRtNodeData::FetchLeafObjectVpnApLC(const TDesC8& aUri, const TDesC8& aLuid, CBufBase*& aObject) |
|
237 { |
|
238 CBufBase* object = CBufFlat::NewL(32); |
|
239 CleanupStack::PushL(object); |
|
240 |
|
241 TPtrC8 lastSeg = TDmAdUtil::LastUriSeg(aUri); |
|
242 if (lastSeg.Compare(KDmAdLeafName) == 0) |
|
243 { |
|
244 HBufC8* obj = u.iVpnAp->NameLC(); |
|
245 object->InsertL(0, *obj); |
|
246 CleanupStack::PopAndDestroy(); //obj |
|
247 } |
|
248 else if (lastSeg.Compare(KDmAdLeafThisRef) == 0) |
|
249 { |
|
250 HBufC8* obj = u.iVpnAp->ThisRefLC(aLuid); |
|
251 object->InsertL(0, *obj); |
|
252 CleanupStack::PopAndDestroy(); //obj |
|
253 } |
|
254 else if (lastSeg.Compare(KDmAdLeafId) == 0) |
|
255 { |
|
256 HBufC* policyRef = u.iVpnAp->PolicyRefIdLC(); |
|
257 HBufC8* obj = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*policyRef); |
|
258 CleanupStack::PushL(obj); |
|
259 object->InsertL(0, *obj); |
|
260 CleanupStack::PopAndDestroy(obj); |
|
261 CleanupStack::PopAndDestroy(policyRef); |
|
262 } |
|
263 else if (lastSeg.Compare(KDmAdLeafUri) == 0) |
|
264 { |
|
265 HBufC8* obj = u.iVpnAp->PolicyRefUriLC(); |
|
266 object->InsertL(0, *obj); |
|
267 CleanupStack::PopAndDestroy(); //obj |
|
268 } |
|
269 else if (lastSeg.Compare(KDmAdLeafConRef) == 0) |
|
270 { |
|
271 HBufC8* obj = u.iVpnAp->ConRefLC(); |
|
272 object->InsertL(0, *obj); |
|
273 CleanupStack::PopAndDestroy(); //obj |
|
274 } |
|
275 else |
|
276 { |
|
277 DEBUG_LOG(_L("Node not found")); |
|
278 User::Leave(KErrNotFound); |
|
279 } |
|
280 |
|
281 aObject = object; |
|
282 } |
|
283 |
|
284 void CDmAdRtNodeData::FetchLeafObjectPolicyLC(const TDesC8& aUri, const TDesC8& aLuid, CBufBase*& aObject) |
|
285 { |
|
286 (void)aLuid; |
|
287 CBufBase* object = CBufFlat::NewL(32); |
|
288 CleanupStack::PushL(object); |
|
289 |
|
290 TPtrC8 lastSeg = TDmAdUtil::LastUriSeg(aUri); |
|
291 if (lastSeg.Compare(KDmAdLeafName) == 0) |
|
292 { |
|
293 HBufC8* obj = u.iPolicy->NameLC(); |
|
294 object->InsertL(0, *obj); |
|
295 CleanupStack::PopAndDestroy(); //obj |
|
296 } |
|
297 else if (lastSeg.Compare(KDmAdLeafId) == 0) |
|
298 { |
|
299 HBufC8* obj = u.iPolicy->IdLC(); |
|
300 object->InsertL(0, *obj); |
|
301 CleanupStack::PopAndDestroy(); //obj |
|
302 } |
|
303 else if (lastSeg.Compare(KDmAdLeafVersion) == 0) |
|
304 { |
|
305 HBufC8* obj = u.iPolicy->VersionLC(); |
|
306 object->InsertL(0, *obj); |
|
307 CleanupStack::PopAndDestroy(); //obj |
|
308 } |
|
309 else if (lastSeg.Compare(KDmAdLeafDescription) == 0) |
|
310 { |
|
311 HBufC8* obj = u.iPolicy->DescriptionLC(); |
|
312 object->InsertL(0, *obj); |
|
313 CleanupStack::PopAndDestroy(); //obj |
|
314 } |
|
315 else if (lastSeg.Compare(KDmAdLeafIssuer) == 0) |
|
316 { |
|
317 HBufC8* obj = u.iPolicy->IssuerLC(); |
|
318 object->InsertL(0, *obj); |
|
319 CleanupStack::PopAndDestroy(); //obj |
|
320 } |
|
321 else if (lastSeg.Compare(KDmAdLeafContact) == 0) |
|
322 { |
|
323 HBufC8* obj = u.iPolicy->ContactLC(); |
|
324 object->InsertL(0, *obj); |
|
325 CleanupStack::PopAndDestroy(); //obj |
|
326 } |
|
327 else if (lastSeg.Compare(KDmAdLeafContent) == 0) |
|
328 { |
|
329 TPtrC8 obj(u.iPolicy->Content()); |
|
330 object->InsertL(0, obj); |
|
331 } |
|
332 else |
|
333 { |
|
334 DEBUG_LOG(_L("Node not found")); |
|
335 User::Leave(KErrNotFound); |
|
336 } |
|
337 |
|
338 aObject = object; |
|
339 } |
|
340 |
|
341 |
|
342 //====================================================================================== |
|
343 //====================================================================================== |
|
344 |
|
345 CDmAdVpnApData* CDmAdVpnApData::NewL(MDmAdCallBack* aCallBack) |
|
346 { |
|
347 TRACE("CDmAdVpnApData::NewL"); |
|
348 |
|
349 CDmAdVpnApData *self = new (ELeave) CDmAdVpnApData(aCallBack); |
|
350 return self; |
|
351 } |
|
352 |
|
353 |
|
354 CDmAdVpnApData::CDmAdVpnApData(MDmAdCallBack* aCallBack) : iCallBack(aCallBack) |
|
355 { |
|
356 TRACE("CDmAdVpnApData::CDmAdVpnApData"); |
|
357 } |
|
358 |
|
359 CDmAdVpnApData::~CDmAdVpnApData() |
|
360 { |
|
361 TRACE("CDmAdVpnApData::~CDmAdVpnApData"); |
|
362 |
|
363 delete iName; |
|
364 delete iPolicyRefId; |
|
365 delete iConRef; |
|
366 } |
|
367 |
|
368 void CDmAdVpnApData::SetNameL(const TDesC8& aName) |
|
369 { |
|
370 TRACE("CDmAdVpnApData::SetNameL"); |
|
371 |
|
372 delete iName; |
|
373 iName = NULL; |
|
374 if (aName.Length() > 0) |
|
375 { |
|
376 iName = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aName); |
|
377 } |
|
378 } |
|
379 |
|
380 HBufC8* CDmAdVpnApData::NameLC(void) |
|
381 { |
|
382 if (iName == 0) |
|
383 { |
|
384 return HBufC8::NewLC(1); |
|
385 } |
|
386 HBufC8* ret = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*iName); |
|
387 CleanupStack::PushL(ret); |
|
388 return ret; |
|
389 } |
|
390 |
|
391 void CDmAdVpnApData::SetPolicyRefIdL(const TDesC& aPolicyRefId) |
|
392 { |
|
393 TRACE("CDmAdVpnApData::SetPolicyRefIdL"); |
|
394 |
|
395 delete iPolicyRefId; |
|
396 iPolicyRefId = 0; |
|
397 if (aPolicyRefId.Length() > 0) |
|
398 { |
|
399 iPolicyRefId = aPolicyRefId.AllocL(); |
|
400 } |
|
401 } |
|
402 |
|
403 HBufC* CDmAdVpnApData::PolicyRefIdLC(void) |
|
404 { |
|
405 if (iPolicyRefId == 0) |
|
406 { |
|
407 return HBufC::NewLC(1); |
|
408 } |
|
409 HBufC* ret = iPolicyRefId->AllocLC(); |
|
410 return ret; |
|
411 } |
|
412 |
|
413 void CDmAdVpnApData::SetConRefL(const TDesC8& aConRef) |
|
414 { |
|
415 TRACE("CDmAdVpnApData::SetConRefL"); |
|
416 |
|
417 delete iConRef; |
|
418 iConRef = 0; |
|
419 if (aConRef.Length() > 0) |
|
420 { |
|
421 iConRef = aConRef.AllocL(); |
|
422 } |
|
423 } |
|
424 |
|
425 HBufC8* CDmAdVpnApData::ConRefLC(void) |
|
426 { |
|
427 if (iConRef == 0) |
|
428 { |
|
429 return HBufC8::NewLC(1); |
|
430 } |
|
431 HBufC8* ret = iConRef->AllocLC(); |
|
432 return ret; |
|
433 } |
|
434 |
|
435 HBufC8* CDmAdVpnApData::ThisRefLC(const TDesC8& aLuid) |
|
436 { |
|
437 HBufC8* thisRef = iCallBack->FindChildUriL(KDmAdFetchLinkAp, aLuid); |
|
438 if (thisRef == 0) |
|
439 { |
|
440 return HBufC8::NewLC(1); |
|
441 } |
|
442 CleanupStack::PushL(thisRef); |
|
443 return thisRef; |
|
444 } |
|
445 |
|
446 HBufC8* CDmAdVpnApData::PolicyRefUriLC(void) |
|
447 { |
|
448 if (iPolicyRefId == 0) |
|
449 { |
|
450 return HBufC8::NewLC(1); |
|
451 } |
|
452 |
|
453 const TPtrC8 policyLuid((const TUint8*)iPolicyRefId->Ptr(), iPolicyRefId->Size()); |
|
454 HBufC8* refUri = iCallBack->FindChildUriL(KDmAdFetchLinkPolicy, policyLuid); |
|
455 if (refUri == 0) |
|
456 { |
|
457 return HBufC8::NewLC(1); |
|
458 } |
|
459 CleanupStack::PushL(refUri); |
|
460 return refUri; |
|
461 } |
|
462 |
|
463 void CDmAdVpnApData::RestoreL(const TVpnApParms& aVpnApParms) |
|
464 { |
|
465 TRACE("CDmAdVpnApData::RestoreL"); |
|
466 |
|
467 delete iName; |
|
468 iName = NULL; |
|
469 if (aVpnApParms.iName.Length() > 0) |
|
470 { |
|
471 iName = aVpnApParms.iName.AllocL(); |
|
472 } |
|
473 |
|
474 delete iPolicyRefId; |
|
475 iPolicyRefId = 0; |
|
476 if (aVpnApParms.iPolicyId.Length() > 0) |
|
477 { |
|
478 iPolicyRefId = aVpnApParms.iPolicyId.AllocL(); |
|
479 } |
|
480 |
|
481 delete iConRef; |
|
482 iConRef = NULL; |
|
483 if (aVpnApParms.iRealConnRef != 0) |
|
484 { |
|
485 HBufC8* luid = TDmAdUtil::IntToDes8LC(aVpnApParms.iRealConnRef); |
|
486 |
|
487 switch(aVpnApParms.iRealConnRefType) |
|
488 { |
|
489 case TVpnApParms::EIapRealConnRef: |
|
490 iConRef = iCallBack->FindChildUriL(KDmAdFetchLinkAp, *luid); |
|
491 break; |
|
492 case TVpnApParms::ESnapRealConnRef: |
|
493 iConRef = iCallBack->FindChildUriL(KDmAdFetchLinkSnap, *luid); |
|
494 break; |
|
495 default: |
|
496 User::Invariant(); |
|
497 break; |
|
498 } |
|
499 CleanupStack::PopAndDestroy(); // luid |
|
500 } |
|
501 } |
|
502 |
|
503 void CDmAdVpnApData::ToStoreL(TVpnApParms& aVpnApParms) |
|
504 { |
|
505 TRACE("CDmAdVpnApData::ToStoreL"); |
|
506 |
|
507 if (iName == 0) |
|
508 { |
|
509 aVpnApParms.iName.SetLength(0); |
|
510 } |
|
511 else |
|
512 { |
|
513 if (iName->Length() > aVpnApParms.iName.MaxLength()) |
|
514 { |
|
515 DEBUG_LOG(_L("iName too long")); |
|
516 User::Leave(KErrOverflow); |
|
517 } |
|
518 aVpnApParms.iName.Copy(*iName); |
|
519 } |
|
520 |
|
521 if (iPolicyRefId == 0) |
|
522 { |
|
523 aVpnApParms.iPolicyId.SetLength(0); |
|
524 } |
|
525 else |
|
526 { |
|
527 if (iPolicyRefId->Length() > aVpnApParms.iPolicyId.MaxLength()) |
|
528 { |
|
529 DEBUG_LOG(_L("iPolicyRefId too long")); |
|
530 User::Leave(KErrOverflow); |
|
531 } |
|
532 aVpnApParms.iPolicyId.Copy(*iPolicyRefId); |
|
533 } |
|
534 |
|
535 aVpnApParms.iRealConnRef = 0; |
|
536 if (iConRef != NULL) |
|
537 { |
|
538 if (iConRef->Find(KDmAdFetchLinkAp) == 0) |
|
539 { |
|
540 aVpnApParms.iRealConnRefType = TVpnApParms::EIapRealConnRef; |
|
541 } |
|
542 else if (iConRef->Find(KDmAdFetchLinkSnap) == 0) |
|
543 { |
|
544 aVpnApParms.iRealConnRefType = TVpnApParms::ESnapRealConnRef; |
|
545 } |
|
546 else |
|
547 { |
|
548 User::Leave(KErrGeneral); |
|
549 } |
|
550 |
|
551 HBufC8* luid = iCallBack->GetLuidAllocL(*iConRef); |
|
552 CleanupStack::PushL(luid); |
|
553 if (luid->Length() > 0) |
|
554 { |
|
555 aVpnApParms.iRealConnRef = TDmAdUtil::DesToInt(*luid); |
|
556 } |
|
557 CleanupStack::PopAndDestroy(luid); |
|
558 } |
|
559 } |
|
560 |
|
561 //====================================================================================== |
|
562 //====================================================================================== |
|
563 |
|
564 CDmAdPolicyData* CDmAdPolicyData::NewL(void) |
|
565 { |
|
566 TRACE("CDmAdPolicyData::NewL"); |
|
567 |
|
568 CDmAdPolicyData *self = new (ELeave) CDmAdPolicyData(); |
|
569 return self; |
|
570 } |
|
571 |
|
572 |
|
573 CDmAdPolicyData::CDmAdPolicyData() |
|
574 { |
|
575 TRACE("CDmAdPolicyData::CDmAdPolicyData"); |
|
576 } |
|
577 |
|
578 CDmAdPolicyData::~CDmAdPolicyData() |
|
579 { |
|
580 TRACE("CDmAdPolicyData::~CDmAdPolicyData"); |
|
581 |
|
582 delete iName; |
|
583 delete iId; |
|
584 delete iVersion; |
|
585 delete iDescription; |
|
586 delete iIssuer; |
|
587 delete iContact; |
|
588 delete iContent; |
|
589 } |
|
590 |
|
591 //-------------------------------------------------------------------------- |
|
592 |
|
593 void CDmAdPolicyData::SetNameL(const TDesC8& aName) |
|
594 { |
|
595 TRACE("CDmAdPolicyData::SetNameL"); |
|
596 |
|
597 delete iName; |
|
598 iName = 0; |
|
599 if (aName.Length() > 0) |
|
600 { |
|
601 iName = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aName); |
|
602 } |
|
603 } |
|
604 |
|
605 HBufC8* CDmAdPolicyData::NameLC(void) |
|
606 { |
|
607 if (iName == 0) |
|
608 { |
|
609 return HBufC8::NewLC(1); |
|
610 } |
|
611 HBufC8* ret = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*iName); |
|
612 CleanupStack::PushL(ret); |
|
613 return ret; |
|
614 } |
|
615 |
|
616 void CDmAdPolicyData::SetIdL(const TDesC8& aId) |
|
617 { |
|
618 TRACE("CDmAdPolicyData::SetIdL"); |
|
619 |
|
620 delete iId; |
|
621 iId = NULL; |
|
622 if (aId.Length() > 0) |
|
623 { |
|
624 iId = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aId); |
|
625 } |
|
626 } |
|
627 |
|
628 HBufC8* CDmAdPolicyData::IdLC(void) |
|
629 { |
|
630 if (iId == 0) |
|
631 { |
|
632 return HBufC8::NewLC(1); |
|
633 } |
|
634 HBufC8* ret = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*iId); |
|
635 CleanupStack::PushL(ret); |
|
636 return ret; |
|
637 } |
|
638 |
|
639 void CDmAdPolicyData::SetVersionL(const TDesC8& aVersion) |
|
640 { |
|
641 TRACE("CDmAdPolicyData::SetVersionL"); |
|
642 |
|
643 delete iVersion; |
|
644 iVersion = 0; |
|
645 if (aVersion.Length() > 0) |
|
646 { |
|
647 iVersion = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aVersion); |
|
648 } |
|
649 } |
|
650 |
|
651 HBufC8* CDmAdPolicyData::VersionLC(void) |
|
652 { |
|
653 if (iVersion == 0) |
|
654 { |
|
655 return HBufC8::NewLC(1); |
|
656 } |
|
657 HBufC8* ret = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*iVersion); |
|
658 CleanupStack::PushL(ret); |
|
659 return ret; |
|
660 } |
|
661 |
|
662 void CDmAdPolicyData::SetDescriptionL(const TDesC8& aDescription) |
|
663 { |
|
664 TRACE("CDmAdPolicyData::SetDescriptionL"); |
|
665 |
|
666 delete iDescription; |
|
667 iDescription = NULL; |
|
668 if (aDescription.Length() > 0) |
|
669 { |
|
670 iDescription = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aDescription); |
|
671 } |
|
672 } |
|
673 |
|
674 HBufC8* CDmAdPolicyData::DescriptionLC(void) |
|
675 { |
|
676 if (iDescription == 0) |
|
677 { |
|
678 return HBufC8::NewLC(1); |
|
679 } |
|
680 HBufC8* ret = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*iDescription); |
|
681 CleanupStack::PushL(ret); |
|
682 return ret; |
|
683 } |
|
684 |
|
685 void CDmAdPolicyData::SetIssuerL(const TDesC8& aIssuer) |
|
686 { |
|
687 TRACE("CDmAdPolicyData::SetIssuerL"); |
|
688 |
|
689 delete iIssuer; |
|
690 iIssuer = NULL; |
|
691 if (aIssuer.Length() > 0) |
|
692 { |
|
693 iIssuer = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aIssuer); |
|
694 } |
|
695 } |
|
696 |
|
697 HBufC8* CDmAdPolicyData::IssuerLC(void) |
|
698 { |
|
699 if (iIssuer == 0) |
|
700 { |
|
701 return HBufC8::NewLC(1); |
|
702 } |
|
703 HBufC8* ret = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*iIssuer); |
|
704 CleanupStack::PushL(ret); |
|
705 return ret; |
|
706 } |
|
707 |
|
708 void CDmAdPolicyData::SetContactL(const TDesC8& aContact) |
|
709 { |
|
710 TRACE("CDmAdPolicyData::SetContactL"); |
|
711 |
|
712 delete iContact; |
|
713 iContact = NULL; |
|
714 if (aContact.Length() > 0) |
|
715 { |
|
716 iContact = CnvUtfConverter::ConvertToUnicodeFromUtf8L(aContact); |
|
717 } |
|
718 } |
|
719 |
|
720 HBufC8* CDmAdPolicyData::ContactLC(void) |
|
721 { |
|
722 if (iContact == 0) |
|
723 { |
|
724 return HBufC8::NewLC(1); |
|
725 } |
|
726 HBufC8* ret = CnvUtfConverter::ConvertFromUnicodeToUtf8L(*iContact); |
|
727 CleanupStack::PushL(ret); |
|
728 return ret; |
|
729 } |
|
730 |
|
731 void CDmAdPolicyData::SetContentL(const TDesC8& aContent) |
|
732 { |
|
733 TRACE("CDmAdPolicyData::SetContentL"); |
|
734 |
|
735 delete iContent; |
|
736 iContent = NULL; |
|
737 if (aContent.Length() > 0) |
|
738 { |
|
739 iContent = aContent.AllocL(); |
|
740 } |
|
741 } |
|
742 |
|
743 TPtrC8 CDmAdPolicyData::Content(void) |
|
744 { |
|
745 TRACE("CDmAdPolicyData::Content"); |
|
746 |
|
747 TPtrC8 ret(KNullDesC8); |
|
748 if (iContent != 0) |
|
749 { |
|
750 ret.Set(*iContent); |
|
751 } |
|
752 return ret; |
|
753 } |
|
754 |
|
755 //-------------------------------------------------------------------------- |
|
756 |
|
757 void CDmAdPolicyData::DetailsRestoreL(const TVpnPolicyDetails& aDetails) |
|
758 { |
|
759 TRACE("CDmAdPolicyData::DetailsRestoreL"); |
|
760 |
|
761 delete iName; |
|
762 iName = NULL; |
|
763 if (aDetails.iName.Length() > 0) |
|
764 { |
|
765 iName = aDetails.iName.AllocL(); |
|
766 } |
|
767 |
|
768 delete iId; |
|
769 iId = 0; |
|
770 if (aDetails.iId.Length() > 0) |
|
771 { |
|
772 iId = aDetails.iId.AllocL(); |
|
773 } |
|
774 |
|
775 delete iVersion; |
|
776 iVersion = 0; |
|
777 if (aDetails.iVersion.Length() > 0) |
|
778 { |
|
779 iVersion = aDetails.iVersion.AllocL(); |
|
780 } |
|
781 |
|
782 delete iDescription; |
|
783 iDescription = 0; |
|
784 if (aDetails.iDescription.Length() > 0) |
|
785 { |
|
786 iDescription = aDetails.iDescription.AllocL(); |
|
787 } |
|
788 |
|
789 delete iIssuer; |
|
790 iIssuer = 0; |
|
791 if (aDetails.iIssuerName.Length() > 0) |
|
792 { |
|
793 iIssuer = aDetails.iIssuerName.AllocL(); |
|
794 } |
|
795 |
|
796 delete iContact; |
|
797 iContact = 0; |
|
798 if (aDetails.iContactInfo.Length() > 0) |
|
799 { |
|
800 iContact = aDetails.iContactInfo.AllocL(); |
|
801 } |
|
802 } |
|
803 |
|
804 void CDmAdPolicyData::DetailsToStoreL(TVpnPolicyDetails& aDetails) |
|
805 { |
|
806 TRACE("CDmAdPolicyData::DetailsToStoreL"); |
|
807 |
|
808 if (iName == 0) |
|
809 { |
|
810 aDetails.iName.SetLength(0); |
|
811 } |
|
812 else |
|
813 { |
|
814 if (iName->Length() > aDetails.iName.MaxLength()) |
|
815 { |
|
816 DEBUG_LOG(_L("iName too long")); |
|
817 User::Leave(KErrOverflow); |
|
818 } |
|
819 aDetails.iName.Copy(*iName); |
|
820 } |
|
821 |
|
822 if (iId == 0) |
|
823 { |
|
824 aDetails.iId.SetLength(0); |
|
825 } |
|
826 else |
|
827 { |
|
828 if (iId->Length() > aDetails.iId.MaxLength()) |
|
829 { |
|
830 DEBUG_LOG(_L("iId too long")); |
|
831 User::Leave(KErrOverflow); |
|
832 } |
|
833 aDetails.iId.Copy(*iId); |
|
834 } |
|
835 |
|
836 if (iVersion == 0) |
|
837 { |
|
838 aDetails.iVersion.SetLength(0); |
|
839 } |
|
840 else |
|
841 { |
|
842 if (iVersion->Length() > aDetails.iVersion.MaxLength()) |
|
843 { |
|
844 DEBUG_LOG(_L("iVersion too long")); |
|
845 User::Leave(KErrOverflow); |
|
846 } |
|
847 aDetails.iVersion.Copy(*iVersion); |
|
848 } |
|
849 |
|
850 if (iDescription == 0) |
|
851 { |
|
852 aDetails.iDescription.SetLength(0); |
|
853 } |
|
854 else |
|
855 { |
|
856 if (iDescription->Length() > aDetails.iDescription.MaxLength()) |
|
857 { |
|
858 DEBUG_LOG(_L("iDescription too long")); |
|
859 User::Leave(KErrOverflow); |
|
860 } |
|
861 aDetails.iDescription.Copy(*iDescription); |
|
862 } |
|
863 |
|
864 if (iIssuer == 0) |
|
865 { |
|
866 aDetails.iIssuerName.SetLength(0); |
|
867 } |
|
868 else |
|
869 { |
|
870 if (iIssuer->Length() > aDetails.iIssuerName.MaxLength()) |
|
871 { |
|
872 DEBUG_LOG(_L("iIssuer too long")); |
|
873 User::Leave(KErrOverflow); |
|
874 } |
|
875 aDetails.iIssuerName.Copy(*iIssuer); |
|
876 } |
|
877 |
|
878 if (iContact == 0) |
|
879 { |
|
880 aDetails.iContactInfo.SetLength(0); |
|
881 } |
|
882 else |
|
883 { |
|
884 if (iContact->Length() > aDetails.iContactInfo.MaxLength()) |
|
885 { |
|
886 DEBUG_LOG(_L("iContact too long")); |
|
887 User::Leave(KErrOverflow); |
|
888 } |
|
889 aDetails.iContactInfo.Copy(*iContact); |
|
890 } |
|
891 } |
|
892 |
|
893 void CDmAdPolicyData::ContentRestoreL(const TDesC8& aContent) |
|
894 { |
|
895 TRACE("CDmAdPolicyData::ContentRestoreL"); |
|
896 |
|
897 delete iContent; |
|
898 iContent = NULL; |
|
899 if (aContent.Length() > 0) |
|
900 { |
|
901 iContent = aContent.AllocL(); |
|
902 } |
|
903 } |
|
904 |
|
905 TPtrC8 CDmAdPolicyData::ContentToStore(void) |
|
906 { |
|
907 TRACE("CDmAdPolicyData::ContentToStore"); |
|
908 |
|
909 TPtrC8 ret(KNullDesC8); |
|
910 if (iContent != 0) |
|
911 { |
|
912 ret.Set(*iContent); |
|
913 } |
|
914 return ret; |
|
915 } |