|
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 : sipprofilecacheitem.cpp |
|
15 // Part of : SIP Profile Server |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "SipProfileCacheItem.h" |
|
24 #include "SipProfileServerCore.h" |
|
25 #include "sipextendedconcreteprofileobserver.h" |
|
26 #include "SipProfileState.h" |
|
27 #include "SipProfileLog.h" |
|
28 #include "sipalrmigrationcontroller.h" |
|
29 #include <sipprofile.h> |
|
30 #include <cmmanager.h> |
|
31 #include<e32const.h> |
|
32 |
|
33 const TInt KSnapRetryCountThreshold = 3; |
|
34 const TUint32 KDefaultSNAPIdentifier = KMaxTUint32; |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CSIPProfileCacheItem::NewL |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CSIPProfileCacheItem* |
|
42 CSIPProfileCacheItem::NewL(CSIPProfileServerCore& aCore, |
|
43 CSIPProfileState* aUnregistered) |
|
44 { |
|
45 CSIPProfileCacheItem* self = |
|
46 CSIPProfileCacheItem::NewLC(aCore, aUnregistered); |
|
47 CleanupStack::Pop(self); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CSIPProfileCacheItem::NewLC |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CSIPProfileCacheItem* |
|
56 CSIPProfileCacheItem::NewLC(CSIPProfileServerCore& aCore, |
|
57 CSIPProfileState* aUnregistered) |
|
58 { |
|
59 CSIPProfileCacheItem* self = |
|
60 new (ELeave) CSIPProfileCacheItem(aCore, aUnregistered); |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CSIPProfileCacheItem::CSIPProfileCacheItem |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CSIPProfileCacheItem::CSIPProfileCacheItem(CSIPProfileServerCore& aCore, |
|
71 CSIPProfileState* aUnregistered) : |
|
72 iCacheState(ENormal), |
|
73 iCurrentState(aUnregistered), |
|
74 iServerCore(aCore), |
|
75 iMigrationDisallowed(EFalse), |
|
76 iDeltaTimer(0), |
|
77 iDeltaTimerCallBack(DoNewIapFailed, this), |
|
78 iSnapRetryCounter(0) |
|
79 #ifdef CPPUNIT_TEST |
|
80 // Use array granularity 1, so each append allocates memory |
|
81 , iObservers(1), |
|
82 iUsers(1), |
|
83 iObserversWaitedForPermission(1) |
|
84 #endif |
|
85 { |
|
86 iIsRfsInprogress = EFalse; |
|
87 iDeltaTimerEntry.Set(iDeltaTimerCallBack); |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CSIPProfileCacheItem::ConstructL |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void CSIPProfileCacheItem::ConstructL() |
|
95 { |
|
96 iDeltaTimer = CDeltaTimer::NewL(CActive::EPriorityLow); |
|
97 } |
|
98 |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CSIPProfileCacheItem::~CSIPProfileCacheItem |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 CSIPProfileCacheItem::~CSIPProfileCacheItem() |
|
105 { |
|
106 if (iDeltaTimer) |
|
107 { |
|
108 iDeltaTimer->Cancel(); |
|
109 } |
|
110 delete iDeltaTimer; |
|
111 |
|
112 StopSnapMonitoring(); |
|
113 |
|
114 iObservers.Reset(); |
|
115 iObserversWaitedForPermission.Reset(); |
|
116 iUsers.Reset(); |
|
117 delete iQueuedProfile; |
|
118 delete iProfile; |
|
119 delete iOldProfile; |
|
120 delete iProfileWithNewIAP; |
|
121 delete iProfileWithOldIAP; |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CSIPProfileCacheItem::IapAvailable |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CSIPProfileCacheItem::IapAvailable(TUint32 aSnapId, TUint32 aNewIapId) |
|
129 { |
|
130 iDeltaTimer->Cancel(); |
|
131 |
|
132 TRAPD(err, iCurrentState->IapAvailableL(*this, aSnapId, aNewIapId)); |
|
133 if (err != KErrNone) |
|
134 { |
|
135 iServerCore.HandleProfileError(*this, err); |
|
136 } |
|
137 } |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CSIPProfileCacheItem::MigrationIsAllowedL |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CSIPProfileCacheItem::MigrationIsAllowedL(TUint32 aIapId) |
|
143 { |
|
144 iCurrentState->MigrationIsAllowedL(*this, aIapId); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CSIPProfileCacheItem::MigrationIsDisallowedL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 void CSIPProfileCacheItem::MigrationIsDisallowedL(TUint32 aIapId) |
|
152 { |
|
153 iCurrentState->MigrationIsDisallowedL(*this, aIapId); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CSIPProfileCacheItem::ErrorOccurred |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CSIPProfileCacheItem::ErrorOccurred(TInt aError) |
|
161 { |
|
162 HandleError(aError); |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CSIPProfileCacheItem::NoNewIapAvailable |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CSIPProfileCacheItem::NoNewIapAvailable() |
|
170 { |
|
171 iCurrentState->NoNewIapAvailable(*this); |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CSIPProfileCacheItem::RefreshIAPsFailed |
|
176 // This is a fatal error, as profile no longer gets information of new IAPs. |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CSIPProfileCacheItem::RefreshIAPsFailed() |
|
180 { |
|
181 iProfile->SetLastRegistrationError(KErrNoMemory); |
|
182 iCurrentState->RefreshIAPsFailed(*this); |
|
183 SwitchToUnregisteredState(); |
|
184 PassAlrErrorToClient(KErrNoMemory, Profile().IapId()); |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CSIPProfileCacheItem::SetProfile |
|
189 // Set iProfileId only once, then it never changes. |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CSIPProfileCacheItem::SetProfile(CSIPConcreteProfile* aProfile) |
|
193 { |
|
194 __ASSERT_ALWAYS(aProfile, User::Panic(_L("ProfileCacheItem:SetProfile"), |
|
195 KErrArgument)); |
|
196 delete iProfile; |
|
197 iProfile = aProfile; |
|
198 |
|
199 if (iProfileId == 0) |
|
200 { |
|
201 iProfileId = iProfile->Id(); |
|
202 } |
|
203 |
|
204 CheckProfileEnabledState(); |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CSIPProfileCacheItem::SetProfileId |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 void CSIPProfileCacheItem::SetProfileId(TUint aProfileId) |
|
212 { |
|
213 iProfileId = aProfileId; |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CSIPProfileCacheItem::ProfileId |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 TUint CSIPProfileCacheItem::ProfileId() const |
|
221 { |
|
222 return iProfileId; |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CSIPProfileCacheItem::Profile |
|
227 // Return the CSIPConcreteProfile that is most recently registered. |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 CSIPConcreteProfile& CSIPProfileCacheItem::Profile() |
|
231 { |
|
232 __ASSERT_ALWAYS(iProfile, |
|
233 User::Panic(_L("ProfileCacheItem:Profile"), KErrNotFound)); |
|
234 return *iProfile; |
|
235 } |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // CSIPProfileCacheItem::Profile |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 const CSIPConcreteProfile& CSIPProfileCacheItem::Profile() const |
|
242 { |
|
243 __ASSERT_ALWAYS(iProfile, |
|
244 User::Panic(_L("ProfileCacheItem:ProfileC"), KErrNotFound)); |
|
245 return *iProfile; |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CSIPProfileCacheItem::LatestProfile |
|
250 // Return the CSIPConcreteProfile that includes the most recent updates. |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 CSIPConcreteProfile& CSIPProfileCacheItem::LatestProfile() |
|
254 { |
|
255 return iQueuedProfile ? *iQueuedProfile : Profile(); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CSIPProfileCacheItem::ReferenceCount |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 TUint CSIPProfileCacheItem::ReferenceCount() const |
|
263 { |
|
264 return iUsers.Count(); |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CSIPProfileCacheItem::CacheOldProfile |
|
269 // If update is done before a previous update completed, it contains also the |
|
270 // earlier update's changes. Some states queue the update. If a new update |
|
271 // comes, it is stored and the previous discarded. |
|
272 // ----------------------------------------------------------------------------- |
|
273 // |
|
274 TBool CSIPProfileCacheItem::CacheOldProfile(CSIPConcreteProfile* aNewProfile, |
|
275 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
276 { |
|
277 __ASSERT_ALWAYS(aNewProfile && aNewProfile->Id() == ProfileId(), |
|
278 User::Panic(_L("ProfileCacheItem:CacheOld"), KErrArgument)); |
|
279 |
|
280 if (iCurrentState->CanProfileBeUpdated(*this)) |
|
281 { |
|
282 StoreProfileToUpdate(aNewProfile); |
|
283 return ETrue; |
|
284 } |
|
285 |
|
286 delete iQueuedProfile; |
|
287 iQueuedProfile = aNewProfile; |
|
288 iQueuedObserver = &aObserver; |
|
289 return EFalse; |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CSIPProfileCacheItem::ClearOldProfile |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 void CSIPProfileCacheItem::ClearOldProfile() |
|
297 { |
|
298 delete iOldProfile; |
|
299 iOldProfile = NULL; |
|
300 } |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // CSIPProfileCacheItem::HasProfileUpdate |
|
304 // ----------------------------------------------------------------------------- |
|
305 // |
|
306 TBool CSIPProfileCacheItem::HasProfileUpdate() const |
|
307 { |
|
308 return iOldProfile != NULL; |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // CSIPProfileCacheItem::UsedProfile |
|
313 // Return the CSIPConcreteProfile that most recently used profile agent to |
|
314 // register, deregister or update. |
|
315 // |
|
316 // iProfileWithNewIAP and iProfileWithOldIAP exist only during ALR migration, |
|
317 // and they never exist both at the same time. |
|
318 // iProfileWithNewIAP exists only in state CSIPProfileStateMigratingToNewIAP and |
|
319 // iProfileWithOldIAP exists only in state CSIPProfileStateUnregisteringOldIAP. |
|
320 // |
|
321 // iOldProfile exists during an update. |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 CSIPConcreteProfile& CSIPProfileCacheItem::UsedProfile() |
|
325 { |
|
326 return iProfileWithNewIAP ? *iProfileWithNewIAP : |
|
327 iProfileWithOldIAP ? *iProfileWithOldIAP : |
|
328 iOldProfile ? *iOldProfile : Profile(); |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CSIPProfileCacheItem::UsedProfile |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 const CSIPConcreteProfile& CSIPProfileCacheItem::UsedProfile() const |
|
336 { |
|
337 return iProfileWithNewIAP ? *iProfileWithNewIAP : |
|
338 iProfileWithOldIAP ? *iProfileWithOldIAP : |
|
339 iOldProfile ? *iOldProfile : Profile(); |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // CSIPProfileCacheItem::AddObserverL |
|
344 // Don't add observer to iObserversWaitedForPermission. It has only observers |
|
345 // that were notified of a new IAP. |
|
346 // ----------------------------------------------------------------------------- |
|
347 // |
|
348 void CSIPProfileCacheItem::AddObserverL( |
|
349 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
350 { |
|
351 iObservers.AppendL(&aObserver); |
|
352 } |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // CSIPProfileCacheItem::RemoveObserver |
|
356 // ----------------------------------------------------------------------------- |
|
357 // |
|
358 void CSIPProfileCacheItem::RemoveObserver( |
|
359 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
360 { |
|
361 TInt index = iObservers.Find(&aObserver); |
|
362 if (index != KErrNotFound) |
|
363 { |
|
364 iObservers.Remove(index); |
|
365 } |
|
366 |
|
367 RemoveFromPendingObservers(aObserver); |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // CSIPProfileCacheItem::Observers |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 const RPointerArray<MSIPExtendedConcreteProfileObserver>& |
|
375 CSIPProfileCacheItem::Observers() const |
|
376 { |
|
377 return iObservers; |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CSIPProfileCacheItem::IsObserverOrUser |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 TBool CSIPProfileCacheItem::IsObserverOrUser( |
|
385 const MSIPExtendedConcreteProfileObserver& aObserver) const |
|
386 { |
|
387 return (iObservers.Find(&aObserver) != KErrNotFound) || IsUser(aObserver); |
|
388 } |
|
389 |
|
390 // ----------------------------------------------------------------------------- |
|
391 // CSIPProfileCacheItem::RemoveUser |
|
392 // ----------------------------------------------------------------------------- |
|
393 // |
|
394 void CSIPProfileCacheItem::RemoveUser( |
|
395 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
396 { |
|
397 TInt index = iUsers.Find(&aObserver); |
|
398 if (index != KErrNotFound) |
|
399 { |
|
400 iUsers.Remove(index); |
|
401 CheckProfileEnabledState(); |
|
402 } |
|
403 } |
|
404 |
|
405 // ----------------------------------------------------------------------------- |
|
406 // CSIPProfileCacheItem::RemoveAllUsers |
|
407 // ----------------------------------------------------------------------------- |
|
408 // |
|
409 void CSIPProfileCacheItem::RemoveAllUsers() |
|
410 { |
|
411 iUsers.Reset(); |
|
412 CheckProfileEnabledState(); |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // CSIPProfileCacheItem::IsUser |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 TBool CSIPProfileCacheItem::IsUser( |
|
420 const MSIPExtendedConcreteProfileObserver& aObserver) const |
|
421 { |
|
422 return iUsers.Find(&aObserver) != KErrNotFound; |
|
423 } |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // CSIPProfileCacheItem::MoveToUserL |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 void CSIPProfileCacheItem::MoveToUserL( |
|
430 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
431 { |
|
432 iUsers.AppendL(&aObserver); |
|
433 |
|
434 CheckProfileEnabledState(); |
|
435 } |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // CSIPProfileCacheItem::IsActiveState |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 TBool CSIPProfileCacheItem::IsActiveState() const |
|
442 { |
|
443 return iCacheState == ENormal; |
|
444 } |
|
445 |
|
446 // ----------------------------------------------------------------------------- |
|
447 // CSIPProfileCacheItem::HasAorL |
|
448 // ----------------------------------------------------------------------------- |
|
449 // |
|
450 TBool CSIPProfileCacheItem::HasAorL(const TDesC8& aAOR) const |
|
451 { |
|
452 TUriParser8 otherUriparser; |
|
453 User::LeaveIfError(otherUriparser.Parse(aAOR)); |
|
454 TInt err = otherUriparser.Equivalent(iProfile->AORUri8()); |
|
455 if (err == KErrNoMemory) |
|
456 { |
|
457 User::Leave(err); |
|
458 } |
|
459 return err == KErrNone; |
|
460 } |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // CSIPProfileCacheItem::StartRegisterL |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 void CSIPProfileCacheItem::StartRegisterL(CSIPProfileState& aWaitForIAP, |
|
467 CSIPProfileState& aRegInProg, |
|
468 TBool aGetIap) |
|
469 { |
|
470 TUint32 snapId(0); |
|
471 PROFILE_DEBUG3("ProfileCacheItem::StartRegisterL - SNAP ID", snapId) |
|
472 if (aGetIap && IsSNAPConfigured(snapId)) |
|
473 { |
|
474 PROFILE_DEBUG3("ProfileCacheItem::StartRegisterL - MONITOR SNAP", snapId) |
|
475 MonitorSnapL(snapId, aWaitForIAP, aRegInProg); |
|
476 } |
|
477 else |
|
478 { |
|
479 PROFILE_DEBUG3("ProfileCacheItem::StartRegisterL - REGISTER", snapId) |
|
480 iCurrentState->RegisterL(*this); |
|
481 } |
|
482 } |
|
483 |
|
484 // ----------------------------------------------------------------------------- |
|
485 // CSIPProfileCacheItem::EnableL |
|
486 // ----------------------------------------------------------------------------- |
|
487 // |
|
488 void CSIPProfileCacheItem::EnableL( |
|
489 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
490 { |
|
491 iCurrentState->EnableL(*this, aObserver); |
|
492 } |
|
493 |
|
494 // ----------------------------------------------------------------------------- |
|
495 // CSIPProfileCacheItem::EnableSnapInUseL |
|
496 // ----------------------------------------------------------------------------- |
|
497 // |
|
498 void CSIPProfileCacheItem::EnableSnapInUseL( |
|
499 const MSIPExtendedConcreteProfileObserver& aObserver, |
|
500 TUint32 aSnapId) |
|
501 { |
|
502 iCurrentState->EnableSnapInUseL(*this, aObserver, aSnapId); |
|
503 } |
|
504 |
|
505 // ----------------------------------------------------------------------------- |
|
506 // CSIPProfileCacheItem::DisableL |
|
507 // ----------------------------------------------------------------------------- |
|
508 // |
|
509 void CSIPProfileCacheItem::DisableL( |
|
510 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
511 { |
|
512 iCurrentState->DisableL(*this, aObserver); |
|
513 } |
|
514 |
|
515 // ----------------------------------------------------------------------------- |
|
516 // CSIPProfileCacheItem::RemoveL |
|
517 // ----------------------------------------------------------------------------- |
|
518 // |
|
519 void CSIPProfileCacheItem::RemoveL() |
|
520 { |
|
521 iCacheState = EToBeRemoved; |
|
522 iCurrentState->RemoveL(*this); |
|
523 } |
|
524 |
|
525 // ----------------------------------------------------------------------------- |
|
526 // CSIPProfileCacheItem::ShutdownInitiated |
|
527 // ----------------------------------------------------------------------------- |
|
528 // |
|
529 void CSIPProfileCacheItem::ShutdownInitiated() |
|
530 { |
|
531 iIsShutdownInitiated = ETrue; |
|
532 iCurrentState->ShutdownInitiated(*this); |
|
533 } |
|
534 |
|
535 // ----------------------------------------------------------------------------- |
|
536 // CSIPProfileCacheItem::IsShutdownInitiated |
|
537 // ----------------------------------------------------------------------------- |
|
538 // |
|
539 TBool CSIPProfileCacheItem::IsShutdownInitiated() const |
|
540 { |
|
541 return iIsShutdownInitiated; |
|
542 } |
|
543 |
|
544 // ----------------------------------------------------------------------------- |
|
545 // CSIPProfileCacheItem::RfsInprogress |
|
546 // ----------------------------------------------------------------------------- |
|
547 // |
|
548 void CSIPProfileCacheItem::RfsInprogress(TBool aStatus) |
|
549 { |
|
550 iIsRfsInprogress = aStatus; |
|
551 iCurrentState->ShutdownInitiated(*this); |
|
552 } |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // CSIPProfileCacheItem::IsRfsInprogress |
|
556 // ----------------------------------------------------------------------------- |
|
557 // |
|
558 TBool CSIPProfileCacheItem::IsRfsInprogress() const |
|
559 { |
|
560 return iIsRfsInprogress; |
|
561 } |
|
562 |
|
563 // CSIPProfileCacheItem::CanBePermanentlyRemoved |
|
564 // ----------------------------------------------------------------------------- |
|
565 // |
|
566 TBool CSIPProfileCacheItem::CanBePermanentlyRemoved() const |
|
567 { |
|
568 return iCurrentState->CanBePermanentlyRemoved(*this); |
|
569 } |
|
570 |
|
571 // ----------------------------------------------------------------------------- |
|
572 // CSIPProfileCacheItem::UpdateRegistrationL |
|
573 // ----------------------------------------------------------------------------- |
|
574 // |
|
575 void CSIPProfileCacheItem::UpdateRegistrationL( |
|
576 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
577 { |
|
578 iCurrentState->UpdateRegistrationL(*this, aObserver); |
|
579 } |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // CSIPProfileCacheItem::RegistrationStatusEvent |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 void CSIPProfileCacheItem::RegistrationStatusEventL( |
|
586 CSIPConcreteProfile::TStatus aStatus, |
|
587 TUint32 aStatusId) |
|
588 { |
|
589 UsedProfile().SetContextId(aStatusId); |
|
590 iCurrentState->RegistrationStatusEventL(*this, aStatus); |
|
591 } |
|
592 |
|
593 // ----------------------------------------------------------------------------- |
|
594 // CSIPProfileCacheItem::ChangeStateL |
|
595 // ----------------------------------------------------------------------------- |
|
596 // |
|
597 void CSIPProfileCacheItem::ChangeStateL(CSIPProfileState* aNewState) |
|
598 { |
|
599 CSIPConcreteProfile::TStatus newState = aNewState->Name(); |
|
600 PROFILE_DEBUG5("ProfileCacheItem::ChangeStateL id,old state,new state", |
|
601 ProfileId(), |
|
602 iCurrentState->Name(), |
|
603 newState) |
|
604 |
|
605 TBool maySendRegStatusEvent = !iCurrentState->IsAlrState(); |
|
606 if (!aNewState->IsAlrState()) |
|
607 { |
|
608 iProfile->SetStatus(newState); |
|
609 } |
|
610 |
|
611 iCurrentState = aNewState; |
|
612 iCurrentState->EnterL(*this, maySendRegStatusEvent, iServerCore); |
|
613 |
|
614 ResumeL(); |
|
615 } |
|
616 |
|
617 // ----------------------------------------------------------------------------- |
|
618 // CSIPProfileCacheItem::ResumeL |
|
619 // Don't resume if migrating. Resume is only used with SNAP. |
|
620 // If both a queued update and iMustRefreshIAPs exist, do update first. |
|
621 // ----------------------------------------------------------------------------- |
|
622 // |
|
623 void CSIPProfileCacheItem::ResumeL() |
|
624 { |
|
625 PROFILE_DEBUG3("ProfileCacheItem::ResumeL id", ProfileId()) |
|
626 |
|
627 TUint32 snapId(0); |
|
628 if (!IAPMigrationInProgress()) |
|
629 { |
|
630 PROFILE_DEBUG1("ProfileCacheItem::ResumeL SNAP used,not migrating") |
|
631 |
|
632 if (iQueuedProfile && iCurrentState->CanProfileBeUpdated(*this)) |
|
633 { |
|
634 ResumeQueuedUpdateL(); |
|
635 } |
|
636 else if(IsSNAPConfigured(snapId)) |
|
637 { |
|
638 PROFILE_DEBUG1("ProfileCacheItem::ResumeL don't resume now") |
|
639 |
|
640 // HasProfileUpdate is checked in ShouldRefreshIAPs |
|
641 if (iMustRefreshIAPs && |
|
642 iCurrentState->ShouldRefreshIAPs(*this) && |
|
643 iMigrationController) |
|
644 { |
|
645 iMustRefreshIAPs = EFalse; |
|
646 PROFILE_DEBUG3("Refresh IAPs, snapId=", snapId) |
|
647 iMigrationController->RefreshIapAvailabilityL(snapId); |
|
648 } |
|
649 } |
|
650 } |
|
651 } |
|
652 |
|
653 // ----------------------------------------------------------------------------- |
|
654 // CSIPProfileCacheItem::SetIAPRefreshReminder |
|
655 // ----------------------------------------------------------------------------- |
|
656 // |
|
657 void CSIPProfileCacheItem::SetIAPRefreshReminder() |
|
658 { |
|
659 iMustRefreshIAPs = ETrue; |
|
660 } |
|
661 |
|
662 // ----------------------------------------------------------------------------- |
|
663 // CSIPProfileCacheItem::NewIAPFailed |
|
664 // ----------------------------------------------------------------------------- |
|
665 // |
|
666 void CSIPProfileCacheItem::NewIAPFailed() |
|
667 { |
|
668 PROFILE_DEBUG1("ProfileCacheItem::NewIAPFailed") |
|
669 |
|
670 iDeltaTimer->Remove(iDeltaTimerEntry); |
|
671 |
|
672 const TInt KIapFailedDelay(1); |
|
673 |
|
674 TTimeIntervalMicroSeconds32 interval(KIapFailedDelay); |
|
675 iDeltaTimer->Queue(interval, iDeltaTimerEntry); |
|
676 } |
|
677 |
|
678 // ----------------------------------------------------------------------------- |
|
679 // CSIPProfileCacheItem::SendUnregisteredStatusEventL |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 void CSIPProfileCacheItem::SendUnregisteredStatusEventL() |
|
683 { |
|
684 iServerCore.SendUnregisteredStatusEventL(*this); |
|
685 } |
|
686 |
|
687 // ----------------------------------------------------------------------------- |
|
688 // CSIPProfileCacheItem::HandleProfileError |
|
689 // ----------------------------------------------------------------------------- |
|
690 // |
|
691 void CSIPProfileCacheItem::HandleProfileError(TInt aError, |
|
692 CSIPConcreteProfile& aProfile) |
|
693 { |
|
694 PROFILE_DEBUG3("ProfileCacheItem::HandleProfileError", aError) |
|
695 iServerCore.SIPProfileErrorEvent(aProfile, aError); |
|
696 } |
|
697 |
|
698 // ----------------------------------------------------------------------------- |
|
699 // CSIPProfileCacheItem::HandleError |
|
700 // ----------------------------------------------------------------------------- |
|
701 // |
|
702 TBool CSIPProfileCacheItem::HandleError(TInt aError) |
|
703 { |
|
704 PROFILE_DEBUG4("ProfileCacheItem::HandleError id,err", ProfileId(), aError) |
|
705 |
|
706 if (iCurrentState->ErrorOccurred(*this, aError)) |
|
707 { |
|
708 PROFILE_DEBUG1("ProfileCacheItem::HandleError go unregistered") |
|
709 |
|
710 SwitchToUnregisteredState(); |
|
711 |
|
712 if (aError != KErrNone) |
|
713 { |
|
714 iProfile->SetLastRegistrationError(aError); |
|
715 } |
|
716 return ETrue; |
|
717 } |
|
718 return EFalse; |
|
719 } |
|
720 |
|
721 // ----------------------------------------------------------------------------- |
|
722 // CSIPProfileCacheItem::Compare |
|
723 // During linear search operations the search term is always passed as the first |
|
724 // argument and the second argument is an element of the array being searched. |
|
725 // |
|
726 // As MSIPProfileAgentObserver calls can lead here, aSearched.iProfileId can be |
|
727 // a temp id, used in iOldProfile, iProfileWithNewIAP, iProfileWithOldIAP. |
|
728 // iQueuedProfile has the same profile id as current profile. |
|
729 // ----------------------------------------------------------------------------- |
|
730 // |
|
731 TBool CSIPProfileCacheItem::Compare(const CSIPProfileCacheItem& aSearched, |
|
732 const CSIPProfileCacheItem& aArrayItem) |
|
733 { |
|
734 CSIPConcreteProfile* old = aArrayItem.iOldProfile; |
|
735 CSIPConcreteProfile* newIap = aArrayItem.iProfileWithNewIAP; |
|
736 CSIPConcreteProfile* oldIap = aArrayItem.iProfileWithOldIAP; |
|
737 return (aArrayItem.iProfileId == aSearched.iProfileId) || |
|
738 (old && old->Id() == aSearched.iProfileId) || |
|
739 (newIap && newIap->Id() == aSearched.iProfileId) || |
|
740 (oldIap && oldIap->Id() == aSearched.iProfileId); |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // CSIPProfileCacheItem::ClientAllowsMigrationL |
|
745 // ----------------------------------------------------------------------------- |
|
746 // |
|
747 void CSIPProfileCacheItem::ClientAllowsMigrationL(TUint32 aIapId, |
|
748 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
749 { |
|
750 iCurrentState->ClientAllowsMigrationL(*this, aIapId, aObserver); |
|
751 } |
|
752 |
|
753 // ----------------------------------------------------------------------------- |
|
754 // CSIPProfileCacheItem::ClientDisallowsMigrationL |
|
755 // ----------------------------------------------------------------------------- |
|
756 // |
|
757 void CSIPProfileCacheItem::ClientDisallowsMigrationL(TUint32 aIapId, |
|
758 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
759 { |
|
760 iCurrentState->ClientDisallowsMigrationL(*this, aIapId, aObserver); |
|
761 } |
|
762 |
|
763 // ----------------------------------------------------------------------------- |
|
764 // CSIPProfileCacheItem::SetClientPermission |
|
765 // ----------------------------------------------------------------------------- |
|
766 // |
|
767 void CSIPProfileCacheItem::SetClientPermission(TUint32 aIapId, |
|
768 const MSIPExtendedConcreteProfileObserver* aObserver, |
|
769 TBool aAllowMigration) |
|
770 { |
|
771 PROFILE_DEBUG5("ProfileCacheItem::SetClientPermission id,iap,allow", |
|
772 ProfileId(), |
|
773 aIapId, |
|
774 aAllowMigration) |
|
775 PROFILE_DEBUG3("pending observers=", iObserversWaitedForPermission.Count()) |
|
776 |
|
777 if (!aAllowMigration) |
|
778 { |
|
779 iMigrationDisallowed = ETrue; |
|
780 } |
|
781 if (aObserver) |
|
782 { |
|
783 RemoveFromPendingObservers(*aObserver); |
|
784 } |
|
785 |
|
786 if (iObserversWaitedForPermission.Count() == 0 && iMigrationController) |
|
787 { |
|
788 PROFILE_DEBUG3("ProfileCacheItem::SetClientPermission allow", |
|
789 !iMigrationDisallowed) |
|
790 iMigrationController->SetMigrationPermission(*this, |
|
791 !iMigrationDisallowed, |
|
792 aIapId); |
|
793 } |
|
794 } |
|
795 |
|
796 // ----------------------------------------------------------------------------- |
|
797 // CSIPProfileCacheItem::IsSNAPConfigured |
|
798 // ----------------------------------------------------------------------------- |
|
799 // |
|
800 TBool CSIPProfileCacheItem::IsSNAPConfigured(TUint32& aSnapId) const |
|
801 { |
|
802 TBool Val = (UsedProfile().ExtensionParameter(KSIPSnapId, aSnapId) == KErrNone); |
|
803 |
|
804 PROFILE_DEBUG3("Exceptional SNAP Entry verifier :", KDefaultSNAPIdentifier) |
|
805 if(Val && aSnapId == KDefaultSNAPIdentifier) |
|
806 { |
|
807 PROFILE_DEBUG3("Snap ID Found to be :", aSnapId) |
|
808 TRAPD(err, DefaultSNAPL(aSnapId)); |
|
809 if(err) |
|
810 { |
|
811 Val = EFalse; |
|
812 } |
|
813 } |
|
814 PROFILE_DEBUG3("ProfileCacheItem::IsSNAPConfigured; return SNAP ID Value = ", aSnapId) |
|
815 PROFILE_DEBUG3("ProfileCacheItem::IsSNAPConfigured; return Value = ", Val) |
|
816 return Val; |
|
817 } |
|
818 |
|
819 // ----------------------------------------------------------------------------- |
|
820 // CSIPProfileCacheItem::PassMigrationStartedToClientL |
|
821 // ----------------------------------------------------------------------------- |
|
822 // |
|
823 void CSIPProfileCacheItem::PassMigrationStartedToClientL(TUint32 aSnapId, |
|
824 TUint32 aIapId) |
|
825 { |
|
826 iServerCore.MigrationStartedL(*this, aSnapId, aIapId); |
|
827 } |
|
828 |
|
829 // ----------------------------------------------------------------------------- |
|
830 // CSIPProfileCacheItem::PassAlrErrorToClient |
|
831 // ----------------------------------------------------------------------------- |
|
832 // |
|
833 TInt CSIPProfileCacheItem::PassAlrErrorToClient(TInt aError, TUint32 aIapId) |
|
834 { |
|
835 TUint32 snapId(0); |
|
836 if (!IsSNAPConfigured(snapId)) |
|
837 { |
|
838 return KErrNotFound; |
|
839 } |
|
840 return iServerCore.PassAlrErrorToClient(*this, aError, snapId, aIapId); |
|
841 } |
|
842 |
|
843 // ----------------------------------------------------------------------------- |
|
844 // CSIPProfileCacheItem::HandleNewIapL |
|
845 // ----------------------------------------------------------------------------- |
|
846 // |
|
847 void CSIPProfileCacheItem::HandleNewIapL(TUint32 aSnapId, |
|
848 TUint32 aIapId, |
|
849 TBool aRegistrationExists, |
|
850 CSIPProfileState& aWaitForPermission) |
|
851 { |
|
852 PROFILE_DEBUG5("ProfileCacheItem::HandleNewIapL id,snap,iap", |
|
853 ProfileId(), |
|
854 aSnapId, |
|
855 aIapId) |
|
856 PROFILE_DEBUG3("reg exists=", aRegistrationExists) |
|
857 |
|
858 TUint32 snapId(0); |
|
859 __ASSERT_ALWAYS(IsSNAPConfigured(snapId), User::Leave(KErrNotFound)); |
|
860 __ASSERT_ALWAYS(aSnapId == snapId, User::Leave(KErrArgument)); |
|
861 |
|
862 iMigrationDisallowed = EFalse; |
|
863 |
|
864 // SetMigrationPermission can syncronously lead to MigrationIs(Dis)AllowedL |
|
865 // so enter state first. |
|
866 ChangeStateL(&aWaitForPermission); |
|
867 if (aRegistrationExists) |
|
868 { |
|
869 // Don't wait (dis)allow to an earlier IAP |
|
870 iObserversWaitedForPermission.Reset(); |
|
871 |
|
872 for (TInt i = 0; i < iObservers.Count(); ++i) |
|
873 { |
|
874 if (iObservers[i]->IapAvailableL(ProfileId(), aSnapId, aIapId)) |
|
875 { |
|
876 iObserversWaitedForPermission.AppendL(iObservers[i]); |
|
877 } |
|
878 } |
|
879 PROFILE_DEBUG3("pending count=", iObserversWaitedForPermission.Count()) |
|
880 if (iObserversWaitedForPermission.Count() == 0) |
|
881 { |
|
882 iMigrationController->SetMigrationPermission(*this, ETrue, aIapId); |
|
883 } |
|
884 } |
|
885 else |
|
886 { |
|
887 // Don't pass IAP-Available, MigrationStarted or MigrationCompleted to |
|
888 // clients. This profile's clients are not asked for permission, but |
|
889 // another profile with same SNAP can disallow migration. |
|
890 __ASSERT_ALWAYS(!iProfileWithNewIAP, User::Leave(KErrNotFound)); |
|
891 iMigrationController->SetMigrationPermission(*this, ETrue, aIapId); |
|
892 } |
|
893 } |
|
894 |
|
895 // ----------------------------------------------------------------------------- |
|
896 // CSIPProfileCacheItem::MonitorSnapL |
|
897 // ----------------------------------------------------------------------------- |
|
898 // |
|
899 void CSIPProfileCacheItem::MonitorSnapL(TUint32 aSnapId, |
|
900 CSIPProfileState& aWaitForIAP, |
|
901 CSIPProfileState& aRegInProg) |
|
902 { |
|
903 if (iMigrationController && iMigrationController->SnapId() != aSnapId) |
|
904 { |
|
905 // Stop monitoring the old SNAP id |
|
906 StopSnapMonitoring(); |
|
907 } |
|
908 |
|
909 if (!iMigrationController) |
|
910 { |
|
911 iMigrationController = &iServerCore.MigrationControllerL(aSnapId); |
|
912 TUint32 iapId = iMigrationController->AttachProfileL(*this); |
|
913 if (iapId) |
|
914 { |
|
915 // Initial IAP obtained |
|
916 aRegInProg.RegisterWithIapL(*this, iapId, aRegInProg); |
|
917 } |
|
918 else |
|
919 { |
|
920 // No IAP available yet |
|
921 ChangeStateL(&aWaitForIAP); |
|
922 } |
|
923 } |
|
924 } |
|
925 |
|
926 // ----------------------------------------------------------------------------- |
|
927 // CSIPProfileCacheItem::ProfileRegisteredL |
|
928 // If initial registration, don't pass MigrationCompleted. |
|
929 // ----------------------------------------------------------------------------- |
|
930 // |
|
931 void |
|
932 CSIPProfileCacheItem::ProfileRegisteredL(TBool aMigrating) |
|
933 { |
|
934 TUint32 snapId(0); |
|
935 if (IsSNAPConfigured(snapId)) |
|
936 { |
|
937 __ASSERT_ALWAYS(iMigrationController != NULL, |
|
938 User::Leave(KErrNotFound)); |
|
939 |
|
940 TInt err = iMigrationController->SetIapAcceptance(*this, ETrue); |
|
941 if (err != KErrNone) |
|
942 { |
|
943 iServerCore.HandleProfileError(*this, err); |
|
944 return; |
|
945 } |
|
946 if (aMigrating) |
|
947 { |
|
948 iServerCore.MigrationCompletedL(*this, snapId, Profile().IapId()); |
|
949 } |
|
950 // Send notification of the updated IAP |
|
951 iServerCore.SendProfileUpdatedEventL(*this, Profile()); |
|
952 } |
|
953 } |
|
954 |
|
955 // ----------------------------------------------------------------------------- |
|
956 // CSIPProfileCacheItem::RegistrationEnded |
|
957 // Can use the same profile id, as TerminateHandling cleared earlier profile |
|
958 // from Profile Agent. |
|
959 // If client uses SetClientPermission later, migration controller ignores it |
|
960 // ----------------------------------------------------------------------------- |
|
961 // |
|
962 void CSIPProfileCacheItem::RegistrationEnded() |
|
963 { |
|
964 PROFILE_DEBUG3("ProfileCacheItem::RegistrationEnded id", ProfileId()) |
|
965 |
|
966 // If this has already been done, does nothing. |
|
967 iMigrationController->SetMigrationPermission(*this, ETrue); |
|
968 } |
|
969 |
|
970 // ----------------------------------------------------------------------------- |
|
971 // CSIPProfileCacheItem::CheckProfileEnabledState |
|
972 // ----------------------------------------------------------------------------- |
|
973 // |
|
974 void CSIPProfileCacheItem::CheckProfileEnabledState() |
|
975 { |
|
976 UsedProfile().SetEnabled(iUsers.Count() > 0); |
|
977 } |
|
978 |
|
979 // ----------------------------------------------------------------------------- |
|
980 // CSIPProfileCacheItem::IsReferred |
|
981 // ----------------------------------------------------------------------------- |
|
982 // |
|
983 TBool CSIPProfileCacheItem::IsReferred() const |
|
984 { |
|
985 return ReferenceCount() > 0 || Profile().IsAutoRegistrationEnabled(); |
|
986 } |
|
987 |
|
988 // ----------------------------------------------------------------------------- |
|
989 // CSIPProfileCacheItem::ProceedUpdatingProfileL |
|
990 // If updating SNAP, de-register old SNAP's profile, then register new SNAP's |
|
991 // profile. CSIPProfileStateUnregistered::EnterL calls StartRegisterL, ending |
|
992 // old SNAP monitoring and starts monitoring new SNAP. |
|
993 // ----------------------------------------------------------------------------- |
|
994 // |
|
995 void |
|
996 CSIPProfileCacheItem::ProceedUpdatingProfileL(CSIPProfileState& aUnregInProg) |
|
997 { |
|
998 if (HasProfileUpdate() && !IAPMigrationInProgress()) |
|
999 { |
|
1000 if (IsSnapIdUpdated(Profile())) |
|
1001 { |
|
1002 aUnregInProg.StartDeregisterL(*this, aUnregInProg); |
|
1003 } |
|
1004 else |
|
1005 { |
|
1006 if (aUnregInProg.DoUpdateL(Profile(), *iOldProfile)) |
|
1007 { |
|
1008 ChangeStateL(&aUnregInProg); |
|
1009 } |
|
1010 else |
|
1011 { |
|
1012 ClearOldProfile(); |
|
1013 // Update is complete, resume any pending action |
|
1014 ResumeL(); |
|
1015 } |
|
1016 } |
|
1017 } |
|
1018 } |
|
1019 |
|
1020 // ----------------------------------------------------------------------------- |
|
1021 // CSIPProfileCacheItem::StopSnapMonitoring |
|
1022 // ----------------------------------------------------------------------------- |
|
1023 // |
|
1024 void CSIPProfileCacheItem::StopSnapMonitoring() |
|
1025 { |
|
1026 if (iMigrationController) |
|
1027 { |
|
1028 iMigrationController->DetachProfile(*this); |
|
1029 iMigrationController = NULL; |
|
1030 } |
|
1031 } |
|
1032 |
|
1033 // ----------------------------------------------------------------------------- |
|
1034 // CSIPProfileCacheItem::CloneProfileL |
|
1035 // Use a new profile id for the new IAP, so Profile Agent treats it as different |
|
1036 // profile from the old IAP. |
|
1037 // ----------------------------------------------------------------------------- |
|
1038 // |
|
1039 CSIPConcreteProfile& CSIPProfileCacheItem::CloneProfileL(TUint aIapId) |
|
1040 { |
|
1041 PROFILE_DEBUG4("ProfileCacheItem::CloneProfileL id,iap", |
|
1042 ProfileId(), |
|
1043 aIapId) |
|
1044 __ASSERT_ALWAYS(!iProfileWithNewIAP, User::Leave(KErrAlreadyExists)); |
|
1045 |
|
1046 CSIPConcreteProfile* profile = Profile().CloneL(); |
|
1047 CleanupStack::PushL(profile); |
|
1048 profile->SetId(iServerCore.GenerateProfileIdL()); |
|
1049 profile->SetStorageId(Profile().StorageId()); |
|
1050 |
|
1051 // Use the same Contact user-part as the existing profile. |
|
1052 // CSIPConcreteProfile::CloneL generated a new one. |
|
1053 const TDesC8* user(NULL); |
|
1054 User::LeaveIfError(Profile().ExtensionParameter( |
|
1055 KSIPContactHeaderUser, user)); |
|
1056 profile->SetExtensionParameterL(KSIPContactHeaderUser, *user); |
|
1057 CleanupStack::Pop(profile); |
|
1058 profile->SetIapId(aIapId); |
|
1059 |
|
1060 iProfileWithNewIAP = profile; |
|
1061 return *iProfileWithNewIAP; |
|
1062 } |
|
1063 |
|
1064 // ----------------------------------------------------------------------------- |
|
1065 // CSIPProfileCacheItem::ClearMigrationProfiles |
|
1066 // ----------------------------------------------------------------------------- |
|
1067 // |
|
1068 void CSIPProfileCacheItem::ClearMigrationProfiles() |
|
1069 { |
|
1070 delete iProfileWithNewIAP; |
|
1071 iProfileWithNewIAP = NULL; |
|
1072 delete iProfileWithOldIAP; |
|
1073 iProfileWithOldIAP = NULL; |
|
1074 } |
|
1075 |
|
1076 // ----------------------------------------------------------------------------- |
|
1077 // CSIPProfileCacheItem::UseProfileWithNewIAP |
|
1078 // The new IAP works. Prepare to de-register the old IAP. |
|
1079 // ----------------------------------------------------------------------------- |
|
1080 // |
|
1081 CSIPConcreteProfile& CSIPProfileCacheItem::UseProfileWithNewIAP() |
|
1082 { |
|
1083 __ASSERT_ALWAYS(!iProfileWithOldIAP, |
|
1084 User::Panic(KNullDesC, KErrAlreadyExists)); |
|
1085 __ASSERT_ALWAYS(iProfileWithNewIAP != NULL, |
|
1086 User::Panic(KNullDesC, KErrNotFound)); |
|
1087 |
|
1088 PROFILE_DEBUG4("ProfileCacheItem::UseProfileWithNewIAP Swapping Id1, Id2", |
|
1089 iProfile->Id(), iProfileWithNewIAP->Id() ) |
|
1090 |
|
1091 iProfileWithNewIAP->SetStatus( CSIPConcreteProfile::ERegistered ); |
|
1092 |
|
1093 // Swap profile id's. Only the original id can be passed to clients. |
|
1094 TUint32 originalId( iProfile->Id() ); |
|
1095 iProfile->SetId( iProfileWithNewIAP->Id() ); |
|
1096 iProfileWithNewIAP->SetId( originalId ); |
|
1097 |
|
1098 iProfileWithOldIAP = iProfile; |
|
1099 iProfile = iProfileWithNewIAP; |
|
1100 iProfileWithNewIAP = NULL; |
|
1101 |
|
1102 return *iProfileWithOldIAP; |
|
1103 } |
|
1104 |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // CSIPProfileCacheItem::IAPMigrationInProgress |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // |
|
1109 TBool CSIPProfileCacheItem::IAPMigrationInProgress() const |
|
1110 { |
|
1111 return iProfileWithNewIAP || iProfileWithOldIAP; |
|
1112 } |
|
1113 |
|
1114 // ----------------------------------------------------------------------------- |
|
1115 // CSIPProfileCacheItem::StoreProfileToUpdate |
|
1116 // ----------------------------------------------------------------------------- |
|
1117 // |
|
1118 void |
|
1119 CSIPProfileCacheItem::StoreProfileToUpdate(CSIPConcreteProfile* aNewProfile) |
|
1120 { |
|
1121 PROFILE_DEBUG3("ProfileCacheItem::StoreProfileToUpdate id", ProfileId()) |
|
1122 |
|
1123 if (!iOldProfile) |
|
1124 { |
|
1125 iOldProfile = iProfile; |
|
1126 iProfile = NULL; |
|
1127 } |
|
1128 SetProfile(aNewProfile); |
|
1129 } |
|
1130 |
|
1131 // ----------------------------------------------------------------------------- |
|
1132 // CSIPProfileCacheItem::ResumeQueuedUpdateL |
|
1133 // ----------------------------------------------------------------------------- |
|
1134 // |
|
1135 void CSIPProfileCacheItem::ResumeQueuedUpdateL() |
|
1136 { |
|
1137 PROFILE_DEBUG3("ProfileCacheItem::ResumeQueuedUpdateL id", ProfileId()) |
|
1138 __ASSERT_ALWAYS(iQueuedProfile != NULL && iQueuedObserver != NULL, |
|
1139 User::Leave(KErrNotFound)); |
|
1140 __ASSERT_ALWAYS(!IAPMigrationInProgress(), User::Leave(KErrNotReady)); |
|
1141 |
|
1142 CSIPConcreteProfile* profile = iQueuedProfile; |
|
1143 TUint32 snapId(0); |
|
1144 if (!IsSnapIdUpdated(*profile) && IsSNAPConfigured(snapId)) |
|
1145 { |
|
1146 // Use the current IAP id |
|
1147 profile->SetIapId(UsedProfile().IapId()); |
|
1148 } |
|
1149 const MSIPExtendedConcreteProfileObserver* obs = iQueuedObserver; |
|
1150 iQueuedProfile = NULL; |
|
1151 iQueuedObserver = NULL; |
|
1152 StoreProfileToUpdate(profile); |
|
1153 |
|
1154 iServerCore.UpdateRegistrationL(ProfileId(), *obs); |
|
1155 } |
|
1156 |
|
1157 // ----------------------------------------------------------------------------- |
|
1158 // CSIPProfileCacheItem::IsSnapIdUpdated |
|
1159 // ----------------------------------------------------------------------------- |
|
1160 // |
|
1161 TBool |
|
1162 CSIPProfileCacheItem::IsSnapIdUpdated(CSIPConcreteProfile& aNewProfile) const |
|
1163 { |
|
1164 TUint32 currentSnapId(0); |
|
1165 IsSNAPConfigured(currentSnapId); |
|
1166 |
|
1167 TUint32 newSnapId(0); |
|
1168 TBool res(EFalse); |
|
1169 |
|
1170 res = (aNewProfile.ExtensionParameter(KSIPSnapId, newSnapId) == KErrNone && |
|
1171 newSnapId != currentSnapId); |
|
1172 PROFILE_DEBUG3("Exceptional SNAP Entry verifier :", KDefaultSNAPIdentifier) |
|
1173 if(res && newSnapId == KDefaultSNAPIdentifier) |
|
1174 { |
|
1175 res=EFalse; |
|
1176 } |
|
1177 PROFILE_DEBUG3("CSIPProfileCacheItem::IsSnapIdUpdated CurrentSNAPID",currentSnapId) |
|
1178 PROFILE_DEBUG3("CSIPProfileCacheItem::IsSnapIdUpdated NewSNAPID",newSnapId) |
|
1179 return res; |
|
1180 } |
|
1181 |
|
1182 // ----------------------------------------------------------------------------- |
|
1183 // CSIPProfileCacheItem::RemoveFromPendingObservers |
|
1184 // ----------------------------------------------------------------------------- |
|
1185 // |
|
1186 void CSIPProfileCacheItem::RemoveFromPendingObservers( |
|
1187 const MSIPExtendedConcreteProfileObserver& aObserver) |
|
1188 { |
|
1189 TInt index = iObserversWaitedForPermission.Find(&aObserver); |
|
1190 if (index != KErrNotFound) |
|
1191 { |
|
1192 iObserversWaitedForPermission.Remove(index); |
|
1193 } |
|
1194 } |
|
1195 |
|
1196 // ----------------------------------------------------------------------------- |
|
1197 // CSIPProfileCacheItem::DoNewIapFailed |
|
1198 // Ignore SetIapAcceptance return value, as already handling error (IAP failed). |
|
1199 // ----------------------------------------------------------------------------- |
|
1200 // |
|
1201 TInt CSIPProfileCacheItem::DoNewIapFailed(TAny* aPtr) |
|
1202 { |
|
1203 __ASSERT_DEBUG(aPtr, User::Panic(_L("ProfileCacheItem:DoNewIapFailed"), |
|
1204 KErrArgument)); |
|
1205 PROFILE_DEBUG1("ProfileCacheItem::DoNewIapFailed") |
|
1206 |
|
1207 if ( !aPtr ) |
|
1208 { |
|
1209 return KErrArgument; |
|
1210 } |
|
1211 |
|
1212 CSIPProfileCacheItem* self = static_cast<CSIPProfileCacheItem*>(aPtr); |
|
1213 self->iMigrationController->ResetFlags(); |
|
1214 self->iMigrationController->SetIapAcceptance(*self, EFalse); |
|
1215 return KErrNone; |
|
1216 } |
|
1217 |
|
1218 // ----------------------------------------------------------------------------- |
|
1219 // CSIPProfileCacheItem::SwitchToUnregisteredState |
|
1220 // Enter unregistered state. Don't use ChangeStateL to avoid loop where profile |
|
1221 // would register again (if auto-registration on). |
|
1222 // ----------------------------------------------------------------------------- |
|
1223 // |
|
1224 void CSIPProfileCacheItem::SwitchToUnregisteredState() |
|
1225 { |
|
1226 CSIPProfileState& unregistered = iServerCore.UnregisteredState(); |
|
1227 iProfile->SetStatus(unregistered.Name()); |
|
1228 iCurrentState = &unregistered; |
|
1229 SetSnapRetryCounter(0); |
|
1230 |
|
1231 // No need to monitor SNAP anymore. |
|
1232 StopSnapMonitoring(); |
|
1233 RemoveAllUsers(); |
|
1234 } |
|
1235 |
|
1236 // ----------------------------------------------------------------------------- |
|
1237 // CSIPProfileCacheItem::SetSnapRetryCounter |
|
1238 // ----------------------------------------------------------------------------- |
|
1239 // |
|
1240 void CSIPProfileCacheItem::SetSnapRetryCounter(TInt aCounter) |
|
1241 { |
|
1242 PROFILE_DEBUG3("CSIPProfileCacheItem::SetSnapRetryCounter counter", |
|
1243 aCounter) |
|
1244 iSnapRetryCounter = aCounter; |
|
1245 } |
|
1246 |
|
1247 // ----------------------------------------------------------------------------- |
|
1248 // CSIPProfileCacheItem::SnapRetryCounter |
|
1249 // ----------------------------------------------------------------------------- |
|
1250 // |
|
1251 TInt CSIPProfileCacheItem::SnapRetryCounter() const |
|
1252 { |
|
1253 PROFILE_DEBUG3("CSIPProfileCacheItem::SnapRetryCounter counter", |
|
1254 iSnapRetryCounter) |
|
1255 return iSnapRetryCounter; |
|
1256 } |
|
1257 |
|
1258 // ----------------------------------------------------------------------------- |
|
1259 // CSIPProfileCacheItem::SnapRetryCountReached |
|
1260 // ----------------------------------------------------------------------------- |
|
1261 // |
|
1262 TBool CSIPProfileCacheItem::SnapRetryCountReached() const |
|
1263 { |
|
1264 TBool reached = iSnapRetryCounter >= KSnapRetryCountThreshold; |
|
1265 PROFILE_DEBUG3("CSIPProfileCacheItem::SnapRetryCountReached reached", |
|
1266 reached) |
|
1267 return reached; |
|
1268 } |
|
1269 |
|
1270 // ----------------------------------------------------------------------------- |
|
1271 // CSIPProfileCacheItem::OfferedIapRejected |
|
1272 // ----------------------------------------------------------------------------- |
|
1273 // |
|
1274 void CSIPProfileCacheItem::OfferedIapRejected() |
|
1275 { |
|
1276 PROFILE_DEBUG3("CSIPProfileCacheItem::OfferedIapRejected, status", |
|
1277 iProfile->Status()) |
|
1278 |
|
1279 HandleError( KErrCancel ); |
|
1280 |
|
1281 // State is informed as ERegistrationInProgress to get registration |
|
1282 // error event event in client. |
|
1283 iServerCore.SendErrorEvent( |
|
1284 *this, CSIPConcreteProfile::ERegistrationInProgress, KErrCancel ); |
|
1285 } |
|
1286 // ----------------------------------------------------------------------------- |
|
1287 // CSIPProfileCacheItem::ResetShutdownvariable |
|
1288 // ----------------------------------------------------------------------------- |
|
1289 // |
|
1290 void CSIPProfileCacheItem::ResetShutdownvariable() |
|
1291 { |
|
1292 iIsShutdownInitiated = EFalse; |
|
1293 } |
|
1294 |
|
1295 // ----------------------------------------------------------------------------- |
|
1296 // CSIPProfileCacheItem::DefaultSNAPL |
|
1297 // This function will return the ID of the default SNAP. |
|
1298 // ----------------------------------------------------------------------------- |
|
1299 // |
|
1300 |
|
1301 void CSIPProfileCacheItem::DefaultSNAPL(TUint32& aSnapId) const |
|
1302 |
|
1303 { |
|
1304 RCmManager cmManager; |
|
1305 cmManager.OpenL(); |
|
1306 CleanupClosePushL(cmManager); |
|
1307 TCmDefConnValue defConn; |
|
1308 cmManager.ReadDefConnL( defConn ); |
|
1309 aSnapId = defConn.iId; |
|
1310 PROFILE_DEBUG3("CSIPProfileCacheItem::DefaultSNAPL with Value: ", aSnapId) |
|
1311 CleanupStack::PopAndDestroy(); |
|
1312 } |