|
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 : sipprofilestateunregisteringoldiap.cpp |
|
15 // Part of : Sip Profile Server |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "sipprofilestateunregisteringoldiap.h" |
|
24 #include "sipconcreteprofile.h" |
|
25 #include "SipProfileCacheItem.h" |
|
26 #include "sipplugindirector.h" |
|
27 #include "SipProfileLog.h" |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CSIPProfileStateUnregisteringOldIAP::NewL |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CSIPProfileStateUnregisteringOldIAP* |
|
36 CSIPProfileStateUnregisteringOldIAP::NewL(CSIPPluginDirector& aDirector) |
|
37 { |
|
38 return new (ELeave) CSIPProfileStateUnregisteringOldIAP(aDirector); |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CSIPProfileStateUnregisteringOldIAP::CSIPProfileStateUnregisteringOldIAP |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CSIPProfileStateUnregisteringOldIAP::CSIPProfileStateUnregisteringOldIAP( |
|
46 CSIPPluginDirector& aDirector): |
|
47 CSIPProfileState(aDirector) |
|
48 { |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CSIPProfileStateUnregisteringOldIAP::~CSIPProfileStateUnregisteringOldIAP |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CSIPProfileStateUnregisteringOldIAP::~CSIPProfileStateUnregisteringOldIAP() |
|
56 { |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CSIPProfileStateUnregisteringOldIAP::Name |
|
61 // Though the new IAP has been registered, return the actual state id. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CSIPConcreteProfile::TStatus CSIPProfileStateUnregisteringOldIAP::Name() const |
|
65 { |
|
66 return static_cast<CSIPConcreteProfile::TStatus>(EUnregisteringOldIAP); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CSIPProfileStateUnregisteringOldIAP::EnableL |
|
71 // EnableL is used by a profile that doesn't have a SNAP configured, and such |
|
72 // profile should not be in this state. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CSIPProfileStateUnregisteringOldIAP::EnableL( |
|
76 CSIPProfileCacheItem& aItem, |
|
77 const MSIPExtendedConcreteProfileObserver& /*aObserver*/) |
|
78 { |
|
79 TUint profileId(aItem.ProfileId()); |
|
80 PROFILE_DEBUG3("ProfileStateUnregisteringOldIAP::EnableL(profile id)", |
|
81 profileId) |
|
82 |
|
83 User::Leave(KErrArgument); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CSIPProfileStateUnregisteringOldIAP::EnableSnapInUseL |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CSIPProfileStateUnregisteringOldIAP::EnableSnapInUseL( |
|
91 CSIPProfileCacheItem& aItem, |
|
92 const MSIPExtendedConcreteProfileObserver& aObserver, |
|
93 TUint32 /*aSnapId*/) |
|
94 { |
|
95 PROFILE_DEBUG3("ProfileStateUnregisteringOldIAP::EnableSnapInUseL(profile)", |
|
96 aItem.ProfileId()) |
|
97 |
|
98 DoCommonEnableL(aItem, aObserver); |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CSIPProfileStateUnregisteringOldIAP::DisableL |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CSIPProfileStateUnregisteringOldIAP::DisableL( |
|
106 CSIPProfileCacheItem& aItem, |
|
107 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
108 { |
|
109 PROFILE_DEBUG3("ProfileStateUnregisteringOldIAP::DisableL id", |
|
110 aItem.ProfileId()) |
|
111 |
|
112 DoCommonDisable(aItem, aObserver); |
|
113 if (!aItem.IsReferred()) |
|
114 { |
|
115 // Quit de-registering old IAP, so that can de-register new IAP profile |
|
116 iPluginDirector.TerminateHandling(aItem.UsedProfile()); |
|
117 aItem.ClearMigrationProfiles(); |
|
118 |
|
119 StartDeregisterL(aItem, *iUnregInProg); |
|
120 } |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CSIPProfileStateUnregisteringOldIAP::SetNeighbourStates |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CSIPProfileStateUnregisteringOldIAP::SetNeighbourStates( |
|
128 CSIPProfileState& aRegistered, |
|
129 CSIPProfileState& aUnregInProg) |
|
130 { |
|
131 iRegistered = &aRegistered; |
|
132 iUnregInProg = &aUnregInProg; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CSIPProfileStateUnregisteringOldIAP::RegistrationStatusEventL |
|
137 // Wait until de-register of the old IAP completes. |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 void CSIPProfileStateUnregisteringOldIAP::RegistrationStatusEventL( |
|
141 CSIPProfileCacheItem& aItem, |
|
142 CSIPConcreteProfile::TStatus aStatus) |
|
143 { |
|
144 PROFILE_DEBUG4("ProfileStateUnregisteringOldIAP::RegStatusEventL id,status", |
|
145 // Id of profile that most recently used profile agent |
|
146 aItem.UsedProfile().Id(), |
|
147 aStatus) |
|
148 __ASSERT_ALWAYS(!aItem.HasProfileUpdate(), User::Leave(KErrCorrupt)); |
|
149 |
|
150 if (aStatus == CSIPConcreteProfile::EUnregistered) |
|
151 { |
|
152 // Release the old IAP's connection. UsedProfile() returns now old IAP's |
|
153 // profile. |
|
154 iPluginDirector.TerminateHandling(aItem.UsedProfile()); |
|
155 aItem.ClearMigrationProfiles(); |
|
156 aItem.ChangeStateL(iRegistered); |
|
157 } |
|
158 iPluginDirector.StartTimerForCleanup(); |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CSIPProfileStateUnregisteringOldIAP::ErrorOccurred |
|
163 // De-registering old IAP fails, but the new IAP is registered, so enter |
|
164 // registered-state. |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 TBool CSIPProfileStateUnregisteringOldIAP::ErrorOccurred( |
|
168 CSIPProfileCacheItem& aItem, |
|
169 TInt /*aError*/) |
|
170 { |
|
171 PROFILE_DEBUG3("ProfileStateUnregisteringOldIAP::ErrorOccurred(profile)", |
|
172 aItem.UsedProfile().Id()) |
|
173 |
|
174 // Deletes iProfileWithOldIAP. TerminateHandling was already done in |
|
175 // CSIPProfileServerCore::HandleProfileError. |
|
176 DoCommonErrorOccurred(aItem); |
|
177 |
|
178 // If entering register state fails, handle it as error. |
|
179 TRAPD(err, aItem.ChangeStateL(iRegistered)); |
|
180 return err != KErrNone; |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CSIPProfileStateUnregisteringOldIAP::IsAlrState |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 TBool CSIPProfileStateUnregisteringOldIAP::IsAlrState() const |
|
188 { |
|
189 return ETrue; |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CSIPProfileStateUnregisteringOldIAP::ShutdownInitiated |
|
194 // De-register the currently registered profile (new IAP). |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CSIPProfileStateUnregisteringOldIAP::ShutdownInitiated( |
|
198 CSIPProfileCacheItem& aItem) |
|
199 { |
|
200 TRAP_IGNORE(StartDeregisterL(aItem, *iUnregInProg)) |
|
201 } |