presencefwsimpleadpt/inc/simplepluginwatcher.h
branchRCL_3
changeset 35 fbd2e7cec7ef
parent 0 c8caa15ef882
equal deleted inserted replaced
34:2669f8761a99 35:fbd2e7cec7ef
       
     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:    Simple Protocol implementation for Presence Framework
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CSIMPLEPLUGINWATCHER_H
       
    22 #define CSIMPLEPLUGINWATCHER_H
       
    23 
       
    24 #include <e32std.h>
       
    25 
       
    26 #include <protocolpresencewatching.h>
       
    27 
       
    28 #include <msimplewatcherobserver.h>
       
    29 
       
    30 #include "simpleplugincommon.h"
       
    31 #include "msimplepluginconnectionobs.h"
       
    32 #include "msimplepluginsettings.h"
       
    33 
       
    34 
       
    35 class TXIMPRequestId;
       
    36 class MXIMPIdentity;
       
    37 class MXIMPProtocolConnectionHost;
       
    38 class MPersonPresenceInfo;
       
    39 class MXIMPObjectCollection;
       
    40 
       
    41 class MSimpleDocument;
       
    42 class MSimpleWatcher;
       
    43 
       
    44 class CSimplePluginEntityWatcher;
       
    45 class CSimplePluginXdmUtils;
       
    46 
       
    47 /**
       
    48  * CSimplePluginWatcher
       
    49  *
       
    50  * Simple Engine Connection
       
    51  *
       
    52  * @lib ?library
       
    53  * @since s60 v5.0
       
    54  */
       
    55 NONSHARABLE_CLASS( CSimplePluginWatcher ): public CActive,
       
    56     public MProtocolPresenceWatching
       
    57     {
       
    58     
       
    59 private:
       
    60 
       
    61     /**
       
    62      * Current operation
       
    63      */
       
    64     enum TPluginWatcherOperation
       
    65         {
       
    66         EPluginUndef,
       
    67         EPluginSubscribeGroup,
       
    68         EPluginUnsubscribeGroup
       
    69         };
       
    70         
       
    71     /**
       
    72      * Current actibe object state
       
    73      */
       
    74     enum TPluginXdmState
       
    75         {
       
    76         EPluginIdle,
       
    77         EPluginInitXdm,
       
    78         EPluginFetchRls,
       
    79         EPluginAddGroupMember,
       
    80         EPluginRemoveGroupMember
       
    81         // EPluginCommitRls,
       
    82         // EPluginCommitXdm
       
    83         };        
       
    84             
       
    85 public:
       
    86 
       
    87     /**
       
    88      * Constructor.
       
    89      * @param aconnSets current settings
       
    90      * @param aObs callback for complete requests
       
    91      * @param aConn Simple Engine connection
       
    92      */
       
    93     static CSimplePluginWatcher* NewL(
       
    94         MSimplePluginSettings& aConnSets,
       
    95         MSimplePluginConnectionObs& aObs,
       
    96         MSimpleConnection& aConn );
       
    97 
       
    98     virtual ~CSimplePluginWatcher();
       
    99 
       
   100     /**
       
   101      * SetHost
       
   102      *
       
   103      * Set PrFw Host
       
   104      *
       
   105      * @lib ?library
       
   106      * @since s60 v5.0
       
   107      * @patam aHost PrFW Host
       
   108      */
       
   109     void SetHost( MXIMPProtocolConnectionHost* aHost );
       
   110 
       
   111     /**
       
   112      * SIP Watcher is complets it's task.
       
   113      * @param aStatus error status
       
   114      */
       
   115     void CompleteWatcher( TInt aStatus );
       
   116 
       
   117     /**
       
   118      * Delete a single entity watcher
       
   119      * @param aPresentityid presentity id
       
   120      */
       
   121     void DeleteWatcher(
       
   122         const TDesC8& aPresentityid );
       
   123 
       
   124     /**
       
   125      * Get Block list
       
   126      * @param aList list name
       
   127      * @param aMembers blocked users [OUT]
       
   128      */
       
   129     void GetEntitiesInListL(
       
   130         const TDesC& aList,
       
   131         MXIMPObjectCollection& aMembers );
       
   132 
       
   133 
       
   134 private:
       
   135 
       
   136     CSimplePluginWatcher(
       
   137         MSimplePluginSettings& aConnSets,
       
   138         MSimplePluginConnectionObs& aObs,
       
   139         MSimpleConnection& aConn );
       
   140 
       
   141     void ConstructL( );
       
   142     
       
   143     /**
       
   144      * Calls MXIMPProtocolConnectionHost callback
       
   145      * @param aStatus error status
       
   146      */
       
   147     void CompletePrFwReq( TInt aStatus ); 
       
   148     
       
   149     /**
       
   150      * Handles RunL routines for subscription
       
   151      */
       
   152     void DoRunForSubscriptionL();
       
   153     
       
   154     /**
       
   155      * Handles RunL routines for unsubscription
       
   156      */
       
   157     void DoRunForUnsubscriptionL();    
       
   158 
       
   159 
       
   160 public:
       
   161 
       
   162 
       
   163 // from base class MXIMPBase
       
   164 public:
       
   165 
       
   166     /**
       
   167      * Defined in a base class
       
   168      */
       
   169     TAny* GetInterface(
       
   170         TInt32 aInterfaceId,
       
   171         TIfGetOps aOps );
       
   172 
       
   173     /**
       
   174      * Defined in a base class
       
   175      */
       
   176     const TAny* GetInterface(
       
   177         TInt32 aInterfaceId,
       
   178         TIfGetOps aOps ) const;
       
   179 
       
   180     /**
       
   181      * Defined in a base class
       
   182      */
       
   183     TInt32 GetInterfaceId() const;
       
   184 
       
   185 
       
   186 // from base class MProtocolPresenceWatching
       
   187 public:
       
   188 
       
   189     /**
       
   190      * Defined in a base class
       
   191      */
       
   192     void DoSubscribePresentityPresenceL(
       
   193             const MXIMPIdentity& aPresentityId,
       
   194             const MPresenceInfoFilter& aPif,
       
   195             TXIMPRequestId aReqId );
       
   196 
       
   197     /**
       
   198      * Defined in a base class
       
   199      */
       
   200     void DoUpdatePresentityPresenceSubscriptionPifL(
       
   201             const MXIMPIdentity& aPresentityId,
       
   202             const MPresenceInfoFilter& aPif,
       
   203             TXIMPRequestId aReqId );
       
   204 
       
   205     /**
       
   206      * Defined in a base class
       
   207      */
       
   208     void DoUnsubscribePresentityPresenceL(
       
   209             const MXIMPIdentity& aPresentityId,
       
   210             TXIMPRequestId aReqId );
       
   211 
       
   212     /**
       
   213      * Defined in a base class
       
   214      */
       
   215     void DoSubscribePresentityGroupMembersPresenceL(
       
   216             const MXIMPIdentity& aGroupId,
       
   217             const MPresenceInfoFilter& aPif,
       
   218             TXIMPRequestId aReqId );
       
   219 
       
   220     /**
       
   221      * Defined in a base class
       
   222      */
       
   223     void DoUpdatePresentityGroupMembersPresenceSubscriptionPifL(
       
   224             const MXIMPIdentity& aGroupId,
       
   225             const MPresenceInfoFilter& aPif,
       
   226             TXIMPRequestId aReqId );
       
   227 
       
   228     /**
       
   229      * Defined in a base class
       
   230      */
       
   231     void DoUnsubscribePresentityGroupMembersPresenceL(
       
   232             const MXIMPIdentity& aGroupId,
       
   233             TXIMPRequestId aReqId );
       
   234 
       
   235 protected:
       
   236 
       
   237 // from base class CActive
       
   238 
       
   239     /**
       
   240      * Defined in a base class
       
   241      */
       
   242     void RunL();
       
   243 
       
   244     /**
       
   245      * Defined in a base class
       
   246      */
       
   247     TInt RunError( TInt aError );
       
   248 
       
   249     /**
       
   250      * Defined in a base class
       
   251      */
       
   252     void DoCancel();
       
   253 
       
   254 private:
       
   255 
       
   256     /**
       
   257      * Match existing watcher
       
   258      * @param aPresentityId presentity id
       
   259      * @return watcher or NULL when not found
       
   260      */
       
   261     CSimplePluginEntityWatcher* MatchWatcher2L(
       
   262         const TDesC8& aPresentityId, TBool aCreate );
       
   263 
       
   264     /**
       
   265      * Save presentity id
       
   266      * @param aPresentityId presentity id
       
   267      */
       
   268     void SetPresIdentityL(
       
   269         const MXIMPIdentity& aPresentityId );
       
   270 
       
   271     /**
       
   272      *  Start watching service in RLS
       
   273      */
       
   274     void StartWatchingRlsL();
       
   275 
       
   276     void StartXdmOperationL();
       
   277     
       
   278     /**
       
   279      * StartXdmoperationL calls this
       
   280      */
       
   281     void DoStartXdmOperationL();    
       
   282     
       
   283     void GetListContentL();  
       
   284     
       
   285     /**
       
   286      * Copy data from aIds and from aNames into aCollection
       
   287      * @param aNames group member names [IN]
       
   288      * @param aNames group member display names [IN]
       
   289      * @param aCollection collection of MPresentityGroupMemberInfo [OUT]
       
   290      */        
       
   291     void CopyGroupMembersToCollectionL( 
       
   292         CPtrCArray& aIds, CPtrCArray& aNames, MXIMPObjectCollection& aCollection);
       
   293         
       
   294     /**
       
   295      * DoSubscribePresentityPresenceL calls this. 
       
   296      */
       
   297     void DoDoSubscribePresentityPresenceL(
       
   298             const MXIMPIdentity& aPresentityId,
       
   299             TXIMPRequestId aReqId );  
       
   300             
       
   301     /**
       
   302      * DoUnsubscribePresentityPresenceL calls this.
       
   303      */
       
   304     void DoDoUnsubscribePresentityPresenceL(
       
   305             const MXIMPIdentity& aPresentityId,
       
   306             TXIMPRequestId aReqId );  
       
   307           
       
   308     /**
       
   309      * DoDoUnsubscribePresentityGroupMembersPresenceL calls this
       
   310      */        
       
   311     void DoDoUnsubscribePresentityGroupMembersPresenceL(
       
   312             const MXIMPIdentity& aGroupId,
       
   313             TXIMPRequestId aReqId );                                  
       
   314 
       
   315 
       
   316 private: // Data
       
   317 
       
   318     /**
       
   319      * Current settings
       
   320      */
       
   321     MSimplePluginSettings& iConnSets;
       
   322 
       
   323     /**
       
   324      * PrFw Plugin connection observer
       
   325      */
       
   326     MSimplePluginConnectionObs& iConnObs;
       
   327 
       
   328     /**
       
   329      * SIMPLE engine connection
       
   330      */
       
   331     MSimpleConnection& iConnection;
       
   332 
       
   333     /**
       
   334      * SIMPLE engine watchers
       
   335      */
       
   336     RPointerArray<CSimplePluginEntityWatcher> iWatchers;
       
   337 
       
   338     /**
       
   339      * Current PrFW request id
       
   340      */
       
   341     TXIMPRequestId iPrFwId;
       
   342 
       
   343     /**
       
   344      * Current presentity in progress
       
   345      * Own.
       
   346      */
       
   347     HBufC16* iPresIdentity;
       
   348 
       
   349     /**
       
   350      * XDM Utils
       
   351      * Not own.
       
   352      */
       
   353     CSimplePluginXdmUtils* iXdmUtils;
       
   354 
       
   355     /**
       
   356      * Whether the request is completed
       
   357      */
       
   358     TBool iCompleted;
       
   359     
       
   360     TPluginWatcherOperation iOperation;
       
   361     
       
   362     TPluginXdmState iXdmState;
       
   363 
       
   364     };
       
   365 
       
   366 #endif // CSimplePluginWatcher_H