ximpfw/tsrc/tsrcprotocols/pr_prfwtestprotocol/pr_prfwtestprotocol.h
changeset 0 e6b17d312c8b
equal deleted inserted replaced
-1:000000000000 0:e6b17d312c8b
       
     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:  Test Protocol implementation for XIMP Framework
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef T_PRFWTESTPROTOCOL_H
       
    20 #define T_PRFWTESTPROTOCOL_H
       
    21 
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 #include <ximpprotocolpluginbase.h>
       
    26 #include <protocolpresencepublishing.h>
       
    27 #include <protocolpresencewatching.h>
       
    28 #include <protocolpresenceauthorization.h>
       
    29 #include <protocolpresentitygroups.h>
       
    30 #include <protocolpresencefeatures.h>
       
    31 #include <ximpprotocolconnection.h>
       
    32 #include <ximpprotocolconnectionhostobserver.h>
       
    33 #include <ximpbase.h>
       
    34 
       
    35 #include "prfwwaitobserver.h"
       
    36 
       
    37 #include "prfwtestmessaging.h"
       
    38 
       
    39 class CXIMPTestGeneralWaiter;
       
    40 class CXIMPTestMessenger;
       
    41 class CPeriodic;
       
    42 class CXIMPTestFileLogicHelper;
       
    43 class CXIMPTestFileTool;
       
    44 class MXIMPRestrictedObjectCollection;
       
    45 class MProtocolImFeatures;
       
    46 #define PRIMP_CLSID_CPRESENTITYGROUPINFOIMP 15000
       
    47 
       
    48 class T_XIMPTestConnection :public CBase,
       
    49                             public MXIMPProtocolConnection,
       
    50                             public MProtocolPresenceFeatures,
       
    51                             public MProtocolPresencePublishing,
       
    52                             public MProtocolPresenceWatching,
       
    53                             public MProtocolPresenceAuthorization,
       
    54                             public MProtocolPresentityGroups,
       
    55                             public MXIMPProtocolConnectionHostObserver,
       
    56                             public T_MWaitObserver
       
    57                             
       
    58     {
       
    59     public:
       
    60     /** The class ID. */
       
    61     enum { KClassId = PRIMP_CLSID_CPRESENTITYGROUPINFOIMP };
       
    62 
       
    63 
       
    64         class ClientWrapper : public CBase
       
    65             {
       
    66             private:
       
    67 
       
    68                 void ConstructL( const TDesC& aClientId );
       
    69 
       
    70             public:
       
    71 
       
    72                 static ClientWrapper* NewLC( const TDesC& aClientId );
       
    73                 void InitializeL( MXIMPProtocolConnectionHost& aConnectionHost );
       
    74                 ~ClientWrapper();
       
    75 
       
    76             public:
       
    77 
       
    78                 RBuf iId;
       
    79                 CXIMPTestFileTool* iFileTool;
       
    80                 CXIMPTestMessenger* iMessenger;
       
    81                 CXIMPTestFileLogicHelper* iFileLogicHelper;
       
    82                 TInt iPluginIndex;
       
    83             };
       
    84 
       
    85     public:
       
    86 
       
    87         static T_XIMPTestConnection* NewL( const MXIMPServiceInfo& aServiceInfo,
       
    88                                            const MXIMPContextClientInfo& aClientCtxInfo );
       
    89         static T_XIMPTestConnection* NewLC( const MXIMPServiceInfo& aServiceInfo,
       
    90                                             const MXIMPContextClientInfo& aClientCtxInfo );
       
    91 
       
    92         ~T_XIMPTestConnection();
       
    93 
       
    94 
       
    95     private:
       
    96 
       
    97         T_XIMPTestConnection();
       
    98         void ConstructL( const MXIMPServiceInfo& aServiceInfo,
       
    99                          const MXIMPContextClientInfo& aClientCtxInfo );
       
   100 
       
   101     public: // From MXIMPProtocolConnection
       
   102 
       
   103         /**
       
   104          * host for connection
       
   105          */
       
   106         void PrimeHost( MXIMPProtocolConnectionHost& aHost );
       
   107 
       
   108         void OpenSessionL( const MXIMPContextClientInfo& aClientCtxInfo,
       
   109                                TXIMPRequestId aReqId  );
       
   110 
       
   111         
       
   112         void OpenSessionL(
       
   113                 const TInt& aSettingsId,
       
   114                 TXIMPRequestId aReqId );
       
   115 
       
   116         void CloseSession( const MXIMPContextClientInfo& aClientCtxInfo,
       
   117                                TXIMPRequestId aReqId );
       
   118                                
       
   119         MProtocolPresenceFeatures& ProtocolPresenceFeatures();
       
   120 		
       
   121 		//MProtocolImFeatures* ProtocolImFeatures();
       
   122 		
       
   123 		TAny* GetProtocolInterface(TInt aInterfaceId);
       
   124 		
       
   125     public: // MProtocolPresenceFeatures
       
   126         MProtocolPresenceWatching& PresenceWatching();
       
   127         MProtocolPresencePublishing& PresencePublishing();
       
   128         MProtocolPresentityGroups& PresentityGroups();
       
   129         MProtocolPresenceAuthorization& PresenceAuthorization();
       
   130         
       
   131         
       
   132     public: // From MXIMPProtocolConnectionHostObserver        
       
   133     
       
   134         void HandleProtocolConnectionHostEvent(
       
   135                 const MXIMPProtocolConnectionHost& aHost,
       
   136                 const MXIMPBase& aEvent );
       
   137 
       
   138 
       
   139     public: // from MPscPlugin
       
   140 
       
   141 
       
   142         void GetSupportedFeaturesL(
       
   143                 CDesC8Array& aFeatures ) const;
       
   144 
       
   145         void DoPublishOwnPresenceL(
       
   146                 const MPresenceInfo& aPresence,
       
   147                 TXIMPRequestId aReqId );
       
   148 
       
   149         void DoSubscribeOwnPresenceL( const MPresenceInfoFilter& aPif,
       
   150                                           TXIMPRequestId aReqId );
       
   151 
       
   152         void DoUnsubscribeOwnPresenceL( TXIMPRequestId aReqId );
       
   153 
       
   154         void DoUpdateOwnPresenceSubscriptionPifL( const MPresenceInfoFilter& aPif,
       
   155                                           TXIMPRequestId aReqId );
       
   156 
       
   157 
       
   158         void DoSubscribePresenceWatcherListL( TXIMPRequestId aReqId );
       
   159         void DoUnsubscribePresenceWatcherListL( TXIMPRequestId aReqId );
       
   160 
       
   161         void DoSubscribePresentityGroupListL( TXIMPRequestId aReqId );
       
   162         void DoUnsubscribePresentityGroupListL( TXIMPRequestId aReqId );
       
   163 
       
   164         void DoCreatePresentityGroupL( const MXIMPIdentity& aIdentity,
       
   165                                            const TDesC16& aDisplayName,
       
   166                                            TXIMPRequestId aReqId );
       
   167         void DoDeletePresentityGroupL( const MXIMPIdentity& aIdentity,
       
   168                                                TXIMPRequestId aReqId );
       
   169         void DoUpdatePresentityGroupDisplayNameL( const MXIMPIdentity& aIdentity,
       
   170                                                const TDesC16& aDisplayName,
       
   171                                                TXIMPRequestId aReqId );
       
   172         void DoSubscribePresentityPresenceL(
       
   173                                     const MXIMPIdentity& aIdentity,
       
   174                                     const MPresenceInfoFilter& aPif,
       
   175                                     TXIMPRequestId aReqId );
       
   176         void DoUpdatePresentityPresenceSubscriptionPifL(
       
   177                                     const MXIMPIdentity& aIdentity,
       
   178                                     const MPresenceInfoFilter& aPif,
       
   179                                     TXIMPRequestId aReqId );
       
   180         void DoUnsubscribePresentityPresenceL( const MXIMPIdentity& aIdentity,
       
   181                                     TXIMPRequestId aReqId );
       
   182 
       
   183         void DoSubscribePresentityGroupContentL( const MXIMPIdentity& aGroupId,
       
   184                                                      TXIMPRequestId aReqId );
       
   185 
       
   186         void DoUnsubscribePresentityGroupContentL( const MXIMPIdentity& aGroupId,
       
   187                                                        TXIMPRequestId aReqId );
       
   188 
       
   189         void DoAddPresentityGroupMemberL( const MXIMPIdentity& aGroupId,
       
   190                                               const MXIMPIdentity& aMemberId,
       
   191                                               const TDesC16& aMemberDisplayName,
       
   192                                               TXIMPRequestId aReqId );
       
   193 
       
   194         void DoRemovePresentityGroupMemberL( const MXIMPIdentity& aGroupId,
       
   195                                                  const MXIMPIdentity& aMemberId,
       
   196                                                  TXIMPRequestId aReqId );
       
   197 
       
   198         void DoUpdatePresentityGroupMemberDisplayNameL( const MXIMPIdentity& aGroupId,
       
   199                                                             const MXIMPIdentity& aMemberId,
       
   200                                                             const TDesC16& aMemberDisplayName,
       
   201                                                             TXIMPRequestId aReqId );
       
   202         void DoSubscribePresentityGroupMembersPresenceL(
       
   203                                         const MXIMPIdentity& aIdentity,
       
   204                                         const MPresenceInfoFilter& aPif,
       
   205                                         TXIMPRequestId aReqId );
       
   206 
       
   207         void DoUpdatePresentityGroupMembersPresenceSubscriptionPifL(
       
   208                                         const MXIMPIdentity& aIdentity,
       
   209                                         const MPresenceInfoFilter& aPif,
       
   210                                         TXIMPRequestId aReqId );
       
   211 
       
   212         void DoUnsubscribePresentityGroupMembersPresenceL( const MXIMPIdentity& aIdentity,
       
   213                                         TXIMPRequestId aReqId );
       
   214 
       
   215         void DoSubscribePresenceGrantRequestListL( TXIMPRequestId aReqId );
       
   216 
       
   217         void DoUnsubscribePresenceGrantRequestListL( TXIMPRequestId aReqId );
       
   218 
       
   219         void DoGrantPresenceForPresentityL( const MXIMPIdentity& aIdentity,
       
   220                                                    const MPresenceInfoFilter& aPif,
       
   221                                                    TXIMPRequestId aReqId );
       
   222         void DoGrantPresenceForPresentityGroupMembersL( const MXIMPIdentity& aGroupId,
       
   223                                                                 const MPresenceInfoFilter& aPif,
       
   224                                                                 TXIMPRequestId aReqId );
       
   225 
       
   226         void DoGrantPresenceForEveryoneL( const MPresenceInfoFilter& aPif,
       
   227                                             TXIMPRequestId aReqId );
       
   228 
       
   229         void DoUpdatePresenceGrantPifForPresentityL( const MXIMPIdentity& aIdentity,
       
   230                                                    const MPresenceInfoFilter& aPif,
       
   231                                                    TXIMPRequestId aReqId );
       
   232 
       
   233         void DoUpdatePresenceGrantPifForPresentityGroupMembersL( const MXIMPIdentity& aGroupId,
       
   234                                                                 const MPresenceInfoFilter& aPif,
       
   235                                                                 TXIMPRequestId aReqId );
       
   236 
       
   237         void DoUpdatePresenceGrantPifForEveryoneL( const MPresenceInfoFilter& aPif,
       
   238                                                    TXIMPRequestId aReqId );
       
   239 
       
   240         void DoWithdrawPresenceGrantFromPresentityL( const MXIMPIdentity& aIdentity, TXIMPRequestId aReqId );
       
   241 
       
   242         void DoWithdrawPresenceGrantFromPresentityGroupMembersL( const MXIMPIdentity& aGroupId,
       
   243                                                                     TXIMPRequestId aReqId );
       
   244 
       
   245         void DoWithdrawPresenceGrantFromEveryoneL( TXIMPRequestId aReqId );
       
   246 
       
   247         void DoSubscribePresenceBlockListL( TXIMPRequestId aReqId );
       
   248         void DoUnsubscribePresenceBlockListL( TXIMPRequestId aReqId );
       
   249         void DoBlockPresenceForPresentityL( const MXIMPIdentity& aPresentityId,
       
   250                                             TXIMPRequestId aReqId );
       
   251         void DoCancelPresenceBlockFromPresentityL( const MXIMPIdentity& aPresentityId,
       
   252                                                    TXIMPRequestId aReqId );
       
   253 
       
   254     public: // from T_MWaitObserver
       
   255 
       
   256         void WaitCompleted( TInt aRetVal );
       
   257 
       
   258 
       
   259     public: // from MXIMPBase
       
   260 
       
   261         TAny* GetInterface(
       
   262                 TInt32 aInterfaceId,
       
   263                 TIfGetOps aOptions );
       
   264 
       
   265         const TAny* GetInterface(
       
   266                 TInt32 aInterfaceId,
       
   267                 TIfGetOps aOptions ) const;
       
   268 
       
   269         TInt32 GetInterfaceId() const;
       
   270 
       
   271     private:
       
   272         /**
       
   273          * All plugin API methods should call this method
       
   274          * to handle test code to plugin communication
       
   275          * properly.
       
   276          * Add more common stuff here (such as new special messages
       
   277          * which behave in a common way to all plugin API calls, etc.)
       
   278          * @param aOpId The request id
       
   279          */
       
   280         void PluginAPIMethodCommonL( TXIMPRequestId& aOpId );
       
   281 
       
   282         /**
       
   283          * Callback for aux timer
       
   284          * @see TCallBack
       
   285          */
       
   286         static TInt ReconnectSimulator( TAny* aMyself );
       
   287 
       
   288         /**
       
   289          * Actual callback called from ReconnectSimulator
       
   290          */
       
   291         void DoReconnectSimulator();
       
   292 
       
   293         /**
       
   294          * Leaving version of aux timer callback.
       
   295          */
       
   296         void DoReconnectSimulatorL();
       
   297 
       
   298         void SetBooleanToCurrent( TXIMPTestPropertyKeys aKey );
       
   299         void SetBoolean( TXIMPTestPropertyKeys aKey );
       
   300 
       
   301     public:
       
   302         static TInt OrderOfConnections( const T_XIMPTestConnection& aFirst,
       
   303                                         const T_XIMPTestConnection& aSecond );
       
   304 
       
   305     private:
       
   306 
       
   307         static TInt OrderOfClients( const ClientWrapper& aFirst,
       
   308                                     const ClientWrapper& aSecond );
       
   309     private:
       
   310 
       
   311         HBufC* iServerAddress;
       
   312         HBufC* iUserName;
       
   313         HBufC* iPassword;
       
   314         HBufC* iClientId;
       
   315 
       
   316         //TInt iConnectedClients;
       
   317 
       
   318         RPointerArray< ClientWrapper > iClients;
       
   319         ClientWrapper* iClientToBeDeleted;
       
   320 
       
   321         TXIMPRequestId iReqId;
       
   322         CXIMPTestGeneralWaiter* iWaitter;
       
   323 
       
   324         MXIMPStatus* iStatus;
       
   325 
       
   326         // last received message
       
   327         TXIMPTestMsg iLastMsg;
       
   328 
       
   329         // ETrue if reconnect is to be faked for session lost.
       
   330         TBool iSessionLostReconnect;
       
   331 
       
   332         // ETrue if all reconnects are to be failed.
       
   333         TBool iSessionLostFailReconnects;
       
   334 
       
   335         // auxiliary timer (session lost simulation)
       
   336         CPeriodic* iAuxTimer;
       
   337 
       
   338 
       
   339         /**
       
   340          * File tool for monitoring events.
       
   341          */
       
   342         //CXIMPTestFileTool* iFileTool;
       
   343 
       
   344         /**
       
   345          * Host for connection
       
   346          */
       
   347         MXIMPProtocolConnectionHost* iConnectionHost;
       
   348 
       
   349         CXIMPTestMessenger* iCurrentMessenger;
       
   350     };
       
   351 
       
   352 /**
       
   353  * Example protocol plugin
       
   354  *
       
   355  *
       
   356  * @lib ?library
       
   357  * @since S60 v4.0
       
   358  */
       
   359 class T_XIMPTestProtocol : public CXIMPProtocolPluginBase
       
   360     {
       
   361     public:
       
   362 
       
   363         static T_XIMPTestProtocol* NewL();
       
   364         static T_XIMPTestProtocol* NewLC();
       
   365 
       
   366         ~T_XIMPTestProtocol();
       
   367 
       
   368     private:
       
   369 
       
   370         T_XIMPTestProtocol();
       
   371         void ConstructL();
       
   372 
       
   373     public: // From MXIMPProtocolPlugin
       
   374 
       
   375         void PrimeHost( MXIMPProtocolPluginHost& aHost );
       
   376 
       
   377         MXIMPProtocolConnection& AcquireConnectionL(
       
   378                     const MXIMPServiceInfo& aServiceInfo,
       
   379                     const MXIMPContextClientInfo& aClientCtxInfo );
       
   380         void ReleaseConnection(
       
   381                         MXIMPProtocolConnection& aConnection );
       
   382 
       
   383     public: // from MXIMPBase
       
   384 
       
   385         TAny* GetInterface(
       
   386                 TInt32 aInterfaceId,
       
   387                 TIfGetOps aOptions );
       
   388 
       
   389         const TAny* GetInterface(
       
   390                 TInt32 aInterfaceId,
       
   391                 TIfGetOps aOptions ) const;
       
   392 
       
   393         TInt32 GetInterfaceId() const;
       
   394 
       
   395 
       
   396     private: // Data
       
   397 
       
   398         // Prime host
       
   399         MXIMPProtocolPluginHost* iHost;
       
   400         RXIMPObjOwningPtrArray< T_XIMPTestConnection > iConnections;
       
   401     };
       
   402 
       
   403 #endif // T_PRFWTESTPROTOCOL_H