|
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: Array Process |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _CVIMPSTPROCESSARRAY_H |
|
20 #define _CVIMPSTPROCESSARRAY_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include "mvimpstcmdhandler.h" |
|
25 #include "vimpstcmd.hrh" |
|
26 #include "mvimpststoragecontactsobserver.h" |
|
27 #include "mvimpstprocessarray.h" |
|
28 #include "tvimpstenums.h" |
|
29 #include "mvimpstengineimsubserviceeventobserver.h" |
|
30 #include "mvimpstenginepresencesubserviceeventobserver.h" |
|
31 #include <MVPbkStoreContact.h> |
|
32 |
|
33 // FORWARD DECLARATION |
|
34 class MVIMPSTProcessArrayItem; |
|
35 class MVIMPSTStorageContact; |
|
36 class MVIMPSTStorageContactList; |
|
37 class MVIMPSTStorageServiceView; |
|
38 class MVIMPSTProcessArrayObserver; |
|
39 class MVIMPSTStorageItemModel; |
|
40 class MVPbkContactLink; |
|
41 class MVPbkStoreContact; |
|
42 class MVIMPSTEngine; |
|
43 class CVIMPSTProcessFriendRequestItem; |
|
44 class CVIMPSTProcessUnknownContactItem; |
|
45 |
|
46 // CLASS DECLARATION |
|
47 |
|
48 /** |
|
49 * Array Process. |
|
50 * Responsible for handling all contacts array |
|
51 * @lib vimpstcmdprocess.dll |
|
52 * @since 5.0 |
|
53 */ |
|
54 class CVIMPSTProcessArray : public CBase, |
|
55 public MVIMPSTProcessArray, |
|
56 public MVIMPSTStorageContactsObserver, |
|
57 public MVIMPSTEngineIMSubServiceEventObserver, |
|
58 public MVIMPSTEnginePresenceSubServiceEventObserver |
|
59 { |
|
60 friend class Cvimpstcmdprocess_utest; |
|
61 public: // Construction and destruction |
|
62 |
|
63 /** |
|
64 * Creates a new instance of this class. |
|
65 * @param aEngine, reference to engine. |
|
66 * @return A new instance of this class. |
|
67 */ |
|
68 static CVIMPSTProcessArray* NewL( |
|
69 MVIMPSTEngine& aEngine); |
|
70 |
|
71 /** |
|
72 * Destructor. |
|
73 */ |
|
74 ~CVIMPSTProcessArray(); |
|
75 |
|
76 public: //form mvimpstchatobserver |
|
77 /** |
|
78 * @see MVIMPSTEngineIMSubServiceEventObserver.h |
|
79 **/ |
|
80 void HandleChatMessageEventL(TVIMPSTEnums::TIMEventType aEventType ,const TDesC& aSender ); |
|
81 |
|
82 |
|
83 public: |
|
84 /** |
|
85 * Observer Event for new add request |
|
86 * aRequester - requester for add request. |
|
87 */ |
|
88 void HandleAddRequestEventL(TVIMPSTEnums::TOperationType aType, const TDesC& aRequesterId, |
|
89 const TDesC& aRequestorDisplayName ); |
|
90 |
|
91 |
|
92 public : //from MVIMPSTProcessArray |
|
93 /** |
|
94 * register for array call back |
|
95 * @param aObserver: to be added |
|
96 */ |
|
97 void AddObserver(MVIMPSTProcessArrayObserver* aObserver) ; |
|
98 |
|
99 /** |
|
100 * unregister for array call back |
|
101 * @param aObserver: to be removed |
|
102 */ |
|
103 void RemoveObserver() ; |
|
104 |
|
105 /** |
|
106 * Count: Called by UI components to get total count of array |
|
107 * @return integer Count of array |
|
108 */ |
|
109 virtual TInt Count() const; |
|
110 |
|
111 /** |
|
112 * @return ETrue if presence service is enabled |
|
113 */ |
|
114 TBool IsSubServiceSupportedL( TVIMPSTEnums::SubServiceType aType ) const ; |
|
115 |
|
116 /** |
|
117 * @return, ETrue if IM is supported |
|
118 */ |
|
119 TBool IsIMSupported(); |
|
120 |
|
121 /** |
|
122 * @return, ETrue if Presence is supported |
|
123 */ |
|
124 TBool IsPresenceSupported(); |
|
125 |
|
126 /** |
|
127 * GetType: Function to get the type of list item |
|
128 * @param aIndex: index of the list item |
|
129 * @return TEnumsPC::TItem: type of the list item as EContactItem, EOwnStatusItem etc |
|
130 */ |
|
131 virtual TVIMPSTEnums::TItem GetType(TInt aIndex) const; |
|
132 |
|
133 /** |
|
134 * ResetArray: Function to reset and fill the array |
|
135 */ |
|
136 void ResetArray(); |
|
137 |
|
138 /** |
|
139 * GetItemNameText: To get item name of each list item |
|
140 * @param aIndex: Index of the list item whose name is to be returned |
|
141 * @return TPtrC: Name of the list item |
|
142 */ |
|
143 virtual TPtrC GetItemNameText(TInt aIndex); |
|
144 |
|
145 |
|
146 /** |
|
147 * SetLoginState: To set the loginstate. |
|
148 * @param aLoginState: state of login |
|
149 */ |
|
150 virtual void SetLoginStateL(TVIMPSTEnums::TVIMPSTRegistrationState aLoginState); |
|
151 |
|
152 |
|
153 /** |
|
154 * GetLoginState: To set the loginstate. |
|
155 * @return TVIMPSTRegistrationState, state of login |
|
156 */ |
|
157 virtual TVIMPSTEnums::TVIMPSTRegistrationState GetLoginState(); |
|
158 |
|
159 /** |
|
160 * @returns the VPBK Contact Link |
|
161 */ |
|
162 MVPbkContactLink* ContactLink(TInt aIndex); |
|
163 |
|
164 |
|
165 /** |
|
166 * GetOnlineStatusL gets the status of given index. |
|
167 * @param aIndex: Index of the item |
|
168 * @returns the onlinestatus of given valid index. |
|
169 */ |
|
170 TVIMPSTEnums::TOnlineStatus GetOnlineStatusL(TInt aIndex); |
|
171 |
|
172 /** |
|
173 * Get the status text for the contact |
|
174 * @param aIndex: Index of contact item |
|
175 * @return reference to the status text. |
|
176 */ |
|
177 const TDesC& StatusTextL(TInt aIndex ) ; |
|
178 |
|
179 /** |
|
180 * From MVIMPSTProcessArray |
|
181 * |
|
182 */ |
|
183 void MapContactListPositions(RArray<TInt>& aPositionArray ); |
|
184 /** |
|
185 * IsMsgPending: To find if there are any pending messages to |
|
186 * decide the icons for display |
|
187 * @param aIndex: index of the list item |
|
188 * @return bool: True if there are pending messages else false. |
|
189 */ |
|
190 TBool IsMsgPending(TInt aIndex); |
|
191 |
|
192 /** |
|
193 * ResetPendingMsg: To reset if there are any pending messages to |
|
194 * decide the icons for display |
|
195 * @param aIndex: index of the list item |
|
196 */ |
|
197 void ResetPendingMsg(TInt aIndex); |
|
198 |
|
199 |
|
200 /** |
|
201 * Find any contact which id is aContactId |
|
202 * @param aContactId, user id. |
|
203 * @return ETrue if contact already existst.else EFlase. |
|
204 */ |
|
205 TBool FindAnyContact( const TDesC& aContactId ); |
|
206 |
|
207 /** |
|
208 * Find any contact which id is aContactId |
|
209 * @param aContactId, user id. |
|
210 * @return ETrue if contact already existst.else EFlase. |
|
211 */ |
|
212 TBool FindAnyContactServiceField( const TDesC& aContactId ); |
|
213 /** |
|
214 * Find any friend request which id is aRequesterId |
|
215 * @param aRequesterId, user id. |
|
216 * @return ETrue if request already existst.else EFlase. |
|
217 */ |
|
218 TBool FindAnyAddRequest( const TDesC& aRequesterId ); |
|
219 |
|
220 /** |
|
221 * @param aRequesterId, user id. |
|
222 * @return ETrue if request already existst.else EFlase. |
|
223 */ |
|
224 TBool IsContactBlocked( const TDesC& aRequesterId ); |
|
225 |
|
226 /** |
|
227 * check if already conversation opened |
|
228 * @param aRecipientId, the selected user id with whom conversation is started |
|
229 * @return ETrue if already exist else EFlase. |
|
230 */ |
|
231 TBool IsConversationExistL(const TDesC& aRecipientId) ; |
|
232 /** |
|
233 * check if already conversation opened |
|
234 * @param aRecipientId, the selected user id with whom conversation is started |
|
235 * @return ETrue if already exist else EFlase. |
|
236 */ |
|
237 TBool IsConversationExist(TInt aIndex); |
|
238 |
|
239 /** |
|
240 * Find the index of contact with contact id as aContactId |
|
241 * @param aContactId : id of contact whose index is to be found |
|
242 * @return index of contact else KErrNotFounf if not found |
|
243 */ |
|
244 TInt FindContactIndexL( const TDesC& aContactId ) ; |
|
245 |
|
246 /** |
|
247 * GetItemNameText: To get item name of each list item |
|
248 * @param aIndex, Index of the list item whose name is to be returned |
|
249 * @return TPtrC, Name of the list item |
|
250 */ |
|
251 TPtrC GetItemUserId(TInt aIndex); |
|
252 /** |
|
253 * RemoveFriendRequest: To remove friend request from list. |
|
254 * @param aIndex, Index of the list item to be removed. |
|
255 */ |
|
256 void RemoveFriendRequestL(const TDesC& aRequesterId); |
|
257 /** |
|
258 * Login user name of the own user from settings |
|
259 * owener ship is transferred to the caller |
|
260 * @return allocated HBufC: Login user name of the own user from settings |
|
261 */ |
|
262 const TDesC& LoginUserIdFromStoreL() const; |
|
263 |
|
264 /** |
|
265 * OwnAvatarIndex: Returns the avatar index for the corresponding contact item |
|
266 * This index is used to append the avatar in the UI. |
|
267 * If index is ' 0 ', then it means no avatar is set. |
|
268 * |
|
269 * @return index of the own avatar |
|
270 */ |
|
271 TInt OwnAvatarIndexL( ) ; |
|
272 /** |
|
273 * OwnAvatarContent: Returns the mime type of the avatar image for the conatct |
|
274 * |
|
275 * If nothing returns KNullDesC8 |
|
276 * @return TDesC8& own avatar content |
|
277 */ |
|
278 const TDesC8& OwnAvatarContentL( ) const ; |
|
279 |
|
280 /** |
|
281 * SetOwnAvatarIndex: Sets the index for own avatar contact item |
|
282 * @param aAvatarIndex: Index to be set |
|
283 */ |
|
284 void SetOwnAvatarIndexL( TInt aAvatarIndex ); |
|
285 |
|
286 /** |
|
287 * AvatarMimeType: Returns the mime type of the avatar image for the conatct |
|
288 * |
|
289 * If nothing returns KNullDesC8 |
|
290 * @param aContactIndex : Index of the conatct item |
|
291 * |
|
292 * @return TDesC8& mime type of the avatar |
|
293 */ |
|
294 const TDesC8& AvatarContent(TInt aContactIndex) ; |
|
295 |
|
296 /** |
|
297 * SetAvatarIndex: Sets the index for avatar for for the corresponding contact item |
|
298 * |
|
299 * @param aContactIndex : Index of the conatct item |
|
300 * @param aAvatarIndex: Index to be set |
|
301 */ |
|
302 void SetAvatarIndex( TInt aContactIndex, TInt aAvatarIndex ); |
|
303 |
|
304 /** |
|
305 * AvatarIndex: Returns the avatar index for the corresponding contact item |
|
306 * This index is used to append the avatar in the UI. |
|
307 * If index is ' 0 ', then it means no avatar is set. |
|
308 * |
|
309 * @param aContactIndex : Index of the conatct item |
|
310 * |
|
311 * @return index of the own avatar |
|
312 */ |
|
313 TInt AvatarIndex(TInt aContactIndex) ; |
|
314 |
|
315 /** |
|
316 * from MVIMPSTProcessArray |
|
317 * Return index of aContactId (considering friend request also.). |
|
318 * @param aContactId, contact id for which index to be found. |
|
319 * @return, Index of aContactId including friend request. |
|
320 */ |
|
321 TInt GetSelectedItemIndex(const TDesC& aContactId); |
|
322 |
|
323 /* |
|
324 * find and return the array item |
|
325 */ |
|
326 MVIMPSTProcessArrayItem* FindArrayItem( const TDesC& aSenderId ); |
|
327 |
|
328 /* |
|
329 * reset all pending and open flags to EFalse |
|
330 */ |
|
331 void ResetOpenConversationPendingMsg(); |
|
332 |
|
333 /* |
|
334 * @aIndex, index for the listbox item whose descriptor is needed |
|
335 * @return, the descriptor for the array item to be used by listbox |
|
336 */ |
|
337 TPtrC16 GetFormattedString(TInt aIndex); |
|
338 |
|
339 |
|
340 public: // From MVIMPSTStorageContactsObserver |
|
341 |
|
342 |
|
343 /** |
|
344 * HandleChange: To handle the Chnage event from the MCAStoredContactsObserver |
|
345 * @see MCAStoredContactsObserver |
|
346 * @param aList: reference to the list at which a change has occured |
|
347 * @param aContact: reference to the contact at which a change has occured |
|
348 * @param aEventType: TVIMPSTEnums::TCAObserverEventType,type of change event that has occured |
|
349 * @param aUserIdChanged, ETrue if userid has changed, else EFalse. |
|
350 * @return void |
|
351 */ |
|
352 void HandleStorageChangeL( TVIMPSTEnums::TVIMPSTStorgaeEventType aEventType, |
|
353 MVIMPSTStorageContactList* aList, |
|
354 MVIMPSTStorageContact* aContact, |
|
355 TInt aContactIndex ); |
|
356 |
|
357 |
|
358 private: // Implementation |
|
359 |
|
360 /** |
|
361 * Default constructor |
|
362 * @param aEngine, reference to engine. |
|
363 */ |
|
364 |
|
365 CVIMPSTProcessArray( MVIMPSTEngine& aEngine ); |
|
366 |
|
367 /** |
|
368 * Second phase constructor |
|
369 */ |
|
370 void ConstructL(); |
|
371 |
|
372 /** |
|
373 * FillItemL: fill up the individual item in the array |
|
374 * @return void |
|
375 **/ |
|
376 void FillItemL(); |
|
377 /** |
|
378 * FillOwnDataL: fill up fill the owndata item |
|
379 * @return void |
|
380 **/ |
|
381 TBool FillOwnDataL(); |
|
382 |
|
383 /** |
|
384 * FillArray: fill up the complete array |
|
385 * @return void |
|
386 **/ |
|
387 void FillArrayL(); |
|
388 |
|
389 /** |
|
390 * fill the unknown contact to main array |
|
391 * @return void |
|
392 **/ |
|
393 void FillUnknownContactsL(); |
|
394 /** |
|
395 * FillAddRequestDataL: fill up the add request to array |
|
396 * @return void |
|
397 **/ |
|
398 void FillAddRequestDataL(); |
|
399 |
|
400 /** |
|
401 * remove all the unknown contacts from main array iItemArray, |
|
402 * so that unknown contact can pesist till the session is entertainesd. |
|
403 * @return void |
|
404 **/ |
|
405 void RemoveUnKnownContacts(); |
|
406 /** |
|
407 * RemoveAddRequestData: removes data from iItemArray, |
|
408 * so that request can pesist till the reqest is entertainesd. |
|
409 * @return void |
|
410 **/ |
|
411 void RemoveAddRequestData(); |
|
412 |
|
413 /** |
|
414 * handlle the message which is from unknown buddy |
|
415 * @param aSenderId , Sender Id |
|
416 * @return void |
|
417 **/ |
|
418 void DoHandleUnKnownContactMessageL( const TDesC& aSenderId ,TBool aIsMsgPending); |
|
419 |
|
420 /** |
|
421 * get the all open chat and append unknown contacts |
|
422 * @return void |
|
423 **/ |
|
424 void GetAndCreateOpenChatListL(); |
|
425 |
|
426 /** |
|
427 * remove the item from invitation or unknown array if found |
|
428 * @param aContactId : conatct user Id |
|
429 * @return ETrue if contact is removed |
|
430 */ |
|
431 TBool RemoveFromUnknonOrInvitationListL( const TDesC& aContactId , TBool aBlocked ) ; |
|
432 /** |
|
433 * play the incoming message tone. |
|
434 */ |
|
435 void PlayMsgBeepL(); |
|
436 |
|
437 /** |
|
438 * @return ETrue if unread message exist |
|
439 */ |
|
440 TBool IsUnreadMessageExistsL(const TDesC& aRecipientId); |
|
441 /** |
|
442 * helper method for removing unknown contacts |
|
443 * @return ETrue if contact is removed |
|
444 */ |
|
445 TBool RemoveFromUnknonListL( const TDesC& aAddedUserId ); |
|
446 /** |
|
447 * helper method for removing invitation contacts |
|
448 * @return ETrue if contact is removed |
|
449 */ |
|
450 TBool RemoveFromInvitationListL( const TDesC& aAddedUserId ); |
|
451 /** |
|
452 * helper method for finding and marking as open chat |
|
453 * @return ETrue if contact is find |
|
454 */ |
|
455 TBool FindAndMarkContactAsOpenChat( const TDesC& aContactId, TBool aMesssagePending ); |
|
456 |
|
457 private: // Data |
|
458 |
|
459 /** |
|
460 * starting index of Owndata , it's 0 as per ui spec |
|
461 **/ |
|
462 TInt iOwnDataIndex; |
|
463 |
|
464 /** |
|
465 * starting index of contacts , it's 0 as per ui spec |
|
466 **/ |
|
467 TInt iContactListIndex; |
|
468 |
|
469 //Ref to the engine item for current service |
|
470 MVIMPSTEngine& iEngine; |
|
471 |
|
472 /** |
|
473 * Flag to check whether own data added or not |
|
474 **/ |
|
475 TBool iOwnDataAdded; |
|
476 |
|
477 /** |
|
478 * Owns. Buffer that hold's information about fetched item |
|
479 **/ |
|
480 HBufC* iData; |
|
481 |
|
482 |
|
483 /** |
|
484 * reference to the contact list interface |
|
485 **/ |
|
486 MVIMPSTStorageServiceView* iContactInterface; |
|
487 |
|
488 // owned : take RPointerArray if nedded |
|
489 MVIMPSTProcessArrayObserver* iProcessObservers; |
|
490 |
|
491 /** |
|
492 * list of items here |
|
493 **/ |
|
494 RPointerArray<MVIMPSTProcessArrayItem> iItemArray; |
|
495 |
|
496 |
|
497 /** |
|
498 * reference to the contact list model |
|
499 * not owned. |
|
500 **/ |
|
501 MVIMPSTStorageItemModel* iContactListModel; |
|
502 |
|
503 //service id |
|
504 TUint32 iServiceId; |
|
505 |
|
506 TVIMPSTEnums::TVIMPSTRegistrationState iLoginState; |
|
507 |
|
508 /** |
|
509 * reference list of friend request items here |
|
510 **/ |
|
511 RPointerArray<CVIMPSTProcessFriendRequestItem> iAddRequestArray; |
|
512 |
|
513 /** |
|
514 * reference list of friend request items here |
|
515 **/ |
|
516 RPointerArray<CVIMPSTProcessUnknownContactItem> iUnKnownContactArray; |
|
517 |
|
518 // ETrue if fetch completed |
|
519 TBool iFetchCompleted; |
|
520 |
|
521 // ETrue if engine supports IM subservice |
|
522 TBool iIMSupported; |
|
523 |
|
524 // ETrue if engine supports Presence subservice |
|
525 TBool iPresenceSupported; |
|
526 |
|
527 }; |
|
528 |
|
529 #endif // _CVIMPSTPROCESSARRAY_H |
|
530 |
|
531 // End of File |