realtimenetprots/sipfw/SIP/Transaction/inc/ServerTransaction.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          : ServerTransaction.h
       
    16 * Part of       : Transaction
       
    17 * Version       : SIP/5.0
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @internalComponent
       
    26 */
       
    27 
       
    28 #ifndef SERVERTRANSACTION_H
       
    29 #define SERVERTRANSACTION_H
       
    30 
       
    31 // INCLUDES
       
    32 #include "CTransaction.h"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CResponseQueue;
       
    36 class CResponseQueueItem;
       
    37 
       
    38 // CLASS DECLARATION
       
    39 /*
       
    40  * This class represents a server transaction. It is created for handling an
       
    41  * incoming SIP request message and the SIP response message associated with it.
       
    42  */
       
    43 class CServerTransaction : public CTransaction
       
    44 	{
       
    45 public: // Destructor
       
    46 
       
    47 	~CServerTransaction();	
       
    48 
       
    49 public:	//From CTransaction
       
    50 
       
    51 	void IcmpErrorL(const TInetAddr& aAddress,
       
    52 					CSipConnectionMgr::TICMPError aError);
       
    53 
       
    54 	virtual void DeleteTimer(const CTransactionTimer& aTimer) = 0;
       
    55 
       
    56 	virtual void TerminatedL(TInt aReason);
       
    57 
       
    58 public: //New functions
       
    59 
       
    60 	void PassRequestToUserAgentL(CSIPRequest* aReq);
       
    61 
       
    62 	TBool RequestPassedToUA() const;
       
    63 
       
    64 	/**
       
    65 	 * Creates a 100 response to the SIP request and places it into send
       
    66 	 * buffer (CTransaction::iOutgoingMsg).
       
    67 	 *
       
    68 	 * @pre iOutgoingMsg = NULL
       
    69 	 *
       
    70 	 * @param aReq SIP request which has been received
       
    71 	 */
       
    72 	void Create100L(CSIPRequest& aReq);
       
    73 
       
    74 	void SendToTransmitterL();
       
    75 
       
    76 	/**
       
    77 	 * Sends a SIP response using the currently selected transport protocol and
       
    78 	 * stores the response and its transport parameters.
       
    79 	 *
       
    80 	 * @pre aRespItem != NULL	 
       
    81 	 *
       
    82 	 * @param aRespItem Response item containing the SIP response to be sent.
       
    83 	 *	Ownership is transferred.	 
       
    84 	 */	
       
    85 	void SendAndStoreResponseL(CResponseQueueItem* aRespItem);
       
    86 
       
    87 	/**
       
    88 	 * Sends a SIP response using the transport protocol specified by
       
    89 	 * aTransportProtocol and stores the response and its transport
       
    90 	 * parameters.
       
    91 	 *
       
    92 	 * @pre aRespItem != NULL
       
    93 	 * @pre CSIPMessageUtility::CheckTransport(aTransportProtocol) == ETrue
       
    94 	 *
       
    95 	 * @param aRespItem Response item which is stored in the send queue,
       
    96 	 *	ownership is transferred
       
    97 	 * @param aTransportProtocol Transport protocol to use
       
    98 	 */	
       
    99 	void SendAndStoreResponseL(CResponseQueueItem* aRespItem,
       
   100 							   RStringF aTransportProtocol);
       
   101 	
       
   102 	/**	
       
   103 	 * Adds the response item into the send queue.
       
   104 	 *
       
   105 	 * @pre aRespItem != NULL
       
   106 	 *
       
   107 	 * @param aRespItem Response item which is stored in the send queue,
       
   108 	 *	ownership is transferred	 
       
   109 	 */	
       
   110 	void AddResponseToSendQueueL(CResponseQueueItem* aRespItem) const;
       
   111 
       
   112 	/**
       
   113 	 * Extracts the oldest response from iSendQueue.
       
   114 	 *
       
   115 	 * @return value Response item, or NULL if there are no SIP responses in
       
   116 	 *	the queue. Ownership is transferred.
       
   117 	 */
       
   118 	CResponseQueueItem* GetResponseFromSendQueue() const;	
       
   119 
       
   120 protected:
       
   121 
       
   122 	CServerTransaction(CUserAgentBase& aUserAgent,
       
   123 					   CTransmitter& aTransmitter,
       
   124 					   MTimerManager& aTimers,
       
   125 					   CTransactionState& aInitialState,
       
   126 					   TTimerValues& aTimerValues);
       
   127 
       
   128 	void ConstructServerTaL();
       
   129 
       
   130 private:
       
   131 
       
   132 	void CancelAllTimers() = 0;
       
   133 
       
   134 private: // Data
       
   135 
       
   136 	//Contains the SIP responses that haven't been sent to ConnectionMgr yet.
       
   137 	//If several responses are passed to ServerTransaction quicker than it can
       
   138 	//send them forward, responses are stored here until they can be sent.
       
   139 	//
       
   140 	//CServerTransaction owns the queue. The ownership of the SIP responses
       
   141 	//depends on the value of CResponseQueueItem::iOwnsResponse.
       
   142 	CResponseQueue* iSendQueue;
       
   143 
       
   144 	//Contains the previously sent responses. They can't be deleted when a next
       
   145 	//response comes from UAS as ConnectionMgr might be sending them in case of
       
   146 	//an ICMP error.
       
   147 	//CServerTransaction owns the queue. The ownership of the SIP responses
       
   148 	//depends on the value of CResponseQueueItem::iOwnsResponse.
       
   149 	CResponseQueue* iSentResponses;
       
   150 
       
   151 	//ETrue if the SIP request from network has been passed to UserAgent.
       
   152 	//Used to filter out retransmissions.
       
   153 	TBool iRequestPassedToUA;	
       
   154 
       
   155 	void __DbgTestInvariant() const;
       
   156 
       
   157 
       
   158 #ifdef CPPUNIT_TEST
       
   159 	friend class CServerTransaction_Test;
       
   160 	friend class CTransactionUser_Test;
       
   161 #endif
       
   162 	};
       
   163 
       
   164 #endif // end of SERVERTRANSACTION_H
       
   165 
       
   166 // End of File