|
1 // Copyright (c) 2008-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 : sipprofilestatemigratingtonewiap.cpp |
|
15 // Part of : Sip Profile Server |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "sipprofilestatemigratingtonewiap.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 // CSIPProfileStateMigratingToNewIAP::NewL |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CSIPProfileStateMigratingToNewIAP* |
|
38 CSIPProfileStateMigratingToNewIAP::NewL(CSIPPluginDirector& aDirector) |
|
39 { |
|
40 return new (ELeave) CSIPProfileStateMigratingToNewIAP(aDirector); |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CSIPProfileStateMigratingToNewIAP::CSIPProfileStateMigratingToNewIAP |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CSIPProfileStateMigratingToNewIAP::CSIPProfileStateMigratingToNewIAP( |
|
48 CSIPPluginDirector& aDirector): |
|
49 CSIPProfileState(aDirector) |
|
50 { |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CSIPProfileStateMigratingToNewIAP::~CSIPProfileStateMigratingToNewIAP |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CSIPProfileStateMigratingToNewIAP::~CSIPProfileStateMigratingToNewIAP() |
|
58 { |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CSIPProfileStateMigratingToNewIAP::Name |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CSIPConcreteProfile::TStatus CSIPProfileStateMigratingToNewIAP::Name() const |
|
66 { |
|
67 return static_cast<CSIPConcreteProfile::TStatus>(EMigratingToNewIAP); |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CSIPProfileStateMigratingToNewIAP::EnableL |
|
72 // EnableL is used by a profile that doesn't have a SNAP configured, and such |
|
73 // profile should not be in this state. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CSIPProfileStateMigratingToNewIAP::EnableL( |
|
77 CSIPProfileCacheItem& aItem, |
|
78 const MSIPExtendedConcreteProfileObserver& /*aObserver*/) |
|
79 { |
|
80 TUint profileId(aItem.ProfileId()); |
|
81 PROFILE_DEBUG3("ProfileStateMigratingToNewIAP::EnableL id", |
|
82 profileId) |
|
83 |
|
84 User::Leave(KErrArgument); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSIPProfileStateMigratingToNewIAP::EnableSnapInUseL |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CSIPProfileStateMigratingToNewIAP::EnableSnapInUseL( |
|
92 CSIPProfileCacheItem& aItem, |
|
93 const MSIPExtendedConcreteProfileObserver& aObserver, |
|
94 TUint32 /*aSnapId*/) |
|
95 { |
|
96 PROFILE_DEBUG3("ProfileStateMigratingToNewIAP::EnableSnapInUseL(profile)", |
|
97 aItem.ProfileId()) |
|
98 |
|
99 DoCommonEnableL(aItem, aObserver); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CSIPProfileStateMigratingToNewIAP::DisableL |
|
104 // Actual registration has now been started, and must be stopped. |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CSIPProfileStateMigratingToNewIAP::DisableL( |
|
108 CSIPProfileCacheItem& aItem, |
|
109 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
110 { |
|
111 PROFILE_DEBUG3("ProfileStateMigratingToNewIAP::DisableL id", |
|
112 aItem.ProfileId()) |
|
113 DoCommonDisable(aItem, aObserver); |
|
114 |
|
115 if (IsInitialRegisterDone(aItem)) |
|
116 { |
|
117 // Work as in Registered state |
|
118 if (!aItem.IsReferred()) |
|
119 { |
|
120 StartDeregisterL(aItem, *iUnregInProg); |
|
121 } |
|
122 } |
|
123 else |
|
124 { |
|
125 DisableWhileInProgressL(aItem, *iUnregInProg, *iUnregistered); |
|
126 } |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CSIPProfileStateMigratingToNewIAP::SetNeighbourStates |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CSIPProfileStateMigratingToNewIAP::SetNeighbourStates( |
|
134 CSIPProfileState& aUnregisteringOldIAP, |
|
135 CSIPProfileState& aWaitForIAP, |
|
136 CSIPProfileState& aRegistered, |
|
137 CSIPProfileState& aUnregInProg, |
|
138 CSIPProfileState& aUnregistered) |
|
139 { |
|
140 iUnregisteringOldIAP = &aUnregisteringOldIAP; |
|
141 iWaitForIAP = &aWaitForIAP; |
|
142 iRegistered = &aRegistered; |
|
143 iUnregInProg = &aUnregInProg; |
|
144 iUnregistered = &aUnregistered; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CSIPProfileStateMigratingToNewIAP::RegistrationStatusEventL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 void CSIPProfileStateMigratingToNewIAP::RegistrationStatusEventL( |
|
152 CSIPProfileCacheItem& aItem, |
|
153 CSIPConcreteProfile::TStatus aStatus) |
|
154 { |
|
155 PROFILE_DEBUG4("ProfileStateMigratingToNewIAP::RegStatusEventL id,status", |
|
156 // Id of profile that most recently used profile agent |
|
157 aItem.UsedProfile().Id(), |
|
158 aStatus) |
|
159 __ASSERT_ALWAYS(!aItem.HasProfileUpdate(), User::Leave(KErrCorrupt)); |
|
160 |
|
161 if (aStatus == CSIPConcreteProfile::ERegistered) |
|
162 { |
|
163 // Don't put old IAP's profile to iOldProfile, as ChangeStateL leads to |
|
164 // ProceedUpdatingProfileL using iOldProfile. |
|
165 CSIPConcreteProfile& profileWithOldIap = aItem.UseProfileWithNewIAP(); |
|
166 |
|
167 // Pass profile with new IAP as parameter |
|
168 aItem.ProfileRegisteredL(ETrue); |
|
169 |
|
170 aItem.ChangeStateL(iUnregisteringOldIAP); |
|
171 |
|
172 // New IAP is registered, de-register the old IAP. |
|
173 iPluginDirector.DeregisterL(profileWithOldIap); |
|
174 } |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CSIPProfileStateMigratingToNewIAP::ErrorOccurred |
|
179 // Migrating fails, clear new IAP's profile. Pass ALR error (not ErrorOccurredL) |
|
180 // to client. Old IAP's profile stays registered, so enter registered-state. |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 TBool |
|
184 CSIPProfileStateMigratingToNewIAP::ErrorOccurred(CSIPProfileCacheItem& aItem, |
|
185 TInt aError) |
|
186 { |
|
187 PROFILE_DEBUG4("ProfileStateMigratingToNewIAP::ErrorOccurred id,err", |
|
188 aItem.UsedProfile().Id(), |
|
189 aError) |
|
190 |
|
191 TUint32 failedIapId = aItem.UsedProfile().IapId(); |
|
192 |
|
193 // Deletes iProfileWithNewIAP. TerminateHandling was already done in |
|
194 // CSIPProfileServerCore::HandleProfileError. |
|
195 DoCommonErrorOccurred(aItem); |
|
196 |
|
197 aItem.NewIAPFailed(); |
|
198 TRAP_IGNORE(aItem.ChangeStateL(iRegistered)) |
|
199 aItem.PassAlrErrorToClient(aError, failedIapId); |
|
200 return EFalse; |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CSIPProfileStateMigratingToNewIAP::IapAvailableL |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 void CSIPProfileStateMigratingToNewIAP::IapAvailableL( |
|
208 CSIPProfileCacheItem& aItem, |
|
209 TUint32 /*aSnapId*/, |
|
210 TUint32 aNewIapId) |
|
211 { |
|
212 PROFILE_DEBUG4("ProfileStateMigratingToNewIAP::IapAvailableL(profile,iap)", |
|
213 aItem.ProfileId(), |
|
214 aNewIapId) |
|
215 |
|
216 // If the old IAP is again the preferred IAP, the new IAP has dropped. |
|
217 // Abort migration to new IAP. |
|
218 if (aNewIapId == aItem.Profile().IapId()) |
|
219 { |
|
220 iPluginDirector.TerminateHandling(aItem.UsedProfile()); |
|
221 aItem.ClearMigrationProfiles(); |
|
222 aItem.ChangeStateL(iRegistered); |
|
223 } |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CSIPProfileStateMigratingToNewIAP::IsAlrState |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 TBool CSIPProfileStateMigratingToNewIAP::IsAlrState() const |
|
231 { |
|
232 return ETrue; |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CSIPProfileStateMigratingToNewIAP::ShutdownInitiated |
|
237 // De-register the currently registered profile (old IAP). |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 void CSIPProfileStateMigratingToNewIAP::ShutdownInitiated( |
|
241 CSIPProfileCacheItem& aItem) |
|
242 { |
|
243 TRAPD(err, iPluginDirector.DeregisterL(aItem.Profile())); |
|
244 if (err == KErrNone) |
|
245 { |
|
246 TRAP_IGNORE(aItem.ChangeStateL(iUnregInProg)) |
|
247 } |
|
248 } |