|
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 : sipprofilestatereginprog.cpp |
|
15 // Part of : Sip Profile Server |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "SipProfileStateRegInProg.h" |
|
24 #include "sipconcreteprofile.h" |
|
25 #include "SipProfileCacheItem.h" |
|
26 #include "sipplugindirector.h" |
|
27 #include "SipProfileLog.h" |
|
28 #include "siperr.h" |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CSIPProfileStateRegInProg::NewL |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CSIPProfileStateRegInProg* |
|
37 CSIPProfileStateRegInProg::NewL(CSIPPluginDirector& aDirector) |
|
38 { |
|
39 return new (ELeave) CSIPProfileStateRegInProg(aDirector); |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CSIPProfileStateRegInProg::CSIPProfileStateRegInProg |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CSIPProfileStateRegInProg::CSIPProfileStateRegInProg( |
|
47 CSIPPluginDirector& aDirector): |
|
48 CSIPProfileState(aDirector) |
|
49 { |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CSIPProfileStateRegInProg::~CSIPProfileStateRegInProg |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CSIPProfileStateRegInProg::~CSIPProfileStateRegInProg() |
|
57 { |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CSIPProfileStateRegInProg::Name |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CSIPConcreteProfile::TStatus CSIPProfileStateRegInProg::Name() const |
|
65 { |
|
66 return CSIPConcreteProfile::ERegistrationInProgress; |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CSIPProfileStateRegInProg::SetNeighbourStates |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 void CSIPProfileStateRegInProg::SetNeighbourStates( |
|
74 CSIPProfileState& aRegistered, |
|
75 CSIPProfileState& aUnregistered, |
|
76 CSIPProfileState& aUnregInProg, |
|
77 CSIPProfileState& aWaitForIAP, |
|
78 CSIPProfileState& aWaitForPermission) |
|
79 { |
|
80 iRegistered = &aRegistered; |
|
81 iUnregistered = &aUnregistered; |
|
82 iUnregInProg = &aUnregInProg; |
|
83 iWaitForIAP = &aWaitForIAP; |
|
84 iWaitForPermission = &aWaitForPermission; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSIPProfileStateRegInProg::EnableL |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CSIPProfileStateRegInProg::EnableL( |
|
92 CSIPProfileCacheItem& aItem, |
|
93 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
94 { |
|
95 PROFILE_DEBUG3("ProfileStateRegInProg::EnableL id", aItem.ProfileId()) |
|
96 iPluginDirector.RegisterL(aItem.Profile()); |
|
97 if(!aItem.IsUser(aObserver)) |
|
98 { |
|
99 DoCommonEnableL(aItem,aObserver); |
|
100 } |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CSIPProfileStateRegInProg::EnableSnapInUseL |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CSIPProfileStateRegInProg::EnableSnapInUseL( |
|
108 CSIPProfileCacheItem& aItem, |
|
109 const MSIPExtendedConcreteProfileObserver& aObserver, |
|
110 TUint32 /*aSnapId*/) |
|
111 { |
|
112 PROFILE_DEBUG3("ProfileStateRegInProg::EnableSnapInUseL(profile id)", |
|
113 aItem.ProfileId()) |
|
114 DoCommonEnableL(aItem, aObserver); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CSIPProfileStateRegInProg::DisableL |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CSIPProfileStateRegInProg::DisableL( |
|
122 CSIPProfileCacheItem& aItem, |
|
123 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
124 { |
|
125 PROFILE_DEBUG3("ProfileStateRegInProg::DisableL id", aItem.ProfileId()) |
|
126 |
|
127 DoCommonDisable(aItem, aObserver); |
|
128 DisableWhileInProgressL(aItem, *iUnregInProg, *iUnregistered); |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CSIPProfileStateRegInProg::UpdateRegistrationL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CSIPProfileStateRegInProg::UpdateRegistrationL( |
|
136 CSIPProfileCacheItem& aItem, |
|
137 const MSIPExtendedConcreteProfileObserver& /*aObserver*/) |
|
138 { |
|
139 PROFILE_DEBUG3("ProfileStateRegInProg::UpdateRegistrationL id", |
|
140 aItem.ProfileId()) |
|
141 |
|
142 if (!iPluginDirector.IsRegisterPending(aItem.UsedProfile())) |
|
143 { |
|
144 iPluginDirector.DeregisterL(aItem.UsedProfile()); |
|
145 aItem.ChangeStateL(iUnregistered); |
|
146 } |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CSIPProfileStateRegInProg::RegistrationStatusEventL |
|
151 // Agent uses RegistrationStatusEventL if an action ((de)register..) succeeds, |
|
152 // ErrorOccurred if not. Handle now only ERegistered (=registration done). |
|
153 // Pass "profile updated" before "registration status changed" to client. |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CSIPProfileStateRegInProg::RegistrationStatusEventL( |
|
157 CSIPProfileCacheItem& aItem, |
|
158 CSIPConcreteProfile::TStatus aStatus) |
|
159 { |
|
160 PROFILE_DEBUG4("ProfileStateRegInProg::RegStatusEventL id,status", |
|
161 aItem.ProfileId(), |
|
162 aStatus) |
|
163 |
|
164 if (aStatus == CSIPConcreteProfile::ERegistered) |
|
165 { |
|
166 aItem.ProfileRegisteredL(EFalse); |
|
167 aItem.ChangeStateL(iRegistered); |
|
168 } |
|
169 else |
|
170 { |
|
171 if (aStatus == CSIPConcreteProfile::EUnregistrationInProgress) |
|
172 { |
|
173 aItem.ChangeStateL(iUnregInProg); |
|
174 } |
|
175 } |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CSIPProfileStateRegInProg::ErrorOccurred |
|
180 // If SNAP's initial register causes KErrCouldNotConnect, get another IAP. |
|
181 // Also if SNAP's initial register causes KErrSIPICMPFailure, then do normal error |
|
182 // handling because there is no point in getting New IAP for this error |
|
183 // CSIPProfileCacheItem::HandleError has called SetLastRegistrationError. |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 TBool CSIPProfileStateRegInProg::ErrorOccurred(CSIPProfileCacheItem& aItem, |
|
187 TInt aError) |
|
188 { |
|
189 PROFILE_DEBUG4("ProfileStateRegInProg::ErrorOccurred id,err", |
|
190 aItem.ProfileId(), |
|
191 aError) |
|
192 |
|
193 TUint32 dummySnapId(0); |
|
194 if ( (aError == KErrCouldNotConnect || |
|
195 aError == KErrTimedOut || |
|
196 aError == KErrSIPResolvingFailure || |
|
197 aError == KErrSIPTransportFailure) |
|
198 && aItem.IsSNAPConfigured(dummySnapId)) |
|
199 { |
|
200 TRAPD(err, aItem.ChangeStateL(iWaitForIAP)); |
|
201 if (err == KErrNone) |
|
202 { |
|
203 aItem.NewIAPFailed(); |
|
204 return EFalse; |
|
205 } |
|
206 } |
|
207 |
|
208 DoCommonErrorOccurred(aItem); |
|
209 return ETrue; |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CSIPProfileStateRegInProg::IapAvailableL |
|
214 // Handle a new IAP even if an update is queued, as update can't be done before |
|
215 // successful register. Quit trying old IAP, as after registering new IAP, |
|
216 // de-registering old IAP gives error, as it isn't registered. |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 void CSIPProfileStateRegInProg::IapAvailableL(CSIPProfileCacheItem& aItem, |
|
220 TUint32 aSnapId, |
|
221 TUint32 aNewIapId) |
|
222 { |
|
223 PROFILE_DEBUG5("ProfileStateRegInProg::IapAvailableL id,snap,iap", |
|
224 aItem.ProfileId(), |
|
225 aSnapId, |
|
226 aNewIapId) |
|
227 |
|
228 iPluginDirector.TerminateHandling(aItem.Profile()); |
|
229 aItem.HandleNewIapL(aSnapId, aNewIapId, EFalse, *iWaitForPermission); |
|
230 } |