|
1 /* |
|
2 * Copyright (c) 2004 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 for CClientSessionData objects |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <s32mem.h> |
|
20 #include <featmgr.h> |
|
21 #include <badesca.h> // CDesCArray |
|
22 |
|
23 #include <nsmlconstants.h> |
|
24 #include <nsmldebug.h> |
|
25 #include "NSmlClientAPIUtils.h" |
|
26 #include "NSmlClientAPIDefs.h" |
|
27 #include "nsmlsosserverdefs.h" |
|
28 #include "NSmlTransportHandler.h" |
|
29 |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // |
|
34 // CNSmlClientAPIFeatureHandler |
|
35 // |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL() |
|
39 // Leaves with KErrNotSupported, if data sync is not supported. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 void NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL() |
|
43 { |
|
44 if ( ! FeatureManager::FeatureSupported( KFeatureIdSyncMlDs ) ) |
|
45 { |
|
46 _DBG_FILE("CNSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL: NOT SUPPORTED !"); |
|
47 User::Leave( KErrNotSupported ); |
|
48 } |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // NSmlClientAPIFeatureHandler::LeaveIfDevManNotSupportedL() |
|
53 // Leaves with KErrNotSupported, if device management is not |
|
54 // supported. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void NSmlClientAPIFeatureHandler::LeaveIfDevManNotSupportedL() |
|
58 { |
|
59 if ( ! FeatureManager::FeatureSupported( KFeatureIdSyncMlDm ) ) |
|
60 { |
|
61 _DBG_FILE("CNSmlClientAPIFeatureHandler::LeaveIfDevManNotSupportedL: NOT SUPPORTED !"); |
|
62 User::Leave( KErrNotSupported ); |
|
63 } |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // NSmlClientAPIFeatureHandler::LeaveIfUsageTypeNotSupportedL( |
|
68 // Leaves with KErrNotSupported, if the given usage type is |
|
69 // not supported. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void NSmlClientAPIFeatureHandler::LeaveIfUsageTypeNotSupportedL( TSmlUsageType aUsageType ) |
|
73 { |
|
74 switch ( aUsageType ) |
|
75 { |
|
76 case ESmlDataSync: |
|
77 NSmlClientAPIFeatureHandler::LeaveIfDataSyncNotSupportedL(); |
|
78 break; |
|
79 case ESmlDevMan: |
|
80 NSmlClientAPIFeatureHandler::LeaveIfDevManNotSupportedL(); |
|
81 break; |
|
82 default: |
|
83 break; |
|
84 } |
|
85 } |
|
86 |
|
87 |
|
88 // |
|
89 // CClientSessionData |
|
90 // |
|
91 |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CClientSessionData::CClientSessionData() |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CClientSessionData::CClientSessionData() |
|
98 : iDataPtr( 0, NULL, 0) |
|
99 { |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CClientSessionData::~CClientSessionData() |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 CClientSessionData::~CClientSessionData() |
|
107 { |
|
108 delete iBuffer; |
|
109 iBuffer = NULL; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CClientSessionData::InternalizeL() |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CClientSessionData::InternalizeL( RReadStream& /*aStream*/ ) |
|
117 { |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CClientSessionData::ExternalizeL() |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void CClientSessionData::ExternalizeL( RWriteStream& /*aStream*/ ) const |
|
125 { |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CClientSessionData::DataBuffer() |
|
130 // Returns reference to data buffer |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 CBufBase& CClientSessionData::DataBuffer() |
|
134 { |
|
135 return *iBuffer; |
|
136 } |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CClientSessionData::ReadIntegersToArrayL() |
|
139 // Reads integers from iBuffer to aArray. |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CClientSessionData::ReadIntegersToArrayL( RArray<TInt>& aArray ) |
|
143 { |
|
144 // read data using a stream |
|
145 RDesReadStream stream( iDataPtr ); |
|
146 CleanupClosePushL( stream ); |
|
147 |
|
148 TInt count = stream.ReadInt8L(); |
|
149 |
|
150 // append inttegers to array |
|
151 for ( TInt i = 0; i < count; ++i ) |
|
152 { |
|
153 aArray.AppendL( stream.ReadInt32L() ); |
|
154 } |
|
155 |
|
156 CleanupStack::PopAndDestroy(); // stream |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CClientSessionData::SetBufferSizeL() |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 void CClientSessionData::SetBufferSizeL( TInt aSize ) |
|
164 { |
|
165 if ( iBuffer ) |
|
166 { |
|
167 ClearDataBuffer(); |
|
168 } |
|
169 |
|
170 iBuffer = CBufFlat::NewL( KDefaultNSmlBufferGranularity ); |
|
171 if ( aSize != -1 ) |
|
172 { |
|
173 iBuffer->ResizeL( aSize ); |
|
174 } |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CClientSessionData::ClearDataBuffer() |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CClientSessionData::ClearDataBuffer() |
|
182 { |
|
183 delete iBuffer; |
|
184 iBuffer = NULL; |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CClientSessionData::DataBuffer() |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TPtr8& CClientSessionData::DataBufferPtr() |
|
192 { |
|
193 iDataPtr.Set( iBuffer->Ptr(0) ); |
|
194 return iDataPtr; |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CClientSessionData::PanicIfAlreadyCreated() |
|
199 // Panics the thread if the given pointer is not NULL, i.e. |
|
200 // the object has been instantiated. This method is used |
|
201 // in session and subsession objects to check that they are not |
|
202 // open when the session is opened/created. |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CClientSessionData::PanicIfAlreadyCreated( CClientSessionData* aPtr ) |
|
206 { |
|
207 if ( aPtr ) |
|
208 { |
|
209 _DBG_FILE("CClientSessionData::PanicIfAlreadyCreated: ALREADY CREATED !"); |
|
210 User::Panic(KNSmlClientAPIPanic, ESmlClientPanicSessionAlreadyOpen); |
|
211 } |
|
212 } |
|
213 |
|
214 |
|
215 // |
|
216 // CHistoryLogSessionData |
|
217 // |
|
218 |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // CHistoryLogSessionData::NewL() |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 CHistoryLogSessionData* CHistoryLogSessionData::NewL() |
|
225 { |
|
226 CHistoryLogSessionData* self = CHistoryLogSessionData::NewLC(); |
|
227 CleanupStack::Pop(); |
|
228 return self; |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // CHistoryLogSessionData::NewLC() |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 CHistoryLogSessionData* CHistoryLogSessionData::NewLC() |
|
236 { |
|
237 CHistoryLogSessionData* self = new (ELeave) CHistoryLogSessionData(); |
|
238 CleanupStack::PushL( self ); |
|
239 self->ConstructL(); |
|
240 return self; |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CHistoryLogSessionData::~CHistoryLogSessionData() |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 CHistoryLogSessionData::~CHistoryLogSessionData() |
|
248 { |
|
249 delete iHistoryArray; |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CHistoryLogSessionData::InternalizeL() |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 void CHistoryLogSessionData::InternalizeL( RReadStream& aStream ) |
|
257 { |
|
258 iHistoryArray->InternalizeL( aStream ); |
|
259 } |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // CHistoryLogSessionData::SetProfile() |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void CHistoryLogSessionData::SetProfile( const TSmlProfileId aProfileId ) |
|
266 { |
|
267 iProfileId = aProfileId; |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CHistoryLogSessionData::CHistoryLogSessionData() |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 CHistoryLogSessionData::CHistoryLogSessionData() |
|
275 : iProfileId( KNSmlNullId ) |
|
276 { |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CHistoryLogSessionData::ConstructL() |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CHistoryLogSessionData::ConstructL() |
|
284 { |
|
285 iHistoryArray = CNSmlHistoryArray::NewL(); |
|
286 iHistoryArray->SetOwnerShip( ETrue ); |
|
287 } |
|
288 |
|
289 |
|
290 // |
|
291 // CJobBaseSessionData |
|
292 // |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // CJobBaseSessionData::~CJobBaseSessionData() |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 CJobBaseSessionData::~CJobBaseSessionData() |
|
299 { |
|
300 iParams.Close(); |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // CJobBaseSessionData::InternalizeL() |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 void CJobBaseSessionData::InternalizeL( RReadStream& aStream ) |
|
308 { |
|
309 // read profile id |
|
310 iProfileId = aStream.ReadInt32L(); |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CJobBaseSessionData::WriteIntegersToBufferL() |
|
315 // Writes the integers in iParams to iBuffer. If aArray is |
|
316 // present, it's count is first written to the buffer (after |
|
317 // the values in aArray) and then the integers in aArray. |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 void CJobBaseSessionData::WriteIntegersToBufferL( const RArray<TInt>* aArray ) |
|
321 { |
|
322 TInt size = 0; |
|
323 |
|
324 if ( aArray ) |
|
325 { |
|
326 size += aArray->Count() * KSizeofTInt32; // size of items |
|
327 size += KSizeofTInt8; // count of items |
|
328 } |
|
329 |
|
330 size += iParams.Count() * KSizeofTInt32; |
|
331 |
|
332 SetBufferSizeL( size ); |
|
333 TPtr8 dataPtr = DataBufferPtr(); |
|
334 |
|
335 // open stream to iBuffer |
|
336 RDesWriteStream stream; |
|
337 stream.Open( dataPtr ); |
|
338 CleanupClosePushL( stream ); |
|
339 |
|
340 // write integers in iParams |
|
341 for ( TInt i = 0; i < iParams.Count(); ++i ) |
|
342 { |
|
343 stream.WriteInt32L( iParams[i] ); |
|
344 } |
|
345 |
|
346 // write the count of items in aArray and then the items (if any) |
|
347 if ( aArray ) |
|
348 { |
|
349 TInt count = aArray->Count(); |
|
350 |
|
351 stream.WriteInt8L( count ); |
|
352 |
|
353 for ( TInt j = 0; j < count; ++j ) |
|
354 { |
|
355 stream.WriteInt32L( (*aArray)[j] ); |
|
356 } |
|
357 } |
|
358 |
|
359 CleanupStack::PopAndDestroy(); // stream |
|
360 } |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // CJobBaseSessionData::AddParamL() |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 void CJobBaseSessionData::AddParamL( const TInt aParam ) |
|
367 { |
|
368 iParams.AppendL( aParam ); |
|
369 } |
|
370 |
|
371 // ----------------------------------------------------------------------------- |
|
372 // CJobBaseSessionData::SetIdentifier() |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 void CJobBaseSessionData::SetIdentifier( const TSmlJobId aJobId ) |
|
376 { |
|
377 iJobId = aJobId; |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CJobBaseSessionData::SetProfile() |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 void CJobBaseSessionData::SetProfile( const TSmlProfileId aProfileId ) |
|
385 { |
|
386 iProfileId = aProfileId; |
|
387 } |
|
388 |
|
389 // ----------------------------------------------------------------------------- |
|
390 // CJobBaseSessionData::CJobBaseSessionData() |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 CJobBaseSessionData::CJobBaseSessionData() |
|
394 : iJobId( KNSmlNullId ) |
|
395 { |
|
396 } |
|
397 |
|
398 |
|
399 // |
|
400 // CDataSyncJobSessionData |
|
401 // |
|
402 |
|
403 // ----------------------------------------------------------------------------- |
|
404 // CDataSyncJobSessionData::CDataSyncJobSessionData() |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 CDataSyncJobSessionData::CDataSyncJobSessionData() |
|
408 : CJobBaseSessionData() |
|
409 { |
|
410 } |
|
411 |
|
412 // ----------------------------------------------------------------------------- |
|
413 // CDataSyncJobSessionData::~CDataSyncJobSessionData() |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 CDataSyncJobSessionData::~CDataSyncJobSessionData() |
|
417 { |
|
418 iTasks.Close(); |
|
419 } |
|
420 |
|
421 // ----------------------------------------------------------------------------- |
|
422 // CDataSyncJobSessionData::InternalizeL() |
|
423 // ----------------------------------------------------------------------------- |
|
424 // |
|
425 void CDataSyncJobSessionData::InternalizeL( RReadStream& aStream ) |
|
426 { |
|
427 // base class internalization first |
|
428 CJobBaseSessionData::InternalizeL( aStream ); |
|
429 |
|
430 // read count and the task ids |
|
431 TInt count = aStream.ReadInt8L(); |
|
432 |
|
433 for ( TInt i = 0; i < count; ++i ) |
|
434 { |
|
435 iTasks.AppendL( aStream.ReadInt32L() ); |
|
436 } |
|
437 |
|
438 } |
|
439 |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // CDataSyncJobSessionData::SetTasksL() |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CDataSyncJobSessionData::SetTasksL( const RArray<TInt>& aTasks ) |
|
446 { |
|
447 iTasks.Reset(); |
|
448 |
|
449 for ( TInt i = 0; i < aTasks.Count(); ++i ) |
|
450 { |
|
451 iTasks.AppendL( aTasks[i] ); |
|
452 } |
|
453 } |
|
454 |
|
455 |
|
456 // |
|
457 // CDevManJobSessionData |
|
458 // |
|
459 |
|
460 |
|
461 // ----------------------------------------------------------------------------- |
|
462 // CDevManJobSessionData::CDevManJobSessionData() |
|
463 // ----------------------------------------------------------------------------- |
|
464 // |
|
465 CDevManJobSessionData::CDevManJobSessionData() |
|
466 : CJobBaseSessionData() |
|
467 { |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CDevManJobSessionData::~CDevManJobSessionData() |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 CDevManJobSessionData::~CDevManJobSessionData() |
|
475 { |
|
476 } |
|
477 |
|
478 // ----------------------------------------------------------------------------- |
|
479 // CDevManJobSessionData::InternalizeL() |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 void CDevManJobSessionData::InternalizeL( RReadStream& aStream ) |
|
483 { |
|
484 CJobBaseSessionData::InternalizeL( aStream ); |
|
485 } |
|
486 |
|
487 |
|
488 // |
|
489 // CProfileBaseSessionData |
|
490 // |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // CProfileBaseSessionData::CProfileBaseSessionData() |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 CProfileBaseSessionData::CProfileBaseSessionData() |
|
497 : iSanAction( ESmlConfirmSync ), iCreatorId( KNSmlNullId ), iProfileId( KNSmlNullId ), |
|
498 iOpenMode( ESmlOpenReadWrite ), iDeleteAllowed ( ETrue ),iProfileLocked ( EFalse ) |
|
499 { |
|
500 } |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // CProfileBaseSessionData::~CProfileBaseSessionData() |
|
504 // ----------------------------------------------------------------------------- |
|
505 // |
|
506 CProfileBaseSessionData::~CProfileBaseSessionData() |
|
507 { |
|
508 delete iUserName; |
|
509 delete iPassword; |
|
510 delete iDisplayName; |
|
511 delete iServerPassword; |
|
512 delete iServerId; |
|
513 } |
|
514 |
|
515 // ----------------------------------------------------------------------------- |
|
516 // CProfileBaseSessionData::InternalizeL() |
|
517 // ----------------------------------------------------------------------------- |
|
518 // |
|
519 void CProfileBaseSessionData::InternalizeL( RReadStream& aStream ) |
|
520 { |
|
521 iDisplayName = HBufC::NewL( aStream, aStream.ReadInt32L() ); |
|
522 iUserName = HBufC8::NewL( aStream, aStream.ReadInt32L() ); |
|
523 iPassword = HBufC8::NewL( aStream, aStream.ReadInt32L() ); |
|
524 iServerId = HBufC8::NewL( aStream, aStream.ReadInt32L() ); |
|
525 |
|
526 iSanAction = static_cast<TSmlServerAlertedAction>( aStream.ReadInt8L() ); |
|
527 iCreatorId = aStream.ReadInt32L(); |
|
528 |
|
529 iDeleteAllowed = aStream.ReadInt8L(); |
|
530 } |
|
531 |
|
532 // ----------------------------------------------------------------------------- |
|
533 // CProfileBaseSessionData::ExternalizeL() |
|
534 // ----------------------------------------------------------------------------- |
|
535 // |
|
536 void CProfileBaseSessionData::ExternalizeL( RWriteStream& aStream ) const |
|
537 { |
|
538 aStream.WriteInt32L( iDisplayName->Size() ); |
|
539 aStream << *iDisplayName; |
|
540 |
|
541 aStream.WriteInt32L( iUserName->Size() ); |
|
542 aStream << *iUserName; |
|
543 |
|
544 aStream.WriteInt32L( iPassword->Size() ); |
|
545 aStream << *iPassword; |
|
546 |
|
547 aStream.WriteInt32L( iServerId->Size() ); |
|
548 aStream << *iServerId; |
|
549 |
|
550 aStream.WriteInt8L( iSanAction ); |
|
551 aStream.WriteInt32L( iCreatorId ); |
|
552 } |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // CProfileBaseSessionData::SetType() |
|
556 // ----------------------------------------------------------------------------- |
|
557 // |
|
558 void CProfileBaseSessionData::SetType( TSmlUsageType aUsageType ) |
|
559 { |
|
560 iUsageType = aUsageType; |
|
561 } |
|
562 |
|
563 // ----------------------------------------------------------------------------- |
|
564 // CProfileBaseSessionData::SetCreatorId() |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 void CProfileBaseSessionData::SetCreatorId( TSmlCreatorId aCreatorId ) |
|
568 { |
|
569 iCreatorId = aCreatorId; |
|
570 } |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // CProfileBaseSessionData::SetIdentifier() |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 void CProfileBaseSessionData::SetIdentifier( TSmlProfileId aProfileId ) |
|
577 { |
|
578 iProfileId = aProfileId; |
|
579 } |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // CProfileBaseSessionData::SetDeleteAllowed() |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 void CProfileBaseSessionData::SetDeleteAllowed( const TBool aDeleteAllowed ) |
|
586 { |
|
587 iDeleteAllowed = aDeleteAllowed; |
|
588 } |
|
589 // ----------------------------------------------------------------------------- |
|
590 // CProfileBaseSessionData::SetProfileLock() |
|
591 // ----------------------------------------------------------------------------- |
|
592 // |
|
593 void CProfileBaseSessionData::SetProfileLock( const TBool aProfileLocked ) |
|
594 { |
|
595 iProfileLocked = aProfileLocked; |
|
596 } |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CProfileBaseSessionData::SetOpenMode() |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 void CProfileBaseSessionData::SetOpenMode( TSmlOpenMode aOpenMode ) |
|
602 { |
|
603 iOpenMode = aOpenMode; |
|
604 } |
|
605 |
|
606 // ----------------------------------------------------------------------------- |
|
607 // CProfileBaseSessionData::SetDisplayNameL() |
|
608 // ----------------------------------------------------------------------------- |
|
609 // |
|
610 void CProfileBaseSessionData::SetDisplayNameL( const TDesC& aDisplayName ) |
|
611 { |
|
612 delete iDisplayName; |
|
613 iDisplayName = NULL; |
|
614 iDisplayName = aDisplayName.AllocL(); |
|
615 } |
|
616 |
|
617 // ----------------------------------------------------------------------------- |
|
618 // CProfileBaseSessionData::SetUserNameL() |
|
619 // ----------------------------------------------------------------------------- |
|
620 // |
|
621 void CProfileBaseSessionData::SetUserNameL( const TDesC8& aUserName ) |
|
622 { |
|
623 delete iUserName; |
|
624 iUserName = NULL; |
|
625 iUserName = aUserName.AllocL(); |
|
626 } |
|
627 |
|
628 // ----------------------------------------------------------------------------- |
|
629 // CProfileBaseSessionData::SetPasswordL() |
|
630 // ----------------------------------------------------------------------------- |
|
631 // |
|
632 void CProfileBaseSessionData::SetPasswordL( const TDesC8& aPassword ) |
|
633 { |
|
634 delete iPassword; |
|
635 iPassword = NULL; |
|
636 iPassword = aPassword.AllocL(); |
|
637 } |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CProfileBaseSessionData::SetProfileLockL() |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 void CProfileBaseSessionData::SetProfileLockL( RReadStream& aStream ) |
|
644 { |
|
645 iProfileLocked = aStream.ReadInt8L(); |
|
646 } |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // CProfileBaseSessionData::GetProfileLockL() |
|
650 // ----------------------------------------------------------------------------- |
|
651 // |
|
652 void CProfileBaseSessionData::GetProfileLockL( RWriteStream& aStream ) const |
|
653 { |
|
654 aStream.WriteInt8L( iProfileLocked ); |
|
655 } |
|
656 // ----------------------------------------------------------------------------- |
|
657 // CProfileBaseSessionData::SetServerPasswordL() |
|
658 // ----------------------------------------------------------------------------- |
|
659 // |
|
660 void CProfileBaseSessionData::SetServerPasswordL( const TDesC8& aServerPassword ) |
|
661 { |
|
662 delete iServerPassword; |
|
663 iServerPassword = NULL; |
|
664 iServerPassword = aServerPassword.AllocL(); |
|
665 } |
|
666 |
|
667 // ----------------------------------------------------------------------------- |
|
668 // CProfileBaseSessionData::SetServerIdL() |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 void CProfileBaseSessionData::SetServerIdL( const TDesC8& aServerId ) |
|
672 { |
|
673 delete iServerId; |
|
674 iServerId = NULL; |
|
675 iServerId = aServerId.AllocL(); |
|
676 } |
|
677 |
|
678 // ----------------------------------------------------------------------------- |
|
679 // CProfileBaseSessionData::SetSanAction() |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 void CProfileBaseSessionData::SetSanAction( const TSmlServerAlertedAction aSanAction ) |
|
683 { |
|
684 iSanAction = aSanAction; |
|
685 } |
|
686 |
|
687 // ----------------------------------------------------------------------------- |
|
688 // CProfileBaseSessionData::SetProtocolVersionL() |
|
689 // ----------------------------------------------------------------------------- |
|
690 // |
|
691 void CProfileBaseSessionData::SetProtocolVersionL( const TSmlProtocolVersion aVersion ) |
|
692 { |
|
693 if ( iUsageType == ESmlDevMan && aVersion != ESmlVersion1_1_2 ) |
|
694 { |
|
695 User::Leave( KErrNotSupported ); |
|
696 } |
|
697 |
|
698 iProtocolVersion = aVersion; |
|
699 } |
|
700 |
|
701 // ----------------------------------------------------------------------------- |
|
702 // CProfileBaseSessionData::BaseConstructL() |
|
703 // ----------------------------------------------------------------------------- |
|
704 // |
|
705 void CProfileBaseSessionData::BaseConstructL( TBool aInitValues ) |
|
706 { |
|
707 if ( aInitValues ) |
|
708 { |
|
709 InitValuesL(); |
|
710 } |
|
711 } |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // CProfileBaseSessionData::InitValuesL() |
|
715 // Inits member variables so that they can be safely |
|
716 // externalized. |
|
717 // ----------------------------------------------------------------------------- |
|
718 // |
|
719 void CProfileBaseSessionData::InitValuesL() |
|
720 { |
|
721 iDisplayName = KNSmlInitialString().AllocL(); |
|
722 iServerPassword = KNSmlInitialString8().AllocL(); |
|
723 iUserName = KNSmlInitialString8().AllocL(); |
|
724 iPassword = KNSmlInitialString8().AllocL(); |
|
725 iServerId = KNSmlInitialString8().AllocL(); |
|
726 } |
|
727 |
|
728 |
|
729 // |
|
730 // CDataSyncProfileSessionData |
|
731 // |
|
732 |
|
733 // ----------------------------------------------------------------------------- |
|
734 // CDataSyncProfileSessionData::NewL() |
|
735 // ----------------------------------------------------------------------------- |
|
736 // |
|
737 CDataSyncProfileSessionData* CDataSyncProfileSessionData::NewL( const TBool aInitValues ) |
|
738 { |
|
739 CDataSyncProfileSessionData* self = CDataSyncProfileSessionData::NewLC( aInitValues ); |
|
740 CleanupStack::Pop(); |
|
741 return self; |
|
742 } |
|
743 |
|
744 // ----------------------------------------------------------------------------- |
|
745 // CDataSyncProfileSessionData::NewLC() |
|
746 // ----------------------------------------------------------------------------- |
|
747 // |
|
748 CDataSyncProfileSessionData* CDataSyncProfileSessionData::NewLC( const TBool aInitValues ) |
|
749 { |
|
750 CDataSyncProfileSessionData* self = new (ELeave) CDataSyncProfileSessionData(); |
|
751 CleanupStack::PushL( self ); |
|
752 self->ConstructL( aInitValues ); |
|
753 return self; |
|
754 } |
|
755 |
|
756 // ----------------------------------------------------------------------------- |
|
757 // CDataSyncProfileSessionData::InternalizeL() |
|
758 // ----------------------------------------------------------------------------- |
|
759 // |
|
760 void CDataSyncProfileSessionData::InternalizeL( RReadStream& aStream ) |
|
761 { |
|
762 CProfileBaseSessionData::InternalizeL( aStream ); |
|
763 SetProtocolVersionL( static_cast<TSmlProtocolVersion>( aStream.ReadInt8L() ) ); |
|
764 SetServerPasswordL( KNSmlInitialString8() ); // not received in internalize, dm spesific |
|
765 } |
|
766 |
|
767 // ----------------------------------------------------------------------------- |
|
768 // CDataSyncProfileSessionData::ExternalizeL() |
|
769 // ----------------------------------------------------------------------------- |
|
770 // |
|
771 void CDataSyncProfileSessionData::ExternalizeL( RWriteStream& aStream ) const |
|
772 { |
|
773 CProfileBaseSessionData::ExternalizeL( aStream ); |
|
774 aStream.WriteInt8L( ProtocolVersion() ); |
|
775 aStream.CommitL(); |
|
776 } |
|
777 |
|
778 // ----------------------------------------------------------------------------- |
|
779 // CDataSyncProfileSessionData::~CDataSyncProfileSessionData() |
|
780 // ----------------------------------------------------------------------------- |
|
781 // |
|
782 CDataSyncProfileSessionData::~CDataSyncProfileSessionData() |
|
783 { |
|
784 } |
|
785 |
|
786 // ----------------------------------------------------------------------------- |
|
787 // CDataSyncProfileSessionData::CDataSyncProfileSessionData() |
|
788 // ----------------------------------------------------------------------------- |
|
789 // |
|
790 CDataSyncProfileSessionData::CDataSyncProfileSessionData() |
|
791 : CProfileBaseSessionData() |
|
792 { |
|
793 SetType( ESmlDataSync ); |
|
794 } |
|
795 |
|
796 // ----------------------------------------------------------------------------- |
|
797 // CDataSyncProfileSessionData::ConstructL() |
|
798 // ----------------------------------------------------------------------------- |
|
799 // |
|
800 void CDataSyncProfileSessionData::ConstructL( const TBool aInitValues ) |
|
801 { |
|
802 BaseConstructL( aInitValues ); |
|
803 SetProtocolVersionL( ESmlVersion1_2 ); |
|
804 } |
|
805 |
|
806 |
|
807 // |
|
808 // CDevManProfileSessionData |
|
809 // |
|
810 |
|
811 // ----------------------------------------------------------------------------- |
|
812 // CDevManProfileSessionData::NewL() |
|
813 // ----------------------------------------------------------------------------- |
|
814 // |
|
815 CDevManProfileSessionData* CDevManProfileSessionData::NewL( const TBool aInitValues ) |
|
816 { |
|
817 CDevManProfileSessionData* self = CDevManProfileSessionData::NewLC( aInitValues ); |
|
818 CleanupStack::Pop(); |
|
819 return self; |
|
820 } |
|
821 |
|
822 // ----------------------------------------------------------------------------- |
|
823 // CDevManProfileSessionData::NewLC() |
|
824 // ----------------------------------------------------------------------------- |
|
825 // |
|
826 CDevManProfileSessionData* CDevManProfileSessionData::NewLC( const TBool aInitValues ) |
|
827 { |
|
828 CDevManProfileSessionData* self = new (ELeave) CDevManProfileSessionData(); |
|
829 CleanupStack::PushL( self ); |
|
830 self->ConstructL( aInitValues ); |
|
831 return self; |
|
832 } |
|
833 |
|
834 // ----------------------------------------------------------------------------- |
|
835 // CDevManProfileSessionData::InternalizeL() |
|
836 // ----------------------------------------------------------------------------- |
|
837 // |
|
838 void CDevManProfileSessionData::InternalizeL( RReadStream& aStream ) |
|
839 { |
|
840 CProfileBaseSessionData::InternalizeL( aStream ); |
|
841 SetProfileLockL(aStream); |
|
842 HBufC8* passwd = HBufC8::NewLC( aStream, aStream.ReadInt32L() ); |
|
843 SetServerPasswordL( *passwd ); |
|
844 CleanupStack::PopAndDestroy(); |
|
845 } |
|
846 |
|
847 // ----------------------------------------------------------------------------- |
|
848 // CDevManProfileSessionData::ExternalizeL( |
|
849 // ----------------------------------------------------------------------------- |
|
850 // |
|
851 void CDevManProfileSessionData::ExternalizeL( RWriteStream& aStream ) const |
|
852 { |
|
853 CProfileBaseSessionData::ExternalizeL( aStream ); |
|
854 GetProfileLockL(aStream); |
|
855 aStream.WriteInt32L( ServerPassword().Size() ); |
|
856 aStream << ServerPassword(); |
|
857 aStream.CommitL(); |
|
858 } |
|
859 |
|
860 // ----------------------------------------------------------------------------- |
|
861 // CDevManProfileSessionData::~CDevManProfileSessionData() |
|
862 // ----------------------------------------------------------------------------- |
|
863 // |
|
864 CDevManProfileSessionData::~CDevManProfileSessionData() |
|
865 { |
|
866 } |
|
867 |
|
868 // ----------------------------------------------------------------------------- |
|
869 // CDevManProfileSessionData::CDevManProfileSessionData() |
|
870 // ----------------------------------------------------------------------------- |
|
871 // |
|
872 CDevManProfileSessionData::CDevManProfileSessionData() |
|
873 : CProfileBaseSessionData() |
|
874 { |
|
875 SetType( ESmlDevMan ); |
|
876 } |
|
877 |
|
878 // ----------------------------------------------------------------------------- |
|
879 // CDevManProfileSessionData::ConstructL( |
|
880 // ----------------------------------------------------------------------------- |
|
881 // |
|
882 void CDevManProfileSessionData::ConstructL( const TBool aInitValues ) |
|
883 { |
|
884 BaseConstructL( aInitValues ); |
|
885 SetProtocolVersionL( ESmlVersion1_1_2 ); // not received in internalize |
|
886 } |
|
887 |
|
888 |
|
889 // |
|
890 // CTaskSessionData |
|
891 // |
|
892 |
|
893 // ----------------------------------------------------------------------------- |
|
894 // CTaskSessionData::NewL() |
|
895 // ----------------------------------------------------------------------------- |
|
896 // |
|
897 CTaskSessionData* CTaskSessionData::NewL( const TBool aInitValues ) |
|
898 { |
|
899 CTaskSessionData* self = CTaskSessionData::NewLC( aInitValues ); |
|
900 CleanupStack::Pop(); |
|
901 return self; |
|
902 } |
|
903 |
|
904 // ----------------------------------------------------------------------------- |
|
905 // CTaskSessionData::NewLC() |
|
906 // ----------------------------------------------------------------------------- |
|
907 // |
|
908 CTaskSessionData* CTaskSessionData::NewLC( const TBool aInitValues ) |
|
909 { |
|
910 CTaskSessionData* self = new (ELeave) CTaskSessionData(); |
|
911 CleanupStack::PushL( self ); |
|
912 self->ConstructL( aInitValues ); |
|
913 return self; |
|
914 } |
|
915 |
|
916 // ----------------------------------------------------------------------------- |
|
917 // CTaskSessionData::~CTaskSessionData() |
|
918 // ----------------------------------------------------------------------------- |
|
919 // |
|
920 CTaskSessionData::~CTaskSessionData() |
|
921 { |
|
922 delete iDisplayName; |
|
923 delete iServerDataSource; |
|
924 delete iClientDataSource; |
|
925 |
|
926 iFilterArray.ResetAndDestroy(); |
|
927 iFilterArray.Close(); |
|
928 } |
|
929 |
|
930 // ----------------------------------------------------------------------------- |
|
931 // CTaskSessionData::InternalizeL() |
|
932 // ----------------------------------------------------------------------------- |
|
933 // |
|
934 void CTaskSessionData::InternalizeL( RReadStream& aStream ) |
|
935 { |
|
936 iServerDataSource = HBufC::NewL( aStream, aStream.ReadInt32L() ); |
|
937 iClientDataSource = HBufC::NewL( aStream, aStream.ReadInt32L() ); |
|
938 |
|
939 iDataProviderId = aStream.ReadInt32L(); |
|
940 iEnabled = aStream.ReadInt8L(); |
|
941 iCreatorId = aStream.ReadInt32L(); |
|
942 |
|
943 iDisplayName = HBufC::NewL( aStream, aStream.ReadInt32L() ); |
|
944 |
|
945 iDefaultSyncType = static_cast<TSmlSyncType>( aStream.ReadInt8L() ); |
|
946 |
|
947 } |
|
948 |
|
949 // ----------------------------------------------------------------------------- |
|
950 // CTaskSessionData::ExternalizeL( |
|
951 // ----------------------------------------------------------------------------- |
|
952 // |
|
953 void CTaskSessionData::ExternalizeL( RWriteStream& aStream ) const |
|
954 { |
|
955 aStream.WriteInt32L( iServerDataSource->Size() ); |
|
956 aStream << *iServerDataSource; |
|
957 |
|
958 aStream.WriteInt32L( iClientDataSource->Size() ); |
|
959 aStream << *iClientDataSource; |
|
960 |
|
961 aStream.WriteInt8L( iEnabled ); |
|
962 aStream.WriteInt32L( iCreatorId ); |
|
963 |
|
964 aStream.WriteInt32L( iDisplayName->Size() ); |
|
965 aStream << *iDisplayName; |
|
966 |
|
967 aStream.WriteInt8L( iDefaultSyncType ); |
|
968 |
|
969 aStream.WriteInt8L( iFilterMatchType ); |
|
970 |
|
971 aStream.WriteInt32L( FilterBufSize() ); |
|
972 |
|
973 aStream.WriteInt32L( iFilterArray.Count() ); |
|
974 |
|
975 |
|
976 for (TInt i = 0; i < iFilterArray.Count(); i++) |
|
977 { |
|
978 CSyncMLFilter* filter = iFilterArray[i]; |
|
979 filter->ExternalizeL( aStream ); |
|
980 } |
|
981 |
|
982 aStream.CommitL(); |
|
983 } |
|
984 |
|
985 // ----------------------------------------------------------------------------- |
|
986 // CTaskSessionData::FilterDataSize() |
|
987 // Returns the size of the buffer needed for externalizing |
|
988 // this object. |
|
989 // ----------------------------------------------------------------------------- |
|
990 // |
|
991 TInt CTaskSessionData::FilterDataSize() const |
|
992 { |
|
993 |
|
994 TInt size(0); |
|
995 |
|
996 //CSyncMLFilter |
|
997 for ( TInt index = 0; index < iFilterArray.Count(); index++ ) |
|
998 { |
|
999 size += iFilterArray[index]->DataSize(); |
|
1000 } |
|
1001 |
|
1002 return size; |
|
1003 } |
|
1004 |
|
1005 // ----------------------------------------------------------------------------- |
|
1006 // CTaskSessionData::SetEnabled() |
|
1007 // |
|
1008 // ----------------------------------------------------------------------------- |
|
1009 // |
|
1010 void CTaskSessionData::SetEnabled( const TBool aEnabled ) |
|
1011 { |
|
1012 iEnabled = aEnabled; |
|
1013 } |
|
1014 |
|
1015 // ----------------------------------------------------------------------------- |
|
1016 // CTaskSessionData::SetReadOnly() |
|
1017 // ----------------------------------------------------------------------------- |
|
1018 // |
|
1019 void CTaskSessionData::SetReadOnly( TBool aReadOnly ) |
|
1020 { |
|
1021 iReadOnly = aReadOnly; |
|
1022 } |
|
1023 |
|
1024 // ----------------------------------------------------------------------------- |
|
1025 // CTaskSessionData::SetIdentifier() |
|
1026 // ----------------------------------------------------------------------------- |
|
1027 // |
|
1028 void CTaskSessionData::SetIdentifier( const TSmlTaskId aTaskId ) |
|
1029 { |
|
1030 iTaskId = aTaskId; |
|
1031 } |
|
1032 |
|
1033 // ----------------------------------------------------------------------------- |
|
1034 // CTaskSessionData::SetProfile() |
|
1035 // ----------------------------------------------------------------------------- |
|
1036 // |
|
1037 void CTaskSessionData::SetProfile( const TSmlProfileId aProfileId ) |
|
1038 { |
|
1039 iProfileId = aProfileId; |
|
1040 } |
|
1041 |
|
1042 // ----------------------------------------------------------------------------- |
|
1043 // CTaskSessionData::SetCreatorId() |
|
1044 // ----------------------------------------------------------------------------- |
|
1045 // |
|
1046 void CTaskSessionData::SetCreatorId( const TSmlCreatorId aCreatorId ) |
|
1047 { |
|
1048 iCreatorId = aCreatorId; |
|
1049 } |
|
1050 |
|
1051 // ----------------------------------------------------------------------------- |
|
1052 // CTaskSessionData::SetDisplayNameL() |
|
1053 // ----------------------------------------------------------------------------- |
|
1054 // |
|
1055 void CTaskSessionData::SetDisplayNameL( const TDesC& aDisplayName ) |
|
1056 { |
|
1057 delete iDisplayName; |
|
1058 iDisplayName = NULL; |
|
1059 iDisplayName = aDisplayName.AllocL(); |
|
1060 } |
|
1061 |
|
1062 // ----------------------------------------------------------------------------- |
|
1063 // CTaskSessionData::SetDefaultSyncType() |
|
1064 // ----------------------------------------------------------------------------- |
|
1065 // |
|
1066 void CTaskSessionData::SetDefaultSyncType( const TSmlSyncType aSyncType ) |
|
1067 { |
|
1068 iDefaultSyncType = aSyncType; |
|
1069 } |
|
1070 |
|
1071 // ----------------------------------------------------------------------------- |
|
1072 // CTaskSessionData::SetFilterMatchType() |
|
1073 // ----------------------------------------------------------------------------- |
|
1074 // |
|
1075 void CTaskSessionData::SetFilterMatchType( TSyncMLFilterMatchType aFilterMatchType ) |
|
1076 { |
|
1077 iFilterMatchType = aFilterMatchType; |
|
1078 } |
|
1079 |
|
1080 // ----------------------------------------------------------------------------- |
|
1081 // CTaskSessionData::SetServerDataSourceL() |
|
1082 // ----------------------------------------------------------------------------- |
|
1083 // |
|
1084 void CTaskSessionData::SetServerDataSourceL( const TDesC& aServerDataSource ) |
|
1085 { |
|
1086 delete iServerDataSource; |
|
1087 iServerDataSource = NULL; |
|
1088 iServerDataSource = aServerDataSource.AllocL(); |
|
1089 } |
|
1090 |
|
1091 // ----------------------------------------------------------------------------- |
|
1092 // CTaskSessionData::SetClientDataSourceL() |
|
1093 // ----------------------------------------------------------------------------- |
|
1094 // |
|
1095 void CTaskSessionData::SetClientDataSourceL( const TDesC& aClientDataSource ) |
|
1096 { |
|
1097 delete iClientDataSource; |
|
1098 iClientDataSource = NULL; |
|
1099 iClientDataSource = aClientDataSource.AllocL(); |
|
1100 } |
|
1101 |
|
1102 // ----------------------------------------------------------------------------- |
|
1103 // CTaskSessionData::SetDataProvider() |
|
1104 // ----------------------------------------------------------------------------- |
|
1105 // |
|
1106 void CTaskSessionData::SetDataProvider( const TSmlDataProviderId aDataProviderId ) |
|
1107 { |
|
1108 iDataProviderId = aDataProviderId; |
|
1109 } |
|
1110 |
|
1111 // ----------------------------------------------------------------------------- |
|
1112 // CTaskSessionData::CTaskSessionData() |
|
1113 // ----------------------------------------------------------------------------- |
|
1114 // |
|
1115 CTaskSessionData::CTaskSessionData() |
|
1116 : iCreatorId( KNSmlNullId ), iTaskId( KNSmlNullId ), |
|
1117 iReadOnly( EFalse ), iEnabled( ETrue ) |
|
1118 { |
|
1119 } |
|
1120 |
|
1121 // ----------------------------------------------------------------------------- |
|
1122 // CTaskSessionData::ConstructL() |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // |
|
1125 void CTaskSessionData::ConstructL( const TBool aInitValues ) |
|
1126 { |
|
1127 if ( aInitValues ) |
|
1128 { |
|
1129 InitValuesL(); |
|
1130 } |
|
1131 } |
|
1132 |
|
1133 // ----------------------------------------------------------------------------- |
|
1134 // CTaskSessionData::InitValuesL() |
|
1135 // ----------------------------------------------------------------------------- |
|
1136 // |
|
1137 void CTaskSessionData::InitValuesL() |
|
1138 { |
|
1139 iDisplayName = KNSmlInitialString().AllocL(); |
|
1140 iServerDataSource = KNSmlInitialString().AllocL(); |
|
1141 iClientDataSource = KNSmlInitialString().AllocL(); |
|
1142 } |
|
1143 |
|
1144 // ----------------------------------------------------------------------------- |
|
1145 // CTaskSessionData::SetServerSupportedFiltersL( TDesC8& aData ) |
|
1146 // ----------------------------------------------------------------------------- |
|
1147 // |
|
1148 void CTaskSessionData::SetTaskSupportedFiltersL( TDesC8& aData ) |
|
1149 { |
|
1150 RDesReadStream stream; |
|
1151 stream.Open( aData ); |
|
1152 CleanupClosePushL( stream ); |
|
1153 |
|
1154 //Clear filter buffer |
|
1155 iFilterArray.ResetAndDestroy(); |
|
1156 |
|
1157 iFilterChangeInfo = ( TSyncMLFilterChangeInfo ) stream.ReadInt8L(); |
|
1158 iFilterMatchType = ( TSyncMLFilterMatchType ) stream.ReadInt8L(); |
|
1159 TInt count = stream.ReadInt32L(); |
|
1160 |
|
1161 for ( TInt i = 0; i < count; i++ ) |
|
1162 { |
|
1163 CSyncMLFilter* filter = CSyncMLFilter::NewLC( stream ); |
|
1164 iFilterArray.AppendL( filter ); |
|
1165 CleanupStack::Pop(); //filter |
|
1166 } |
|
1167 CleanupStack::PopAndDestroy(); //stream |
|
1168 } |
|
1169 |
|
1170 // ----------------------------------------------------------------------------- |
|
1171 // CTaskSessionData::CopyTaskSupportedFiltersL( RPointerArray<CSyncMLFilter>& aFilterArray ) |
|
1172 // Ownership is moved from caller |
|
1173 // ----------------------------------------------------------------------------- |
|
1174 // |
|
1175 void CTaskSessionData::CopyTaskSupportedFiltersL( RPointerArray<CSyncMLFilter>& aFilterArray ) |
|
1176 { |
|
1177 iFilterArray.ResetAndDestroy(); |
|
1178 |
|
1179 while ( aFilterArray.Count() ) |
|
1180 { |
|
1181 CSyncMLFilter* filter = aFilterArray[0]; |
|
1182 iFilterArray.AppendL( filter ); |
|
1183 aFilterArray.Remove(0); |
|
1184 } |
|
1185 } |
|
1186 |
|
1187 // ----------------------------------------------------------------------------- |
|
1188 // CTaskSessionData::FilterArray() |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // |
|
1191 RPointerArray<CSyncMLFilter>& CTaskSessionData::FilterArray() |
|
1192 { |
|
1193 return iFilterArray; |
|
1194 } |
|
1195 |
|
1196 // |
|
1197 // CConnectionSessionData |
|
1198 // |
|
1199 |
|
1200 |
|
1201 // ----------------------------------------------------------------------------- |
|
1202 // CConnectionSessionData::NewL() |
|
1203 // Two-phase construction. Set aInitValues to ETrue, when the |
|
1204 // data is not internalized from stream. In that case data members |
|
1205 // are set to such values that this object can be successfully |
|
1206 // externalized. |
|
1207 // ----------------------------------------------------------------------------- |
|
1208 // |
|
1209 CConnectionSessionData* CConnectionSessionData::NewL( const TSmlTransportId aId, const TSmlUsageType aUsageType, const TBool aInitValues ) |
|
1210 { |
|
1211 CConnectionSessionData* self = CConnectionSessionData::NewLC( aId, aUsageType, aInitValues ); |
|
1212 CleanupStack::Pop(); |
|
1213 return self; |
|
1214 } |
|
1215 |
|
1216 // ----------------------------------------------------------------------------- |
|
1217 // CConnectionSessionData::NewLC() |
|
1218 // ----------------------------------------------------------------------------- |
|
1219 // |
|
1220 CConnectionSessionData* CConnectionSessionData::NewLC( const TSmlTransportId aId, const TSmlUsageType aUsageType, const TBool aInitValues ) |
|
1221 { |
|
1222 CConnectionSessionData* self = new (ELeave) CConnectionSessionData( aId ); |
|
1223 CleanupStack::PushL(self); |
|
1224 self->ConstructL( aInitValues, aUsageType ); |
|
1225 return self; |
|
1226 } |
|
1227 |
|
1228 // ----------------------------------------------------------------------------- |
|
1229 // CConnectionSessionData::~CConnectionSessionData() |
|
1230 // ----------------------------------------------------------------------------- |
|
1231 // |
|
1232 CConnectionSessionData::~CConnectionSessionData() |
|
1233 { |
|
1234 iPropVals.ResetAndDestroy(); |
|
1235 iPropVals.Close(); |
|
1236 |
|
1237 delete iHandler; |
|
1238 delete iServerURI; |
|
1239 } |
|
1240 |
|
1241 // ----------------------------------------------------------------------------- |
|
1242 // CConnectionSessionData::InternalizeL() |
|
1243 // ----------------------------------------------------------------------------- |
|
1244 // |
|
1245 void CConnectionSessionData::InternalizeL( RReadStream& aStream ) |
|
1246 { |
|
1247 iPropVals.ResetAndDestroy(); |
|
1248 delete iServerURI; |
|
1249 iServerURI = NULL; |
|
1250 |
|
1251 // read server uri |
|
1252 iServerURI = HBufC8::NewL( aStream, aStream.ReadInt32L() ); |
|
1253 |
|
1254 // read each property |
|
1255 TInt count = iHandler->Array().Count(); |
|
1256 for ( TInt i = 0; i < count; ++i ) |
|
1257 { |
|
1258 TInt data = aStream.ReadInt32L(); |
|
1259 switch ( iHandler->Array()[i].iDataType ) |
|
1260 { |
|
1261 |
|
1262 case EDataTypeText8: |
|
1263 { |
|
1264 // data is the size of the string |
|
1265 HBufC8* value = HBufC8::NewLC( aStream, data ); |
|
1266 iPropVals.AppendL( value ); |
|
1267 CleanupStack::Pop(); |
|
1268 } |
|
1269 break; |
|
1270 |
|
1271 case EDataTypeNumber: |
|
1272 case EDataTypeBoolean: |
|
1273 { |
|
1274 // data is the value, convert it to string |
|
1275 HBufC8* value = HBufC8::NewLC( KNSmlMaxInt32Length ); |
|
1276 value->Des().Num( data ); |
|
1277 iPropVals.AppendL( value ); |
|
1278 CleanupStack::Pop(); |
|
1279 } |
|
1280 break; |
|
1281 |
|
1282 default: |
|
1283 _DBG_FILE("CConnectionSessionData::InternalizeL: UNKNOWN DATATYPE !"); |
|
1284 User::Panic( KNSmlClientAPIPanic, KErrUnknown ); |
|
1285 } |
|
1286 |
|
1287 } |
|
1288 } |
|
1289 |
|
1290 // ----------------------------------------------------------------------------- |
|
1291 // CConnectionSessionData::ExternalizeL() |
|
1292 // ----------------------------------------------------------------------------- |
|
1293 // |
|
1294 void CConnectionSessionData::ExternalizeL( RWriteStream& aStream ) const |
|
1295 { |
|
1296 // write transport id and server uri |
|
1297 aStream.WriteInt32L( iId ); |
|
1298 aStream.WriteInt32L( iServerURI->Size() ); |
|
1299 aStream << *iServerURI; |
|
1300 |
|
1301 // write each property |
|
1302 TInt count = iHandler->Array().Count(); |
|
1303 for ( TInt i = 0; i < count; ++i ) |
|
1304 { |
|
1305 switch ( iHandler->Array()[i].iDataType ) |
|
1306 { |
|
1307 |
|
1308 case EDataTypeText8: |
|
1309 { |
|
1310 aStream.WriteInt32L( iPropVals[i]->Size() ); |
|
1311 aStream << *iPropVals[i]; |
|
1312 } |
|
1313 break; |
|
1314 |
|
1315 case EDataTypeNumber: |
|
1316 case EDataTypeBoolean: |
|
1317 { |
|
1318 TLex8 lex( *iPropVals[i] ); |
|
1319 TInt value = 0; |
|
1320 lex.Val( value ); |
|
1321 aStream.WriteInt32L( value ); |
|
1322 } |
|
1323 break; |
|
1324 |
|
1325 default: |
|
1326 _DBG_FILE("CConnectionSessionData::ExternalizeL: UNKNOWN DATATYPE !"); |
|
1327 User::Panic( KNSmlClientAPIPanic, KErrUnknown ); |
|
1328 } |
|
1329 |
|
1330 } |
|
1331 |
|
1332 aStream.CommitL(); |
|
1333 } |
|
1334 |
|
1335 // ----------------------------------------------------------------------------- |
|
1336 // CConnectionSessionData::GetPropertyL() |
|
1337 // Finds and returns the value of the given property. If |
|
1338 // it is not found, leaves with KErrNotFound. |
|
1339 // ----------------------------------------------------------------------------- |
|
1340 // |
|
1341 const TDesC8& CConnectionSessionData::GetPropertyL( const TDesC8& aName ) const |
|
1342 { |
|
1343 TInt index = FindL( aName ); |
|
1344 return *iPropVals[ index ]; |
|
1345 } |
|
1346 |
|
1347 // ----------------------------------------------------------------------------- |
|
1348 // CConnectionSessionData::SetPropertyL() |
|
1349 // If this transport has a property with name aName, then |
|
1350 // that property's value is set to aValue. |
|
1351 // ----------------------------------------------------------------------------- |
|
1352 // |
|
1353 void CConnectionSessionData::SetPropertyL( const TDesC8& aName, const TDesC8& aValue ) |
|
1354 { |
|
1355 TInt index = FindL( aName ); |
|
1356 delete iPropVals[ index ]; |
|
1357 iPropVals[ index ] = NULL; |
|
1358 iPropVals[ index ] = aValue.AllocL(); |
|
1359 } |
|
1360 |
|
1361 // ----------------------------------------------------------------------------- |
|
1362 // CConnectionSessionData::SetPriority() |
|
1363 // Not supported. |
|
1364 // ----------------------------------------------------------------------------- |
|
1365 // |
|
1366 void CConnectionSessionData::SetPriority( const TUint /*aPriority*/ ) |
|
1367 { |
|
1368 } |
|
1369 |
|
1370 // ----------------------------------------------------------------------------- |
|
1371 // CConnectionSessionData::SetRetryCount() |
|
1372 // Not supported. |
|
1373 // ----------------------------------------------------------------------------- |
|
1374 // |
|
1375 void CConnectionSessionData::SetRetryCount( const TUint /*aRetryCount*/ ) |
|
1376 { |
|
1377 } |
|
1378 |
|
1379 // ----------------------------------------------------------------------------- |
|
1380 // CConnectionSessionData::SetServerURIL() |
|
1381 // ----------------------------------------------------------------------------- |
|
1382 // |
|
1383 void CConnectionSessionData::SetServerURIL( const TDesC8& aServerURI ) |
|
1384 { |
|
1385 delete iServerURI; |
|
1386 iServerURI = NULL; |
|
1387 iServerURI = aServerURI.AllocL(); |
|
1388 } |
|
1389 |
|
1390 // ----------------------------------------------------------------------------- |
|
1391 // CConnectionSessionData::SetOpenMode() |
|
1392 // ----------------------------------------------------------------------------- |
|
1393 // |
|
1394 void CConnectionSessionData::SetOpenMode( const TSmlOpenMode aOpenMode ) |
|
1395 { |
|
1396 iOpenMode = aOpenMode; |
|
1397 } |
|
1398 |
|
1399 // ----------------------------------------------------------------------------- |
|
1400 // CConnectionSessionData::SetIdentifier() |
|
1401 // ----------------------------------------------------------------------------- |
|
1402 // |
|
1403 void CConnectionSessionData::SetIdentifier( const TSmlTransportId aId ) |
|
1404 { |
|
1405 iId = aId; |
|
1406 } |
|
1407 |
|
1408 // ----------------------------------------------------------------------------- |
|
1409 // CConnectionSessionData::SetProfile() |
|
1410 // ----------------------------------------------------------------------------- |
|
1411 // |
|
1412 void CConnectionSessionData::SetProfile( const TSmlProfileId aProfileId ) |
|
1413 { |
|
1414 iProfileId = aProfileId; |
|
1415 } |
|
1416 |
|
1417 // ----------------------------------------------------------------------------- |
|
1418 // CConnectionSessionData::FindL() |
|
1419 // Tries to find a property of name aName from iHandler. |
|
1420 // If it is not found, leaves with KErrNotFound. Else returns |
|
1421 // index of the property relative to zero. |
|
1422 // ----------------------------------------------------------------------------- |
|
1423 // |
|
1424 TInt CConnectionSessionData::FindL( const TDesC8& aName ) const |
|
1425 { |
|
1426 TInt index = iHandler->Find( aName ); |
|
1427 if ( index == 0 ) |
|
1428 { |
|
1429 User::Leave( KErrNotFound ); |
|
1430 } |
|
1431 |
|
1432 return index-1; |
|
1433 } |
|
1434 |
|
1435 // ----------------------------------------------------------------------------- |
|
1436 // CConnectionSessionData::InitValuesL() |
|
1437 // This method is used to set the data this object contains |
|
1438 // to such initial values, that the values can be externalized |
|
1439 // without errors. This method is used, when aInitValues |
|
1440 // argument is set ETrue, when calling NewL. This should be done |
|
1441 // when the data is not internalized from stream. |
|
1442 // ----------------------------------------------------------------------------- |
|
1443 // |
|
1444 void CConnectionSessionData::InitValuesL() |
|
1445 { |
|
1446 iServerURI = KNSmlInitialString8().AllocL(); |
|
1447 |
|
1448 TInt count = iHandler->Array().Count(); |
|
1449 for ( TInt i = 0; i < count; ++i ) |
|
1450 { |
|
1451 switch ( iHandler->Array()[i].iDataType ) |
|
1452 { |
|
1453 case EDataTypeText8: |
|
1454 iPropVals.AppendL( KNSmlInitialString8().AllocL() ); |
|
1455 break; |
|
1456 case EDataTypeNumber: |
|
1457 case EDataTypeBoolean: |
|
1458 iPropVals.AppendL( KNSmlInitialZeroString8().AllocL() ); |
|
1459 break; |
|
1460 default: |
|
1461 _DBG_FILE("CConnectionSessionData::InitValuesL: UNKNOWN DATATYPE !"); |
|
1462 User::Panic( KNSmlClientAPIPanic, KErrUnknown ); |
|
1463 break; |
|
1464 } |
|
1465 } |
|
1466 } |
|
1467 |
|
1468 // ----------------------------------------------------------------------------- |
|
1469 // CConnectionSessionData::ConstructL() |
|
1470 // ----------------------------------------------------------------------------- |
|
1471 // |
|
1472 void CConnectionSessionData::ConstructL( const TBool aInitValues, const TSmlUsageType aUsageType ) |
|
1473 { |
|
1474 iHandler = CNSmlTransportHandler::NewL( aUsageType ); |
|
1475 iHandler->CreateL( iId ); |
|
1476 |
|
1477 if ( aInitValues ) |
|
1478 { |
|
1479 InitValuesL(); |
|
1480 } |
|
1481 } |
|
1482 |
|
1483 // ----------------------------------------------------------------------------- |
|
1484 // CConnectionSessionData::CConnectionSessionData() |
|
1485 // ----------------------------------------------------------------------------- |
|
1486 // |
|
1487 CConnectionSessionData::CConnectionSessionData( const TSmlTransportId aId ) |
|
1488 : iId( aId ), iProfileId( KNSmlNullId ), iOpenMode( ESmlOpenReadWrite ) |
|
1489 { |
|
1490 } |
|
1491 |
|
1492 |
|
1493 // |
|
1494 // CTransportSessionData |
|
1495 // |
|
1496 |
|
1497 |
|
1498 // ----------------------------------------------------------------------------- |
|
1499 // CTransportSessionData::NewL() |
|
1500 // ----------------------------------------------------------------------------- |
|
1501 // |
|
1502 CTransportSessionData* CTransportSessionData::NewL( const TSmlTransportId aId, const TSmlUsageType aUsageType ) |
|
1503 { |
|
1504 CTransportSessionData* self = new (ELeave) CTransportSessionData( aId ); |
|
1505 CleanupStack::PushL(self); |
|
1506 self->ConstructL( aUsageType ); |
|
1507 CleanupStack::Pop(); |
|
1508 return self; |
|
1509 } |
|
1510 |
|
1511 // ----------------------------------------------------------------------------- |
|
1512 // CTransportSessionData::~CTransportSessionData() |
|
1513 // ----------------------------------------------------------------------------- |
|
1514 // |
|
1515 CTransportSessionData::~CTransportSessionData() |
|
1516 { |
|
1517 delete iHandler; |
|
1518 } |
|
1519 |
|
1520 // ----------------------------------------------------------------------------- |
|
1521 // CTransportSessionData::SetIdentifier() |
|
1522 // ----------------------------------------------------------------------------- |
|
1523 // |
|
1524 void CTransportSessionData::SetIdentifier( const TSmlTransportId aId ) |
|
1525 { |
|
1526 iId = aId; |
|
1527 } |
|
1528 |
|
1529 // ----------------------------------------------------------------------------- |
|
1530 // CTransportSessionData::ConstructL() |
|
1531 // ----------------------------------------------------------------------------- |
|
1532 // |
|
1533 void CTransportSessionData::ConstructL( const TSmlUsageType aUsageType ) |
|
1534 { |
|
1535 if ( iHandler ) |
|
1536 { |
|
1537 delete iHandler; |
|
1538 iHandler = NULL; |
|
1539 } |
|
1540 |
|
1541 iHandler = CNSmlTransportHandler::NewL( aUsageType ); |
|
1542 iHandler->CreateL( iId ); |
|
1543 } |
|
1544 |
|
1545 // ----------------------------------------------------------------------------- |
|
1546 // CTransportSessionData::CTransportSessionData() |
|
1547 // ----------------------------------------------------------------------------- |
|
1548 // |
|
1549 CTransportSessionData::CTransportSessionData( const TSmlTransportId aId ) |
|
1550 : iId( aId ) |
|
1551 { |
|
1552 } |
|
1553 |
|
1554 |
|
1555 // |
|
1556 // CDataProviderSessionData |
|
1557 // |
|
1558 |
|
1559 |
|
1560 // ----------------------------------------------------------------------------- |
|
1561 // CDataProviderSessionData::CDataProviderSessionData() |
|
1562 // ----------------------------------------------------------------------------- |
|
1563 // |
|
1564 CDataProviderSessionData::CDataProviderSessionData() |
|
1565 : iId( KNSmlNullId ), iAllowMultipleDataStores( EFalse ) |
|
1566 { |
|
1567 } |
|
1568 |
|
1569 // ----------------------------------------------------------------------------- |
|
1570 // CDataProviderSessionData::~CDataProviderSessionData() |
|
1571 // ----------------------------------------------------------------------------- |
|
1572 // |
|
1573 CDataProviderSessionData::~CDataProviderSessionData() |
|
1574 { |
|
1575 iDataStores.ResetAndDestroy(); |
|
1576 iDataStores.Close(); |
|
1577 |
|
1578 iMimeTypes.ResetAndDestroy(); |
|
1579 iMimeTypes.Close(); |
|
1580 |
|
1581 iMimeVersions.ResetAndDestroy(); |
|
1582 iMimeVersions.Close(); |
|
1583 |
|
1584 delete iDisplayName; |
|
1585 } |
|
1586 |
|
1587 // ----------------------------------------------------------------------------- |
|
1588 // CDataProviderSessionData::InternalizeL() |
|
1589 // ----------------------------------------------------------------------------- |
|
1590 // |
|
1591 void CDataProviderSessionData::InternalizeL( RReadStream& aStream ) |
|
1592 { |
|
1593 iVersion.iMajor = aStream.ReadInt32L(); |
|
1594 iVersion.iMinor = aStream.ReadInt32L(); |
|
1595 iVersion.iBuild = aStream.ReadInt32L(); |
|
1596 |
|
1597 iRequiredProtocolVersion = (TSmlProtocolVersion) aStream.ReadInt8L(); |
|
1598 |
|
1599 iDisplayName = HBufC::NewL( aStream, aStream.ReadInt32L() ); |
|
1600 |
|
1601 TInt mimeCount = aStream.ReadInt32L(); |
|
1602 for ( TInt i = 0; i < mimeCount; ++i ) |
|
1603 { |
|
1604 iMimeTypes.Append( HBufC::NewL( aStream, aStream.ReadInt32L() ) ); |
|
1605 } |
|
1606 |
|
1607 for ( TInt j = 0; j < mimeCount; ++j ) |
|
1608 { |
|
1609 iMimeVersions.Append( HBufC::NewL( aStream, aStream.ReadInt32L() ) ); |
|
1610 } |
|
1611 |
|
1612 TInt dataStoreCount = aStream.ReadInt8L(); |
|
1613 for ( TInt k = 0; k < dataStoreCount; ++k ) // default store first, then all stores |
|
1614 { |
|
1615 iDataStores.AppendL( HBufC::NewL( aStream, aStream.ReadInt32L() ) ); |
|
1616 } |
|
1617 |
|
1618 iAllowMultipleDataStores = aStream.ReadInt8L(); |
|
1619 } |
|
1620 |
|
1621 // ----------------------------------------------------------------------------- |
|
1622 // CDataProviderSessionData::GetDataStoreNamesL() |
|
1623 // ----------------------------------------------------------------------------- |
|
1624 // |
|
1625 void CDataProviderSessionData::GetDataStoreNamesL( CDesCArray& aArray ) const |
|
1626 { |
|
1627 aArray.Reset(); |
|
1628 |
|
1629 // append the datastores. first slot is the default store, skip it |
|
1630 // (the default store is also in the rest of the list) |
|
1631 for ( TInt i = 1; i < iDataStores.Count(); ++i ) |
|
1632 { |
|
1633 aArray.AppendL( *iDataStores[i] ); |
|
1634 } |
|
1635 } |
|
1636 |
|
1637 // ----------------------------------------------------------------------------- |
|
1638 // CDataProviderSessionData::SetIdentifier() |
|
1639 // ----------------------------------------------------------------------------- |
|
1640 // |
|
1641 void CDataProviderSessionData::SetIdentifier( const TSmlDataProviderId aId ) |
|
1642 { |
|
1643 iId = aId; |
|
1644 } |
|
1645 |
|
1646 |
|
1647 |