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