simpledatamodeladapter/inc/presencepluginwatcher.h
branchGCC_SURGE
changeset 28 d9861ae9169c
parent 23 77cb48a03620
parent 26 04ca1926b01c
equal deleted inserted replaced
23:77cb48a03620 28:d9861ae9169c
     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 CPRESENCEPLUGINWATCHER_H
       
    20 #define CPRESENCEPLUGINWATCHER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <s32strm.h>
       
    24 #include <ximpbase.h>
       
    25 #include <protocolpresencewatching.h>
       
    26 
       
    27 #include "mpresencepluginconnectionobs.h"
       
    28 #include "presencelogger.h"
       
    29 
       
    30 class TXIMPRequestId;
       
    31 class MXIMPIdentity;
       
    32 class MXIMPProtocolConnectionHost;
       
    33 class MSimpleConnection;
       
    34 class CPresencePluginEntityWatcher;
       
    35 class CPresencePluginData;
       
    36 
       
    37 /**
       
    38  * CPresencePluginWatcher
       
    39  *
       
    40  * Simple Engine Connection
       
    41  *
       
    42  * @lib presenceplugin.dll
       
    43  * @since S60 v3.2
       
    44  */
       
    45 NONSHARABLE_CLASS( CPresencePluginWatcher ): public CActive,
       
    46     public MProtocolPresenceWatching
       
    47     {
       
    48     public:
       
    49 
       
    50         /**
       
    51          * Current operation
       
    52          */
       
    53         enum TPluginWatcherOperation
       
    54             {
       
    55             EPluginUndef,
       
    56             EPluginSubscribeGroup,
       
    57             EPluginUnsubscribeGroup,
       
    58             EPluginSubscribeSingle,
       
    59             EPluginSubscribeByAdding,
       
    60             EPluginUnSubscribeByRemoving
       
    61             };
       
    62             
       
    63         /**
       
    64          * Current actibe object state
       
    65          */
       
    66         enum TPluginXdmState
       
    67             {
       
    68             EPluginIdle,
       
    69             EPluginInitXdm,
       
    70             EPluginFetchRls,
       
    71             EPluginAddGroupMember,
       
    72             EPluginRemoveGroupMember
       
    73             };        
       
    74 
       
    75         /**
       
    76          * Constructor.
       
    77          * @param aObs callback for complete requests
       
    78          * @param aConn Simple Engine connection
       
    79          */ 
       
    80         static CPresencePluginWatcher* NewL(
       
    81             MPresencePluginConnectionObs& aObs,
       
    82             MSimpleConnection& aConn,
       
    83             CPresencePluginData* aPresenceData );
       
    84         
       
    85         /**
       
    86          * Standard C++ destructor
       
    87          */ 
       
    88         virtual ~CPresencePluginWatcher();
       
    89 
       
    90         /**
       
    91          * SIP Watcher is complets it's task.
       
    92          * @param aStatus error status
       
    93          * @return none         
       
    94          */
       
    95         void CompleteWatcher( TInt aStatus );
       
    96 
       
    97         /**
       
    98          * Delete a single entity watcher
       
    99          * @param aPresentityid presentity id
       
   100          * @return none         
       
   101          */
       
   102         void DeleteWatcher(
       
   103             const TDesC8& aPresentityid );
       
   104         
       
   105         /**
       
   106          * SubscribeL()
       
   107          *
       
   108          * @since S60 5.1
       
   109          * @param aIdentity presentity id to subscribe
       
   110          * @return none
       
   111          */
       
   112         void SubscribeL( const TDesC& aIdentity );
       
   113         
       
   114         /**
       
   115          * SubscribeAllL()
       
   116          *
       
   117          * @since S60 3.2
       
   118          * @param none
       
   119          * @return none
       
   120          */
       
   121         void SubscribeAllL();
       
   122         
       
   123         /**
       
   124          * UnSubscribeAllL()
       
   125          *
       
   126          * @since S60 3.2
       
   127          * @param none
       
   128          * @return none
       
   129          */
       
   130         void UnSubscribeAllL(); 
       
   131         
       
   132         /**
       
   133          * Subscribes presentity presence.
       
   134          *
       
   135          * @since S60 5.0
       
   136          * @param aPresentityId, presentity id
       
   137          * @param aStatus, client status to complete
       
   138          * @return none
       
   139          */            
       
   140         void DoPerformSubscribePresentityPresenceL(
       
   141             const MXIMPIdentity& aPresentityId,
       
   142             TRequestStatus& aStatus );    
       
   143             
       
   144         /**
       
   145          * Unsubscribes presentity presence.
       
   146          *
       
   147          * @since S60 5.0
       
   148          * @param aPresentityId, presentity id
       
   149          * @param aStatus, client status to complete
       
   150          * @return none
       
   151          */            
       
   152         void DoPerformUnsubscribePresentityPresenceL(
       
   153             const MXIMPIdentity& aPresentityId,
       
   154             TRequestStatus& aStatus );
       
   155               
       
   156         /**
       
   157          * Accept watcher to watcher list
       
   158          *
       
   159          * @since S60 5.1
       
   160          * @param aWatcher, watcher
       
   161          * @return none
       
   162          */
       
   163         void AcceptL( const CPresencePluginEntityWatcher* aWatcher );
       
   164         
       
   165     private:
       
   166 
       
   167         /**
       
   168          * Standard C++ constructor
       
   169          * @param aObs, Presence plugin connection
       
   170          * @param aConn, SIMPLE connection             
       
   171          */ 
       
   172         CPresencePluginWatcher(
       
   173             MPresencePluginConnectionObs& aObs,
       
   174             MSimpleConnection& aConn,
       
   175             CPresencePluginData* aPresenceData );
       
   176             
       
   177     public: // from base class MXIMPBase
       
   178 
       
   179         /**
       
   180          * Defined in a base class
       
   181          */
       
   182         TAny* GetInterface(
       
   183             TInt32 aInterfaceId,
       
   184             TIfGetOps aOps );
       
   185 
       
   186         /**
       
   187          * Defined in a base class
       
   188          */
       
   189         const TAny* GetInterface(
       
   190             TInt32 aInterfaceId,
       
   191             TIfGetOps aOps ) const;
       
   192 
       
   193         /**
       
   194          * Defined in a base class
       
   195          */
       
   196         TInt32 GetInterfaceId() const;
       
   197         
       
   198     public: // from base class MXIMPProtocolPresenceWatching
       
   199 
       
   200         /**
       
   201          * Defined in a base class
       
   202          */
       
   203         void DoSubscribePresentityPresenceL(
       
   204             const MXIMPIdentity& aPresentityId,
       
   205             const MPresenceInfoFilter& aPif,
       
   206             TXIMPRequestId aReqId );
       
   207 
       
   208         /**
       
   209          * Defined in a base class
       
   210          */
       
   211         void DoUpdatePresentityPresenceSubscriptionPifL(
       
   212             const MXIMPIdentity& aPresentityId,
       
   213             const MPresenceInfoFilter& aPif,
       
   214             TXIMPRequestId aReqId );
       
   215 
       
   216         /**
       
   217          * Defined in a base class
       
   218          */
       
   219         void DoUnsubscribePresentityPresenceL(
       
   220             const MXIMPIdentity& aPresentityId,
       
   221             TXIMPRequestId aReqId );
       
   222 
       
   223         /**
       
   224          * Defined in a base class
       
   225          */
       
   226         void DoSubscribePresentityGroupMembersPresenceL(
       
   227             const MXIMPIdentity& aGroupId,
       
   228             const MPresenceInfoFilter& aPif,
       
   229             TXIMPRequestId aReqId );
       
   230 
       
   231         /**
       
   232          * Defined in a base class
       
   233          */
       
   234         void DoUpdatePresentityGroupMembersPresenceSubscriptionPifL(
       
   235             const MXIMPIdentity& aGroupId,
       
   236             const MPresenceInfoFilter& aPif,
       
   237             TXIMPRequestId aReqId );
       
   238 
       
   239         /**
       
   240          * Defined in a base class
       
   241          */
       
   242         void DoUnsubscribePresentityGroupMembersPresenceL(
       
   243             const MXIMPIdentity& aGroupId,
       
   244             TXIMPRequestId aReqId );
       
   245 
       
   246     public:
       
   247 
       
   248          /**
       
   249          * Save presentity id
       
   250          *
       
   251          * @since S60 3.2
       
   252          * @param aPresentityId presentity id
       
   253          * @param aFormatUri, attempt to format uri
       
   254          * @return none         
       
   255          */
       
   256         void SetPresIdentityL(
       
   257             const MXIMPIdentity& aPresentityId,
       
   258             TBool aFormatUri );
       
   259             
       
   260         /**
       
   261          * Calls MXIMPProtocolConnectionHost callback
       
   262          *
       
   263          * @since S60 3.2
       
   264          * @param aStatus error status
       
   265          * @return none     
       
   266          */
       
   267         void CompleteXIMPReq( TInt aStatus );
       
   268         
       
   269         /**
       
   270          * Set XIMP request id
       
   271          *
       
   272          * @since S60 3.2
       
   273          * @param aId, request id
       
   274          * @return none    
       
   275          */
       
   276         void SetXIMPId( TXIMPRequestId aId );
       
   277 
       
   278         /**
       
   279          * Check if ID matches with existing watcher
       
   280          *
       
   281          * @since S60 5.1
       
   282          * @param aPresentityId presentity ID
       
   283          * @return ETrue if matching watcher found
       
   284          */
       
   285         TBool MatchWatcherId( const TDesC8& aPresentityId ) const;
       
   286 
       
   287     protected: // from base class CActive
       
   288 
       
   289         /**
       
   290          * Defined in a base class
       
   291          */
       
   292         void RunL();
       
   293 
       
   294         /**
       
   295          * Defined in a base class
       
   296          */
       
   297         TInt RunError( TInt aError );
       
   298 
       
   299         /**
       
   300          * Defined in a base class
       
   301          */
       
   302         void DoCancel();
       
   303 
       
   304     private:
       
   305     
       
   306         /**
       
   307          * Match existing watcher
       
   308          *
       
   309          * @since S60 3.2         
       
   310          * @param aPresentityId presentity id
       
   311          * @return watcher or NULL when not found
       
   312          */
       
   313         CPresencePluginEntityWatcher* MatchWatcherL(
       
   314             const TDesC8& aPresentityId, TBool aCreate );   
       
   315         
       
   316         /**
       
   317          * StartXdmOperationL
       
   318          *
       
   319          * @since S60 3.2
       
   320          * @param none
       
   321          * @return none
       
   322          */
       
   323         void StartXdmOperationL();
       
   324                                       
       
   325     private: // Data
       
   326 
       
   327         /**
       
   328          * XIMP Plugin connection observer
       
   329          * Own.
       
   330          */
       
   331         MPresencePluginConnectionObs& iConnObs;
       
   332         
       
   333         /**
       
   334          * XIMP Host.     
       
   335          * Not Own.
       
   336          */    
       
   337         MXIMPProtocolConnectionHost* iHost;
       
   338 
       
   339         /**
       
   340          * SIMPLE engine connection
       
   341          * Not Own.
       
   342          */
       
   343         MSimpleConnection& iConnection;
       
   344 
       
   345         /**
       
   346          * SIMPLE engine watchers
       
   347          * Own.
       
   348          */
       
   349         RPointerArray<CPresencePluginEntityWatcher> iWatchers;    
       
   350         
       
   351         /**
       
   352          * Watcher candidates
       
   353          * Own.
       
   354          */
       
   355         RPointerArray<CPresencePluginEntityWatcher> iWatcherCandidates;
       
   356         
       
   357         /**
       
   358          * Current PrFW request id
       
   359          * Own.
       
   360          */
       
   361         TXIMPRequestId iXIMPId;
       
   362         
       
   363         /**
       
   364          * Simple Engine request id
       
   365          * Own.         
       
   366          */
       
   367         TInt iSimpleId;
       
   368         
       
   369          /**
       
   370          * XDM Utils
       
   371          * Not own.
       
   372          */
       
   373         CPresencePluginXdmUtils* iXdmUtils;
       
   374          
       
   375         /**
       
   376          * Current presentity in progress
       
   377          * Own.
       
   378          */
       
   379         HBufC16* iPresIdentity;
       
   380         
       
   381         /**
       
   382          * Presence data
       
   383          * Own
       
   384          */
       
   385         CPresencePluginData* iPresenceData;
       
   386         
       
   387         /**
       
   388          * XDM state
       
   389          */
       
   390         TPluginXdmState iXdmState;
       
   391         
       
   392         /**
       
   393          * Whether the request is completed
       
   394          * Own.
       
   395          */
       
   396         TBool iCompleted;
       
   397         
       
   398         /**
       
   399          * Current operation
       
   400          * Own.
       
   401          */
       
   402         TPluginWatcherOperation iOperation;    
       
   403         
       
   404         SIMPLE_UNIT_TEST( T_CPresencePluginWatcher )
       
   405         SIMPLE_UNIT_TEST( T_CPresencePluginXdmUtils )
       
   406     };
       
   407 
       
   408 #endif // CPRESENCEPLUGINWATCHER_H