simpledatamodeladapter/inc/presencepluginpublisher.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 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     public:  // from MSimpleETagObserver
       
   137 
       
   138 	    /**
       
   139 	     * Defined in a base class
       
   140 	     */
       
   141         void NewETagL( const TDesC8& aVal );
       
   142 
       
   143     public: // from base class MSimplePublishObserver
       
   144 
       
   145         /**
       
   146          * Defined in a base class
       
   147          */
       
   148         void PublishReqCompleteL( TInt aOpid, TInt aStatus);
       
   149 
       
   150         /**
       
   151          * Defined in a base class
       
   152          */
       
   153         void PublishTerminatedL( TInt aOpid );
       
   154     
       
   155     public: // from base class MSimpleWatcherObserver
       
   156 
       
   157         /**
       
   158          * Defined in a base class
       
   159          */
       
   160         void WatcherReqCompleteL( TInt aOpId, TInt aStatus );
       
   161 
       
   162         /**
       
   163          * Defined in a base class
       
   164          */
       
   165         void WatcherNotificationL( MSimpleDocument& aDocument );
       
   166 
       
   167         /**
       
   168          * Defined in a base class
       
   169          */
       
   170         void WatcherListNotificationL( MSimplePresenceList& aList );
       
   171 
       
   172         /**
       
   173          * Defined in a base class
       
   174          */
       
   175         void WatcherTerminatedL(
       
   176             TInt aOpId, TInt aReason );
       
   177        
       
   178     public: // from base class MximpBase
       
   179 
       
   180         /**
       
   181          * Defined in a base class
       
   182          */
       
   183         TAny* GetInterface(
       
   184             TInt32 aInterfaceId,
       
   185             TIfGetOps aOps );
       
   186 
       
   187         /**
       
   188          * Defined in a base class
       
   189          */
       
   190         const TAny* GetInterface(
       
   191             TInt32 aInterfaceId,
       
   192             TIfGetOps aOps ) const;
       
   193 
       
   194         /**
       
   195          * Defined in a base class
       
   196          */
       
   197         TInt32 GetInterfaceId() const;
       
   198     
       
   199     public:     // from base class MximpProtocolPresencePublishing
       
   200 
       
   201         /**
       
   202          * Defined in a base class
       
   203          */
       
   204         void DoPublishOwnPresenceL(
       
   205             const MPresenceInfo& aOwnPresence,
       
   206             TXIMPRequestId aReqId );
       
   207 
       
   208         /**
       
   209          * Defined in a base class
       
   210          */
       
   211         void DoSubscribeOwnPresenceL(
       
   212             const MPresenceInfoFilter& aPif,
       
   213             TXIMPRequestId aReqId );
       
   214 
       
   215         /**
       
   216          * Defined in a base class
       
   217          */
       
   218         void DoUpdateOwnPresenceSubscriptionPifL(
       
   219             const MPresenceInfoFilter& aPif,
       
   220             TXIMPRequestId aReqId );
       
   221 
       
   222         /**
       
   223          * Defined in a base class
       
   224          */
       
   225         void DoUnsubscribeOwnPresenceL(
       
   226             TXIMPRequestId aReqId );
       
   227 
       
   228         /**
       
   229          * Defined in a base class
       
   230          */
       
   231         void DoSubscribePresenceWatcherListL(
       
   232             TXIMPRequestId aReqId );
       
   233 
       
   234         /**
       
   235          * Defined in a base class
       
   236          */
       
   237         void DoUnsubscribePresenceWatcherListL(
       
   238             TXIMPRequestId aReqId );
       
   239 
       
   240     protected: // from base class CActive
       
   241 
       
   242         /**
       
   243          * Defined in a base class
       
   244          */
       
   245         void RunL();
       
   246 
       
   247         /**
       
   248          * Defined in a base class
       
   249          */
       
   250         TInt RunError( TInt aError );
       
   251 
       
   252         /**
       
   253          * Defined in a base class
       
   254          */
       
   255         void DoCancel();
       
   256 
       
   257     private:
       
   258           
       
   259         /**
       
   260          * Calls MximpProtocolConnectionHost callback
       
   261          *
       
   262          * @since S60 3.2          
       
   263          * @param aStatus error status     
       
   264          */
       
   265         void CompleteXIMPReq( TInt aStatus );
       
   266         
       
   267         /**
       
   268          * Complete client request
       
   269          *
       
   270          * @since S60 3.2          
       
   271          * @param aStatus error status     
       
   272          */
       
   273         void CompleteClientReq( TInt aStatus );
       
   274         
       
   275         /**
       
   276          * Initialize a document
       
   277          */
       
   278         void InitializeSimpleDocumentL( );    
       
   279         
       
   280         /**
       
   281          * Add person information to the document.
       
   282          *
       
   283          * @since S60 3.2         
       
   284          * @param aPersInfo personal information
       
   285          */
       
   286         void AddSimpleDocumentPersL( 
       
   287             const MPersonPresenceInfo* aInfo );
       
   288                        
       
   289         /**
       
   290          * Make a publish request
       
   291          *
       
   292          * @since S60 3.2
       
   293          * @param none
       
   294          * @return none 
       
   295          */    
       
   296         void MakePublishReqL();            
       
   297         
       
   298         /**
       
   299          * Start XDM initialization
       
   300          *
       
   301          * @since S60 3.2
       
   302          * @param aReqId, XIMP request id           
       
   303          */
       
   304         void StartXdmOperationL( TXIMPRequestId aReqId );
       
   305         
       
   306         /**
       
   307          * Delete watcher information
       
   308          *
       
   309          * @since S60 3.2
       
   310          * @param none
       
   311          * @return none         
       
   312          */
       
   313         void DeleteWatchers();  
       
   314         
       
   315         /**
       
   316          * Add Watcher if not exist
       
   317          *
       
   318          * @since S60 3.2
       
   319          * @param aId, watcher identity
       
   320          * @param aSipId, watcher sip URL
       
   321          * @return none
       
   322          */ 
       
   323         void AddWatcherIfNotExistsL( 
       
   324             const TDesC8& aId, 
       
   325             const TDesC& aSipId );
       
   326          
       
   327         /**
       
   328          * Remove Watcher if not exist
       
   329          *
       
   330          * @since S60 3.2
       
   331          * @param aId, watcher identity
       
   332          * @param aSipId, watcher sip URL
       
   333          * @return none
       
   334          */    
       
   335         void RemoveWatcherIfExists( 
       
   336             const TDesC8& aId, 
       
   337             const TDesC& aSipId );
       
   338         
       
   339         /**
       
   340          * Make current watcher list
       
   341          *
       
   342          * @since S60 3.2
       
   343          * @param none
       
   344          * @return CDesCArrayFlat, watcher array
       
   345          */ 
       
   346         CDesCArrayFlat* MakeCurrentWatcherListLC(); 
       
   347         
       
   348         /**
       
   349          * Collect watcher from winfo
       
   350          *
       
   351          * @since S60 3.2
       
   352          * @param aElems element array
       
   353          * @return none
       
   354          */
       
   355         void CollectWatchersL(  
       
   356 			RPointerArray<MSimpleElement>& aElems );
       
   357         
       
   358         /**
       
   359          * CreatePublisherL()
       
   360          *
       
   361          * @since S60 3.2
       
   362          * @param none
       
   363          * @return none
       
   364          */
       
   365         void CreatePublisherL();
       
   366 		
       
   367         /**
       
   368          * Stores own presence status to presence cache
       
   369          *
       
   370          * @since S60 5.0
       
   371          * @return none
       
   372          */			
       
   373         void StoreOwnStatusToCacheL();
       
   374 
       
   375         /**
       
   376          * Resolves presence cache values according to provided
       
   377          * unicode string content.
       
   378          *
       
   379          * @since S60 5.0
       
   380          * @param aUnicodeContent, string containing info data
       
   381          * @param aActivities, activities string
       
   382          * @param aCacheAvailability, will store enumerated status
       
   383          * @param aCacheAvailability, will store extended status string
       
   384          * @param aXimpApiAvailability, will store ximp api availabiltiy
       
   385          * @return TBool, was handled or not
       
   386          */
       
   387         TBool ResolveOwnCacheValues( 
       
   388             const TDesC& aUnicodeContent,
       
   389             const TDesC& aActivities, 
       
   390             MPresenceBuddyInfo2::TAvailabilityValues& aCacheAvailability,
       
   391             TPtr& aExtendedCacheAvailability,
       
   392             NPresenceInfo::TAvailabilityValues& aXimpApiAvailability );
       
   393       
       
   394     private: // Data
       
   395 
       
   396         /**
       
   397          * ximp Plugin connection observer
       
   398          * Own.
       
   399          */
       
   400         MPresencePluginConnectionObs& iConnObs;
       
   401         
       
   402         /**
       
   403          * ximp Host.     
       
   404          * Not Own.
       
   405          */    
       
   406         MXIMPProtocolConnectionHost* iHost;
       
   407 
       
   408         /**
       
   409          * SIMPLE engine connection
       
   410          * Not Own.
       
   411          */
       
   412         MSimpleConnection& iConnection;
       
   413 
       
   414         /**
       
   415          * SIMPLE engine publisher
       
   416          * Own.
       
   417          */
       
   418         MSimplePublisher* iPublisher;
       
   419         
       
   420         /**
       
   421          * SIMPLE engine watcher
       
   422          * Own.
       
   423          */
       
   424         MSimpleWatcher* iWatcher;    
       
   425         
       
   426         /**
       
   427          * ximp request id
       
   428          * Own.
       
   429          */
       
   430         TXIMPRequestId iXIMPId;
       
   431         
       
   432         /**
       
   433          * Simple Engine request id
       
   434          * Own.
       
   435          */
       
   436         TInt iSimpleId;
       
   437         
       
   438         /**
       
   439          * Subscribed winfo
       
   440          * Own.
       
   441          */
       
   442         TBool iSubscribed; 
       
   443         
       
   444         /**
       
   445          * Subscribed own data
       
   446          * Own.         
       
   447          */
       
   448         TBool iSubscribedOwn;     
       
   449         
       
   450         /**
       
   451          * Published own data
       
   452          * Own.
       
   453          */
       
   454         TBool iPublished;  
       
   455 
       
   456         /**
       
   457          * RePublish status
       
   458          * Own.
       
   459          */
       
   460         TBool iRePublish;
       
   461         
       
   462         /**
       
   463          * Current operation
       
   464          * Own.
       
   465          */
       
   466         TPluginPublishOperation iOperation;     
       
   467            
       
   468         /**
       
   469          * Simple publish document
       
   470          * Own.
       
   471          */
       
   472         MSimpleDocument* iDocument;
       
   473        
       
   474         /**
       
   475          * XDM Utils
       
   476          * Not own.
       
   477          */
       
   478         CPresencePluginXdmUtils* iXdmUtils; 
       
   479         
       
   480         /**
       
   481          * WINFO watchers
       
   482          * Own.
       
   483          */
       
   484         TDblQue<CPresencePluginWatcherInfo> iWatcherList;
       
   485         
       
   486         /**
       
   487          * Presence Data
       
   488          * Not Own
       
   489          */
       
   490         CPresencePluginData* iPresenceData;
       
   491         
       
   492         /**
       
   493          * client statutus.
       
   494          * Not own.
       
   495          */
       
   496         TRequestStatus* iClientStatus;
       
   497         
       
   498         SIMPLE_UNIT_TEST( T_CPresencePluginPublisher )
       
   499 
       
   500         
       
   501     };
       
   502 
       
   503 #endif // CPRESENCEPLUGINPUBLISHER_H