|
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 : NormalServerTa.cpp |
|
15 // Part of : Transaction |
|
16 // Version : SIP/5.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "SipAssert.h" |
|
22 #include "Lwtimer.h" |
|
23 #include "siprequest.h" |
|
24 #include "sipresponse.h" |
|
25 #include "UserAgentBase.h" |
|
26 #include "TimerValues.h" |
|
27 |
|
28 #include "NormalServerTa.h" |
|
29 #include "TransactionTimer.h" |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CNormalServerTransaction::NewL |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CNormalServerTransaction* |
|
36 CNormalServerTransaction::NewL(CUserAgentBase& aUserAgent, |
|
37 CTransmitter& aTransmitter, |
|
38 MTimerManager& aTimers, |
|
39 CTransactionState& aInitialState, |
|
40 TTimerValues& aTimerValues) |
|
41 { |
|
42 CNormalServerTransaction* self = |
|
43 new (ELeave) CNormalServerTransaction(aUserAgent, |
|
44 aTransmitter, |
|
45 aTimers, |
|
46 aInitialState, |
|
47 aTimerValues); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructServerTaL(); |
|
50 CleanupStack::Pop(self); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CNormalServerTransaction::CNormalServerTransaction |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CNormalServerTransaction::CNormalServerTransaction(CUserAgentBase& aUserAgent, |
|
59 CTransmitter& aTransmitter, |
|
60 MTimerManager& aTimers, |
|
61 CTransactionState& aInitialState, |
|
62 TTimerValues& aTimerValues) : |
|
63 CServerTransaction(aUserAgent, |
|
64 aTransmitter, |
|
65 aTimers, |
|
66 aInitialState, |
|
67 aTimerValues) |
|
68 { |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CNormalServerTransaction::~CNormalServerTransaction |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CNormalServerTransaction::~CNormalServerTransaction() |
|
76 { |
|
77 //Scope operator to silence lint warning |
|
78 CNormalServerTransaction::CancelAllTimers(); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CNormalServerTransaction::DeleteTimer |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CNormalServerTransaction::DeleteTimer(const CTransactionTimer& aTimer) |
|
86 { |
|
87 __TEST_INVARIANT; |
|
88 |
|
89 if (&aTimer == iTimerF2) |
|
90 { |
|
91 StopTimerF2(); |
|
92 } |
|
93 |
|
94 if (&aTimer == iTimerJ) |
|
95 { |
|
96 StopTimerJ(); |
|
97 } |
|
98 |
|
99 if (&aTimer == iTimerSend100) |
|
100 { |
|
101 StopTimerSend100(); |
|
102 } |
|
103 |
|
104 __TEST_INVARIANT; |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CNormalServerTransaction::StartTimerF2UnlessExistsL |
|
109 // Same duration as for timer F (64*T1). |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CNormalServerTransaction::StartTimerF2UnlessExistsL() |
|
113 { |
|
114 __TEST_INVARIANT; |
|
115 |
|
116 if (!iTimerF2) |
|
117 { |
|
118 iTimerF2 = CTimerTerminateTa::NewL(iTimers, |
|
119 this, |
|
120 iTimerValues.Duration64xT1(), |
|
121 KErrTimedOut); |
|
122 } |
|
123 |
|
124 __TEST_INVARIANT; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CNormalServerTransaction::StopTimerF2 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CNormalServerTransaction::StopTimerF2() |
|
132 { |
|
133 __TEST_INVARIANT; |
|
134 |
|
135 delete iTimerF2; |
|
136 iTimerF2 = NULL; |
|
137 |
|
138 __TEST_INVARIANT; |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CNormalServerTransaction::StartTimerJUnlessExistsL |
|
143 // Duration is 0s for reliable and 64*T1 for unreliable transports. |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void CNormalServerTransaction::StartTimerJUnlessExistsL() |
|
147 { |
|
148 __TEST_INVARIANT; |
|
149 |
|
150 if (!iTimerJ) |
|
151 { |
|
152 TUint32 duration = 0; |
|
153 if (IsUnreliableTransportUsed()) |
|
154 { |
|
155 duration = iTimerValues.Duration64xT1(); |
|
156 } |
|
157 |
|
158 iTimerJ = CTimerTerminateTa::NewL(iTimers, this, duration); |
|
159 } |
|
160 |
|
161 __TEST_INVARIANT; |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CNormalServerTransaction::StopTimerJ |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CNormalServerTransaction::StopTimerJ() |
|
169 { |
|
170 __TEST_INVARIANT; |
|
171 |
|
172 delete iTimerJ; |
|
173 iTimerJ = NULL; |
|
174 |
|
175 __TEST_INVARIANT; |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CNormalServerTransaction::IsTimerSend100Running |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 TBool CNormalServerTransaction::IsTimerSend100Running() const |
|
183 { |
|
184 __TEST_INVARIANT; |
|
185 return iTimerSend100 != NULL; |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CNormalServerTransaction::StartTimerSend100L |
|
190 // Same duration can be used for both reliable and unreliable transports. |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 void CNormalServerTransaction::StartTimerSend100L(CSIPRequest& aRequest) |
|
194 { |
|
195 __TEST_INVARIANT; |
|
196 __SIP_ASSERT_LEAVE(!iTimerSend100, KErrAlreadyExists); |
|
197 |
|
198 TUint32 duration = 0; |
|
199 TUint step = 0; |
|
200 iTimerValues.DoubleUptoT2(step); |
|
201 |
|
202 while (step < iTimerValues.T2()) |
|
203 { |
|
204 duration += step; |
|
205 iTimerValues.DoubleUptoT2(step); |
|
206 } |
|
207 |
|
208 Create100L(aRequest); |
|
209 iTimerSend100 = CTimerSend100::NewL(iTimers, |
|
210 this, |
|
211 duration, |
|
212 static_cast<CSIPResponse*>(iOutgoingMsg), |
|
213 iTransportProtocol, |
|
214 iTransportParams); |
|
215 //Timer took ownership of the SIP response |
|
216 iOutgoingMsg = NULL; |
|
217 |
|
218 __TEST_INVARIANT; |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CNormalServerTransaction::StopTimerSend100 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void CNormalServerTransaction::StopTimerSend100() |
|
226 { |
|
227 __TEST_INVARIANT; |
|
228 |
|
229 delete iTimerSend100; |
|
230 iTimerSend100 = NULL; |
|
231 |
|
232 __TEST_INVARIANT; |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CNormalServerTransaction::ReceiveRetransmissionL |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 void CNormalServerTransaction::ReceiveRetransmissionL(CSIPRequest* aRequest) |
|
240 { |
|
241 __SIP_ASSERT_LEAVE(aRequest, KErrArgument); |
|
242 |
|
243 if (!IsTransmitterSending()) |
|
244 { |
|
245 SendToTransmitterL(); |
|
246 } |
|
247 |
|
248 delete aRequest; |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // CNormalServerTransaction::CancelAllTimers |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 void CNormalServerTransaction::CancelAllTimers() |
|
256 { |
|
257 __TEST_INVARIANT; |
|
258 |
|
259 StopTimerJ(); |
|
260 StopTimerF2(); |
|
261 StopTimerSend100(); |
|
262 |
|
263 __TEST_INVARIANT; |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CNormalServerTransaction::Ptr |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 CNormalServerTransaction& |
|
271 CNormalServerTransaction::Ptr(CTransaction& aTransaction) |
|
272 { |
|
273 return static_cast<CNormalServerTransaction&>(aTransaction); |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CNormalServerTransaction::__DbgTestInvariant |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 |
|
281 void CNormalServerTransaction::__DbgTestInvariant() const |
|
282 { |
|
283 //Timers J and F2 must not run at the same time |
|
284 if (iTimerJ && iTimerF2) |
|
285 { |
|
286 User::Invariant(); |
|
287 } |
|
288 } |
|
289 |