realtimenetprots/sipfw/SIP/TransactionUser/inc/MTransactionUser.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     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:
       
    15 * Name          : MTransactionUser.h
       
    16 * Part of       : TransactionUser
       
    17 * Version       : SIP/6.0
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 
       
    29 #ifndef MTRANSACTIONUSER_H
       
    30 #define MTRANSACTIONUSER_H
       
    31 
       
    32 // INCLUDES
       
    33 #include "SipStackServerDefs.h"
       
    34 #include <in_sock.h>
       
    35 
       
    36 // FORWARD DECLARATIONS
       
    37 class CSIPRequest;
       
    38 class CSIPResponse;
       
    39 class CURIContainer;
       
    40 class MTransactionOwner;
       
    41 class MTransactionHeaders;
       
    42 class TSIPTransportParams;
       
    43 class MSIPNATBindingObserver;
       
    44 
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49  * Transaction user interface for sending SIP messages, retrieving state of a
       
    50  * particular transaction and detaching from transaction.
       
    51  */
       
    52 class MTransactionUser
       
    53 	{
       
    54 public:
       
    55 	enum TRandomStringLength
       
    56 		{
       
    57 		// Amount of characters in a To/From header's tag when TransactionUser
       
    58 		// creates it
       
    59 		KTagLength = 20,
       
    60 
       
    61 		// Amount of characters in a Call-ID when TransactionUser creates it
       
    62 		KCallIDLength = 30
       
    63 		};
       
    64 
       
    65 	virtual ~MTransactionUser() {}
       
    66 
       
    67 	/**
       
    68 	 * Send a SIP request message. In case of error, function leaves and 
       
    69 	 * the ownership of the SIP Request isn't transferred.
       
    70 	 *
       
    71 	 * @pre aRequest!=NULL
       
    72 	 * @pre aObserver!=NULL
       
    73 	 *
       
    74 	 * @param aTransactionId   IN: If the request is ACK, this parameter should
       
    75      *                         be a TransactionId of the INVITE transaction.
       
    76 	 *						   OUT: If the request is not ACK, a new transaction
       
    77 	 *						   is created and its TransactionId is filled here.
       
    78 	 * @param aRegistrationId  IN: a registration id by which TU tries to find
       
    79 	 *                         an outbound proxy for the request.
       
    80 	 * @param aRequest	       IN: SIP request message. Ownership is transferred.
       
    81 	 * @param aObserver		   IN: Callback where the transaction will send
       
    82 	 *						   events. Ownership isn't transferred.	 
       
    83 	 * @param aRemoteTarget    IN: Remote target of the request.
       
    84      * @param aTransportParams IN: Transport parameters to be used when handing
       
    85      *                         the request to SIP Connection Mgr.
       
    86 	 * @param aDeleteRequest   If ETrue, TransactionUser will delete aRequest
       
    87 	 *						   when the transaction ends. If EFalse, aRequest is
       
    88 	 *						   not deleted by TransactionUser.
       
    89 	 */
       
    90 	virtual void SendL (TTransactionId& aTransactionId,
       
    91 	                    TRegistrationId aRegistrationId,
       
    92 					    CSIPRequest* aRequest,
       
    93 					    MTransactionOwner* aObserver,
       
    94 						CURIContainer& aRemoteTarget,
       
    95                         const TSIPTransportParams& aTransportParams,
       
    96 					    TBool aDeleteRequest) = 0;
       
    97 
       
    98 	/**
       
    99 	 * Send a SIP request message. In case of error, function leaves and 
       
   100 	 * the ownership of the SIP Request isn't transferred.
       
   101 	 *
       
   102 	 * @pre aRequest!=NULL
       
   103 	 * @pre aObserver!=NULL
       
   104 	 *
       
   105 	 * @param aTransactionId   IN: If the request is ACK, this parameter should
       
   106      *                         be a TransactionId of the INVITE transaction.
       
   107 	 *						   OUT: If the request is not ACK, a new transaction
       
   108 	 *						   is created and its TransactionId is filled here.
       
   109 	 * @param aRegistrationId  IN: a registration id by which TU tries to find
       
   110 	 *                         an outbound proxy for the request.
       
   111 	 * @param aRequest	       IN: SIP request message. Ownership is transferred.
       
   112 	 * @param aObserver		   IN: Callback where the transaction will send events.
       
   113 	 *						   Ownership isn't transferred.
       
   114 	 * @param aRemoteTarget    IN: Remote target of the request.
       
   115      * @param aTransportParams IN: Transport parameters to be used when handing
       
   116      *                         the request to SIP Connection Mgr.
       
   117 	 * @param aDeleteRequest   If ETrue, TransactionUser will delete aRequest
       
   118 	 *						   when the transaction ends. If EFalse, aRequest is
       
   119 	 *						   not deleted by TransactionUser.
       
   120 	 * @returns                A pointer to copies of transaction related headers
       
   121 	 *                         stored and possibly created by transactions.
       
   122 	 *                         The ownership is transferred.
       
   123 	 */
       
   124 	virtual MTransactionHeaders*
       
   125         SendAndGetHeadersL (TTransactionId& aTransactionId,
       
   126 		                    TRegistrationId aRegistrationId,
       
   127 	                        CSIPRequest* aRequest,
       
   128 	                        MTransactionOwner* aObserver,
       
   129 					        CURIContainer& aRemoteTarget,
       
   130                             const TSIPTransportParams& aTransportParams,
       
   131                             TBool aDeleteRequest) = 0;
       
   132 
       
   133 	/**
       
   134 	 * Send a SIP response message, using an existing transaction.
       
   135 	 * Fills From- and To-header and other transaction related headers
       
   136 	 * if they are missing. In case of error, function leaves and
       
   137 	 * the ownership of aResponse is NOT transferred.
       
   138 	 *
       
   139 	 * @pre transaction identified by aTransactionId exists,
       
   140 	 * @pre aResponse!=NULL
       
   141 	 *
       
   142 	 * @param aTransactionId   Identifies the transaction
       
   143 	 * @param aResponse	       IN: SIP response message.
       
   144 	 *                         The ownership is transferred.
       
   145      * @param aTransportParams IN: Transport parameters to be used when handing
       
   146      *                         the response to SIP Connection Mgr.
       
   147 	 */
       
   148 	virtual void SendL (TTransactionId aTransactionId,
       
   149 					    CSIPResponse* aResponse,
       
   150 					    const TSIPTransportParams& aTransportParams) const = 0;
       
   151 
       
   152 
       
   153 	/**
       
   154 	 * Send a SIP response using an existing transaction and specify a new
       
   155 	 * callback for the transaction to use.
       
   156 	 * Fills From- and To-header and other transaction related headers
       
   157 	 * if they are missing. In case of error, function leaves and
       
   158 	 * the ownership of aResponse is NOT transferred.
       
   159 	 *
       
   160 	 * @pre transaction identified by aTransactionId exists
       
   161 	 * @pre aResponse!=NULL
       
   162 	 * @pre aNewObserver!=NULL
       
   163 	 *
       
   164 	 * @param aTransactionId   Identifies the transaction
       
   165 	 * @param aResponse		   IN: SIP response message. Ownership transferred.
       
   166 	 * @param aNewObserver     IN: New callback replacing the existing callback
       
   167 	 *						   used by the the transaction. Ownership isn't
       
   168 	 *						   transferred.
       
   169      * @param aTransportParams IN: Transport parameters to be used when handing
       
   170      *                         the response to SIP Connection Mgr.	 
       
   171 	 */		
       
   172 	virtual void SendL (TTransactionId aTransactionId,
       
   173 					    CSIPResponse* aResponse,
       
   174 					    MTransactionOwner* aNewObserver,
       
   175 					    const TSIPTransportParams& aTransportParams) const = 0;
       
   176 
       
   177 	/**
       
   178 	 * Send a CANCEL request. In case of error, function leaves and 
       
   179 	 * the ownership of the aCancel isn't transferred. CANCEL can only be sent
       
   180 	 * when the INVITE client transaction has received a provisional response,
       
   181 	 * but hasn't yet received a final response.
       
   182 	 *
       
   183 	 * @pre aCancel!=NULL
       
   184 	 * @pre aObserver!=NULL
       
   185 	 *
       
   186 	 * @param aInviteTaId	  TransactionId of the INVITE client transaction to
       
   187 	 *						  be canceled.
       
   188 	 * @param aCancelTaId	  OUT: TransactionId of the transaction sending
       
   189 	 *						  CANCEL	 
       
   190 	 * @param aObserver		  IN: Callback where the CANCEL transaction will
       
   191 	 *						  send events. Ownership isn't transferred.	 
       
   192 	 */
       
   193 	virtual void SendCancelL (TTransactionId aInviteTaId,
       
   194 							  TTransactionId& aCancelTaId,							  
       
   195 							  MTransactionOwner* aObserver) = 0;
       
   196 
       
   197 	/**
       
   198 	 * The transaction with the specified transaction id clears its
       
   199 	 * MTransactionOwner callback and won't send any more events.
       
   200 	 * Transaction won't be stopped prematurely, it runs silently to completion.
       
   201 	 *
       
   202 	 * This function doesn't leave in case of error, as it is thought this
       
   203 	 * function is usually also called from destructors.
       
   204 	 *	 
       
   205 	 * @pre aTransactionId != KSIPEmptyTransactionId
       
   206 	 *
       
   207 	 * @param aTransactionId Identifies the transaction	 
       
   208 	 * @returns KErrNone if successful
       
   209 	 *          KErrNotFound if no such transaction exists
       
   210 	 */	
       
   211 	virtual TInt
       
   212         ClearTransactionOwner (TTransactionId aTransactionId) const = 0;
       
   213 
       
   214 	/**
       
   215 	 * Transactions using the specified callback clear their MTransactionOwner
       
   216      * callback and won't send any more events.
       
   217 	 * Transactions won't be stopped prematurely, they run silently to
       
   218 	 * completion.
       
   219 	 *
       
   220 	 * This function doesn't leave in case of error, as it is thought this
       
   221 	 * function is usually also called from destructors.
       
   222 	 *
       
   223 	 * @pre aObserver != NULL
       
   224 	 *
       
   225 	 * @param aObserver	IN: Callback address. Ownership isn't transferred.
       
   226 	 * @returns KErrNone if successful
       
   227 	 *          KErrNotFound if no such transaction exists
       
   228 	 */
       
   229 	virtual TInt ClearTransactionOwner (MTransactionOwner* aObserver) const = 0;
       
   230 
       
   231 	/**
       
   232 	 * Retrieve the transaction related headers of the SIP message that created
       
   233 	 * the transaction. Leaves if memory allocation for the requested headers
       
   234 	 * fails.
       
   235 	 *
       
   236 	 * @param aTransactionId the transaction whose SIP headers are requested.
       
   237 	 *
       
   238 	 * @returns NULL if no such transaction exists,
       
   239 	 *          otherwise an object implementing MTransactionHeaders interface,
       
   240 	 *          that contains copies of the transaction related SIP headers.
       
   241 	 *          Ownership is transferred.
       
   242 	 */
       
   243 	virtual MTransactionHeaders*
       
   244         TransactionHeadersL (TTransactionId aTransactionId) const = 0;
       
   245 
       
   246 	/**
       
   247 	 * Fills the descriptor with random characters.
       
   248 	 *
       
   249 	 * @param aTag Descriptor into which the random characters are added.
       
   250 	 *        The existing characters are not overwritten.
       
   251 	 *        Adds as many characters as there is space left in the aTag.
       
   252 	 */
       
   253 	virtual void MakeTagL (TDes8& aTag) const = 0;
       
   254 
       
   255     /**
       
   256  	 * Obtain the local address associated with the given IAP identifier.
       
   257 	 *
       
   258 	 * @param aIapId IAP identifier
       
   259      * @param aAddr Local address will be written here
       
   260 	 */
       
   261     virtual void GetLocalAddress (TUint32 aIapId, TInetAddr& aAddr) const = 0;
       
   262 
       
   263     /**
       
   264     * Frees all the resources reserved for the observer.
       
   265     * @param aSIPNATBindingObserver a observer
       
   266     */
       
   267     virtual void
       
   268     	FreeResources (MSIPNATBindingObserver& aSIPNATBindingObserver) = 0;
       
   269     
       
   270     /**
       
   271     * Obtains  the next hop address associated with the given transaction id.
       
   272 	*
       
   273     * @param aTransactionId transaction identifier
       
   274 	*
       
   275     * @param aAddr Local address will be written here
       
   276 	*
       
   277 	* @returns nex hop IP
       
   278     */
       
   279     virtual TInt 
       
   280     	NextHopIP(const TTransactionId& aTransactionId, TInetAddr& aAddr) = 0;
       
   281 	};
       
   282 
       
   283 #endif // MTRANSACTIONUSER_H
       
   284 
       
   285 // End of File