simpleengine/siputils/inc/simplesipconnectionobserver.h
changeset 0 c8caa15ef882
child 12 e6a66db4e9d0
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     1 /*
       
     2 * Copyright (c) 2006-2009 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:    Implementation of MSIPConnectionObserver.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CSimpleSipConnectionObserver_H
       
    22 #define CSimpleSipConnectionObserver_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <e32base.h>
       
    26 #include <sipconnectionobserver.h>
       
    27 
       
    28 #include "simplecommon.h"
       
    29 
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CSIPRegistrationBinding;
       
    33 class CSIPClientTransaction;
       
    34 class MSimpleSipConnCallback;
       
    35 class CSIPDialogAssocBase;
       
    36 class CSIPInviteDialogAssoc;
       
    37 class MSimpleEngineRequest;
       
    38 
       
    39 #ifdef _DEBUG
       
    40 #ifdef __LOCAL_MODE
       
    41 // INTERNAL TEST SUITE
       
    42 class CSimpleLocalModeUtils;
       
    43 #endif
       
    44 #endif
       
    45 
       
    46 
       
    47 /**
       
    48  * Implementation of MSIPConnectionObserver.
       
    49  *
       
    50  * @lib simplesiputils
       
    51  * since S60 3.2
       
    52  */
       
    53 class CSimpleSipConnectionObserver: public CBase,
       
    54                                     public MSIPConnectionObserver
       
    55     {
       
    56 
       
    57 public:
       
    58 
       
    59     /**
       
    60      * Two phase constructore
       
    61      * @param aCallback status observer
       
    62      */
       
    63     static CSimpleSipConnectionObserver* NewL( MSimpleSipConnCallback& aCallback );
       
    64     
       
    65     /**
       
    66      * destructor
       
    67      */
       
    68     virtual ~CSimpleSipConnectionObserver();    
       
    69 
       
    70 public: 
       
    71 
       
    72     /**
       
    73      * SIP state accesor
       
    74      *
       
    75      * since S60 3.2     
       
    76      * @return SIP state
       
    77      */    
       
    78     TSimpleSipState SIPState();
       
    79             
       
    80     /**
       
    81      * SIP Profile state has changed.
       
    82      *
       
    83      * since S60 3.2      
       
    84      * @param aState indicates the current profile state
       
    85      * @param aSipError SIP error code
       
    86      */
       
    87     void ProfileStateChanged( 
       
    88         CSIPConnection::TState aState, TInt aSipError );   
       
    89     
       
    90     /**
       
    91      * SIP Profile has updated. 
       
    92      * 
       
    93      * @see MSIPProfileRegistryObserver::EProfileUpdated
       
    94      * @since S60 3.2.3
       
    95      */
       
    96     void ProfileUpdated();
       
    97 
       
    98 // from base class MSIPConnectionObserver
       
    99 
       
   100     /**
       
   101      * A SIP request outside a dialog has been received from the network.
       
   102      * @param aTransaction SIP server transaction
       
   103      * The ownership is transferred.
       
   104      */
       
   105     void IncomingRequest( CSIPServerTransaction* aTransaction );
       
   106 
       
   107     /**
       
   108      * A SIP request within a dialog has been received from the network.
       
   109      * The client must resolve the actual dialog association to which
       
   110      * this request belongs.
       
   111      * @param aTransaction SIP server transaction
       
   112      * The ownership is transferred.
       
   113      * @param aDialog the dialog  that
       
   114      *        this transaction belongs to.
       
   115      */
       
   116     void IncomingRequest(
       
   117         CSIPServerTransaction* aTransaction,
       
   118         CSIPDialog& aDialog );
       
   119 
       
   120     /**
       
   121      * A SIP response received from the network.
       
   122      * @param aTransaction contains response elements.
       
   123      */
       
   124     void IncomingResponse( CSIPClientTransaction& aTransaction );
       
   125 
       
   126     /**
       
   127      * A SIP response that is within a dialog association or creates
       
   128      * a dialog association.
       
   129      * @param aTransaction contains response elements.
       
   130      * The ownership is transferred.
       
   131      * @param aDialogAssoc a dialog association
       
   132      */
       
   133     void IncomingResponse(
       
   134         CSIPClientTransaction& aTransaction,
       
   135         CSIPDialogAssocBase& aDialogAssoc );
       
   136 
       
   137     /**
       
   138      * A SIP response that is within a Invite association or creates
       
   139      * a dialog association.
       
   140      * @param aTransaction contains response elements.
       
   141      * The ownership is transferred.
       
   142      * @param aDialogAssoc a dialog association
       
   143      */
       
   144     void IncomingResponse(
       
   145         CSIPClientTransaction& aTransaction,
       
   146         CSIPInviteDialogAssoc* aDialogAssoc );
       
   147 
       
   148     /**
       
   149      * A SIP response creating a registration binding or an error response
       
   150      * that is related to an refreshed registration binding
       
   151      * has been received from the network.
       
   152      * @param aTransaction contains response elements.
       
   153      * The ownership is transferred.
       
   154      * @param aSIPRegistration associated registration
       
   155      */
       
   156     void IncomingResponse(
       
   157         CSIPClientTransaction& aTransaction,
       
   158         CSIPRegistrationBinding& aRegistration );
       
   159 
       
   160     /**
       
   161      * An asynchronous error has occured related to a periodical refresh
       
   162      * that relates to a registration.
       
   163      * @param aError error code
       
   164      * @param aSIPRegistration associated registration
       
   165      */
       
   166     void ErrorOccured(
       
   167         TInt aError,
       
   168         CSIPRegistrationBinding& aRegistration );
       
   169     /**
       
   170      * An asynchronous error has occurred in the stack related
       
   171      * to the request indicated by the given transaction.
       
   172      * @param aError error code
       
   173      * @param aTransaction the failed transaction
       
   174      * @param aRegistration the failed registration
       
   175      */
       
   176     void ErrorOccured(
       
   177         TInt aError,
       
   178         CSIPClientTransaction& aTransaction,
       
   179         CSIPRegistrationBinding& aRegistration );
       
   180 
       
   181     /**
       
   182      * An asynchronous error has occurred in the stack related to the
       
   183      * request indicated by the given transaction.
       
   184      * @param aError error code
       
   185      * @param aTransaction failed transaction
       
   186      */
       
   187     void ErrorOccured(
       
   188         TInt aError,
       
   189         CSIPTransactionBase& aTransaction );
       
   190 
       
   191     /**
       
   192      * An asynchronous error has occured related to a request within
       
   193      * an existing dialog.
       
   194      * @param aError error code
       
   195      * @param aTransaction the failed transaction
       
   196      * @param aDialogAssoc the failed dialog associoation
       
   197      */
       
   198     void ErrorOccured(
       
   199         TInt aError,
       
   200         CSIPTransactionBase& aTransaction,
       
   201         CSIPDialogAssocBase& aDialogAssoc );
       
   202 
       
   203     /**
       
   204      * An asynchronous error has occured related to a refresh
       
   205      * @param aError error code
       
   206      * @param aSIPRefresh original refresh object
       
   207      */
       
   208     void ErrorOccured(
       
   209         TInt aError,
       
   210         CSIPRefresh& aRefresh );
       
   211 
       
   212     /**
       
   213      * An asynchronous error has occured related to a periodical refresh
       
   214      * that belongs to SIP dialog association.
       
   215      * @param aError error code
       
   216      * @param aDialogAssoc SIP dialog association
       
   217      */
       
   218     void ErrorOccured(
       
   219         TInt aError,
       
   220         CSIPDialogAssocBase& aDialogAssoc );
       
   221 
       
   222     /**
       
   223      * SIP stack has completed UAC core INVITE transaction 64*T1 seconds
       
   224      * after the reception of the first 2xx response. No more 2xx responses
       
   225      * can be received to the issued single INVITE.
       
   226      *
       
   227      * @param aTransaction a complete UAC core INVITE transaction
       
   228      */
       
   229     void InviteCompleted( CSIPClientTransaction& aTransaction );
       
   230 
       
   231     /**
       
   232      * Invite was canceled with the CANCEL
       
   233      * @param aTransaction a canceled INVITE UAS transaction
       
   234      */
       
   235     void InviteCanceled( CSIPServerTransaction& aTransaction );
       
   236 
       
   237     /**
       
   238      * Connection state has changed.
       
   239      * @param aState indicates the current connection state
       
   240      */
       
   241     void ConnectionStateChanged( CSIPConnection::TState aState );
       
   242      
       
   243 
       
   244 protected:
       
   245 
       
   246     /**
       
   247      * Two-phase constructor.
       
   248      */
       
   249     void ConstructL();
       
   250 
       
   251     /**
       
   252      * Default constructor
       
   253      * @param aCallback status observer
       
   254      */
       
   255     CSimpleSipConnectionObserver( MSimpleSipConnCallback& aCallback );
       
   256 
       
   257 private:
       
   258 
       
   259     /**
       
   260      * Handle Server request data content
       
   261      */
       
   262     void DoHandleSrvrReqContentL(
       
   263         const CSIPMessageElements& aElems,
       
   264         MSimpleEngineRequest& aR );
       
   265     
       
   266     /**
       
   267      * A SIP request outside a dialog has been received from the network.
       
   268      *
       
   269      * since S60 5.0
       
   270      * @param aTransaction SIP server transaction
       
   271      * The ownership is transferred.
       
   272      */
       
   273     void DoIncomingRequestL( CSIPServerTransaction* aTransaction );
       
   274         
       
   275     /**
       
   276      * A SIP request within a dialog has been received from the network.
       
   277      * The client must resolve the actual dialog association to which
       
   278      * this request belongs.
       
   279      * @param aTransaction SIP server transaction
       
   280      * The ownership is transferred.
       
   281      * @param aDialog the dialog  that
       
   282      *        this transaction belongs to.
       
   283      */
       
   284     void DoIncomingRequestL(
       
   285         CSIPServerTransaction* aTransaction,
       
   286         CSIPDialog& aDialog );
       
   287         
       
   288     /**
       
   289      * A SIP response received from the network.
       
   290      * @param aTransaction contains response elements.
       
   291      */
       
   292     void DoIncomingResponse( CSIPClientTransaction& aTransaction );
       
   293     
       
   294     /**
       
   295      * A SIP response that is within a dialog association or creates
       
   296      * a dialog association.
       
   297      * @param aTransaction contains response elements.
       
   298      * The ownership is transferred.
       
   299      * @param aDialogAssoc a dialog association
       
   300      */
       
   301     void DoIncomingResponse(
       
   302         CSIPClientTransaction& aTransaction,
       
   303         CSIPDialogAssocBase& aDialogAssoc );
       
   304             
       
   305     /**
       
   306      * Convert Sip error code to the S60 error code
       
   307      * @param aSip SIP error code
       
   308      * @param aRetryAfter wheter retry-after header is available
       
   309      * @param aPublishModify wheteer publish modify request
       
   310      * @return S60 error code
       
   311      */
       
   312     TInt ConvertSipCode( TUint aSip, TBool aRetryAfter, TBool aPublishModify ); 
       
   313     
       
   314     /**
       
   315      * Convert Sip publish modify error code to the S60 error code
       
   316      * @param aSip SIP error code
       
   317      * @return S60 error code
       
   318      */
       
   319     TInt ConvertSipModifyCode( TUint aSip );    
       
   320     
       
   321     /**
       
   322      * Get retry-after SIP header value
       
   323      * @param aElems
       
   324      * @return retry-after value
       
   325      */
       
   326     TUint GetRetryAfter( const CSIPResponseElements* aElems );
       
   327     
       
   328     /**
       
   329      * Connection state has changed.
       
   330      *
       
   331      * since S60 3.2      
       
   332      * @param aState indicates the current connection state
       
   333      * @param aSipError SIP error code
       
   334      */
       
   335     void ConnectionStateChanged2( 
       
   336         CSIPConnection::TState aState, TInt aSipError );    
       
   337 	                       
       
   338 
       
   339 private: // data
       
   340 
       
   341     /**
       
   342      * callback observer
       
   343      */
       
   344     MSimpleSipConnCallback& iCallback;
       
   345     
       
   346     /**
       
   347      * Error code from network
       
   348      */
       
   349     TInt iError;
       
   350     
       
   351     
       
   352 #ifdef _DEBUG
       
   353 #ifdef __LOCAL_MODE
       
   354     /**
       
   355      * INTERNAL TEST SUITE
       
   356      * Own.
       
   357      */
       
   358     CSimpleLocalModeUtils* iLocalModeUtils;
       
   359 #endif
       
   360 #endif        
       
   361 
       
   362 #ifdef _DEBUG
       
   363     friend class T_CSimpleSipConnectionObserver;
       
   364 #endif   
       
   365     };
       
   366 
       
   367 #endif