simpledatamodeladapter/inc/presencepluginpublisher.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 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 CPRESENCEPLUGINPUBLISHER_H
       
    20 #define CPRESENCEPLUGINPUBLISHER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include <ximpbase.h>
       
    25 #include <protocolpresencepublishing.h>
       
    26 #include <msimplepublishobserver.h>
       
    27 #include <msimplewatcherobserver.h>
       
    28 #include <mpresencebuddyinfo2.h>
       
    29 #include <presenceinfo.h>
       
    30 
       
    31 #include "presencepluginentitywatcher.h"
       
    32 #include "presenceplugincommon.h"
       
    33 #include "mpresencepluginconnectionobs.h"
       
    34 #include "msimpleetagobserver.h"
       
    35 #include "presencelogger.h"
       
    36 
       
    37 class TXIMPRequestId;
       
    38 class MXIMPProtocolConnectionHost;
       
    39 class MPersonPresenceInfo;
       
    40 class MServicePresenceInfo;
       
    41 class MDevicePresenceInfo;
       
    42 class MSimplePublisher;
       
    43 class MSimpleDocument;
       
    44 class MSimpleElement;
       
    45 class MSimpleWatcher;
       
    46 class CPresencePluginXdmUtils;
       
    47 class CPresencePluginData;
       
    48 class CPresencePluginWatcherInfo;
       
    49 
       
    50 /**
       
    51  * CPresencePluginPublisher
       
    52  *
       
    53  * Simple Engine Connection
       
    54  *
       
    55  * @lib presenceplugin.dll
       
    56  * @since S60 v3.2
       
    57  */
       
    58 NONSHARABLE_CLASS( CPresencePluginPublisher ): public CActive,
       
    59     public MSimplePublishObserver,
       
    60     public MSimpleWatcherObserver,
       
    61     public MProtocolPresencePublishing,
       
    62     public MSimpleETagObserver
       
    63     {
       
    64     public:
       
    65 
       
    66         /**
       
    67          * Current operation
       
    68          */
       
    69         enum TPluginPublishOperation
       
    70             {
       
    71             ENoOperation,
       
    72             EPublishOwn,
       
    73             ESubscribeOwn,
       
    74             EUnsubscribeOwn,
       
    75             ESubscribeWinfo,
       
    76             EUnsubscribeWinfo,
       
    77             EPublishReq
       
    78             };     
       
    79 
       
    80         /**
       
    81          * NewL
       
    82          * @param aObs callback for complete requests
       
    83          * @param aConn Simple Engine connection
       
    84          */ 
       
    85         static CPresencePluginPublisher* NewL(
       
    86             MPresencePluginConnectionObs& aObs,
       
    87             MSimpleConnection& aConn,
       
    88             CPresencePluginData* aPresenceData );
       
    89             
       
    90         /**
       
    91          * Standard C++ destructor
       
    92          */
       
    93         virtual ~CPresencePluginPublisher();
       
    94         
       
    95         /**
       
    96          * WinfoTerminatedL
       
    97          * 
       
    98          * SIMPLE Winfo watcher sunscription is terminated
       
    99          * @param aReason reason code
       
   100          */
       
   101         void WinfoTerminatedL( TInt aReason );
       
   102          
       
   103         /** 
       
   104          * WINFO received from SIMPLE
       
   105          * @param aWinfo WINFO
       
   106          */
       
   107         void WinfoNotificationL( MSimpleWinfo& aWinfo );
       
   108     
       
   109     private:
       
   110     
       
   111         /**
       
   112          * Standard C++ constructor
       
   113          * @param aObs, connection observer
       
   114          * @param aConn, SIMPLE connection 
       
   115          */ 
       
   116         CPresencePluginPublisher(
       
   117             MPresencePluginConnectionObs& aObs,
       
   118             MSimpleConnection& aConn );
       
   119             
       
   120         /**
       
   121          * Performs the 2nd phase of construction.
       
   122          */ 
       
   123         void ConstructL( CPresencePluginData* aPresenceData );
       
   124     
       
   125     public: //Own public methods
       
   126 
       
   127         /**
       
   128          * StopPublishL()
       
   129          *
       
   130          * @since S60 3.2 
       
   131          * @param none
       
   132          * @return none
       
   133          */
       
   134         void StopPublishL( TRequestStatus& aStatus ); 
       
   135         
       
   136         /**
       
   137          * Published()
       
   138          *
       
   139          * @since S60 3.2 
       
   140          * @param none
       
   141          * @return none
       
   142          */
       
   143         TBool Published();
       
   144 
       
   145     public:  // from MSimpleETagObserver
       
   146 
       
   147 	    /**
       
   148 	     * Defined in a base class
       
   149 	     */
       
   150         void NewETagL( const TDesC8& aVal );
       
   151 
       
   152     public: // from base class MSimplePublishObserver
       
   153 
       
   154         /**
       
   155          * Defined in a base class
       
   156          */
       
   157         void PublishReqCompleteL( TInt aOpid, TInt aStatus);
       
   158 
       
   159         /**
       
   160          * Defined in a base class
       
   161          */
       
   162         void PublishTerminatedL( TInt aOpid );
       
   163     
       
   164     public: // from base class MSimpleWatcherObserver
       
   165 
       
   166         /**
       
   167          * Defined in a base class
       
   168          */
       
   169         void WatcherReqCompleteL( TInt aOpId, TInt aStatus );
       
   170 
       
   171         /**
       
   172          * Defined in a base class
       
   173          */
       
   174         void WatcherNotificationL( MSimpleDocument& aDocument );
       
   175 
       
   176         /**
       
   177          * Defined in a base class
       
   178          */
       
   179         void WatcherListNotificationL( MSimplePresenceList& aList );
       
   180 
       
   181         /**
       
   182          * Defined in a base class
       
   183          */
       
   184         void WatcherTerminatedL(
       
   185             TInt aOpId, TInt aReason );
       
   186        
       
   187     public: // from base class MximpBase
       
   188 
       
   189         /**
       
   190          * Defined in a base class
       
   191          */
       
   192         TAny* GetInterface(
       
   193             TInt32 aInterfaceId,
       
   194             TIfGetOps aOps );
       
   195 
       
   196         /**
       
   197          * Defined in a base class
       
   198          */
       
   199         const TAny* GetInterface(
       
   200             TInt32 aInterfaceId,
       
   201             TIfGetOps aOps ) const;
       
   202 
       
   203         /**
       
   204          * Defined in a base class
       
   205          */
       
   206         TInt32 GetInterfaceId() const;
       
   207     
       
   208     public:     // from base class MximpProtocolPresencePublishing
       
   209 
       
   210         /**
       
   211          * Defined in a base class
       
   212          */
       
   213         void DoPublishOwnPresenceL(
       
   214             const MPresenceInfo& aOwnPresence,
       
   215             TXIMPRequestId aReqId );
       
   216 
       
   217         /**
       
   218          * Defined in a base class
       
   219          */
       
   220         void DoSubscribeOwnPresenceL(
       
   221             const MPresenceInfoFilter& aPif,
       
   222             TXIMPRequestId aReqId );
       
   223 
       
   224         /**
       
   225          * Defined in a base class
       
   226          */
       
   227         void DoUpdateOwnPresenceSubscriptionPifL(
       
   228             const MPresenceInfoFilter& aPif,
       
   229             TXIMPRequestId aReqId );
       
   230 
       
   231         /**
       
   232          * Defined in a base class
       
   233          */
       
   234         void DoUnsubscribeOwnPresenceL(
       
   235             TXIMPRequestId aReqId );
       
   236 
       
   237         /**
       
   238          * Defined in a base class
       
   239          */
       
   240         void DoSubscribePresenceWatcherListL(
       
   241             TXIMPRequestId aReqId );
       
   242 
       
   243         /**
       
   244          * Defined in a base class
       
   245          */
       
   246         void DoUnsubscribePresenceWatcherListL(
       
   247             TXIMPRequestId aReqId );
       
   248 
       
   249     protected: // from base class CActive
       
   250 
       
   251         /**
       
   252          * Defined in a base class
       
   253          */
       
   254         void RunL();
       
   255 
       
   256         /**
       
   257          * Defined in a base class
       
   258          */
       
   259         TInt RunError( TInt aError );
       
   260 
       
   261         /**
       
   262          * Defined in a base class
       
   263          */
       
   264         void DoCancel();
       
   265 
       
   266     private:
       
   267           
       
   268         /**
       
   269          * Calls MximpProtocolConnectionHost callback
       
   270          *
       
   271          * @since S60 3.2          
       
   272          * @param aStatus error status     
       
   273          */
       
   274         void CompleteXIMPReq( TInt aStatus );
       
   275         
       
   276         /**
       
   277          * Complete client request
       
   278          *
       
   279          * @since S60 3.2          
       
   280          * @param aStatus error status     
       
   281          */
       
   282         void CompleteClientReq( TInt aStatus );
       
   283         
       
   284         /**
       
   285          * Initialize a document
       
   286          */
       
   287         void InitializeSimpleDocumentL( );    
       
   288         
       
   289         /**
       
   290          * Add person information to the document.
       
   291          *
       
   292          * @since S60 3.2         
       
   293          * @param aPersInfo personal information
       
   294          */
       
   295         void AddSimpleDocumentPersL( 
       
   296             const MPersonPresenceInfo* aInfo );
       
   297                        
       
   298         /**
       
   299          * Make a publish request
       
   300          *
       
   301          * @since S60 3.2
       
   302          * @param none
       
   303          * @return none 
       
   304          */    
       
   305         void MakePublishReqL();            
       
   306         
       
   307         /**
       
   308          * Start XDM initialization
       
   309          *
       
   310          * @since S60 3.2
       
   311          * @param aReqId, XIMP request id           
       
   312          */
       
   313         void StartXdmOperationL( TXIMPRequestId aReqId );
       
   314         
       
   315         /**
       
   316          * Delete watcher information
       
   317          *
       
   318          * @since S60 3.2
       
   319          * @param none
       
   320          * @return none         
       
   321          */
       
   322         void DeleteWatchers();  
       
   323         
       
   324         /**
       
   325          * Add Watcher if not exist
       
   326          *
       
   327          * @since S60 3.2
       
   328          * @param aId, watcher identity
       
   329          * @param aSipId, watcher sip URL
       
   330          * @return none
       
   331          */ 
       
   332         void AddWatcherIfNotExistsL( 
       
   333             const TDesC8& aId, 
       
   334             const TDesC& aSipId );
       
   335          
       
   336         /**
       
   337          * Remove Watcher if not exist
       
   338          *
       
   339          * @since S60 3.2
       
   340          * @param aId, watcher identity
       
   341          * @param aSipId, watcher sip URL
       
   342          * @return none
       
   343          */    
       
   344         void RemoveWatcherIfExists( 
       
   345             const TDesC8& aId, 
       
   346             const TDesC& aSipId );
       
   347         
       
   348         /**
       
   349          * Make current watcher list
       
   350          *
       
   351          * @since S60 3.2
       
   352          * @param none
       
   353          * @return CDesCArrayFlat, watcher array
       
   354          */ 
       
   355         CDesCArrayFlat* MakeCurrentWatcherListLC(); 
       
   356         
       
   357         /**
       
   358          * Collect watcher from winfo
       
   359          *
       
   360          * @since S60 3.2
       
   361          * @param aElems element array
       
   362          * @return none
       
   363          */
       
   364         void CollectWatchersL(  
       
   365 			RPointerArray<MSimpleElement>& aElems );
       
   366         
       
   367         /**
       
   368          * CreatePublisherL()
       
   369          *
       
   370          * @since S60 3.2
       
   371          * @param none
       
   372          * @return none
       
   373          */
       
   374         void CreatePublisherL();
       
   375 		
       
   376         /**
       
   377          * Stores own presence status to presence cache
       
   378          *
       
   379          * @since S60 5.0
       
   380          * @return none
       
   381          */			
       
   382         void StoreOwnStatusToCacheL();
       
   383 
       
   384         /**
       
   385          * Resolves presence cache values according to provided
       
   386          * unicode string content.
       
   387          *
       
   388          * @since S60 5.0
       
   389          * @param aUnicodeContent, string containing info data
       
   390          * @param aActivities, activities string
       
   391          * @param aCacheAvailability, will store enumerated status
       
   392          * @param aCacheAvailability, will store extended status string
       
   393          * @param aXimpApiAvailability, will store ximp api availabiltiy
       
   394          * @return TBool, was handled or not
       
   395          */
       
   396         TBool ResolveOwnCacheValues( 
       
   397             const TDesC& aUnicodeContent,
       
   398             const TDesC& aActivities, 
       
   399             MPresenceBuddyInfo2::TAvailabilityValues& aCacheAvailability,
       
   400             TPtr& aExtendedCacheAvailability,
       
   401             NPresenceInfo::TAvailabilityValues& aXimpApiAvailability );
       
   402       
       
   403     private: // Data
       
   404 
       
   405         /**
       
   406          * ximp Plugin connection observer
       
   407          * Own.
       
   408          */
       
   409         MPresencePluginConnectionObs& iConnObs;
       
   410         
       
   411         /**
       
   412          * ximp Host.     
       
   413          * Not Own.
       
   414          */    
       
   415         MXIMPProtocolConnectionHost* iHost;
       
   416 
       
   417         /**
       
   418          * SIMPLE engine connection
       
   419          * Not Own.
       
   420          */
       
   421         MSimpleConnection& iConnection;
       
   422 
       
   423         /**
       
   424          * SIMPLE engine publisher
       
   425          * Own.
       
   426          */
       
   427         MSimplePublisher* iPublisher;
       
   428         
       
   429         /**
       
   430          * SIMPLE engine watcher
       
   431          * Own.
       
   432          */
       
   433         MSimpleWatcher* iWatcher;    
       
   434         
       
   435         /**
       
   436          * ximp request id
       
   437          * Own.
       
   438          */
       
   439         TXIMPRequestId iXIMPId;
       
   440         
       
   441         /**
       
   442          * Simple Engine request id
       
   443          * Own.
       
   444          */
       
   445         TInt iSimpleId;
       
   446         
       
   447         /**
       
   448          * Subscribed winfo
       
   449          * Own.
       
   450          */
       
   451         TBool iSubscribed; 
       
   452         
       
   453         /**
       
   454          * Subscribed own data
       
   455          * Own.         
       
   456          */
       
   457         TBool iSubscribedOwn;     
       
   458         
       
   459         /**
       
   460          * Published own data
       
   461          * Own.
       
   462          */
       
   463         TBool iPublished;  
       
   464 
       
   465         /**
       
   466          * RePublish status
       
   467          * Own.
       
   468          */
       
   469         TBool iRePublish;
       
   470         
       
   471         /**
       
   472          * Current operation
       
   473          * Own.
       
   474          */
       
   475         TPluginPublishOperation iOperation;     
       
   476            
       
   477         /**
       
   478          * Simple publish document
       
   479          * Own.
       
   480          */
       
   481         MSimpleDocument* iDocument;
       
   482        
       
   483         /**
       
   484          * XDM Utils
       
   485          * Not own.
       
   486          */
       
   487         CPresencePluginXdmUtils* iXdmUtils; 
       
   488         
       
   489         /**
       
   490          * WINFO watchers
       
   491          * Own.
       
   492          */
       
   493         TDblQue<CPresencePluginWatcherInfo> iWatcherList;
       
   494         
       
   495         /**
       
   496          * Presence Data
       
   497          * Not Own
       
   498          */
       
   499         CPresencePluginData* iPresenceData;
       
   500         
       
   501         /**
       
   502          * client statutus.
       
   503          * Not own.
       
   504          */
       
   505         TRequestStatus* iClientStatus;
       
   506         
       
   507         SIMPLE_UNIT_TEST( T_CPresencePluginPublisher )
       
   508 
       
   509         
       
   510     };
       
   511 
       
   512 #endif // CPRESENCEPLUGINPUBLISHER_H