|
1 /** |
|
2 * Copyright (c) 1997-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 __CCONTACTPRIVATE_H__ |
|
28 #define __CCONTACTPRIVATE_H__ |
|
29 |
|
30 #include <cntitem.h> |
|
31 |
|
32 |
|
33 const TInt KNoValueSet = -1; // Used in CContactDatabase - not published. |
|
34 const TInt KFiveMins = 300000000; // Used in CContactDatabase - not published. |
|
35 |
|
36 |
|
37 class CPrivConverter; |
|
38 class CContactConverter; |
|
39 class CTextFieldMinimal; |
|
40 |
|
41 |
|
42 /** |
|
43 Base class for Contacts Model plug-ins. |
|
44 */ |
|
45 NONSHARABLE_CLASS(CContactPlugin) : public CBase |
|
46 { |
|
47 public: |
|
48 ~CContactPlugin(); |
|
49 |
|
50 protected: |
|
51 TUid LoadEComPluginFromInterface(TUid aInterfaceUid); |
|
52 CContactPlugin(); |
|
53 |
|
54 private: |
|
55 RLibrary iDll; |
|
56 }; |
|
57 |
|
58 |
|
59 /** |
|
60 Class for all template related functionality. |
|
61 */ |
|
62 NONSHARABLE_CLASS(CCntTemplateCache) : public CBase |
|
63 { |
|
64 public: |
|
65 static CCntTemplateCache* NewL(RCntModel& aCntSvr); |
|
66 ~CCntTemplateCache(); |
|
67 inline TContactItemId TemplateId()const {return iTemplateId;} |
|
68 void MergeWithTemplateL(CContactItem& aContact, const CContactItemViewDef* aViewDef = NULL); |
|
69 void RemoveTemplate(TContactItemId aId); |
|
70 CContactItem& SystemTemplateL(); |
|
71 |
|
72 private: |
|
73 CContactItem& TemplateL(TContactItemId aId); |
|
74 CCntTemplateCache(RCntModel& aCntSvr); |
|
75 void DeleteEntry(TInt aIndex); |
|
76 CContactItemViewDef& DefaultViewDefL(); |
|
77 void ResetSystemTemplate(); |
|
78 |
|
79 private: |
|
80 RPointerArray <CContactItem> iCache; |
|
81 RCntModel& iCntSvr; |
|
82 CContactItem* iSystemTemplate; |
|
83 TContactItemId iTemplateId; |
|
84 CContactItemViewDef* iViewDef; |
|
85 }; |
|
86 |
|
87 |
|
88 /** |
|
89 Contact item to vCard converter plug-in. |
|
90 */ |
|
91 NONSHARABLE_CLASS(CPrivConverter) : public CContactPlugin |
|
92 { |
|
93 public: |
|
94 static CPrivConverter* NewL(TUid aUid); |
|
95 static CPrivConverter* NewL(TUid aUid, TInt64 aContactFieldFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel); |
|
96 TVCardVersion GetCurrentVersion() const; |
|
97 TInt64 GetPBAPFilter() const; |
|
98 TBool GetExportTel()const; |
|
99 void LoadEComPluginL(TUid aUid, TInt64 aFilter, MConverterCallBack* aCallback, TVCardVersion aVersion, TBool aExportTel); |
|
100 void LoadEComPluginL(TUid aUid); |
|
101 ~CPrivConverter(); |
|
102 inline CContactConverter* Converter() const; |
|
103 private: |
|
104 TBool IsImplementationAvailableL(TUid aUid); |
|
105 private: |
|
106 CContactConverter* iConverter; |
|
107 TVCardVersion iVersion; |
|
108 TInt64 iPBAPFilter; |
|
109 TBool iExportTel; |
|
110 }; |
|
111 |
|
112 |
|
113 inline CContactConverter* CPrivConverter::Converter() const { return iConverter;} |
|
114 |
|
115 |
|
116 NONSHARABLE_CLASS(CSortArray) : public CBase |
|
117 { |
|
118 public: |
|
119 CSortArray(); |
|
120 ~CSortArray(); |
|
121 void AppendL(const TDesC &Text, TContactItemId aId); |
|
122 void SortL(CContactDatabase::TSortPref::TOrder aOrder); |
|
123 inline TInt Count() const; |
|
124 TContactItemId Id(TInt aIndex) const; |
|
125 HBufC *Text(TInt aIndex) const; |
|
126 void Merge(CSortArray *aDuplicates,TInt aStartPos); |
|
127 |
|
128 private: |
|
129 static TInt DefaultAlgorithmToCompareNames(const CTextFieldMinimal& aName1, const CTextFieldMinimal& aName2); |
|
130 |
|
131 private: |
|
132 RPointerArray<CTextFieldMinimal> iArray; |
|
133 }; |
|
134 |
|
135 |
|
136 inline TInt CSortArray::Count() const {return(iArray.Count());} |
|
137 |
|
138 |
|
139 NONSHARABLE_CLASS(CTextFieldMinimal) : public CBase |
|
140 { |
|
141 public: |
|
142 ~CTextFieldMinimal(); |
|
143 inline CTextFieldMinimal() : iId(KNullContactId) {}; |
|
144 void ConstructL(const TDesC &aText, TContactItemId aId); |
|
145 |
|
146 public: |
|
147 TContactItemId iId; |
|
148 HBufC *iText; |
|
149 }; |
|
150 |
|
151 |
|
152 NONSHARABLE_CLASS(CCntIdleSorter) : public CBase |
|
153 { |
|
154 public: |
|
155 static CCntIdleSorter* NewL(CContactDatabase& aContactDatabase); |
|
156 ~CCntIdleSorter(); |
|
157 |
|
158 public: |
|
159 // Access methods. |
|
160 void ResetL(); |
|
161 void Cancel(); |
|
162 void StartSortingL(CArrayFix<CContactDatabase::TSortPref>* aSortOrder, TRequestStatus& aStatus); |
|
163 void StartSortingL(CArrayFix<CContactDatabase::TSortPref>* aSortOrder, TRequestStatus& aStatus, MContactSortObserver& aObserver); |
|
164 |
|
165 private: |
|
166 // Internal construction methods. |
|
167 CCntIdleSorter(); |
|
168 CCntIdleSorter(CContactDatabase& aContactDatabase); |
|
169 void ConstructL(); |
|
170 |
|
171 private: |
|
172 // Sort state. |
|
173 enum TState {EReadContacts, ESortContacts}; |
|
174 |
|
175 private: |
|
176 static TInt SortCallBack(TAny* aThis); |
|
177 TInt PeformSortStep(); |
|
178 TBool ReadContactsL(TInt aNumber = 4); |
|
179 void SortListAndSaveL(); |
|
180 void CompleteRequest(TInt aError = KErrNone); |
|
181 void ReportProgressL(); |
|
182 |
|
183 private: |
|
184 inline TInt& TotalCount() { return iTotalCount; } |
|
185 inline TInt TotalCount() const { return iTotalCount; } |
|
186 inline TInt& ReadSoFar() { return iReadSoFar; } |
|
187 inline TInt ReadSoFar() const { return iReadSoFar; } |
|
188 inline TBool& HasObserver() { return iHasObserver; } |
|
189 inline TBool HasObserver() const { return iHasObserver; } |
|
190 |
|
191 private: |
|
192 TBool iHasObserver; |
|
193 TInt iTotalCount; |
|
194 TInt iReadSoFar; |
|
195 |
|
196 MContactSortObserver* iObserver; |
|
197 CContactDatabase& iDb; |
|
198 CArrayFix<CContactDatabase::TSortPref>* iSortOrder; |
|
199 TRequestStatus* iStatus; |
|
200 |
|
201 CIdle* iIdle; |
|
202 TState iState; |
|
203 CContactIdArray* iFinalItems; |
|
204 CSortArray* iSortedList; |
|
205 TContactItemId iCurrentId; |
|
206 TBool iSortStarted; |
|
207 }; |
|
208 |
|
209 |
|
210 NONSHARABLE_CLASS (CDataBaseChangeObserver) : public CBase, public MContactDbObserver |
|
211 { |
|
212 public: |
|
213 void HandleDatabaseEventL(TContactDbObserverEvent aEvent); |
|
214 static CDataBaseChangeObserver* NewL(MContactDbPrivObserver& aPrivateObserver); |
|
215 ~CDataBaseChangeObserver(); |
|
216 |
|
217 private: |
|
218 CDataBaseChangeObserver (MContactDbPrivObserver& aPrivateObserver); |
|
219 MContactDbPrivObserver& iPrivateObserver; |
|
220 }; |
|
221 |
|
222 |
|
223 #endif //__CCONTACTPRIVATE_H__ |