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