|
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 : sipprofilestateunregistered |
|
15 // Part of : Sip Profile Server |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "SipProfileStateUnregistered.h" |
|
24 #include "SipProfileServerCore.h" |
|
25 #include "sipconcreteprofile.h" |
|
26 #include "SipProfileCacheItem.h" |
|
27 #include "sipplugindirector.h" |
|
28 #include "sipalrmonitor.h" |
|
29 #include "SipProfileLog.h" |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CSIPProfileStateUnregistered::NewL |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CSIPProfileStateUnregistered* CSIPProfileStateUnregistered::NewL( |
|
38 CSIPPluginDirector& aDirector) |
|
39 { |
|
40 return new (ELeave) CSIPProfileStateUnregistered(aDirector); |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CSIPProfileStateUnregistered::CSIPProfileStateUnregistered |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CSIPProfileStateUnregistered::CSIPProfileStateUnregistered( |
|
48 CSIPPluginDirector& aDirector): |
|
49 CSIPProfileState(aDirector) |
|
50 { |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CSIPProfileStateUnregistered::~CSIPProfileStateUnregistered |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CSIPProfileStateUnregistered::~CSIPProfileStateUnregistered() |
|
58 { |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CSIPProfileStateUnregistered::Name |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CSIPConcreteProfile::TStatus CSIPProfileStateUnregistered::Name() const |
|
66 { |
|
67 return CSIPConcreteProfile::EUnregistered; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CSIPProfileStateUnregistered::SetNeighbourStates |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void |
|
75 CSIPProfileStateUnregistered::SetNeighbourStates(CSIPProfileState& aRegInProg, |
|
76 CSIPProfileState& aWaitForIAP) |
|
77 { |
|
78 iRegInProg = &aRegInProg; |
|
79 iWaitForIAP = &aWaitForIAP; |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CSIPProfileStateUnregistered::EnterL |
|
84 // Check if should initiate registration. |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void |
|
88 CSIPProfileStateUnregistered::EnterL(CSIPProfileCacheItem& aItem, |
|
89 TBool /*aMaySendRegStatusEvent*/, |
|
90 CSIPProfileServerCore& /*aServerCore*/) |
|
91 { |
|
92 TBool updating = aItem.HasProfileUpdate(); |
|
93 // Use current IAP if updating profile, but SNAP stays same. |
|
94 // Call IsSnapIdUpdated before ClearOldProfile. |
|
95 TBool getIap = !updating || aItem.IsSnapIdUpdated(aItem.Profile()); |
|
96 aItem.SetSnapRetryCounter(0); |
|
97 |
|
98 PROFILE_DEBUG5("ProfileStateUnregistered::EnterL id,updating,getIap", |
|
99 aItem.ProfileId(), |
|
100 updating, |
|
101 getIap) |
|
102 __ASSERT_ALWAYS( |
|
103 aItem.Profile().Status() == CSIPConcreteProfile::EUnregistered, |
|
104 User::Leave(KErrGeneral)); |
|
105 |
|
106 // aItem.ClearOldProfile() can't be called here, because |
|
107 // iPluginDirector.TerminateHandling is tring to do something |
|
108 // to oldProfile still, and it got crashes |
|
109 aItem.ClearMigrationProfiles(); |
|
110 if (aItem.IsActiveState()) |
|
111 { |
|
112 aItem.SendUnregisteredStatusEventL(); |
|
113 |
|
114 if (aItem.IsReferred() && !aItem.IsShutdownInitiated() && !aItem.IsRfsInprogress()) |
|
115 { |
|
116 aItem.ClearOldProfile(); |
|
117 aItem.StartRegisterL(*iWaitForIAP, *iRegInProg, getIap); |
|
118 // CSIPProfileCacheItem::MonitorSnapL stops ALR monitor later if |
|
119 // updating SNAP. |
|
120 return; |
|
121 } |
|
122 } |
|
123 // Stay unregistered, no need to monitor SNAP |
|
124 aItem.StopSnapMonitoring(); |
|
125 iPluginDirector.TerminateHandling(aItem.UsedProfile()); |
|
126 iPluginDirector.StartTimerForCleanup(); |
|
127 aItem.ClearOldProfile(); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CSIPProfileStateUnregistered::RegisterL |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CSIPProfileStateUnregistered::RegisterL(CSIPProfileCacheItem& aItem) |
|
135 { |
|
136 PROFILE_DEBUG3("ProfileStateUnregistered::RegisterL id", aItem.ProfileId()) |
|
137 |
|
138 iPluginDirector.RegisterL(aItem.Profile()); |
|
139 aItem.ChangeStateL(iRegInProg); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CSIPProfileStateUnregistered::RegistrationStatusEventL |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 void CSIPProfileStateUnregistered::RegistrationStatusEventL( |
|
147 CSIPProfileCacheItem& aItem, |
|
148 CSIPConcreteProfile::TStatus aStatus) |
|
149 { |
|
150 PROFILE_DEBUG4("ProfileStateUnregistered::RegStatusEventL", |
|
151 aItem.ProfileId(), |
|
152 aStatus) |
|
153 |
|
154 if (aStatus == CSIPConcreteProfile::ERegistrationInProgress) |
|
155 { |
|
156 aItem.ChangeStateL(iRegInProg); |
|
157 } |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CSIPProfileStateUnregistered::EnableL |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void CSIPProfileStateUnregistered::EnableL(CSIPProfileCacheItem& aItem, |
|
165 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
166 { |
|
167 PROFILE_DEBUG3("ProfileStateUnregistered::EnableL id", aItem.ProfileId()) |
|
168 |
|
169 RegisterL(aItem); |
|
170 DoCommonEnableL(aItem, aObserver); |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CSIPProfileStateUnregistered::EnableSnapInUseL |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 void CSIPProfileStateUnregistered::EnableSnapInUseL( |
|
178 CSIPProfileCacheItem& aItem, |
|
179 const MSIPExtendedConcreteProfileObserver& aObserver, |
|
180 TUint32 aSnapId) |
|
181 { |
|
182 PROFILE_DEBUG4("ProfileStateUnregistered::EnableSnapInUseL(profile,snap)", |
|
183 aItem.ProfileId(), |
|
184 aSnapId) |
|
185 |
|
186 aItem.MonitorSnapL(aSnapId, *iWaitForIAP, *iRegInProg); |
|
187 DoCommonEnableL(aItem, aObserver); |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CSIPProfileStateUnregistered::DisableL |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 void CSIPProfileStateUnregistered::DisableL(CSIPProfileCacheItem& aItem, |
|
195 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
196 { |
|
197 PROFILE_DEBUG3("ProfileStateUnregistered::DisableL id", aItem.ProfileId()) |
|
198 |
|
199 DoCommonDisable(aItem, aObserver); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CSIPProfileStateUnregistered::CanBePermanentlyRemoved |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 TBool CSIPProfileStateUnregistered::CanBePermanentlyRemoved( |
|
207 const CSIPProfileCacheItem& aItem) const |
|
208 { |
|
209 TUint profileId(aItem.ProfileId()); |
|
210 PROFILE_DEBUG3("ProfileStateUnregistered::CanBePermanentlyRemoved id", |
|
211 profileId) |
|
212 return ETrue; |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CSIPProfileStateUnregistered::UpdateRegistrationL |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 void CSIPProfileStateUnregistered::UpdateRegistrationL( |
|
220 CSIPProfileCacheItem& aItem, |
|
221 const MSIPExtendedConcreteProfileObserver& /*aObserver*/) |
|
222 { |
|
223 PROFILE_DEBUG3("ProfileStateUnregistered::UpdateRegistrationL id", |
|
224 aItem.ProfileId()) |
|
225 aItem.ClearOldProfile(); |
|
226 |
|
227 CSIPConcreteProfile::TStatus state; |
|
228 __ASSERT_ALWAYS( |
|
229 iPluginDirector.State(state, aItem.Profile()) == KErrNotFound || |
|
230 state == CSIPConcreteProfile::EUnregistered, User::Leave(KErrArgument)); |
|
231 |
|
232 if (aItem.IsReferred() && !aItem.IsShutdownInitiated()) |
|
233 { |
|
234 aItem.StartRegisterL(*iWaitForIAP, *iRegInProg, ETrue); |
|
235 } |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // CSIPProfileStateUnregistered::ErrorOccurred |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 TBool CSIPProfileStateUnregistered::ErrorOccurred(CSIPProfileCacheItem& aItem, |
|
243 TInt /*aError*/) |
|
244 { |
|
245 PROFILE_DEBUG3("ProfileStateUnregistered::ErrorOccurred(profile id)", |
|
246 aItem.ProfileId()) |
|
247 DoCommonErrorOccurred(aItem); |
|
248 return ETrue; |
|
249 } |
|
250 |
|
251 // ----------------------------------------------------------------------------- |
|
252 // CSIPProfileStateUnregistered::IapAvailableL |
|
253 // Disallow migration during profile update. |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 void CSIPProfileStateUnregistered::IapAvailableL(CSIPProfileCacheItem& aItem, |
|
257 TUint32 /*aSnapId*/, |
|
258 TUint32 aNewIapId) |
|
259 { |
|
260 PROFILE_DEBUG4("ProfileStateUnregistered::IapAvailableL(profile,iap)", |
|
261 aItem.ProfileId(), |
|
262 aNewIapId) |
|
263 |
|
264 TBool allowMigration = !aItem.HasProfileUpdate(); |
|
265 if (!allowMigration) |
|
266 { |
|
267 aItem.SetIAPRefreshReminder(); |
|
268 } |
|
269 aItem.SetClientPermission(aNewIapId, NULL, allowMigration); |
|
270 } |