simpleengine/engine/inc/simplepublisher.h
changeset 0 c8caa15ef882
child 9 36d970e98ad0
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     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 Engine publisher
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef simplepublisher_H
       
    22 #define simplepublisher_H
       
    23 
       
    24 #include <e32std.h>
       
    25 #include "simplecommon.h"
       
    26 #include "simpleclient.h"
       
    27 #include "msimpleconnection.h"
       
    28 #include "msimplepublisher.h"
       
    29 #include "msimpleowncallback.h"
       
    30 #include "msimpleenginerequest.h"
       
    31 
       
    32 // FORWARD DECLARATION
       
    33 class CSimpleEngineRequest;
       
    34 class MSimplePublishObserver;
       
    35 class MSimpleConnectionObserver;
       
    36 class MSimpleETagObserver;
       
    37 
       
    38 /**
       
    39  *  CSimplePublisher
       
    40  *
       
    41  *  SIMPLE Engine core.
       
    42  *
       
    43  *  @lib simpleengine
       
    44  *  @since S60 3.2
       
    45  */
       
    46 
       
    47 class CSimplePublisher : public CSimpleClient, public MSimplePublisher
       
    48     {
       
    49 
       
    50 public:
       
    51 
       
    52     /**
       
    53      * Two-phased constructor.
       
    54      * @since S60 3.2
       
    55      * @param aConn connection
       
    56      * @param aObserver callback observer
       
    57      * @return CSimplePublisher
       
    58      */
       
    59     static CSimplePublisher* NewL(
       
    60         MSimpleConnection& aConn,
       
    61         MSimplePublishObserver& aObserver );
       
    62 
       
    63     /**
       
    64      * Destructor.
       
    65      */
       
    66     virtual ~CSimplePublisher();
       
    67 
       
    68     /**
       
    69      * Destroy this entity
       
    70      *
       
    71      * @since S60 3.2
       
    72      */
       
    73     void Close();
       
    74 
       
    75 // from base class MSimplePublisher
       
    76 
       
    77     /**
       
    78      * Getter for the SIMPLE engine connection.
       
    79      * @since S60 3.2
       
    80      * @return the attribute name.
       
    81      */
       
    82     const MSimpleConnection& Connection();
       
    83 
       
    84     /**
       
    85      * Start to publish data.
       
    86      * Expiry time is set based on SIMPLE settings.
       
    87      * Refreshing is made by SIMPLE engine.
       
    88      * @since S60 3.2
       
    89      * @param aDocument data to be published
       
    90      * @param aRefresh where refresh is made automatically
       
    91      * @return operation id
       
    92      */
       
    93     TInt StartPublishL( MSimpleDocument& aDocument,
       
    94         TBool aRefresh);
       
    95         
       
    96     /**
       
    97      * Continue data publication
       
    98      * Leaves with KErrInUse if there is already active publication
       
    99      * in this MSimplePublisher entity.
       
   100      * Expiry time is set based on SIMPLE settings.
       
   101      * Refreshing is made by SIMPLE Engine.
       
   102      *
       
   103      * @since S60 3.2
       
   104      * @param aDocument data to be published
       
   105      * @param aRefresh whether refresh is made automatically
       
   106      * @param aETag SIP ETag header value to be used in SIP-If-Match header.
       
   107      * @return operation id
       
   108      */        
       
   109     TInt ContinuePublishL( MSimpleDocument& aDocument,
       
   110         TBool aRefresh, const TDesC8& aETag );          
       
   111 
       
   112     /**
       
   113      * Update published data.
       
   114      * @since S60 3.2
       
   115      * @param aDocument data to be published
       
   116      * @return operation id
       
   117      */
       
   118     TInt ModifyPublishL( MSimpleDocument& aDocument );
       
   119 
       
   120     /**
       
   121      * Stop publishing data.
       
   122      * @since S60 3.2
       
   123      * @return operation id
       
   124      */
       
   125     TInt StopPublishL();
       
   126     
       
   127     /**
       
   128      * Stop publication.
       
   129      *
       
   130      * @since S60 3.2
       
   131      * @param aETag SIP ETag header value to be used in SIP-If-Match header.     
       
   132      * @return operation id
       
   133      */
       
   134     TInt StopPublishL( const TDesC8& aETag );    
       
   135 
       
   136     /**
       
   137      * SIP Status accessor
       
   138      * Get the status of the last completed request.
       
   139      * @since S60 3.2     
       
   140      * @return SIP status, 0 if not available
       
   141      */
       
   142     TUint SIPStatus( );
       
   143 
       
   144     /**
       
   145      * SIP Retry-after accessor
       
   146      * Get the header of the last completed request.
       
   147      * @since S60 3.2     
       
   148      * @return retry-after value in seconds, 0 if not available
       
   149      */
       
   150     TUint SIPRetryAfter( );
       
   151     
       
   152     /**
       
   153      * SIP ETag header value accessor.
       
   154      * Notice that this value changes after each modification or automatic refresh
       
   155      * of publication. 
       
   156      * Refer to RFC3903.     
       
   157      *
       
   158      * @since S60 3.2
       
   159      * @return ETag header value received from a network server.. 
       
   160      *         Zero length if not available. 
       
   161      */
       
   162     TPtrC8 SIPETag();
       
   163     
       
   164     /**
       
   165      * SIP ETag header value change observer setter.    
       
   166      * Notice that this value changes after each modification or automatic refresh
       
   167      * of publication. Observer is called when the ETag value changes next time.
       
   168      * Refer to RFC3903.     
       
   169      *
       
   170      * @since S60 3.2
       
   171      * @param aObs ETag value observer. Can be NULL to stop notification.
       
   172      */
       
   173     void SetSIPETagObserver( MSimpleETagObserver* aObs );
       
   174 
       
   175 
       
   176 // from base class MSimpleOwnCallback
       
   177 
       
   178     /**
       
   179      * Complete the open client request
       
   180      * @since S60 3.2
       
   181      * @param aOpId operation id
       
   182      * @param aStatus result status
       
   183      * @param aReq request
       
   184      */
       
   185     void Complete( TInt aOpId, TInt aStatus, MSimpleEngineRequest& aReq );
       
   186 
       
   187 private:
       
   188 
       
   189     /**
       
   190      * Two-phase constructor
       
   191      */
       
   192     void ConstructL( );
       
   193 
       
   194     /**
       
   195      * constructor
       
   196      * @param aConn connection
       
   197      * @param aObserver callback observer
       
   198      */
       
   199     CSimplePublisher(
       
   200         MSimpleConnection& aConn,
       
   201         MSimplePublishObserver& aObserver );
       
   202 
       
   203     /**
       
   204      * Stream document into request
       
   205      *
       
   206      * @since S60 3.2     
       
   207      * @param aReq request
       
   208      * @param aDocument document
       
   209      */
       
   210     void StreamDocumentL(
       
   211         CSimpleEngineRequest& aReq,
       
   212         MSimpleDocument& aDocument );
       
   213     
       
   214       
       
   215     /**
       
   216      * Publish data.
       
   217      * Leaves with KErrInUse if there is already active publication
       
   218      * in this MSimplePublisher entity.
       
   219      * Expiry time is set based on SIMPLE settings.
       
   220      * Refreshing is made by SIMPLE Engine.
       
   221      *
       
   222      * @since S60 3.2
       
   223      * @param aDocument data to be published
       
   224      * @param aRefresh whether refresh is made automatically
       
   225      * @param aETag SIP ETag header value to be used in SIP-If-Match header. 
       
   226      * Zero length is ignored.
       
   227      * @return operation id
       
   228      */        
       
   229     TInt CSimplePublisher::DoStartPublishL( MSimpleDocument& aDocument,
       
   230         TBool aRefresh, const TDesC8& aETag );
       
   231 
       
   232 
       
   233 private:    // data
       
   234 
       
   235     /**
       
   236      * Publish state
       
   237      */
       
   238     TBool                       iPublished;
       
   239 
       
   240     /**
       
   241      * Client API observer for events
       
   242      */
       
   243     MSimplePublishObserver&      iObserver;
       
   244 
       
   245     /**
       
   246      * Data buffer for transmission
       
   247      * OWN.
       
   248      */
       
   249     CBufFlat* iBuffer;
       
   250     
       
   251     /**
       
   252      * current SIP ETag.
       
   253      * Own.
       
   254      */
       
   255     HBufC8* iETag; 
       
   256     
       
   257     /**
       
   258      * ETag change callback observer
       
   259      * Not own.
       
   260      **/
       
   261     MSimpleETagObserver* iETagObserver;    
       
   262 
       
   263     };
       
   264 
       
   265 #endif      // simplepublisher_H
       
   266 
       
   267 // End of File