|
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: presene status handler |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CSERVICEWIDGETPRESENCEHANDLER_H |
|
21 #define CSERVICEWIDGETPRESENCEHANDLER_H |
|
22 |
|
23 #include <presencecachereader2.h> |
|
24 #include <mpresencebuddyinfo2.h> // buddy info class |
|
25 #include <presenceinfo.h> //Presence info test |
|
26 #include <presencecachereadhandler2.h> // handling the presence cache events |
|
27 #include <ximpcontextobserver.h> |
|
28 #include "servicewidgetenums.hrh" |
|
29 |
|
30 // farword declarations |
|
31 class MXIMPContext; |
|
32 class MXIMPClient; |
|
33 class MPresenceCacheReadHandler2; |
|
34 class MServiceWidgetPresenceObserver; |
|
35 class CActiveSchedulerWait; |
|
36 class MXIMPBase; |
|
37 class MPresenceFeatures; |
|
38 class CServiceWidgetBuddyPresence; |
|
39 class CFbsBitmap; |
|
40 |
|
41 // class defnitions |
|
42 class CServiceWidgetPresenceHandler : public CBase, |
|
43 public MXIMPContextObserver, |
|
44 public MPresenceCacheReadHandler2 |
|
45 |
|
46 { |
|
47 public: |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 * @param aPresenceObserver, prsence observer |
|
52 * @param aServiceName, service name |
|
53 */ |
|
54 static CServiceWidgetPresenceHandler* NewL( MServiceWidgetPresenceObserver& aPresenceObserver, |
|
55 const TDesC& aServiceName, |
|
56 const TDesC& aOwnId ); |
|
57 |
|
58 /** |
|
59 * Two-phased constructor. |
|
60 * @param aPresenceObserver, prsence observer |
|
61 * @param aServiceName, service name |
|
62 */ |
|
63 static CServiceWidgetPresenceHandler* NewLC( MServiceWidgetPresenceObserver& aPresenceObserver, |
|
64 const TDesC& aServiceName, |
|
65 const TDesC& aOwnId ); |
|
66 |
|
67 /** |
|
68 * Standard C++ destructor |
|
69 */ |
|
70 ~CServiceWidgetPresenceHandler(); |
|
71 |
|
72 public: |
|
73 |
|
74 /** |
|
75 * @return online counts |
|
76 */ |
|
77 TInt OnlineBuddyCount(); |
|
78 |
|
79 /** |
|
80 * @return all friend count |
|
81 */ |
|
82 TInt AllBuddyCount(); |
|
83 |
|
84 /** |
|
85 * @return all inviations count |
|
86 */ |
|
87 TInt GetInviteCounts(); |
|
88 |
|
89 /** |
|
90 * @return on going operation id |
|
91 */ |
|
92 TWServiceOperationId GetOngoingOperationId(); |
|
93 |
|
94 /** |
|
95 * get the connected session |
|
96 * @param aProtocolUid, protocal to use |
|
97 * @param aServiceId, service id to use |
|
98 */ |
|
99 void GetConnectedSessionL(TInt aProtocolUid, |
|
100 TInt aServiceId ); |
|
101 |
|
102 /** |
|
103 * release the connected session |
|
104 */ |
|
105 void ReleaseConnectionL(); |
|
106 |
|
107 /** |
|
108 * release the connected session |
|
109 */ |
|
110 TWSPresenceStatus GetOwnStatus(); |
|
111 |
|
112 |
|
113 private : // from MXIMPContextObserver |
|
114 /** |
|
115 * HandleximpContextEvent method from context obsrver |
|
116 * ximp framework |
|
117 * @param aContext |
|
118 * @param aEvent, event |
|
119 */ |
|
120 void HandlePresenceContextEvent(const MXIMPContext& aContext, |
|
121 const MXIMPBase& aEvent ); |
|
122 |
|
123 private: // from prescachereadhandler |
|
124 /** |
|
125 * Handler for AllBuddiesPresenceInService method of MPresenceCacheReader. |
|
126 * |
|
127 * @param aErrorCode |
|
128 * @param aPresenceBuddyInfoList presence infos for all buddies requested. |
|
129 * Ownership of elements to callee. Can be empty if not found. |
|
130 */ |
|
131 void HandlePresenceReadL(TInt aErrorCode, |
|
132 RPointerArray<MPresenceBuddyInfo2>& aPresenceBuddyInfoList) ; |
|
133 |
|
134 /** |
|
135 * Handler for Buddy presence change notifications. |
|
136 * |
|
137 * @param aErrorCode |
|
138 * @param aPresenceBuddyInfo presence info for buddy. |
|
139 * Ownership to callee. Can be NULL if aErrorCode exist. |
|
140 */ |
|
141 void HandlePresenceNotificationL(TInt aErrorCode, |
|
142 MPresenceBuddyInfo2* aPresenceBuddyInfo); |
|
143 |
|
144 private: // Implementation |
|
145 |
|
146 /** |
|
147 * Standard C++ constructor |
|
148 */ |
|
149 CServiceWidgetPresenceHandler( MServiceWidgetPresenceObserver& aPresenceObserver ); |
|
150 |
|
151 /** |
|
152 * Performs the 2nd phase of construction. |
|
153 * @param aServiceName, service name |
|
154 */ |
|
155 void ConstructL(const TDesC& aServiceName, const TDesC& aOwnId ); |
|
156 |
|
157 |
|
158 /** |
|
159 * subsribe the presence change notification |
|
160 */ |
|
161 void RetrieveSubscribedListL(); |
|
162 |
|
163 /** |
|
164 * subsribe the presence change notification |
|
165 */ |
|
166 void SubscribeForAuthorizationL(); |
|
167 |
|
168 /** |
|
169 * subsribe the presence change notification |
|
170 * @param aUserId, user to use |
|
171 */ |
|
172 void SubscribePresenceL( const TDesC& aUserId ); |
|
173 |
|
174 /** |
|
175 * read buddy presence from cache |
|
176 */ |
|
177 void ReadPresenceFromCacheL(); |
|
178 |
|
179 /** |
|
180 * helper method for bind complete |
|
181 */ |
|
182 void DoHandleBindCompleteL(); |
|
183 |
|
184 /** |
|
185 * helper method buddy fetch event |
|
186 * @param aEvent, group list event |
|
187 */ |
|
188 void DoHandlePresentityGroupContentEventL( const MXIMPBase& aEvent ); |
|
189 |
|
190 /** |
|
191 * helper method friend request fetch event |
|
192 * @param aEvent, grand list event |
|
193 */ |
|
194 void DoHandlePresenceGrantRequestListEventL( const MXIMPBase& aEvent ); |
|
195 |
|
196 /** |
|
197 * helper method for converting ximpstatus to local status |
|
198 * @param aAvailabilityEnum, availability of contact |
|
199 */ |
|
200 TWSPresenceStatus ConvertPresenceCacheEnums(MPresenceBuddyInfo2::TAvailabilityValues aAvailabilityEnum,TPtrC aAvabilityText); |
|
201 |
|
202 /** |
|
203 * method for maitain the unique information about status |
|
204 * @param aUserId, a user id of contact |
|
205 * @param aStatus, status of contact |
|
206 */ |
|
207 void CheckAndCacheBuddyAvailabilityL( const TDesC& aUserId, TWSPresenceStatus aStatus ); |
|
208 |
|
209 private: // Data |
|
210 |
|
211 // not owns : reference to presence observer for notification |
|
212 MServiceWidgetPresenceObserver& iPresenceObserver; |
|
213 // owns : service name |
|
214 HBufC* iServiceName; |
|
215 // owns : own user id |
|
216 HBufC* iOwnUserId; |
|
217 // not own |
|
218 TInt iServiceId; |
|
219 // own , client for presence framework |
|
220 MXIMPClient* iClient; |
|
221 // own ,presence context to prsence framework |
|
222 MXIMPContext* iPresenceCtx; |
|
223 //Stores the XIMPFw EventTypes Subscribed for |
|
224 RArray< TInt32 > iAcceptedEventTypes; |
|
225 //owns : reference to presence cache reader |
|
226 MPresenceCacheReader2* iPresenceCacheReader; |
|
227 // owns : total budy count |
|
228 TInt iTotalCount; |
|
229 // owned pointer to presence plugin |
|
230 MPresenceFeatures* iFeatures; |
|
231 // own : current ongoing operation |
|
232 TWServiceOperationId iOperationId; |
|
233 // owns : list of presence buddy |
|
234 RPointerArray<CServiceWidgetBuddyPresence> iOnlineBuddyArray; |
|
235 // owns : own status |
|
236 TWSPresenceStatus iOwnStatus; |
|
237 // owns : invitation count |
|
238 TInt iInvitationCount; |
|
239 |
|
240 }; |
|
241 |
|
242 #endif /*CSERVICEWIDGETPRESENCEHANDLER_H*/ |