|
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 : InviteServerTa.cpp |
|
15 // Part of : Transaction |
|
16 // Version : SIP/5.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "SipAssert.h" |
|
22 #include "siperr.h" |
|
23 #include "Lwtimer.h" |
|
24 #include "sipmessage.h" |
|
25 #include "UserAgentBase.h" |
|
26 #include "TimerValues.h" |
|
27 |
|
28 #include "InviteServerTa.h" |
|
29 #include "TransactionTimer.h" |
|
30 #include "SIPMessageUtility.h" |
|
31 |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CInviteServerTransaction::NewL |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CInviteServerTransaction* |
|
38 CInviteServerTransaction::NewL(CUserAgentBase& aUserAgent, |
|
39 CTransmitter& aTransmitter, |
|
40 MTimerManager& aTimers, |
|
41 CTransactionState& aInitialState, |
|
42 TTimerValues& aTimerValues) |
|
43 { |
|
44 CInviteServerTransaction* self = |
|
45 new (ELeave) CInviteServerTransaction(aUserAgent, |
|
46 aTransmitter, |
|
47 aTimers, |
|
48 aInitialState, |
|
49 aTimerValues); |
|
50 CleanupStack::PushL(self); |
|
51 self->ConstructServerTaL(); |
|
52 CleanupStack::Pop(self); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CInviteServerTransaction::CInviteServerTransaction |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CInviteServerTransaction::CInviteServerTransaction( |
|
61 CUserAgentBase& aUserAgent, |
|
62 CTransmitter& aTransmitter, |
|
63 MTimerManager& aTimers, |
|
64 CTransactionState& aInitialState, |
|
65 TTimerValues& aTimerValues) : |
|
66 CServerTransaction(aUserAgent, |
|
67 aTransmitter, |
|
68 aTimers, |
|
69 aInitialState, |
|
70 aTimerValues) |
|
71 { |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CInviteServerTransaction::~CInviteServerTransaction |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CInviteServerTransaction::~CInviteServerTransaction() |
|
79 { |
|
80 //Scope operator to silence lint warning |
|
81 CInviteServerTransaction::CancelAllTimers(); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CInviteServerTransaction::IsInviteTransaction |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 TBool CInviteServerTransaction::IsInviteTransaction() const |
|
89 { |
|
90 return ETrue; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CInviteServerTransaction::ResponseSent |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CInviteServerTransaction::ResponseSent(TUint aRespCode, |
|
98 CTransactionState& aSending2xx, |
|
99 CTransactionState& aCompleted) |
|
100 { |
|
101 __TEST_INVARIANT; |
|
102 |
|
103 if (aRespCode >= 200) |
|
104 { |
|
105 if (aRespCode < 300) |
|
106 { |
|
107 ChangeState(aSending2xx); |
|
108 } |
|
109 else |
|
110 { |
|
111 ChangeState(aCompleted); |
|
112 } |
|
113 } |
|
114 |
|
115 __TEST_INVARIANT; |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CInviteServerTransaction::EnterConfirmedStateL |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void |
|
123 CInviteServerTransaction::EnterConfirmedStateL(CTransactionState& aConfirmed) |
|
124 { |
|
125 __TEST_INVARIANT; |
|
126 |
|
127 StopTimerG(); |
|
128 StopTimerH(); |
|
129 StartTimerIL(); |
|
130 ChangeState(aConfirmed); |
|
131 |
|
132 __TEST_INVARIANT; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CInviteServerTransaction::StartTimerGUnlessExistsL |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CInviteServerTransaction::StartTimerGUnlessExistsL() |
|
140 { |
|
141 __TEST_INVARIANT; |
|
142 |
|
143 if (!iTimerG) |
|
144 { |
|
145 iTimerValues.DoubleUptoT2(iTimerGDuration); |
|
146 iTimerG = CTimerRetransmit::NewL(iTimers, this, iTimerGDuration); |
|
147 } |
|
148 |
|
149 __TEST_INVARIANT; |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CInviteServerTransaction::StopTimerG |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CInviteServerTransaction::StopTimerG() |
|
157 { |
|
158 __TEST_INVARIANT; |
|
159 |
|
160 delete iTimerG; |
|
161 iTimerG = NULL; |
|
162 |
|
163 __TEST_INVARIANT; |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CInviteServerTransaction::StartTimerHL |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CInviteServerTransaction::StartTimerHL() |
|
171 { |
|
172 __TEST_INVARIANT; |
|
173 __SIP_ASSERT_LEAVE(!iTimerH, KErrAlreadyExists); |
|
174 |
|
175 iTimerH = CTimerTerminateTa::NewL(iTimers, |
|
176 this, |
|
177 iTimerValues.Duration64xT1(), |
|
178 KErrTimedOut); |
|
179 __TEST_INVARIANT; |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CInviteServerTransaction::StopTimerH |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CInviteServerTransaction::StopTimerH() |
|
187 { |
|
188 __TEST_INVARIANT; |
|
189 |
|
190 delete iTimerH; |
|
191 iTimerH = NULL; |
|
192 |
|
193 __TEST_INVARIANT; |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CInviteServerTransaction::StartTimerIL |
|
198 // Duration is 0s for reliable and T4 for unreliable transports. |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 void CInviteServerTransaction::StartTimerIL() |
|
202 { |
|
203 __TEST_INVARIANT; |
|
204 __SIP_ASSERT_LEAVE(!iTimerI, KErrAlreadyExists); |
|
205 |
|
206 TUint32 duration = 0; |
|
207 if (IsUnreliableTransportUsed()) |
|
208 { |
|
209 duration = iTimerValues.T4(); |
|
210 } |
|
211 |
|
212 iTimerI = CTimerTerminateTa::NewL(iTimers, this, duration); |
|
213 |
|
214 __TEST_INVARIANT; |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CInviteServerTransaction::StopTimerI |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CInviteServerTransaction::StopTimerI() |
|
222 { |
|
223 __TEST_INVARIANT; |
|
224 |
|
225 delete iTimerI; |
|
226 iTimerI = NULL; |
|
227 |
|
228 __TEST_INVARIANT; |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // CInviteServerTransaction::DeleteTimer |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 void CInviteServerTransaction::DeleteTimer(const CTransactionTimer& aTimer) |
|
236 { |
|
237 __TEST_INVARIANT; |
|
238 |
|
239 if (&aTimer == iTimerG) |
|
240 { |
|
241 StopTimerG(); |
|
242 } |
|
243 |
|
244 if (&aTimer == iTimerH) |
|
245 { |
|
246 StopTimerH(); |
|
247 } |
|
248 |
|
249 if (&aTimer == iTimerI) |
|
250 { |
|
251 StopTimerI(); |
|
252 } |
|
253 |
|
254 __TEST_INVARIANT; |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CInviteServerTransaction::CancelAllTimers |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void CInviteServerTransaction::CancelAllTimers() |
|
262 { |
|
263 __TEST_INVARIANT; |
|
264 |
|
265 StopTimerG(); |
|
266 StopTimerH(); |
|
267 StopTimerI(); |
|
268 |
|
269 __TEST_INVARIANT; |
|
270 } |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CInviteServerTransaction::TerminatedL |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 void CInviteServerTransaction::TerminatedL(TInt aReason) |
|
277 { |
|
278 __TEST_INVARIANT; |
|
279 |
|
280 if (!iTerminated) |
|
281 { |
|
282 //CInviteServerTransaction specific stuff |
|
283 Leave2xxForUAS(); |
|
284 |
|
285 //Common stuff |
|
286 CServerTransaction::TerminatedL(aReason); |
|
287 } |
|
288 |
|
289 __TEST_INVARIANT; |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CInviteServerTransaction::Leave2xxForUAS |
|
294 // InviteUAS owns 2xx. If iOutgoingMsg is 2xx, clear it so ~CServerTransaction |
|
295 // won't delete it. 2xx may be in iSendQueue, but the queue never owns 2xx to |
|
296 // INVITE. 2xx can't be in iSentResponses as only one final response is sent to |
|
297 // ServerTransaction and the most recent response is in iOutgoingMsg. |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 void CInviteServerTransaction::Leave2xxForUAS() |
|
301 { |
|
302 __TEST_INVARIANT; |
|
303 |
|
304 if (iOutgoingMsg) |
|
305 { |
|
306 __SIP_ASSERT_RETURN(!iOutgoingMsg->IsRequest(), |
|
307 KErrSIPMalformedMessage); |
|
308 if (CSIPMessageUtility::Is2xxResponse(*iOutgoingMsg)) |
|
309 { |
|
310 iOutgoingMsg = NULL; |
|
311 } |
|
312 } |
|
313 |
|
314 __TEST_INVARIANT; |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // CInviteServerTransaction::Ptr |
|
319 // ----------------------------------------------------------------------------- |
|
320 // |
|
321 CInviteServerTransaction& |
|
322 CInviteServerTransaction::Ptr(CTransactionBase& aTransaction) |
|
323 { |
|
324 return static_cast<CInviteServerTransaction&>(aTransaction); |
|
325 } |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // CInviteServerTransaction::__DbgTestInvariant |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 |
|
332 void CInviteServerTransaction::__DbgTestInvariant() const |
|
333 { |
|
334 if (iTimerGDuration > iTimerValues.T2()) |
|
335 { |
|
336 User::Invariant(); |
|
337 } |
|
338 } |