|
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 : ClientTransaction.h |
|
16 * Part of : Transaction |
|
17 * Version : SIP/5.0 |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 /** |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 #ifndef CLIENTTRANSACTION_H |
|
29 #define CLIENTTRANSACTION_H |
|
30 |
|
31 // INCLUDES |
|
32 #include "CTransaction.h" |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CDeleteMgr; |
|
36 class MTransactionStore; |
|
37 |
|
38 // CLASS DECLARATION |
|
39 /* |
|
40 * This class represents a client transaction. It is created for handling an |
|
41 * outgoing SIP request message and the SIP response message associated with it. |
|
42 */ |
|
43 class CClientTransaction : public CTransaction |
|
44 { |
|
45 public: // Destructor |
|
46 |
|
47 ~CClientTransaction(); |
|
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 /** |
|
57 * ClientTransaction enters terminated state. If transaction has been |
|
58 * detached from the UAC, it uses DeleteMgr to free itself. |
|
59 * |
|
60 * @param aReason Reason why ClientTransaction ends |
|
61 */ |
|
62 void TerminatedL(TInt aReason); |
|
63 |
|
64 /** |
|
65 * Sends the SIP request in the send buffer (iOutgoingMsg) to CTransmitter. |
|
66 * |
|
67 * CClientTransaction passes a reference to the iOutgoingMsg for the |
|
68 * CTransmitter, which in turn gives a reference to the request for the |
|
69 * ConnectionMgr. |
|
70 * |
|
71 * UAC owns the request, unless it is an ACK created by |
|
72 * CInviteClientTransaction instead of UAC. |
|
73 * |
|
74 * @pre iOutgoingMsg != NULL, iTransmitter isn't active |
|
75 */ |
|
76 void SendToTransmitterL(); |
|
77 |
|
78 private: // From CTransaction |
|
79 |
|
80 virtual void CancelAllTimers() = 0; |
|
81 |
|
82 public: // New functions |
|
83 |
|
84 TTransactionId TransactionId() const; |
|
85 |
|
86 /** |
|
87 * Stores SIP request and related parameters. |
|
88 * |
|
89 * @pre !iOutgoingMsg && !iOutboundProxy |
|
90 * |
|
91 * @param aReq SIP request |
|
92 * @param aAddress Address where the request will be sent to |
|
93 * @param aParams Transport parameters to use when sending the SIP request |
|
94 * @param aTransportProtocol The transport protocol used for sending |
|
95 * @param aForceUDP ETrue if transport protocol can't be changed from UDP |
|
96 * @param aOutboundProxy Outbound proxy, NULL pointer if not used. |
|
97 * The ownership is transferred. |
|
98 */ |
|
99 void StoreRequest(CSIPRequest& aReq, |
|
100 const TInetAddr& aAddress, |
|
101 const TSIPTransportParams& aParams, |
|
102 RStringF aTransportProtocol, |
|
103 TBool aForceUDP, |
|
104 CUri8* aOutboundProxy); |
|
105 |
|
106 /** |
|
107 * Clears, but does not delete, the outbound proxy. |
|
108 * |
|
109 * @post iOutboundProxy == NULL |
|
110 */ |
|
111 void ClearProxy(); |
|
112 |
|
113 /** |
|
114 * Filter out retransmissions and invalid SIP responses. |
|
115 * |
|
116 * @param aResp Received SIP response |
|
117 * @return ETrue: Transaction will handle the response, ownership of aResp |
|
118 * isn't transferred. |
|
119 * EFalse: Response is dropped, ownership of aResp has been transferred. |
|
120 */ |
|
121 TBool ShouldTaHandleResponse(CSIPResponse* aResp) const; |
|
122 |
|
123 /** |
|
124 * Forwards the SIP response to UAC. |
|
125 * |
|
126 * @pre iUserAgent != NULL, aResp != NULL |
|
127 * |
|
128 * @param aResp SIP response, ownership is transferred |
|
129 */ |
|
130 void PassResponseToUserAgentL(CSIPResponse* aResp); |
|
131 |
|
132 /** |
|
133 * CTransaction will run independently of UAC. |
|
134 * |
|
135 * CNormalClientTransaction absorbs response retransmissions. |
|
136 * |
|
137 * CInviteClientTransaction sends ACK to a non-2xx response by itself, and |
|
138 * takes ownership of CTransaction::iTransmitter. |
|
139 * |
|
140 * @param aTransactionId TransactionId that CTransaction will use to |
|
141 * remove its information from MTransactionStore |
|
142 * @param aDeleteMgr DeleteMgr to use to free the transaction when it |
|
143 * terminates. Ownership isn't transferred. |
|
144 * @param aClearTransmitter If ETrue, transaction detaches itself from |
|
145 * CTransmitter and clears its pointer to it. |
|
146 */ |
|
147 void RunIndependently(TTransactionId aTransactionId, |
|
148 CDeleteMgr* aDeleteMgr, |
|
149 TBool aClearTransmitter); |
|
150 |
|
151 /** |
|
152 * Check if ConnectionMgr has changed the transport protocol in the top |
|
153 * Via header from the value that transaction used. If transport changes, |
|
154 * it affects some transaction timers. |
|
155 */ |
|
156 void CheckForTransportChange(); |
|
157 |
|
158 protected: |
|
159 |
|
160 /** |
|
161 * Constructor |
|
162 * |
|
163 * @param aUserAgent UAC owning the new transaction being created. |
|
164 * @param aTransmitter CTransmitter for sending requests |
|
165 * @param aTimers Timer services |
|
166 * @param aInitialState Initial state of the transaction |
|
167 * @param aTimerValues Values for calculating timer durations |
|
168 * @param aTransactionStore TransactionStore |
|
169 */ |
|
170 CClientTransaction(CUserAgentBase& aUserAgent, |
|
171 CTransmitter& aTransmitter, |
|
172 MTimerManager& aTimers, |
|
173 CTransactionState& aInitialState, |
|
174 TTimerValues& aTimerValues, |
|
175 MTransactionStore& aTransactionStore); |
|
176 |
|
177 /** |
|
178 * Check whether the received SIP response is ok. |
|
179 * |
|
180 * @param aResp SIP response |
|
181 * @return value ETrue the response is ok, |
|
182 * EFalse otherwise |
|
183 */ |
|
184 TBool CheckReceivedResponse(CSIPResponse& aResp) const; |
|
185 |
|
186 protected: // Data |
|
187 |
|
188 //Used for deleting CClientTransaction if it has been detached from the UAC. |
|
189 //This is non-NULL only when UAC decided to send the request again, using |
|
190 //another transaction instance. |
|
191 //If iDeleteMgr is non-NULL, CInviteClientTransaction owns the |
|
192 //CTransaction::iTransmitter. |
|
193 CDeleteMgr* iDeleteMgr; |
|
194 |
|
195 private: // Data |
|
196 |
|
197 //The response code of the most recently received SIP response. Used to |
|
198 //filter the retransmissions from being sent to UserAgent. |
|
199 TUint iReceivedResponseCode; |
|
200 |
|
201 //Address where the SIP request is sent. Obtained from UserAgent and |
|
202 //stored here for retransmissions. |
|
203 TInetAddr iRemoteAddr; |
|
204 |
|
205 //ETrue if transport protocol can't be changed from UDP |
|
206 TBool iForceUDP; |
|
207 |
|
208 //iTransactionId and iTransactionStore are needed by a detached transaction |
|
209 //when UserAgent has created another transaction to send an updated request. |
|
210 |
|
211 //Identifies the transaction |
|
212 TTransactionId iTransactionId; |
|
213 |
|
214 //A detached transaction must remove its information from MTransactionStore |
|
215 //when terminating, since UAC is attached to the new transaction, and no |
|
216 //longer to the old transaction(s). |
|
217 MTransactionStore& iTransactionStore; |
|
218 |
|
219 //Outbound proxy, or NULL if proxy is not used. Owned. |
|
220 CUri8* iOutboundProxy; |
|
221 |
|
222 private: // For testing purposes |
|
223 |
|
224 void __DbgTestInvariant() const; |
|
225 |
|
226 |
|
227 #ifdef CPPUNIT_TEST |
|
228 friend class ClientTransaction_Test; |
|
229 friend class CNormalCTa_Trying_Test; |
|
230 friend class CTransactionUser_Test; |
|
231 friend class CInviteCTa_Calling_Test; |
|
232 #endif |
|
233 }; |
|
234 |
|
235 #endif // end of CLIENTTRANSACTION_H |
|
236 |
|
237 // End of File |