realtimenetprots/sipfw/SIP/Transaction/inc/Transmitter.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          : Transmitter.h
       
    16 * Part of       : Transaction
       
    17 * Version       : SIP/5.0
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 #ifndef TRANSMITTER_H
       
    29 #define TRANSMITTER_H
       
    30 
       
    31 // INCLUDES
       
    32 #include <e32base.h>
       
    33 #include <in_sock.h>
       
    34 
       
    35 #include "SipStackServerDefs.h"
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class CUri8;
       
    39 class MSipConnectionMgr;
       
    40 class CSIPRequest;
       
    41 class CSIPResponse;
       
    42 class TSIPTransportParams;
       
    43 class MSendStatus;
       
    44 
       
    45 // CLASS DECLARATION
       
    46 
       
    47 /*
       
    48  * CTransmitter handles sending data to ConnectionMgr.
       
    49  *
       
    50  * Every CUserAgent owns one CTransmitter instance, and the associated
       
    51  * CTransaction uses the same CTransmitter object for sending.
       
    52  *
       
    53  * In case of a 2xx response to an INVITE, the InviteUAS/InviteUAC also use the
       
    54  * CTransmitter. CUserAgent can use the same instance as the CTransaction was
       
    55  * using since they are never both sending at the same time.
       
    56  */
       
    57 class CTransmitter : public CActive
       
    58 	{
       
    59 public: // Constructors and destructor
       
    60 
       
    61 	/**
       
    62 	 * Creates an instance of CTransmitter.
       
    63 	 *	 
       
    64 	 * @param aConnectionMgr ConnectionMgr to be used for sending.
       
    65 	 * @return value New CTransmitter object, ownership is transferred.
       
    66 	 */
       
    67 	static CTransmitter* NewL(MSipConnectionMgr& aConnectionMgr);
       
    68 
       
    69 	~CTransmitter();
       
    70 
       
    71 public: // From CActive:
       
    72 
       
    73 	void DoCancel();
       
    74 
       
    75 	void RunL();
       
    76 
       
    77 	TInt RunError(TInt aError);
       
    78 
       
    79 public: // New functions
       
    80 
       
    81 	/**
       
    82 	 * Send a SIP request message to network. 
       
    83 	 *
       
    84 	 * @pre aObserver != NULL
       
    85 	 *
       
    86 	 * @param aReq SIP request to be sent. Ownership is not transferred.
       
    87 	 * @param aAddress Address where the message will be sent
       
    88 	 * @param aForceUDP ETrue if transport protocol must remain UDP
       
    89 	 * @param aParams Transport parameters that are given to ConnectionMgr when
       
    90 	 *	sending the SIP request.
       
    91 	 * @param aOutboundProxy outbound proxy, NULL pointer if not used.
       
    92      *        The ownership is not transferred.
       
    93 	 * @param aObserver Callback which CTransmitter will use after it has
       
    94 	 *	served the sending of the message. Since CUserAgent and CTransaction
       
    95 	 *	share a common CTransmitter object, the MSendStatus callback is passed
       
    96 	 *  on every SendRequestL/SendResponseL call, so CTransmitter calls the
       
    97 	 *  correct object. Ownership isn't	transferred.	 
       
    98 	 */
       
    99 	void SendRequestL(CSIPRequest& aReq,
       
   100 					  const TInetAddr& aAddress,
       
   101 					  TBool aForceUDP,
       
   102 					  const TSIPTransportParams& aParams,
       
   103 					  const CUri8* aOutboundProxy,
       
   104 					  MSendStatus* aObserver);
       
   105 
       
   106 	/**
       
   107 	 * Send a SIP response message to network. 
       
   108 	 *
       
   109 	 * @pre aObserver != NULL
       
   110 	 *
       
   111 	 * @param aResp SIP response to be sent. Ownership is not transferred.
       
   112 	 * @param aParams Transport parameters that are given to ConnectionMgr when
       
   113 	 *	sending the SIP response.
       
   114 	 * @param aObserver Callback which CTransmitter will use after it has
       
   115 	 *	served the sending of the message. Since CUserAgent and CTransaction
       
   116 	 *	share a common CTransmitter object, the MSendStatus callback is passed
       
   117 	 *  on every SendRequestL/SendResponseL call, so CTransmitter calls the
       
   118 	 *  correct object. Ownership isn't	transferred.
       
   119 	 * @param aTransactionId TransactionId of transaction that sends the
       
   120 	 *	response.
       
   121 	 */
       
   122 	void SendResponseL(CSIPResponse& aResp,
       
   123 					   const TSIPTransportParams& aParams,
       
   124 					   MSendStatus* aObserver,
       
   125 					   TTransactionId aTransactionId);
       
   126 
       
   127 	/**
       
   128 	 * The user of CTransmitter indicates it doesn't want any events to the
       
   129 	 * callback it has provided earlier in SendRequestL or SendResponseL.
       
   130 	 *
       
   131 	 * E.g. a CTransaction is ending, but it doesn't use CTransmitter::Cancel()
       
   132 	 * to make sure CTransmitter won't use callback anymore, since in case some
       
   133 	 * other CTransaction instance or CUserAgent is currently sending, their
       
   134 	 * sending would get canceled.	 
       
   135 	 *
       
   136 	 * @param aObserver Callback which CTransmitter shouldn't use anymore.
       
   137 	 *	In case CTransmitter is already serving another user (meaning its
       
   138 	 *  iObserver != aObserver), nothing is done. Ownership isn't transferred.
       
   139 	 * @return value -
       
   140 	 */
       
   141 	void DetachCallback(MSendStatus* aObserver);
       
   142 
       
   143 	/**
       
   144 	 * Tells ConnectionMgr to clear any references to SIP responses associated
       
   145 	 * with the aTransactionId.
       
   146 	 *
       
   147 	 * @param aTransactionId Identifies the transaction
       
   148 	 * @param aAlso2xx Indicates if 2xx responses are also included
       
   149 	 */
       
   150 	void CancelSendResponses(TTransactionId aTransactionId,
       
   151 							 TBool aAlso2xx) const;
       
   152 
       
   153     /**
       
   154 	 * Disconnect TCP connection to the remote host
       
   155 	 *
       
   156 	 * @param aRemoteAddr Address of the remote host
       
   157 	 * @param aParams Transport parameters
       
   158 	 */
       
   159 	void TcpDisconnect(TInetAddr& aRemoteAddr,
       
   160 					   const TSIPTransportParams& aParams) const;
       
   161 
       
   162 private: // New functions, for internal use
       
   163 
       
   164 	CTransmitter(MSipConnectionMgr& aConnectionMgr);
       
   165 
       
   166     /**
       
   167 	 * Converts certain error codes into CSIP::ETransportFailure, to indicate
       
   168      * a transport layer error has occurred but UAC might have a chance to
       
   169      * try again.
       
   170 	 *
       
   171 	 * @param aError Error code received from ConnectionMgr
       
   172 	 * @return Error code which will be used instead of the aError
       
   173 	 */
       
   174 	TInt MapErrorCode(TInt aError) const;
       
   175 
       
   176 private: // Data
       
   177 
       
   178 	//Callback to the object of the most recent SendRequestL/SendResponseL
       
   179 	//call. Not owned.
       
   180 	MSendStatus* iObserver;
       
   181 
       
   182     //Transport layer used for sending
       
   183 	MSipConnectionMgr& iConnectionMgr;
       
   184 
       
   185 #ifdef CPPUNIT_TEST	
       
   186 	friend class CTransmitter_Test;
       
   187 	friend class CInviteCTa_Completed_Test;
       
   188 #endif
       
   189 	};
       
   190 
       
   191 #endif // end of TRANSMITTER_H
       
   192 
       
   193 // End of File