|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Manager for presence operations (fetcher/notifier/publisher). |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CCAPENGPRESENCEMANAGER_H |
|
20 #define CCAPENGPRESENCEMANAGER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include "CAPresenceDefinitions.h" |
|
24 #include "TStorageManagerGlobals.h" |
|
25 #include "MCAPresence.h" |
|
26 #include "TCARequestQueue.h" |
|
27 #include "MCASettings.h" |
|
28 #include "SServerPrefers.h" |
|
29 #include "TDecodeAttrParams.h" |
|
30 #include "MCAPresenceUpdater.h" |
|
31 |
|
32 #include <MPEngPresenceObserver2.h> |
|
33 #include <MPEngAttributeTransactionObserver2.h> |
|
34 #include <MPEngReactAuthObserver.h> |
|
35 #include <MPEngReactAuthTransactionObserver.h> |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CPEngAttributeListTransaction; |
|
39 class CPEngAttributeStore2; |
|
40 class CPEngPresenceNotifier2; |
|
41 class CPEngAttributeTransaction; |
|
42 class MPEngPresenceAttrModel; |
|
43 class MCASettings; |
|
44 class CCAPEngListManager; |
|
45 class CCAPresenceErrors; |
|
46 class MCAStoredContacts; |
|
47 class CPEngTrackedPresenceIDs2; |
|
48 class MPEngPresenceAttrModel2; |
|
49 |
|
50 class MCAReactiveAuthObserver; |
|
51 class MPEngAuthorizationRequest; |
|
52 class MPEngAuthorizationStatus; |
|
53 class CPEngReactAuthStore; |
|
54 class CPEngReactAuthNotifier; |
|
55 class CPEngReactAuthTransaction; |
|
56 class CCAState; |
|
57 |
|
58 // CLASS DECLARATION |
|
59 |
|
60 /** |
|
61 * Manager for presence-list operations |
|
62 * |
|
63 * @lib CAPresence.dll |
|
64 * @since 2.1 |
|
65 */ |
|
66 class CCAPEngPresenceManager : public CBase, |
|
67 public MCAPresence, |
|
68 public MPEngPresenceObserver2, |
|
69 public MPEngAttributeTransactionObserver2, |
|
70 public MPEngReactAuthObserver, |
|
71 public MPEngReactAuthTransactionObserver, |
|
72 public MCAPresenceUpdater |
|
73 { |
|
74 public: // Constructors and destructor |
|
75 |
|
76 /** |
|
77 * Two-phased constructor. |
|
78 */ |
|
79 static CCAPEngPresenceManager* NewL( |
|
80 MCASettings* aApplicationSettings ); |
|
81 |
|
82 /** |
|
83 * Destructor. |
|
84 */ |
|
85 virtual ~CCAPEngPresenceManager(); |
|
86 |
|
87 public: // New public methods |
|
88 |
|
89 /** |
|
90 * Returns settings API handle |
|
91 * @since 2.1 |
|
92 * @return Settings API handle |
|
93 */ |
|
94 MCASettings* SettingsAPI() const; |
|
95 |
|
96 /** |
|
97 * Sets setting API handle |
|
98 * @since 2.1 |
|
99 * @param aApplicationSettings Settings API handle |
|
100 */ |
|
101 void SetSettingsAPIL( MCASettings* aApplicationSettings ); |
|
102 |
|
103 public: // From MCAPresence |
|
104 |
|
105 /** |
|
106 * @see MCAPresence |
|
107 */ |
|
108 void HandleNetworkStateL( TNetworkStatus aState, |
|
109 const SServerPrefers& aServerPreferences, |
|
110 CPEngNWSessionSlotID2* aSessionSlotID ); |
|
111 |
|
112 /** |
|
113 * @see MCAPresence |
|
114 */ |
|
115 void HandleSettingsChangeL( TInt aChangedSettingEnum ); |
|
116 |
|
117 /** |
|
118 * @see MCAPresence |
|
119 */ |
|
120 void SetPresenceObserver( MCAPresenceObserver* aObserver ); |
|
121 |
|
122 /** |
|
123 * @see MCAPresence |
|
124 */ |
|
125 MCAPresenceObserver* PresenceObserver() const; |
|
126 |
|
127 /** |
|
128 * @see MCAPresence |
|
129 */ |
|
130 void SetWatcherObserver( MCAWatcherObserver* aObserver ); |
|
131 |
|
132 /** |
|
133 * @see MCAPresence |
|
134 */ |
|
135 void AddWatcherL( const TDesC& aWVId ); |
|
136 |
|
137 /** |
|
138 * @see MCAPresence |
|
139 */ |
|
140 void RemoveWatcherL( const TDesC& aWVId ); |
|
141 |
|
142 /** |
|
143 * @see MCAPresence |
|
144 */ |
|
145 void RefreshFriendsL(); |
|
146 |
|
147 /** |
|
148 * @see MCAPresence |
|
149 */ |
|
150 void GetOnlineUsersL( const CDesCArray& aUserList, |
|
151 CDesCArray* aOnlineList, |
|
152 CDesCArray* aOfflineList, |
|
153 TBool aUpdateStorage = EFalse ); |
|
154 |
|
155 /** |
|
156 * @see MCAPresence |
|
157 */ |
|
158 void GetOnlineFriendsL( CDesCArray& aOnlineList, |
|
159 TBool aFetchFromNetwork = EFalse ); |
|
160 |
|
161 /** |
|
162 * @see MCAPresence |
|
163 */ |
|
164 void SubscribeFriendsL( const TSubscribeMode aMode ); |
|
165 |
|
166 /** |
|
167 * @see MCAPresence |
|
168 */ |
|
169 MCAContactLists* ContactLists(); |
|
170 |
|
171 /** |
|
172 * @see MCAPresence |
|
173 */ |
|
174 const CCAPresenceErrors& LastOperationResult() const; |
|
175 |
|
176 /** |
|
177 * Cancel pending requests to network |
|
178 */ |
|
179 void CancelPendingRequests(); |
|
180 |
|
181 /** |
|
182 * @see MCAPresence |
|
183 */ |
|
184 void SynchronizePresenceSettingsL( |
|
185 const SServerPrefers& aServerPreferences ); |
|
186 |
|
187 /** |
|
188 * @see MCAPresence |
|
189 */ |
|
190 HBufC* AliasL( const TDesC& aUserId ); |
|
191 |
|
192 /** |
|
193 * @see MCAPresence |
|
194 */ |
|
195 HBufC* AliasL( MCAStoredContact* aContact ); |
|
196 |
|
197 /** |
|
198 * @see MCAPresence |
|
199 */ |
|
200 void ChangeStatusL( TPresenceStatus aStatus ); |
|
201 |
|
202 /** |
|
203 * @see MCAPresence |
|
204 */ |
|
205 TInt ChangeStatusL( TPresenceStatus aStatus, |
|
206 const TDesC& aStatusMessage ); |
|
207 |
|
208 /** |
|
209 * @see MCAPresence |
|
210 */ |
|
211 TInt ChangeStatusMessageL( const TDesC& aStatusMessage ); |
|
212 |
|
213 /** |
|
214 * @see MCAPresence |
|
215 */ |
|
216 MCAPresence::TPresenceStatus StatusL(); |
|
217 |
|
218 /** |
|
219 * @see MCAPresence |
|
220 */ |
|
221 void AddOwnPresenceStatusObserverL( MCAPresenceObserver* aObserver ); |
|
222 |
|
223 /** |
|
224 * @see MCAPresence |
|
225 */ |
|
226 void InitializePresenceAPIL( CPEngNWSessionSlotID2& aSessionSlotID ); |
|
227 |
|
228 /** |
|
229 * @see MCAPresence |
|
230 */ |
|
231 void AddAttributeL( TInt aAttribute ); |
|
232 |
|
233 /** |
|
234 * @see MCAPresence |
|
235 */ |
|
236 void RemoveAttributeL( TInt aAttribute ); |
|
237 |
|
238 /** |
|
239 * @see MCAPresence |
|
240 */ |
|
241 void ResetAttributesL( TBool aNotifyListManager /* = ETrue */ ); |
|
242 |
|
243 /** |
|
244 * @see MCAPresence |
|
245 */ |
|
246 void UpdateAliasAttributeL(); |
|
247 |
|
248 /** |
|
249 * @see MCAPresence |
|
250 */ |
|
251 void SetReactiveAuthObserver( MCAReactiveAuthObserver* aRAObserver ); |
|
252 |
|
253 /** |
|
254 * @see MCAPresence |
|
255 */ |
|
256 void SendReactiveAuthResponseL( TInt aId, TBool aResponse ); |
|
257 |
|
258 /** |
|
259 * @see MCAPresence |
|
260 */ |
|
261 TInt PendingRARequestCount(); |
|
262 |
|
263 /** |
|
264 * @see MCAPresence |
|
265 */ |
|
266 TBool GetNextPendingRARequestL( TInt& aId, |
|
267 TDes& aUserId, |
|
268 TInt& aLastPos ); |
|
269 |
|
270 /** |
|
271 * @see MCAPresence |
|
272 */ |
|
273 TInt RAStatusCount(); |
|
274 |
|
275 /** |
|
276 * @see MCAPresence |
|
277 */ |
|
278 TBool GetNextRAStatusL( TInt& aId, TBool& aStatus, |
|
279 TDes& aUserId, TInt& aLastPos ); |
|
280 |
|
281 /** |
|
282 * @see MCAPresence |
|
283 */ |
|
284 void PostLoginRAFlushL(); |
|
285 |
|
286 private: // From MPEngAttributeTransactionObserver2 |
|
287 |
|
288 /** |
|
289 * @see MPEngAttributeTransactionObserver2 |
|
290 */ |
|
291 void HandleAttributeTransactionError( |
|
292 TInt aError, |
|
293 CPEngAttributeTransaction2& aTransaction, |
|
294 TInt aTransactionOperation ); |
|
295 |
|
296 /** |
|
297 * @see MPEngAttributeTransactionObserver2 |
|
298 */ |
|
299 void HandleAttributeTransactionCompleteL( |
|
300 MPEngTransactionStatus2& aStatus, |
|
301 CPEngAttributeTransaction2& aTransaction, |
|
302 TInt aTransactionOperation ); |
|
303 |
|
304 |
|
305 private: // From MPEngPresenceObserver2 |
|
306 |
|
307 /** |
|
308 * @see MPEngPresenceObserver2 |
|
309 */ |
|
310 void HandlePresenceChangeL( CPEngPresenceNotifier2& aNotifier, |
|
311 CPEngTrackedPresenceIDs2& aChangedPresenceIDs ); |
|
312 |
|
313 /** |
|
314 * @see MPEngPresenceObserver2 |
|
315 */ |
|
316 void HandlePresenceError( TInt aError, |
|
317 CPEngPresenceNotifier2& aNotifier ); |
|
318 |
|
319 public: // from MPEngReactAuthObserver |
|
320 |
|
321 // @see MPEngReactAuthObserver |
|
322 void HandlePendingAuthorizationReqL( |
|
323 CPEngReactAuthNotifier& aNotifier, |
|
324 TArray< MPEngAuthorizationRequest* >& aPendingAuthReqs ); |
|
325 |
|
326 // @see MPEngReactAuthObserver |
|
327 void HandlerAuthorizationStatusL( |
|
328 CPEngReactAuthNotifier& aNotifier, |
|
329 TArray< const MPEngAuthorizationStatus* > aAuthStatuses ); |
|
330 |
|
331 // @see MPEngReactAuthObserver |
|
332 void HandleReactAuthError( |
|
333 TInt aError, |
|
334 CPEngReactAuthNotifier& aNotifier ); |
|
335 |
|
336 private: // from MPEngReactAuthTransactionObserver |
|
337 |
|
338 void HandleReactAuthTransactionCompleteL( |
|
339 MPEngTransactionStatus2& aStatus, |
|
340 CPEngReactAuthTransaction& aTransaction, |
|
341 TInt aTransactionOperation ); |
|
342 |
|
343 void HandleReactAuthTransactionError( |
|
344 TInt aError, |
|
345 CPEngReactAuthTransaction& aTransaction, |
|
346 TInt aTransactionOperation ); |
|
347 |
|
348 private: // From MCAPresenceUpdater |
|
349 |
|
350 /** |
|
351 * @see MCAPresenceUpdater |
|
352 */ |
|
353 void UpdatePresenceL( const TDesC& aUserId ); |
|
354 |
|
355 /** |
|
356 * @see MCAPresenceUpdater |
|
357 */ |
|
358 void ExtractAttributeModelsForUserL( |
|
359 const TDesC& aUserId, |
|
360 RPointerArray<MPEngPresenceAttrModel2>& aAttrModels ); |
|
361 |
|
362 const RPointerArray<CCAState>& PresenceStates(); |
|
363 |
|
364 void SetAttributeProcessing( TBool aEnabled ); |
|
365 |
|
366 private: |
|
367 |
|
368 /** |
|
369 * C++ default constructor. |
|
370 */ |
|
371 CCAPEngPresenceManager(); |
|
372 |
|
373 /** |
|
374 * By default Symbian 2nd phase constructor is private. |
|
375 */ |
|
376 void ConstructL( MCASettings* aApplicationSettings ); |
|
377 |
|
378 // Prohibit copy constructor if not deriving from CBase. |
|
379 // CCAPEngPresenceManager( const CCAPEngPresenceManager& ) |
|
380 // Prohibit assigment operator if not deriving from CBase. |
|
381 // CCAPEngPresenceManager& operator=( const CCAPEngPresenceManager& ) |
|
382 void DecodeFetcherDataL( |
|
383 const MDesCArray& aUserList, |
|
384 CDesCArray* aStateOnline = NULL, |
|
385 CDesCArray* aStateOffline = NULL, |
|
386 CDesCArray* aStateUnknown = NULL, |
|
387 TBool aUpdateStorage = EFalse ); |
|
388 |
|
389 static TInt DecodeAttrModels( TAny *aInstance ); |
|
390 TInt DoDecodeAttrModels(); |
|
391 |
|
392 void DecodeNotifierDataL( |
|
393 CPEngTrackedPresenceIDs2* aChangedPresenceIDs, |
|
394 const MDesCArray* aUserList ); |
|
395 |
|
396 TBool IsLoggedIn() const; |
|
397 |
|
398 /** |
|
399 * Populates the attribute models from PEC Engine cache |
|
400 * of fetched/subscribed attributes |
|
401 * @param aArray Will contain the populated attribute models |
|
402 * @param aUserList The list of users to parse, ignored |
|
403 * in case of notifier |
|
404 * @param aChangedPresenceIDs The IDs which were changed |
|
405 * (NULL if fetcher) |
|
406 */ |
|
407 void PopulateAttrModelsL( |
|
408 RPointerArray<MPEngPresenceAttrModel2>& aArray, |
|
409 const MDesCArray* aUserList = NULL, |
|
410 CPEngTrackedPresenceIDs2* aChangedPresenceIDs = NULL ); |
|
411 |
|
412 // See MCASettings.h for authorization modes |
|
413 void SetPresenceAuthorizationL( TInt aAppSettingsAuthValue ); |
|
414 |
|
415 void FetchAttributesL( const MDesCArray& aUsers, |
|
416 CDesCArray *aStateOnline, |
|
417 CDesCArray *aStateOffline, |
|
418 CDesCArray *aStateUnknown, |
|
419 TBool aUpdateStorage ); |
|
420 |
|
421 /** |
|
422 * Initializes PEng API related handlers |
|
423 * @param aSessionSlotID a network session slot id |
|
424 */ |
|
425 void InitializePEngAPIL(); |
|
426 |
|
427 |
|
428 /** |
|
429 * Initializes a pending own presence observer |
|
430 */ |
|
431 void InitializeOwnPresenceObserverL(); |
|
432 |
|
433 /** |
|
434 * Notifies own presence observer, |
|
435 */ |
|
436 void NotifyOwnPresenceObserverL(); |
|
437 |
|
438 /** |
|
439 * Map internal dynamic attributes to PEC attributes, |
|
440 * @param aAttribute The attribute |
|
441 */ |
|
442 TUint32 InternalToPECAttrL( TDynamicAttributes aAttribute ); |
|
443 |
|
444 /** |
|
445 * Helper method to extract the attribute model for the given attribute |
|
446 * out of the current attribute store. |
|
447 * @params aId The WVID |
|
448 * @params aArray Where to put the attribute (appended) |
|
449 * @params aAttribute The attribute to parse |
|
450 * Will leave with errors. |
|
451 */ |
|
452 void ExtractAttributeModelL( |
|
453 const TDesC& aId, |
|
454 RPointerArray<MPEngPresenceAttrModel2>& aArray, |
|
455 TUint32 aAttribute ); |
|
456 |
|
457 /** |
|
458 * Extracts all supported attribute models for the users |
|
459 * given in the list. Attribute models are appended to |
|
460 * the given array. |
|
461 * @param aUserList The list of users |
|
462 * @param aAttrModels The attribute models to which to append |
|
463 * the extracted models |
|
464 */ |
|
465 void ExtractAttributeModelsForUsersL( |
|
466 const MDesCArray& aUserList, |
|
467 RPointerArray<MPEngPresenceAttrModel2>& aAttrModels ); |
|
468 |
|
469 private: // Data |
|
470 // Owns. Internal list-manager |
|
471 CCAPEngListManager* iListManager; |
|
472 // Doesn't own. Presence module observer |
|
473 MCAPresenceObserver* iPresenceObserver; |
|
474 // Owns. Presence fetcher from Presence Engine |
|
475 CPEngAttributeTransaction2* iPEngAttributeTransaction; |
|
476 |
|
477 // Owns. Presence attribute store from Presence Engine |
|
478 CPEngAttributeStore2* iPEngAttributeStore; |
|
479 // Doesn't own. |
|
480 MCASettings* iApplicationSettings; |
|
481 // Doesn't own. |
|
482 MCAWatcherObserver* iWatcherObserver; |
|
483 // Owns. Queue for incoming requests |
|
484 TCARequestQueue iRequestQueue; |
|
485 // Error data container |
|
486 CCAPresenceErrors* iErrors; |
|
487 |
|
488 RArray<TUint32> iAttributes; |
|
489 TInt iOperationError; |
|
490 TInt iAuthMode; |
|
491 TInt iNetworkState; |
|
492 |
|
493 TBool iPEngAPIInitialized; |
|
494 |
|
495 // Doesn't own. Own presence status observer |
|
496 MCAPresenceObserver* iOwnStatusObserver; |
|
497 |
|
498 // Owns. presence notifier |
|
499 CPEngPresenceNotifier2* iOwnPresenceNotifier; |
|
500 |
|
501 // Owns. Network session slot ID |
|
502 CPEngNWSessionSlotID2* iSessionSlotID; |
|
503 |
|
504 // a flag that tells if there is an observer |
|
505 // which needs initialization |
|
506 TBool iObserverQueued; |
|
507 |
|
508 // cached app auth settings value |
|
509 TInt iCachedAppSettingsAuthValue; |
|
510 |
|
511 // a flag which tells if there is a cached |
|
512 // status value (both status and status text) |
|
513 TBool iCachedStatus; |
|
514 // cached presence status |
|
515 TPresenceStatus iCachedPresenceStatus; |
|
516 // cached status text |
|
517 HBufC* iCachedStatusText; |
|
518 |
|
519 // ----- reactive authorization ----- |
|
520 |
|
521 // ETrue if reactive authorization in use |
|
522 TBool iRAUsed; |
|
523 |
|
524 // observer for reactive authorization, not owned |
|
525 MCAReactiveAuthObserver* iRAObserver; |
|
526 |
|
527 // reactive authorization store, owned |
|
528 CPEngReactAuthStore* iRAStore; |
|
529 |
|
530 // reactive authorization notifer, owned |
|
531 CPEngReactAuthNotifier* iRANotifier; |
|
532 |
|
533 // reactive authorization transaction, owned |
|
534 CPEngReactAuthTransaction* iRATransaction; |
|
535 |
|
536 // alias support enabled (ETrue) or not (EFalse) |
|
537 TBool iAliasUsed; |
|
538 |
|
539 // Server preferences structure given by the IM Engine |
|
540 // used for branding purposes |
|
541 SServerPrefers iServerPrefers; |
|
542 |
|
543 // owned |
|
544 RPointerArray<CCAState> iOwnStates; |
|
545 |
|
546 // owned |
|
547 RPointerArray<CCAState> iPresenceStates; |
|
548 |
|
549 // owned. Model arrays are used for attribute decoding. |
|
550 RArray< TDecodeAttrParams > iAttrArrays; |
|
551 |
|
552 // owned: Idle for attribute decoding. |
|
553 CIdle* iIdle; |
|
554 |
|
555 // should we process attributes or not |
|
556 TBool iAttributeProcessing; |
|
557 |
|
558 // Objects fetched with FetchAttributesToObjects() are placed here |
|
559 RPointerArray<MPEngPresenceAttrModel2> iFetchObjects; |
|
560 }; |
|
561 |
|
562 #endif // CCAPENGPRESENCEMANAGER_H |
|
563 |
|
564 // End of File |
|
565 |