|
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 : sipprofilestateregistered |
|
15 // Part of : Sip Profile Server |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "SipProfileStateRegistered.h" |
|
24 #include "SipProfileCacheItem.h" |
|
25 #include "sipplugindirector.h" |
|
26 #include "SipProfileServerCore.h" |
|
27 #include "SipProfileLog.h" |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CSIPProfileStateRegistered::NewL |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CSIPProfileStateRegistered* CSIPProfileStateRegistered::NewL( |
|
36 CSIPPluginDirector& aDirector) |
|
37 { |
|
38 return new (ELeave) CSIPProfileStateRegistered(aDirector); |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CSIPProfileStateRegistered::CSIPProfileStateRegistered |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CSIPProfileStateRegistered::CSIPProfileStateRegistered( |
|
46 CSIPPluginDirector& aDirector): |
|
47 CSIPProfileState(aDirector) |
|
48 { |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CSIPProfileStateRegistered::~CSIPProfileStateRegistered |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CSIPProfileStateRegistered::~CSIPProfileStateRegistered() |
|
56 { |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CSIPProfileStateRegistered::Name |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CSIPConcreteProfile::TStatus CSIPProfileStateRegistered::Name() const |
|
64 { |
|
65 return CSIPConcreteProfile::ERegistered; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CSIPProfileStateRegistered::SetNeighbourStates |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CSIPProfileStateRegistered::SetNeighbourStates( |
|
73 CSIPProfileState& aUnregInProg, |
|
74 CSIPProfileState& aUnregistered, |
|
75 CSIPProfileState& aRegInProg, |
|
76 CSIPProfileState& aWaitForPermission) |
|
77 { |
|
78 iUnregInProg = &aUnregInProg; |
|
79 iUnregistered = &aUnregistered; |
|
80 iRegInProg = &aRegInProg; |
|
81 iWaitForPermission = &aWaitForPermission; |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CSIPProfileStateRegistered::EnterL |
|
86 // Checks if a deregister or update registration should be initiated. |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CSIPProfileStateRegistered::EnterL(CSIPProfileCacheItem& aItem, |
|
90 TBool aMaySendRegStatusEvent, |
|
91 CSIPProfileServerCore& aServerCore) |
|
92 { |
|
93 PROFILE_DEBUG3("ProfileStateRegistered::EnterL id", aItem.ProfileId()) |
|
94 // Migration never happens in this state |
|
95 __ASSERT_ALWAYS(!aItem.IAPMigrationInProgress(), User::Leave(KErrGeneral)); |
|
96 aItem.SetSnapRetryCounter(0); |
|
97 // Clear the error code here, because it might be set to KErrDisconnnected, |
|
98 // if the state was previously changed from registered to registering. |
|
99 aItem.Profile().SetLastRegistrationError( KErrNone ); |
|
100 |
|
101 if (aItem.IsActiveState()) |
|
102 { |
|
103 // Don't pass registration status event if migration was disallowed, as |
|
104 // application sees the profile stays registered. |
|
105 if (aMaySendRegStatusEvent) |
|
106 { |
|
107 aServerCore.SendRegistrationStatusEventL(aItem); |
|
108 } |
|
109 |
|
110 if (aItem.IsReferred()) |
|
111 { |
|
112 aItem.ProceedUpdatingProfileL(*iUnregInProg); |
|
113 return; |
|
114 } |
|
115 } |
|
116 |
|
117 StartDeregisterL(aItem, *iUnregInProg); |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CSIPProfileStateRegistered::EnableL |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void CSIPProfileStateRegistered::EnableL( |
|
125 CSIPProfileCacheItem& aItem, |
|
126 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
127 { |
|
128 PROFILE_DEBUG3("ProfileStateRegistered::EnableL id", aItem.ProfileId()) |
|
129 |
|
130 DoCommonEnableL(aItem, aObserver); |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CSIPProfileStateRegistered::EnableSnapInUseL |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CSIPProfileStateRegistered::EnableSnapInUseL( |
|
138 CSIPProfileCacheItem& aItem, |
|
139 const MSIPExtendedConcreteProfileObserver& aObserver, |
|
140 TUint32 /*aSnapId*/) |
|
141 { |
|
142 PROFILE_DEBUG3("ProfileStateRegistered::EnableSnapInUseL(profile id)", |
|
143 aItem.ProfileId()) |
|
144 |
|
145 DoCommonEnableL(aItem, aObserver); |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CSIPProfileStateRegistered::DisableL |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CSIPProfileStateRegistered::DisableL( |
|
153 CSIPProfileCacheItem& aItem, |
|
154 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
155 { |
|
156 PROFILE_DEBUG3("ProfileStateRegistered::DisableL id", aItem.ProfileId()) |
|
157 |
|
158 DoCommonDisable(aItem, aObserver); |
|
159 if (!aItem.IsReferred()) |
|
160 { |
|
161 StartDeregisterL(aItem, *iUnregInProg); |
|
162 } |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CSIPProfileStateRegistered::RemoveL |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CSIPProfileStateRegistered::RemoveL(CSIPProfileCacheItem& aItem) |
|
170 { |
|
171 PROFILE_DEBUG3("ProfileStateRegistered::RemoveL id", aItem.ProfileId()) |
|
172 |
|
173 StartDeregisterL(aItem, *iUnregInProg); |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CSIPProfileStateRegistered::UpdateRegistrationL |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 void CSIPProfileStateRegistered::UpdateRegistrationL( |
|
181 CSIPProfileCacheItem& aItem, |
|
182 const MSIPExtendedConcreteProfileObserver& /*aObserver*/) |
|
183 { |
|
184 PROFILE_DEBUG3("ProfileStateRegistered::UpdateRegistrationL id", |
|
185 aItem.ProfileId()) |
|
186 |
|
187 if (aItem.IsReferred()) |
|
188 { |
|
189 aItem.ProceedUpdatingProfileL(*iUnregInProg); |
|
190 } |
|
191 else |
|
192 { |
|
193 StartDeregisterL(aItem, *iUnregInProg); |
|
194 } |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CSIPProfileStateRegistered::RegistrationStatusEventL |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 void CSIPProfileStateRegistered::RegistrationStatusEventL( |
|
202 CSIPProfileCacheItem& aItem, |
|
203 CSIPConcreteProfile::TStatus aStatus) |
|
204 { |
|
205 PROFILE_DEBUG4("ProfileStateRegistered::RegStatusEventL id,status", |
|
206 aItem.ProfileId(), |
|
207 aStatus) |
|
208 |
|
209 if (aStatus == CSIPConcreteProfile::ERegistrationInProgress) |
|
210 { |
|
211 aItem.ChangeStateL(iRegInProg); |
|
212 // If state is changed REGISTERED->REGISTERING, we can assume that |
|
213 // the connection was lost. |
|
214 aItem.Profile().SetLastRegistrationError( KErrDisconnected ); |
|
215 aItem.SendUnregisteredStatusEventL(); |
|
216 } |
|
217 if (aStatus == CSIPConcreteProfile::EUnregistered) |
|
218 { |
|
219 aItem.ChangeStateL(iUnregistered); |
|
220 } |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CSIPProfileStateRegistered::ErrorOccurred |
|
225 // CSIPProfileCacheItem::HandleError calls SetLastRegistrationError. No need to |
|
226 // call it here. |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 TBool CSIPProfileStateRegistered::ErrorOccurred(CSIPProfileCacheItem& aItem, |
|
230 TInt /*aError*/) |
|
231 { |
|
232 PROFILE_DEBUG3("ProfileStateRegistered::ErrorOccurred(profile id)", |
|
233 aItem.ProfileId()) |
|
234 |
|
235 DoCommonErrorOccurred(aItem); |
|
236 return ETrue; |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CSIPProfileStateRegistered::IapAvailableL |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 void CSIPProfileStateRegistered::IapAvailableL(CSIPProfileCacheItem& aItem, |
|
244 TUint32 aSnapId, |
|
245 TUint32 aNewIapId) |
|
246 { |
|
247 if ( aNewIapId == aItem.Profile().IapId() ) |
|
248 { |
|
249 // The IAP that we are already using was offered for migration. |
|
250 // Let's allow the migration in order to allow other profiles |
|
251 // to use the IAP. |
|
252 aItem.SetClientPermission(aNewIapId, NULL, ETrue); |
|
253 } |
|
254 else if (aItem.HasProfileUpdate()) |
|
255 { |
|
256 // Currently updating, disallow migration |
|
257 aItem.SetIAPRefreshReminder(); |
|
258 aItem.SetClientPermission(aNewIapId, NULL, EFalse); |
|
259 } |
|
260 else |
|
261 { |
|
262 aItem.HandleNewIapL(aSnapId, aNewIapId, ETrue, *iWaitForPermission); |
|
263 } |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CSIPProfileStateRegistered::ShouldRefreshIAPs |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 TBool CSIPProfileStateRegistered::ShouldRefreshIAPs( |
|
271 CSIPProfileCacheItem& aItem) const |
|
272 { |
|
273 return !aItem.HasProfileUpdate(); |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CSIPProfileStateRegistered::ShutdownInitiated |
|
278 // Initiate de-registration. PluginDirector never has a pending register in |
|
279 // registered state. |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 void CSIPProfileStateRegistered::ShutdownInitiated(CSIPProfileCacheItem& aItem) |
|
283 { |
|
284 TRAP_IGNORE(StartDeregisterL(aItem, *iUnregInProg)) |
|
285 } |