epoc32/include/mw/sipconnection.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/sipconnection.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:
williamr@2
    15
* Name        : sipconnection.h
williamr@2
    16
* Part of     : SIP Client
williamr@2
    17
* Interface   : SDK API, SIP API
williamr@2
    18
* Version     : 1.0
williamr@2
    19
*
williamr@2
    20
*/
williamr@2
    21
williamr@2
    22
williamr@2
    23
williamr@2
    24
#ifndef CSIPCONNECTION_H
williamr@2
    25
#define CSIPCONNECTION_H
williamr@2
    26
williamr@2
    27
// INCLUDES
williamr@2
    28
#include <e32base.h>
williamr@2
    29
#include <in_sock.h>
williamr@2
    30
#include "_sipcodecdefs.h"
williamr@2
    31
williamr@2
    32
// FORWARD DECLARATIONS
williamr@2
    33
class CSIP;
williamr@2
    34
class MSIPConnectionObserver;
williamr@2
    35
class CSIPClientTransaction;
williamr@2
    36
class MSIPRegistrationContext;
williamr@2
    37
class CSIPRefresh;
williamr@2
    38
class CSIPRequestElements;
williamr@2
    39
class CSIPConnectionImplementation;
williamr@2
    40
williamr@2
    41
// CONSTANTS
williamr@2
    42
williamr@2
    43
// CLASS DECLARATION
williamr@2
    44
williamr@2
    45
/**
williamr@2
    46
* @publishedAll
williamr@2
    47
* @released
williamr@2
    48
*
williamr@2
    49
* Class for monitoring connection's state and sending SIP requests outside
williamr@2
    50
* the dialog associations. Class must not be used
williamr@2
    51
* - for sending requests to which received non-failure response creates a dialog
williamr@2
    52
* - for sending requests that must be sent within SIP dialog
williamr@2
    53
*  
williamr@2
    54
* Note that the user can have only one instance of the class per same IAP-id.
williamr@2
    55
*/
williamr@2
    56
