|
1 /* |
|
2 * Copyright (c) 2002 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: Presence handling interface for clients. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MCAPRESENCE_H |
|
20 #define MCAPRESENCE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <badesca.h> |
|
25 #include "impsbuilddefinitions.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class MCAPresenceObserver; |
|
29 class MCAWatcherObserver; |
|
30 class MCAContactLists; |
|
31 class CCAPresenceErrors; |
|
32 class CPEngNWSessionSlotID2; |
|
33 class MCAStoredContact; |
|
34 class MCAReactiveAuthObserver; |
|
35 |
|
36 struct SServerPrefers; |
|
37 |
|
38 // CLASS DECLARATION |
|
39 |
|
40 /** |
|
41 * Presence handling interface for UI. |
|
42 * |
|
43 * @lib CAPresence.lib |
|
44 * @since 1.2 |
|
45 */ |
|
46 class MCAPresence |
|
47 { |
|
48 public: |
|
49 |
|
50 enum TSubscribeMode |
|
51 { |
|
52 ESubscribe, // Subscribe |
|
53 EUnSubscribe // Unsubscribe |
|
54 }; |
|
55 |
|
56 enum TAuthorizationMode |
|
57 { |
|
58 EAuthorizedToAll, // Everybody can see your presence |
|
59 EAuthorizedToFriends, // Only friends can see your presence |
|
60 EAuthorizedToNone // Nobody can see your presence |
|
61 }; |
|
62 |
|
63 enum TNetworkStatus |
|
64 { |
|
65 ELoggedIn, // Client is logged in |
|
66 ELoggedOut, // Client is logged out |
|
67 ELoggingOut, // Client is about to log out |
|
68 EUpdateBrand // Brand status of client is changed |
|
69 }; |
|
70 |
|
71 enum TPresenceStatus |
|
72 { |
|
73 EUnknown = -1, |
|
74 EOffline, |
|
75 EOnline, |
|
76 EAway, |
|
77 EBusy |
|
78 }; |
|
79 |
|
80 enum TDynamicAttributes |
|
81 { |
|
82 EAliasAttr = 0 |
|
83 // add more here |
|
84 }; |
|
85 |
|
86 public: |
|
87 |
|
88 /** |
|
89 * If network state changes, module state should be updated by calling |
|
90 * this method. |
|
91 * @param aState New state. |
|
92 * @param aServerPreferences Server preferences structure |
|
93 */ |
|
94 virtual void HandleNetworkStateL( TNetworkStatus aState, |
|
95 const SServerPrefers& aServerPreferences, |
|
96 CPEngNWSessionSlotID2* aSessionSlotID = NULL ) = 0; |
|
97 |
|
98 /** |
|
99 * If some setting value changes, this must be called for presence |
|
100 * module to have correct behaviour |
|
101 * @param aState New state. |
|
102 */ |
|
103 virtual void HandleSettingsChangeL( TInt aChangedSettingEnum ) = 0; |
|
104 |
|
105 /** |
|
106 * Registers observer for presence data changes in friends-list. |
|
107 * Unregister can be by passing NULL pointer. |
|
108 * @param aObserver Pointer to observer |
|
109 */ |
|
110 virtual void SetPresenceObserver( MCAPresenceObserver* aObserver ) = 0; |
|
111 |
|
112 /** |
|
113 * Retrieves the observer. |
|
114 * @return Pointer to the observer. |
|
115 */ |
|
116 virtual MCAPresenceObserver* PresenceObserver() const = 0; |
|
117 |
|
118 /** |
|
119 * Registers observer for presence data changes in friends-list. |
|
120 * Unregister can be by passing NULL pointer. |
|
121 * @param aObserver Pointer to observer. |
|
122 */ |
|
123 virtual void SetWatcherObserver( MCAWatcherObserver* aObserver ) = 0; |
|
124 |
|
125 /** |
|
126 * Adds a contact, whose presence status is monitored and if |
|
127 * it changes, then client receives an event through. |
|
128 * MCAWatcherObserver-interface. Given contact must be in friends-list! |
|
129 * @param aWatchList Contact, that gets added. |
|
130 */ |
|
131 virtual void AddWatcherL( const TDesC& aWVId ) = 0; |
|
132 |
|
133 /** |
|
134 * Removes a contact from observed contacts list. |
|
135 * Given contact must be in observed list. |
|
136 * @param aWatchList Contact, that is to be removed. |
|
137 */ |
|
138 virtual void RemoveWatcherL( const TDesC& aWVId ) = 0; |
|
139 |
|
140 /** |
|
141 * Refreshes friends-storage presence data. |
|
142 */ |
|
143 virtual void RefreshFriendsL() = 0; |
|
144 |
|
145 /** |
|
146 * Places all friends (from aUserList) that are online to aOnlineList |
|
147 * and users that are offline to aOfflineList. |
|
148 * @param aUserList List of users, whose presence data is to be fetched. |
|
149 * @param aOnlineList List of users, that are online, can be NULL. |
|
150 * @param aOfflineList List of users, that are offline, can be NULL. |
|
151 * @param aUpdateStorage If ETrue, contact storage flags are updated |
|
152 */ |
|
153 virtual void GetOnlineUsersL( |
|
154 const CDesCArray& aUserList, |
|
155 CDesCArray* aOnlineList, |
|
156 CDesCArray* aOfflineList, |
|
157 TBool aUpdateStorage = EFalse ) = 0; |
|
158 |
|
159 /** |
|
160 * Fills aOnlineList with the user id's from friends-list that are |
|
161 * online. |
|
162 * @param aOnlineList List that will be populated with online friends. |
|
163 * @param aFetchFromNetwork Fetch presence information from network |
|
164 */ |
|
165 virtual void GetOnlineFriendsL( CDesCArray& aOnlineList, |
|
166 TBool aFetchFromNetwork = EFalse ) = 0; |
|
167 |
|
168 /** |
|
169 * Subscribes/Unsubscribes friends-list |
|
170 * @param aMode Request type |
|
171 * @param aForced Force operation even if application settings state |
|
172 * that application is in manual-mode |
|
173 */ |
|
174 virtual void SubscribeFriendsL( const TSubscribeMode aMode ) = 0; |
|
175 |
|
176 /** |
|
177 * Returns list-handling interface |
|
178 * @return List-handling interface |
|
179 */ |
|
180 virtual MCAContactLists* ContactLists() = 0; |
|
181 |
|
182 /** |
|
183 * Returns a reference to error container, that was filled by the last |
|
184 * operation response. |
|
185 * @return Reference to error container |
|
186 */ |
|
187 virtual const CCAPresenceErrors& LastOperationResult() const = 0; |
|
188 |
|
189 /** |
|
190 * Cancel pending requests to network |
|
191 * @since 2.5 |
|
192 */ |
|
193 virtual void CancelPendingRequests() = 0; |
|
194 |
|
195 /** |
|
196 * Synchronizes our presence-related settings to the server |
|
197 * (subcriptions to the friends, presence authorization). |
|
198 * aServerPreferences The resource branded flags for this server, |
|
199 in a struct |
|
200 * @since 2.5 |
|
201 */ |
|
202 virtual void SynchronizePresenceSettingsL( |
|
203 const SServerPrefers& aServerPreferences ) = 0; |
|
204 |
|
205 /** |
|
206 * Changes client own presence status, and sets status message |
|
207 * @param aStatus Presence status |
|
208 * @param aStatusMessage Presence status message |
|
209 * @return Error code. |
|
210 */ |
|
211 virtual TInt ChangeStatusL( TPresenceStatus aStatus, |
|
212 const TDesC& aStatusMessage ) = 0; |
|
213 |
|
214 /** |
|
215 * Changes presence status message |
|
216 * @param aStatusMessage Presence status message |
|
217 * @return Operation error. |
|
218 */ |
|
219 virtual TInt ChangeStatusMessageL( const TDesC& aStatusMessage ) = 0; |
|
220 |
|
221 /** |
|
222 * Gets client own current presence status |
|
223 * @return current presence status |
|
224 */ |
|
225 virtual TPresenceStatus StatusL() = 0; |
|
226 /** |
|
227 * Get alias for given user. |
|
228 * Use this only for one-shot rare operations. |
|
229 * @param aUserId The user id for which to fetch alias attribute |
|
230 * @return The alias, ownership is transferred. |
|
231 * Leaves with KErrNotFound if the alias cannot be found, |
|
232 * otherwise some other KErr-code (e.g. KErrNoMemory) |
|
233 */ |
|
234 virtual HBufC* AliasL( const TDesC& aUserId ) = 0; |
|
235 |
|
236 /** |
|
237 * Get alias for given user. |
|
238 * Use this only for one-shot rare operations. |
|
239 * @param aContact The user for which to fetch alias attribute |
|
240 * @return The alias, ownership is transferred. |
|
241 * Leaves with KErrNotFound if the alias cannot be found, |
|
242 * otherwise some other KErr-code (e.g. KErrNoMemory) |
|
243 */ |
|
244 virtual HBufC* AliasL( MCAStoredContact* aContact ) = 0; |
|
245 |
|
246 /** |
|
247 * Adds own presence status observer. |
|
248 * Leaves with KErrNotReady if not logged in. |
|
249 */ |
|
250 virtual void AddOwnPresenceStatusObserverL( |
|
251 MCAPresenceObserver* aObserver ) = 0; |
|
252 |
|
253 /** |
|
254 * Initializes presence engine interface |
|
255 */ |
|
256 virtual void InitializePresenceAPIL( |
|
257 CPEngNWSessionSlotID2& aSessionSlotID ) = 0; |
|
258 |
|
259 /** |
|
260 * Add given attribute to the list of attributes. |
|
261 * After this the new attributesd will be |
|
262 * subscribed to. |
|
263 * @param aAttribute The attribute to add |
|
264 */ |
|
265 virtual void AddAttributeL( TInt aAttribute ) = 0; |
|
266 |
|
267 /** |
|
268 * Remove given attribute from the list of attributes |
|
269 * After this the new attributesd will be |
|
270 * subscribed to. |
|
271 * @param aAttribute The attribute to remove |
|
272 */ |
|
273 virtual void RemoveAttributeL( TInt aAttribute ) = 0; |
|
274 |
|
275 /** |
|
276 * Reset the attributes to defaults. |
|
277 * @param aNotifyListManager Notify the list manager about the |
|
278 * resetting (ETrue), or not (EFalse) |
|
279 */ |
|
280 virtual void ResetAttributesL( TBool aNotifyListManager = ETrue ) = 0; |
|
281 |
|
282 /** |
|
283 * Update the alias data to network server, if supported |
|
284 */ |
|
285 virtual void UpdateAliasAttributeL() = 0; |
|
286 |
|
287 /** |
|
288 * Set the observer for reactive authorization |
|
289 */ |
|
290 virtual void SetReactiveAuthObserver( |
|
291 MCAReactiveAuthObserver* aRAObserver ) = 0; |
|
292 |
|
293 /** |
|
294 * Send reactive authorization response |
|
295 * @param aId The id number given through observer |
|
296 * @param aResponse The response, ETrue if authorizing, |
|
297 EFalse if denying |
|
298 */ |
|
299 virtual void SendReactiveAuthResponseL( TInt aId, TBool aResponse ) = 0; |
|
300 |
|
301 /** |
|
302 * @return The number of pending requests |
|
303 */ |
|
304 virtual TInt PendingRARequestCount() = 0; |
|
305 |
|
306 /** |
|
307 * Get the information from the next reactive authorization request for |
|
308 * processing |
|
309 * @param aId Will contain the id for the request |
|
310 * @param aUserId Will contain the user id |
|
311 * @param aLastPos Position of previous found request in queue |
|
312 * @return ETrue if there is another request in the queue |
|
313 */ |
|
314 virtual TBool GetNextPendingRARequestL( TInt& aId, TDes& aUserId, |
|
315 TInt& aLastPos ) = 0; |
|
316 |
|
317 /** |
|
318 * @return The number of new status messages |
|
319 */ |
|
320 virtual TInt RAStatusCount() = 0; |
|
321 |
|
322 /** |
|
323 * Get the information from the next reactive authorization status |
|
324 * request for processing |
|
325 * @param aId Will contain the id for the request |
|
326 * @param aStatus ETrue if accepted, EFalse if denied |
|
327 * @param aUserId Will contain the user id |
|
328 * @param aLastPos Position of previous found request in queue |
|
329 * @return ETrue if there is another request in the queue |
|
330 */ |
|
331 virtual TBool GetNextRAStatusL( TInt& aId, TBool& aStatus, |
|
332 TDes& aUserId, TInt& aLastPos ) = 0; |
|
333 |
|
334 /** |
|
335 * Called after the login is fully done, this method will notify the |
|
336 * observers of any RA messages received during the login phase. |
|
337 */ |
|
338 virtual void PostLoginRAFlushL() = 0; |
|
339 |
|
340 protected: |
|
341 |
|
342 /** |
|
343 * Destructor. |
|
344 */ |
|
345 virtual ~MCAPresence() {}; |
|
346 }; |
|
347 |
|
348 #endif // MCAPRESENCE_H |
|
349 |
|
350 // End of File |
|
351 |