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 handling connection to precense framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CVIMPSTENGINEPRESENCESUBSERVICE_H |
|
20 #define CVIMPSTENGINEPRESENCESUBSERVICE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <presencecachereadhandler2.h> // handling the presence cache events |
|
25 #include <mpresencebuddyinfo2.h> // buddy info class |
|
26 #include <presenceinfo.h> //Presence info test |
|
27 |
|
28 #include "mvimpstenginesubservice.h" |
|
29 #include "mvimpstenginepresencesubservice.h" |
|
30 #include "mvimpstenginecchhandlerobserver.h" |
|
31 #include "mvimpstenginesessioncntxtobserver.h" |
|
32 #include "tvimpstenums.h" |
|
33 #include "cvimpstengineimagehandler.h" |
|
34 //FORWARD DECLARATIONS |
|
35 class CVIMPSTEngineServiceTableFetcher; |
|
36 class CVIMPSTEngineCchHandler; |
|
37 class CVIMPSTEngineSessionCntxtObserver; |
|
38 class MPresenceCacheReader2; |
|
39 class CIMCacheFactory; |
|
40 class MIMCacheUpdater; |
|
41 class MPresentityGroupContentEvent; |
|
42 class CVIMPSTBlockedListManager; |
|
43 class MVIMPSTEngineServiceConnectionEventObserver; |
|
44 |
|
45 // CLASS DECLARATION |
|
46 /** |
|
47 * Presence sub service |
|
48 * This class implements the presence subservice |
|
49 * The problem in VOIP case would be that this "sip" must be hardcoded. Can this be avoided |
|
50 * |
|
51 * |
|
52 * The Presence Information can be fetched either thro PresenceCache or |
|
53 * thro XIMP's MPresentityPresenceEvent. So somehow we should be able to differentiate |
|
54 * which service uses PresenceCache or XIMP's MPresentityPresenceEvent during the creation of this object |
|
55 * One of the proposal could be is to use the CCH, if it could provide us this information or SP Settings |
|
56 * |
|
57 * All the Block/Friend Request/Presence information of a contact should be passed |
|
58 * to the VIMPSTStorage which will update the list on the UI. |
|
59 * |
|
60 */ |
|
61 |
|
62 |
|
63 NONSHARABLE_CLASS( CVIMPSTEnginePresenceSubService ): public CBase, |
|
64 public MVIMPSTEnginePresenceSubService, |
|
65 public MPresenceCacheReadHandler2, |
|
66 public MVIMPSTEngineCchHandlerObserver, |
|
67 public MVIMPSTEngineSessionCntxtObserver |
|
68 { |
|
69 //for testcases |
|
70 friend class T_VimpstEnginePresenceSubService; |
|
71 |
|
72 public: |
|
73 |
|
74 /** |
|
75 * Two-phased constructor. |
|
76 * |
|
77 * @since s60 5.0 |
|
78 * @param aServiceId, service id |
|
79 * @param aCchHandler, reference to cchhandler. |
|
80 * @param aTableFetcher, reference to settingstable. |
|
81 * @param aXimpEventObserver, reference to ximpevent observer. |
|
82 * @param aServiceStateListener, reference to servicestatelistener. |
|
83 */ |
|
84 static CVIMPSTEnginePresenceSubService* NewL( TUint32 aServiceId, |
|
85 CVIMPSTEngineCchHandler& aCchHandler, |
|
86 CVIMPSTEngineServiceTableFetcher& aTableFetcher, |
|
87 CVIMPSTEngineSessionCntxtObserver& aXimpEventObserver, |
|
88 MVIMPSTEngineServiceConnectionEventObserver& aObserver); |
|
89 |
|
90 /** |
|
91 * Two-phased constructor. |
|
92 * |
|
93 * @since s60 5.0 |
|
94 * @param aServiceId, service id |
|
95 * @param aCchHandler, reference to cchhandler. |
|
96 * @param aTableFetcher, reference to settingstable. |
|
97 * @param aXimpEventObserver, reference to ximpevent observer. |
|
98 * @param aServiceStateListener, reference to servicestatelistener. |
|
99 */ |
|
100 static CVIMPSTEnginePresenceSubService* NewLC(TUint32 aServiceId, |
|
101 CVIMPSTEngineCchHandler& aCchHandler, |
|
102 CVIMPSTEngineServiceTableFetcher& aTableFetcher, |
|
103 CVIMPSTEngineSessionCntxtObserver& aXimpEventObserver, |
|
104 MVIMPSTEngineServiceConnectionEventObserver& aObserver); |
|
105 |
|
106 /** |
|
107 * Standard C++ destructor |
|
108 */ |
|
109 ~CVIMPSTEnginePresenceSubService(); |
|
110 |
|
111 public: //From MVIMPSTSubService |
|
112 |
|
113 /** |
|
114 * @return TVIMPSTRegistrationState Service State of this service |
|
115 */ |
|
116 TVIMPSTEnums::TVIMPSTRegistrationState SubServiceState() const; |
|
117 |
|
118 |
|
119 TVIMPSTEnums::SubServiceType Type() const; |
|
120 |
|
121 |
|
122 /** |
|
123 * @see MVIMPSTSubService |
|
124 */ |
|
125 TBool Enabled(); |
|
126 |
|
127 /** |
|
128 * Set the blocked list manager. |
|
129 @param aBlockedListMgr blocked list instance pointer. |
|
130 */ |
|
131 void SetBlockedListManager(CVIMPSTBlockedListManager* aBlockedListMgr); |
|
132 |
|
133 //Reset the blocked list to zero blocked contact |
|
134 void ResetBlockedListManagerL(); |
|
135 public: //From MVIMPSTEnginePresenceSubService |
|
136 |
|
137 /** |
|
138 * @see MVIMPSTEnginePresenceSubService |
|
139 */ |
|
140 void RegisterPresenceEventObserverL( |
|
141 MVIMPSTEnginePresenceSubServiceEventObserver* aObserver); |
|
142 |
|
143 /** |
|
144 * @see MVIMPSTEnginePresenceSubService |
|
145 */ |
|
146 void UnRegisterPresenceEventObserver( |
|
147 MVIMPSTEnginePresenceSubServiceEventObserver* aObserver); |
|
148 |
|
149 /** |
|
150 * Subsribes presence of a single contact |
|
151 * Can be done for the contacts who are already subscribed(Required atleast in XMPP Case) |
|
152 * This function can be used on FriendRequests also wherein it performs 2 operation |
|
153 * 1. Accepts the invitation if Friend Request is Pending(GrantPresenceForPresentityL) |
|
154 * 2. Subscribes for the presence either to PresenceCache |
|
155 * or XIMP (MPresentityPresenceEvent) |
|
156 * |
|
157 * |
|
158 * @since S60 5.0 |
|
159 * @param aUriOfTheContact, Presence URI to be subscribed |
|
160 */ |
|
161 void SubscribePresenceOfSingleContactL( const TDesC& aUriOfTheContact ); |
|
162 |
|
163 |
|
164 /** |
|
165 * Unsubsribes presence of a single contact |
|
166 * Used for those contact whose presence has been subscribed |
|
167 * Can be used for Friend Requests also |
|
168 * 1. Denies the invitation for the contact (WithdrawPresenceGrantFromPresentityL) |
|
169 * 2. Sends a unsubscribe to PresenceCache |
|
170 * or XIMP (UnsubscribePresentityPresenceL) |
|
171 * |
|
172 * @since S60 5.0 |
|
173 * @param aUriOfTheContact, Presence URI to be subscribed |
|
174 */ |
|
175 void UnSubscribePresenceOfSingleContactL( const TDesC& aUriOfTheContact ); |
|
176 |
|
177 /** |
|
178 * Fetches presence from presencecache. |
|
179 * |
|
180 * @since 5.0 |
|
181 **/ |
|
182 TInt FetchPresenceFromCache(); |
|
183 |
|
184 /** |
|
185 * Unsubscribes ximp group contents. |
|
186 * |
|
187 * Buddy list and authorization lists are always unsubscibed. |
|
188 * Block list is unsubscribed if it is supported. |
|
189 * |
|
190 * @since S60 5.0 |
|
191 * @param None |
|
192 * @leave Standard Symbian error codes. |
|
193 * @return None |
|
194 */ |
|
195 void UnsubscribeListsL(); |
|
196 |
|
197 /** |
|
198 * Requests the XIMPFw to subscribe for presence |
|
199 * grant request list subscription. |
|
200 */ |
|
201 void SubscribeForAuthorizationL(); |
|
202 |
|
203 /** |
|
204 * sends PresenceGrantForPresentity response to server |
|
205 * @param aContactId, id of the requesting party.. |
|
206 * @param aResponse , Etrue if accpeted else rejected. |
|
207 * @return TInt error if any |
|
208 */ |
|
209 TInt SendPresenceGrantPresentityL( const TDesC& aContactId , TBool aResponse ); |
|
210 |
|
211 /** |
|
212 * IsChangeOwnStatusSupported by the protocol |
|
213 * |
|
214 * @since S60 5.0 |
|
215 * @return TBool ETrue if supported else EFalse. |
|
216 */ |
|
217 TBool IsChangeOwnStatusSupported() ; |
|
218 |
|
219 /** |
|
220 * IsStatusMsgSupported by the protocol |
|
221 * |
|
222 * @since S60 5.0 |
|
223 * @return TBool ETrue if supported else EFalse. |
|
224 */ |
|
225 TBool IsStatusMsgSupported(); |
|
226 |
|
227 /** |
|
228 * IsAvatarSupported by the protocol |
|
229 * |
|
230 * @since S60 5.0 |
|
231 * @return TBool ETrue if supported else EFalse. |
|
232 */ |
|
233 TBool IsAvatarSupported() ; |
|
234 |
|
235 /** |
|
236 * SetAvatarSupported by the protocol |
|
237 * |
|
238 * @since S60 5.0 |
|
239 * @param aSupported, TBool ETrue if supported else EFalse. |
|
240 */ |
|
241 void SetAvatarSupported(TBool aSupported ) ; |
|
242 |
|
243 |
|
244 /** |
|
245 * PublishOwnPresenceL |
|
246 * to update the ownstatus to server. |
|
247 * and publishes the own status. |
|
248 * |
|
249 * @param aStatus ,status to be updated to the server. |
|
250 * @param aValue , text for the status message |
|
251 * @param aFilename , avatar file name |
|
252 * @param aMimetype , a mime type |
|
253 * @param aIsAvatar , a avatar field included |
|
254 * @return TInt error if any |
|
255 */ |
|
256 TInt PublishOwnPresenceL(TVIMPSTEnums::TOnlineStatus aStatus, |
|
257 const TDesC& aValue, |
|
258 const TDesC& aFilename = KNullDesC, |
|
259 const TDesC8& aMimetype = KNullDesC8, |
|
260 TBool aIsAvatar = EFalse ); |
|
261 |
|
262 |
|
263 /** |
|
264 * Removes URI from block list |
|
265 * |
|
266 * @since S60 5.0 |
|
267 * @param aUriOfTheContact, URI to be removed |
|
268 * @return error. |
|
269 */ |
|
270 TInt RemoveFromBlockListL( const TDesC& aUriOfTheContact ); |
|
271 |
|
272 /** |
|
273 * Adds URI to block list |
|
274 * |
|
275 * @since S60 5.0 |
|
276 * @param aContactId, URI to be added |
|
277 * @return error. |
|
278 */ |
|
279 TInt AddToBlockListL( const TDesC& aContactId ); |
|
280 |
|
281 /** |
|
282 * Get list of blocked contact. |
|
283 */ |
|
284 RPointerArray<HBufC>* GetBlockedList(); |
|
285 |
|
286 /** |
|
287 * fetch blocked list from server to get the freshed blocked list. |
|
288 */ |
|
289 void FetchBlockedListFromServerL(MVIMPSTEngineBlockedListFetchEventObserver* aOb); |
|
290 |
|
291 /** |
|
292 * function called from the engine once contact fetching completes |
|
293 */ |
|
294 void UpdatePresenceStateL(); |
|
295 |
|
296 /** |
|
297 * Fetches the presence of singlecontact form presence cache |
|
298 * @param aContact, user id of the ocntact who's presence |
|
299 * needs to eb fetched. |
|
300 */ |
|
301 void FetchPresenceOfSingleContactL(const TDesC& aContact); |
|
302 |
|
303 |
|
304 |
|
305 private: // prescachereadhandler |
|
306 |
|
307 /** |
|
308 * Handler for AllBuddiesPresenceInService method of MPresenceCacheReader. |
|
309 * |
|
310 * @param aErrorCode |
|
311 * @param aPresenceBuddyInfoList presence infos for all buddies requested. |
|
312 * Ownership of elements to callee. Can be empty if not found. |
|
313 */ |
|
314 void HandlePresenceReadL(TInt aErrorCode, |
|
315 RPointerArray<MPresenceBuddyInfo2>& aPresenceBuddyInfoList) ; |
|
316 |
|
317 /** |
|
318 * Handler for Buddy presence change notifications. |
|
319 * |
|
320 * @param aErrorCode |
|
321 * @param aPresenceBuddyInfo presence info for buddy. |
|
322 * Ownership to callee. Can be NULL if aErrorCode exist. |
|
323 */ |
|
324 void HandlePresenceNotificationL(TInt aErrorCode, |
|
325 MPresenceBuddyInfo2* aPresenceBuddyInfo); |
|
326 |
|
327 |
|
328 private: // From MVIMPSTEngineCchHandlerObserver |
|
329 |
|
330 /** |
|
331 * From MVIMPSTEngineCchHandlerObserver |
|
332 * Observer callback for CCH event |
|
333 * |
|
334 * @param aServiceId, service id |
|
335 * @param aState, service state |
|
336 * @param aServiceError, error |
|
337 * @since S60 5.0 |
|
338 */ |
|
339 void CchEventOccuredL( |
|
340 TUint aServiceId, |
|
341 TCCHSubserviceState aState, |
|
342 TInt aServiceError ); |
|
343 /** |
|
344 * Handles any error that occured during login. |
|
345 |
|
346 * @since S60 5.0 |
|
347 * @param aServiceError, error |
|
348 */ |
|
349 void DoHandleCchErrorL( TInt aServiceError ); |
|
350 |
|
351 public: |
|
352 /** |
|
353 * Observer Event for forwarding the ximp events. |
|
354 * @param aContext - ximpfw context |
|
355 * @param aEvent - ximpfw event |
|
356 */ |
|
357 void HandleSessionContextEventL( const MXIMPContext& aContext, |
|
358 const MXIMPBase& aEvent, |
|
359 TXimpOperation aXimpOperation = EVIMPSTXimpOperationNoOperation); |
|
360 |
|
361 private: |
|
362 |
|
363 /** |
|
364 * Resolves service state for given service id. |
|
365 * |
|
366 * @since S60 5.0 |
|
367 * @param aState, state of the subservice |
|
368 * @param aServiceError, service error is stored here |
|
369 * @return TVIMPSTRegistrationState, |
|
370 * service state to use |
|
371 */ |
|
372 TVIMPSTEnums::TVIMPSTRegistrationState ResolveServiceStateL( TCCHSubserviceState aState, |
|
373 TInt aServiceError ); |
|
374 |
|
375 /** |
|
376 * Gets a list of all presence subscribtions |
|
377 * |
|
378 * @since S60 5.0 |
|
379 */ |
|
380 void RetrieveSubscribedListL(); |
|
381 |
|
382 /** |
|
383 * Handles presentity group context events. |
|
384 * |
|
385 * @since S60 5.0 |
|
386 * @param aContext, presence context |
|
387 * @param aEvent, presence event |
|
388 */ |
|
389 void DoHandlePresentityGroupContentEventL( |
|
390 const MXIMPContext& aContext, |
|
391 const MXIMPBase& aEvent ); |
|
392 |
|
393 /** |
|
394 * Handles presentity grant request list events. |
|
395 * |
|
396 * @since S60 5.0 |
|
397 * @param aContext, presence context |
|
398 * @param aEvent, presence event |
|
399 */ |
|
400 void DoHandlePresenceGrantRequestListEventL( |
|
401 const MXIMPContext& aContext, |
|
402 const MXIMPBase& aEvent ); |
|
403 |
|
404 /** |
|
405 * Handles presentity block list events. |
|
406 * |
|
407 * @since S60 5.0 |
|
408 * @param aContext, presence context |
|
409 * @param aEvent, presence event |
|
410 */ |
|
411 void DoHandlePresenceBlockListEventL( |
|
412 const MXIMPContext& aContext, |
|
413 const MXIMPBase& aEvent ); |
|
414 |
|
415 /** |
|
416 * Handles completed ximp event. |
|
417 * |
|
418 * @since S60 5.0 |
|
419 * @param aType, completed event. |
|
420 * @param aCompleteCode, error code of complete |
|
421 * @param aEvent, MXIMBase for the clients to use information |
|
422 */ |
|
423 void HandleXimpRequestCompleteL( TXimpOperation aType, |
|
424 TInt aCompleteCode, |
|
425 const MXIMPBase& aEvent); |
|
426 |
|
427 /** |
|
428 * Handles completed list/bind/unbind events. |
|
429 * |
|
430 * @since S60 5.0 |
|
431 * @param aType, completed event. |
|
432 * @param aCompleteCode, error code of complete |
|
433 * @param aEvent, MXIMBase for the clients to use information |
|
434 */ |
|
435 void HandleListEventCompleteL(TXimpOperation aType, |
|
436 TInt aCompleteCode, |
|
437 const MXIMPBase& aEvent ); |
|
438 /** |
|
439 * ConvertPresenceStatus |
|
440 * @param aStatus presence status to be converted |
|
441 * @return TAvailabilityValues |
|
442 */ |
|
443 NPresenceInfo::TAvailabilityValues ConvertPresenceStatus(TVIMPSTEnums::TOnlineStatus aStatus); |
|
444 |
|
445 |
|
446 /** |
|
447 * Stores all the contact into virtual store |
|
448 * need to chec how thi has to be handled for sip:as |
|
449 * sip does not fetch the contacts from the server. |
|
450 * |
|
451 * @since 5.0 |
|
452 * @param aListEvent list containing all the group members. |
|
453 */ |
|
454 void StoreToVirtualStoreL( const MPresentityGroupContentEvent& aListEvent ); |
|
455 |
|
456 |
|
457 |
|
458 /** |
|
459 * Converts the presence cache status to client supported presence status. |
|
460 * |
|
461 * @since 5.0 |
|
462 * @param aAvailabilityEnum presence cache status value. |
|
463 * @param aAvabilityText avability text, To support Multiple presence states. |
|
464 * @return TVIMPSTEnums::TOnlineStatus client presence status. |
|
465 */ |
|
466 TVIMPSTEnums::TOnlineStatus ConvertPresenceCacheEnums(MPresenceBuddyInfo2::TAvailabilityValues aAvailabilityEnum,TPtrC aAvabilityText); |
|
467 /** |
|
468 * Initiates downloading of block list |
|
469 * @since 5.0 |
|
470 */ |
|
471 void RetrieveBlockListL(); |
|
472 |
|
473 /** |
|
474 * Converts the presence cache extension keys |
|
475 * user for block and pending states to client supported presence status. |
|
476 * |
|
477 * @since 5.0 |
|
478 * @param aPresenceBuddyInfo presence buddy info class. |
|
479 * @param TVIMPSTEnums::TOnlineStatus client presence status. |
|
480 */ |
|
481 void GetKeyFieldsAndValuesL(MPresenceBuddyInfo2& aPresenceBuddyInfo,TVIMPSTEnums::TOnlineStatus &aStatus); |
|
482 |
|
483 /** |
|
484 * Handler for Buddy presence change notifications. |
|
485 * |
|
486 * @param aPresenceBuddyInfo presence info for buddy. |
|
487 */ |
|
488 void DoHandlePresenceNotificationL(MPresenceBuddyInfo2& aPresenceBuddyInfo); |
|
489 |
|
490 |
|
491 private: // Implementation |
|
492 |
|
493 /** |
|
494 * Standard C++ constructor |
|
495 * |
|
496 * @since s60 5.0 |
|
497 * @param aServiceId, service id |
|
498 * @param aCchHandler, reference to cchhandler. |
|
499 * @param aTableFetcher, reference to settingstable. |
|
500 * @param aXimpEventObserver, reference to ximpevent observer. |
|
501 * @param aServiceStateListener, reference to servicestatelistener. |
|
502 */ |
|
503 CVIMPSTEnginePresenceSubService( TUint32 aServiceId, |
|
504 CVIMPSTEngineCchHandler& aCchHandler, |
|
505 CVIMPSTEngineServiceTableFetcher& aTableFetcher, |
|
506 CVIMPSTEngineSessionCntxtObserver& aXimpEventObserver, |
|
507 MVIMPSTEngineServiceConnectionEventObserver& aObserver ); |
|
508 |
|
509 /** |
|
510 * Performs the 2nd phase of construction. |
|
511 */ |
|
512 void ConstructL(); |
|
513 |
|
514 private: // Data |
|
515 |
|
516 // Service identifier |
|
517 TUint32 iServiceId; |
|
518 |
|
519 //Ref to the CCH Handler |
|
520 //thro this interface Presence sub service listens to the |
|
521 //ECCHPrsenceSub connectivity events. |
|
522 CVIMPSTEngineCchHandler& iCchHandler; |
|
523 |
|
524 //doesnt own, reference to settings table. |
|
525 CVIMPSTEngineServiceTableFetcher& iSettingsTableFetcher; |
|
526 |
|
527 //doesnot own, reference to ximpeventobserver. |
|
528 CVIMPSTEngineSessionCntxtObserver& iXimpEventObserver; |
|
529 |
|
530 //does not own, reference to servicestatelistener. |
|
531 MVIMPSTEngineServiceConnectionEventObserver& iObserver; |
|
532 |
|
533 |
|
534 //owns |
|
535 MPresenceCacheReader2* iPresenceCacheReader; |
|
536 |
|
537 //Owns, service name |
|
538 HBufC* iServiceName; |
|
539 |
|
540 |
|
541 // Stores services current state |
|
542 TVIMPSTEnums::TVIMPSTRegistrationState iServiceState; |
|
543 |
|
544 TBool iChangeStatusSupported; |
|
545 |
|
546 TBool iChangeStatusMsgSupported; |
|
547 |
|
548 // ETrue if supported |
|
549 TBool iAvatarSupported; |
|
550 |
|
551 //Doesnt Own |
|
552 MVIMPSTEnginePresenceSubServiceEventObserver* iSubServiceObserver; |
|
553 |
|
554 // Etrue if clearing avatar in progress |
|
555 TBool iIsClearingAvatar; |
|
556 |
|
557 //stores the default MBM path |
|
558 TFileName iDefaultMbmPath; |
|
559 |
|
560 //Blocked list manager instance pointer. |
|
561 CVIMPSTBlockedListManager* iBlockedListMgr; |
|
562 |
|
563 //Not owned;Notify that blocked list has been fetched. |
|
564 MVIMPSTEngineBlockedListFetchEventObserver* iBlockedListObserver; |
|
565 |
|
566 //flag indicate if request for fetching blocked list is pending. |
|
567 TBool iBlockListFetchReqPending; |
|
568 |
|
569 //flag indicates pending Logout request |
|
570 TBool iLogoutRequest; |
|
571 // owns : ETrue if fetching is ongoing |
|
572 TBool iIsFetchingContact; |
|
573 |
|
574 TBool iAutoAccept; |
|
575 |
|
576 // owns, tells weather it is subscribe to authorization list or not. |
|
577 TBool iSubscribeToAuthList; |
|
578 |
|
579 }; |
|
580 |
|
581 #endif //CVIMPSTENGINEPRESENCESUBSERVICE_H |
|
582 |
|