|
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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "NSmlProfileContentHandler.h" |
|
22 #include "nsmldssettings.h" |
|
23 |
|
24 #include <commdb.h> //access point resolution |
|
25 #include <commsdattypesv1_1.h> |
|
26 |
|
27 |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 |
|
32 CNSmlProfileContentHandler::CNSmlProfileContentHandler() |
|
33 { |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CXMLAttributes::ConstructL |
|
38 // Symbian 2nd phase constructor can leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 void CNSmlProfileContentHandler::ConstructL(CNSmlDSSettings* aSettings ,CNSmlProfileArray* aArray) |
|
42 { |
|
43 iCounter = 0; |
|
44 //iDSAccountInProgress = FALSE; |
|
45 iDSSettingInProgress = FALSE; |
|
46 iDSContentInProgress = FALSE; |
|
47 iSettings = aSettings; |
|
48 iCustomProfileArray = aArray; |
|
49 //iCustomProfileArray = new (ELeave) CArrayPtrFlat<CNSmlDSProfile> (5); |
|
50 iContentArray = new (ELeave) CArrayPtrFlat<CNSmlDSContentSettingType> (7); |
|
51 iSyncTypeArray = new (ELeave) CArrayFixFlat<TInt> (1); |
|
52 iContentCounter = 0; |
|
53 iInvalidContent = EFalse; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CXMLAttributes::NewL |
|
58 // Two-phased constructor. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CNSmlProfileContentHandler* CNSmlProfileContentHandler::NewL(CNSmlDSSettings* aSettings,CNSmlProfileArray* aArray) |
|
62 { |
|
63 CNSmlProfileContentHandler* self = new( ELeave ) CNSmlProfileContentHandler; |
|
64 |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(aSettings ,aArray); |
|
67 CleanupStack::Pop(); |
|
68 |
|
69 return self; |
|
70 } |
|
71 |
|
72 |
|
73 // Destructor |
|
74 CNSmlProfileContentHandler::~CNSmlProfileContentHandler() |
|
75 { |
|
76 if (iContentArray) |
|
77 { |
|
78 iContentArray->ResetAndDestroy(); |
|
79 } |
|
80 delete iContentArray; |
|
81 delete iSyncTypeArray; |
|
82 } |
|
83 |
|
84 |
|
85 TInt CNSmlProfileContentHandler::StartDocument() |
|
86 { |
|
87 return 1; |
|
88 } |
|
89 |
|
90 TInt CNSmlProfileContentHandler::EndDocument() |
|
91 { |
|
92 |
|
93 return 1; |
|
94 } |
|
95 |
|
96 //=============================================== |
|
97 // CNSmlProfileContentHandler::StartElement() |
|
98 // |
|
99 // |
|
100 //=============================================== |
|
101 |
|
102 TInt CNSmlProfileContentHandler::StartElement(TDesC& /*aURI*/, TDesC& /*aLocalName*/, TDesC& aName, MXMLAttributes* /*aAttributeList*/) |
|
103 { |
|
104 if (aName == _L("DSSettings")) |
|
105 { |
|
106 iDSSettingInProgress = TRUE; |
|
107 CNSmlDSProfile* profile = iSettings->CreateProfileL(); |
|
108 iCustomProfileArray->AppendL(profile); |
|
109 |
|
110 |
|
111 } |
|
112 if (aName == _L("DSContentSettings")) |
|
113 { |
|
114 iDSContentInProgress = TRUE; |
|
115 CNSmlDSContentSettingType* content = CNSmlDSContentSettingType::NewL(); |
|
116 iContentArray->AppendL(content); |
|
117 |
|
118 |
|
119 } |
|
120 if (iDSSettingInProgress) |
|
121 { |
|
122 if (aName.Compare(KNSmlDSProfileDisplayName) == 0) |
|
123 { |
|
124 iState = EProfileDisplayName; |
|
125 } |
|
126 |
|
127 if (aName.Compare(KNSmlDSProfileServerURL) == 0) |
|
128 { |
|
129 iState = EProfileServerURL; |
|
130 |
|
131 } |
|
132 if (aName.Compare(KNSmlDSProfileIAPId) == 0) |
|
133 { |
|
134 iState = EProfileIAPId; |
|
135 |
|
136 } |
|
137 if (aName.Compare(KNSmlDSProfileTransportId) == 0) |
|
138 { |
|
139 iState = EProfileTransportId; |
|
140 |
|
141 } |
|
142 if (aName.Compare(KNSmlDSProfileSyncServerUsername) == 0) |
|
143 { |
|
144 iState = EProfileSyncServerUsername; |
|
145 } |
|
146 if (aName.Compare(KNSmlDSProfileSyncServerPassword) == 0) |
|
147 { |
|
148 iState = EProfileSyncServerPassword; |
|
149 } |
|
150 if (aName.Compare(KNSmlDSProfileServerAlertedAction) == 0) |
|
151 { |
|
152 iState = EProfileServerAlertedAction; |
|
153 } |
|
154 if (aName.Compare(KNSmlDSProfileHidden) == 0) |
|
155 { |
|
156 iState = EProfileHidden; |
|
157 } |
|
158 if (aName.Compare(KNSmlDSProfileHttpAuthUsed) == 0) |
|
159 { |
|
160 iState = EProfileHttpAuthUsed; |
|
161 } |
|
162 if (aName.Compare(KNSmlDSProfileHttpAuthUsername) == 0) |
|
163 { |
|
164 iState = EProfileHttpAuthUsername; |
|
165 } |
|
166 if (aName.Compare(KNSmlDSProfileHttpAuthPassword) == 0) |
|
167 { |
|
168 iState = EProfileHttpAuthPassword; |
|
169 } |
|
170 if (aName.Compare(KNSmlDSProfileServerId) == 0) |
|
171 { |
|
172 iState = EProfileServerId; |
|
173 |
|
174 } |
|
175 if (aName.Compare(KNSmlDSProfileProtocolVersion) == 0) |
|
176 { |
|
177 iState = EProfileProtocolVersion; |
|
178 } |
|
179 if (aName.Compare(KNSmlAdapterSyncType) == 0) |
|
180 { |
|
181 iState = ESyncType; |
|
182 } |
|
183 if (aName.Compare(KNSmlDSProfileDefaultProfile) == 0) |
|
184 { |
|
185 iState = EDefaultProfile; |
|
186 } |
|
187 } |
|
188 else if(iDSContentInProgress) |
|
189 { |
|
190 if (aName.Compare(KNSmlDSProfileDisplayName) == 0) |
|
191 { |
|
192 iState = EProfileDisplayName; |
|
193 } |
|
194 if (aName.Compare(KNSmlDSProfileServerId) == 0) |
|
195 { |
|
196 iState = EProfileServerId; |
|
197 } |
|
198 if (aName.Compare(KNSmlAdapterImlementationUID) == 0) |
|
199 { |
|
200 iState = EAdapterImplementationId; |
|
201 } |
|
202 if (aName.Compare(KNSmlAdapterServerDataSource) == 0) |
|
203 { |
|
204 iState = EAdapterServerDataSource; |
|
205 } |
|
206 |
|
207 } |
|
208 |
|
209 return 1; |
|
210 } |
|
211 |
|
212 //=============================================== |
|
213 // CNSmlProfileContentHandler::StartElement() |
|
214 // |
|
215 // |
|
216 //=============================================== |
|
217 TInt CNSmlProfileContentHandler::EndElement(TDesC& /*aURI*/, TDesC& /*aLocalName*/, TDesC& aName) |
|
218 { |
|
219 |
|
220 if (aName == _L("DSSettings") && iDSSettingInProgress ) |
|
221 { |
|
222 iDSSettingInProgress = FALSE; |
|
223 iCounter++; |
|
224 |
|
225 } |
|
226 else if (aName == _L("DSContentSettings") && iDSContentInProgress ) |
|
227 { |
|
228 iDSContentInProgress = FALSE; |
|
229 CreateContentTypeL(); |
|
230 iContentCounter++; |
|
231 iInvalidContent = EFalse; |
|
232 } |
|
233 |
|
234 if (iState != EStateHandled) |
|
235 { |
|
236 iState = EStateHandled; //Assume that empty feild. No need to set. |
|
237 } |
|
238 |
|
239 |
|
240 |
|
241 return 1; |
|
242 } |
|
243 |
|
244 //=============================================== |
|
245 // CNSmlProfileContentHandler::StartCDATA() |
|
246 // |
|
247 // |
|
248 //=============================================== |
|
249 TInt CNSmlProfileContentHandler::StartCDATA() |
|
250 { |
|
251 |
|
252 return 1; |
|
253 } |
|
254 |
|
255 //=============================================== |
|
256 // CNSmlProfileContentHandler::EndCDATA() |
|
257 // |
|
258 // |
|
259 //=============================================== |
|
260 TInt CNSmlProfileContentHandler::EndCDATA() |
|
261 { |
|
262 |
|
263 return 1; |
|
264 } |
|
265 |
|
266 //=============================================== |
|
267 // CNSmlProfileContentHandler::Charecters() |
|
268 // |
|
269 // |
|
270 //=============================================== |
|
271 TInt CNSmlProfileContentHandler::Charecters(TDesC& aBuf, TInt /*aStart*/, TInt /*aLength*/) |
|
272 { |
|
273 |
|
274 TInt aValue; |
|
275 if (iDSSettingInProgress) |
|
276 { |
|
277 |
|
278 if(iState == EProfileDisplayName) |
|
279 { |
|
280 if(aBuf.Length() > KNSmlMaxProfileNameLength) |
|
281 { |
|
282 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileDisplayName, KEmpty) ; |
|
283 } |
|
284 else |
|
285 { |
|
286 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileDisplayName, aBuf) ; |
|
287 } |
|
288 iState = EStateHandled; |
|
289 } |
|
290 if(iState == EProfileServerURL) |
|
291 { |
|
292 if(aBuf.Length() > KDSMaxURLLength) |
|
293 { |
|
294 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileDisplayName, KEmpty) ; |
|
295 } |
|
296 else |
|
297 { |
|
298 SetServerURL(aBuf); |
|
299 } |
|
300 iState = EStateHandled; |
|
301 } |
|
302 if(iState == EProfileIAPId) |
|
303 { |
|
304 |
|
305 if(aBuf.Length() > KAccessPointNameMaxLen) |
|
306 { |
|
307 _LIT(KDefaultValue ,"-1"); |
|
308 aBuf = KDefaultValue; |
|
309 } |
|
310 |
|
311 TInt iapId = AccessPointIdL(aBuf); |
|
312 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileIAPId, iapId) ; |
|
313 iState = EStateHandled; |
|
314 } |
|
315 if(iState == EProfileTransportId) |
|
316 { |
|
317 _LIT16(KHexCode,"0x"); |
|
318 TBuf<64> tempBuf(aBuf); |
|
319 TInt temp = tempBuf.Find(KHexCode); |
|
320 tempBuf.Delete(0, temp + 2); |
|
321 |
|
322 iLex = tempBuf; |
|
323 TInt64 aVal; |
|
324 User::LeaveIfError(iLex.Val(aVal ,EHex)); |
|
325 if (aVal != KUidNSmlMediumTypeInternet.iUid && aVal != KUidNSmlMediumTypeBluetooth.iUid) |
|
326 { |
|
327 aVal = KUidNSmlMediumTypeInternet.iUid; |
|
328 } |
|
329 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileTransportId, aVal) ; |
|
330 iState = EStateHandled; |
|
331 } |
|
332 |
|
333 if(iState == EProfileSyncServerUsername) |
|
334 { |
|
335 if(aBuf.Length() > KNSmlMaxUsernameLength) |
|
336 { |
|
337 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileDisplayName, KEmpty) ; |
|
338 } |
|
339 else |
|
340 { |
|
341 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileSyncServerUsername, aBuf) ; |
|
342 } |
|
343 iState = EStateHandled; |
|
344 } |
|
345 if(iState == EProfileSyncServerPassword) |
|
346 { |
|
347 if(aBuf.Length() > KNSmlMaxPasswordLength) |
|
348 { |
|
349 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileDisplayName, KEmpty) ; |
|
350 } |
|
351 else |
|
352 { |
|
353 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileSyncServerPassword, aBuf) ; |
|
354 } |
|
355 iState = EStateHandled; |
|
356 } |
|
357 if(iState == EProfileServerAlertedAction) |
|
358 { |
|
359 iLex = aBuf; |
|
360 User::LeaveIfError(iLex.Val(aValue)); |
|
361 TInt typeId = ServerAlertType(aValue); |
|
362 |
|
363 if(aValue != ESmlEnableSync && aValue != ESmlConfirmSync && aValue != ESmlDisableSync) |
|
364 { |
|
365 aValue = ESmlEnableSync; |
|
366 } |
|
367 |
|
368 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileServerAlertedAction, typeId) ; |
|
369 iState = EStateHandled; |
|
370 } |
|
371 |
|
372 if(iState == EProfileHidden) |
|
373 { |
|
374 iLex = aBuf; |
|
375 User::LeaveIfError(iLex.Val(aValue)); |
|
376 SetVisibility(aValue); |
|
377 iState = EStateHandled; |
|
378 } |
|
379 |
|
380 if(iState == EProfileHttpAuthUsed) |
|
381 { |
|
382 iLex = aBuf; |
|
383 User::LeaveIfError(iLex.Val(aValue)); |
|
384 if (aValue != 0 && aValue != 1) |
|
385 { |
|
386 aValue = 1; |
|
387 } |
|
388 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileHttpAuthUsed, aValue) ; |
|
389 iState = EStateHandled; |
|
390 } |
|
391 |
|
392 if(iState == EProfileHttpAuthUsername) |
|
393 { |
|
394 if(iCustomProfileArray->At(iCounter)->IntValue(EDSProfileTransportId) |
|
395 == KUidNSmlMediumTypeBluetooth.iUid |
|
396 || !iCustomProfileArray->At(iCounter)->IntValue(EDSProfileHttpAuthUsed)) |
|
397 { |
|
398 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileHttpAuthUsername, KEmpty) ; |
|
399 } |
|
400 else if (aBuf.Length() > KNSmlMaxHttpAuthUsernameLength) |
|
401 { |
|
402 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileDisplayName, KEmpty) ; |
|
403 } |
|
404 else |
|
405 { |
|
406 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileHttpAuthUsername, aBuf) ; |
|
407 } |
|
408 iState = EStateHandled; |
|
409 } |
|
410 |
|
411 if(iState == EProfileHttpAuthPassword) |
|
412 { |
|
413 if(iCustomProfileArray->At(iCounter)->IntValue(EDSProfileTransportId) |
|
414 == KUidNSmlMediumTypeBluetooth.iUid |
|
415 || !iCustomProfileArray->At(iCounter)->IntValue(EDSProfileHttpAuthUsed)) |
|
416 { |
|
417 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileHttpAuthPassword, KEmpty) ; |
|
418 } |
|
419 else if(aBuf.Length() > KNSmlMaxHttpAuthPasswordLength) |
|
420 { |
|
421 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileDisplayName, KEmpty) ; |
|
422 } |
|
423 else |
|
424 { |
|
425 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileHttpAuthPassword, aBuf) ; |
|
426 } |
|
427 iState = EStateHandled; |
|
428 } |
|
429 |
|
430 if(iState == EProfileServerId) |
|
431 { |
|
432 if(aBuf.Length() > KNSmlMaxServerIdLength) |
|
433 { |
|
434 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileDisplayName, KEmpty) ; |
|
435 } |
|
436 else |
|
437 { |
|
438 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileServerId, aBuf) ; |
|
439 } |
|
440 iState = EStateHandled; |
|
441 } |
|
442 if(iState == EProfileProtocolVersion) |
|
443 { |
|
444 iLex = aBuf; |
|
445 User::LeaveIfError(iLex.Val(aValue)); |
|
446 |
|
447 if(aValue != ESmlVersion1_1_2 && aValue != ESmlVersion1_2) |
|
448 { |
|
449 aValue = ESmlVersion1_2; |
|
450 } |
|
451 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileProtocolVersion, aValue) ; |
|
452 iState = EStateHandled; |
|
453 } |
|
454 |
|
455 if(iState == ESyncType) |
|
456 { |
|
457 TInt syncType = SyncType (aBuf); |
|
458 iSyncTypeArray->AppendL(syncType); |
|
459 iState = EStateHandled; |
|
460 } |
|
461 |
|
462 if(iState == EDefaultProfile) |
|
463 { |
|
464 if(aBuf.Compare(_L("true")) == 0) |
|
465 { |
|
466 aValue = 1; |
|
467 } |
|
468 else |
|
469 { |
|
470 aValue = 0; |
|
471 } |
|
472 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileDefaultProfile, aValue ); |
|
473 iState = EStateHandled; |
|
474 } |
|
475 } |
|
476 else if (iDSContentInProgress) |
|
477 { |
|
478 if(iState == EProfileDisplayName) |
|
479 { |
|
480 if(aBuf.Length() > KNSmlMaxProfileNameLength) |
|
481 { |
|
482 iContentArray->At(iContentCounter)->SetStrValue( EXMLDSProfileName, KEmpty) ; |
|
483 iInvalidContent = ETrue; |
|
484 } |
|
485 else |
|
486 { |
|
487 iContentArray->At(iContentCounter)->SetStrValue( EXMLDSProfileName ,aBuf); |
|
488 } |
|
489 iState = EStateHandled; |
|
490 } |
|
491 if(iState == EProfileServerId) |
|
492 { |
|
493 if(aBuf.Length() > KNSmlMaxServerIdLength || iInvalidContent) |
|
494 { |
|
495 iContentArray->At(iContentCounter)->SetStrValue( EXMLDSProfileName, KEmpty) ; |
|
496 iContentArray->At(iContentCounter)->SetStrValue( EXMLDSServerId, KEmpty) ; |
|
497 } |
|
498 else |
|
499 { |
|
500 iContentArray->At(iContentCounter)->SetStrValue( EXMLDSServerId ,aBuf); |
|
501 } |
|
502 iState = EStateHandled; |
|
503 } |
|
504 if(iState == EAdapterServerDataSource ) |
|
505 { |
|
506 if(aBuf.Length() > KDSMaxRemoteNameLength) |
|
507 { |
|
508 iContentArray->At(iContentCounter)->SetStrValue( EXMLDSServerDataSource, KEmpty) ; |
|
509 } |
|
510 else |
|
511 { |
|
512 iContentArray->At(iContentCounter)->SetStrValue( EXMLDSServerDataSource, aBuf); |
|
513 } |
|
514 iState = EStateHandled; |
|
515 } |
|
516 if(iState == EAdapterImplementationId ) |
|
517 { |
|
518 if(aBuf.Length() > KNSmlMaxAdapterIdLength) |
|
519 { |
|
520 iContentArray->At(iContentCounter)->SetStrValue( EXMLDSAdapaterId, KEmpty) ; |
|
521 } |
|
522 else |
|
523 { |
|
524 iContentArray->At(iContentCounter)->SetStrValue( EXMLDSAdapaterId, aBuf); |
|
525 } |
|
526 iState = EStateHandled; |
|
527 } |
|
528 |
|
529 |
|
530 } |
|
531 |
|
532 return 1; |
|
533 } |
|
534 |
|
535 |
|
536 //===================================================== |
|
537 // CNSmlProfileContentHandler::CreateContentTypeL() |
|
538 // |
|
539 // |
|
540 //===================================================== |
|
541 void CNSmlProfileContentHandler::CreateContentTypeL() |
|
542 { |
|
543 |
|
544 TBuf<128> buffer; |
|
545 buffer = iContentArray->At(iContentCounter)->StrValue( EXMLDSAdapaterId); |
|
546 |
|
547 TInt64 adapterId = 0; |
|
548 |
|
549 if (buffer.Compare(KEmpty) == 0) |
|
550 { |
|
551 return; |
|
552 } |
|
553 _LIT16(KHexCode,"0x"); |
|
554 TInt temp = buffer.Find(KHexCode); |
|
555 buffer.Delete(0, temp + 2); |
|
556 iLex = buffer; |
|
557 User::LeaveIfError(iLex.Val(adapterId ,EHex)); |
|
558 |
|
559 if (IsContentAdded(adapterId)) |
|
560 { |
|
561 return; |
|
562 } |
|
563 |
|
564 buffer = iContentArray->At(iContentCounter)->StrValue( EXMLDSServerDataSource); |
|
565 TBuf<16> clientDataSource(KEmpty) ; |
|
566 TInt index; |
|
567 if(CheckXMLContentSetting()) |
|
568 { |
|
569 if(iContentArray->At(iContentCounter)->StrValue( EXMLDSServerId).Compare(KEmpty) != 0) |
|
570 { |
|
571 for(index = 0; index < iCounter; index++) |
|
572 { |
|
573 if(iContentArray->At(iContentCounter)->StrValue( EXMLDSServerId). |
|
574 Compare(iCustomProfileArray->At(index)->StrValue(EDSProfileServerId)) == 0) |
|
575 { |
|
576 break; |
|
577 } |
|
578 } |
|
579 |
|
580 } |
|
581 else |
|
582 { |
|
583 for(index = 0; index < iCounter; index++) |
|
584 { |
|
585 if(iContentArray->At(iContentCounter)->StrValue( EXMLDSProfileName). |
|
586 Compare(iCustomProfileArray->At(index)->StrValue(EDSProfileDisplayName)) == 0) |
|
587 { |
|
588 break; |
|
589 } |
|
590 } |
|
591 } |
|
592 |
|
593 if (index < iCounter) |
|
594 { |
|
595 if (adapterId == KUidNSmlAdapterEMail.iUid && |
|
596 iCustomProfileArray->At(index)->IntValue(EDSProfileProtocolVersion) == ESmlVersion1_1_2) |
|
597 { |
|
598 return; |
|
599 } |
|
600 iCustomProfileArray->At(index)->AddContentTypeL( adapterId, clientDataSource, buffer); |
|
601 |
|
602 CNSmlDSContentType* content = iCustomProfileArray->At(index)->ContentType(adapterId); |
|
603 content->SetIntValue( EDSAdapterSyncType, iSyncTypeArray->At(index)); |
|
604 } |
|
605 |
|
606 } |
|
607 |
|
608 } |
|
609 |
|
610 //===================================================== |
|
611 // CNSmlProfileContentHandler::IsContentAdded() |
|
612 // |
|
613 // |
|
614 //===================================================== |
|
615 TBool CNSmlProfileContentHandler::IsContentAdded(TInt aAdapter) |
|
616 { |
|
617 TBuf<KNSmlMaxServerIdLength> serverId; |
|
618 TBuf<KNSmlMaxProfileNameLength> profileName; |
|
619 |
|
620 serverId = iContentArray->At(iContentCounter)->StrValue( EXMLDSServerId); |
|
621 |
|
622 if (serverId.Compare(KEmpty) != 0) |
|
623 { |
|
624 for(TInt i = 0; i < iCounter; i++) |
|
625 { |
|
626 if(serverId.Compare(iCustomProfileArray->At(i)->StrValue(EDSProfileServerId)) == 0) |
|
627 { |
|
628 if(iCustomProfileArray->At(i)->ContentType(aAdapter)) |
|
629 { |
|
630 return ETrue; |
|
631 } |
|
632 } |
|
633 } |
|
634 } |
|
635 else |
|
636 { |
|
637 profileName = iContentArray->At(iContentCounter)->StrValue( EXMLDSProfileName); |
|
638 for(TInt i = 0; i < iCounter; i++) |
|
639 { |
|
640 if(profileName.Compare(iCustomProfileArray->At(i)->StrValue(EDSProfileDisplayName)) == 0) |
|
641 { |
|
642 if(iCustomProfileArray->At(i)->ContentType(aAdapter)) |
|
643 { |
|
644 return ETrue; |
|
645 } |
|
646 } |
|
647 } |
|
648 |
|
649 } |
|
650 |
|
651 return EFalse; |
|
652 } |
|
653 |
|
654 //===================================================== |
|
655 // CNSmlProfileContentHandler::AccessPointIdL() |
|
656 // |
|
657 // |
|
658 //===================================================== |
|
659 TInt CNSmlProfileContentHandler::AccessPointIdL(TDesC& aBuf) |
|
660 { |
|
661 |
|
662 const TInt defConn = -2; |
|
663 if (aBuf == _L("-1")) |
|
664 { |
|
665 return defConn; // return default connection always |
|
666 } |
|
667 |
|
668 CCommsDatabase *database = CCommsDatabase::NewL(); |
|
669 TUint32 aId ; |
|
670 TInt retVal; |
|
671 CleanupStack::PushL(database); |
|
672 CCommsDbTableView* checkView; |
|
673 checkView = database->OpenViewMatchingTextLC(TPtrC(IAP),TPtrC(COMMDB_NAME), aBuf); |
|
674 TInt error = checkView->GotoFirstRecord(); |
|
675 if (error == KErrNone) |
|
676 { |
|
677 //Get the IAP ID |
|
678 checkView->ReadUintL(TPtrC(COMMDB_ID), aId); |
|
679 retVal = aId; |
|
680 } |
|
681 else |
|
682 { |
|
683 retVal = defConn; |
|
684 } |
|
685 |
|
686 CleanupStack::PopAndDestroy(2); |
|
687 return retVal; |
|
688 |
|
689 |
|
690 } |
|
691 |
|
692 //===================================================== |
|
693 // CNSmlProfileContentHandler::SetServerURL() |
|
694 // |
|
695 // |
|
696 //===================================================== |
|
697 void CNSmlProfileContentHandler::SetServerURL(TDesC &aBuf) |
|
698 { |
|
699 |
|
700 _LIT(KColon, ":"); |
|
701 _LIT(KSlash, "/"); |
|
702 |
|
703 const TInt KPortMaxLen = 5; |
|
704 TBuf<150> temp; |
|
705 TBuf<KPortMaxLen> port; |
|
706 |
|
707 _LIT(KHttpHeader, "http://"); |
|
708 _LIT(KHttpsHeader, "https://"); |
|
709 _LIT(KDefaultPort,":80"); |
|
710 |
|
711 const TInt KHttpLength = 7; |
|
712 const TInt KHttpsLength = 8; |
|
713 |
|
714 TInt insertPos = 0; |
|
715 |
|
716 if (iCustomProfileArray->At(iCounter)->IntValue(EDSProfileTransportId) == KUidNSmlMediumTypeBluetooth.iUid) |
|
717 { |
|
718 if (aBuf.Left(KHttpLength).Compare(KHttpHeader) == 0 |
|
719 || aBuf.Left(KHttpsLength).Compare(KHttpsHeader) == 0) |
|
720 { |
|
721 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileServerURL, KEmpty); |
|
722 } |
|
723 else |
|
724 { |
|
725 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileServerURL, aBuf); |
|
726 } |
|
727 return; |
|
728 } |
|
729 if (aBuf.Compare(KEmpty) == 0 || aBuf.Compare(KHttpHeader) == 0 || aBuf.Compare(KHttpsHeader) == 0 |
|
730 || (aBuf.Left(KHttpLength).Compare(KHttpHeader) != 0 && aBuf.Left(KHttpsLength).Compare(KHttpsHeader) != 0)) |
|
731 { |
|
732 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileServerURL, KEmpty); |
|
733 return; |
|
734 } |
|
735 |
|
736 temp = aBuf; |
|
737 if(temp.Left(KHttpsLength).Compare(KHttpsHeader) == 0) |
|
738 { |
|
739 temp.Delete(0, KHttpsLength); |
|
740 insertPos += KHttpsLength; |
|
741 } |
|
742 else if(temp.Left(KHttpLength).Compare(KHttpHeader) == 0) |
|
743 { |
|
744 temp.Delete(0, KHttpLength); |
|
745 insertPos += KHttpLength; |
|
746 } |
|
747 TInt start = temp.Find(KColon); |
|
748 |
|
749 if (start > 0) |
|
750 { |
|
751 |
|
752 temp.Delete(0, start+1); |
|
753 TInt length = temp.Find(KSlash); |
|
754 if (length == KErrNotFound) |
|
755 { |
|
756 length = temp.Length(); |
|
757 } |
|
758 if (length > KPortMaxLen) |
|
759 { |
|
760 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileServerURL, KEmpty); |
|
761 return; |
|
762 } |
|
763 if (length > 0) |
|
764 { |
|
765 port.Append(temp.Left(length)); |
|
766 } |
|
767 insertPos += length; |
|
768 } |
|
769 else |
|
770 { |
|
771 TInt len = temp.Find(KSlash); |
|
772 insertPos += len; |
|
773 } |
|
774 |
|
775 if(port.Compare(KEmpty) != 0) |
|
776 { |
|
777 iLex = port; |
|
778 TInt portNum; |
|
779 TInt err = iLex.Val(portNum); |
|
780 const TInt KMinURIPortNumber = 1; |
|
781 const TInt KMaxURIPortNumber = 65535; |
|
782 |
|
783 if( err != KErrNone || portNum < KMinURIPortNumber || portNum > KMaxURIPortNumber ) |
|
784 { |
|
785 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileServerURL, KEmpty); |
|
786 return; |
|
787 } |
|
788 } |
|
789 else |
|
790 { |
|
791 temp = aBuf; |
|
792 TBuf<150> temp1; |
|
793 |
|
794 temp1.Append(temp.Left(insertPos)); |
|
795 temp1.Append(KDefaultPort); |
|
796 temp.Delete(0, insertPos); |
|
797 temp1.Append(temp); |
|
798 |
|
799 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileServerURL, temp1); |
|
800 return; |
|
801 } |
|
802 |
|
803 |
|
804 iCustomProfileArray->At(iCounter)->SetStrValue( EDSProfileServerURL, aBuf); |
|
805 |
|
806 } |
|
807 //===================================================== |
|
808 // CNSmlProfileContentHandler::ServerAlertType() |
|
809 // |
|
810 // |
|
811 //===================================================== |
|
812 TSmlServerAlertedAction CNSmlProfileContentHandler::ServerAlertType(TInt aType) |
|
813 { |
|
814 TSmlServerAlertedAction retVal = ESmlEnableSync; |
|
815 switch(aType) |
|
816 { |
|
817 case 1: |
|
818 { |
|
819 retVal = ESmlEnableSync; |
|
820 break; |
|
821 } |
|
822 |
|
823 case 2: |
|
824 { |
|
825 retVal = ESmlConfirmSync; |
|
826 break; |
|
827 } |
|
828 |
|
829 case 3: |
|
830 { |
|
831 retVal = ESmlDisableSync; |
|
832 break; |
|
833 } |
|
834 |
|
835 } |
|
836 |
|
837 return retVal; |
|
838 |
|
839 } |
|
840 |
|
841 //===================================================== |
|
842 // CNSmlProfileContentHandler::SyncType() |
|
843 // |
|
844 // |
|
845 //===================================================== |
|
846 TSmlSyncType CNSmlProfileContentHandler::SyncType(TDesC& aBuf) |
|
847 { |
|
848 TSmlSyncType retVal = ESmlTwoWay; |
|
849 if (aBuf == _L("ESmlTwoWay")) |
|
850 { |
|
851 retVal = ESmlTwoWay; |
|
852 } |
|
853 else if(aBuf ==_L("ESmlOneWayFromServer")) |
|
854 { |
|
855 retVal = ESmlOneWayFromServer; |
|
856 |
|
857 } |
|
858 else if(aBuf ==_L("ESmlOneWayFromClient")) |
|
859 { |
|
860 retVal = ESmlOneWayFromClient; |
|
861 } |
|
862 |
|
863 return retVal;; |
|
864 } |
|
865 |
|
866 //===================================================== |
|
867 // CNSmlProfileContentHandler::CheckXMLContentSetting() |
|
868 // |
|
869 // |
|
870 //===================================================== |
|
871 TBool CNSmlProfileContentHandler::CheckXMLContentSetting() |
|
872 { |
|
873 |
|
874 if (iContentArray->At(iContentCounter)->StrValue(EXMLDSServerDataSource).Compare(KEmpty) == 0 |
|
875 || (iContentArray->At(iContentCounter)->StrValue(EXMLDSServerId).Compare(KEmpty) == 0 |
|
876 &&iContentArray->At(iContentCounter)->StrValue(EXMLDSProfileName).Compare(KEmpty) == 0) |
|
877 || iContentArray->At(iContentCounter)->StrValue(EXMLDSAdapaterId).Compare(KEmpty) == 0) |
|
878 { |
|
879 return EFalse; |
|
880 } |
|
881 |
|
882 if(iSyncTypeArray->At(iCounter - 1) != ESmlTwoWay && iSyncTypeArray->At(iCounter - 1) != ESmlOneWayFromServer |
|
883 && iSyncTypeArray->At(iCounter - 1) != ESmlOneWayFromClient) |
|
884 { |
|
885 return EFalse; |
|
886 } |
|
887 |
|
888 for (TInt index = 0; index < iCustomProfileArray->Count() ;index++ ) |
|
889 { |
|
890 if (iContentArray->At(iContentCounter)->StrValue(EXMLDSProfileName). |
|
891 Compare(iCustomProfileArray->At(index)->StrValue(EDSProfileDisplayName)) == 0) |
|
892 { |
|
893 break; |
|
894 } |
|
895 else if (index == (iCustomProfileArray->Count() - 1) |
|
896 && iContentArray->At(iContentCounter)->StrValue(EXMLDSProfileName).Compare(KEmpty) != 0) |
|
897 { |
|
898 return EFalse; |
|
899 } |
|
900 } |
|
901 |
|
902 return ETrue; |
|
903 } |
|
904 |
|
905 //===================================================== |
|
906 // CNSmlProfileContentHandler::SetVisibility() |
|
907 // |
|
908 // |
|
909 //===================================================== |
|
910 void CNSmlProfileContentHandler::SetVisibility(TInt aValue) |
|
911 { |
|
912 switch(aValue) |
|
913 { |
|
914 case 0: |
|
915 { |
|
916 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileHidden, EFalse) ; |
|
917 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileDeleteAllowed, ETrue) ; |
|
918 break; |
|
919 } |
|
920 case 1: |
|
921 { |
|
922 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileHidden, EFalse) ; |
|
923 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileDeleteAllowed, EFalse) ; |
|
924 iCustomProfileArray->At(iCounter)->InitVisibilityArray(KReadOnlyVisiblity); |
|
925 break; |
|
926 } |
|
927 case 2: |
|
928 { |
|
929 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileHidden, ETrue) ; |
|
930 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileDeleteAllowed, EFalse) ; |
|
931 break; |
|
932 } |
|
933 default: |
|
934 |
|
935 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileHidden, EFalse) ; |
|
936 iCustomProfileArray->At(iCounter)->SetIntValue( EDSProfileDeleteAllowed, ETrue) ; |
|
937 } |
|
938 |
|
939 } |
|
940 |
|
941 //===================================================== |
|
942 // CNSmlProfileContentHandler::Comment() |
|
943 // |
|
944 // |
|
945 //===================================================== |
|
946 |
|
947 TInt CNSmlProfileContentHandler::Comment(TDesC& /*aComment*/) |
|
948 { |
|
949 |
|
950 return 1; |
|
951 } |
|
952 |
|
953 //===================================================== |
|
954 // CNSmlProfileContentHandler::ProcessingInstructions() |
|
955 // |
|
956 // |
|
957 //===================================================== |
|
958 TInt CNSmlProfileContentHandler::ProcessingInstructions(TDesC& /*aTarget*/, TDesC& /*aData*/) |
|
959 { |
|
960 |
|
961 return 1; |
|
962 } |
|
963 |
|
964 //===================================================== |
|
965 // CNSmlProfileContentHandler::IgnoreWhiteSpace() |
|
966 // |
|
967 // |
|
968 //===================================================== |
|
969 TInt CNSmlProfileContentHandler::IgnoreWhiteSpace(TDesC& /*aString*/) |
|
970 { |
|
971 return 1; |
|
972 } |
|
973 |
|
974 //===================================================== |
|
975 // CNSmlProfileContentHandler::StartEntity() |
|
976 // |
|
977 // |
|
978 //===================================================== |
|
979 TInt CNSmlProfileContentHandler::StartEntity(TDesC& /*aName*/) |
|
980 { |
|
981 |
|
982 return 1; |
|
983 } |
|
984 |
|
985 //===================================================== |
|
986 // CNSmlProfileContentHandler::EndEntity() |
|
987 // |
|
988 // |
|
989 //===================================================== |
|
990 TInt CNSmlProfileContentHandler::EndEntity(TDesC& /*aName*/) |
|
991 { |
|
992 |
|
993 return 1; |
|
994 } |
|
995 |
|
996 //===================================================== |
|
997 // CNSmlProfileContentHandler::SkippedEntity() |
|
998 // |
|
999 // |
|
1000 //===================================================== |
|
1001 TInt CNSmlProfileContentHandler::SkippedEntity(TDesC& /*aName*/) |
|
1002 { |
|
1003 return 1; |
|
1004 } |
|
1005 |
|
1006 //===================================================== |
|
1007 // CNSmlProfileContentHandler::Error() |
|
1008 // |
|
1009 // |
|
1010 //===================================================== |
|
1011 TInt CNSmlProfileContentHandler::Error(TInt /*aErrorCode*/, TInt /*aSeverity*/) |
|
1012 { |
|
1013 return 1; |
|
1014 } |
|
1015 |
|
1016 |
|
1017 |
|
1018 // End of File |