epoc32/include/mw/sipregistrationbinding.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2006-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@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.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        : sipregistrationbinding.h
williamr@2
    16
* Part of     : SIP Client
williamr@2
    17
* Interface   : SDK API, SIP Client 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 CSIPREGISTRATIONBINDING_H
williamr@2
    25
#define CSIPREGISTRATIONBINDING_H
williamr@2
    26
williamr@2
    27
// INCLUDES
williamr@2
    28
#include "sipregistrationcontext.h"
williamr@4
    29
williamr@4
    30
//CONSTANTS
williamr@4
    31
williamr@4
    32
/** Property to modify the registration behaviour of the SIP stack. 
williamr@4
    33
* Property value is of type boolean. When the value is set to false,
williamr@4
    34
* registration will be attempted without expires value.
williamr@4
    35
* Default value for this property is true.
williamr@4
    36
*/
williamr@4
    37
const TUint32 KSIPSendWithExpires = 200;
williamr@4
    38
williamr@4
    39
/** Property to modify the registration behaviour of the SIP stack.
williamr@4
    40
* Property value is of type boolean. When the value is set to true,
williamr@4
    41
* resolved outbound proxy ip of the registration will be used for all
williamr@4
    42
* transactions which uses this registration context(id). The resolved ip is
williamr@4
    43
* updated on every successful registration in that context.
williamr@4
    44
* Default value for this property is false.
williamr@4
    45
*/
williamr@4
    46
const TUint32 KSIPCacheOutboundProxyIP = 201;
williamr@2
    47
williamr@2
    48
// FORWARD DECLARATIONS
williamr@2
    49
class CUri8;
williamr@2
    50
class CSIPToHeader;
williamr@2
    51
class CSIPFromHeader;
williamr@2
    52
class CSIPContactHeader;
williamr@2
    53
class CSIPRouteHeader;
williamr@2
    54
class CSIPMessageElements;
williamr@2
    55
class CSIPConnection;
williamr@2
    56
class CSIPRefresh;
williamr@2
    57
class CSIPClientTransaction;
williamr@2
    58
class CRegBindingImplementation;
williamr@2
    59
williamr@2
    60
// CLASS DECLARATION
williamr@2
    61
williamr@2
    62
/**
williamr@2
    63
*  @publishedAll
williamr@2
    64
*  @released
williamr@2
    65
*
williamr@2
    66
*  Class for managing SIP registration binding.
williamr@2
    67
*  Class provides functions for creating and updating SIP registration bindings.
williamr@2
    68
*
williamr@2
    69
*  @lib sipclient.lib
williamr@2
    70
*/
williamr@2
    71
class CSIPRegistrationBinding :
williamr@2
    72
    public CBase,
williamr@2
    73
    public MSIPRegistrationContext    
