|
1 /* |
|
2 * Copyright (c) 2004 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: Notifier API to listen presence changes. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CPENGPRESENCENOTIFIER2_H |
|
19 #define __CPENGPRESENCENOTIFIER2_H |
|
20 |
|
21 // INCLUDES |
|
22 #include <E32Base.h> |
|
23 #include <BamDesca.h> |
|
24 #include <MPEngContactList2.h> |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 //FORWARD DECLARATIONS |
|
30 class MPEngPresenceObserver2; |
|
31 class CPEngTrackedPresenceIDs2; |
|
32 class CPEngPresenceNotifier2Imp; |
|
33 class CPEngNWSessionSlotID2; |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 /** |
|
39 * Notifier API for presence changes. |
|
40 * |
|
41 * With this API clients can |
|
42 * 1. Receive notifications from changes in cached |
|
43 * presence attributes. Cached presence attributes |
|
44 * are subscribed or fetched presence attributes |
|
45 * stored to presence cache. |
|
46 * |
|
47 * Notifications are triggered from: |
|
48 * - Attribute creation to presence cache when |
|
49 * the user is subscribed |
|
50 * |
|
51 * - Attribute value changes in presence cache |
|
52 * after receiving attribute notification from network |
|
53 * or attributes were manually fetched from network |
|
54 * |
|
55 * - Attribute removal from storage when user |
|
56 * attributes are unsubscribed or fetched |
|
57 * attributes are cleared. |
|
58 * |
|
59 * Thus, client can request presence notifications from |
|
60 * such Presence IDs and presence attributes that do not |
|
61 * exist yet in presence cache. Clients must be prepared |
|
62 * also to handle the cases that attribute doesn't anymore |
|
63 * exist in storage, if the notification was delivered due |
|
64 * attribute clearing from storage. |
|
65 * |
|
66 * 2. Receive notifications from user own attribute changes. |
|
67 * Notification from user own attributes is requested with |
|
68 * zero length PresenceID and they are also delivered with |
|
69 * zero length PresenceID. (See: KPEngUserOwnPresenceId from |
|
70 * PEngPresenceEngineConsts2.h) |
|
71 * |
|
72 * @lib PEngManager2.lib |
|
73 * @since 3.0 |
|
74 */ |
|
75 class CPEngPresenceNotifier2 : public CBase |
|
76 { |
|
77 //----------------------------------------------------------------------- |
|
78 public: /* Construction */ |
|
79 |
|
80 /** |
|
81 * Instantiates CPEngPresenceNotifier2 object. |
|
82 * |
|
83 * Instantiates CPEngPresenceNotifier2 object and connects it to |
|
84 * identified Presence Engine side NWSessionSlot. NWSessionSlot |
|
85 * must be a valid, existing slot. |
|
86 * |
|
87 * Errors: |
|
88 * - Requested NWSessionSlot not found: KErrNotFound |
|
89 * - Given NWSessionSlotID malformed: KErrArgument |
|
90 * |
|
91 * @param aNWSessionSlotID The session slot ID to identify the |
|
92 * session slot. |
|
93 * @param aPriority The priority for CPEngPresenceNotifier2 |
|
94 * client side active objects. These active objects are used when |
|
95 * asynchronously delivering events to observers. |
|
96 * |
|
97 * @return New CPEngPresenceNotifier2 instance. |
|
98 */ |
|
99 IMPORT_C static CPEngPresenceNotifier2* NewL( |
|
100 const CPEngNWSessionSlotID2& aNWSessionSlotID, |
|
101 TInt aPriority = CActive::EPriorityStandard ); |
|
102 |
|
103 IMPORT_C static CPEngPresenceNotifier2* NewLC( |
|
104 const CPEngNWSessionSlotID2& aNWSessionSlotID, |
|
105 TInt aPriority = CActive::EPriorityStandard ); |
|
106 |
|
107 |
|
108 /** |
|
109 * Destructor. |
|
110 * Virtual by CBase. |
|
111 */ |
|
112 ~CPEngPresenceNotifier2(); |
|
113 |
|
114 |
|
115 |
|
116 protected: |
|
117 |
|
118 /** |
|
119 * C++ constructor. |
|
120 */ |
|
121 CPEngPresenceNotifier2(); |
|
122 |
|
123 |
|
124 |
|
125 //----------------------------------------------------------------------- |
|
126 public: /* Basic Presence notifier */ |
|
127 |
|
128 /** |
|
129 * Check if the notifier is active. |
|
130 * |
|
131 * @since 3.0 |
|
132 * @return ETrue if the notifier is active. Else EFalse. |
|
133 */ |
|
134 IMPORT_C TBool IsActive() const; |
|
135 |
|
136 |
|
137 /** |
|
138 * Starts observing presence changes. |
|
139 * Ignores duplicate presence attributes. |
|
140 * |
|
141 * @since 3.0 |
|
142 * @param aPresenceID Presence ID which changes to track. |
|
143 * @param aTypes The attribute types to track. Attribute types |
|
144 * known by Presence Engine are listed in |
|
145 * PEngWVPresenceAttributes2.h. |
|
146 * |
|
147 * @return Result from observer start. |
|
148 * - KErrNone if notifier start succeeds. |
|
149 * - KErrNotSupported if attribute type isn't supported. |
|
150 * - KErrInUse if notifier already started. |
|
151 * - Else one of system wide error codes. |
|
152 */ |
|
153 IMPORT_C TInt Start( const TDesC& aPresenceID, |
|
154 const TArray<TUint32>& aTypes ); |
|
155 |
|
156 |
|
157 /** |
|
158 * Starts observing presence changes. |
|
159 * Ignores duplicate presence attributes and presence IDs. |
|
160 * Presence ID list can be empty. |
|
161 * |
|
162 * @since 3.0 |
|
163 * @param aPresenceIDs Presence IDs which changes to track. |
|
164 * @param aTypes The attribute types to track. Attribute types |
|
165 * known by Presence Engine are listed in |
|
166 * PEngWVPresenceAttributes2.h. |
|
167 * |
|
168 * @return Result from observer start. |
|
169 * - KErrNone if notifier start succeeds. |
|
170 * - KErrNotSupported if attribute type isn't supported. |
|
171 * - KErrInUse if notifier already started. |
|
172 * - Else one of system wide error codes. |
|
173 */ |
|
174 IMPORT_C TInt Start( const MDesCArray& aPresenceIDs, |
|
175 const TArray<TUint32>& aTypes ); |
|
176 |
|
177 |
|
178 /** |
|
179 * Starts observing presence changes. |
|
180 * Ignores duplicate presence attributes and presence IDs. |
|
181 * Presence ID list can be empty. |
|
182 * |
|
183 * @since 3.0 |
|
184 * @param aList The contact list from which to take |
|
185 * tracked Presence IDs. |
|
186 * @param aContactListView From which contact list |
|
187 * view to take observed contacts. |
|
188 * @param aTypes The attribute types to track. Attribute types |
|
189 * known by Presence Engine are listed in |
|
190 * PEngWVPresenceAttributes2.h. |
|
191 * |
|
192 * @return Result from observer start. |
|
193 * - KErrNone if notifier start succeeds. |
|
194 * - KErrNotSupported if attribute type isn't supported. |
|
195 * - KErrInUse if notifier already started. |
|
196 * - Else one of system wide error codes. |
|
197 */ |
|
198 IMPORT_C TInt Start( const MPEngContactList2& aList, |
|
199 TPEngContactListView aContactListView, |
|
200 const TArray<TUint32>& aTypes ); |
|
201 |
|
202 |
|
203 /** |
|
204 * Stops observing presence changes. |
|
205 * |
|
206 * @since 3.0 |
|
207 */ |
|
208 IMPORT_C void Stop(); |
|
209 |
|
210 |
|
211 |
|
212 //----------------------------------------------------------------------- |
|
213 public: /* Track list update */ |
|
214 |
|
215 /** |
|
216 * Updates the list of observed presence IDs. Replaces |
|
217 * list of tracked Presence ID's with given list. |
|
218 * (Same effect than using separated Stop() and Start() calls |
|
219 * but is much more efficient.) Uses presence attributes given |
|
220 * in CPEngPresenceNotifier2::Start(). Ignores duplicate |
|
221 * presence IDs. |
|
222 * |
|
223 * @since 3.0 |
|
224 * @param aPresenceIDs List of Presence IDs which changes to track. |
|
225 * |
|
226 * @return Result from observer start. |
|
227 * - KErrNone if notifier update succeeds. |
|
228 * - KErrNotReady if notifier not started. |
|
229 * - Else one of system wide error codes. |
|
230 */ |
|
231 IMPORT_C TInt Update( const MDesCArray& aPresenceIDs ); |
|
232 |
|
233 |
|
234 |
|
235 /** |
|
236 * Updates the list of observed presence IDs. Replaces |
|
237 * list of tracked Presence ID's with given list. |
|
238 * (Same effect than using separated Stop() and Start() calls |
|
239 * but is much more efficient.) Uses presence attributes given |
|
240 * in CPEngPresenceNotifier2::Start(). Ignores duplicate |
|
241 * presence IDs. |
|
242 * |
|
243 * @since 3.0 |
|
244 * @param aList The contact list from which to take |
|
245 * tracked Presence IDs. |
|
246 * @param aContactListView From which contact list |
|
247 * view to take observed contacts. |
|
248 * |
|
249 * @return Result from observer start. |
|
250 * - KErrNone if notifier update succeeds. |
|
251 * - KErrNotReady if notifier not started. |
|
252 * - Else one of system wide error codes. |
|
253 */ |
|
254 IMPORT_C TInt Update( const MPEngContactList2& aList, |
|
255 TPEngContactListView aContactListView ); |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 //----------------------------------------------------------------------- |
|
261 public: /* Presence ID and attribute handling */ |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 /** |
|
267 * Adds Presence ID to the list of tracked presences. |
|
268 * |
|
269 * @since 3.0 |
|
270 * @param aPresenceID Presence ID which changes to track. |
|
271 * If Presence ID is already tracked, new requested |
|
272 * attributes are added in the list of tracked attributes. |
|
273 * @param aTypes The attribute types to track. Attribute types |
|
274 * known by Presence Engine are listed in |
|
275 * PEngWVPresenceAttributes2.h. Ignores duplicate |
|
276 * presence attributes. |
|
277 * |
|
278 * @return Result from adding Presence ID. |
|
279 * - KErrNone if Presence ID add succeeds. |
|
280 * - KErrNotSupported if attribute type isn't supported. |
|
281 * - KErrNotReady if notifier not started. |
|
282 * - Else one of system wide error codes. |
|
283 */ |
|
284 IMPORT_C TInt Add( const TDesC& aPresenceID, |
|
285 const TArray<TUint32>& aTypes ); |
|
286 |
|
287 |
|
288 /** |
|
289 * Removes Presence ID from the list of tracked presences. |
|
290 * |
|
291 * @since 3.0 |
|
292 * @param aPresenceID Presence ID which tracking to stop. |
|
293 * |
|
294 * @return Result from removing Presence ID. |
|
295 * - KErrNone if Presence ID remove succeeds. |
|
296 * - KErrNotReady if notifier not started. |
|
297 * - KErrNotFound if Presence ID not tracked. |
|
298 * - Else one of system wide error codes. |
|
299 */ |
|
300 IMPORT_C TInt Remove( const TDesC& aPresenceID ); |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 /** |
|
306 * Removes Presence attribute from the list of tracked |
|
307 * attributes. Removes also such Presence IDs from |
|
308 * the tracked ones which do not have anymore tracked |
|
309 * attributes. |
|
310 * |
|
311 * @since 3.0 |
|
312 * @param aType Attribute type which tracking to stop. Attribute |
|
313 * types known by Presence Engine are listed in |
|
314 * PEngWVPresenceAttributes2.h. |
|
315 * |
|
316 * @return Result from removing attribute. |
|
317 * - KErrNone if attribute remove succeeds. |
|
318 * - KErrNotSupported if attribute type isn't supported. |
|
319 * - KErrNotReady if notifier not started. |
|
320 * - KErrNotFound if attribute not tracked. |
|
321 * - Else one of system wide error codes. |
|
322 */ |
|
323 IMPORT_C TInt Remove( TUint32 aType ); |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 //----------------------------------------------------------------------- |
|
329 public: /* Tracked presence IDs */ |
|
330 |
|
331 |
|
332 /** |
|
333 * Tracked Presence ID's. |
|
334 * |
|
335 * Gets the list of tracked Presence ID's. |
|
336 * Tracked Presence IDs can be iterated with: |
|
337 * - CPEngTrackedPresenceIDs2::FirstTrackedPresenceID() |
|
338 * - CPEngTrackedPresenceIDs2::NextTrackedPresenceID() |
|
339 * |
|
340 * List holds also information from last notified |
|
341 * changes. (Thus clients can access the notify information |
|
342 * also after notify callback has gone, without making a |
|
343 * copy from data. However, each new notification |
|
344 * overwrites the data from previous notification.) |
|
345 * |
|
346 * Last changed Presence ID's can be iterated with: |
|
347 * - CPEngTrackedPresenceIDs::FirstChangedPresenceID() |
|
348 * - CPEngTrackedPresenceIDs::NextChangedPresenceID() |
|
349 * |
|
350 * @since 3.0 |
|
351 * @return Collection of tracked Presence ID's. |
|
352 */ |
|
353 IMPORT_C const CPEngTrackedPresenceIDs2& TrackedPresenceIDs() const; |
|
354 IMPORT_C CPEngTrackedPresenceIDs2& TrackedPresenceIDs(); |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 //----------------------------------------------------------------------- |
|
360 public: /* Presence observers */ |
|
361 |
|
362 |
|
363 /** |
|
364 * Registers observer to be notified from presence changes. |
|
365 * |
|
366 * Observers are notified in their registeration order. |
|
367 * (First registerd notified first.) |
|
368 * |
|
369 * @param aObserver The observer to be notified. |
|
370 * Panics if NULL pointer passed. |
|
371 * @return KErrNone is observer added succesfully. |
|
372 * Else one of the system wide error codes. |
|
373 */ |
|
374 IMPORT_C TInt AddObserver( |
|
375 MPEngPresenceObserver2& aObserver ); |
|
376 |
|
377 |
|
378 |
|
379 /** |
|
380 * Unregisters presence observer. |
|
381 * |
|
382 * @param aObserver The observer to remove. |
|
383 * @return KErrNone is observer removed succesfully. |
|
384 * KErrNotFound if the observer wasn't registered. |
|
385 */ |
|
386 IMPORT_C TInt RemoveObserver( |
|
387 MPEngPresenceObserver2& aObserver ); |
|
388 |
|
389 |
|
390 |
|
391 //----------------------------------------------------------------------- |
|
392 private: /* Data */ |
|
393 |
|
394 |
|
395 //OWN: Implementation |
|
396 CPEngPresenceNotifier2Imp* iImp; |
|
397 |
|
398 |
|
399 }; |
|
400 |
|
401 #endif //__CPENGPRESENCENOTIFIER2_H |
|
402 |
|
403 // End of File |