simpledatamodeladapter/inc/presencepluginxdmutils.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 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 CPRESENCEPLUGINXDMUTILS_H
       
    20 #define CPRESENCEPLUGINXDMUTILS_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <ximpbase.h>
       
    24 #include <protocolpresenceauthorization.h>
       
    25 #include "presenceplugincommon.h"
       
    26 #include "mpresrulesasynchandler.h"
       
    27 #include "presencelogger.h"
       
    28 
       
    29 class CPresencePluginXdmPresRules;
       
    30 class TXIMPRequestId;
       
    31 class MXIMPIdentity;
       
    32 class MXIMPObjectCollection;
       
    33 class CXdmEngine;
       
    34 class CXdmDocument;
       
    35 class CXdmDocumentNode;
       
    36 class TRequestStatus;
       
    37 class MPresencePluginConnectionObs;
       
    38 
       
    39 /**
       
    40  * CPresencePluginXdmUtils
       
    41  *
       
    42  * Simple Engine Connection
       
    43  *
       
    44  * @lib presenceplugin.dll
       
    45  * @since S60 v3.2
       
    46  */
       
    47 NONSHARABLE_CLASS( CPresencePluginXdmUtils ) : public CActive,
       
    48     public MPresRulesAsyncHandler
       
    49     {
       
    50     public: // Constructor and destructor
       
    51 
       
    52         /**
       
    53          * Active object asynch states
       
    54          */
       
    55         enum TPluginXdmState
       
    56             {
       
    57             EStateIdle,
       
    58             /** Get XDM lists 1*/
       
    59             EGetXdmLists,
       
    60             /** Create XDM lists */
       
    61             ECreateXdmLists,
       
    62             /** Get XDM lists only, no rules later */
       
    63             EGetXdmListsOnly,
       
    64             /** Create XDM lists only, no rules later */
       
    65             ECreateXdmListsOnly,        
       
    66             /** Get RLS service */
       
    67             EGetRlsServices,
       
    68             /** Create RLS service */
       
    69             ECreateRlsServices,
       
    70             /** Update RLS service */
       
    71             EUpdateRlsServices,
       
    72             /** Get rules from server for GrantPresenceForPresentity */
       
    73             EGetXdmRules,
       
    74             /** Update rules to server for GrantPresenceForPresentity */
       
    75             EUpdateXdmRules,
       
    76             /** Update XDM List */
       
    77             EUpdateXdmList,
       
    78             /** Cancel XDM document operation */
       
    79             ECancelDocument,
       
    80             /** Get Block list */
       
    81             EGetXdmBlockList,
       
    82             /** Create presence rules */
       
    83             ECreateXdmRules,
       
    84             /** Subscripe block list */
       
    85             ESubsBlockList,
       
    86             EGetResourceListFromServer
       
    87             };
       
    88 
       
    89         /**
       
    90          * Current operation
       
    91          */
       
    92         enum TPluginXdmOperation
       
    93             {
       
    94             ENoOperation,
       
    95             EXdmInit,   
       
    96             EXdmDeleteAll,
       
    97             EXdmCancel,
       
    98             EXdmAddUserToGroup,
       
    99             EXdmAddGroupToGroup,
       
   100             EXdmRemoveUserFromGroup,
       
   101             EXdmRemoveGroupFromGroup,
       
   102             EXdmGrantForAll,
       
   103             EXdmWithdrawFromAll,
       
   104             EXdmGetBlockedList,
       
   105             EXdmCreateGroup,
       
   106             EXdmDeleteGroup,
       
   107             EXdmRlsFetch,
       
   108             EXdmRlsAdd,
       
   109             EXdmRlsRemove,
       
   110             EXdmCommitXdm,
       
   111             EXdmCommitRls,
       
   112             EXdmGetBuddyList,
       
   113             EXdmAddUserToRules,
       
   114             EXdmRemoveUserFromRules
       
   115             };
       
   116 
       
   117         /**
       
   118          * Operation state for rules update
       
   119          */
       
   120         enum TPluginPresRulesState
       
   121             {
       
   122             EStateNoOperation,
       
   123             EStateAddToWhiteList,
       
   124             EStateAddToBlockList,
       
   125             EStateRemoveFromWhiteList,
       
   126             EStateRemoveFromBlackList,
       
   127             EStateInitializeRules
       
   128             };
       
   129             
       
   130         /**
       
   131          * NewL
       
   132          * @param aObs callback for complete requests
       
   133          * @param aXdmId XDm settings id
       
   134          */
       
   135         static CPresencePluginXdmUtils* NewL(
       
   136             MPresencePluginConnectionObs& aObs,
       
   137             TInt aXmdId,
       
   138             TBool aLocalMode );
       
   139 
       
   140         virtual ~CPresencePluginXdmUtils();
       
   141 
       
   142         /**
       
   143          * Initialize XDMS and Presence XDM structures in network
       
   144          *
       
   145          * @since S60 3.2
       
   146          * @param aStatus Request status of the caller
       
   147          */
       
   148         void InitializeXdmL( TRequestStatus& aStatus );
       
   149         
       
   150         /**
       
   151          * Initialize XDMS in network
       
   152          *
       
   153          * @since S60 3.2
       
   154          * @param aStatus Request status of the caller
       
   155          */
       
   156         void InitializeXdmsOnlyL( TRequestStatus& aStatus );    
       
   157 
       
   158         /**
       
   159          * Initialize Presence rules document only
       
   160          *
       
   161          * @since S60 3.2        
       
   162          * @param aStatus Request status of the caller
       
   163          */
       
   164         void InitializePresRulesL( );
       
   165 
       
   166         /**
       
   167          * Add entity to granted list
       
   168          *
       
   169          * @since S60 3.2        
       
   170          * @param aUri, entity URL
       
   171          * @param aStatus, request status
       
   172          * @return none
       
   173          */
       
   174         void AddEntityToGrantedL( 
       
   175             const TDesC&  aUri,
       
   176             TRequestStatus& aStatus );
       
   177          
       
   178         /**
       
   179          * Remove entity from granted list
       
   180          *
       
   181          * @since S60 3.2        
       
   182          * @param aUri, entity URL
       
   183          * @param aStatus, request status
       
   184          * @return none
       
   185          */
       
   186         void RemoveEntityFromGrantedL( 
       
   187             const TDesC&  aUri,
       
   188             TRequestStatus& aStatus );
       
   189 
       
   190         /**
       
   191          * Remove entity from blocked list
       
   192          *
       
   193          * @since S60 3.2        
       
   194          * @param aName, entity URL
       
   195          * @param aStatus, request status
       
   196          * @return none
       
   197          */
       
   198         void RemoveEntityFromBlockedL( 
       
   199             const TDesC&  aName,
       
   200             TRequestStatus& aStatus );
       
   201         
       
   202         /**
       
   203          * Add entity to blocked list
       
   204          *
       
   205          * @since S60 3.2        
       
   206          * @param aUri, entity URL
       
   207          * @param aStatus, request status
       
   208          * @return none
       
   209          */
       
   210         void AddEntityToBlockedL( 
       
   211             const TDesC&  aUri,
       
   212             TRequestStatus& aStatus );
       
   213     
       
   214         /**
       
   215          * Get (subscribe) Block List
       
   216          *
       
   217          * @since S60 3.2        
       
   218          * @param aMembers, member list array
       
   219          * @return none
       
   220          */
       
   221         void SubscribeBlockListL( RPointerArray<MXIMPIdentity>& aMembers );
       
   222 
       
   223         /**
       
   224          * Get (subscribe) Buddy List
       
   225          *
       
   226          * @since S60 3.2        
       
   227          * @param aMembers, member list array
       
   228          * @return none
       
   229          */
       
   230         void SubscribeBuddyListL( RPointerArray<MXIMPIdentity>& aMembers );
       
   231         
       
   232         /**
       
   233          * GetUserListsL
       
   234          *
       
   235          * @since S60 3.2
       
   236          * @param aList, List name
       
   237          * @param aColl, XIMP object collection        
       
   238          */
       
   239         void GetEntitiesInListL(
       
   240             const TDesC&  aList, MXIMPObjectCollection& aColl );
       
   241         
       
   242         /**
       
   243          * Add identity to virtual list
       
   244          *
       
   245          * @since S60 3.2
       
   246          * @param aList, List name
       
   247          */
       
   248         void AddIdentityToVirtualListL(
       
   249             const TDesC&  aList );
       
   250         
       
   251        /**
       
   252         * CheckXdmDoc
       
   253         *
       
   254         * @since S60 3.2
       
   255         * @param none
       
   256         * @return TBool, state of xdm documents        
       
   257         */    
       
   258        TBool CheckXdmDoc();
       
   259     
       
   260     public: //From assync
       
   261         
       
   262         /**
       
   263          * Defined in a base class
       
   264          */
       
   265         void HandlePresUpdateDocumentL( TInt aErrorCode );
       
   266         
       
   267         /**
       
   268          * Defined in a base class
       
   269          */
       
   270         void HandlePresUpdateCancelL( TInt aErrorCode );
       
   271    
       
   272     private:
       
   273     
       
   274         /**
       
   275          * Standard C++ constructor
       
   276          *
       
   277          * @param aObs, plugin connection observer
       
   278          * @param aXmdId, XDM settings id 
       
   279          */ 
       
   280         CPresencePluginXdmUtils( 
       
   281         		MPresencePluginConnectionObs& aObs,
       
   282         		TInt aXmdId,
       
   283         		TBool aLocalmode );
       
   284 
       
   285         /**
       
   286          * Performs the 2nd phase of construction.
       
   287          */ 
       
   288         void ConstructL( );
       
   289 
       
   290     protected:// from base class CActive
       
   291 
       
   292         /**
       
   293          * Defined in a base class
       
   294          */
       
   295         void RunL();
       
   296 
       
   297         /**
       
   298          * Defined in a base class
       
   299          */
       
   300         TInt RunError( TInt aError );
       
   301 
       
   302         /**
       
   303          * Defined in a base class
       
   304          */
       
   305         void DoCancel();
       
   306 
       
   307     private:
       
   308     
       
   309         /**
       
   310          * DoUpdateXdmLists
       
   311          *
       
   312          * @since S60 3.2
       
   313          * @param aMyStatus, RunL status
       
   314          * @return aOrigState, xdm state
       
   315          */    
       
   316         void DoUpdateXdmListsL( TInt aMyStatus,
       
   317             TPluginXdmState aOrigState );
       
   318                 
       
   319         /**
       
   320          * DoGetXdmLists
       
   321          *
       
   322          * @since S60 3.2
       
   323          * @param aMyStatus, RunL status
       
   324          * @return aOrigState, xdm state
       
   325          */    
       
   326         void DoGetXdmListsL( TInt aMyStatus,
       
   327             TPluginXdmState aOrigState );
       
   328 
       
   329         /**
       
   330          * DoCreateXdmLists
       
   331          *
       
   332          * @since S60 3.2
       
   333          * @param aMyStatus, RunL status
       
   334          * @return aOrigState, xdm state
       
   335          */    
       
   336         void DoCreateXdmListsL( TInt aMyStatus,
       
   337             TPluginXdmState aOrigState,
       
   338             TBool aOnlyResourceList );
       
   339                
       
   340         /**
       
   341          * Search list under parent
       
   342          *
       
   343          * @since S60 3.2        
       
   344          * @param none
       
   345          * @return none
       
   346          */
       
   347         CXdmDocumentNode* SearchListUnderParentL(
       
   348             CXdmDocumentNode* aParent,
       
   349             const TDesC& aName );
       
   350 
       
   351         /**
       
   352          * Complete client request
       
   353          *
       
   354          * @since S60 3.2
       
   355          * @param aStatus, client status
       
   356          * @return none
       
   357          */    
       
   358         void CompleteClientReq( TInt aStatus );
       
   359 
       
   360         /**
       
   361          * Get XDM lists
       
   362          *
       
   363          * @since S60 3.2
       
   364          * @param aCreateRules, create new rule document
       
   365          * @param aLocalMode, use localmode
       
   366          * @return none
       
   367          */
       
   368         void GetXdmListsL( TBool aCreateRules, TBool aLocalMode );
       
   369 
       
   370         /**
       
   371          * Create XDM list document model
       
   372          *
       
   373          * @since S60 3.2
       
   374          * @param aCreateRules, create new rule document
       
   375          * @return none
       
   376          */
       
   377         void CreateXdmListsL( TBool aCreateRules );
       
   378 
       
   379         /**
       
   380          * Update document to server
       
   381          *
       
   382          * @since S60 3.2
       
   383          * @param none
       
   384          * @return none
       
   385          */
       
   386         void UpdateXdmToServerL();
       
   387           
       
   388         /**
       
   389          * Updates XDMS reource lists into server
       
   390          *
       
   391          * @since S60 3.2
       
   392          * @param none
       
   393          * @return none
       
   394          */  
       
   395         void UpdateXdmsL();
       
   396         
       
   397         /**
       
   398          * Updates XDM rules
       
   399          *
       
   400          * @since S60 3.2
       
   401          * @param none
       
   402          * @return none
       
   403          */        
       
   404         void UpdateXdmRulesL();
       
   405         
       
   406         /**
       
   407          * Get XDM rules
       
   408          *
       
   409          * @since S60 3.2
       
   410          * @param none
       
   411          * @return none
       
   412          */         
       
   413         void GetXdmRulesL();
       
   414                  
       
   415         /**
       
   416          * Handle presence document 
       
   417          *
       
   418          * @since S60 3.2        
       
   419          * @param aList, list name
       
   420          * @param aUser, entity name
       
   421          * @return none
       
   422          */
       
   423         void DoHandlePresUpdateDocumentL( TInt aErrorCode );
       
   424 
       
   425         /**
       
   426          * Add User to resource list
       
   427          *
       
   428          * @since S60 3.2
       
   429          * @param aList, list name
       
   430          * @param aName, url         
       
   431          */
       
   432         void DoAddUserToListL(
       
   433             const TDesC& aList,
       
   434             const TDesC&  aName );
       
   435         
       
   436         /**
       
   437          * Remove user from list
       
   438          *
       
   439          * @since S60 3.2
       
   440          * @param aList, list name
       
   441          * @param aUser, entity name
       
   442          * @return none
       
   443          */
       
   444         void DoRemoveUserFromListL(
       
   445             const TDesC& aList,
       
   446             const TDesC&  aName );
       
   447 
       
   448         /**
       
   449          * Get member list
       
   450          *
       
   451          * @since S60 3.2
       
   452          * @param aList, list name
       
   453          * @param aMembers, member array
       
   454          * @return none
       
   455          */
       
   456         void DoGetListMembersL(
       
   457             const TDesC& aList,
       
   458             RPointerArray<MXIMPIdentity>& aMembers  );
       
   459 
       
   460         /**
       
   461          * Get buddy list
       
   462          *
       
   463          * @since S60 3.2
       
   464          * @param aList, list name
       
   465          * @return XDM document
       
   466          */
       
   467         CXdmDocumentNode* DoGetBuddyListL( const TDesC& aParent);
       
   468 
       
   469         /**
       
   470          * Get buddy list
       
   471          *
       
   472          * @since S60 3.2
       
   473          * @param aList, list name
       
   474          * @parma aBuddyList, xdm document node
       
   475          * @return XDM document
       
   476          */
       
   477         CXdmDocumentNode* DoGetUserListL(
       
   478             const TDesC& aList,
       
   479             CXdmDocumentNode* aBuddyList );
       
   480         
       
   481         /**
       
   482          * Check XDM errors
       
   483          *
       
   484          * @since S60 3.2
       
   485          * @param aMyStatus, XDM error code
       
   486          * @return errorcode
       
   487          */    
       
   488         TInt CheckIfErrorL( TInt aMyStatus );
       
   489 
       
   490         /**
       
   491          * Check if entity already exist
       
   492          *
       
   493          * @since S60 3.2
       
   494          * @param aList, listname
       
   495          * @param aUri, entity url
       
   496          * @return TBool
       
   497          */
       
   498         TBool CheckIfEnityExistL( const TDesC& aList, const TDesC&  aUri );
       
   499         
       
   500         /**
       
   501          * Update document from server
       
   502          *
       
   503          * @since S60 3.2
       
   504          * @param none
       
   505          * @return none
       
   506          */
       
   507         void UpdateFromServerL();
       
   508         
       
   509     private: // Data
       
   510 
       
   511         /**
       
   512          * ximp Plugin connection observer
       
   513          * Own.
       
   514          */
       
   515         MPresencePluginConnectionObs& iConnObs;
       
   516 
       
   517         /**
       
   518          * XDM Settings id
       
   519          * Own.
       
   520          */
       
   521         TInt iSettingsId;
       
   522 
       
   523         /**
       
   524          * ximp request id
       
   525          * Own.         
       
   526          */
       
   527         TXIMPRequestId iximpId;
       
   528 
       
   529         /**
       
   530          * ximp request id for own requests
       
   531          * Own.         
       
   532          */
       
   533         TXIMPRequestId iximpIdOwn;
       
   534 
       
   535         /**
       
   536          * Simple Engine request id
       
   537          * Own.         
       
   538          */
       
   539         TInt iSimpleId;
       
   540 
       
   541         /**
       
   542          * XDM Engine
       
   543          * Own.
       
   544          */
       
   545         CXdmEngine* iXdmEngine;
       
   546 
       
   547         /**
       
   548          * XDM document for resource-lists
       
   549          * Own.
       
   550          */
       
   551         CXdmDocument* iXdmDoc;
       
   552        
       
   553         /**
       
   554          * Current state
       
   555          * Own.         
       
   556          */
       
   557         TPluginXdmState iXdmState;
       
   558          
       
   559         /**
       
   560          * Current operation
       
   561          * Own.         
       
   562          */
       
   563         TPluginXdmOperation iOperation;
       
   564 
       
   565         /**
       
   566          * Whether Presence XDM is up-to-date
       
   567          * Own.         
       
   568          */
       
   569         TBool iPresXdmOk;
       
   570 
       
   571         /**
       
   572          * Whether XDM is up-to-date
       
   573          * Own.         
       
   574          */
       
   575         TBool iXdmOk;
       
   576 
       
   577         /**
       
   578          * client statutus.
       
   579          * Not own.
       
   580          */
       
   581         TRequestStatus* iClientStatus;
       
   582            
       
   583         /**
       
   584          * XDM presence rules handling
       
   585          * own.
       
   586          */
       
   587         CPresencePluginXdmPresRules*  iXdmPresRules;
       
   588         
       
   589         /**
       
   590          * Entity uri
       
   591          * Own.         
       
   592          */
       
   593         HBufC* iEntityUri;
       
   594         
       
   595         /**
       
   596          * TPluginPresRulesUpdateState
       
   597          * Own.         
       
   598          */
       
   599         TPluginPresRulesState iRulesUpdateState;
       
   600         
       
   601         /**
       
   602          * XDM localmode
       
   603          * Own.         
       
   604          */
       
   605         TBool iLocalMode;
       
   606         
       
   607         SIMPLE_UNIT_TEST( T_CPresencePluginGroups )
       
   608         SIMPLE_UNIT_TEST( T_CPresencePluginWatcher )
       
   609         SIMPLE_UNIT_TEST( T_CPresencePluginAuthorization )
       
   610         SIMPLE_UNIT_TEST( T_CPresencePluginXdmUtils )
       
   611     };
       
   612 
       
   613 #endif // CPRESENCEPLUGINXDMUTILS_H