class CSIPConnection : public CBase
williamr@2
    57
	{
williamr@2
    58
    public:
williamr@2
    59
        /** Connection states */
williamr@2
    60
        enum TState 
williamr@2
    61
            {
williamr@2
    62
            /** Connection initializing */
williamr@2
    63
			EInit=1,
williamr@2
    64
			/** Connection active */
williamr@2
    65
			EActive,
williamr@2
    66
			/** Connection suspended */
williamr@2
    67
			ESuspended,
williamr@2
    68
			/** Connection is inactive */
williamr@2
    69
			EInactive,
williamr@2
    70
			/** Connection is permanently unavailable */
williamr@2
    71
			EUnavailable
williamr@2
    72
            };
williamr@2
    73
williamr@2
    74
    public:  // Constructors and destructor
williamr@2
    75
williamr@2
    76
	    /**
williamr@2
    77
        * Two-phased constructor.
williamr@2
    78
		* @param aSip a handle to the SIP server
williamr@2
    79
		* @param aIapId IAP-id
williamr@2
    80
		* @param aObserver a observer for receiving asynchonous events on this
williamr@2
    81
        *   connection
williamr@2
    82
        * @return New object, ownership is transferred
williamr@2
    83
        * @capability NetworkServices
williamr@2
    84
        */
williamr@2
    85
		IMPORT_C static CSIPConnection*
williamr@2
    86
            NewL(CSIP& aSIP,
williamr@2
    87
				 TUint32 aIapId,
williamr@2
    88
				 MSIPConnectionObserver& aObserver);
williamr@2
    89
williamr@2
    90
	    /**
williamr@2
    91
        * Two-phased constructor.
williamr@2
    92
		* Constructs an object and adds the pointer to the cleanup stack;
williamr@2
    93
		* @param aSip a handle to the SIP server
williamr@2
    94
		* @param aIapId IAP-id
williamr@2
    95
		* @param aObserver a observer for receiving asynchonous events on this
williamr@2
    96
        *   connection
williamr@2
    97
        * @return New object, ownership is transferred
williamr@2
    98
        * @capability NetworkServices
williamr@2
    99
        */
williamr@2
   100
		IMPORT_C static CSIPConnection*
williamr@2
   101
            NewLC(CSIP& aSIP,
williamr@2
   102
				  TUint32 aIapId,
williamr@2
   103
				  MSIPConnectionObserver& aObserver);
williamr@2
   104
williamr@2
   105
		/**
williamr@2
   106
		* Destructor
williamr@2
   107
        * @capability NetworkServices
williamr@2
   108
		*/
williamr@2
   109
		IMPORT_C ~CSIPConnection();
williamr@2
   110
williamr@2
   111
    public: // New functions
williamr@2
   112
williamr@2
   113
        /**
williamr@2
   114
		* Gets current state of the connection        
williamr@2
   115
        * @return current state of the connection
williamr@2
   116
        */
williamr@2
   117
		IMPORT_C TState State() const;
williamr@2
   118
williamr@2
   119
        /**
williamr@2
   120
		* Creates SIP request and sends it to the given destination.
williamr@2
   121
		* The function must not be used with SIP requests that creates
williamr@2
   122
		* SIP dialog associations or must be sent within SIP dialog
williamr@2
   123
		* association.
williamr@2
   124
		* This provokes the Non-invite state machine.
williamr@2
   125
		* This function must be used if the user has created the
williamr@2
   126
		* registration binding.
williamr@2
   127
		* @pre State() == EActive.
williamr@2
   128
		* @pre aContext.IsContextActive() == ETrue
williamr@2
   129
		* @param aElements contains local and remote addresses,
williamr@2
   130
		*		 optional SIP message headers and body.
williamr@2
   131
		*        The ownership is transferred.
williamr@2
   132
		* @param aContext defines outbound proxy to be used. If the user
williamr@2
   133
		*        does not provide from-address it will be constucted using
williamr@2
   134
		*        user's AOR used during the registration.
williamr@2
   135
        * @return SIP client transaction, ownership is transferred
williamr@2
   136
        * @leave KErrArgument if aElements == 0
williamr@2
   137
        * @leave KErrSIPInvalidRegistrationState if aContext.IsContextActive()
williamr@2
   138
        *	== EFalse
williamr@2
   139
		* @capability NetworkServices
williamr@2
   140
        */
williamr@2
   141
		IMPORT_C CSIPClientTransaction*
williamr@2
   142
            SendRequestL(CSIPRequestElements* aElements,
williamr@2
   143
                         const MSIPRegistrationContext& aContext);
williamr@2
   144
williamr@2
   145
        /**
williamr@2
   146
		* Creates SIP request and sends it to the given destination.
williamr@2
   147
		* The function must not be used with SIP requests that creates
williamr@2
   148
		* SIP dialog associations or must be sent within SIP dialog
williamr@2
   149
		* association.
williamr@2
   150
		* This provokes the Non-invite state machine.
williamr@2
   151
		* This function must be used if the user has created the
williamr@2
   152
		* registration binding.
williamr@2
   153
		* @pre State() == EActive.
williamr@2
   154
		* @pre aContext.IsContextActive() == ETrue
williamr@2
   155
		* @param aElements contains local and remote addresses,
williamr@2
   156
		*		 optional SIP message headers and body.
williamr@2
   157
		*        The ownership is transferred.
williamr@2
   158
		* @param aContext defines outbound proxy to be used. If the user
williamr@2
   159
		*        does not provide from-address it will 
williamr@2
   160
		*        be constucted using user's AOR used during the registration.
williamr@2
   161
		* @param aRefresh defines the refresh interval for this transaction.
williamr@2
   162
        * @return SIP client transaction, ownership is transferred
williamr@2
   163
        * @leave KErrArgument if aElements == 0
williamr@2
   164
        * @leave KErrSIPInvalidRegistrationState if aContext.IsContextActive()
williamr@2
   165
        *	== EFalse
williamr@2
   166
        * @capability NetworkServices
williamr@2
   167
        */
williamr@2
   168
		IMPORT_C CSIPClientTransaction*
williamr@2
   169
            SendRequestL(CSIPRequestElements* aElements,                                        
williamr@2
   170
                         const MSIPRegistrationContext& aContext,
williamr@2
   171
						 CSIPRefresh& aRefresh); 
williamr@2
   172
williamr@2
   173
        /**
williamr@2
   174
		* Creates SIP request and sends it to the given destination.
williamr@2
   175
		* The function must not be used with SIP requests that creates SIP
williamr@2
   176
		* dialog associations or must be sent within SIP dialog association.
williamr@2
   177
		* This invokes the Non-invite state machine.
williamr@2
   178
		* @pre State() == EActive.
williamr@2
   179
		* @pre aElements.FromHeader() != 0
williamr@2
   180
		* @param aElements contains local and remote addresses,
williamr@2
   181
		*		 optional SIP message headers and body.
williamr@2
   182
		*        The ownership is transferred.
williamr@2
   183
        * @return SIP client transaction, ownership is transferred
williamr@2
   184
        * @leave KErrArgument if aElements == 0 or if From-header is not
williamr@2
   185
        *	present in aElements
williamr@2
   186
        * @capability NetworkServices
williamr@2
   187
        */
williamr@2
   188
		IMPORT_C CSIPClientTransaction*
williamr@2
   189
            SendRequestL(CSIPRequestElements* aElements);
williamr@2
   190
williamr@2
   191
        /**
williamr@2
   192
		* Creates SIP request and sends it to the given destination.
williamr@2
   193
		* The function must not be used with SIP requests that creates SIP
williamr@2
   194
		* dialog associations or must be sent within SIP dialog association.
williamr@2
   195
		* This invokes the Non-invite state machine.
williamr@2
   196
		* @pre State() == EActive.
williamr@2
   197
		* @pre aElements.FromHeader() != 0
williamr@2
   198
		* @param aElements contains local and remote addresses,
williamr@2
   199
		*		 optional SIP message headers and body.
williamr@2
   200
		*        The ownership is transferred.
williamr@2
   201
		* @param aRefresh indicates that transaction will be refreshed
williamr@2
   202
        * @return SIP client transaction, ownership is transferred
williamr@2
   203
        * @leave KErrArgument if aElements == 0 or if From-header is not
williamr@2
   204
        *	present in aElements
williamr@2
   205
        * @capability NetworkServices
williamr@2
   206
        */
williamr@2
   207
		IMPORT_C CSIPClientTransaction*
williamr@2
   208
            SendRequestL(CSIPRequestElements* aElements,
williamr@2
   209
						 CSIPRefresh& aRefresh);
williamr@2
   210
williamr@2
   211
		/**
williamr@2
   212
		* Creates SIP REGISTER request and sends it to the given destination.
williamr@2
   213
		* User must no define any Contact or Expires-headers
williamr@2
   214
		* in the provided elements.
williamr@2
   215
		* @pre State() == EActive
williamr@2
   216
        * @pre aElements != 0
williamr@2
   217
        * @pre aElements->Method().DesC().Length()==0
williamr@2
   218
		* @param aElements contains local and remote addresses, optional SIP
williamr@2
   219
        *        message headers and body. User must not set any expires values
williamr@2
   220
        *        to aElements. The ownership is transferred.
williamr@2
   221
        * @return SIP REGISTER client transaction, ownership is transferred
williamr@2
   222
        * @leave KErrArgument if aElements == 0 or if the request method has
williamr@2
   223
        *	been defined in aElements
williamr@2
   224
        * @capability NetworkServices
williamr@2
   225
        */
williamr@2
   226
		IMPORT_C CSIPClientTransaction*
williamr@2
   227
            FetchRegistrationsL(CSIPRequestElements* aElements);
williamr@2
   228
williamr@2
   229
		/**
williamr@2
   230
		* Gets Iap-id used for this connection
williamr@2
   231
		* @return Iap-id
williamr@2
   232
		*/
williamr@2
   233
        IMPORT_C TUint32 IapId() const;
williamr@2
   234
williamr@2
   235
		/**
williamr@2
   236
        * Gets SIP server handle
williamr@2
   237
        * @return handle to SIP server, or 0-pointer if SIP server does not
williamr@2
   238
        *	exist any more
williamr@2
   239
        */        
williamr@2
   240
        IMPORT_C CSIP* SIP();
williamr@2
   241
williamr@2
   242
        /**
williamr@2
   243
        * Gets SIP server handle
williamr@2
   244
        * @return handle to SIP server, or 0-pointer if SIP server does not
williamr@2
   245
        *	exist any more
williamr@2
   246
        */        
williamr@2
   247
        IMPORT_C const CSIP* SIP() const;
williamr@2
   248
      
williamr@2
   249
		/**
williamr@2
   250
		* Sets a RSocket option used for all the sockets used for sending 
williamr@2
   251
		* SIP requests and responses in this CSIPConnection.
williamr@2
   252
		* @pre State() == EActive
williamr@2
   253
		* @param aOptionName An integer constant which identifies an option.
williamr@2
   254
        * @param aOptionLevel An integer constant which identifies 
williamr@2
   255
        *        level of an option.
williamr@2
   256
        * @param aOption Option value packaged in a descriptor.
williamr@2
   257
        * @leave A system-wide error code
williamr@2
   258
        * @capability NetworkControl
williamr@2
   259
        * @capability NetworkServices
williamr@2
   260
        * @capability Location
williamr@2
   261
        * @capability ReadDeviceData
williamr@2
   262
        * @capability WriteDeviceData        
williamr@2
   263
        */        
williamr@2
   264
	    IMPORT_C void SetOptL(TUint aOptionName,
williamr@2
   265
	                      	  TUint aOptionLevel,
williamr@2
   266
	                      	  const TDesC8& aOption=KNullDesC8);
williamr@2
   267
williamr@2
   268
		/**
williamr@2
   269
		* Sets a RSocket option used for all the sockets used for sending 
williamr@2
   270
		* SIP requests and responses in this CSIPConnection.
williamr@2
   271
		* @pre State() == EActive
williamr@2
   272
		* @param aOptionName An integer constant which identifies an option.
williamr@2
   273
        * @param aOptionLevel An integer constant which identifies 
williamr@2
   274
        *        level of an option.
williamr@2
   275
        * @param aOption Option value as an integer.
williamr@2
   276
        * @leave A system-wide error codes
williamr@2
   277
        * @capability NetworkControl
williamr@2
   278
        * @capability NetworkServices
williamr@2
   279
        * @capability Location
williamr@2
   280
        * @capability ReadDeviceData
williamr@2
   281
        * @capability WriteDeviceData
williamr@2
   282
        */ 	                         
williamr@2
   283
	    IMPORT_C void SetOptL(TUint aOptionName,
williamr@2
   284
	                          TUint aOptionLevel,
williamr@2
   285
	                          TInt aOption);
williamr@2
   286
williamr@2
   287
        /**
williamr@2
   288
        * Gets the local IP address of this CSIPConnection 
williamr@2
   289
        * that is used by the SIP implementation.
williamr@2
   290
        * The user should re-new the call whenever the connection state changes
williamr@2
   291
        * to the CSIPConnection::EActive in order to verify the correctness of
williamr@2
   292
        * the previously retrieved local IP address. The local IP address might
williamr@2
   293
        * be different as a result of the connection state change.
williamr@2
   294
        * @pre State() == CSIPConnection::EActive
williamr@2
   295
        * @param aAddr on return filled with local IP address
williamr@2
   296
        * @leave a system-wide error code
williamr@2
   297
        */ 	                         
williamr@2
   298
	    IMPORT_C void GetLocalAddrL(TInetAddr& aAddr) const;
williamr@2
   299
	    
williamr@2
   300
	/**
williamr@2
   301
	* Refreshes the connection.
williamr@2
   302
	* This will retrieve the Bearer Monitor Instance if any, is available for this  CSIPConnection and issue a Connection Refresh Request to it.
williamr@2
   303
	* The state of the Connection can be retrieved from State() to check if there is any change after Refreshing the connection.
williamr@2
   304
	* @capability NetworkServices.
williamr@2
   305
	*/
williamr@2
   306
	    
williamr@2
   307
	  IMPORT_C void RefreshConnection() const;
williamr@2
   308
williamr@2
   309
	public: // New functions, for internal use
williamr@2
   310
	
williamr@2
   311
		/**
williamr@2
   312
		* Returns the implementation instance.
williamr@2
   313
		*
williamr@2
   314
 		* @return CSIPConnectionImplementation
williamr@2
   315
		*/
williamr@2
   316
		CSIPConnectionImplementation& Implementation();
williamr@2
   317
williamr@2
   318
    private: // Constructors
williamr@2
   319
    
williamr@2
   320
        CSIPConnection();
williamr@2
   321
williamr@2
   322
        void ConstructL(CSIP& aSIP,
williamr@2
   323
                        TUint32 aIapId,
williamr@2
   324
                        MSIPConnectionObserver& aObserver);
williamr@2
   325
williamr@2
   326
	private: // Data
williamr@2
   327
	
williamr@2
   328
		CSIPConnectionImplementation* iImplementation;
williamr@2
   329
		        
williamr@2
   330
	private: // For testing purposes
williamr@2
   331
	
williamr@2
   332
	    UNIT_TEST(CSIP_Test)
williamr@2
   333
        UNIT_TEST(CSIPConnection_Test)
williamr@2
   334
        UNIT_TEST(CSIPSubscribeDialogAssoc_Test)
williamr@2
   335
        UNIT_TEST(CSIPInviteDialogAssoc_Test)
williamr@2
   336
        UNIT_TEST(CSIPReferDialogAssoc_Test)
williamr@2
   337
        UNIT_TEST(CSIPNotifyDialogAssoc_Test)
williamr@2
   338
        UNIT_TEST(CSIPDialogTrying_Test)
williamr@2
   339
        UNIT_TEST(CSIPRegistrationBinding_Test)
williamr@2
   340
        
williamr@2
   341
        __DECLARE_TEST;
williamr@2
   342
	};
williamr@2
   343
williamr@2
   344
#endif