|
1 /** |
|
2 * Copyright (c) 2007-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 @released |
|
24 */ |
|
25 |
|
26 |
|
27 #ifndef __CVIEWCONTACTMANAGER_H__ |
|
28 #define __CVIEWCONTACTMANAGER_H__ |
|
29 |
|
30 #include "persistencelayer.h" |
|
31 #include <cntviewbase.h> |
|
32 |
|
33 class MContactViewSortObserver |
|
34 { |
|
35 public: |
|
36 enum TIccViewNotify |
|
37 { |
|
38 TIccViewNotify_IccOnlyLocked, |
|
39 TIccViewNotify_IccUnlocked |
|
40 }; |
|
41 |
|
42 public: |
|
43 virtual TBool IdleSorterNotifyL(TInt aSortErr) =0; |
|
44 virtual void IccViewNotifyL(TInt aIccViewReady) =0; |
|
45 }; |
|
46 |
|
47 |
|
48 /** |
|
49 The CViewContactManager is an internal class responsible to sort contact view items, |
|
50 according to sort plug-in, and provide CViewContact items for CContactLocalView. |
|
51 And it's the only view class interact with persistence layer(CPplContactViewItemManager) |
|
52 to retrieve contact view item from database. |
|
53 @internalComponent |
|
54 */ |
|
55 NONSHARABLE_CLASS(CViewContactManager) : public CBase, public MContactViewSortObserver |
|
56 { |
|
57 public: |
|
58 static CViewContactManager* NewL(CContactLocalView& aLocalView, MLplPersistenceLayerFactory& aFactory, const CContactTextDef& aTextDef, TContactViewPreferences aViewPerference, CViewContactSortPlugin* aSortPlugin); |
|
59 ~CViewContactManager(); |
|
60 |
|
61 TContactItemId AtL(TInt aIndex) const; |
|
62 TInt Count() const; |
|
63 TInt FindL(TContactItemId aContactId) const; |
|
64 void SortL(); |
|
65 void SortL(const CContactTextDef& aTextDef); |
|
66 void StopSortL(); |
|
67 TInt InsertL(const TContactItemId aContactId, TContactViewPreferences& aViewPreference); |
|
68 TInt RemoveL(const TContactItemId aContactId); |
|
69 HBufC* AllFieldsLC(TInt aIndex, const TDesC& aSeparator) const; |
|
70 |
|
71 const CViewContact& ContactAtL(TInt aIndex) const; |
|
72 |
|
73 TBool IsICCSynchronised() const; |
|
74 |
|
75 //Implementation for MContactSortObserver |
|
76 TBool IdleSorterNotifyL(TInt aSortErr); |
|
77 void IccViewNotifyL(TInt aIccViewReady); |
|
78 |
|
79 private: |
|
80 /* To represent the state when retrieving data from database */ |
|
81 enum TReadState |
|
82 { |
|
83 EReadFullChunk, // The read items reached the number of limitation per invocation |
|
84 EReadFullForMerge, // The read items reached the number of limitation per merge |
|
85 EReadCompleted // Read is completed, no more view contact item in database. |
|
86 }; |
|
87 |
|
88 private: |
|
89 CViewContactManager(CContactLocalView& aLocalView, MLplViewIteratorManager& aLplViewMgr, TContactViewPreferences aViewPerference, CViewContactSortPlugin* aSortPlugin); |
|
90 void ConstructL(MLplPersistenceLayerFactory& aFactory, const CContactTextDef& aTextDef); |
|
91 |
|
92 TInt InsertViewContactL(const CViewContact* aNewContact, TBool aSortByIdOnly, TInt aStart); |
|
93 void HeapSortL(RPointerArray<CViewContact>& aViewContacts); |
|
94 RPointerArray<CViewContact>* MergeL(RPointerArray<CViewContact>& aLeftContacts, RPointerArray<CViewContact>& aRightContacts); |
|
95 |
|
96 TReadState ReadInViewContactsL(RPointerArray<CViewContact>& aViewContacts); |
|
97 CViewContact& ViewContactAtL(TInt aIndex) const; |
|
98 |
|
99 void ResetSort(); |
|
100 |
|
101 static TBool ContactCorrectType(TUid aType, TContactViewPreferences aTypeToInclude); |
|
102 static void ResetAndDestroyRPointerArrayPointer(TAny *aArray); |
|
103 |
|
104 //These functions are copied from CContactViewBase classes |
|
105 TBool IsContactSortable(const CViewContact& aContact, TContactViewPreferences& aViewPreferences) const; |
|
106 TInt CompareContactsAndIdsL(const CViewContact& aFirst, const CViewContact& aSecond) const; |
|
107 TInt TextCompareFieldsL(const CViewContact& aFirst, const CViewContact& aSecond) const; |
|
108 HBufC* FieldsWithSeparatorLC(const CViewContact& aViewContact, const TDesC& aSeparator) const; |
|
109 static TInt CompareFieldsWithCollationLevel(const CViewContact& aFirst, const CViewContact& aSecond, TInt aCollationLevel, const TCollationMethod* aCollateMethod); |
|
110 |
|
111 private: |
|
112 CContactLocalView& iLocalView; |
|
113 |
|
114 CIdleContactSorter* iIdleSorter; |
|
115 |
|
116 TInt iViewSessionId; |
|
117 |
|
118 RPointerArray<CViewContact>* iViewContacts; |
|
119 RPointerArray<CViewContact>* iUnsortedViewContacts; |
|
120 RPointerArray<CViewContact>* iViewContactsBuffer; |
|
121 |
|
122 CViewContactSortPlugin* iSortPluginImpl; //this is not owned by the class |
|
123 |
|
124 TContactViewPreferences iViewPreferences; |
|
125 TCollationMethod iCollationMethod; |
|
126 |
|
127 MLplViewIteratorManager& iLplViewItemMgr; |
|
128 }; |
|
129 |
|
130 #endif // __CVIEWCONTACTMANAGER_H__ |