realtimenetprots/sipfw/SIP/Transaction/src/InviteClientTa.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          : InviteClientTa.h
       
    16 * Part of       : Transaction
       
    17 * Version       : SIP/5.0
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 #ifndef INVITECLIENTTA_H
       
    29 #define INVITECLIENTTA_H
       
    30 
       
    31 // INCLUDES
       
    32 #include "ClientTransaction.h"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CTimerBase;
       
    36 class CTimerRetransmit;
       
    37 class CTimerTerminateTa;
       
    38 
       
    39 // CLASS DECLARATION
       
    40 /*
       
    41  * This class is used for sending INVITE, receiving responses to it and sending
       
    42  * ACK.
       
    43  */
       
    44 class CInviteClientTransaction : public CClientTransaction
       
    45 	{
       
    46 public: // Constructors and destructor
       
    47 
       
    48 	/**
       
    49 	 * Creates a new instance of CInviteClientTransaction	 
       
    50 	 *
       
    51 	 * @param aUserAgent UserAgent owning the new transaction being created.
       
    52 	 * @param aTransmitter CTransmitter used for sending messages
       
    53 	 * @param aTimers Timer services interface
       
    54 	 * @param aInitialState Initial state of the CTransaction object
       
    55 	 * @param aTimerValues Values for calculating timer durations
       
    56 	 * @param aTransactionStore TransactionStore
       
    57 	 * @param aRetransmitInvite If ETrue and using UDP, INVITE is retransmitted
       
    58 	 *		  even after receiving a provisional response.
       
    59 	 * @return New CInviteClientTransaction object, ownership is transferred
       
    60 	 */
       
    61 	static CInviteClientTransaction*
       
    62 		NewL(CUserAgentBase& aUserAgent,
       
    63 			 CTransmitter& aTransmitter,
       
    64 			 MTimerManager& aTimers,
       
    65 			 CTransactionState& aInitialState,
       
    66 			 TTimerValues& aTimerValues,
       
    67 			 MTransactionStore& aTransactionStore,
       
    68 			 TBool aRetransmitInvite);
       
    69 
       
    70 	~CInviteClientTransaction();
       
    71 
       
    72 public: // From CClientTransaction:
       
    73 
       
    74 	void DeleteTimer(const CTransactionTimer& aTimer);
       
    75 
       
    76 	TBool IsInviteTransaction() const;
       
    77 
       
    78 public: // New functions
       
    79 
       
    80 	/**
       
    81 	 * Receive a response.
       
    82 	 *	 
       
    83 	 * @pre aResponse != NULL
       
    84 	 *
       
    85      * @param aResponse SIP response, ownership is transferred
       
    86      * @param aCurrent Transaction's current state
       
    87      * @param aCompleted Completed state of transaction state machine
       
    88      * @param aTimer If non-NULL, this timer is stopped if leave occurs.
       
    89      *		  Ownership is not transferred.
       
    90      * @param aTimer2 If non-NULL, this timer is stopped if leave occurs.
       
    91      *		  Ownership is not transferred.
       
    92 	 */
       
    93 	void ReceiveResponseL(CSIPResponse* aResponse,
       
    94 						  const CTransactionState& aCurrent,                            
       
    95                           const CTransactionState& aCompleted,
       
    96                           CTransactionTimer* aTimer=NULL,
       
    97                           CTransactionTimer* aTimer2=NULL);
       
    98 
       
    99 	/**
       
   100 	 * Send ACK created by transaction to network.
       
   101 	 *
       
   102 	 * @post iOutgoingMsg = aAck
       
   103 	 *
       
   104 	 * @param aAck ACK request, ownership is transferred.	 
       
   105 	 */	
       
   106 	void SendAck(CSIPRequest* aAck);
       
   107 
       
   108 	/**
       
   109 	 * Starts timer A.
       
   110 	 *	 
       
   111 	 * @pre iTimerA = NULL	 
       
   112 	 */
       
   113 	void StartTimerAL();
       
   114 
       
   115 	/**
       
   116 	 * Starts timer B, unless it is already running.	 
       
   117 	 */
       
   118 	void StartTimerBUnlessExistsL();
       
   119 
       
   120 	/**
       
   121 	 * Starts timer D, unless it is already running.
       
   122 	 */
       
   123 	void StartTimerDUnlessExistsL();
       
   124 
       
   125 	/**
       
   126 	 * Starts timer for waiting a final response in the Proceeding state.
       
   127 	 *	 
       
   128 	 * @pre iTimerProceeding = NULL
       
   129 	 *
       
   130 	 * @return The new timer, ownership is not transferred
       
   131 	 */
       
   132 	CTransactionTimer* StartTimerProceedingL();
       
   133 
       
   134 	/**
       
   135 	 * Depending on the value of iRetransmitInvite, starts timer for INVITE
       
   136 	 * retransmissions to keep NAT binding alive.
       
   137 	 *
       
   138 	 * @pre iTimerNAT = NULL
       
   139 	 *
       
   140 	 * @return The new timer, ownership is not transferred. NULL if the timer
       
   141 	 *	was not started.
       
   142 	 */
       
   143 	CTransactionTimer* StartTimerNATL();
       
   144 
       
   145 	/**
       
   146 	 * Stops timer A.
       
   147 	 *
       
   148 	 * @post iTimerA = NULL	 
       
   149 	 */
       
   150 	void StopTimerA();
       
   151 
       
   152 	/**
       
   153 	 * Stops timer B
       
   154 	 *
       
   155 	 * @post iTimerB = NULL	 
       
   156 	 */
       
   157 	void StopTimerB();
       
   158 
       
   159 	/**
       
   160 	 * Stops timer used in Proceeding state.
       
   161 	 *	 
       
   162 	 * @post iTimerProceeding = NULL	 
       
   163 	 */
       
   164 	void StopTimerProceeding();
       
   165 	
       
   166 	/**
       
   167 	 * Stops NAT binding keepalive timer.
       
   168 	 *
       
   169 	 * @post iTimerNAT = NULL	 
       
   170 	 */
       
   171 	void StopTimerNAT();
       
   172 
       
   173 	static CInviteClientTransaction& Ptr(CTransaction& aTransaction);
       
   174 
       
   175 private: // Constructor, for internal use
       
   176 
       
   177 	CInviteClientTransaction(CUserAgentBase& aUserAgent,
       
   178 							 CTransmitter& aTransmitter,
       
   179 							 MTimerManager& aTimers,
       
   180 							 CTransactionState& aInitialState,
       
   181 							 TTimerValues& aTimerValues,
       
   182 							 MTransactionStore& aTransactionStore,
       
   183 							 TBool aRetransmitInvite);
       
   184 
       
   185 private: // New functions, for internal use
       
   186 
       
   187 	/**
       
   188 	 * Creates an ACK request and pushes it to CleanupStack.
       
   189 	 *
       
   190 	 * @param aResp SIP response for which the ACK is an acknowledgement
       
   191 	 * @return ACK request, ownership is transferred
       
   192 	 */	
       
   193 	CSIPRequest* MakeAckLC(CSIPResponse& aResp) const;
       
   194 
       
   195 	/**
       
   196 	 * Copies information from the INVITE into ACK. Copies Request-URI, From,
       
   197 	 * Call-ID and the top Via header, that has been completely filled by
       
   198 	 * ConnectionMgr.
       
   199 	 *
       
   200 	 * @param aAck ACK request
       
   201 	 */
       
   202 	void CopyHeadersFromInviteToAckL(CSIPRequest& aAck) const;	
       
   203 
       
   204 	/**
       
   205 	 * Stops timer D
       
   206 	 *	 
       
   207 	 * @post iTimerD = NULL
       
   208 	 */
       
   209 	void StopTimerD();
       
   210 
       
   211 	/**
       
   212 	 * Stops all timers of this transaction
       
   213 	 *
       
   214 	 * @post iTimerA = NULL, iTimerB = NULL, iTimerD = NULL	 
       
   215 	 */
       
   216 	void CancelAllTimers();
       
   217 
       
   218 private: // Data
       
   219 
       
   220 	//Tells if transaction owns the SIP request in CTransaction::iOutgoingMsg.
       
   221 	//Value is normally EFalse. Only when CInviteClientTransaction (instead of
       
   222 	//UAC) creates ACK and puts it to CTransaction::iOutgoingMsg, the value is
       
   223 	//ETrue.
       
   224 	TBool iTaOwnsRequest;
       
   225 
       
   226 	//Duration (ms) of timer A
       
   227 	TUint iTimerADuration;
       
   228 
       
   229 	//Retransmission timer
       
   230 	CTimerRetransmit* iTimerA;
       
   231 
       
   232 	//Transaction timeout timer
       
   233 	CTimerTerminateTa* iTimerB;
       
   234 
       
   235 	//Timer used to stop transaction waiting from response retransmissions in
       
   236 	//the Completed state
       
   237 	CTimerTerminateTa* iTimerD;
       
   238 
       
   239 	//Timer used to stop transaction if no final response is received in
       
   240 	//Proceeding state
       
   241 	CTimerTerminateTa* iTimerProceeding;
       
   242 
       
   243 	//If ETrue and using unreliable transport, INVITE is retransmitted even
       
   244 	//after receiving a provisional response, to keep the NAT binding alive.
       
   245 	TBool iRetransmitInvite;
       
   246 
       
   247 	//Retransmission timer to keep NAT binding alive.
       
   248 	CTimerRetransmit* iTimerNAT;
       
   249 
       
   250 	//Error code that will be passed while starting the Timer D
       
   251 	TInt iDTimerErrCode;
       
   252 
       
   253 private: // For testing purposes
       
   254 
       
   255 	void __DbgTestInvariant() const;
       
   256 
       
   257 
       
   258 #ifdef CPPUNIT_TEST
       
   259 	friend class CTransactionUser_Test;
       
   260 	friend class CInviteCTa_Calling_Test;
       
   261 	friend class CInviteCTa_Completed_Test;
       
   262 #endif
       
   263 	};
       
   264 
       
   265 #endif // end of INVITECLIENTTA_H
       
   266 
       
   267 // End of File