|
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 : sipprflregisteredstate.cpp |
|
15 // Part of : sip profile fsm |
|
16 // implementation |
|
17 // Version : %version: 2.1.1 % |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "sipprflregisteredstate.h" |
|
24 #include "sipconcreteprofile.h" |
|
25 #include "sipregistrationbinding.h" |
|
26 #include "sipclienttransaction.h" |
|
27 #include "sipresponseelements.h" |
|
28 #include "sipmessageelements.h" |
|
29 #include "sipconcreteprofilecomparison.h" |
|
30 #include "sipprofile.h" |
|
31 #include "siperr.h" |
|
32 #include "sipprofileagentobserver.h" |
|
33 #include "sipprofilefsmuser.h" |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CSIPPrflRegisteredState::NewL() |
|
39 // (other items were commented in a header). |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 EXPORT_C CSIPPrflRegisteredState* CSIPPrflRegisteredState::NewL( |
|
43 MSIPProfileFSMUser& aUser) |
|
44 { |
|
45 return new (ELeave) CSIPPrflRegisteredState(aUser); |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CSIPPrflRegisteredState::CSIPPrflRegisteredState |
|
50 // (other items were commented in a header). |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CSIPPrflRegisteredState::CSIPPrflRegisteredState(MSIPProfileFSMUser& aUser): |
|
54 CSIPPrflStateBase(aUser,MSIPProfileContext::ERegistered) |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CSIPPrflRegisteredState::~CSIPPrflRegisteredState |
|
60 // (other items were commented in a header). |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 EXPORT_C CSIPPrflRegisteredState::~CSIPPrflRegisteredState() |
|
64 { |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CSIPPrflRegisteredState::LinkStates() |
|
69 // (other items were commented in a header). |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 EXPORT_C void CSIPPrflRegisteredState::LinkStates( |
|
73 CSIPPrflStateBase& aDeregisterState, |
|
74 CSIPPrflStateBase& aDeregistrationInProgressState, |
|
75 CSIPPrflStateBase& aInitState, |
|
76 CSIPPrflStateBase& aRegisterRequested, |
|
77 CSIPPrflStateBase& aRegisterDelayRequested) |
|
78 { |
|
79 iDeregisterState = &aDeregisterState; |
|
80 iDeregistrationInProgressState = &aDeregistrationInProgressState; |
|
81 iInitState = &aInitState; |
|
82 iRegisterRequestedState = &aRegisterRequested; |
|
83 iRegisterDelayRequestedState = &aRegisterDelayRequested; |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CSIPPrflRegisteredState::ConcreteProfileState() |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CSIPConcreteProfile::TStatus |
|
91 CSIPPrflRegisteredState::ConcreteProfileState() const |
|
92 { |
|
93 return CSIPConcreteProfile::ERegistered; |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CSIPPrflRegisteredState::DeregisterL() |
|
98 // (other items were commented in a header). |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CSIPPrflRegisteredState::DeregisterL( |
|
102 MSIPProfileContext& aContext) |
|
103 { |
|
104 __ASSERT_DEBUG(aContext.Profile()!=0, User::Invariant()); |
|
105 __ASSERT_DEBUG(aContext.Registration()!=0, User::Invariant()); |
|
106 if (aContext.Connection().State()==CSIPConnection::EActive) |
|
107 { |
|
108 if (iUser.AddProfileIntoQueue(*aContext.Profile())) |
|
109 { |
|
110 aContext.SetNextState(*iDeregisterState); |
|
111 iUser.DeregisterProfileL(*aContext.Profile()); |
|
112 } |
|
113 else |
|
114 { |
|
115 CSIPMessageElements* elements = |
|
116 aContext.CreateDeRegisterElementsL(); |
|
117 CleanupStack::PushL(elements); |
|
118 CSIPClientTransaction* tx = |
|
119 aContext.Registration()->DeregisterL(elements); |
|
120 CleanupStack::Pop(elements); |
|
121 aContext.SetTransaction(tx); |
|
122 aContext.SetNextState(*iDeregistrationInProgressState); |
|
123 } |
|
124 } |
|
125 else |
|
126 { |
|
127 aContext.SetNextState(*iDeregisterState); |
|
128 } |
|
129 aContext.AgentObserver().SIPProfileStatusEvent( |
|
130 *aContext.Profile(), |
|
131 aContext.Registration()->ContextId()); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CSIPPrflRegisteredState::UpdateL() |
|
136 // (other items were commented in a header). |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CSIPPrflRegisteredState::UpdateL( |
|
140 MSIPProfileContext& aContext, |
|
141 CSIPConcreteProfile& aNewProfile) |
|
142 { |
|
143 __ASSERT_DEBUG(aContext.Profile()!=0, User::Invariant()); |
|
144 |
|
145 CSIPConcreteProfile* oldProfile = aContext.Profile(); |
|
146 |
|
147 if (SIPConcreteProfileComparison::ValueModified( |
|
148 CSIPConcreteProfile::EOutboundProxyParameters, |
|
149 *oldProfile, aNewProfile) || |
|
150 SIPConcreteProfileComparison::ValuesModified( |
|
151 CSIPConcreteProfile::EName| |
|
152 CSIPConcreteProfile::EOutboundProxyParameters, |
|
153 *oldProfile, aNewProfile) || |
|
154 SIPConcreteProfileComparison::ValuesModified( |
|
155 CSIPConcreteProfile::EName| |
|
156 CSIPConcreteProfile::EOutboundProxyParameters| |
|
157 CSIPConcreteProfile::EAutoRegistration, |
|
158 *oldProfile, aNewProfile) || |
|
159 SIPConcreteProfileComparison::ValuesModified( |
|
160 CSIPConcreteProfile::EOutboundProxyParameters| |
|
161 CSIPConcreteProfile::EAutoRegistration, |
|
162 *oldProfile, aNewProfile)) |
|
163 { |
|
164 aContext.SetProfile(&aNewProfile); |
|
165 } |
|
166 else if (SIPConcreteProfileComparison::ValueModified( |
|
167 CSIPConcreteProfile::ERegistrarParameters, |
|
168 *oldProfile, aNewProfile) || |
|
169 SIPConcreteProfileComparison::ValuesModified( |
|
170 CSIPConcreteProfile::EName| |
|
171 CSIPConcreteProfile::ERegistrarParameters, |
|
172 *oldProfile, aNewProfile) || |
|
173 SIPConcreteProfileComparison::ValuesModified( |
|
174 CSIPConcreteProfile::EName| |
|
175 CSIPConcreteProfile::ERegistrarParameters| |
|
176 CSIPConcreteProfile::EAutoRegistration, |
|
177 *oldProfile, aNewProfile) || |
|
178 SIPConcreteProfileComparison::ValuesModified( |
|
179 CSIPConcreteProfile::ERegistrarParameters| |
|
180 CSIPConcreteProfile::EAutoRegistration, |
|
181 *oldProfile, aNewProfile)) |
|
182 { |
|
183 aContext.SetProfile(&aNewProfile); |
|
184 } |
|
185 else if (SIPConcreteProfileComparison::ValuesModified( |
|
186 CSIPConcreteProfile::ERegistrarParameters| |
|
187 CSIPConcreteProfile::EOutboundProxyParameters, |
|
188 *oldProfile, aNewProfile) || |
|
189 SIPConcreteProfileComparison::ValuesModified( |
|
190 CSIPConcreteProfile::EName| |
|
191 CSIPConcreteProfile::ERegistrarParameters| |
|
192 CSIPConcreteProfile::EOutboundProxyParameters, |
|
193 *oldProfile, aNewProfile) || |
|
194 SIPConcreteProfileComparison::ValuesModified( |
|
195 CSIPConcreteProfile::EName| |
|
196 CSIPConcreteProfile::ERegistrarParameters| |
|
197 CSIPConcreteProfile::EOutboundProxyParameters| |
|
198 CSIPConcreteProfile::EAutoRegistration, |
|
199 *oldProfile, aNewProfile) || |
|
200 SIPConcreteProfileComparison::ValuesModified( |
|
201 CSIPConcreteProfile::ERegistrarParameters| |
|
202 CSIPConcreteProfile::EOutboundProxyParameters| |
|
203 CSIPConcreteProfile::EAutoRegistration, |
|
204 *oldProfile, aNewProfile)) |
|
205 { |
|
206 aContext.SetProfile(&aNewProfile); |
|
207 } |
|
208 else if (SIPConcreteProfileComparison::ValuesModified( |
|
209 CSIPConcreteProfile::EContactHeaderParams| |
|
210 CSIPConcreteProfile::EOutboundProxyParameters, |
|
211 *oldProfile, aNewProfile) || |
|
212 SIPConcreteProfileComparison::ValuesModified( |
|
213 CSIPConcreteProfile::EName| |
|
214 CSIPConcreteProfile::EContactHeaderParams| |
|
215 CSIPConcreteProfile::EOutboundProxyParameters, |
|
216 *oldProfile, aNewProfile) || |
|
217 SIPConcreteProfileComparison::ValuesModified( |
|
218 CSIPConcreteProfile::EName| |
|
219 CSIPConcreteProfile::EContactHeaderParams| |
|
220 CSIPConcreteProfile::EOutboundProxyParameters| |
|
221 CSIPConcreteProfile::EAutoRegistration, |
|
222 *oldProfile, aNewProfile) || |
|
223 SIPConcreteProfileComparison::ValuesModified( |
|
224 CSIPConcreteProfile::EContactHeaderParams| |
|
225 CSIPConcreteProfile::EOutboundProxyParameters| |
|
226 CSIPConcreteProfile::EAutoRegistration, |
|
227 *oldProfile, aNewProfile)) |
|
228 { |
|
229 aContext.UpdateContactHeaderParamsL(aNewProfile); |
|
230 aContext.SetProfile(&aNewProfile); |
|
231 } |
|
232 else if (SIPConcreteProfileComparison::ValuesModified( |
|
233 CSIPConcreteProfile::EContactHeaderParams| |
|
234 CSIPConcreteProfile::ERegistrarParameters, |
|
235 *oldProfile, aNewProfile) || |
|
236 SIPConcreteProfileComparison::ValuesModified( |
|
237 CSIPConcreteProfile::EName| |
|
238 CSIPConcreteProfile::EContactHeaderParams| |
|
239 CSIPConcreteProfile::ERegistrarParameters, |
|
240 *oldProfile, aNewProfile) || |
|
241 SIPConcreteProfileComparison::ValuesModified( |
|
242 CSIPConcreteProfile::EName| |
|
243 CSIPConcreteProfile::EContactHeaderParams| |
|
244 CSIPConcreteProfile::ERegistrarParameters| |
|
245 CSIPConcreteProfile::EAutoRegistration, |
|
246 *oldProfile, aNewProfile) || |
|
247 SIPConcreteProfileComparison::ValuesModified( |
|
248 CSIPConcreteProfile::EContactHeaderParams| |
|
249 CSIPConcreteProfile::ERegistrarParameters| |
|
250 CSIPConcreteProfile::EAutoRegistration, |
|
251 *oldProfile, aNewProfile)) |
|
252 { |
|
253 aContext.UpdateContactHeaderParamsL(aNewProfile); |
|
254 aContext.SetProfile(&aNewProfile); |
|
255 } |
|
256 else if (SIPConcreteProfileComparison::ValueModified( |
|
257 CSIPConcreteProfile::EContactHeaderParams, |
|
258 *oldProfile, aNewProfile) || |
|
259 SIPConcreteProfileComparison::ValuesModified( |
|
260 CSIPConcreteProfile::EName| |
|
261 CSIPConcreteProfile::EContactHeaderParams, |
|
262 *oldProfile, aNewProfile) || |
|
263 SIPConcreteProfileComparison::ValuesModified( |
|
264 CSIPConcreteProfile::EName| |
|
265 CSIPConcreteProfile::EContactHeaderParams| |
|
266 CSIPConcreteProfile::EAutoRegistration, |
|
267 *oldProfile, aNewProfile) || |
|
268 SIPConcreteProfileComparison::ValuesModified( |
|
269 CSIPConcreteProfile::EContactHeaderParams| |
|
270 CSIPConcreteProfile::EAutoRegistration, |
|
271 *oldProfile, aNewProfile)) |
|
272 { |
|
273 aContext.UpdateContactHeaderParamsL(aNewProfile); |
|
274 aContext.SetProfile(&aNewProfile); |
|
275 } |
|
276 else if (SIPConcreteProfileComparison::ValueModified( |
|
277 CSIPConcreteProfile::EContactHeaderParams, |
|
278 *oldProfile, aNewProfile) || |
|
279 SIPConcreteProfileComparison::ValuesModified( |
|
280 CSIPConcreteProfile::EName, |
|
281 *oldProfile, aNewProfile) || |
|
282 SIPConcreteProfileComparison::ValuesModified( |
|
283 CSIPConcreteProfile::EName| |
|
284 CSIPConcreteProfile::EAutoRegistration, |
|
285 *oldProfile, aNewProfile) || |
|
286 SIPConcreteProfileComparison::ValuesModified( |
|
287 CSIPConcreteProfile::EAutoRegistration, |
|
288 *oldProfile, aNewProfile)) |
|
289 { |
|
290 aContext.SetProfile(&aNewProfile); |
|
291 } |
|
292 else if((&aNewProfile)->IsDefault() != (oldProfile)->IsDefault()) |
|
293 { |
|
294 aContext.SetProfile(&aNewProfile); |
|
295 } |
|
296 else |
|
297 { |
|
298 DeregisterL(aContext); |
|
299 } |
|
300 } |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // CSIPPrflRegisteredState::ConnectionStateChanged() |
|
304 // (other items were commented in a header). |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 void CSIPPrflRegisteredState::ConnectionStateChanged( |
|
308 MSIPProfileContext& aContext, |
|
309 CSIPConnection::TState aState) |
|
310 { |
|
311 if (aState==CSIPConnection::EInactive) |
|
312 { |
|
313 //registration was cleared by the SIP stack |
|
314 aContext.SetNextState(*iRegisterRequestedState); |
|
315 __ASSERT_DEBUG(aContext.Profile()!=0, User::Invariant()); |
|
316 __ASSERT_DEBUG(aContext.Registration()!=0, User::Invariant()); |
|
317 TUint32 contextId(aContext.Registration()->ContextId()); |
|
318 aContext.DestroyRegistration(); |
|
319 aContext.AgentObserver().SIPProfileStatusEvent( |
|
320 *aContext.Profile(),contextId); |
|
321 } |
|
322 /* When State EUnavailable is received, the registration Binding in the SIPStack |
|
323 * is no longer present. Hence we have to do the cleanup here and propagate the |
|
324 * error back to clients of profiles. |
|
325 */ |
|
326 else if(aState==CSIPConnection::EUnavailable) |
|
327 { |
|
328 HandleError(aContext, KErrCouldNotConnect, iInitState); |
|
329 } |
|
330 else |
|
331 { |
|
332 // make pclint happy |
|
333 } |
|
334 } |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CSIPPrflRegisteredState::ErrorOccurred() |
|
338 // (other items were commented in a header). |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 void CSIPPrflRegisteredState::ErrorOccured( |
|
342 MSIPProfileContext& aContext, |
|
343 TInt aError) |
|
344 { |
|
345 __ASSERT_DEBUG(aContext.Registration()!=0, User::Invariant()); |
|
346 CSIPConcreteProfile& profile = *aContext.Profile(); |
|
347 TUint32 contextId(aContext.Registration()->ContextId()); |
|
348 if ( aError == KErrTotalLossOfPrecision ) |
|
349 { |
|
350 iUser.SetInterimProfile(&profile); |
|
351 } |
|
352 aContext.DestroyRegistration(); |
|
353 if ( aContext.RetryAfterTimer() ) |
|
354 { |
|
355 //registration failed , re-try later |
|
356 aContext.SetTransaction(0); |
|
357 |
|
358 if( aContext.RetryTimerInUse() ) |
|
359 { |
|
360 aContext.SetNextState(*iRegisterDelayRequestedState); |
|
361 aContext.AgentObserver().SIPProfileStatusEvent(profile,contextId); |
|
362 } |
|
363 else |
|
364 { |
|
365 DoCleanup(aContext,contextId); |
|
366 aContext.SetNextState(*iRegisterDelayRequestedState); |
|
367 aContext.AgentObserver().SIPProfileStatusEvent(profile,contextId); |
|
368 aContext.SetNextState(*iInitState); |
|
369 } |
|
370 } |
|
371 else if ((aError == KErrSIPTransportFailure || |
|
372 aError == KErrSIPResolvingFailure || |
|
373 aError == KErrSIPICMPFailure) && |
|
374 aContext.Connection().State() == CSIPConnection::ESuspended) |
|
375 { |
|
376 //registration was dropped due to the expired |
|
377 // refresh while connection is suspended |
|
378 aContext.SetNextState(*iRegisterRequestedState); |
|
379 aContext.AgentObserver().SIPProfileStatusEvent(profile,contextId); |
|
380 } |
|
381 else if (aContext.RetryTimerInUse()) |
|
382 { |
|
383 aContext.SetNextState(*iRegisterDelayRequestedState); |
|
384 aContext.AgentObserver().SIPProfileErrorEvent(profile,contextId); |
|
385 } |
|
386 else |
|
387 { |
|
388 HandleError(aContext, aError, iInitState); |
|
389 } |
|
390 } |