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