|
1 /* |
|
2 * Copyright (c) 2005 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: Contact list transaction manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPEngContactListTransactionManager.h" |
|
21 |
|
22 #include "PEngListLibraryFactory.h" |
|
23 #include "MPEngListLibFactory.h" |
|
24 #include "PEngPresenceEngineConsts2.h" |
|
25 |
|
26 #include "CPEngContactListModBase.h" |
|
27 #include "CPEngContactListSettings.h" |
|
28 #include "CPEngContactListModChangeMonitor.h" |
|
29 |
|
30 #include "CPEngContactListMngTransAddId.h" |
|
31 #include "CPEngContactListMngTransRemoveId.h" |
|
32 #include "CPEngContactListMngTransProperties.h" |
|
33 #include "CPEngContactListMngTransSubcription.h" |
|
34 #include "CPEngContactListDeleteTrans.h" |
|
35 #include "CPEngGetWatchersTransaction.h" |
|
36 #include "CPEngStartSyncTransaction.h" |
|
37 |
|
38 #include "CPEngContactListTransCreate.h" |
|
39 #include "CPEngContactListTransSync.h" |
|
40 |
|
41 #include "PEngContactIdsTools.h" |
|
42 #include "PEngListLibTools.h" |
|
43 |
|
44 #include "MPEngStorageManager.h" |
|
45 #include "PEngMessagePacker.h" |
|
46 |
|
47 #include "CPEngSessionSlotId.h" |
|
48 |
|
49 #include "PresenceDebugPrint.h" |
|
50 #include <e32std.h> |
|
51 |
|
52 |
|
53 // CONSTANTS |
|
54 _LIT( KPEngUnsubscribe, "UNSUB" ); |
|
55 |
|
56 // ============================ MEMBER FUNCTIONS =============================== |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CPEngContactListTransactionManager::CPEngContactListTransactionManager() |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CPEngContactListTransactionManager::CPEngContactListTransactionManager( |
|
63 MPEngListLibFactory& aFactory, |
|
64 TPEngWVCspVersion& aCSPVersion ) |
|
65 : CPEngContactListManagerBase( aFactory ), |
|
66 iCSPVersion( aCSPVersion ) |
|
67 { |
|
68 } |
|
69 |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CPEngContactListTransactionManager::ConstructL() |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CPEngContactListTransactionManager::ConstructL( |
|
76 const CPEngSessionSlotId& aSessionSlot ) |
|
77 { |
|
78 CPEngContactListManagerBase::ConstructL( aSessionSlot ); |
|
79 InitializePlainUserId(); |
|
80 } |
|
81 |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CPEngContactListTransactionManager::NewL() |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CPEngContactListTransactionManager* CPEngContactListTransactionManager::NewLC( |
|
88 MPEngListLibFactory& aFactory, |
|
89 const CPEngSessionSlotId& aSessionSlot, |
|
90 TPEngWVCspVersion& aCSPVersion ) |
|
91 { |
|
92 CPEngContactListTransactionManager* self = |
|
93 new ( ELeave ) CPEngContactListTransactionManager( aFactory, |
|
94 aCSPVersion ); |
|
95 |
|
96 CleanupClosePushL( *self ); |
|
97 self->ConstructL( aSessionSlot ); |
|
98 |
|
99 return self; |
|
100 } |
|
101 |
|
102 |
|
103 // Destructor |
|
104 CPEngContactListTransactionManager::~CPEngContactListTransactionManager() |
|
105 { |
|
106 } |
|
107 |
|
108 |
|
109 |
|
110 // ============================================================================= |
|
111 // ===============Function from MPEngTransactionFactory ====================== |
|
112 // ============================================================================= |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CPEngContactListTransactionManager::Release() |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CPEngContactListTransactionManager::Close() |
|
119 { |
|
120 iAccessCount--; |
|
121 if ( iAccessCount == 0 ) |
|
122 { |
|
123 iFactory.RemoveCntListTransManager( this ); |
|
124 delete this; |
|
125 } |
|
126 } |
|
127 |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CPEngContactListTransactionManager::GetIncomingNwTransactionHandlersL() |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 MPEngIncomingTransactionHandler* CPEngContactListTransactionManager::IncomingTransactionHandlerL( |
|
134 const TDesC8& /* aIncomingRequest */ ) |
|
135 { |
|
136 return NULL; |
|
137 } |
|
138 |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CPEngContactListTransactionManager::GetOutgoingNwTransactionHandlersL() |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CPEngContactListTransactionManager::OutgoingTransactionHandlerL( |
|
145 TInt aOperation, |
|
146 const TDesC& aData, |
|
147 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers ) |
|
148 { |
|
149 PENG_DP( D_PENG_LIT( "CPEngContactListTransactionManager::OutgoingTransactionHandlerL() [%d]" ), |
|
150 aOperation ); |
|
151 |
|
152 switch ( aOperation ) |
|
153 { |
|
154 case EPEngTransOpCntListUpdateList: |
|
155 case EPEngTransOpCntListSyncList: |
|
156 { |
|
157 if ( !iEnviromentSynchronized ) |
|
158 { |
|
159 User::Leave( KErrNotReady ); |
|
160 } |
|
161 |
|
162 //Create handlers |
|
163 GetOutGoingTransactionHandlersL( aData, |
|
164 aHandlers, |
|
165 aOperation ); |
|
166 break; |
|
167 } |
|
168 |
|
169 |
|
170 case EPEngTransOpCntListBaseSync: |
|
171 { |
|
172 if ( iEnviromentSynchronized ) |
|
173 { |
|
174 // already done, no need for it |
|
175 return; |
|
176 } |
|
177 |
|
178 TBool needToUnsubscribe( EFalse ); |
|
179 if ( aData.Compare( KPEngUnsubscribe ) == 0 ) |
|
180 { |
|
181 needToUnsubscribe = ETrue; |
|
182 } |
|
183 |
|
184 CPEngStartSyncTransaction* startSync = |
|
185 CPEngStartSyncTransaction::NewLC( *this, |
|
186 iCSPVersion, |
|
187 aOperation, |
|
188 needToUnsubscribe ); |
|
189 |
|
190 aHandlers.AppendL( startSync ); |
|
191 CleanupStack::Pop(); //newHandler |
|
192 |
|
193 break; |
|
194 } |
|
195 |
|
196 default: |
|
197 { |
|
198 } |
|
199 } |
|
200 } |
|
201 |
|
202 |
|
203 // ============================================================================= |
|
204 // =============== from MPEngContactListTransactionManager ===================== |
|
205 // ============================================================================= |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CPEngContactListTransactionManager::CompleteEnviromentSyncL() |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 void CPEngContactListTransactionManager::CompleteEnviromentSyncL( |
|
212 CDesCArray& aExistingLists, |
|
213 const TDesC& aDefaultList, |
|
214 TBool aListsUnsubscribed ) |
|
215 { |
|
216 //Generate array of plain list names |
|
217 //+1 to prevent having count 0 |
|
218 const TInt existingCount = aExistingLists.Count(); |
|
219 CPtrCArray* planeNames = new ( ELeave ) CPtrCArray( existingCount + 1 ); |
|
220 CleanupStack::PushL( planeNames ); |
|
221 |
|
222 for ( TInt i( 0 ) ; i < existingCount ; ++i ) |
|
223 { |
|
224 TPtrC name( aExistingLists[ i ] ); |
|
225 NContactListIdsTools::ExtractPureContactListName( name, |
|
226 iPlainUserName ); |
|
227 planeNames->AppendL( name ); |
|
228 } |
|
229 |
|
230 |
|
231 //Process all known contact list settings, |
|
232 //wether thay exist on the server or not |
|
233 for ( TInt x( iContactListSettings.Count() - 1 ) ; x >= 0 ; --x ) |
|
234 { |
|
235 // For future: what if is it master and default |
|
236 // Update is needed |
|
237 CPEngContactListSettings* sett = iContactListSettings[ x ]; |
|
238 |
|
239 sett->DeletePropertyL( KPEngCntLstDefault, |
|
240 KPEngCntLstPropertyNativePermanent ); |
|
241 sett->DeletePropertyL( KPEngHasBeenSynchronized, |
|
242 KPEngCntLstPropertyNativeCached ); |
|
243 |
|
244 |
|
245 //Try locate list from plain names array |
|
246 //If list is found, remove it from plain names and parameter array |
|
247 TInt cn( planeNames->Count() - 1 ); |
|
248 for ( ; cn >= 0 ; --cn ) |
|
249 { |
|
250 if ( KErrNone == NContactListIdsTools::CompareContactListIds( sett->Name(), |
|
251 ( *planeNames )[ cn ] ) ) |
|
252 { |
|
253 sett->SetPropertyL( KPEngListExistsOnServer, |
|
254 KPEngCntLstPropertyNativeCached, |
|
255 ETrue ); |
|
256 if ( aListsUnsubscribed ) |
|
257 { |
|
258 sett->DeletePropertyL( KPEngCntLstSubscribe, |
|
259 KPEngCntLstPropertyNativePermanent ); |
|
260 |
|
261 sett->DeletePropertyL( KPEngSubcriptionUpdate, |
|
262 KPEngCntLstPropertyNativeCached ); |
|
263 } |
|
264 aExistingLists.Delete( cn ); |
|
265 planeNames->Delete( cn ); |
|
266 break; |
|
267 } |
|
268 } |
|
269 |
|
270 |
|
271 //Process the case that list was not among server lists |
|
272 if ( cn == -1 ) |
|
273 { |
|
274 //List was not found from plain names |
|
275 if ( !sett->Property( KPEngCntLstSyncMaster, KPEngCntLstPropertyNativePermanent ) && |
|
276 sett->Property( KPEngCntLstMustExistOnServer, KPEngCntLstPropertyNativePermanent ) ) |
|
277 { |
|
278 CompleteCntListDeletionL( sett->Name() ); |
|
279 } |
|
280 else |
|
281 { |
|
282 sett->DeletePropertyL( KPEngListExistsOnServer, KPEngCntLstPropertyNativeCached ); |
|
283 } |
|
284 } |
|
285 } |
|
286 |
|
287 |
|
288 //Process those lists which were left over in the existing lists array |
|
289 //=> those are new ones that needs to be registered to local system |
|
290 const TInt remainingCount( aExistingLists.Count() ); |
|
291 for ( TInt y( 0 ) ; y < remainingCount ; ++y ) |
|
292 { |
|
293 CPEngContactListSettings* sett = |
|
294 CPEngContactListSettings::NewServerLC( ( *planeNames )[ y ], |
|
295 aExistingLists[ y ], |
|
296 *this ); |
|
297 |
|
298 CPEngContactListManagerBase::InsertContactListSettingsL( *sett ); |
|
299 CleanupStack::Pop( sett ); |
|
300 |
|
301 sett->SetPropertyL( KPEngListExistsOnServer, |
|
302 KPEngCntLstPropertyNativeCached, |
|
303 ETrue ); |
|
304 } |
|
305 |
|
306 |
|
307 //List of lists handled |
|
308 CleanupStack::PopAndDestroy(); // planeNames |
|
309 iEnviromentSynchronized = ETrue; |
|
310 |
|
311 |
|
312 |
|
313 // Handle the default contact list |
|
314 TPtrC defaultList( aDefaultList ); |
|
315 NContactListIdsTools::ExtractPureContactListName( defaultList, |
|
316 iPlainUserName ); |
|
317 |
|
318 CPEngContactListSettings* sett = ContactListSettingsOrNull( defaultList ); |
|
319 if ( sett ) |
|
320 { |
|
321 sett->SetPropertyL( KPEngCntLstDefault, |
|
322 KPEngCntLstPropertyNativePermanent, |
|
323 ETrue ); |
|
324 } |
|
325 else |
|
326 { |
|
327 //Force store of contact list manager, |
|
328 //to distribute the enviroment sync state |
|
329 StoreL(); |
|
330 } |
|
331 } |
|
332 |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // CPEngContactListTransactionManager::UserDomain() |
|
336 // ----------------------------------------------------------------------------- |
|
337 // |
|
338 const TDesC& CPEngContactListTransactionManager::UserDomain() |
|
339 { |
|
340 return iUserDomain; |
|
341 } |
|
342 |
|
343 |
|
344 // ----------------------------------------------------------------------------- |
|
345 // CPEngContactListTransactionManager::DefaultCntListSettingsOrNull() |
|
346 // ----------------------------------------------------------------------------- |
|
347 // |
|
348 CPEngContactListSettings* CPEngContactListTransactionManager::DefaultCntListSettingsOrNull() |
|
349 { |
|
350 return CPEngContactListManagerBase::DefaultCntListSettingsOrNull(); |
|
351 } |
|
352 |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // CPEngContactListTransactionManager::CompleteCntListDeletionL() |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 void CPEngContactListTransactionManager::CompleteCntListDeletionL( |
|
359 const TDesC& aContactList ) |
|
360 { |
|
361 DeleteContactListSettingsL( aContactList ); |
|
362 } |
|
363 |
|
364 |
|
365 |
|
366 // ============================================================================= |
|
367 // =============== From main class ============================================= |
|
368 // ============================================================================= |
|
369 |
|
370 |
|
371 // ----------------------------------------------------------------------------- |
|
372 // CPEngContactListTransactionManager::GetOutGoingTransactionHandlersL() |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 void CPEngContactListTransactionManager::GetOutGoingTransactionHandlersL( |
|
376 const TDesC& aData, |
|
377 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
378 TInt aOperationId ) |
|
379 { |
|
380 PENG_DP( D_PENG_LIT( "CPEngContactListTransactionManager::GetOutGoingTransactionHandlersL()" ) ); |
|
381 if ( aData.Length() == 0 ) |
|
382 { |
|
383 return; |
|
384 } |
|
385 |
|
386 // unpack SIDs, creates sIds and its count |
|
387 CDesC16Array* sIds = PEngMessagePacker::UnpackDesArrayLC( aData ); |
|
388 TInt countStoreIDs( sIds->Count() ); |
|
389 |
|
390 // loop going through all requested Store IDs |
|
391 for ( TInt x( 0 ) ; x < countStoreIDs ; x++ ) |
|
392 { |
|
393 // try to load contact list from store |
|
394 CPEngContactListModBase* volatile model = NULL; |
|
395 TRAPD( e, model = &( LoadContactListModelL( sIds->MdcaPoint( x ), |
|
396 ETrue, |
|
397 ETrue ) ) ); |
|
398 |
|
399 // if list does not exists, continue for next SID |
|
400 if ( e == KErrNotFound ) |
|
401 { |
|
402 continue; |
|
403 } |
|
404 |
|
405 User::LeaveIfError( e ); |
|
406 CleanupClosePushL( *model ); |
|
407 |
|
408 // is update already in progress? |
|
409 if ( model->UpdateInProgress() ) |
|
410 { |
|
411 User::Leave( KErrInUse ); |
|
412 } |
|
413 |
|
414 // clean change monitor |
|
415 model->ChangeMonitor().Reset(); |
|
416 model->StoreEntryL(); |
|
417 |
|
418 |
|
419 // is it watcher list? |
|
420 if ( KErrNone == sIds->MdcaPoint( x ).CompareF( KPEngWatcherList ) ) |
|
421 { |
|
422 GetWatcherListHandlerL( *model, |
|
423 aHandlers, |
|
424 aOperationId ); |
|
425 CleanupStack::PopAndDestroy(); // model |
|
426 continue; |
|
427 } |
|
428 |
|
429 |
|
430 // is this delete contact list request |
|
431 if ( model->Settings().Property( KPEngContactListDeleteNeeded, |
|
432 KPEngCntLstPropertyNativeCached ) ) |
|
433 { |
|
434 GetDeleteCntListHandlerL( *model, |
|
435 aHandlers, |
|
436 aOperationId ); |
|
437 CleanupStack::PopAndDestroy(); // model |
|
438 continue; |
|
439 } |
|
440 |
|
441 |
|
442 // is list synchronized |
|
443 if ( model->Settings().Synchronized() ) |
|
444 { |
|
445 GetContactListsUpdateHandlersL( *model, |
|
446 aHandlers, |
|
447 aOperationId ); |
|
448 } |
|
449 else |
|
450 { |
|
451 GetContactListsSyncHandlersL( *model, |
|
452 aHandlers, |
|
453 aOperationId ); |
|
454 } |
|
455 CleanupStack::PopAndDestroy(); // model |
|
456 } |
|
457 |
|
458 CleanupStack::PopAndDestroy( sIds ); |
|
459 } |
|
460 |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // CPEngContactListTransactionManager::GetContactListUpdateHandlersL() |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 void CPEngContactListTransactionManager::GetContactListsUpdateHandlersL( |
|
467 CPEngContactListModBase& aContactList, |
|
468 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
469 TInt aOperationId ) |
|
470 { |
|
471 CPEngContactListSettings& settings = aContactList.Settings(); |
|
472 if ( settings.Property( KPEngListExistsOnServer, |
|
473 KPEngCntLstPropertyNativeCached ) ) |
|
474 { |
|
475 GetUpdateHandlersForExistingCntListL( aContactList, |
|
476 aHandlers, |
|
477 aOperationId ); |
|
478 |
|
479 // check if subscription needs some update |
|
480 if ( settings.Property( KPEngSubcriptionUpdate, |
|
481 KPEngCntLstPropertyNativeCached ) ) |
|
482 { |
|
483 GetSubscriptionUpdateHandlerL( aContactList, |
|
484 aHandlers, |
|
485 aOperationId ); |
|
486 } |
|
487 |
|
488 // is property update needed |
|
489 if ( settings.Property( KPEngPropertiesUpdateNeeded, |
|
490 KPEngCntLstPropertyNativeCached ) ) |
|
491 { |
|
492 GetUpdateCntListPropertiesHandlerL( aContactList, |
|
493 aHandlers, |
|
494 aOperationId ); |
|
495 } |
|
496 } |
|
497 |
|
498 else |
|
499 { |
|
500 GetUpdateHandlersForNotExistingCntListL( aContactList, |
|
501 aHandlers, |
|
502 aOperationId ); |
|
503 } |
|
504 } |
|
505 |
|
506 |
|
507 // ----------------------------------------------------------------------------- |
|
508 // CPEngContactListTransactionManager::GetContactListSyncHandlersL() |
|
509 // ----------------------------------------------------------------------------- |
|
510 // |
|
511 void CPEngContactListTransactionManager::GetContactListsSyncHandlersL( |
|
512 CPEngContactListModBase& aContactList, |
|
513 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
514 TInt aOperationId ) |
|
515 { |
|
516 // check if there is need to created any handler |
|
517 CPEngContactListSettings& settings = aContactList.Settings(); |
|
518 |
|
519 if ( // list must exists on the server -> need transaction |
|
520 ( settings.Property( KPEngCntLstMustExistOnServer, |
|
521 KPEngCntLstPropertyNativePermanent ) ) |
|
522 || |
|
523 // list exists on the server -> need of transaction |
|
524 ( settings.Property( KPEngListExistsOnServer, |
|
525 KPEngCntLstPropertyNativeCached ) ) |
|
526 || |
|
527 // is anything in the contact list -> sync it |
|
528 ( aContactList.Count() != 0 ) ) |
|
529 { |
|
530 // create sync handler |
|
531 CleanContactListSettingsForListCreationL( aContactList.Settings() ); |
|
532 GetSynchronizeOneCntListHandlerL( aContactList, |
|
533 aHandlers, |
|
534 aOperationId ); |
|
535 } |
|
536 else |
|
537 { |
|
538 // there was no need to create sync transaction for |
|
539 // the contact list, set it as synchronized |
|
540 settings.SetPropertyL( KPEngHasBeenSynchronized, |
|
541 KPEngCntLstPropertyNativeCached, |
|
542 ETrue ); |
|
543 } |
|
544 } |
|
545 |
|
546 |
|
547 // ----------------------------------------------------------------------------- |
|
548 // CPEngContactListTransactionManager::GetDeleteCntListHandlerL() |
|
549 // ----------------------------------------------------------------------------- |
|
550 // |
|
551 void CPEngContactListTransactionManager::GetDeleteCntListHandlerL( |
|
552 CPEngContactListModBase& aModel, |
|
553 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
554 TInt aOperationId ) |
|
555 { |
|
556 // check if contact list exists on the presence server, can be that it is just |
|
557 // lazy initialized |
|
558 if ( aModel.Settings().Property( KPEngListExistsOnServer, |
|
559 KPEngCntLstPropertyNativeCached ) ) |
|
560 { |
|
561 // handler is needed, create it here |
|
562 CreateHandler2ParamL < CPEngContactListDeleteTrans, |
|
563 CPEngContactListModBase&, |
|
564 MPEngContactListTransactionManager& > ( aHandlers, |
|
565 aModel, |
|
566 *this, |
|
567 iCSPVersion, |
|
568 aOperationId ); |
|
569 } |
|
570 else |
|
571 { |
|
572 // no need to create handler, just commit change on the store |
|
573 CompleteCntListDeletionL( aModel.Settings().Name() ); |
|
574 } |
|
575 } |
|
576 |
|
577 |
|
578 // ----------------------------------------------------------------------------- |
|
579 // CPEngContactListTransactionManager::GetUpdateCntListPropertiesHandlerL() |
|
580 // ----------------------------------------------------------------------------- |
|
581 // |
|
582 void CPEngContactListTransactionManager::GetUpdateCntListPropertiesHandlerL( |
|
583 CPEngContactListModBase& aModel, |
|
584 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
585 TInt aOperationId ) |
|
586 { |
|
587 CreateHandler2ParamL < CPEngContactListMngTransProperties, |
|
588 CPEngContactListModBase&, |
|
589 MPEngContactListTransactionManager& > ( aHandlers, |
|
590 aModel, |
|
591 *this, |
|
592 iCSPVersion, |
|
593 aOperationId ); |
|
594 } |
|
595 |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CPEngContactListTransactionManager::GetUpdateHandlersForExistingCntListL() |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 void CPEngContactListTransactionManager::GetUpdateHandlersForExistingCntListL( |
|
602 CPEngContactListModBase& aModel, |
|
603 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
604 TInt aOperationId ) |
|
605 { |
|
606 RPointerArray<CPEngContactListModItemContainer> nickList; |
|
607 CleanupClosePushL( nickList ); |
|
608 |
|
609 // check is there is something to update |
|
610 aModel.FillAddNickListL( nickList ); |
|
611 if ( 0 != nickList.Count() ) |
|
612 { |
|
613 // something to update => create update handler |
|
614 CreateHandler2ParamL < CPEngContactListMngTransAddId, |
|
615 CPEngContactListModBase&, |
|
616 CPEngSessionSlotId& > ( aHandlers, |
|
617 aModel, |
|
618 *iSessionId, |
|
619 iCSPVersion, |
|
620 aOperationId ); |
|
621 } |
|
622 |
|
623 |
|
624 nickList.Reset(); |
|
625 aModel.FillRemoveNickListL( nickList ); |
|
626 if ( 0 != nickList.Count() ) |
|
627 { |
|
628 // something to update => create update handler |
|
629 CreateHandler2ParamL < CPEngContactListMngTransRemoveId, |
|
630 CPEngContactListModBase&, |
|
631 CPEngSessionSlotId& > ( aHandlers, |
|
632 aModel, |
|
633 *iSessionId, |
|
634 iCSPVersion, |
|
635 aOperationId ); |
|
636 } |
|
637 |
|
638 CleanupStack::PopAndDestroy(); // nickList |
|
639 } |
|
640 |
|
641 |
|
642 // ----------------------------------------------------------------------------- |
|
643 // CPEngContactListTransactionManager::GetUpdateHandlersForNotExistingCntListL() |
|
644 // ----------------------------------------------------------------------------- |
|
645 // |
|
646 void CPEngContactListTransactionManager::GetUpdateHandlersForNotExistingCntListL( |
|
647 CPEngContactListModBase& aModel, |
|
648 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
649 TInt aOperationId ) |
|
650 { |
|
651 // delete properties which are not needed |
|
652 CleanContactListSettingsForListCreationL( aModel.Settings() ); |
|
653 |
|
654 if ( aModel.Count() != 0 ) |
|
655 { |
|
656 // something to update => create update handler |
|
657 CreateHandler3ParamL < CPEngContactListTransCreate, |
|
658 CPEngContactListModBase&, |
|
659 CPEngSessionSlotId&, |
|
660 MPEngContactListTransactionManager& > ( aHandlers, |
|
661 aModel, |
|
662 *iSessionId, |
|
663 *this, |
|
664 iCSPVersion, |
|
665 aOperationId ); |
|
666 } |
|
667 else |
|
668 { |
|
669 // Harmonize default contact list settings if list was configured as new one |
|
670 NListLibTools::HarmonizeDefaultContactListSettingsL( aModel.Settings(), *this ); |
|
671 } |
|
672 } |
|
673 |
|
674 |
|
675 // ----------------------------------------------------------------------------- |
|
676 // CPEngContactListTransactionManager::GetWatcherListHandlerL() |
|
677 // ----------------------------------------------------------------------------- |
|
678 // |
|
679 void CPEngContactListTransactionManager::GetWatcherListHandlerL( |
|
680 CPEngContactListModBase& aModel, |
|
681 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
682 TInt aOperationId ) |
|
683 { |
|
684 CreateHandler1ParamL < CPEngGetWatchersTransaction, |
|
685 CPEngContactListModBase& > ( aHandlers, |
|
686 aModel, |
|
687 iCSPVersion, |
|
688 aOperationId ); |
|
689 } |
|
690 |
|
691 |
|
692 // ----------------------------------------------------------------------------- |
|
693 // CPEngContactListTransactionManager::GetSynchronizeOneCntListHandlerL() |
|
694 // ----------------------------------------------------------------------------- |
|
695 // |
|
696 void CPEngContactListTransactionManager::GetSynchronizeOneCntListHandlerL( |
|
697 CPEngContactListModBase& aModel, |
|
698 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
699 TInt aOperationId ) |
|
700 { |
|
701 |
|
702 if ( aModel.Settings().Property( KPEngListExistsOnServer, |
|
703 KPEngCntLstPropertyNativeCached ) ) |
|
704 { |
|
705 CreateHandler3ParamL < CPEngContactListTransSync, |
|
706 CPEngContactListModBase&, |
|
707 CPEngSessionSlotId&, |
|
708 MPEngContactListTransactionManager& > ( aHandlers, |
|
709 aModel, |
|
710 *iSessionId, |
|
711 *this, |
|
712 iCSPVersion, |
|
713 aOperationId ); |
|
714 |
|
715 } |
|
716 |
|
717 else |
|
718 { |
|
719 CreateHandler3ParamL < CPEngContactListTransCreate, |
|
720 CPEngContactListModBase&, |
|
721 CPEngSessionSlotId&, |
|
722 MPEngContactListTransactionManager& > ( aHandlers, |
|
723 aModel, |
|
724 *iSessionId, |
|
725 *this, |
|
726 iCSPVersion, |
|
727 aOperationId ); |
|
728 } |
|
729 } |
|
730 |
|
731 |
|
732 // ----------------------------------------------------------------------------- |
|
733 // CPEngContactListTransactionManager::GetSubscriptionUpdateHandlerL() |
|
734 // ----------------------------------------------------------------------------- |
|
735 // |
|
736 void CPEngContactListTransactionManager::GetSubscriptionUpdateHandlerL( |
|
737 CPEngContactListModBase& aModel, |
|
738 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
739 TInt aOperationId ) |
|
740 { |
|
741 CreateHandler2ParamL < CPEngContactListMngTransSubcription, |
|
742 CPEngContactListModBase&, |
|
743 CPEngSessionSlotId& > ( aHandlers, |
|
744 aModel, |
|
745 *iSessionId, |
|
746 iCSPVersion, |
|
747 aOperationId ); |
|
748 } |
|
749 |
|
750 |
|
751 // ----------------------------------------------------------------------------- |
|
752 // CPEngContactListTransactionManager::CreateHandler1ParamL() |
|
753 // ----------------------------------------------------------------------------- |
|
754 // |
|
755 template < class THandlerClass, |
|
756 class TParam1 > |
|
757 void CPEngContactListTransactionManager::CreateHandler1ParamL( |
|
758 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
759 TParam1 aParam1, |
|
760 TPEngWVCspVersion& aParam2, |
|
761 TInt aParam3 ) |
|
762 { |
|
763 // create start synchronization handler |
|
764 THandlerClass* newHandler = THandlerClass::NewLC( aParam1, |
|
765 aParam2, |
|
766 aParam3 ); |
|
767 |
|
768 aHandlers.AppendL( newHandler ); |
|
769 CleanupStack::Pop(); // newHandler |
|
770 } |
|
771 |
|
772 |
|
773 // ----------------------------------------------------------------------------- |
|
774 // CPEngContactListTransactionManager::CreateHandler2ParamL() |
|
775 // ----------------------------------------------------------------------------- |
|
776 // |
|
777 template < class THandlerClass, |
|
778 class TParam1, |
|
779 class TParam2 > |
|
780 void CPEngContactListTransactionManager::CreateHandler2ParamL( |
|
781 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
782 TParam1 aParam1, |
|
783 TParam2 aParam2, |
|
784 TPEngWVCspVersion& aParam3, |
|
785 TInt aParam4 ) |
|
786 { |
|
787 THandlerClass* newHandler = THandlerClass::NewLC( aParam1, |
|
788 aParam2, |
|
789 aParam3, |
|
790 aParam4 ); |
|
791 |
|
792 aHandlers.AppendL( newHandler ); |
|
793 CleanupStack::Pop(); //newHandler |
|
794 } |
|
795 |
|
796 |
|
797 // ----------------------------------------------------------------------------- |
|
798 // CPEngContactListTransactionManager::CreateHandler3ParamL() |
|
799 // ----------------------------------------------------------------------------- |
|
800 // |
|
801 template < class THandlerClass, |
|
802 class TParam1, |
|
803 class TParam2, |
|
804 class TParam3 > |
|
805 void CPEngContactListTransactionManager::CreateHandler3ParamL( |
|
806 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers, |
|
807 TParam1 aParam1, |
|
808 TParam2 aParam2, |
|
809 TParam3 aParam3, |
|
810 TPEngWVCspVersion& aParam4, |
|
811 TInt aParam5 ) |
|
812 { |
|
813 THandlerClass* newHandler = THandlerClass::NewLC( aParam1, |
|
814 aParam2, |
|
815 aParam3, |
|
816 aParam4, |
|
817 aParam5 ); |
|
818 |
|
819 aHandlers.AppendL( newHandler ); |
|
820 CleanupStack::Pop(); // newHandler |
|
821 } |
|
822 |
|
823 |
|
824 // ----------------------------------------------------------------------------- |
|
825 // CPEngContactListTransactionManager::InitializePlainUserId() |
|
826 // ----------------------------------------------------------------------------- |
|
827 // |
|
828 void CPEngContactListTransactionManager::InitializePlainUserId() |
|
829 { |
|
830 TChar add( '@' ); |
|
831 TInt offset( iSessionId->UserId().Locate( add ) ); |
|
832 // remove domain |
|
833 if ( KErrNotFound != offset ) |
|
834 { |
|
835 iPlainUserName.Set( iSessionId->UserId().Left( offset ) ); |
|
836 } |
|
837 else |
|
838 { |
|
839 iPlainUserName.Set( iSessionId->UserId() ); |
|
840 } |
|
841 |
|
842 // remove wv ID begining wv: |
|
843 if ( KErrNone == iPlainUserName.Left( KPEngWVIDPrefixLength |
|
844 ).CompareF( KPEngWVIDPrefix ) ) |
|
845 { |
|
846 iPlainUserName.Set( iPlainUserName.Mid( KPEngWVIDPrefixLength ) ); |
|
847 } |
|
848 } |
|
849 |
|
850 |
|
851 // ----------------------------------------------------------------------------- |
|
852 // CPEngContactListTransactionManager::CleanContactListSettingsForListCreationL() |
|
853 // ----------------------------------------------------------------------------- |
|
854 // |
|
855 void CPEngContactListTransactionManager::CleanContactListSettingsForListCreationL( |
|
856 CPEngContactListSettings& aSettings ) |
|
857 { |
|
858 // Clean contact list settings which are not needed when contact |
|
859 // list will be created |
|
860 aSettings.DeletePropertyL( KPEngSubcriptionUpdate, |
|
861 KPEngCntLstPropertyNativeCached ); |
|
862 aSettings.DeletePropertyL( KPEngPropertiesUpdateNeeded, |
|
863 KPEngCntLstPropertyNativeCached ); |
|
864 } |
|
865 |
|
866 // End of File |
|
867 |
|
868 |
|
869 |
|
870 |
|
871 |