|
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 lists manager base |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 |
|
22 #include "CPEngContactListManagerBase.h" |
|
23 #include "PEngListLibTools.h" |
|
24 |
|
25 #include "CPEngContactListModBase.h" |
|
26 #include "CPEngWatcherList.h" |
|
27 #include "CPEngContactListSettings.h" |
|
28 |
|
29 #include "MPEngContactListAdvance.h" |
|
30 #include "MPEngContactListManager.h" |
|
31 |
|
32 #include "PEngStorageGlobals.h" |
|
33 #include "MPEngStorageManager.h" |
|
34 #include "PEngStorageManager.h" |
|
35 #include "CPEngSessionSlotId.h" |
|
36 #include "PresenceDebugPrint.h" |
|
37 |
|
38 // Minimum store ocupation |
|
39 //counts the settings count, syncFlag, domain length, each 4 bytes |
|
40 static const TInt KMinimumStoreEntrySize = 12; |
|
41 |
|
42 |
|
43 |
|
44 // ========================== HELPERS ============================================ |
|
45 |
|
46 /** |
|
47 * Abstract array entry id accessor. |
|
48 */ |
|
49 class MPEngEntryIdAccessor |
|
50 { |
|
51 public: |
|
52 |
|
53 /** |
|
54 * Gets descriptor id identifying the array item. |
|
55 * Derived implementation should cast the given |
|
56 * entry pointer to concrete type and return |
|
57 * descriptor identifying the entry. |
|
58 * |
|
59 * @param aEntry The array element. |
|
60 * @return The element descriptor id. |
|
61 */ |
|
62 virtual const TDesC& DesId( const TAny* aEntry ) const = 0; |
|
63 }; |
|
64 |
|
65 |
|
66 /** |
|
67 * Concrete array entry id accessor to be used with |
|
68 * CPEngContactListSettings. |
|
69 */ |
|
70 NONSHARABLE_CLASS ( TPEngContactListSettingsIdAccessor ) : public MPEngEntryIdAccessor |
|
71 { |
|
72 public: |
|
73 inline TPEngContactListSettingsIdAccessor() {} |
|
74 |
|
75 /** |
|
76 * Gets descriptor id identifying the |
|
77 * CPEngContactListSettings item. |
|
78 */ |
|
79 inline const TDesC& DesId( const TAny* aEntry ) const |
|
80 { |
|
81 return ( ( CPEngContactListSettings* )aEntry )->Name(); |
|
82 } |
|
83 }; |
|
84 |
|
85 |
|
86 |
|
87 /** |
|
88 * Concrete array entry id accessor to be used with |
|
89 * CPEngContactListModBase. |
|
90 */ |
|
91 NONSHARABLE_CLASS( TPEngContactListModelIdAccessor ) |
|
92 : public MPEngEntryIdAccessor |
|
93 { |
|
94 public: |
|
95 inline TPEngContactListModelIdAccessor() {} |
|
96 |
|
97 /** |
|
98 * Gets descriptor id identifying the |
|
99 * CPEngContactListModBase item. |
|
100 */ |
|
101 inline const TDesC& DesId( const TAny* aEntry ) const |
|
102 { |
|
103 return ( ( CPEngContactListModBase* )aEntry )->Settings().Name(); |
|
104 } |
|
105 }; |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 /** |
|
111 * Templated find method. |
|
112 */ |
|
113 template<class T> |
|
114 inline TInt FindEntryInArray( const RPointerArray<T>& aArray, |
|
115 const TDesC& aContactId, |
|
116 TInt& aIndex, |
|
117 const MPEngEntryIdAccessor& aAccessor, |
|
118 const TDesC& aUserDomain = KNullDesC ) |
|
119 { |
|
120 TInt l( 0 ); |
|
121 TInt r( aArray.Count() ); |
|
122 TInt ret( KErrNotFound ); |
|
123 while ( r > l ) |
|
124 { |
|
125 TInt inx = ( l + r ) >> 1; |
|
126 TInt k ( NContactIdsTools::CompareContactIds( aContactId, |
|
127 aAccessor.DesId( aArray[ inx ] ), |
|
128 aUserDomain ) ); |
|
129 if ( k == 0 ) |
|
130 { |
|
131 aIndex = inx; |
|
132 return KErrNone; |
|
133 } |
|
134 else if ( k > 0 ) |
|
135 l = inx + 1; |
|
136 else |
|
137 r = inx; |
|
138 } |
|
139 |
|
140 aIndex = r; |
|
141 return ret; |
|
142 } |
|
143 |
|
144 |
|
145 |
|
146 //Default granurality for contact lists |
|
147 const TInt KListObjectsGranurality = 3; |
|
148 |
|
149 |
|
150 // ============================ MEMBER FUNCTIONS =============================== |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CPEngContactListManagerBase::CPEngContactListManagerBase() |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 CPEngContactListManagerBase::CPEngContactListManagerBase( |
|
157 MPEngListLibFactory& aFactory ) |
|
158 : CPEngStoreEntry( static_cast<TPEngStorageType> ( EPEngMixedPermanentCached | |
|
159 EPEngStorageFlagVersionChecked ) ), |
|
160 iAccessCount( 1 ), // init ref count on 1 |
|
161 iFactory( aFactory ), |
|
162 iContactListSettings( KListObjectsGranurality ), |
|
163 iContactLists( KListObjectsGranurality ) |
|
164 { |
|
165 iSize = KMinimumStoreEntrySize; |
|
166 } |
|
167 |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CPEngContactListManagerBase::ConstructL() |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CPEngContactListManagerBase::ConstructL( |
|
174 const CPEngSessionSlotId& aSessionSlot ) |
|
175 { |
|
176 iSessionId = aSessionSlot.CloneL(); |
|
177 MPEngStorageManager* storageManager = NULL; |
|
178 storageManager = PEngStorageManager::GetStorageManagerL( *iSessionId ); |
|
179 CleanupClosePushL( *storageManager ); |
|
180 CPEngStoreEntry::BaseConstructL( *storageManager ); |
|
181 CleanupStack::PopAndDestroy(); //storageManager |
|
182 |
|
183 |
|
184 InitDomainNameL( *iSessionId ); |
|
185 |
|
186 |
|
187 TInt err( iStorageManager->RetrieveL( *this ) ); |
|
188 if ( err == KErrNotFound ) |
|
189 { |
|
190 // store does not exist, create it |
|
191 InitWatcherListL(); |
|
192 StoreL(); |
|
193 } |
|
194 } |
|
195 |
|
196 |
|
197 // Destructor |
|
198 CPEngContactListManagerBase::~CPEngContactListManagerBase() |
|
199 { |
|
200 iContactListSettings.ResetAndDestroy(); |
|
201 for ( TInt x( iContactLists.Count() - 1 ) ; x >= 0 ; --x ) |
|
202 { |
|
203 iContactLists[ x ]->Close(); |
|
204 } |
|
205 |
|
206 iContactLists.Reset(); |
|
207 iCntLstSettingsObservers.Reset(); |
|
208 delete iSessionId; |
|
209 } |
|
210 |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CPEngContactListManagerBase::CreateEmptyAttributeListL() |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 const CPEngSessionSlotId& CPEngContactListManagerBase::SessionId( ) const |
|
217 { |
|
218 return *iSessionId; |
|
219 } |
|
220 |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CPEngContactListManagerBase::Open() |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 void CPEngContactListManagerBase::Open() |
|
227 { |
|
228 iAccessCount++; |
|
229 } |
|
230 |
|
231 |
|
232 |
|
233 // ============================================================================= |
|
234 // =============== Functions from MPEngContactListSettingsManager ============== |
|
235 // ============================================================================= |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // CPEngContactListManagerBase::ContactListSettingsOrNull() |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 CPEngContactListSettings* CPEngContactListManagerBase::ContactListSettingsOrNull( |
|
242 const TDesC& aContactList ) |
|
243 { |
|
244 TInt x ( FindContactListSettings( aContactList ) ); |
|
245 if ( x == KErrNotFound ) |
|
246 { |
|
247 return NULL; |
|
248 } |
|
249 |
|
250 return iContactListSettings[ x ]; |
|
251 } |
|
252 |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CPEngContactListManagerBase::AddContactListSettingsObserverL() |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 void CPEngContactListManagerBase::AddContactListSettingsObserverL( |
|
259 const MPEngContactListSettingsObserver* aObserver ) |
|
260 { |
|
261 // add observer |
|
262 User::LeaveIfError( iCntLstSettingsObservers.InsertInAddressOrder( aObserver ) ); |
|
263 } |
|
264 |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CPEngContactListManagerBase::RemoveContactListSettingsObserver() |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 void CPEngContactListManagerBase::RemoveContactListSettingsObserver( |
|
271 const MPEngContactListSettingsObserver* aObserver ) |
|
272 { |
|
273 // remove observer |
|
274 TInt index ( iCntLstSettingsObservers.FindInAddressOrder( aObserver ) ); |
|
275 if ( index != KErrNotFound ) |
|
276 { |
|
277 iCntLstSettingsObservers.Remove( index ); |
|
278 } |
|
279 } |
|
280 |
|
281 |
|
282 // ----------------------------------------------------------------------------- |
|
283 // CPEngContactListManagerBase::RemoveModel() |
|
284 // ----------------------------------------------------------------------------- |
|
285 // |
|
286 void CPEngContactListManagerBase::RemoveModel( CPEngContactListModBase* aModel ) |
|
287 { |
|
288 TInt index( iContactLists.Find( aModel ) ); |
|
289 if ( index != KErrNotFound ) |
|
290 { |
|
291 iContactLists.Remove( index ); |
|
292 } |
|
293 } |
|
294 |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // CPEngContactListManagerBase::UserDomain() |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 const TDesC& CPEngContactListManagerBase::UserDomain() const |
|
301 { |
|
302 return iUserDomain; |
|
303 } |
|
304 |
|
305 |
|
306 // ----------------------------------------------------------------------------- |
|
307 // CPEngContactListManagerBase::StoreSettingsL() |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 void CPEngContactListManagerBase::StoreSettingsL() |
|
311 { |
|
312 StoreL(); |
|
313 } |
|
314 |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // CPEngContactListManagerBase::StoreSize() |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 TInt& CPEngContactListManagerBase::StoreSize( ) |
|
321 { |
|
322 return iSize; |
|
323 } |
|
324 |
|
325 |
|
326 |
|
327 // ============================================================================= |
|
328 // ==================== Functions from CPresenceStoreEntry ===================== |
|
329 // ============================================================================= |
|
330 |
|
331 |
|
332 // ----------------------------------------------------------------------------- |
|
333 // CPEngContactListMainArray::ExternalizeL() |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 void CPEngContactListManagerBase::ExternalizeL( RWriteStream& aStream, |
|
337 TPEngStorageType aStorageType ) const |
|
338 { |
|
339 switch ( aStorageType ) |
|
340 { |
|
341 case EPEngStorageBasicPermanent: |
|
342 { |
|
343 TInt count ( iContactListSettings.Count() ); |
|
344 aStream.WriteInt32L( count ); |
|
345 for ( TInt x ( 0 ) ; x < count ; x++ ) |
|
346 { |
|
347 iContactListSettings[x]->ExternalizeL( aStream, |
|
348 aStorageType ); |
|
349 } |
|
350 break; |
|
351 } |
|
352 |
|
353 |
|
354 case EPEngStorageBasicCached: |
|
355 { |
|
356 aStream.WriteInt32L( iEnviromentSynchronized ); |
|
357 |
|
358 TInt count ( iContactListSettings.Count() ); |
|
359 for ( TInt x ( 0 ) ; x < count ; x++ ) |
|
360 { |
|
361 iContactListSettings[x]->ExternalizeL( aStream, |
|
362 aStorageType ); |
|
363 } |
|
364 break; |
|
365 } |
|
366 |
|
367 |
|
368 default: |
|
369 { |
|
370 break; |
|
371 } |
|
372 } |
|
373 } |
|
374 |
|
375 |
|
376 // ----------------------------------------------------------------------------- |
|
377 // CPEngContactListManagerBase::InternalizeL() |
|
378 // ----------------------------------------------------------------------------- |
|
379 // |
|
380 void CPEngContactListManagerBase::InternalizeL( |
|
381 RReadStream& aStream, |
|
382 TPEngStorageType aStorageType ) |
|
383 { |
|
384 switch ( aStorageType ) |
|
385 { |
|
386 case EPEngStorageBasicPermanent: |
|
387 { |
|
388 iContactListSettings.ResetAndDestroy(); |
|
389 iSize = KMinimumStoreEntrySize; |
|
390 |
|
391 TInt count ( aStream.ReadInt32L() ); |
|
392 for ( TInt x ( 0 ) ; x < count ; x++ ) |
|
393 { |
|
394 CPEngContactListSettings* newSettings = |
|
395 CPEngContactListSettings::NewStreamLC( aStream, |
|
396 *this ); |
|
397 iContactListSettings.AppendL( newSettings ); |
|
398 CleanupStack::Pop(); // newSettings |
|
399 } |
|
400 |
|
401 iEnviromentSynchronized = EFalse; |
|
402 break; |
|
403 } |
|
404 |
|
405 |
|
406 case EPEngStorageBasicCached: |
|
407 { |
|
408 iEnviromentSynchronized = aStream.ReadInt32L(); |
|
409 |
|
410 TInt count ( iContactListSettings.Count() ); |
|
411 for ( TInt x( 0 ) ; x < count ; ++x ) |
|
412 { |
|
413 iContactListSettings[ x ]->InternalizeL( aStream, |
|
414 aStorageType ); |
|
415 } |
|
416 break; |
|
417 } |
|
418 default: |
|
419 { |
|
420 |
|
421 break; |
|
422 } |
|
423 } |
|
424 } |
|
425 |
|
426 |
|
427 // ----------------------------------------------------------------------------- |
|
428 // CPEngContactListManagerBase::StorageId() |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 const TDesC& CPEngContactListManagerBase::StorageId() const |
|
432 { |
|
433 return KPEngContactListManagerSId; |
|
434 } |
|
435 |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // CPEngContactListManagerBase::EntrySize() |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 TUint32 CPEngContactListManagerBase::EntrySize() const |
|
442 { |
|
443 return iSize; |
|
444 } |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 // ============================================================================= |
|
450 // ==================== Functions from MPEngSIDChangeObserver ================== |
|
451 // ============================================================================= |
|
452 |
|
453 // ----------------------------------------------------------------------------- |
|
454 // CPEngContactListManagerBase::HandleSIDsChangeL() |
|
455 // ----------------------------------------------------------------------------- |
|
456 // |
|
457 void CPEngContactListManagerBase::HandleSIDsChangeL( |
|
458 CPtrCArray& /* aChangedSIDs */ ) |
|
459 { |
|
460 TInt err( iStorageManager->RetrieveL( *this ) ); |
|
461 if ( err == KErrNotFound ) |
|
462 { |
|
463 InitWatcherListL(); |
|
464 StoreL(); |
|
465 } |
|
466 |
|
467 NotifyCntLstSettingsObservers(); |
|
468 HandleSettingsUpdateL(); |
|
469 } |
|
470 |
|
471 |
|
472 // ----------------------------------------------------------------------------- |
|
473 // CPEngContactListManagerBase::HandleSIDNotifyError() |
|
474 // ----------------------------------------------------------------------------- |
|
475 // |
|
476 void CPEngContactListManagerBase::HandleSIDNotifyError( TInt /* aError */ ) |
|
477 { |
|
478 NotifyCntLstSettingsObservers(); |
|
479 } |
|
480 |
|
481 |
|
482 // ============================================================================= |
|
483 // =============== protected functions for derived classes ===================== |
|
484 // ============================================================================= |
|
485 |
|
486 // ----------------------------------------------------------------------------- |
|
487 // CPEngContactListManagerBase::FindContactListSettings() |
|
488 // ----------------------------------------------------------------------------- |
|
489 // |
|
490 TInt CPEngContactListManagerBase::FindContactListSettings( |
|
491 const TDesC& aContactList ) const |
|
492 { |
|
493 TInt index( KErrNotFound ); |
|
494 TPEngContactListSettingsIdAccessor settingsOrder; |
|
495 |
|
496 if ( KErrNone == FindEntryInArray( iContactListSettings, |
|
497 aContactList, |
|
498 index, |
|
499 settingsOrder, |
|
500 iUserDomain ) ) |
|
501 { |
|
502 return index; |
|
503 } |
|
504 |
|
505 return KErrNotFound; |
|
506 } |
|
507 |
|
508 |
|
509 // ----------------------------------------------------------------------------- |
|
510 // CPEngContactListManagerBase::InsertContactListSettingsL() |
|
511 // ----------------------------------------------------------------------------- |
|
512 // |
|
513 void CPEngContactListManagerBase::InsertContactListSettingsL( |
|
514 CPEngContactListSettings& aSettings ) |
|
515 { |
|
516 TInt index( KErrNotFound ); |
|
517 TPEngContactListSettingsIdAccessor settingsOrder; |
|
518 |
|
519 if ( KErrNone == FindEntryInArray( iContactListSettings, |
|
520 aSettings.Name(), |
|
521 index, |
|
522 settingsOrder, |
|
523 iUserDomain ) ) |
|
524 { |
|
525 delete iContactListSettings[ index ]; |
|
526 iContactListSettings[ index ] = &aSettings; |
|
527 } |
|
528 |
|
529 else |
|
530 { |
|
531 iContactListSettings.InsertL( &aSettings, index ); |
|
532 } |
|
533 } |
|
534 |
|
535 |
|
536 // ----------------------------------------------------------------------------- |
|
537 // CPEngContactListManagerBase::DeleteContactListSettingsL() |
|
538 // ----------------------------------------------------------------------------- |
|
539 // |
|
540 void CPEngContactListManagerBase::DeleteContactListSettingsL( |
|
541 const TDesC& aContactList ) |
|
542 { |
|
543 TInt index( KErrNotFound ); |
|
544 TPEngContactListSettingsIdAccessor settingsOrder; |
|
545 if ( KErrNone == FindEntryInArray( iContactListSettings, |
|
546 aContactList, |
|
547 index, |
|
548 settingsOrder, |
|
549 iUserDomain ) ) |
|
550 { |
|
551 // delete contact list from store |
|
552 iStorageManager->Delete( aContactList ); |
|
553 |
|
554 // delete contact list from the settings array |
|
555 delete iContactListSettings[ index ]; |
|
556 iContactListSettings.Remove( index ); |
|
557 |
|
558 //notify observers |
|
559 NotifyCntLstSettingsObservers(); |
|
560 StoreL(); |
|
561 } |
|
562 } |
|
563 |
|
564 // ----------------------------------------------------------------------------- |
|
565 // CPEngContactListManagerBase::DefaultCntListSettingsOrNull() |
|
566 // ----------------------------------------------------------------------------- |
|
567 // |
|
568 CPEngContactListSettings* CPEngContactListManagerBase::DefaultCntListSettingsOrNull() |
|
569 { |
|
570 TInt count( iContactListSettings.Count() ); |
|
571 for ( TInt x( 0 ) ; x < count ; ++x ) |
|
572 { |
|
573 CPEngContactListSettings* settings = iContactListSettings[ x ]; |
|
574 if ( settings->IsDefault() ) |
|
575 { |
|
576 return settings; |
|
577 } |
|
578 } |
|
579 |
|
580 return NULL; |
|
581 } |
|
582 |
|
583 |
|
584 // ----------------------------------------------------------------------------- |
|
585 // CPEngContactListManagerBase::HandleSettingsUpdateL() |
|
586 // ----------------------------------------------------------------------------- |
|
587 // |
|
588 void CPEngContactListManagerBase::HandleSettingsUpdateL() |
|
589 { |
|
590 } |
|
591 |
|
592 |
|
593 // ----------------------------------------------------------------------------- |
|
594 // CPEngContactListManagerBase::LoadContactListModelL() |
|
595 // ----------------------------------------------------------------------------- |
|
596 // |
|
597 CPEngContactListModBase& CPEngContactListManagerBase::LoadContactListModelL( |
|
598 const TDesC& aContactList, |
|
599 TBool aReferenceUpdate, |
|
600 TBool aAnyTime ) |
|
601 { |
|
602 PENG_DP( D_PENG_LIT( "CPEngContactListManagerBase::LoadContactListModelL() [%S]" ), |
|
603 &aContactList ); |
|
604 |
|
605 CPEngContactListModBase* model = ContactListModelOrNull( aContactList ); |
|
606 if ( model ) |
|
607 { |
|
608 if ( aReferenceUpdate ) |
|
609 { |
|
610 model->Open(); // CSI: 65 # |
|
611 } |
|
612 |
|
613 return *model; |
|
614 } |
|
615 |
|
616 |
|
617 // check if requested list is watcher list |
|
618 if ( KErrNone == aContactList.CompareF( KPEngWatcherList ) ) |
|
619 { |
|
620 // Create watcher list and append it to array |
|
621 TInt x( FindContactListSettings( KPEngWatcherList ) ); |
|
622 CPEngWatcherList* newList = CPEngWatcherList::NewLC( |
|
623 *iContactListSettings[ x ], |
|
624 *iStorageManager, *this ); |
|
625 |
|
626 InsertContactListModelL( *newList ); |
|
627 CleanupStack::Pop(); // newList |
|
628 return *newList; |
|
629 } |
|
630 |
|
631 |
|
632 // try to find settings for contact list to load it |
|
633 CPEngContactListSettings* settings = ContactListSettingsOrNull( aContactList ); |
|
634 if ( settings ) |
|
635 { |
|
636 if ( !aAnyTime |
|
637 && |
|
638 !settings->Synchronized() |
|
639 && |
|
640 !settings->Property( KPEngCntLstSyncMaster, |
|
641 KPEngCntLstPropertyNativePermanent ) ) |
|
642 { |
|
643 User::Leave( KErrNotReady ); |
|
644 } |
|
645 |
|
646 // create list and append it to array |
|
647 CPEngContactListModBase* newList = CPEngContactListModBase::NewLC( |
|
648 *settings, |
|
649 *iStorageManager, |
|
650 *this ); |
|
651 |
|
652 InsertContactListModelL( *newList ); |
|
653 CleanupStack::Pop(); // newList |
|
654 return *newList; |
|
655 } |
|
656 |
|
657 User::Leave( KErrNotFound ); |
|
658 return *( iContactLists[0] ); //To keep compiler happy |
|
659 } |
|
660 |
|
661 |
|
662 // ----------------------------------------------------------------------------- |
|
663 // CPEngContactListManagerBase::ContactListModelOrNull() |
|
664 // ----------------------------------------------------------------------------- |
|
665 // |
|
666 CPEngContactListModBase* CPEngContactListManagerBase::ContactListModelOrNull( |
|
667 const TDesC& aContactList ) |
|
668 { |
|
669 TInt index( KErrNotFound ); |
|
670 TPEngContactListModelIdAccessor listModelOrder; |
|
671 if ( KErrNone == FindEntryInArray( iContactLists, |
|
672 aContactList, |
|
673 index, |
|
674 listModelOrder, |
|
675 iUserDomain ) ) |
|
676 { |
|
677 return iContactLists[ index ]; |
|
678 } |
|
679 |
|
680 return NULL; |
|
681 } |
|
682 |
|
683 // ----------------------------------------------------------------------------- |
|
684 // CPEngContactListManagerBase::InsertContactListModelL() |
|
685 // ----------------------------------------------------------------------------- |
|
686 // |
|
687 void CPEngContactListManagerBase::InsertContactListModelL( |
|
688 CPEngContactListModBase& aModel ) |
|
689 { |
|
690 TInt index( KErrNotFound ); |
|
691 TPEngContactListModelIdAccessor listModelOrder; |
|
692 if ( KErrNone == FindEntryInArray( iContactLists, |
|
693 aModel.Settings().Name(), |
|
694 index, |
|
695 listModelOrder, |
|
696 iUserDomain ) ) |
|
697 { |
|
698 User::Leave( KErrAlreadyExists ); |
|
699 } |
|
700 |
|
701 iContactLists.InsertL( &aModel, index ); |
|
702 } |
|
703 |
|
704 |
|
705 // ----------------------------------------------------------------------------- |
|
706 // CPEngContactListManagerBase::NotifyCntLstSettingsObservers() |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 void CPEngContactListManagerBase::NotifyCntLstSettingsObservers( ) |
|
710 { |
|
711 for ( TInt x ( iCntLstSettingsObservers.Count() - 1 ) ; x >= 0 ; x-- ) |
|
712 { |
|
713 iCntLstSettingsObservers[ x ]->RefreshSettingsReference(); |
|
714 } |
|
715 } |
|
716 |
|
717 |
|
718 // ============================================================================= |
|
719 // =============== New private functions ======================================= |
|
720 // ============================================================================= |
|
721 |
|
722 |
|
723 // ----------------------------------------------------------------------------- |
|
724 // CPEngContactListManagerBase::InitDomainNameL() |
|
725 // ----------------------------------------------------------------------------- |
|
726 // |
|
727 void CPEngContactListManagerBase::InitDomainNameL( |
|
728 const CPEngSessionSlotId& aSessionSlot ) |
|
729 { |
|
730 TChar domainSeparator( '@' ); |
|
731 TInt offset( aSessionSlot.UserId().LocateF( domainSeparator ) ); |
|
732 if ( KErrNotFound == offset ) |
|
733 { |
|
734 iUserDomain.Set( KNullDesC ); |
|
735 } |
|
736 else |
|
737 { |
|
738 // copy first part till '@' |
|
739 iUserDomain.Set( aSessionSlot.UserId().Mid( offset ) ); |
|
740 } |
|
741 } |
|
742 |
|
743 |
|
744 // ----------------------------------------------------------------------------- |
|
745 // CPEngContactListManagerBase::InitDomainNameL() |
|
746 // ----------------------------------------------------------------------------- |
|
747 // |
|
748 void CPEngContactListManagerBase::InitWatcherListL() |
|
749 { |
|
750 TPEngContactListBaseSettings baseSettings; |
|
751 baseSettings.iContactListNameAutoUpdate = EFalse; |
|
752 baseSettings.iContactListType = EPEngCachedContactList; |
|
753 |
|
754 CPEngContactListSettings* watcherSettings = |
|
755 CPEngContactListSettings::NewLC( KPEngWatcherList, |
|
756 baseSettings, |
|
757 *this ); |
|
758 watcherSettings->SetDisplayNameL( KPEngWatcherList ); |
|
759 |
|
760 // reset list, we start from beginning |
|
761 iContactListSettings.Reset(); |
|
762 iContactListSettings.AppendL( watcherSettings ); |
|
763 |
|
764 CleanupStack::Pop(); // watcherSettings |
|
765 } |
|
766 |
|
767 |
|
768 // End of File |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |