|
1 /* |
|
2 * Copyright (c) 2006-2010 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: IETF SIMPLE Protocol implementation for XIMP Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CPRESENCEPLUGINAUTHORIZATION_H |
|
20 #define CPRESENCEPLUGINAUTHORIZATION_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <ximpbase.h> |
|
24 #include <protocolpresenceauthorization.h> |
|
25 #include "mpresencepluginconnectionobs.h" |
|
26 #include "presenceplugincontactsobs.h" |
|
27 #include "presencelogger.h" |
|
28 |
|
29 class TXIMPRequestId; |
|
30 class MXIMPIdentity; |
|
31 class MPresenceInfoFilter; |
|
32 class MProtocolPresenceAuthorizationDataHost; |
|
33 class MSimpleWinfo; |
|
34 class CPresencePluginData; |
|
35 class CPresencePluginContacts; |
|
36 |
|
37 /** |
|
38 * CPresencePluginAuthorization |
|
39 * |
|
40 * Simple Engine Connection |
|
41 * |
|
42 * @lib presenceplugin.dll |
|
43 * @since S60 v3.2 |
|
44 */ |
|
45 NONSHARABLE_CLASS( CPresencePluginAuthorization ) : |
|
46 public CActive, |
|
47 public MProtocolPresenceAuthorization, |
|
48 public MPresencePluginContactsObs |
|
49 { |
|
50 public: // Constructor and destructor |
|
51 |
|
52 /** |
|
53 * Current operation |
|
54 */ |
|
55 enum TPluginAuthOperation |
|
56 { |
|
57 ENoOperation, |
|
58 EGrantPresenceForPresentity, |
|
59 EGrantPresenceForPresentityGroupMembers, |
|
60 EWithdrawFromPresentity, |
|
61 EWithdrawFromGroupMembers, |
|
62 EGrantForEveryone, |
|
63 EWithdrawFromEveryone, |
|
64 ESubscribeBlockList, |
|
65 EUnsubscribeBlockList, |
|
66 EBlockPresentity, |
|
67 EUnblockPresentity |
|
68 }; |
|
69 |
|
70 /** |
|
71 * Block state |
|
72 */ |
|
73 enum TPluginAuthState |
|
74 { |
|
75 EStateIdle, |
|
76 EStateBlocked, |
|
77 EStateDoBlock, |
|
78 EStateIsContactBlockedBuddyRequest, |
|
79 EStateDoUnBlock, |
|
80 EStatePresenceGranted, |
|
81 EStateRemovePresentityFromGranted, |
|
82 EStateAcceptBuddyRequest |
|
83 }; |
|
84 |
|
85 /** |
|
86 * Constructor. |
|
87 * @param aObs callback for complete requests |
|
88 */ |
|
89 static CPresencePluginAuthorization* NewL( |
|
90 MPresencePluginConnectionObs& aObs, |
|
91 CPresencePluginData* aPresenceData ); |
|
92 |
|
93 /** |
|
94 * Standard C++ destructor |
|
95 */ |
|
96 virtual ~CPresencePluginAuthorization(); |
|
97 |
|
98 /** |
|
99 * SetDataHost |
|
100 * |
|
101 * @since S60 3.2 |
|
102 * @param aDataHost, XIMP Plugin Authorization Data Host |
|
103 */ |
|
104 void SetDataHost( MProtocolPresenceAuthorizationDataHost& aDataHost ); |
|
105 |
|
106 /** |
|
107 * WinfoTerminatedL |
|
108 * |
|
109 * @since S60 3.2 |
|
110 * SIMPLE Winfo watcher sunscription is terminated |
|
111 * @param aReason reason code |
|
112 */ |
|
113 void WinfoTerminatedL( TInt aReason ); |
|
114 |
|
115 /** |
|
116 * WINFO received from SIMPLE |
|
117 * @since S60 3.2 |
|
118 * @param aWinfo WINFO |
|
119 */ |
|
120 void WinfoNotificationL( MSimpleWinfo& aWinfo ); |
|
121 |
|
122 /** |
|
123 * Return List subscribe state |
|
124 * |
|
125 * @since S60 3.2 |
|
126 * @param none |
|
127 * @return TBool subscribe state |
|
128 */ |
|
129 TBool ReturnListSubsState(); |
|
130 |
|
131 /** |
|
132 * Returns plugin data handler. |
|
133 * |
|
134 * @since S60 5.0 |
|
135 * @param none |
|
136 * @return CPresencePluginData data handler reference |
|
137 */ |
|
138 CPresencePluginData& PluginData(); |
|
139 |
|
140 /** |
|
141 * Internal grant operation for group operation. |
|
142 * |
|
143 * @since S60 5.0 |
|
144 * @param aPresentityId, identity to be subscribed |
|
145 * @param aClientStatus, client status to be completed |
|
146 * @return none |
|
147 */ |
|
148 void DoPerformGrantPresenceForPresentityL( |
|
149 const MXIMPIdentity& aPresentityId, |
|
150 TRequestStatus& aClientStatus ); |
|
151 |
|
152 /** |
|
153 * Internal withdraw grant operation for group operation. |
|
154 * |
|
155 * @since S60 5.0 |
|
156 * @param aPresentityId, identity to be ungranted |
|
157 * @param aClientStatus, client status to be completed |
|
158 * @return none |
|
159 */ |
|
160 void DoPerformWithdrawPresGrantFromPresentityL( |
|
161 const MXIMPIdentity& aPresentityId, |
|
162 TRequestStatus& aClientStatus ); |
|
163 |
|
164 /** |
|
165 * Internal block operation for group operation. |
|
166 * |
|
167 * @since S60 5.0 |
|
168 * @param aPresentityId, identity to be blocked |
|
169 * @param aClientStatus, client status to be completed |
|
170 * @return none |
|
171 */ |
|
172 void DoPerformBlockPresenceForPresentityL( |
|
173 const MXIMPIdentity& aPresentityId, |
|
174 TRequestStatus& aClientStatus ); |
|
175 |
|
176 /** |
|
177 * Internal unblock operation for group operation. |
|
178 * |
|
179 * @since S60 5.0 |
|
180 * @param aPresentityId, identity to be unblocked |
|
181 * @param aClientStatus, client status to be completed |
|
182 * @return none |
|
183 */ |
|
184 void DoPerformCancelPresenceBlockFromPresentityL( |
|
185 const MXIMPIdentity& aPresentityId, |
|
186 TRequestStatus& aClientStatus ); |
|
187 |
|
188 /** |
|
189 * Resolve is blocked contact a blocked friend request |
|
190 * |
|
191 * @since S60 5.0 |
|
192 * @param aPresenceId, identity to be resolved |
|
193 * @param aObserver, Returns results |
|
194 * @param aStatus, client status |
|
195 */ |
|
196 void IsBlockedContactFriendRequestL( |
|
197 const TDesC& aPresenceId, |
|
198 MPresencePluginContactsObs& aObserver, |
|
199 TRequestStatus& aStatus ); |
|
200 |
|
201 private: |
|
202 |
|
203 /** |
|
204 * Standard C++ constructor |
|
205 * @param aObs callback for complete requests |
|
206 */ |
|
207 CPresencePluginAuthorization( |
|
208 MPresencePluginConnectionObs& aObs, |
|
209 CPresencePluginData* aPresenceData ); |
|
210 |
|
211 void ConstructL(); |
|
212 |
|
213 public: // from base class MXIMPBase |
|
214 |
|
215 /** |
|
216 * Defined in a base class |
|
217 */ |
|
218 TAny* GetInterface( |
|
219 TInt32 aInterfaceId, |
|
220 TIfGetOps aOps ); |
|
221 |
|
222 /** |
|
223 * Defined in a base class |
|
224 */ |
|
225 const TAny* GetInterface( |
|
226 TInt32 aInterfaceId, |
|
227 TIfGetOps aOps ) const; |
|
228 |
|
229 /** |
|
230 * Defined in a base class |
|
231 */ |
|
232 TInt32 GetInterfaceId() const; |
|
233 |
|
234 |
|
235 public: // from base class MXIMPProtocolPresenceAuthorization |
|
236 |
|
237 /** |
|
238 * Defined in a base class |
|
239 */ |
|
240 void DoSubscribePresenceGrantRequestListL( |
|
241 TXIMPRequestId aReqId ); |
|
242 |
|
243 /** |
|
244 * Defined in a base class |
|
245 */ |
|
246 void DoUnsubscribePresenceGrantRequestListL( |
|
247 TXIMPRequestId aReqId ); |
|
248 |
|
249 // Granting presence information access to single presentities |
|
250 |
|
251 /** |
|
252 * Defined in a base class |
|
253 */ |
|
254 void DoGrantPresenceForPresentityL( |
|
255 const MXIMPIdentity& aPresentityId, |
|
256 const MPresenceInfoFilter& aPif, |
|
257 TXIMPRequestId aReqId ); |
|
258 |
|
259 /** |
|
260 * Defined in a base class |
|
261 */ |
|
262 void DoUpdatePresenceGrantPifForPresentityL( |
|
263 const MXIMPIdentity& aPresentityId, |
|
264 const MPresenceInfoFilter& aPif, |
|
265 TXIMPRequestId aReqId ); |
|
266 |
|
267 /** |
|
268 * Defined in a base class |
|
269 */ |
|
270 void DoWithdrawPresenceGrantFromPresentityL( |
|
271 const MXIMPIdentity& aPresentityId, |
|
272 TXIMPRequestId aReqId ); |
|
273 |
|
274 // Granting presence information access to presentity group members |
|
275 |
|
276 /** |
|
277 * Defined in a base class |
|
278 */ |
|
279 void DoGrantPresenceForPresentityGroupMembersL( |
|
280 const MXIMPIdentity& aGroupId, |
|
281 const MPresenceInfoFilter& aPif, |
|
282 TXIMPRequestId aReqId ); |
|
283 |
|
284 /** |
|
285 * Defined in a base class |
|
286 */ |
|
287 void DoUpdatePresenceGrantPifForPresentityGroupMembersL( |
|
288 const MXIMPIdentity& aGroupId, |
|
289 const MPresenceInfoFilter& aPif, |
|
290 TXIMPRequestId aReqId ); |
|
291 |
|
292 /** |
|
293 * Defined in a base class |
|
294 */ |
|
295 void DoWithdrawPresenceGrantFromPresentityGroupMembersL( |
|
296 const MXIMPIdentity& aGroupId, |
|
297 TXIMPRequestId aReqId ); |
|
298 |
|
299 // Granting presence information access to everyone |
|
300 |
|
301 /** |
|
302 * Defined in a base class |
|
303 */ |
|
304 void DoGrantPresenceForEveryoneL( |
|
305 const MPresenceInfoFilter& aPif, |
|
306 TXIMPRequestId aReqId ); |
|
307 |
|
308 /** |
|
309 * Defined in a base class |
|
310 */ |
|
311 void DoUpdatePresenceGrantPifForEveryoneL( |
|
312 const MPresenceInfoFilter& aPif, |
|
313 TXIMPRequestId aReqId ); |
|
314 |
|
315 /** |
|
316 * Defined in a base class |
|
317 */ |
|
318 void DoWithdrawPresenceGrantFromEveryoneL( |
|
319 TXIMPRequestId aReqId ); |
|
320 |
|
321 // Subscribe presence block list |
|
322 |
|
323 /** |
|
324 * Defined in a base class |
|
325 */ |
|
326 void DoSubscribePresenceBlockListL( |
|
327 TXIMPRequestId aReqId ); |
|
328 |
|
329 /** |
|
330 * Defined in a base class |
|
331 */ |
|
332 void DoUnsubscribePresenceBlockListL( |
|
333 TXIMPRequestId aReqId ); |
|
334 |
|
335 // Blocking presence information access from single presentities |
|
336 |
|
337 /** |
|
338 * Defined in a base class |
|
339 */ |
|
340 void DoBlockPresenceForPresentityL( |
|
341 const MXIMPIdentity& aPresentityId, |
|
342 TXIMPRequestId aReqId ); |
|
343 |
|
344 /** |
|
345 * Defined in a base class |
|
346 */ |
|
347 void DoCancelPresenceBlockFromPresentityL( |
|
348 const MXIMPIdentity& aPresentityId, |
|
349 TXIMPRequestId aReqId ); |
|
350 |
|
351 public: // MPresencePluginContactsObs |
|
352 |
|
353 /** |
|
354 * Request Complete |
|
355 * |
|
356 * @param aResult Result data returned, ownership changed to client. |
|
357 * In operation EOperationIsPresenceStoredToContacts |
|
358 * return type is TBool*. |
|
359 * @param aOperation Operation type |
|
360 * @param aError Completion error code |
|
361 */ |
|
362 void RequestComplete( TAny* aResult, |
|
363 TPresenceContactsOperation aOperation, TInt aError ); |
|
364 |
|
365 protected: // from base class CActive |
|
366 |
|
367 /** |
|
368 * Defined in a base class |
|
369 */ |
|
370 void RunL(); |
|
371 |
|
372 /** |
|
373 * Defined in a base class |
|
374 */ |
|
375 TInt RunError( TInt aError ); |
|
376 |
|
377 /** |
|
378 * Defined in a base class |
|
379 */ |
|
380 void DoCancel(); |
|
381 |
|
382 private: |
|
383 |
|
384 /** |
|
385 * Save presentity id |
|
386 * |
|
387 * @since S60 3.2 |
|
388 * @param aPresentityId presentity id |
|
389 * @param aFormatUri, attempt to format URI (set |
|
390 * ETrue is aPresentityId is uri identity) |
|
391 * @return none |
|
392 */ |
|
393 void SetPresIdentityL( |
|
394 const MXIMPIdentity& aPresentityId, |
|
395 TBool aFormatUri ); |
|
396 |
|
397 /** |
|
398 * Complete client request |
|
399 * |
|
400 * @since S60 3.2 |
|
401 * @param aStatus |
|
402 * @return none |
|
403 */ |
|
404 void CompleteXIMPReq( TInt aStatus ); |
|
405 |
|
406 /** |
|
407 * Start XDM operation |
|
408 * |
|
409 * @since S60 3.2 |
|
410 * @param aId, XIMP identity |
|
411 * @param aReqId, request id |
|
412 * @param aOperation, plugin operation |
|
413 * @return none |
|
414 */ |
|
415 void StartXdmOperationL( |
|
416 const MXIMPIdentity& aId, |
|
417 TXIMPRequestId aReqId, |
|
418 TPluginAuthOperation aOperation ); |
|
419 |
|
420 /** |
|
421 * Start XDM operation |
|
422 * |
|
423 * @since S60 5.0 |
|
424 * @param aId, XIMP identity |
|
425 * @param aOperation, plugin operation |
|
426 * @param aClientStatus, client status to complete |
|
427 * @return none |
|
428 */ |
|
429 void StartXdmOperationL( |
|
430 const MXIMPIdentity& aId, |
|
431 TPluginAuthOperation aOperation, |
|
432 TRequestStatus& aClientStatus ); |
|
433 |
|
434 /** |
|
435 * Call actual xdm operation from xdm utils |
|
436 * |
|
437 * @since S60 3.2 |
|
438 * @param none |
|
439 * @return none |
|
440 */ |
|
441 void CallActualXdmOperationL(); |
|
442 |
|
443 /** |
|
444 * Subscribe block list |
|
445 * |
|
446 * @since S60 3.2 |
|
447 * @param none |
|
448 * @return none |
|
449 */ |
|
450 void SubscribeBlockListL( ); |
|
451 |
|
452 /** |
|
453 * Unsubscribe block list |
|
454 * |
|
455 * @since S60 3.2 |
|
456 * @param none |
|
457 * @return none |
|
458 */ |
|
459 void UnSubscribeBlockListL(); |
|
460 |
|
461 /** |
|
462 * Handle full winfo notification |
|
463 * |
|
464 * @since S60 3.2 |
|
465 * @param MSimpleWinfo winfo notification |
|
466 * @return none |
|
467 */ |
|
468 void HandleFullWinfoNotificationL( MSimpleWinfo& aWinfo ); |
|
469 |
|
470 /** |
|
471 * Handle partial winfo notification |
|
472 * |
|
473 * @since S60 3.2 |
|
474 * @param MSimpleWinfo winfo notification |
|
475 * @return none |
|
476 */ |
|
477 void HandlePartialWinfoNotificationL( MSimpleWinfo& aWinfo ); |
|
478 |
|
479 /** |
|
480 * Handle received grant request |
|
481 * |
|
482 * @since S60 3.2 |
|
483 * @param TDesC userid |
|
484 * @return none |
|
485 */ |
|
486 void CallHandlePresenceGrantRequestReceivedL( const TDesC& aUserId ); |
|
487 |
|
488 /** |
|
489 * Handle obsolated grantrequest |
|
490 * |
|
491 * @since S60 3.2 |
|
492 * @param TDesC userid |
|
493 * @return none |
|
494 */ |
|
495 void CallHandlePresenceGrantRequestObsoletedL( const TDesC& aUserId ); |
|
496 |
|
497 /** |
|
498 * Grant presence for presentity |
|
499 * |
|
500 * @since S60 3.2 |
|
501 * @param none |
|
502 * @return none |
|
503 */ |
|
504 void GrantPresenceForPresentityL(); |
|
505 |
|
506 /** |
|
507 * Withdraw from presentity |
|
508 * |
|
509 * @since S60 3.2 |
|
510 * @param none |
|
511 * @return none |
|
512 */ |
|
513 void WithdrawFromPresentityL(); |
|
514 |
|
515 /** |
|
516 * Set presentity blocked to XIMP |
|
517 * |
|
518 * @since S60 5.1 |
|
519 * @param none |
|
520 * @return none |
|
521 */ |
|
522 void SetPresentityBlockedToXIMPL(); |
|
523 |
|
524 /** |
|
525 * Block presentity |
|
526 * |
|
527 * @since S60 3.2 |
|
528 * @param none |
|
529 * @return none |
|
530 */ |
|
531 void BlockPresentityL(); |
|
532 |
|
533 /** |
|
534 * Unblock presentity |
|
535 * |
|
536 * @since S60 3.2 |
|
537 * @param none |
|
538 * @return none |
|
539 */ |
|
540 void UnblockPresentityL(); |
|
541 |
|
542 /** |
|
543 * Unsubscribe presentity presence |
|
544 * |
|
545 * @since S60 3.2 |
|
546 * @param none |
|
547 * @return none |
|
548 */ |
|
549 void UnsubscribePresentityPresenceL(); |
|
550 |
|
551 private: // Data |
|
552 |
|
553 /** |
|
554 * XIMP Plugin connection observer |
|
555 * Own. |
|
556 */ |
|
557 MPresencePluginConnectionObs& iConnObs; |
|
558 |
|
559 /** |
|
560 * XIMP Plugin Authorization Data Host |
|
561 * Not own. |
|
562 */ |
|
563 MProtocolPresenceAuthorizationDataHost* iDataHost; |
|
564 |
|
565 /** |
|
566 * XDM Settings id |
|
567 * Own. |
|
568 */ |
|
569 TInt iSettingsId; |
|
570 |
|
571 /** |
|
572 * PrFW request id |
|
573 * Own. |
|
574 */ |
|
575 TXIMPRequestId iXIMPId; |
|
576 |
|
577 /** |
|
578 * PrFW request id for own requests |
|
579 * Own. |
|
580 */ |
|
581 TXIMPRequestId iXIMPIdOwn; |
|
582 |
|
583 /** |
|
584 * Simple Engine request id |
|
585 * Own. |
|
586 */ |
|
587 TInt iSimpleId; |
|
588 |
|
589 /** |
|
590 * Subscribed items. |
|
591 * Own. |
|
592 */ |
|
593 TBool iSubscribed; |
|
594 |
|
595 /** |
|
596 * Current operation |
|
597 * Own. |
|
598 */ |
|
599 TPluginAuthOperation iOperation; |
|
600 |
|
601 /** |
|
602 * Current presentity in progress |
|
603 * Own. |
|
604 */ |
|
605 HBufC16* iPresIdentity; |
|
606 |
|
607 /** |
|
608 * Whether Presence XDM is up-to-date |
|
609 * Own. |
|
610 */ |
|
611 TBool iXdmOk; |
|
612 |
|
613 /** |
|
614 * XDM Utils |
|
615 * Not own. |
|
616 */ |
|
617 CPresencePluginXdmUtils* iXdmUtils; |
|
618 |
|
619 /** |
|
620 * Authorization complete |
|
621 * Own. |
|
622 */ |
|
623 TBool iComplete; |
|
624 |
|
625 /** |
|
626 * Presence Data |
|
627 * Not Own |
|
628 */ |
|
629 CPresencePluginData* iPresenceData; |
|
630 |
|
631 /** |
|
632 * client statutus. |
|
633 * Not own. |
|
634 */ |
|
635 TRequestStatus* iClientStatus; |
|
636 |
|
637 /** |
|
638 * Block state. |
|
639 * Own. |
|
640 */ |
|
641 TPluginAuthState iAuthState; |
|
642 |
|
643 /* |
|
644 * Virtual phone book contact database operations |
|
645 * Own. |
|
646 */ |
|
647 CPresencePluginContacts* iContacts; |
|
648 |
|
649 /* |
|
650 * Data Returned by CPresencePluginContacts |
|
651 */ |
|
652 TBool iContactIsStored; |
|
653 |
|
654 SIMPLE_UNIT_TEST( T_CPresencePluginAuthorization ) |
|
655 SIMPLE_UNIT_TEST( T_CPresencePluginXdmUtils ) |
|
656 |
|
657 }; |
|
658 |
|
659 #endif // CPresencePluginAuthorization_H |