1 /* |
|
2 * Copyright (c) 2008 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: Class that provides handling of vpbk local store |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CVIMPSTSTORAGELOCALSTORE_H |
|
20 #define C_CVIMPSTSTORAGELOCALSTORE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <d32dbms.h> |
|
24 #include <s32file.h> |
|
25 |
|
26 #include "mvimpststoragevpbkcontactstore.h" |
|
27 #include "mvimpststoragevpbkstorehandler.h" |
|
28 |
|
29 //forward declaration |
|
30 class CVIMPSTStorageVPbkStoreHandler; |
|
31 class MVPbkViewContact; |
|
32 class CVPbkContactIdConverter; |
|
33 class MVIMPSTStorageVPbkStoreHandler; |
|
34 class MVIMPSTStorageServiceCacheWriter; |
|
35 class MVPbkContactLink; |
|
36 class MVPbkStoreContact; |
|
37 class CVPbkContactLinkArray; |
|
38 class MVIMPSTStorageContact; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 /** |
|
42 * vpbk local store |
|
43 * This class implements the use of Virtual Phonebook for Local Store(Contacts.cdb) |
|
44 * |
|
45 * @lib vimpststorage.lib |
|
46 * @since S60 5.0 |
|
47 */ |
|
48 NONSHARABLE_CLASS( CVIMPSTStorageVPbkLocalStore ) : public CActive, |
|
49 public MVIMPSTStorageVPbkContactStore, |
|
50 public MVIMPSTStorageVPbkStoreHandler |
|
51 |
|
52 |
|
53 { |
|
54 |
|
55 public: |
|
56 |
|
57 /** |
|
58 * Two-phased constructor. |
|
59 * |
|
60 * @param aContactDb, contact database |
|
61 * @param aListId, Default List ID |
|
62 * @param aServiceId - Service Id |
|
63 * @param aServiceName - Service Name |
|
64 * @param aStorageView, Ref to Storage (CVIMPSTStorageViewId) |
|
65 */ |
|
66 static CVIMPSTStorageVPbkLocalStore* NewL(const TDesC& aContactDb, const TDesC& aServiceName, |
|
67 MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter ); |
|
68 |
|
69 /** |
|
70 * Two-phased constructor. |
|
71 * |
|
72 * @param aContactDb, contact database |
|
73 * @param aListId, Default List ID |
|
74 * @param aServiceId - Service Id |
|
75 * @param aServiceName - Service Name |
|
76 * @param aStorageView, Ref to Storage (CVIMPSTStorageViewId) |
|
77 */ |
|
78 static CVIMPSTStorageVPbkLocalStore* NewLC( const TDesC& aContactDb, const TDesC& aServiceName, |
|
79 MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter ); |
|
80 |
|
81 /** |
|
82 * Standard C++ destructor |
|
83 */ |
|
84 ~CVIMPSTStorageVPbkLocalStore(); |
|
85 |
|
86 public: // from MVIMPSTStorageVPbkContactStore |
|
87 |
|
88 /** |
|
89 * See @MVIMPSTStorageVPbkContactStore |
|
90 * @ return ETrue |
|
91 **/ |
|
92 TBool LocalStore() const ; |
|
93 |
|
94 TInt CreateVPbkContactL( const TDesC& aUserId, |
|
95 const TDesC& aDisplayName, |
|
96 TBool aInvitationAutoAccept = EFalse) ; |
|
97 |
|
98 TInt RemoveVPbkContactL(const MVPbkContactLink& aContactLink) ; |
|
99 |
|
100 TInt RemoveVPbkContactsL(const MVPbkContactLink& aContactLink) ; |
|
101 |
|
102 TInt RetrieveVPbkXSPIdL(const TDesC8& aPackedLinks ) ; |
|
103 |
|
104 TInt CreateRetriveVPbkContactL(TInt aIndexToUse ) ; |
|
105 |
|
106 TInt deleteRetriveVPbkContactL(TInt aIndexToUse ) ; |
|
107 |
|
108 TInt UpdateAvatarFieldDataL(const MVPbkContactLink& aContactLink, |
|
109 const TDesC8& aAvatartData ); |
|
110 |
|
111 TInt RemoveAvatarFieldL(MVPbkStoreContact& aStoreContact); |
|
112 |
|
113 |
|
114 void AddVPbkFetchContactsL( RArray <TPtrC> &aFirstNameList, |
|
115 RArray <TPtrC> &aServiceField ) ; |
|
116 |
|
117 TInt RemoveAllVPbkContactsL() ; |
|
118 |
|
119 const TDesC& GetRetrieveVPbkXSPIdL(TInt aIndex ) ; |
|
120 |
|
121 void DeleteDatabaseL() ; |
|
122 |
|
123 public : // MVIMPSTStorageVPbkStoreHandler |
|
124 /** |
|
125 * From MVPbkContactStoreObserver |
|
126 * Callback: Store event occured |
|
127 * |
|
128 * @since S60 5.0 |
|
129 * @param aContactStore, contact store |
|
130 * @param aStoreEvent, event |
|
131 */ |
|
132 void HandleVPbkStoreEventL(TVIMPSTVPbkStoreEvent aVPbkStoreEvent) ; |
|
133 |
|
134 private: // From CActive |
|
135 void RunL(); |
|
136 void DoCancel(); |
|
137 TInt RunError(TInt aError ); |
|
138 |
|
139 private: |
|
140 |
|
141 /** |
|
142 * Issues Request |
|
143 * |
|
144 */ |
|
145 void IssueRequest(); |
|
146 |
|
147 |
|
148 private: |
|
149 |
|
150 /** |
|
151 * Check if database exists |
|
152 * @return ETrue, if database exists. |
|
153 */ |
|
154 TBool DbExists(); |
|
155 |
|
156 /** |
|
157 * Creates new CPermanentFileStore stream and creates database on it. |
|
158 */ |
|
159 void CreateDbL(); |
|
160 |
|
161 /** |
|
162 * Open existing database. |
|
163 */ |
|
164 |
|
165 void OpenDbL(); |
|
166 |
|
167 |
|
168 /** |
|
169 * Close database. |
|
170 */ |
|
171 void CloseDb(); |
|
172 |
|
173 /* |
|
174 * Create tables to database |
|
175 */ |
|
176 void CreateTablesL(); |
|
177 |
|
178 |
|
179 /** |
|
180 * Add a column to colset |
|
181 * @param aName Name of column |
|
182 * @param aType Type of column |
|
183 * @param aColset Colset, where column is added. |
|
184 * @param aMaxLength Maximum column length |
|
185 * 0 = use columns default value |
|
186 */ |
|
187 void AddColumnL( const TDesC& aName, TDbColType aType, |
|
188 CDbColSet* aColset ); |
|
189 |
|
190 |
|
191 /* |
|
192 * Leaves if free diskspace is low. |
|
193 * @param aSize amount of free diskspace needed. |
|
194 */ |
|
195 void DoFreespaceLevelCheckL( TInt aSize ); |
|
196 |
|
197 |
|
198 /** |
|
199 * Opens database table |
|
200 */ |
|
201 void OpenTableL(); |
|
202 |
|
203 /** |
|
204 * Closes database table |
|
205 */ |
|
206 void CloseTable(); |
|
207 |
|
208 |
|
209 /** |
|
210 * Seek a specific row with given contactlink in the database file. |
|
211 * @param aColNo The column number (KContactLink) |
|
212 * @param aContactLink - Packed Contact Link |
|
213 * @return ETrue if seek successful, otherwise EFalse |
|
214 */ |
|
215 TBool SeekRowL( TDbColNo aColNo, TDesC8& aContactLink ); |
|
216 |
|
217 |
|
218 /** |
|
219 * Seek a specific row with given contact identifier in the database file. |
|
220 * @param aColNo The column number (KContactId) |
|
221 * @param aContactId - Contact identifier |
|
222 * @return ETrue if seek successful, otherwise EFalse |
|
223 */ |
|
224 TBool SeekRowL( TDbColNo aColNo, TInt32& aContactId ); |
|
225 |
|
226 |
|
227 /** |
|
228 * Write the given data to the database file |
|
229 * @param aContactLink - Packed Contact Link |
|
230 * @param aIdentifier - Contact identifier |
|
231 */ |
|
232 void WriteToStoreDbL( TInt32& aIdentifier ); |
|
233 |
|
234 |
|
235 /** |
|
236 * Reads first contact from storage |
|
237 * @param aContactLink - Packed Contact Link |
|
238 * @return KErrNone, if successful. |
|
239 */ |
|
240 void ReadCurrentL( TInt32& aContactLink); |
|
241 |
|
242 |
|
243 /** |
|
244 * Reads next contact from storage |
|
245 * @param aContactLink - Packed Contact Link |
|
246 * @return KErrNone, if successful. |
|
247 */ |
|
248 TInt ReadNextL( TInt32& aContactId ); |
|
249 |
|
250 /** |
|
251 * Reads first contact from storage |
|
252 * @param aContactLink - Packed Contact Link |
|
253 * @return KErrNone, if successful. |
|
254 */ |
|
255 TInt ReadFirstL( TInt32& aContactLink ); |
|
256 |
|
257 |
|
258 /* |
|
259 * Deletes contact from storage |
|
260 * @param aContactId - Contact Identifier of the Contact to Delete |
|
261 */ |
|
262 void DeleteContactFromInternalStoreL( TInt32& aContactId ); |
|
263 |
|
264 void DeleteAllContactFromInternalStoreL(); |
|
265 |
|
266 |
|
267 private: // Implementation |
|
268 |
|
269 /** |
|
270 * Standard C++ constructor |
|
271 */ |
|
272 CVIMPSTStorageVPbkLocalStore(MVIMPSTStorageServiceCacheWriter& aServiceCacheWriter); |
|
273 |
|
274 /** |
|
275 * Performs the 2nd phase of construction. |
|
276 * |
|
277 * @param aContactDb, contact database address |
|
278 * @param aServiceName, service name |
|
279 */ |
|
280 void ConstructL(const TDesC& aContactDb, const TDesC& aServiceName ); |
|
281 |
|
282 /* |
|
283 * helper method for deleting entry from iFetchContactsToBeAdded |
|
284 */ |
|
285 void ResetAndDestroyLocalArrayL(); |
|
286 |
|
287 /* |
|
288 * compare both string without colon part |
|
289 * return ETrue if both contact are same |
|
290 */ |
|
291 TBool IsSameContactIdL(const TDesC& aFirstId, const TDesC& aSecondId ); |
|
292 |
|
293 private: // Data |
|
294 |
|
295 MVIMPSTStorageServiceCacheWriter& iServiceCacheWriter; |
|
296 // Own: pointer to a class which interact with Virtual phonebook |
|
297 CVIMPSTStorageVPbkStoreHandler* iVPbkStoreHandler; |
|
298 |
|
299 // own , contact id converter to and from link |
|
300 CVPbkContactIdConverter* iIdConverter; |
|
301 |
|
302 //Ownns - DB Store |
|
303 CPermanentFileStore* iFileStore; |
|
304 |
|
305 //File Stream |
|
306 RFs iFs; |
|
307 |
|
308 //DataBase Object for Creating/Opening/Closing DB |
|
309 RDbStoreDatabase iDb; |
|
310 |
|
311 // current column set |
|
312 CDbColSet* iColset; // owned |
|
313 |
|
314 RDbTable iTable; // current table |
|
315 |
|
316 HBufC* iLocalDBName; |
|
317 |
|
318 RArray<TVIMPSTContactInfo> iFetchContactsToBeAdded; |
|
319 |
|
320 TVIMPSTFetchingSteps iFetchStep; |
|
321 |
|
322 RPointerArray<MVIMPSTStorageContact> iRetrivedContactArray; |
|
323 // owns : id of invitation geting accepted |
|
324 HBufC* iInviteId; |
|
325 }; |
|
326 |
|
327 #endif // C_CVIMPSTSTORAGELOCALSTORE_H |
|
328 |
|
329 // End of file |
|