|
1 // Copyright (c) 2007-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 : InviteUASStates.cpp |
|
15 // Part of : TransactionUser |
|
16 // Version : SIP/6.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "siperr.h" |
|
22 #include "sipresponse.h" |
|
23 #include "siprequest.h" |
|
24 #include "SipLogs.h" |
|
25 #include "SipAssert.h" |
|
26 |
|
27 #include "InviteUAS.h" |
|
28 #include "InviteUASStates.h" |
|
29 #include "SIPMessageUtility.h" |
|
30 |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CInviteUAS_Start::CInviteUAS_Start |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CInviteUAS_Start::CInviteUAS_Start() |
|
37 { |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CInviteUAS_Start::~CInviteUAS_Start |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CInviteUAS_Start::~CInviteUAS_Start() |
|
45 { |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CInviteUAS_Start::SetNeighbourStates |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CInviteUAS_Start::SetNeighbourStates(CUserAgentState& aGetTxOwner, |
|
53 CUserAgentState& aWaitRespFromApp, |
|
54 CUserAgentState& aRejected) |
|
55 { |
|
56 iGetTxOwner = &aGetTxOwner; |
|
57 iWaitRespFromApp = &aWaitRespFromApp; |
|
58 iRejected = &aRejected; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CInviteUAS_Start::TransactionEndsL |
|
63 // Can happen if leave occurs when obtaining upper layer callback. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void |
|
67 CInviteUAS_Start::TransactionEndsL(CUserAgent& aUserAgent, TInt aReason) const |
|
68 { |
|
69 aUserAgent.Stop(aReason); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CInviteUAS_Start::ReceiveL |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void |
|
77 CInviteUAS_Start::ReceiveL(CUserAgent& aUserAgent, CSIPRequest* aRequest) const |
|
78 { |
|
79 __SIP_ASSERT_LEAVE(aRequest, KErrArgument); |
|
80 |
|
81 CInviteUAS::Ptr(aUserAgent).InitialRequestReceivedL(aRequest, |
|
82 *iGetTxOwner, |
|
83 *iWaitRespFromApp, |
|
84 *iRejected); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CInviteUAS_Start::SendResponseL |
|
89 // Application shouldn't know about this transactionId yet |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void |
|
93 CInviteUAS_Start::SendResponseL(CUserAgent& /*aUserAgent*/, |
|
94 CSIPResponse* aResp, |
|
95 const TSIPTransportParams& /*aParams*/) const |
|
96 { |
|
97 __SIP_ASSERT_LEAVE(aResp, KErrArgument); |
|
98 |
|
99 User::Leave(KErrSIPInvalidTransactionState); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CInviteUAS_Start::CancelL |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 TBool CInviteUAS_Start::CancelL(CUserAgent& aUserAgent) const |
|
107 { |
|
108 CInviteUAS::Ptr(aUserAgent).HandleCancelInviteL(*iRejected); |
|
109 return ETrue; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CInviteUAS_GetTxOwner::CInviteUAS_GetTxOwner |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 CInviteUAS_GetTxOwner::CInviteUAS_GetTxOwner() |
|
117 { |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CInviteUAS_GetTxOwner::~CInviteUAS_GetTxOwner |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 CInviteUAS_GetTxOwner::~CInviteUAS_GetTxOwner() |
|
125 { |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CInviteUAS_GetTxOwner::SetNeighbourStates |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void |
|
133 CInviteUAS_GetTxOwner::SetNeighbourStates(CUserAgentState& aWaitRespFromApp, |
|
134 CUserAgentState& aRejected) |
|
135 { |
|
136 iWaitRespFromApp = &aWaitRespFromApp; |
|
137 iRejected = &aRejected; |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CInviteUAS_GetTxOwner::OwnerFoundL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CInviteUAS_GetTxOwner::OwnerFoundL(CUserAgent& aUserAgent, |
|
145 MTransactionOwner* aOwner) const |
|
146 { |
|
147 __SIP_ASSERT_LEAVE(aOwner, KErrArgument); |
|
148 |
|
149 CInviteUAS::Ptr(aUserAgent).HandleOwnerFoundL(aOwner, *iWaitRespFromApp); |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CInviteUAS_GetTxOwner::OwnerNotFoundL |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CInviteUAS_GetTxOwner::OwnerNotFoundL(CUserAgent& aUserAgent, |
|
157 CSIPResponse* aResp) const |
|
158 { |
|
159 __SIP_ASSERT_LEAVE(aResp, KErrArgument); |
|
160 |
|
161 CInviteUAS::Ptr(aUserAgent).HandleOwnerNotFoundL(aResp, *iRejected); |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CInviteUAS_GetTxOwner::SendResponseL |
|
166 // Application shouldn't know about this transaction yet |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CInviteUAS_GetTxOwner::SendResponseL(CUserAgent& /*aUserAgent*/, |
|
170 CSIPResponse* aResp, |
|
171 const TSIPTransportParams& /*aParams*/) const |
|
172 { |
|
173 __SIP_ASSERT_LEAVE(aResp, KErrArgument); |
|
174 |
|
175 User::Leave(KErrSIPInvalidTransactionState); |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CInviteUAS_GetTxOwner::TransactionEndsL |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 void CInviteUAS_GetTxOwner::TransactionEndsL(CUserAgent& aUserAgent, |
|
183 TInt aReason) const |
|
184 { |
|
185 aUserAgent.Stop(aReason); |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CInviteUAS_GetTxOwner::TimerExpiredL |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CInviteUAS_GetTxOwner::TimerExpiredL(CUserAgent& aUserAgent, |
|
193 TTimerId aTimerId, |
|
194 TAny* aTimerParam) const |
|
195 { |
|
196 __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument); |
|
197 |
|
198 HandleTimerExpirationL(aUserAgent, aTimerId, aTimerParam); |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CInviteUAS_GetTxOwner::RequestRouterErrorL |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CInviteUAS_GetTxOwner::RequestRouterErrorL(CUserAgent& aUserAgent) const |
|
206 { |
|
207 static_cast<CUserAgentServer*>(&aUserAgent)-> |
|
208 HandleRequestRouterErrorL(*iRejected); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CInviteUAS_GetTxOwner::CancelL |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 TBool CInviteUAS_GetTxOwner::CancelL(CUserAgent& aUserAgent) const |
|
216 { |
|
217 CInviteUAS::Ptr(aUserAgent).HandleCancelInviteL(*iRejected); |
|
218 return ETrue; |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CInviteUAS_WaitRespFromApp::CInviteUAS_WaitRespFromApp |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 CInviteUAS_WaitRespFromApp::CInviteUAS_WaitRespFromApp() |
|
226 { |
|
227 } |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // CInviteUAS_WaitRespFromApp::~CInviteUAS_WaitRespFromApp |
|
231 // ----------------------------------------------------------------------------- |
|
232 // |
|
233 CInviteUAS_WaitRespFromApp::~CInviteUAS_WaitRespFromApp() |
|
234 { |
|
235 } |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // CInviteUAS_WaitRespFromApp::SetNeighbourStates |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 void CInviteUAS_WaitRespFromApp::SetNeighbourStates(CUserAgentState& aAccepted, |
|
242 CUserAgentState& aRejected) |
|
243 { |
|
244 iAccepted = &aAccepted; |
|
245 iRejected = &aRejected; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CInviteUAS_WaitRespFromApp::SendResponseL |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void CInviteUAS_WaitRespFromApp::SendResponseL(CUserAgent& aUserAgent, |
|
253 CSIPResponse* aResp, |
|
254 const TSIPTransportParams& aParams) const |
|
255 { |
|
256 __SIP_ASSERT_LEAVE(aResp, KErrArgument); |
|
257 |
|
258 CInviteUAS& ua = CInviteUAS::Ptr(aUserAgent); |
|
259 ua.HandleSendResponseL(aResp, aParams); |
|
260 |
|
261 if (aResp->Type() == CSIPResponse::E2XX) |
|
262 { |
|
263 aUserAgent.ChangeState(*iAccepted); |
|
264 ua.SendFirst2xxL(aResp); |
|
265 } |
|
266 else |
|
267 { |
|
268 if (aResp->IsErrorResponse()) |
|
269 { |
|
270 // Enter "rejected" before sending response to transaction. If |
|
271 // transaction ends already in SendMessageToTransactionL, UAS is in |
|
272 // the correct state. |
|
273 aUserAgent.ChangeState(*iRejected); |
|
274 } |
|
275 ua.SendResponseToTransactionL(aResp); |
|
276 } |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CInviteUAS_WaitRespFromApp::TransactionEndsL |
|
281 // Transaction ends, likely application hasn't sent any final response. |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void CInviteUAS_WaitRespFromApp::TransactionEndsL(CUserAgent& aUserAgent, |
|
285 TInt aReason) const |
|
286 { |
|
287 aUserAgent.Stop(aReason); |
|
288 } |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // CInviteUAS_WaitRespFromApp::ShouldUASStop |
|
292 // ----------------------------------------------------------------------------- |
|
293 // |
|
294 TBool CInviteUAS_WaitRespFromApp::ShouldUASStop() const |
|
295 { |
|
296 return ETrue; |
|
297 } |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // CInviteUAS_WaitRespFromApp::CancelL |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 TBool CInviteUAS_WaitRespFromApp::CancelL(CUserAgent& aUserAgent) const |
|
304 { |
|
305 CInviteUAS::Ptr(aUserAgent).HandleCancelInviteL(*iRejected); |
|
306 return ETrue; |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CInviteUAS_Accepted::CInviteUAS_Accepted |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 CInviteUAS_Accepted::CInviteUAS_Accepted() |
|
314 { |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CInviteUAS_Accepted::~CInviteUAS_Accepted |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 CInviteUAS_Accepted::~CInviteUAS_Accepted() |
|
322 { |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // CInviteUAS_Accepted::SendResponseL |
|
327 // Final response has already been sent |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void |
|
331 CInviteUAS_Accepted::SendResponseL(CUserAgent& /*aUserAgent*/, |
|
332 CSIPResponse* aResp, |
|
333 const TSIPTransportParams& /*aParams*/) const |
|
334 { |
|
335 __SIP_ASSERT_LEAVE(aResp, KErrArgument); |
|
336 |
|
337 User::Leave(KErrSIPInvalidTransactionState); |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CInviteUAS_Accepted::TransactionEndsL |
|
342 // Free the transaction that sent the first 2xx. Even if send failed, UAS begins |
|
343 // to retransmit the 2xx, regardless of the used transport protocol. |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 void CInviteUAS_Accepted::TransactionEndsL(CUserAgent& aUserAgent, |
|
347 TInt /*aReason*/) const |
|
348 { |
|
349 aUserAgent.RequestDeletionOfTransactionL(); |
|
350 CInviteUAS::Ptr(aUserAgent).StartTimerRetransmit2xxL(); |
|
351 } |
|
352 |
|
353 // ----------------------------------------------------------------------------- |
|
354 // CInviteUAS_Accepted::ReceiveL |
|
355 // ----------------------------------------------------------------------------- |
|
356 // |
|
357 void CInviteUAS_Accepted::ReceiveL(CUserAgent& aUserAgent, |
|
358 CSIPRequest* aRequest) const |
|
359 { |
|
360 __SIP_ASSERT_LEAVE(aRequest, KErrArgument); |
|
361 |
|
362 if (CSIPMessageUtility::IsAck(*aRequest)) |
|
363 { |
|
364 // Received ACK to 2xx directly from ConnectionMgr. CUserAgent::ReceiveL |
|
365 // wrote ACK to log, unless CUserAgent::iTransaction still runs. |
|
366 if (aUserAgent.Transaction()) |
|
367 { |
|
368 __SIP_MESSAGE_LOG("TransactionUser", *aRequest) |
|
369 } |
|
370 |
|
371 CInviteUAS& ua = CInviteUAS::Ptr(aUserAgent); |
|
372 ua.StopTimerRetransmit2xx(); |
|
373 |
|
374 // Ask MTransactionOwner also for ACK |
|
375 if (ua.DoesDialogExistForAckL(*aRequest)) |
|
376 { |
|
377 aUserAgent.PassMsgToTransactionOwnerL(aRequest); |
|
378 aUserAgent.Stop(KErrNone); |
|
379 } |
|
380 else |
|
381 { |
|
382 // Broken ACK. No need to wait any more. |
|
383 delete aRequest; |
|
384 aUserAgent.Stop(KErrTimedOut); |
|
385 } |
|
386 } |
|
387 else |
|
388 { |
|
389 // Drop other messages than ACKs |
|
390 delete aRequest; |
|
391 } |
|
392 } |
|
393 |
|
394 // ----------------------------------------------------------------------------- |
|
395 // CInviteUAS_Accepted::SendCompleteL |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 void CInviteUAS_Accepted::SendCompleteL(CUserAgent& aUserAgent) const |
|
399 { |
|
400 CInviteUAS::Ptr(aUserAgent).StartTimerRetransmit2xxL(); |
|
401 } |
|
402 |
|
403 // ----------------------------------------------------------------------------- |
|
404 // CInviteUAS_Accepted::SendFailedL |
|
405 // Sending 2xx failed. Response can't be sent to any other address, so stop. |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 void CInviteUAS_Accepted::SendFailedL(CUserAgent& aUserAgent, |
|
409 TInt aError) const |
|
410 { |
|
411 aUserAgent.Stop(aError); |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // CInviteUAS_Accepted::TimerExpiredL |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 void CInviteUAS_Accepted::TimerExpiredL(CUserAgent& aUserAgent, |
|
419 TTimerId aTimerId, |
|
420 TAny* aTimerParam) const |
|
421 { |
|
422 __SIP_ASSERT_LEAVE(aTimerParam, KErrArgument); |
|
423 |
|
424 HandleTimerExpirationL(aUserAgent, aTimerId, aTimerParam); |
|
425 } |
|
426 |
|
427 // ----------------------------------------------------------------------------- |
|
428 // CInviteUAS_Accepted::CancelL |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 TBool CInviteUAS_Accepted::CancelL(CUserAgent& aUserAgent) const |
|
432 { |
|
433 CInviteUAS::Ptr(aUserAgent).InformObserverAboutCancel(); |
|
434 return ETrue; |
|
435 } |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // CInviteUAS_Rejected::CInviteUAS_Rejected |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 CInviteUAS_Rejected::CInviteUAS_Rejected() |
|
442 { |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CInviteUAS_Rejected::~CInviteUAS_Rejected |
|
447 // ----------------------------------------------------------------------------- |
|
448 // |
|
449 CInviteUAS_Rejected::~CInviteUAS_Rejected() |
|
450 { |
|
451 } |
|
452 |
|
453 // ----------------------------------------------------------------------------- |
|
454 // CInviteUAS_Rejected::TransactionEndsL |
|
455 // ----------------------------------------------------------------------------- |
|
456 // |
|
457 void CInviteUAS_Rejected::TransactionEndsL(CUserAgent& aUserAgent, |
|
458 TInt aReason) const |
|
459 { |
|
460 aUserAgent.Stop(aReason); |
|
461 } |
|
462 |
|
463 // ----------------------------------------------------------------------------- |
|
464 // CInviteUAS_Rejected::SendResponseL |
|
465 // Final response has already been sent |
|
466 // ----------------------------------------------------------------------------- |
|
467 // |
|
468 void |
|
469 CInviteUAS_Rejected::SendResponseL(CUserAgent& /*aUserAgent*/, |
|
470 CSIPResponse* aResp, |
|
471 const TSIPTransportParams& /*aParams*/) const |
|
472 { |
|
473 __SIP_ASSERT_LEAVE(aResp, KErrArgument); |
|
474 |
|
475 User::Leave(KErrSIPInvalidTransactionState); |
|
476 } |