28 // ----------------------------------------------------------------------------- |
28 // ----------------------------------------------------------------------------- |
29 // CSipAlrMigrationController::NewLC |
29 // CSipAlrMigrationController::NewLC |
30 // ----------------------------------------------------------------------------- |
30 // ----------------------------------------------------------------------------- |
31 // |
31 // |
32 CSipAlrMigrationController* |
32 CSipAlrMigrationController* |
33 CSipAlrMigrationController::NewLC(CSipAlrMonitor& aAlrMonitor, TSipSNAPConfigurationData aSnapData) |
33 CSipAlrMigrationController::NewLC(CSipAlrMonitor& aAlrMonitor, TUint32 aSnapId) |
34 { |
34 { |
35 CSipAlrMigrationController* self = |
35 CSipAlrMigrationController* self = |
36 new (ELeave) CSipAlrMigrationController(aAlrMonitor, aSnapData); |
36 new (ELeave) CSipAlrMigrationController(aAlrMonitor, aSnapId); |
37 CleanupStack::PushL(self); |
37 CleanupStack::PushL(self); |
38 return self; |
38 return self; |
39 } |
39 } |
40 |
40 |
41 // ----------------------------------------------------------------------------- |
41 // ----------------------------------------------------------------------------- |
42 // CSipAlrMigrationController::CSipAlrMigrationController |
42 // CSipAlrMigrationController::CSipAlrMigrationController |
43 // ----------------------------------------------------------------------------- |
43 // ----------------------------------------------------------------------------- |
44 // |
44 // |
45 CSipAlrMigrationController::CSipAlrMigrationController( |
45 CSipAlrMigrationController::CSipAlrMigrationController( |
46 CSipAlrMonitor& aAlrMonitor, |
46 CSipAlrMonitor& aAlrMonitor, |
47 TSipSNAPConfigurationData aSnapData) : |
47 TUint32 aSnapId) : |
48 iAlrMonitor(aAlrMonitor), |
48 iAlrMonitor(aAlrMonitor), |
49 iSnapData(aSnapData) |
49 iSnapId(aSnapId) |
50 #ifdef CPPUNIT_TEST |
50 #ifdef CPPUNIT_TEST |
51 // Set the array granularity to 1, so it allocates memory in each append |
51 // Set the array granularity to 1, so it allocates memory in each append |
52 , iObservers(1) |
52 , iObservers(1) |
53 #endif |
53 #endif |
54 { |
54 { |
123 // CSipAlrMigrationController::SnapId |
123 // CSipAlrMigrationController::SnapId |
124 // ----------------------------------------------------------------------------- |
124 // ----------------------------------------------------------------------------- |
125 // |
125 // |
126 TUint32 CSipAlrMigrationController::SnapId() const |
126 TUint32 CSipAlrMigrationController::SnapId() const |
127 { |
127 { |
128 return iSnapData.iSnapId; |
128 return iSnapId; |
129 } |
129 } |
130 |
|
131 TUint32 CSipAlrMigrationController::BearerId() const |
|
132 { |
|
133 return iSnapData.iBearerId; |
|
134 } |
|
135 |
130 |
136 // ----------------------------------------------------------------------------- |
131 // ----------------------------------------------------------------------------- |
137 // CSipAlrMigrationController::IsUsed |
132 // CSipAlrMigrationController::IsUsed |
138 // ----------------------------------------------------------------------------- |
133 // ----------------------------------------------------------------------------- |
139 // |
134 // |
151 TUint32 |
146 TUint32 |
152 CSipAlrMigrationController::AttachProfileL(MSipAlrMigrationObserver& aObserver) |
147 CSipAlrMigrationController::AttachProfileL(MSipAlrMigrationObserver& aObserver) |
153 { |
148 { |
154 TSipAlrMigrationObserverInfo observerInfo(aObserver); |
149 TSipAlrMigrationObserverInfo observerInfo(aObserver); |
155 iObservers.AppendL(observerInfo); |
150 iObservers.AppendL(observerInfo); |
156 |
151 |
157 const TInt KFirstObserverExists = 1; |
152 const TInt KFirstObserverExists = 1; |
158 if (iObservers.Count() == KFirstObserverExists) |
153 if (iObservers.Count() == KFirstObserverExists) |
159 { |
154 { |
160 PROFILE_DEBUG3("CSipAlrMigrCtrl::AttachProfileL snapId", SnapId()) |
155 PROFILE_DEBUG3("CSipAlrMigrCtrl::AttachProfileL snapId", iSnapId) |
161 PROFILE_DEBUG3("CSipAlrMigrCtrl::AttachProfileL BearerFiltered.. ", BearerId()) |
156 iAlrMonitor.MonitorSnapL(iSnapId, *this); |
162 iAlrMonitor.MonitorSnapL(iSnapData, *this); |
|
163 return KNoIap; |
157 return KNoIap; |
164 } |
158 } |
165 |
159 |
166 return iAllowedIapId; |
160 return iAllowedIapId; |
167 } |
161 } |
176 { |
170 { |
177 TInt index = FindIndex(aObserver); |
171 TInt index = FindIndex(aObserver); |
178 if (index != KErrNotFound) |
172 if (index != KErrNotFound) |
179 { |
173 { |
180 iObservers.Remove(index); |
174 iObservers.Remove(index); |
181 iObservers.Compress(); |
|
182 } |
175 } |
183 |
176 |
184 if (iObservers.Count() == 0) |
177 if (iObservers.Count() == 0) |
185 { |
178 { |
186 PROFILE_DEBUG1("CSipAlrMigrCtrl::DetachProfile free resources") |
179 PROFILE_DEBUG1("CSipAlrMigrCtrl::DetachProfile free resources") |
256 PROFILE_DEBUG3("CSipAlrMigrCtrl::SetMigrPermission, allow=", |
249 PROFILE_DEBUG3("CSipAlrMigrCtrl::SetMigrPermission, allow=", |
257 !iMigrationDisallowed) |
250 !iMigrationDisallowed) |
258 TInt err(KErrNone); |
251 TInt err(KErrNone); |
259 if (iMigrationDisallowed) |
252 if (iMigrationDisallowed) |
260 { |
253 { |
261 err = iAlrMonitor.DisallowMigration(iSnapData); |
254 err = iAlrMonitor.DisallowMigration(iSnapId); |
262 } |
255 } |
263 else |
256 else |
264 { |
257 { |
265 err = iAlrMonitor.AllowMigration(iSnapData); |
258 err = iAlrMonitor.AllowMigration(iSnapId); |
266 } |
259 } |
267 if (err != KErrNone) |
260 if (err != KErrNone) |
268 { |
261 { |
269 for (TInt i = 0; i < iObservers.Count(); ++i) |
262 for (TInt i = 0; i < iObservers.Count(); ++i) |
270 { |
263 { |
279 // CSipAlrMigrationController::RefreshIapAvailabilityL |
272 // CSipAlrMigrationController::RefreshIapAvailabilityL |
280 // ----------------------------------------------------------------------------- |
273 // ----------------------------------------------------------------------------- |
281 // |
274 // |
282 void CSipAlrMigrationController::RefreshIapAvailabilityL(TUint32 aSnapId) |
275 void CSipAlrMigrationController::RefreshIapAvailabilityL(TUint32 aSnapId) |
283 { |
276 { |
284 if (!iRefreshIssued && aSnapId == SnapId()) |
277 if (!iRefreshIssued && aSnapId == iSnapId) |
285 { |
278 { |
286 |
279 iAlrMonitor.RefreshIapAvailabilityL(aSnapId); |
287 iAlrMonitor.RefreshIapAvailabilityL(iSnapData); |
|
288 iRefreshIssued = ETrue; |
280 iRefreshIssued = ETrue; |
289 } |
281 } |
290 } |
282 } |
291 |
283 |
292 // ----------------------------------------------------------------------------- |
284 // ----------------------------------------------------------------------------- |
299 TBool aIapWorks) |
291 TBool aIapWorks) |
300 { |
292 { |
301 PROFILE_DEBUG4("CSipAlrMigrCtrl::SetIapAcceptance, iap,works=", |
293 PROFILE_DEBUG4("CSipAlrMigrCtrl::SetIapAcceptance, iap,works=", |
302 iAllowedIapId, |
294 iAllowedIapId, |
303 aIapWorks) |
295 aIapWorks) |
304 |
296 |
305 TInt index = FindIndex(aObserver); |
297 TInt index = FindIndex(aObserver); |
306 if (index != KErrNotFound && iObservers[index].iIsWaitingForAcceptance) |
298 if (index != KErrNotFound && iObservers[index].iIsWaitingForAcceptance) |
307 { |
299 { |
308 iObservers[index].iIsWaitingForAcceptance = EFalse; |
300 iObservers[index].iIsWaitingForAcceptance = EFalse; |
309 if (aIapWorks) |
301 if (aIapWorks) |
312 for (TInt i = 0; i < iObservers.Count(); ++i) |
304 for (TInt i = 0; i < iObservers.Count(); ++i) |
313 { |
305 { |
314 iObservers[i].iIsWaitingForAcceptance = EFalse; |
306 iObservers[i].iIsWaitingForAcceptance = EFalse; |
315 } |
307 } |
316 PROFILE_DEBUG1("CSipAlrMigrCtrl::SetIapAcceptance accepted") |
308 PROFILE_DEBUG1("CSipAlrMigrCtrl::SetIapAcceptance accepted") |
317 return iAlrMonitor.NewIapAccepted(iSnapData); |
309 return iAlrMonitor.NewIapAccepted(iSnapId); |
318 } |
310 } |
319 |
311 |
320 if (!ObserversWaitingAcceptance()) |
312 if (!ObserversWaitingAcceptance()) |
321 { |
313 { |
322 // Nobody got IAP to work |
314 // Nobody got IAP to work |
323 PROFILE_DEBUG1("CSipAlrMigrCtrl::SetIapAcceptance rejected") |
315 PROFILE_DEBUG1("CSipAlrMigrCtrl::SetIapAcceptance rejected") |
324 return iAlrMonitor.NewIapRejected(iSnapData); |
316 return iAlrMonitor.NewIapRejected(iSnapId); |
325 } |
317 } |
326 } |
318 } |
327 return KErrNone; |
319 return KErrNone; |
328 } |
320 } |
329 |
321 |