|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : InviteClientTaStates.cpp |
|
15 // Part of : Transaction |
|
16 // Version : SIP/5.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "siprequest.h" |
|
22 #include "sipresponse.h" |
|
23 #include "SipAssert.h" |
|
24 #include "SIPMessageUtility.h" |
|
25 |
|
26 #include "InviteClientTa.h" |
|
27 #include "InviteClientTaStates.h" |
|
28 #include "ClearProxy.h" |
|
29 |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CInviteClientTa_Calling::CInviteClientTa_Calling |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CInviteClientTa_Calling::CInviteClientTa_Calling() |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CInviteClientTa_Calling::~CInviteClientTa_Calling |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CInviteClientTa_Calling::~CInviteClientTa_Calling() |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CInviteClientTa_Calling::GetState |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CInviteClientTa_Calling::GetState(CSIPInternalStates::TState& aState) const |
|
52 { |
|
53 aState = CSIPInternalStates::ETransactionCalling; |
|
54 } |
|
55 |
|
56 #if defined(USE_SIP_LOGS) |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CInviteClientTa_Calling::Log |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 const TDesC8& CInviteClientTa_Calling::Log() const |
|
62 { |
|
63 _LIT8(KState, "Calling"); |
|
64 return KState; |
|
65 } |
|
66 #endif |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CInviteClientTa_Calling::SetNeighbourStates |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void |
|
73 CInviteClientTa_Calling::SetNeighbourStates(CTransactionState& aProceeding, |
|
74 CTransactionState& aCompleted) |
|
75 { |
|
76 iProceeding = &aProceeding; |
|
77 iCompleted = &aCompleted; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CInviteClientTa_Calling::SendRequestL |
|
82 // CleanupItem handles ownership of aOutboundProxy in case of leave. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CInviteClientTa_Calling::SendRequestL(CTransaction& aTransaction, |
|
86 CSIPRequest& aInvite, |
|
87 const TInetAddr& aAddress, |
|
88 RStringF aProtocol, |
|
89 TBool aForceUDP, |
|
90 const TSIPTransportParams& aParams, |
|
91 CUri8* aOutboundProxy) const |
|
92 { |
|
93 __SIP_ASSERT_LEAVE(CSIPMessageUtility::CheckTransport(aProtocol), |
|
94 KErrArgument); |
|
95 |
|
96 CInviteClientTransaction& ta = CInviteClientTransaction::Ptr(aTransaction); |
|
97 |
|
98 TClearProxy clearProxy(ta); |
|
99 CleanupStack::PushL(clearProxy.CleanupItem()); |
|
100 |
|
101 ta.StoreRequest(aInvite, |
|
102 aAddress, |
|
103 aParams, |
|
104 aProtocol, |
|
105 aForceUDP, |
|
106 aOutboundProxy); |
|
107 ta.SendToTransmitterL(); |
|
108 |
|
109 CleanupStack::Pop(); //cleanupItem |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CInviteClientTa_Calling::SendCompleteL |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CInviteClientTa_Calling::SendCompleteL(CTransaction& aTransaction) const |
|
117 { |
|
118 CInviteClientTransaction& ta = CInviteClientTransaction::Ptr(aTransaction); |
|
119 ta.CheckForTransportChange(); |
|
120 ta.StartTimerBUnlessExistsL(); |
|
121 |
|
122 if (aTransaction.IsUnreliableTransportUsed()) |
|
123 { |
|
124 ta.StartTimerAL(); |
|
125 } |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CInviteClientTa_Calling::SendFailedL |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CInviteClientTa_Calling::SendFailedL(CTransaction& aTransaction, |
|
133 TInt aError) const |
|
134 { |
|
135 aTransaction.TerminatedL(aError); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CInviteClientTa_Calling::ReceiveL |
|
140 // If 2xx is received, UAC terminates the transaction. Stop timers when |
|
141 // transaction can't return to previous state (ReceiveResponseL has returned). |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CInviteClientTa_Calling::ReceiveL(CTransaction& aTransaction, |
|
145 CSIPResponse* aResponse) const |
|
146 { |
|
147 __SIP_ASSERT_LEAVE(aResponse, KErrArgument); |
|
148 |
|
149 CInviteClientTransaction& ta = CInviteClientTransaction::Ptr(aTransaction); |
|
150 |
|
151 if (ta.ShouldTaHandleResponse(aResponse)) |
|
152 { |
|
153 CTransactionTimer* proceedingTimer = NULL; |
|
154 CTransactionTimer* natTimer = NULL; |
|
155 if (!CSIPMessageUtility::IsFinalResponse(*aResponse)) |
|
156 { |
|
157 proceedingTimer = ta.StartTimerProceedingL(); |
|
158 natTimer = ta.StartTimerNATL(); |
|
159 aTransaction.ChangeState(*iProceeding); |
|
160 } |
|
161 |
|
162 ta.ReceiveResponseL(aResponse, |
|
163 *this, |
|
164 *iCompleted, |
|
165 proceedingTimer, |
|
166 natTimer); |
|
167 //Stop retransmission timer A. Timer B has only effect in Calling state |
|
168 ta.StopTimerA(); |
|
169 ta.StopTimerB(); |
|
170 } |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CInviteClientTa_Calling::TimerExpiredL |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CInviteClientTa_Calling::TimerExpiredL(CTransaction& aTransaction, |
|
178 TTimerId aTimerId, |
|
179 TAny* aTimerParam) const |
|
180 { |
|
181 __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument); |
|
182 |
|
183 HandleTimerExpirationL(aTransaction, aTimerId, aTimerParam); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CInviteClientTa_Proceeding::CInviteClientTa_Proceeding |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 CInviteClientTa_Proceeding::CInviteClientTa_Proceeding() |
|
191 { |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CInviteClientTa_Proceeding::~CInviteClientTa_Proceeding |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 CInviteClientTa_Proceeding::~CInviteClientTa_Proceeding() |
|
199 { |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CInviteClientTa_Proceeding::GetState |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 void |
|
207 CInviteClientTa_Proceeding::GetState(CSIPInternalStates::TState& aState) const |
|
208 { |
|
209 aState = CSIPInternalStates::ETransactionProceeding; |
|
210 } |
|
211 |
|
212 #if defined(USE_SIP_LOGS) |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CInviteClientTa_Proceeding::Log |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 const TDesC8& CInviteClientTa_Proceeding::Log() const |
|
218 { |
|
219 _LIT8(KState, "Proceeding"); |
|
220 return KState; |
|
221 } |
|
222 #endif |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CInviteClientTa_Proceeding::SetNeighbourStates |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void |
|
229 CInviteClientTa_Proceeding::SetNeighbourStates(CTransactionState& aCompleted) |
|
230 { |
|
231 iCompleted = &aCompleted; |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CInviteClientTa_Proceeding::SendCompleteL |
|
236 // Occurs if 1xx comes before CTransmitter sent SendCompleteL or if iTimerNAT |
|
237 // retransmitted INVITE. |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void CInviteClientTa_Proceeding::SendCompleteL(CTransaction& aTransaction) const |
|
241 { |
|
242 CInviteClientTransaction& ta = CInviteClientTransaction::Ptr(aTransaction); |
|
243 ta.CheckForTransportChange(); |
|
244 ta.StartTimerNATL(); |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // CInviteClientTa_Proceeding::SendFailedL |
|
249 // ----------------------------------------------------------------------------- |
|
250 // |
|
251 void CInviteClientTa_Proceeding::SendFailedL(CTransaction& aTransaction, |
|
252 TInt aError) const |
|
253 { |
|
254 aTransaction.TerminatedL(aError); |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CInviteClientTa_Proceeding::ReceiveL |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void CInviteClientTa_Proceeding::ReceiveL(CTransaction& aTransaction, |
|
262 CSIPResponse* aResponse) const |
|
263 { |
|
264 __SIP_ASSERT_LEAVE(aResponse, KErrArgument); |
|
265 |
|
266 CInviteClientTransaction& ta = CInviteClientTransaction::Ptr(aTransaction); |
|
267 |
|
268 if (ta.ShouldTaHandleResponse(aResponse)) |
|
269 { |
|
270 TBool isErrorResponse = aResponse->IsErrorResponse(); |
|
271 ta.ReceiveResponseL(aResponse, *this, *iCompleted); |
|
272 if (isErrorResponse) |
|
273 { |
|
274 ta.StopTimerProceeding(); |
|
275 ta.StopTimerNAT(); |
|
276 } |
|
277 } |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CInviteClientTa_Proceeding::TimerExpiredL |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void CInviteClientTa_Proceeding::TimerExpiredL(CTransaction& aTransaction, |
|
285 TTimerId aTimerId, |
|
286 TAny* aTimerParam) const |
|
287 { |
|
288 __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument); |
|
289 |
|
290 HandleTimerExpirationL(aTransaction, aTimerId, aTimerParam); |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CInviteClientTa_Completed::CInviteClientTa_Completed |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 CInviteClientTa_Completed::CInviteClientTa_Completed() |
|
298 { |
|
299 } |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
|
302 // CInviteClientTa_Completed::~CInviteClientTa_Completed |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 CInviteClientTa_Completed::~CInviteClientTa_Completed() |
|
306 { |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CInviteClientTa_Completed::GetState |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 void |
|
314 CInviteClientTa_Completed::GetState(CSIPInternalStates::TState& aState) const |
|
315 { |
|
316 aState = CSIPInternalStates::ETransactionCompleted; |
|
317 } |
|
318 |
|
319 #if defined(USE_SIP_LOGS) |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CInviteClientTa_Completed::Log |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 const TDesC8& CInviteClientTa_Completed::Log() const |
|
325 { |
|
326 _LIT8(KState, "Completed"); |
|
327 return KState; |
|
328 } |
|
329 #endif |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CInviteClientTa_Completed::SendCompleteL |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 void CInviteClientTa_Completed::SendCompleteL(CTransaction& aTransaction) const |
|
336 { |
|
337 CInviteClientTransaction::Ptr(aTransaction).StartTimerDUnlessExistsL(); |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CInviteClientTa_Completed::SendFailedL |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 void CInviteClientTa_Completed::SendFailedL(CTransaction& aTransaction, |
|
345 TInt aError) const |
|
346 { |
|
347 aTransaction.TerminatedL(aError); |
|
348 } |
|
349 |
|
350 // ----------------------------------------------------------------------------- |
|
351 // CInviteClientTa_Completed::ReceiveL |
|
352 // Retransmit ACK unless currently being sent. |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 void CInviteClientTa_Completed::ReceiveL(CTransaction& aTransaction, |
|
356 CSIPResponse* aResponse) const |
|
357 { |
|
358 __SIP_ASSERT_LEAVE(aResponse, KErrArgument); |
|
359 |
|
360 if (!aTransaction.IsTransmitterSending() && aResponse->IsErrorResponse()) |
|
361 { |
|
362 CInviteClientTransaction::Ptr(aTransaction).SendToTransmitterL(); |
|
363 } |
|
364 |
|
365 delete aResponse; |
|
366 } |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // CInviteClientTa_Completed::TimerExpiredL |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 void CInviteClientTa_Completed::TimerExpiredL(CTransaction& aTransaction, |
|
373 TTimerId aTimerId, |
|
374 TAny* aTimerParam) const |
|
375 { |
|
376 __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument); |
|
377 |
|
378 HandleTimerExpirationL(aTransaction, aTimerId, aTimerParam); |
|
379 } |