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 store |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CVIMPSTSTOTRAGEVPBKSTOREHANDLER_H |
|
20 #define CVIMPSTSTOTRAGEVPBKSTOREHANDLER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <cntdef.h> |
|
25 |
|
26 #include "mvimpststoragevpbkstorehandler.h" |
|
27 |
|
28 #include <MVPbkContactViewObserver.h> |
|
29 #include <MVPbkContactStoreObserver.h> |
|
30 #include <MVPbkContactStoreListObserver.h> |
|
31 #include <MVPbkContactObserver.h> |
|
32 #include <MVPbkBatchOperationObserver.h> |
|
33 #include <MVPbkSingleContactOperationObserver.h> |
|
34 |
|
35 #include <badesca.h> |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class MVPbkContactViewBase; |
|
39 class MVPbkContactLink; |
|
40 class CVPbkContactManager; |
|
41 class MVPbkContactStoreList; |
|
42 class MVPbkContactView; |
|
43 class MVPbkStoreContact; |
|
44 class MVPbkViewContact; |
|
45 class CVPbkContactLinkArray; |
|
46 class MVIMPSTStorageVPbkStoreHandler; |
|
47 class CPbk2SortOrderManager; |
|
48 class MVPbkContactOperationBase; |
|
49 class MVPbkBaseContact; |
|
50 class CVPbkContactLinkArray; |
|
51 |
|
52 // CLASS DECLARATION |
|
53 /** |
|
54 * vpbk store Handler |
|
55 * This class implements the use of Virtual Phonebook for XSP Stores |
|
56 * |
|
57 * @lib vimpststorage.lib |
|
58 * @since S60 5.0 |
|
59 */ |
|
60 NONSHARABLE_CLASS( CVIMPSTStorageVPbkStoreHandler ) : public CActive, |
|
61 public MVPbkContactViewObserver, |
|
62 public MVPbkContactStoreObserver, |
|
63 public MVPbkContactStoreListObserver, |
|
64 public MVPbkContactObserver, |
|
65 public MVPbkBatchOperationObserver, |
|
66 public MVPbkSingleContactOperationObserver |
|
67 { |
|
68 |
|
69 struct TVIMPSTAvatarData |
|
70 { |
|
71 // owns |
|
72 MVPbkContactLink* iContactLink; |
|
73 // owns |
|
74 HBufC8* iAvatarContent; |
|
75 }; |
|
76 public: |
|
77 |
|
78 /** |
|
79 * Two-phased constructor. |
|
80 * |
|
81 * @param aContactDb, contact database |
|
82 * @param aListId, Default List ID |
|
83 * @param aServiceId - Service Id |
|
84 * @param aServiceName - Service Name |
|
85 * @param aStorageView, Ref to Storage (CVIMPSTStorageViewId) |
|
86 */ |
|
87 static CVIMPSTStorageVPbkStoreHandler* NewL(const TDesC& aContactDb, |
|
88 const TDesC& aServiceName, |
|
89 MVIMPSTStorageVPbkStoreHandler& aStoreHandler, |
|
90 TBool aLocalStore ); |
|
91 |
|
92 /** |
|
93 * Two-phased constructor. |
|
94 * |
|
95 * @param aContactDb, contact database |
|
96 * @param aListId, Default List ID |
|
97 * @param aServiceId - Service Id |
|
98 * @param aServiceName - Service Name |
|
99 * @param aStorageView, Ref to Storage (CVIMPSTStorageViewId) |
|
100 */ |
|
101 static CVIMPSTStorageVPbkStoreHandler* NewLC(const TDesC& aContactDb, |
|
102 const TDesC& aServiceName, |
|
103 MVIMPSTStorageVPbkStoreHandler& aStoreHandler, |
|
104 TBool aLocalStore ); |
|
105 |
|
106 /** |
|
107 * Standard C++ destructor |
|
108 */ |
|
109 ~CVIMPSTStorageVPbkStoreHandler(); |
|
110 public : // |
|
111 /** |
|
112 * return vpbk store |
|
113 * @param aUri uri of store |
|
114 */ |
|
115 MVPbkContactStore* GetDefaultStoreL( const TDesC& aUri ); |
|
116 |
|
117 TInt CreateVPbkContactL( const TDesC& aUserId, |
|
118 const TDesC& aDisplayName ) ; |
|
119 |
|
120 TInt RemoveVPbkContactL(const CVPbkContactLinkArray& aContactLinkArray ) ; |
|
121 |
|
122 TInt RetrieveVPbkContactL(const TDesC8& aPackedLinks ); |
|
123 |
|
124 TInt UpdateAvatarFieldDataL(const MVPbkContactLink& aContactLink, |
|
125 const TDesC8& aAvatartData ); |
|
126 |
|
127 TInt RemoveAvatarFieldL(MVPbkStoreContact& aStoreContact); |
|
128 |
|
129 TInt RemoveAllVPbkContactsL(); |
|
130 |
|
131 private: // From MVPbkContactViewObserver |
|
132 |
|
133 /** |
|
134 * From MVPbkContactViewObserver |
|
135 * Callback: Contact view is ready |
|
136 * |
|
137 * @since S60 5.0 |
|
138 * @param aView, view that is ready |
|
139 */ |
|
140 void ContactViewReady( MVPbkContactViewBase& aView ); |
|
141 |
|
142 /** |
|
143 * From MVPbkContactViewObserver |
|
144 * Callback: Contact view is unavailable |
|
145 * |
|
146 * @since S60 5.0 |
|
147 * @param aView, view that is unavailable |
|
148 */ |
|
149 void ContactViewUnavailable( MVPbkContactViewBase& aView ); |
|
150 |
|
151 /** |
|
152 * From MVPbkContactViewObserver |
|
153 * Callback: Contact is added to view |
|
154 * |
|
155 * @since S60 5.0 |
|
156 * @param aView, view that contact was added to |
|
157 * @param aIndex, position to where the contact was added to |
|
158 * @param MVPbkContactLink, contact link of the added contact |
|
159 */ |
|
160 void ContactAddedToView( MVPbkContactViewBase& aView, |
|
161 TInt aIndex, const MVPbkContactLink& aContactLink ); |
|
162 |
|
163 /** |
|
164 * From MVPbkContactViewObserver |
|
165 * Callback: Contact was removed from the view |
|
166 * |
|
167 * @since S60 5.0 |
|
168 * @param aView, view that contact was removed from |
|
169 * @param aIndex, position from where the contact was removed from |
|
170 * @param MVPbkContactLink, contact link of the removed contact |
|
171 */ |
|
172 void ContactRemovedFromView( MVPbkContactViewBase& aView, |
|
173 TInt aIndex, const MVPbkContactLink& aContactLink ); |
|
174 |
|
175 /** |
|
176 * From MVPbkContactViewObserver |
|
177 * Callback: Contact view error |
|
178 * |
|
179 * @since S60 5.0 |
|
180 * @param aView, view that caused the error |
|
181 * @param aError, error that occured |
|
182 * @param aErrorNotified, was it notified |
|
183 */ |
|
184 void ContactViewError( MVPbkContactViewBase& aView, |
|
185 TInt aError, TBool aErrorNotified ); |
|
186 |
|
187 private: // From MVPbkContactStoreObserver |
|
188 |
|
189 /** |
|
190 * From MVPbkContactStoreObserver |
|
191 * Callback: Contact store is ready |
|
192 * |
|
193 * @since S60 5.0 |
|
194 * @param aContactStore, contact store |
|
195 */ |
|
196 void StoreReady( MVPbkContactStore& aContactStore); |
|
197 |
|
198 /** |
|
199 * From MVPbkContactStoreObserver |
|
200 * Callback: Store is unavailable |
|
201 * |
|
202 * @since S60 5.0 |
|
203 * @param aContactStore, contact store |
|
204 * @param aReason, error code |
|
205 */ |
|
206 void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason); |
|
207 |
|
208 /** |
|
209 * From MVPbkContactStoreObserver |
|
210 * Callback: Store event occured |
|
211 * |
|
212 * @since S60 5.0 |
|
213 * @param aContactStore, contact store |
|
214 * @param aStoreEvent, event |
|
215 */ |
|
216 void HandleStoreEventL( MVPbkContactStore& aContactStore , |
|
217 TVPbkContactStoreEvent aStoreEvent ); |
|
218 |
|
219 private: // From MVPbkContactStoreListObserver |
|
220 |
|
221 /** |
|
222 * From MVPbkContactStoreListObserver |
|
223 * Callback: List open is completed |
|
224 * |
|
225 * @since S60 5.0 |
|
226 */ |
|
227 void OpenComplete(); |
|
228 |
|
229 private: |
|
230 /** |
|
231 * From MVPbkContactObserver |
|
232 */ |
|
233 void ContactOperationCompleted(TContactOpResult aResult); |
|
234 |
|
235 /** |
|
236 * From MVPbkContactObserver |
|
237 */ |
|
238 void ContactOperationFailed( TContactOp aOpCode, |
|
239 TInt aErrorCode, |
|
240 TBool aErrorNotified); |
|
241 |
|
242 private: // From MVPbkBatchOperationObserver |
|
243 void StepComplete( MVPbkContactOperationBase& aOperation, |
|
244 TInt aStepSize ); |
|
245 TBool StepFailed( MVPbkContactOperationBase& aOperation, |
|
246 TInt aStepSize, TInt aError ); |
|
247 void OperationComplete( MVPbkContactOperationBase& aOperation ); |
|
248 |
|
249 public: // From MVPbkSingleContactOperationObserver |
|
250 |
|
251 /** |
|
252 * from MVPbkSingleContactOperationObserver. |
|
253 * Called when the operation is completed. |
|
254 * |
|
255 * A client has the operation as a member and it can delete the operation |
|
256 * instance in this function call. If the implementation of the store |
|
257 * calls the function from the operation instance it must not handle |
|
258 * any member data after calling it. |
|
259 * |
|
260 * @param aOperation The completed operation. |
|
261 * @param aContact The contact returned by the operation. |
|
262 * A client must take the ownership immediately. |
|
263 * |
|
264 * NOTE: |
|
265 * If you use CleanupStack for MVPbkStoreContact |
|
266 * Use MVPbkStoreContact::PushL or |
|
267 * CleanupDeletePushL from e32base.h. |
|
268 * (Do Not Use CleanupStack::PushL(TAny*) because |
|
269 * then the virtual destructor of the M-class |
|
270 * won't be called when the object is deleted). |
|
271 * @since S60 v5.0 |
|
272 */ |
|
273 void VPbkSingleContactOperationComplete( |
|
274 MVPbkContactOperationBase& aOperation, |
|
275 MVPbkStoreContact* aContact); |
|
276 |
|
277 /** |
|
278 * from MVPbkSingleContactOperationObserver. |
|
279 * Called if the operation fails. |
|
280 * |
|
281 * A client has the operation as a member and it can delete the operation |
|
282 * instance in this function call. If the implementation of the store |
|
283 * calls the function from the operation instance it must not handle |
|
284 * any member data after calling it. |
|
285 * |
|
286 * @param aOperation The failed operation. |
|
287 * @param aError An error code of the failure. |
|
288 * @since S60 v5.0 |
|
289 */ |
|
290 void VPbkSingleContactOperationFailed( |
|
291 MVPbkContactOperationBase& aOperation, |
|
292 TInt aError); |
|
293 |
|
294 private: // From CActive |
|
295 void RunL(); |
|
296 void DoCancel(); |
|
297 TInt RunError(TInt aError ); |
|
298 |
|
299 private: |
|
300 |
|
301 /** |
|
302 * Issues Request |
|
303 * |
|
304 */ |
|
305 void IssueRequest(); |
|
306 |
|
307 void HandleContactViewReadyL( MVPbkContactViewBase& aView ); |
|
308 |
|
309 void DoHnadleSingleContactOperationCompleteL( MVPbkContactOperationBase& aOperation, |
|
310 MVPbkStoreContact* aContact ); |
|
311 |
|
312 void DoHnadleOpenCompleteL(); |
|
313 |
|
314 void RetriveFieldDataAndSendEventL(const MVPbkStoreContact& aContact ); |
|
315 |
|
316 /** |
|
317 * destroys the content of RArray. |
|
318 */ |
|
319 void ResetAndDestroyRArray(); |
|
320 |
|
321 private: // Implementation |
|
322 |
|
323 /** |
|
324 * Standard C++ constructor |
|
325 */ |
|
326 CVIMPSTStorageVPbkStoreHandler( MVIMPSTStorageVPbkStoreHandler& aStoreHandler,TBool aLocalStore ); |
|
327 |
|
328 /** |
|
329 * Performs the 2nd phase of construction. |
|
330 * |
|
331 * @param aContactDb, contact database address |
|
332 * @param aServiceName, service Name |
|
333 */ |
|
334 void ConstructL( const TDesC& aContactDb,const TDesC& aServiceName ); |
|
335 |
|
336 |
|
337 HBufC* GetContactFieldDataLC(const MVPbkStoreContact& aContact, |
|
338 TInt aFieldResId ) ; |
|
339 |
|
340 /** |
|
341 * To get the avatar data |
|
342 * |
|
343 * @param aContact, contact |
|
344 * @param aFieldResId, field id |
|
345 */ |
|
346 HBufC8* GetContactBinaryFieldDataLC(const MVPbkStoreContact& aContact, |
|
347 TInt aFieldResId ); |
|
348 |
|
349 /** |
|
350 * check if any pending add contacts |
|
351 * commit if pending |
|
352 */ |
|
353 void CommitNextPendingContactsL() ; |
|
354 |
|
355 private: // Data |
|
356 // Not owns reference to contactStore |
|
357 MVIMPSTStorageVPbkStoreHandler& iStoreHandler; |
|
358 // Own: Virtual phonebook |
|
359 CVPbkContactManager* iContactManager; |
|
360 // Not own, Contact store list owned by the contact |
|
361 // manager, do not delete |
|
362 MVPbkContactStoreList* iStores; |
|
363 // Not own, Contact store owned by the contact |
|
364 // manager, do not delete |
|
365 MVPbkContactStore* iStore; |
|
366 // Own, contact view containing contacts in store |
|
367 MVPbkContactView* iContactView; |
|
368 //OWN: Active scheduler wait for waiting the completion |
|
369 CActiveSchedulerWait iWait; |
|
370 // owns : Service store name |
|
371 HBufC* iStoreName; |
|
372 // Own, sort order manager |
|
373 CPbk2SortOrderManager* iSortOrderManager; |
|
374 // owns : service name |
|
375 HBufC* iServiceName; |
|
376 // owns : a vpbk store contact |
|
377 MVPbkStoreContact* iStoreContact; |
|
378 // owns : operation contact |
|
379 MVPbkContactOperationBase* iContactOperation; |
|
380 // owns : a contact Link; |
|
381 MVPbkContactLink* iContactLink; |
|
382 // owns : results |
|
383 TInt iOperationError; |
|
384 // owns : Store event type |
|
385 TVIMPSTVPbkStoreEventType iStoreEventType; |
|
386 // owns : fetching index |
|
387 TInt iFetcingIndex; |
|
388 // owns : adding of contact is in progress |
|
389 HBufC* iAddIdInProgress; |
|
390 // ETrue if local store used |
|
391 TBool iLocalStore; |
|
392 // is contact operation is in use |
|
393 TBool iCommitOperationInProgress; |
|
394 // owns : synch contact which are overlapping or pending contacts |
|
395 RPointerArray<MVPbkStoreContact> iUnCommittedVPbkContacts; |
|
396 |
|
397 // owns : synch avatars which are overlapping or pending avatars |
|
398 RArray<TVIMPSTAvatarData> iPendingAvatars; |
|
399 |
|
400 }; |
|
401 |
|
402 #endif // CVIMPSTSTOTRAGEVPBKSTOREHANDLER_H |
|
403 |
|
404 // End of file |
|