simpleengine/engine/inc/simplewatcher.h
changeset 0 c8caa15ef882
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 watcher
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef simplewatcher_H
       
    22 #define simplewatcher_H
       
    23 
       
    24 #include <e32std.h>
       
    25 #include "simplecommon.h"
       
    26 #include "simpleclient.h"
       
    27 #include "msimpleconnection.h"
       
    28 #include "msimplewatcher.h"
       
    29 #include "msimpleowncallback.h"
       
    30 
       
    31 
       
    32 // FORWARD DECLARATION
       
    33 class CSimpleEngineRequest;
       
    34 class MSimpleWatcherObserver;
       
    35 class MSimpleConnectionObserver;
       
    36 
       
    37 /**
       
    38  *  CSimpleWatcher
       
    39  *
       
    40  *  SIMPLE Engine core.
       
    41  *
       
    42  *  @lib simpleengine
       
    43  *  @since S60 3.2
       
    44  */
       
    45 class CSimpleWatcher : public CSimpleClient, public MSimpleWatcher
       
    46     {
       
    47 
       
    48 public:
       
    49 
       
    50     /**
       
    51      * Two-phased constructor.
       
    52      * @since S60 3.2
       
    53      * @param aConn connection
       
    54      * @param aObserver callback observer
       
    55      * @return CSimpleWatcher
       
    56      */
       
    57     static CSimpleWatcher* NewL(
       
    58         MSimpleConnection& aConn,
       
    59         MSimpleWatcherObserver& aObserver );
       
    60 
       
    61     /**
       
    62      * Destructor.
       
    63      */
       
    64     virtual ~CSimpleWatcher();
       
    65 
       
    66 // from base class MSimpleWatcher
       
    67 
       
    68     /**
       
    69      * Destroy this entity
       
    70      *
       
    71      * @since S60 3.2
       
    72      */
       
    73     void Close();
       
    74 
       
    75     /**
       
    76      * Getter for the SIMPLE engine connection.
       
    77      * @since S60 3.2
       
    78      * @return the connection
       
    79      */
       
    80     const MSimpleConnection& Connection();
       
    81 
       
    82     /**
       
    83      * Subscribe presence entity.
       
    84      * Expiry time is set based on SIMPLE settings.
       
    85      * Refreshing is made by SIMPLE engine.
       
    86      * Leaves with KErrInUse if there is already active subscription.
       
    87      * @since S60 3.2
       
    88      * @param aURI URI of entity to be subscribed
       
    89      * @param aFilter filter data, may be NULL.
       
    90      * @param aRefresh whether refresh is made automatically
       
    91      * @param aAnonymous whether anonymous subscription is wanted
       
    92      * @return operation id
       
    93      */
       
    94     TInt SubscribeL(
       
    95         const TDesC8& aURI,
       
    96         MSimpleFilterDocument* aFilter,
       
    97         TBool aRefresh,
       
    98         TBool aAnonymous );
       
    99 
       
   100     /**
       
   101      * Subscribe presence list.
       
   102      * Expiry time is set based on SIMPLE settings.
       
   103      * Refreshing is made by SIMPLE engine.
       
   104      * @since S60 3.2
       
   105      * @param aURI URI of entity to be subscribed
       
   106      * @param aFilter filter data, may be NULL.
       
   107      * @param aRefresh whether refresh is made automatically
       
   108      * @param aAnonymous whether anonymous subscription is wanted
       
   109      * @return operation id
       
   110      */
       
   111     TInt SubscribeListL(
       
   112         const TDesC8& aURI,
       
   113         MSimpleFilterDocument* aFilter,
       
   114         TBool aRefresh,
       
   115         TBool aAnonymous );
       
   116 
       
   117     /**
       
   118      * Get presence data.3
       
   119      * @since S60 3.2
       
   120      * @param aURI URI of entity to be subscribed
       
   121      * @param aFilter filter data, may be NULL.
       
   122      * @param aAnonymous whether anonymous subscription is wanted
       
   123      * @return operation id
       
   124      */
       
   125     TInt GetPresenceL( const TDesC8& aURI, MSimpleFilterDocument* aFilter, TBool aAnonymous );
       
   126 
       
   127     /**
       
   128      * Unsubscribe.
       
   129      * Leaves with KErrNotFound if there is no active subscription.
       
   130      * @since S60 3.2
       
   131      * @return operation id
       
   132      */
       
   133     TInt UnsubscribeL();    
       
   134 
       
   135     /**
       
   136      * SIP Status accessor
       
   137      * Get the status of the last completed request.
       
   138      * @since S60 3.2     
       
   139      * @return SIP status, 0 if not available
       
   140      */
       
   141     TUint SIPStatus();
       
   142 
       
   143     /**
       
   144      * SIP Retry-after accessor
       
   145      * Get the header of the last completed request.
       
   146      * @since S60 3.2     
       
   147      * @return retry-after value in seconds, 0 if not available
       
   148      */
       
   149     TUint SIPRetryAfter();  
       
   150         
       
   151     /**
       
   152      * SIP Subscription-state header value accessor.
       
   153      * Get the SIP Subscription-state header value of the last NOTIFY message or
       
   154      * ESimpleStateTerminated when the subscription is terminated by a client.
       
   155      * Refer to RFC3265     
       
   156      *
       
   157      * @since S60 3.2
       
   158      * @return subscription state
       
   159      */
       
   160     TSimpleSipSubscriptionState SipSubscriptionState();
       
   161 
       
   162 // from base class MSimpleOwnCallback
       
   163 
       
   164     /**
       
   165      * Complete the open client request
       
   166      * @since S60 3.2
       
   167      * @param aOpId operation id
       
   168      * @param aStatus result status
       
   169      * @param aReq request
       
   170      */
       
   171     void Complete( TInt aOpId, TInt aStatus, MSimpleEngineRequest& aReq );
       
   172 
       
   173 
       
   174 private:
       
   175 
       
   176 
       
   177     /**
       
   178      * Two-phase constructor
       
   179      */
       
   180     void ConstructL( );
       
   181 
       
   182 
       
   183     /**
       
   184      * constructor
       
   185      * @param aConn connection
       
   186      * @param aObserver callback observer
       
   187      */
       
   188     CSimpleWatcher(
       
   189         MSimpleConnection& aConn,
       
   190         MSimpleWatcherObserver& aObserver );
       
   191 
       
   192     /**
       
   193      * Stream document into request
       
   194      * @param aReq request
       
   195      * @param aFilter document
       
   196      */
       
   197     void StreamDocumentL(
       
   198         CSimpleEngineRequest& aReq,
       
   199         MSimpleFilterDocument& aFilter );
       
   200 
       
   201     /**
       
   202      * New Request from server
       
   203      * @since S60 3.2
       
   204      * @param aReq request
       
   205      */
       
   206     void NewRequestL( MSimpleEngineRequest& aReq );
       
   207     
       
   208     /**
       
   209      * Complete client request
       
   210      * @param aOpId operation id
       
   211      * @param aStatus result status     
       
   212      * @return error when observer has deleted ourself in callback
       
   213      */
       
   214     TInt DoCallReqComplete(
       
   215         TInt aOpId, TInt aStatus );   
       
   216 
       
   217 
       
   218 private:    // data
       
   219 
       
   220     /**
       
   221      * Client API observer for events
       
   222      */
       
   223     MSimpleWatcherObserver&      iObserver;
       
   224 
       
   225     /**
       
   226      * Subscription id
       
   227      */
       
   228     TInt iSubsId;
       
   229 
       
   230     /**
       
   231      * Response counter in error situations, or state. reply + notify
       
   232      */
       
   233     TInt iResCount;
       
   234 
       
   235     /**
       
   236      * Whether WatcherReqCompleteL callback method is called
       
   237      */
       
   238     TBool iComplete;
       
   239 
       
   240     /**
       
   241      * Data buffer for transmission
       
   242      * OWN.
       
   243      */
       
   244     CBufFlat* iBuffer;
       
   245 
       
   246     };
       
   247 
       
   248 #endif      // simplewatcher_H
       
   249 
       
   250 // End of File