|
1 /* |
|
2 * Copyright (c) 2006 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: Simple Protocol implementation for Presence Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CSIMPLEPLUGINPUBLISHER_H |
|
22 #define CSIMPLEPLUGINPUBLISHER_H |
|
23 |
|
24 #include <e32std.h> |
|
25 |
|
26 #include <ximpbase.h> |
|
27 #include <protocolpresencepublishing.h> |
|
28 |
|
29 #include <msimplepublishobserver.h> |
|
30 #include <msimplewatcherobserver.h> |
|
31 |
|
32 #include "simpleplugincommon.h" |
|
33 #include "msimplepluginconnectionobs.h" |
|
34 #include "msimplepluginsettings.h" |
|
35 |
|
36 class TXIMPRequestId; |
|
37 class MXIMPIdentity; |
|
38 class MXIMPProtocolConnectionHost; |
|
39 |
|
40 class MPersonPresenceInfo; |
|
41 class MServicePresenceInfo; |
|
42 class MDevicePresenceInfo; |
|
43 |
|
44 class MSimplePublisher; |
|
45 class MSimpleDocument; |
|
46 class MSimpleWinfo; |
|
47 class MSimpleWatcher; |
|
48 class MSimpleElement; |
|
49 |
|
50 |
|
51 /** |
|
52 * CSimplePluginWatcherInfo |
|
53 * |
|
54 * watcher info. |
|
55 * |
|
56 * @lib ?library |
|
57 * @since s60 v5.0 |
|
58 */ |
|
59 NONSHARABLE_CLASS( CSimplePluginWatcherInfo ): public CBase |
|
60 { |
|
61 public: |
|
62 |
|
63 /** |
|
64 * Constructor. |
|
65 * @param aId watcher id |
|
66 * @param aSipId watcher SIP identity |
|
67 */ |
|
68 static CSimplePluginWatcherInfo* NewL( |
|
69 const TDesC8& aId, |
|
70 const TDesC& aSipId ); |
|
71 |
|
72 virtual ~CSimplePluginWatcherInfo(); |
|
73 |
|
74 /** |
|
75 * Destructor |
|
76 */ |
|
77 void Destroy(); |
|
78 |
|
79 /** |
|
80 * Match to given info |
|
81 * @param aId watcher id |
|
82 * @param aSipId watcher SIP identity |
|
83 * @return ETrue if current entity matches to the parameters |
|
84 */ |
|
85 TBool Match( const TDesC8& aId, |
|
86 const TDesC& aSipId ); |
|
87 |
|
88 TPtrC SipId(); |
|
89 |
|
90 inline static TInt LinkOffset(); |
|
91 |
|
92 private: |
|
93 |
|
94 CSimplePluginWatcherInfo( ); |
|
95 |
|
96 /** |
|
97 * Constructor |
|
98 * @param aId watcher id |
|
99 * @param aSipId watcher SIP identity |
|
100 */ |
|
101 void ConstructL( |
|
102 const TDesC8& aId, |
|
103 const TDesC& aSipId ); |
|
104 |
|
105 public: // data |
|
106 |
|
107 TDblQueLink iLink; |
|
108 |
|
109 private: // data |
|
110 |
|
111 HBufC8* iId; |
|
112 HBufC* iSipId; |
|
113 |
|
114 }; |
|
115 |
|
116 /** |
|
117 * CSimplePluginPublisher |
|
118 * |
|
119 * publisher. |
|
120 * |
|
121 * @lib ?library |
|
122 * @since s60 v5.0 |
|
123 */ |
|
124 NONSHARABLE_CLASS( CSimplePluginPublisher ): public CActive, |
|
125 public MSimplePublishObserver, |
|
126 public MSimpleWatcherObserver, |
|
127 public MProtocolPresencePublishing |
|
128 { |
|
129 public: |
|
130 |
|
131 /** |
|
132 * Current operation |
|
133 */ |
|
134 enum TPluginPublishOperation |
|
135 { |
|
136 ENoOperation, |
|
137 EPublishOwn, |
|
138 ESubscribeOwn, |
|
139 EUnsubscribeOwn, |
|
140 ESubscribeWinfo, |
|
141 EUnsubscribeWinfo |
|
142 }; |
|
143 |
|
144 /** |
|
145 * Constructor. |
|
146 * @param aConnSetts current settings |
|
147 * @param aObs callback for complete requests |
|
148 * @param aConn Simple Engine connection |
|
149 */ |
|
150 static CSimplePluginPublisher* NewL( |
|
151 MSimplePluginSettings& aConnSetts, |
|
152 MSimplePluginConnectionObs& aObs, |
|
153 MSimpleConnection& aConn ); |
|
154 |
|
155 virtual ~CSimplePluginPublisher(); |
|
156 |
|
157 /** |
|
158 * WinfoTerminatedL |
|
159 * |
|
160 * SIMPLE Winfo watcher sunscription is terminated |
|
161 * @param aReason reason code |
|
162 */ |
|
163 void WinfoTerminatedL( TInt aReason ); |
|
164 |
|
165 /** |
|
166 * WINFO received from SIMPLE |
|
167 * @param aWinfo WINFO |
|
168 */ |
|
169 void WinfoNotificationL( MSimpleWinfo& aWinfo ); |
|
170 |
|
171 private: |
|
172 |
|
173 CSimplePluginPublisher( |
|
174 MSimplePluginSettings& aConnSetts, |
|
175 MSimplePluginConnectionObs& aObs, |
|
176 MSimpleConnection& aConn ); |
|
177 |
|
178 void ConstructL( ); |
|
179 |
|
180 |
|
181 public: |
|
182 |
|
183 // from base class MSimplePublishObserver |
|
184 |
|
185 /** |
|
186 * Defined in a base class |
|
187 */ |
|
188 void PublishReqCompleteL( TInt aOpid, TInt aStatus); |
|
189 |
|
190 /** |
|
191 * Defined in a base class |
|
192 */ |
|
193 void PublishTerminatedL( TInt aOpid ); |
|
194 |
|
195 // from base class MSimpleWatcherObserver |
|
196 |
|
197 /** |
|
198 * Defined in a base class |
|
199 */ |
|
200 void WatcherReqCompleteL( TInt aOpId, TInt aStatus ); |
|
201 |
|
202 /** |
|
203 * Defined in a base class |
|
204 */ |
|
205 void WatcherNotificationL( MSimpleDocument& aDocument ); |
|
206 |
|
207 /** |
|
208 * Defined in a base class |
|
209 */ |
|
210 void WatcherListNotificationL( MSimplePresenceList& aList ); |
|
211 |
|
212 /** |
|
213 * Defined in a base class |
|
214 */ |
|
215 void WatcherTerminatedL( |
|
216 TInt aOpId, TInt aReason ); |
|
217 |
|
218 |
|
219 // from base class MXIMPBase |
|
220 public: |
|
221 |
|
222 /** |
|
223 * Defined in a base class |
|
224 */ |
|
225 TAny* GetInterface( |
|
226 TInt32 aInterfaceId, |
|
227 TIfGetOps aOps ); |
|
228 |
|
229 /** |
|
230 * Defined in a base class |
|
231 */ |
|
232 const TAny* GetInterface( |
|
233 TInt32 aInterfaceId, |
|
234 TIfGetOps aOps ) const; |
|
235 |
|
236 /** |
|
237 * Defined in a base class |
|
238 */ |
|
239 TInt32 GetInterfaceId() const; |
|
240 |
|
241 |
|
242 // from base class MProtocolPresencePublishing |
|
243 public: |
|
244 |
|
245 /** |
|
246 * Defined in a base class |
|
247 */ |
|
248 void DoPublishOwnPresenceL( |
|
249 const MPresenceInfo& aOwnPresence, |
|
250 TXIMPRequestId aReqId ); |
|
251 |
|
252 /** |
|
253 * Defined in a base class |
|
254 */ |
|
255 void DoSubscribeOwnPresenceL( |
|
256 const MPresenceInfoFilter& aPif, |
|
257 TXIMPRequestId aReqId ); |
|
258 |
|
259 /** |
|
260 * Defined in a base class |
|
261 */ |
|
262 void DoUpdateOwnPresenceSubscriptionPifL( |
|
263 const MPresenceInfoFilter& aPif, |
|
264 TXIMPRequestId aReqId ); |
|
265 |
|
266 /** |
|
267 * Defined in a base class |
|
268 */ |
|
269 void DoUnsubscribeOwnPresenceL( |
|
270 TXIMPRequestId aReqId ); |
|
271 |
|
272 /** |
|
273 * Defined in a base class |
|
274 */ |
|
275 void DoSubscribePresenceWatcherListL( |
|
276 TXIMPRequestId aReqId ); |
|
277 |
|
278 /** |
|
279 * Defined in a base class |
|
280 */ |
|
281 void DoUnsubscribePresenceWatcherListL( |
|
282 TXIMPRequestId aReqId ); |
|
283 |
|
284 |
|
285 protected: |
|
286 |
|
287 // from base class CActive |
|
288 |
|
289 /** |
|
290 * Defined in a base class |
|
291 */ |
|
292 void RunL(); |
|
293 |
|
294 /** |
|
295 * Defined in a base class |
|
296 */ |
|
297 TInt RunError( TInt aError ); |
|
298 |
|
299 /** |
|
300 * Defined in a base class |
|
301 */ |
|
302 void DoCancel(); |
|
303 |
|
304 private: |
|
305 |
|
306 |
|
307 /** |
|
308 * Calls MXIMPProtocolConnectionHost callback |
|
309 * @param aStatus error status |
|
310 */ |
|
311 void CompletePrFwReq( TInt aStatus ); |
|
312 |
|
313 /** |
|
314 * Initialize a document |
|
315 */ |
|
316 void InitializeSimpleDocumentL( ); |
|
317 |
|
318 /** |
|
319 * Add person information to the document. |
|
320 * @param aPersInfo personal information |
|
321 */ |
|
322 void AddSimpleDocumentPersL( |
|
323 const MPersonPresenceInfo* aInfo ); |
|
324 |
|
325 void AddSimpleDocumentServiceL( |
|
326 const MServicePresenceInfo& aInfo ); |
|
327 |
|
328 void AddSimpleDocumentDeviceL( |
|
329 const MDevicePresenceInfo& aInfo ); |
|
330 |
|
331 /** |
|
332 * Make a publish request |
|
333 */ |
|
334 void MakePublishReqL(); |
|
335 |
|
336 /** |
|
337 * Start XDM initialization |
|
338 */ |
|
339 void StartXdmOperationL( TXIMPRequestId aReqId ); |
|
340 |
|
341 /** |
|
342 * Start XDM initialization. StartXdmOperationL calls this. |
|
343 */ |
|
344 void DoStartXdmOperationL( TXIMPRequestId aReqId ); |
|
345 |
|
346 /** |
|
347 * Delete watcher information |
|
348 */ |
|
349 void DeleteWatchers(); |
|
350 |
|
351 void AddWatcherIfNotExistsL( const TDesC8& aId, const TDesC& aSipId ); |
|
352 |
|
353 void RemoveWatcherIfExistsL( const TDesC8& aId, const TDesC& aSipId ); |
|
354 |
|
355 CDesCArrayFlat* MakeCurrentWatcherListLC(); |
|
356 |
|
357 |
|
358 /** |
|
359 * Update private data member of active watchers list |
|
360 * @param aElems SIMPLE elements [IN] |
|
361 */ |
|
362 void UpdateActiveWatchersListL( |
|
363 RPointerArray<MSimpleElement>& aElems ); |
|
364 |
|
365 |
|
366 private: // Data |
|
367 |
|
368 /** |
|
369 * PrFw Plugin connection observer |
|
370 */ |
|
371 MSimplePluginConnectionObs& iConnObs; |
|
372 |
|
373 /** |
|
374 * Current settings |
|
375 */ |
|
376 MSimplePluginSettings& iConnSets; |
|
377 |
|
378 /** |
|
379 * SIMPLE engine connection |
|
380 */ |
|
381 MSimpleConnection& iConnection; |
|
382 |
|
383 /** |
|
384 * SIMPLE engine publisher |
|
385 * Own. |
|
386 */ |
|
387 MSimplePublisher* iPublisher; |
|
388 |
|
389 /** |
|
390 * SIMPLE engine watcher |
|
391 * Own. |
|
392 */ |
|
393 MSimpleWatcher* iWatcher; |
|
394 |
|
395 /** |
|
396 * PrFW request id |
|
397 */ |
|
398 TXIMPRequestId iPrFwId; |
|
399 |
|
400 /** |
|
401 * Simple Engine request id |
|
402 */ |
|
403 TInt iSimpleId; |
|
404 |
|
405 /** |
|
406 * Subscribed winfo |
|
407 */ |
|
408 TBool iSubscribed; |
|
409 |
|
410 /** |
|
411 * Subscribed own data |
|
412 */ |
|
413 TBool iSubscribedOwn; |
|
414 |
|
415 /** |
|
416 * Published own data |
|
417 */ |
|
418 TBool iPublished; |
|
419 |
|
420 /** |
|
421 * Current operation |
|
422 */ |
|
423 TPluginPublishOperation iOperation; |
|
424 |
|
425 /** |
|
426 * Simple publish document |
|
427 * Own. |
|
428 */ |
|
429 MSimpleDocument* iDocument; |
|
430 |
|
431 /** |
|
432 * XDM Utils |
|
433 * Not own. |
|
434 */ |
|
435 CSimplePluginXdmUtils* iXdmUtils; |
|
436 |
|
437 /** |
|
438 * WINFO watchers |
|
439 * Own. |
|
440 */ |
|
441 TDblQue<CSimplePluginWatcherInfo> iWatcherList; |
|
442 |
|
443 }; |
|
444 |
|
445 TInt CSimplePluginWatcherInfo::LinkOffset() |
|
446 { |
|
447 return _FOFF(CSimplePluginWatcherInfo, iLink); |
|
448 } |
|
449 |
|
450 #endif // CSimplePluginPublisher_H |