|
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 : InviteServerTaStates.cpp |
|
15 // Part of : Transaction |
|
16 // Version : SIP/5.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "siperr.h" |
|
22 #include "siprequest.h" |
|
23 #include "sipresponse.h" |
|
24 #include "SipAssert.h" |
|
25 #include "SIPMessageUtility.h" |
|
26 #include "sipstrings.h" |
|
27 #include "sipstrconsts.h" |
|
28 |
|
29 #include "InviteServerTa.h" |
|
30 #include "InviteServerTaStates.h" |
|
31 #include "ResponseQueueItem.h" |
|
32 |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CInviteServerTa_Proceeding::CInviteServerTa_Proceeding |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CInviteServerTa_Proceeding::CInviteServerTa_Proceeding() |
|
39 { |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CInviteServerTa_Proceeding::~CInviteServerTa_Proceeding |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CInviteServerTa_Proceeding::~CInviteServerTa_Proceeding() |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CInviteServerTa_Proceeding::GetState |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void |
|
55 CInviteServerTa_Proceeding::GetState(CSIPInternalStates::TState& aState) const |
|
56 { |
|
57 aState = CSIPInternalStates::ETransactionProceeding; |
|
58 } |
|
59 |
|
60 #if defined(USE_SIP_LOGS) |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CInviteServerTa_Proceeding::Log |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 const TDesC8& CInviteServerTa_Proceeding::Log() const |
|
66 { |
|
67 _LIT8(KState, "Proceeding"); |
|
68 return KState; |
|
69 } |
|
70 #endif |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CInviteServerTa_Proceeding::SetNeighbourStates |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void |
|
77 CInviteServerTa_Proceeding::SetNeighbourStates(CTransactionState& aCompleted, |
|
78 CTransactionState& aSending2xx) |
|
79 { |
|
80 iCompleted = &aCompleted; |
|
81 iSending2xx = &aSending2xx; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CInviteServerTa_Proceeding::ReceiveL |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CInviteServerTa_Proceeding::ReceiveL(CTransaction& aTransaction, |
|
89 CSIPRequest* aRequest) const |
|
90 { |
|
91 __SIP_ASSERT_LEAVE(aRequest, KErrArgument); |
|
92 |
|
93 CInviteServerTransaction& ta = CInviteServerTransaction::Ptr(aTransaction); |
|
94 if (!ta.RequestPassedToUA()) |
|
95 { |
|
96 __ASSERT_ALWAYS(ta.UpdateTransportProtocol(*aRequest), |
|
97 User::Leave(KErrSIPMalformedMessage)); |
|
98 ta.Create100L(*aRequest); |
|
99 } |
|
100 |
|
101 //Send the most recent response, unless already being sent |
|
102 if (!ta.IsTransmitterSending()) |
|
103 { |
|
104 ta.SendToTransmitterL(); |
|
105 } |
|
106 |
|
107 if (ta.RequestPassedToUA()) |
|
108 { |
|
109 //Absorb retransmissions |
|
110 delete aRequest; |
|
111 } |
|
112 else |
|
113 { |
|
114 //Pass the first INVITE to UAS |
|
115 ta.PassRequestToUserAgentL(aRequest); |
|
116 } |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CInviteServerTa_Proceeding::SendResponseL |
|
121 // Queue the new response, if a previous response is being sent. |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void CInviteServerTa_Proceeding::SendResponseL(CTransaction& aTransaction, |
|
125 CSIPResponse* aResp, |
|
126 RStringF aProtocol, |
|
127 const TSIPTransportParams& aParams) const |
|
128 { |
|
129 __SIP_ASSERT_LEAVE(aResp, KErrArgument); |
|
130 __SIP_ASSERT_LEAVE(CSIPMessageUtility::CheckTransport(aProtocol), |
|
131 KErrArgument); |
|
132 |
|
133 CInviteServerTransaction& ta = CInviteServerTransaction::Ptr(aTransaction); |
|
134 TUint respCode = aResp->ResponseCode(); |
|
135 CResponseQueueItem* respItem = |
|
136 CResponseQueueItem::NewLC(aResp, aParams, ETrue); |
|
137 |
|
138 if (ta.IsTransmitterSending()) |
|
139 { |
|
140 ta.AddResponseToSendQueueL(respItem); |
|
141 } |
|
142 else |
|
143 { |
|
144 /* TimerH is started after the StateChange and sending the Response |
|
145 * This is done to avoid the timer expiry in proceeding state if |
|
146 * SendAndStoreResponseL() function leaves and state change doesn't happen |
|
147 * In proceeding State, timer expiry is not expected and not handled |
|
148 */ |
|
149 ta.ResponseSent(respCode, *iSending2xx, *iCompleted); |
|
150 |
|
151 ta.SendAndStoreResponseL(respItem, aProtocol); |
|
152 |
|
153 if (respCode >= 300) |
|
154 { |
|
155 ta.StartTimerHL(); |
|
156 } |
|
157 } |
|
158 CleanupStack::Pop(respItem); |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CInviteServerTa_Proceeding::SendCompleteL |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CInviteServerTa_Proceeding::SendCompleteL(CTransaction& aTransaction) const |
|
166 { |
|
167 CInviteServerTransaction& ta = CInviteServerTransaction::Ptr(aTransaction); |
|
168 CResponseQueueItem* respItem = ta.GetResponseFromSendQueue(); |
|
169 |
|
170 /* TimerH is started after the StateChange and sending the Response |
|
171 * This is done to avoid the timer expiry in proceeding state if |
|
172 * SendAndStoreResponseL() function leaves and state change doesn't happen |
|
173 * In proceeding State, timer expiry is not expected and not handled |
|
174 */ |
|
175 if (respItem) |
|
176 { |
|
177 CleanupStack::PushL(respItem); |
|
178 |
|
179 TUint respCode = respItem->Response().ResponseCode(); |
|
180 |
|
181 ta.ResponseSent(respCode, *iSending2xx, *iCompleted); |
|
182 |
|
183 ta.SendAndStoreResponseL(respItem); |
|
184 |
|
185 if (respCode >= 300) |
|
186 { |
|
187 ta.StartTimerHL(); |
|
188 } |
|
189 CleanupStack::Pop(respItem); |
|
190 } |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CInviteServerTa_Proceeding::SendFailedL |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CInviteServerTa_Proceeding::SendFailedL(CTransaction& aTransaction, |
|
198 TInt aError) const |
|
199 { |
|
200 aTransaction.TerminatedL(aError); |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CInviteServerTa_Completed::CInviteServerTa_Completed |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 CInviteServerTa_Completed::CInviteServerTa_Completed() |
|
208 { |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CInviteServerTa_Completed::~CInviteServerTa_Completed |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 CInviteServerTa_Completed::~CInviteServerTa_Completed() |
|
216 { |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CInviteServerTa_Completed::GetState |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 void |
|
224 CInviteServerTa_Completed::GetState(CSIPInternalStates::TState& aState) const |
|
225 { |
|
226 aState = CSIPInternalStates::ETransactionCompleted; |
|
227 } |
|
228 |
|
229 #if defined(USE_SIP_LOGS) |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CInviteServerTa_Completed::Log |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 const TDesC8& CInviteServerTa_Completed::Log() const |
|
235 { |
|
236 _LIT8(KState, "Completed"); |
|
237 return KState; |
|
238 } |
|
239 #endif |
|
240 |
|
241 // ----------------------------------------------------------------------------- |
|
242 // CInviteServerTa_Completed::SetNeighbourStates |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 void |
|
246 CInviteServerTa_Completed::SetNeighbourStates(CTransactionState& aConfirmed) |
|
247 { |
|
248 iConfirmed = &aConfirmed; |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // CInviteServerTa_Completed::SendCompleteL |
|
253 // Only one timer G exists at once. It can already exist if: |
|
254 // 1. Timer G is started |
|
255 // 2. INVITE is received and response sent |
|
256 // 3. SendCompleteL event comes while timer G is running |
|
257 // ----------------------------------------------------------------------------- |
|
258 // |
|
259 void CInviteServerTa_Completed::SendCompleteL(CTransaction& aTransaction) const |
|
260 { |
|
261 if (aTransaction.IsUnreliableTransportUsed()) |
|
262 { |
|
263 CInviteServerTransaction::Ptr(aTransaction).StartTimerGUnlessExistsL(); |
|
264 } |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CInviteServerTa_Completed::SendFailedL |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 void CInviteServerTa_Completed::SendFailedL(CTransaction& aTransaction, |
|
272 TInt aError) const |
|
273 { |
|
274 aTransaction.TerminatedL(aError); |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // CInviteServerTa_Completed::ReceiveL |
|
279 // Don't pass ACK to UAS. If retransmitted INVITE, retransmit the most recent |
|
280 // response unless already being sent. |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CInviteServerTa_Completed::ReceiveL(CTransaction& aTransaction, |
|
284 CSIPRequest* aRequest) const |
|
285 { |
|
286 __SIP_ASSERT_LEAVE(aRequest, KErrArgument); |
|
287 |
|
288 CInviteServerTransaction& ta = CInviteServerTransaction::Ptr(aTransaction); |
|
289 |
|
290 if (CSIPMessageUtility::IsAck(*aRequest)) |
|
291 { |
|
292 ta.EnterConfirmedStateL(*iConfirmed); |
|
293 } |
|
294 else |
|
295 { |
|
296 if ((aRequest->Method() == SIPStrings::StringF(SipStrConsts::EInvite)) |
|
297 && |
|
298 !ta.IsTransmitterSending()) |
|
299 { |
|
300 ta.SendToTransmitterL(); |
|
301 } |
|
302 } |
|
303 |
|
304 delete aRequest; |
|
305 } |
|
306 |
|
307 // ----------------------------------------------------------------------------- |
|
308 // CInviteServerTa_Completed::TimerExpiredL |
|
309 // ----------------------------------------------------------------------------- |
|
310 // |
|
311 void CInviteServerTa_Completed::TimerExpiredL(CTransaction& aTransaction, |
|
312 TTimerId aTimerId, |
|
313 TAny* aTimerParam) const |
|
314 { |
|
315 __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument); |
|
316 |
|
317 HandleTimerExpirationL(aTransaction, aTimerId, aTimerParam); |
|
318 } |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // CInviteServerTa_Confirmed::CInviteServerTa_Confirmed |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 CInviteServerTa_Confirmed::CInviteServerTa_Confirmed() |
|
325 { |
|
326 } |
|
327 |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CInviteServerTa_Confirmed::~CInviteServerTa_Confirmed |
|
330 // ----------------------------------------------------------------------------- |
|
331 // |
|
332 CInviteServerTa_Confirmed::~CInviteServerTa_Confirmed() |
|
333 { |
|
334 } |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CInviteServerTa_Confirmed::GetState |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 void |
|
341 CInviteServerTa_Confirmed::GetState(CSIPInternalStates::TState& aState) const |
|
342 { |
|
343 aState = CSIPInternalStates::ETransactionConfirmed; |
|
344 } |
|
345 |
|
346 #if defined(USE_SIP_LOGS) |
|
347 // ----------------------------------------------------------------------------- |
|
348 // CInviteServerTa_Confirmed::Log |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 const TDesC8& CInviteServerTa_Confirmed::Log() const |
|
352 { |
|
353 _LIT8(KState, "Confirmed"); |
|
354 return KState; |
|
355 } |
|
356 #endif |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // CInviteServerTa_Confirmed::CanContinueWithoutOutgoingMsg |
|
360 // This is never called for a server side. |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 TBool CInviteServerTa_Confirmed::CanContinueWithoutOutgoingMsg() const |
|
364 { |
|
365 return ETrue; |
|
366 } |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // CInviteServerTa_Confirmed::SendCompleteL |
|
370 // Happens if entered Confirmed state before CTransmitter finished sending. |
|
371 // Nothing is sent anymore, so no need to update transport protocol. |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 void |
|
375 CInviteServerTa_Confirmed::SendCompleteL(CTransaction& /*aTransaction*/) const |
|
376 { |
|
377 } |
|
378 |
|
379 // ----------------------------------------------------------------------------- |
|
380 // CInviteServerTa_Confirmed::SendFailedL |
|
381 // No action, wait for timer I to expire. |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 void CInviteServerTa_Confirmed::SendFailedL(CTransaction& /*aTransaction*/, |
|
385 TInt /*aError*/) const |
|
386 { |
|
387 } |
|
388 |
|
389 // ----------------------------------------------------------------------------- |
|
390 // CInviteServerTa_Confirmed::ReceiveL |
|
391 // Absorb any additional ACKs. |
|
392 // ----------------------------------------------------------------------------- |
|
393 // |
|
394 void CInviteServerTa_Confirmed::ReceiveL(CTransaction& /*aTransaction*/, |
|
395 CSIPRequest* aRequest) const |
|
396 { |
|
397 __SIP_ASSERT_LEAVE(aRequest, KErrArgument); |
|
398 |
|
399 delete aRequest; |
|
400 } |
|
401 |
|
402 // ----------------------------------------------------------------------------- |
|
403 // CInviteServerTa_Confirmed::TimerExpiredL |
|
404 // ----------------------------------------------------------------------------- |
|
405 // |
|
406 void CInviteServerTa_Confirmed::TimerExpiredL(CTransaction& aTransaction, |
|
407 TTimerId aTimerId, |
|
408 TAny* aTimerParam) const |
|
409 { |
|
410 __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument); |
|
411 |
|
412 HandleTimerExpirationL(aTransaction, aTimerId, aTimerParam); |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // CInviteServerTa_Sending2xx::CInviteServerTa_Sending2xx |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 CInviteServerTa_Sending2xx::CInviteServerTa_Sending2xx() |
|
420 { |
|
421 } |
|
422 |
|
423 // ----------------------------------------------------------------------------- |
|
424 // CInviteServerTa_Sending2xx::~CInviteServerTa_Sending2xx |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 CInviteServerTa_Sending2xx::~CInviteServerTa_Sending2xx() |
|
428 { |
|
429 } |
|
430 |
|
431 // ----------------------------------------------------------------------------- |
|
432 // CInviteServerTa_Sending2xx::GetState |
|
433 // 2xx was sent but SendCompleteL not yet received. Treat state as terminated, |
|
434 // as "Sending2xx" is implementation's internal state. |
|
435 // ----------------------------------------------------------------------------- |
|
436 // |
|
437 void |
|
438 CInviteServerTa_Sending2xx::GetState(CSIPInternalStates::TState& aState) const |
|
439 { |
|
440 aState = CSIPInternalStates::ETransactionTerminated; |
|
441 } |
|
442 |
|
443 #if defined(USE_SIP_LOGS) |
|
444 // ----------------------------------------------------------------------------- |
|
445 // CInviteServerTa_Sending2xx::Log |
|
446 // Don't log transition to this state, as RFC doesn't specify it. |
|
447 // ----------------------------------------------------------------------------- |
|
448 // |
|
449 const TDesC8& CInviteServerTa_Sending2xx::Log() const |
|
450 { |
|
451 return EnteringThisStateIsntLogged(); |
|
452 } |
|
453 #endif |
|
454 |
|
455 // ----------------------------------------------------------------------------- |
|
456 // CInviteServerTa_Sending2xx::CanContinueWithoutOutgoingMsg |
|
457 // This is never called for a server side. |
|
458 // ----------------------------------------------------------------------------- |
|
459 // |
|
460 TBool CInviteServerTa_Sending2xx::CanContinueWithoutOutgoingMsg() const |
|
461 { |
|
462 return ETrue; |
|
463 } |
|
464 |
|
465 // ----------------------------------------------------------------------------- |
|
466 // CInviteServerTa_Sending2xx::SendCompleteL |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 void CInviteServerTa_Sending2xx::SendCompleteL(CTransaction& aTransaction) const |
|
470 { |
|
471 aTransaction.TerminatedL(KErrNone); |
|
472 } |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // CInviteServerTa_Sending2xx::SendFailedL |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 void CInviteServerTa_Sending2xx::SendFailedL(CTransaction& aTransaction, |
|
479 TInt aError) const |
|
480 { |
|
481 aTransaction.TerminatedL(aError); |
|
482 } |