williamr@2
    74
	{
williamr@2
    75
    public: // Constructors and destructor
williamr@2
    76
williamr@2
    77
        /**
williamr@2
    78
        * Two-phased constructor.
williamr@2
    79
		* @pre aAor != 0 &&		
williamr@2
    80
		*      aContact != 0
williamr@2
    81
        * @pre "Expires" parameter in aContact must be >= KSIPMinExpirationValue
williamr@2
    82
		* @param aConnection a SIP connection to be used
williamr@2
    83
		* @param aAor contains user's address-of-record to register;
williamr@2
    84
		*        the ownership is transfered
williamr@2
    85
		* @param aContact contact(s) to be registered. The "expires" parameter
williamr@2
    86
		*        indicates how long the client would like the binding to be
williamr@2
    87
        *        valid.
williamr@2
    88
		*        "expires" parameter value must be >= KSIPMinExpirationValue; 
williamr@2
    89
		*		 the ownership is transfered
williamr@2
    90
 		* @param aRefresh if set, created binding will be refreshed;
williamr@2
    91
		*        the ownership is transfered
williamr@2
    92
		* @param aOutboundProxy an outbound proxy address;
williamr@2
    93
		*        the ownership is transfered
williamr@2
    94
		* @param aRemoteUri if set, will be used in request-uri construction;
williamr@2
    95
		*        the ownership is transfered
williamr@2
    96
        * @param aFrom From header, the ownership is transferred
williamr@2
    97
        * @return New object, ownership is transferred.
williamr@2
    98
        * @leave KErrArgument if aAor == 0, aContact == 0 or if "Expires"
williamr@2
    99
        *	parameter in aContact is less than KSIPMinExpirationValue
williamr@2
   100
		*/
williamr@2
   101
		IMPORT_C static CSIPRegistrationBinding*
williamr@2
   102
            NewL(CSIPConnection& aConnection,
williamr@2
   103
			     CSIPToHeader* aAor,
williamr@2
   104
			     CSIPContactHeader* aContact,
williamr@2
   105
 			     CSIPRefresh* aRefresh=0,
williamr@2
   106
			     CSIPRouteHeader* aOutboundProxy=0,
williamr@2
   107
			     CUri8* aRemoteUri=0,
williamr@2
   108
                 CSIPFromHeader* aFrom=0);
williamr@2
   109
williamr@2
   110
		/**
williamr@2
   111
        * Two-phased constructor.
williamr@2
   112
		* @pre aAor != 0 &&
williamr@2
   113
		*      aContact != 0
williamr@2
   114
        * @pre "Expires" parameter in aContact must be >= KSIPMinExpirationValue
williamr@2
   115
		* @param aConnection a SIP connection to be used
williamr@2
   116
		* @param aAor contains user's address-of-record to register;
williamr@2
   117
		*        the ownership is transfered		
williamr@2
   118
		* @param aContact contact to be registered; The "expires" parameter
williamr@2
   119
		*        indicates how long the client would like the binding to be
williamr@2
   120
        *        valid.
williamr@2
   121
        *        "expires" parameter value must be >= KSIPMinExpirationValue;
williamr@2
   122
		*		 the ownership is transfered
williamr@2
   123
		* @param aRefresh if set, created binding will be refreshed;
williamr@2
   124
		*        the ownership is transfered
williamr@2
   125
		* @param aOutboundProxy an outbound proxy address;
williamr@2
   126
		*        the ownership is transfered
williamr@2
   127
		* @param aRemoteUri if set, will be used in request-uri construction;
williamr@2
   128
		*        the ownership is transfered
williamr@2
   129
        * @param aFrom From header, the ownership is transferred
williamr@2
   130
        * @return New object, ownership is transferred.
williamr@2
   131
        * @leave KErrArgument if aAor == 0, aContact == 0 or if "Expires"
williamr@2
   132
        *	parameter in aContact is less than KSIPMinExpirationValue
williamr@2
   133
		*/
williamr@2
   134
		IMPORT_C static CSIPRegistrationBinding*
williamr@2
   135
            NewLC(CSIPConnection& aConnection,
williamr@2
   136
			      CSIPToHeader* aAor,
williamr@2
   137
			      CSIPContactHeader* aContact,
williamr@2
   138
			      CSIPRefresh* aRefresh=0,
williamr@2
   139
			      CSIPRouteHeader* aOutboundProxy=0,
williamr@2
   140
			      CUri8* aRemoteUri=0,
williamr@2
   141
                  CSIPFromHeader* aFrom=0);
williamr@2
   142
williamr@2
   143
		/**
williamr@2
   144
		* Destructor
williamr@2
   145
		*/
williamr@2
   146
		IMPORT_C ~CSIPRegistrationBinding();
williamr@2
   147
williamr@2
   148
	public: //From MSIPRegistrationContext:
williamr@2
   149
williamr@2
   150
        /**
williamr@2
   151
        * Checks if the registration context can be
williamr@2
   152
        * used for creating SIP messages/dialogs
williamr@2
   153
        * @return ETrue if the registration binding exists; EFalse
williamr@2
   154
        *         otherwise
williamr@2
   155
        */
williamr@2
   156
        IMPORT_C TBool IsContextActive() const;
williamr@2
   157
williamr@2
   158
        /**
williamr@2
   159
        * Gets the context id
williamr@2
   160
        * @return context id
williamr@2
   161
        * For internal use only
williamr@2
   162
        */        
williamr@2
   163
        IMPORT_C TUint32 ContextId() const;               
williamr@2
   164
        
williamr@2
   165
    public: // New functions
williamr@2
   166
        /**
williamr@2
   167
		* Creates SIP REGISTER request, sends it to the given destination.
williamr@2
   168
		* Received 2xx response will create at least one registration
williamr@2
   169
		* binding.
williamr@2
   170
		* @pre Connection().State()==EActive
williamr@2
   171
		* @param aElements contains user SIP headers and content; the ownership
williamr@2
   172
		*        is taken
williamr@2
   173
        * @return SIP REGISTER transaction; the ownership is transfered
williamr@2
   174
        * @leave KErrSIPMalformedMessage if aElements contains contact or
williamr@2
   175
        *		 expires headers
williamr@2
   176
        * @leave KErrSIPInvalidRegistrationState if already registered or
williamr@2
   177
        *	registering is in progress or deregistering is in progress.
williamr@2
   178
        * @capability NetworkServices
williamr@2
   179
        */
williamr@2
   180
		IMPORT_C CSIPClientTransaction*
williamr@2
   181
            RegisterL(CSIPMessageElements* aElements=0);
williamr@2
   182
williamr@2
   183
        /**
williamr@2
   184
		* Creates SIP (de)REGISTER request, sends it to the given destination.
williamr@2
   185
		* This function will remove registration binding.
williamr@2
   186
		* Any SIP response (2xx - 6xx) to this request removes the binding.
williamr@2
   187
		* Note that deregistration can be done then the 2xx is received to the
williamr@2
   188
		* initial REGISTER transaction and there is no on-going registration
williamr@2
   189
		* updates.
williamr@2
   190
		* @pre Connection().State()==EActive
williamr@2
   191
		* @pre IsContextActive()==ETrue
williamr@2
   192
		* @param aElements contains user SIP headers and content; the ownership
williamr@2
   193
		*        is transfered. If set, user SIP headers must not contain any 
williamr@2
   194
		*        Contact-header nor Expires-header
williamr@2
   195
        * @return SIP REGISTER transaction; the ownership is transfered
williamr@2
   196
        * @leave KErrSIPInvalidRegistrationState if IsContextActive()==EFalse
williamr@2
   197
        * @capability NetworkServices
williamr@2
   198
        */
williamr@2
   199
		IMPORT_C CSIPClientTransaction*
williamr@2
   200
            DeregisterL(CSIPMessageElements* aElements=0);
williamr@2
   201
williamr@2
   202
		/**
williamr@2
   203
		* Updates the registration binding. Note that update can be done
williamr@2
   204
		* then the 2xx is received to the REGISTER transaction that relates
williamr@2
   205
		* to the initial registration or to update.
williamr@2
   206
		* @pre aElements!=0
williamr@2
   207
		* @pre Connection().State()==EActive
williamr@2
   208
		* @pre IsContextActive()==ETrue
williamr@2
   209
		* @param aElements contains user SIP header and content, must not
williamr@2
   210
        *        contain any Contact-header nor Expires-header; 
williamr@2
   211
		*        the ownership is transferred.
williamr@2
   212
        * @return SIP REGISTER transaction; the ownership is transfered
williamr@2
   213
        * @leave KErrArgument if aElements == NULL
williamr@2
   214
        * @leave KErrSIPInvalidRegistrationState if IsContextActive()==EFalse
williamr@2
   215
        * @capability NetworkServices
williamr@2
   216
		*/
williamr@2
   217
		IMPORT_C CSIPClientTransaction* UpdateL(CSIPMessageElements* aElements);
williamr@2
   218
williamr@2
   219
		/**
williamr@2
   220
		* Updates the regisration binding. Note that update can be done
williamr@2
   221
		* then the 2xx is received to the REGISTER transaction that relates
williamr@2
   222
		* to the initial registration or to update.
williamr@2
   223
		* @pre aExpirationValue >= KSIPMinExpirationValue
williamr@2
   224
		* @pre Connection().State()==EActive
williamr@2
   225
		* @pre IsContextActive()==ETrue
williamr@2
   226
		* @param aExpirationValue a new expiration value in seconds
williamr@2
   227
		* @param aElements contains user SIP headers and content; must not
williamr@2
   228
        *        contain any Contact-header nor Expires-header;
williamr@2
   229
        *        the ownership is transferred.
williamr@2
   230
        * @return SIP REGISTER transaction; the ownership is transfered
williamr@2
   231
        * @leave KErrSIPInvalidRegistrationState if IsContextActive()==EFalse
williamr@2
   232
        * @capability NetworkServices
williamr@2
   233
		*/
williamr@2
   234
		IMPORT_C CSIPClientTransaction*
williamr@2
   235
            UpdateL(TUint aExpirationValue, CSIPMessageElements* aElements=0);
williamr@2
   236
williamr@2
   237
        /**
williamr@2
   238
		* Gets the SIP connection used for the registration.
williamr@2
   239
		* @return SIP connection used for the registration, or 0-pointer if the
williamr@2
   240
        *   	  connection has been deleted. Ownership is not transferred.
williamr@2
   241
		*/
williamr@2
   242
        IMPORT_C CSIPConnection* Connection();
williamr@2
   243
williamr@2
   244
        /**
williamr@2
   245
		* Gets the SIP connection used for the registration.
williamr@2
   246
		* @return SIP connection used for the registration, or 0-pointer if the
williamr@2
   247
        *   	  connection has been deleted. Ownership is not transferred.
williamr@2
   248
		*/
williamr@2
   249
        IMPORT_C const CSIPConnection* Connection() const;
williamr@2
   250
williamr@2
   251
		/**
williamr@2
   252
		* Sets/resets outbound proxy.
williamr@2
   253
		* If a 0-pointer is given the outbound proxy will be reset.
williamr@2
   254
		* @param aOutboundProxy an outbound proxy. Ownership is transferred.
williamr@2
   255
		* @leave KErrSIPResourceNotAvailable if a required SIP Client API
williamr@2
   256
		*	object has been deleted
williamr@2
   257
		*/
williamr@2
   258
		IMPORT_C void SetOutboundProxyL(CSIPRouteHeader* aOutboundProxy);
williamr@2
   259
williamr@2
   260
		/**
williamr@2
   261
		* Gets the address-of-record (AOR) used for creating binding
williamr@2
   262
		* @return address-of-record (AOR)
williamr@2
   263
		*/		
williamr@2
   264
		IMPORT_C const CSIPToHeader& Aor() const;
williamr@2
   265
williamr@2
   266
		/**
williamr@2
   267
		* Gets Contact header associated with the registration binding
williamr@2
   268
		* @return Contact header
williamr@2
   269
		*/
williamr@2
   270
		IMPORT_C const CSIPContactHeader& ContactHeader() const;
williamr@2
   271
williamr@2
   272
		/**
williamr@2
   273
		* Gets Contact header associated with the registration binding
williamr@2
   274
		* @return Contact header
williamr@2
   275
		*/
williamr@2
   276
		IMPORT_C CSIPContactHeader& ContactHeader();
williamr@2
   277
		
williamr@2
   278
		/**
williamr@2
   279
		* Gets used outbound proxy
williamr@2
   280
		* @return outbound proxy or a 0-pointer if not set. Ownership is not
williamr@2
   281
        *   transferred.
williamr@2
   282
		*/
williamr@2
   283
		IMPORT_C const CSIPRouteHeader* OutboundProxy() const;
williamr@2
   284
williamr@2
   285
        /**
williamr@2
   286
		* Gets associated refresh in case the user has requested the refresh of
williamr@2
   287
        * the registration. Note that client cannot use update or terminate
williamr@2
   288
        * functions defined in the CSIPRefresh class. 
williamr@2
   289
		* @return Associated refresh or a 0-pointer if the user has not
williamr@2
   290
        *   requested a refresh of registration binding. Ownership is not
williamr@2
   291
        *	transferred.
williamr@2
   292
		*/
williamr@2
   293
		IMPORT_C const CSIPRefresh* SIPRefresh() const;
williamr@2
   294
williamr@2
   295
       /**
williamr@2
   296
		* Gets associated refresh in case the user has requested the refresh of
williamr@2
   297
        * the registration. Note that client cannot use update or terminate
williamr@2
   298
        * functions defined in the CSIPRefresh class. 
williamr@2
   299
		* @return Associated refresh or a 0-pointer if the user has not
williamr@2
   300
        *  requested a refresh of registration binding. Ownership is not
williamr@2
   301
        *  transferred.
williamr@2
   302
		*/
williamr@2
   303
		IMPORT_C CSIPRefresh* SIPRefresh();
williamr@2
   304
		
williamr@2
   305
        /**
williamr@2
   306
		* Compares this object to another object
williamr@2
   307
		* @param aRegistration CSIPRegistrationBinding object to compare
williamr@2
   308
		* @return ETrue if the objects are equal, otherwise EFalse
williamr@2
   309
		*/
williamr@2
   310
        IMPORT_C TBool
williamr@2
   311
        	operator==(const CSIPRegistrationBinding& aRegistration) const;
williamr@2
   312
williamr@2
   313
        /**
williamr@2
   314
        * Gets the registered Contact-header received in the 200 OK response.
williamr@2
   315
        * @return Contact header, or NULL if IsContextActive() is EFalse.
williamr@2
   316
        *         Ownership is not transferred.
williamr@2
   317
        */
williamr@2
   318
        IMPORT_C const CSIPContactHeader* RegisteredContact() const;
williamr@4
   319
        
williamr@4
   320
        /**
williamr@4
   321
        * Sets/resets properties.
williamr@4
   322
        * @param aProperty. Property name
williamr@4
   323
        * @param aValue. Property value
williamr@4
   324
        * @return KErrSIPInvalidRegistrationState if IsContextActive() is ETrue
williamr@4
   325
        * @return KErrNotFound if property is not found, KErrNone otherwise
williamr@4
   326
        */
williamr@4
   327
        IMPORT_C TInt SetProperty(TUint32 aProperty,TBool aValue);
williamr@2
   328
williamr@2
   329
	public: // New functions, for internal use
williamr@2
   330
		/**
williamr@2
   331
		* Returns the implementation instance.
williamr@2
   332
		*
williamr@2
   333
 		* @return CRegBindingImplementation
williamr@2
   334
		*/
williamr@2
   335
		CRegBindingImplementation& Implementation();
williamr@4
   336
		
williamr@2
   337
	private: // Constructors
williamr@2
   338
		CSIPRegistrationBinding();
williamr@2
   339
williamr@2
   340
        void ConstructL(CSIPConnection& aConnection,
williamr@2
   341
        			    CSIPToHeader* aAor,
williamr@2
   342
						CSIPContactHeader* aContacts,                        
williamr@2
   343
						CSIPRefresh* aRefresh,
williamr@2
   344
						CSIPRouteHeader* aOutboundProxy,
williamr@2
   345
						CUri8* aRemoteUri,
williamr@2
   346
                        CSIPFromHeader* aFrom);        
williamr@4
   347
		
williamr@2
   348
	private: // Data
williamr@2
   349
		CRegBindingImplementation* iImplementation;
williamr@2
   350
williamr@2
   351
	private: // For testing purposes		        
williamr@4
   352
#ifdef CPPUNIT_TEST
williamr@4
   353
		friend class CSIP_Test;
williamr@4
   354
        friend class CSIPRegistrationBinding_Test;
williamr@4
   355
        friend class CSIPInviteDialogAssoc_Test;
williamr@4
   356
        friend class CSIPSubscribeDialogAssoc_Test;
williamr@4
   357
        friend class CSIPReferDialogAssoc_Test;
williamr@4
   358
#endif
williamr@4
   359
		void __DbgTestInvariant() const;
williamr@4
   360
	
williamr@2
   361
	};
williamr@2
   362
williamr@2
   363
#endif