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