|
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: Storage view implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CVIMPSTSTORAGESERVICEVIEW_H |
|
19 #define CVIMPSTSTORAGESERVICEVIEW_H |
|
20 |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <f32file.h> |
|
25 #include <babackup.h> |
|
26 |
|
27 #include "mvimpststorageserviceview.h" |
|
28 #include "tvimpststoragepanics.h" |
|
29 #include "tvimpstenums.h" |
|
30 #include "mvimpststorageitemmodel.h" |
|
31 #include "mvimpststorageactiveobserver.h" |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CVIMPSTStorageContactList; |
|
35 class CVIMPSTStorageContactSorter; |
|
36 class MVIMPSTStorageVPbkContactStore; |
|
37 class MVPbkContactLink; |
|
38 class CVIMPSTStorageActiveHandler; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 |
|
42 NONSHARABLE_CLASS ( CVIMPSTStorageServiceView ): public CBase, |
|
43 public MVIMPSTStorageServiceView, |
|
44 public MVIMPSTStorageServiceCacheWriter, |
|
45 public MVIMPSTStorageItemModel, |
|
46 public MVIMPSTStorageActiveObserver |
|
47 |
|
48 { |
|
49 public: // Constructors and destructor |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 */ |
|
54 static CVIMPSTStorageServiceView* NewL(TUint32 aServiceId, const TDesC& aStoreName, |
|
55 const TDesC& aServiceName); |
|
56 |
|
57 /** |
|
58 * Destructor. |
|
59 */ |
|
60 ~CVIMPSTStorageServiceView(); |
|
61 |
|
62 public: // New functions |
|
63 |
|
64 |
|
65 TUint32 GetServiceId(); |
|
66 |
|
67 public: // Functions from base classes |
|
68 |
|
69 /** |
|
70 * From MVIMPSTStorageServiceView |
|
71 */ |
|
72 void AddObserverL( MVIMPSTStorageContactsObserver* aObserver ) ; |
|
73 |
|
74 /** |
|
75 * From MVIMPSTStorageServiceView |
|
76 */ |
|
77 void RemoveObserver( MVIMPSTStorageContactsObserver* aObserver ) ; |
|
78 |
|
79 /** |
|
80 * From MVIMPSTStorageServiceView |
|
81 */ |
|
82 MVIMPSTStorageContact* FindContactByUserId( const TDesC& aUserId ) ; |
|
83 |
|
84 /** |
|
85 * From MVIMPSTStorageServiceView |
|
86 */ |
|
87 MVIMPSTStorageContact* FindContactByLink(const MVPbkContactLink& aContactLink ) ; |
|
88 |
|
89 /** |
|
90 * From MVIMPSTStorageServiceView |
|
91 */ |
|
92 TInt ListCount() const ; |
|
93 |
|
94 |
|
95 /** |
|
96 * From MVIMPSTStorageServiceView |
|
97 */ |
|
98 MVIMPSTStorageContactList& ListAt( TInt aIndex ) const ; |
|
99 |
|
100 |
|
101 /** |
|
102 * From MVIMPSTStorageServiceView |
|
103 */ |
|
104 MVIMPSTStorageContactList* FindContactList( const TDesC& aListId ) ; |
|
105 |
|
106 |
|
107 /** |
|
108 * From MVIMPSTStorageServiceView |
|
109 */ |
|
110 MVIMPSTStorageContactList* CreateContactListL( const TDesC& aContactListId, |
|
111 const TDesC& aDisplayName ) ; |
|
112 |
|
113 |
|
114 /** |
|
115 * From MVIMPSTStorageServiceView |
|
116 */ |
|
117 void RemoveContactList( const TDesC& aContactListId ) ; |
|
118 |
|
119 |
|
120 |
|
121 /** |
|
122 * From MVIMPSTStorageServiceView |
|
123 */ |
|
124 TInt ContactCount( TBool aSkipOfflineContacts = EFalse ) const ; |
|
125 |
|
126 |
|
127 /** |
|
128 * Update presence information of contact. |
|
129 * @param aContactId Id of contact which presence is updated. |
|
130 * @param aStatus. New presence status |
|
131 * @param aAlias. New alias. |
|
132 * @param aStatusText New status message text. |
|
133 * @return MVIMPSTStorageContact* pointer of the contact |
|
134 */ |
|
135 MVIMPSTStorageContact* UpdatePresenceL(const TDesC& aContactId, |
|
136 TVIMPSTEnums::TOnlineStatus aStatus, |
|
137 const TDesC& aStatusText, |
|
138 const TDesC8& aAvatarData, |
|
139 TBool aIsClearingAvatar = EFalse) ; |
|
140 |
|
141 /** |
|
142 * Update presence information of contact. |
|
143 * @param aContactId Id of contact which presence is updated. |
|
144 * @param aStatus. New presence status |
|
145 * @param aAlias. New alias. |
|
146 * @param aStatusText New status message text. |
|
147 * @return MVIMPSTStorageContact* pointer of the contact |
|
148 */ |
|
149 MVIMPSTStorageContact* UpdateAvatarL(const TDesC& aContactId, |
|
150 const TDesC8& aAvatarData ) ; |
|
151 |
|
152 /** |
|
153 * add contact ot the virtual phonebook. |
|
154 * @param aContact contact id to be added. |
|
155 */ |
|
156 MVIMPSTStorageContact* CreateNewContactL(const TDesC& aUserId, |
|
157 const TDesC& aDisplayName = KNullDesC, |
|
158 TBool aIsInvitationItem = EFalse, |
|
159 TBool aInvitationAutoAccept = EFalse) ; |
|
160 |
|
161 /** |
|
162 * add contact ot the virtual phonebook. |
|
163 * @param aContact contact id to be added. |
|
164 */ |
|
165 TInt CreateNewContactFromRetrivedIdL( TInt aIndexToUse ); |
|
166 |
|
167 /** |
|
168 * remove contact ot the virtual phonebook. |
|
169 * @param aContact contact id to be removed. |
|
170 */ |
|
171 TInt DeleteNewContactFromRetrivedIdL( TInt aIndexToUse ); |
|
172 |
|
173 /** |
|
174 * add contact ot the virtual phonebook. |
|
175 * @param aContact contact id to be added. |
|
176 */ |
|
177 void CreateNewFetchContactsL( RArray <TPtrC> &aFirstNameList, |
|
178 RArray <TPtrC> &aServiceField ) ; |
|
179 |
|
180 |
|
181 /** |
|
182 * add contact ot the virtual phonebook. |
|
183 * @param aContact contact id to be added. |
|
184 */ |
|
185 TInt RemoveContactL( MVIMPSTStorageContact* aContact ) ; |
|
186 |
|
187 |
|
188 /** |
|
189 * From MVIMPSTStorageServiceView |
|
190 */ |
|
191 TBool IsLocalStore() const ; |
|
192 |
|
193 /** |
|
194 * From MVIMPSTStorageServiceView |
|
195 */ |
|
196 void SetOwnUserIdL( const TDesC& aUserId ); |
|
197 |
|
198 |
|
199 /** |
|
200 * From MVIMPSTStorageServiceView |
|
201 */ |
|
202 TInt RetriveLinkXSPIdsL(const TDesC8& aContactPackLink ); |
|
203 |
|
204 /** |
|
205 * From MVIMPSTStorageServiceView |
|
206 */ |
|
207 const TDesC& GetRetrieveXSPIdL(TInt aIndex ) ; |
|
208 |
|
209 /** |
|
210 * From MVIMPSTStorageServiceView |
|
211 */ |
|
212 MVIMPSTStorageContact& OwnContactL(); |
|
213 |
|
214 /** |
|
215 * From MVIMPSTStorageServiceView |
|
216 */ |
|
217 void DeleteDatabaseL(); |
|
218 |
|
219 /** |
|
220 * From MVIMPSTStorageServiceView |
|
221 */ |
|
222 void SetUnnamedTextL(HBufC* aUnnamedText ); |
|
223 |
|
224 public: // MVIMPSTStorageServiceCacheWriter |
|
225 |
|
226 /** |
|
227 * update existing contact |
|
228 * @param aContactLink contact id to be updatated |
|
229 * @param aUserId contact id to be updated |
|
230 * @param aDisplayName contact display name to be updated |
|
231 * @reurn the storage contact pointer if found else NULL |
|
232 */ |
|
233 MVIMPSTStorageContact* UpdateCacheContactL(const MVPbkContactLink& aContactLink, |
|
234 const TDesC& aUserId, |
|
235 const TDesC& aDisplayName, |
|
236 const TDesC8& aAvatarContent ) ; |
|
237 |
|
238 /** |
|
239 * add a new contact to cache |
|
240 * @param aContactLink contact id to be add |
|
241 * @param aUserId contact id to be add |
|
242 * @param aDisplayName contact display name to be add |
|
243 * @reurn the new storage contact pointer if contact is already exist return the smae |
|
244 |
|
245 */ |
|
246 MVIMPSTStorageContact* AddContactToCacheL(const MVPbkContactLink& aContactLink, |
|
247 const TDesC& aUserId, |
|
248 const TDesC& aDisplayName, |
|
249 const TDesC8& aAvatarContent, |
|
250 TVIMPSTEnums::TVIMPSTStorgaeEventType aType ) ; |
|
251 |
|
252 /* |
|
253 * remopve existing contact |
|
254 * @param aContactLink contact id to be removed |
|
255 * @param aUserId contact id to be removed |
|
256 * @param aDisplayName contact display name to be removed |
|
257 * @reurn the error if any |
|
258 */ |
|
259 TInt RemoveContactFromCacheL(const MVPbkContactLink& aContactLink,TVIMPSTEnums::TVIMPSTStorgaeEventType aType ) ; |
|
260 |
|
261 |
|
262 /** |
|
263 * Removes all contacts from cache and notify to observers |
|
264 */ |
|
265 void RemoveAllCacheContactsL() ; |
|
266 |
|
267 /** |
|
268 * Read the default contact list if exist else create default list |
|
269 * @return contact list pointer |
|
270 */ |
|
271 MVIMPSTStorageContactList* GetDefaultContactListL() ; |
|
272 |
|
273 /** |
|
274 * find contact by user id |
|
275 * @param aUserId contact id to be find |
|
276 * @return storage contact pointer if found else NULL |
|
277 */ |
|
278 MVIMPSTStorageContact* FindCacheContactByUserId( const TDesC& aUserId ) ; |
|
279 |
|
280 |
|
281 /** |
|
282 * find contact by user id |
|
283 * @param aContactLink contact link to be find |
|
284 * @return storage contact pointer if found else NULL |
|
285 */ |
|
286 MVIMPSTStorageContact* FindCacheContactByLink(const MVPbkContactLink& aContactLink) ; |
|
287 |
|
288 /** |
|
289 * add contact to the contact cache and notify the observers |
|
290 * @param aContact contact id to be added. |
|
291 */ |
|
292 TInt AddStorageContactToCacheL(MVIMPSTStorageContact* aContactToAdd ); |
|
293 |
|
294 /** |
|
295 * add contact to the contact cache and notify the observers |
|
296 * @param aContact contact id to be added. |
|
297 */ |
|
298 void NotifyServiceViewL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType, |
|
299 MVIMPSTStorageContact* aContact = NULL ) ; |
|
300 |
|
301 public : //MVIMPSTStorageActiveObserver |
|
302 |
|
303 /** |
|
304 * This call is made when the waiting completes |
|
305 * @param aError error code for waiting error, KErrNone if completes without error |
|
306 * |
|
307 */ |
|
308 void HandleDelayedNotificationL(TVIMPSTEnums::TVIMPSTStorgaeEventType aType, |
|
309 MVIMPSTStorageContactList *aList, |
|
310 MVIMPSTStorageContact* aContact, |
|
311 TInt aContactIndex) ; |
|
312 private: |
|
313 |
|
314 |
|
315 /** |
|
316 * C++ default constructor. |
|
317 */ |
|
318 CVIMPSTStorageServiceView(TUint32 aServiceId); |
|
319 |
|
320 /** |
|
321 * By default Symbian 2nd phase constructor is private. |
|
322 */ |
|
323 void ConstructL(const TDesC& aStoreName, const TDesC& aServiceName); |
|
324 |
|
325 |
|
326 CVIMPSTStorageContactList* FindContactListInternal( const TDesC& aListId ); |
|
327 |
|
328 |
|
329 TInt FindContactListById(const TDesC& aListId ); |
|
330 |
|
331 // TLinearOrder |
|
332 static TInt ContactListOrderByDisplayName( |
|
333 const CVIMPSTStorageContactList& aContactA, |
|
334 const CVIMPSTStorageContactList& aContactB ); |
|
335 |
|
336 static TBool ContactListFindByContactListId( |
|
337 const CVIMPSTStorageContactList& aContactA, |
|
338 const CVIMPSTStorageContactList& aContactB ); |
|
339 |
|
340 |
|
341 /** |
|
342 * Notify all the observers about the given event |
|
343 * @param aType The type of observer event |
|
344 * @param aContact The contact in question |
|
345 * (or -1 == KCAStorageDontKnowPos to force search for given contact id |
|
346 * in aParameter) |
|
347 * @param aFromPEC, ETrue, if event is coming from PEC |
|
348 */ |
|
349 void NotifyAllObserversL( TVIMPSTEnums::TVIMPSTStorgaeEventType aType, |
|
350 MVIMPSTStorageContactList* aContactList, |
|
351 MVIMPSTStorageContact* aContact, |
|
352 TInt aContactIndex ); |
|
353 |
|
354 /** |
|
355 * Notify all the observer about the given event after small delay |
|
356 * If new notify events come during delay, then notify is "shifted" |
|
357 * with new delay time and notify event is change to "multiplechanges". |
|
358 * @param aType The type of observer event |
|
359 * @param aContact The contact in question |
|
360 * (or -1 == KCAStorageDontKnowPos to force search for given contact id |
|
361 * in aParameter) |
|
362 * @param aFromPEC, ETrue, if event is coming from PEC |
|
363 */ |
|
364 void NotifyAllObserversWithDelay( TVIMPSTEnums::TVIMPSTStorgaeEventType aType, |
|
365 MVIMPSTStorageContactList* aContactList, |
|
366 MVIMPSTStorageContact* aContact, |
|
367 TInt aContactIndex ); |
|
368 |
|
369 |
|
370 public : // from MVIMPSTStorageItemModel |
|
371 |
|
372 /** |
|
373 * @return Count of items |
|
374 */ |
|
375 TInt Count() const; |
|
376 |
|
377 /** |
|
378 * Returns List item at given index. |
|
379 * @param aIndex |
|
380 * @return List item |
|
381 */ |
|
382 MVIMPSTStorageItemModel::SItem Item( TInt aIndex ) const; |
|
383 |
|
384 /** |
|
385 * @see MVIMPSTStorageItemModel |
|
386 */ |
|
387 TInt IndexOfContact( MVIMPSTStorageContact* aContact ) const; |
|
388 |
|
389 /** |
|
390 * @see MVIMPSTStorageItemModel |
|
391 */ |
|
392 TInt IndexOfList( MVIMPSTStorageContactList* aList, |
|
393 TBool aIgnoreOwnItem /*= EFalse*/, |
|
394 TBool aIgnoreEmptyLists /*= ETrue*/ ) const; |
|
395 |
|
396 public : |
|
397 |
|
398 /** |
|
399 * Sets the correct sorting method to storage |
|
400 * according to current setting value |
|
401 */ |
|
402 void SetSort(); |
|
403 |
|
404 /** |
|
405 * sort the contacts of list |
|
406 * according to current setting value |
|
407 */ |
|
408 void Sort( const TDesC& aContactListId = KNullDesC ); |
|
409 |
|
410 |
|
411 protected: // Functions from MDesCArray |
|
412 |
|
413 /** |
|
414 * @see MDesCArray |
|
415 */ |
|
416 TInt MdcaCount() const; |
|
417 |
|
418 /** |
|
419 * @see MDesCArray |
|
420 */ |
|
421 TPtrC MdcaPoint(TInt aIndex) const; |
|
422 |
|
423 private: // Data |
|
424 |
|
425 // observers list, used with MVIMPSTStorageServiceView inherited methods |
|
426 RPointerArray< MVIMPSTStorageContactsObserver > iContactObservers; |
|
427 |
|
428 // list of contacts |
|
429 RPointerArray< CVIMPSTStorageContactList > iContactListArray; // owns |
|
430 |
|
431 //Service ID |
|
432 TUint32 iServiceId; |
|
433 // owns : pointer to service store ,Local/Server |
|
434 MVIMPSTStorageVPbkContactStore* iVPbkContactStore; |
|
435 |
|
436 /// Sorter for contacts. Owns |
|
437 CVIMPSTStorageContactSorter* iContactSorter; |
|
438 |
|
439 /// Contact for own data |
|
440 MVIMPSTStorageContact* iOwnContact; |
|
441 /// Owns : refreshTimer |
|
442 CVIMPSTStorageActiveHandler* iActiveHandler; |
|
443 |
|
444 // if ETrue meaning a invitation is getting added to cache |
|
445 TBool iIsInvitationItem; |
|
446 |
|
447 // owns : unnamed text |
|
448 HBufC* iUnNamedText; |
|
449 |
|
450 }; |
|
451 |
|
452 #endif // CVIMPSTSTORAGESERVICEVIEW_H |
|
453 |
|
454 // End of File |