80 // ----------------------------------------------------------------------------- |
88 // ----------------------------------------------------------------------------- |
81 // CSIPProfileServerCore::CSIPProfileServerCore |
89 // CSIPProfileServerCore::CSIPProfileServerCore |
82 // ----------------------------------------------------------------------------- |
90 // ----------------------------------------------------------------------------- |
83 // |
91 // |
84 CSIPProfileServerCore::CSIPProfileServerCore() : |
92 CSIPProfileServerCore::CSIPProfileServerCore() : |
85 iBackupInProgress(EFalse) |
93 iBackupInProgress(EFalse), |
|
94 iDeltaTimerCallBack(ConnectionCloseTimerExpired, this) |
86 #ifdef CPPUNIT_TEST |
95 #ifdef CPPUNIT_TEST |
87 // Set the array granularity to 1, so they allocate memory for every append |
96 // Set the array granularity to 1, so they allocate memory for every append |
88 , iProfileCache(1), |
97 , iProfileCache(1), |
89 iObservers(1), |
98 iObservers(1), |
90 iMigrationControllers(1) |
99 iMigrationControllers(1) |
91 #endif |
100 #endif |
92 { |
101 { |
|
102 iFeatMgrInitialized = EFalse; |
|
103 iDeltaTimerEntry.Set(iDeltaTimerCallBack); |
93 } |
104 } |
94 |
105 |
95 // ----------------------------------------------------------------------------- |
106 // ----------------------------------------------------------------------------- |
96 // CSIPProfileServerCore::ConstructL |
107 // CSIPProfileServerCore::ConstructL |
97 // ----------------------------------------------------------------------------- |
108 // ----------------------------------------------------------------------------- |
98 // |
109 // |
99 void CSIPProfileServerCore::ConstructL() |
110 void CSIPProfileServerCore::ConstructL() |
100 { |
111 { |
101 User::LeaveIfError(iFs.Connect()); |
112 User::LeaveIfError(iFs.Connect()); |
|
113 |
|
114 FeatureManager::InitializeLibL(); |
|
115 iFeatMgrInitialized = ETrue; |
|
116 |
|
117 iDeltaTimer = CDeltaTimer::NewL(CActive::EPriorityStandard); |
102 |
118 |
103 iFindEntry = CSIPProfileCacheItem::NewL(*this, iUnregistered); |
119 iFindEntry = CSIPProfileCacheItem::NewL(*this, iUnregistered); |
104 |
120 |
105 iPluginDirector = CSIPPluginDirector::NewL(*this); |
121 iPluginDirector = CSIPPluginDirector::NewL(*this); |
106 |
122 |
264 "ProfileServerCore::SIPProfileStatusEventL(removed) id", |
289 "ProfileServerCore::SIPProfileStatusEventL(removed) id", |
265 aProfileId) |
290 aProfileId) |
266 } |
291 } |
267 |
292 |
268 } |
293 } |
269 if (item && item->IsRfsInprogress()) |
294 TBool eventCompleted = EFalse; |
|
295 if(item && (item->IsRfsInprogress() || iOfflineEventReceived || |
|
296 (FeatureManager::FeatureSupported( KFeatureIdFfImsDeregistrationInVpn )&& |
|
297 item->IsVpnInUse()))) |
270 { |
298 { |
271 CSIPConcreteProfile::TStatus status; |
299 CSIPConcreteProfile::TStatus status; |
272 TInt count = iProfileCache.Count(); |
300 TInt count = iProfileCache.Count(); |
273 for (TInt i = 0; i < iProfileCache.Count(); i++) |
301 for ( TInt i = 0; i < iProfileCache.Count(); i++ ) |
274 { |
302 { |
275 iPluginDirector->State(status, iProfileCache[i]->UsedProfile()); |
303 iPluginDirector->State( status, iProfileCache[i]->UsedProfile() ); |
276 if (status == CSIPConcreteProfile::EUnregistered) |
304 if ( status == CSIPConcreteProfile::EUnregistered ) |
|
305 { |
277 count--; |
306 count--; |
|
307 } |
|
308 else if (status == CSIPConcreteProfile::ERegistered ) |
|
309 { |
|
310 iProfileCache[i]->ShutdownInitiated(); |
|
311 } |
278 } |
312 } |
279 if (!count) |
313 if ( !count ) |
280 { |
314 eventCompleted = ETrue; |
281 iSystemStateMonitor->EventProcessingCompleted( |
315 } |
282 CSipSystemStateMonitor::ERfsState, 0, *this); |
316 if(eventCompleted) |
283 } |
317 { |
284 } |
318 if (item->IsRfsInprogress()) |
285 } |
319 StartConnectionCloseTimer(); |
286 |
320 else if(iOfflineEventReceived) |
287 if (iOfflineEventReceived) |
321 ConfirmSystemstateMonitor(CSipSystemStateMonitor::ESystemState); |
288 { |
322 else if((FeatureManager::FeatureSupported( KFeatureIdFfImsDeregistrationInVpn )&& |
289 CSIPConcreteProfile::TStatus status; |
323 item->IsVpnInUse())) |
290 TInt count = iProfileCache.Count(); |
324 ConfirmSystemstateMonitor(CSipSystemStateMonitor::EVpnState); |
291 for (TInt i = 0; i < iProfileCache.Count(); i++) |
325 } |
292 { |
326 } |
293 iPluginDirector->State(status, iProfileCache[i]->UsedProfile()); |
|
294 if (status == CSIPConcreteProfile::EUnregistered) |
|
295 count--; |
|
296 } |
|
297 if (!count) |
|
298 { |
|
299 iSystemStateMonitor->EventProcessingCompleted(CSipSystemStateMonitor::ESystemState, 0, *this); |
|
300 } |
|
301 } |
|
302 |
|
303 CheckServerStatus(); |
327 CheckServerStatus(); |
304 } |
328 } |
305 |
329 |
306 // ----------------------------------------------------------------------------- |
330 // ----------------------------------------------------------------------------- |
307 // CSIPProfileServerCore::SIPProfileErrorEvent |
331 // CSIPProfileServerCore::SIPProfileErrorEvent |
428 |
452 |
429 if ( aVariable == CSipSystemStateMonitor::ESystemState && |
453 if ( aVariable == CSipSystemStateMonitor::ESystemState && |
430 (aValue == CSipSystemStateMonitor::ESystemShuttingDown || |
454 (aValue == CSipSystemStateMonitor::ESystemShuttingDown || |
431 aValue == CSipSystemStateMonitor::ESystemOffline |
455 aValue == CSipSystemStateMonitor::ESystemOffline |
432 )) |
456 )) |
433 { |
457 { |
|
458 TBool waitForDeregistration = EFalse; |
434 for (TInt i = 0; i < iProfileCache.Count(); i++) |
459 for (TInt i = 0; i < iProfileCache.Count(); i++) |
435 { |
460 { |
436 iProfileCache[i]->ShutdownInitiated(); |
461 iProfileCache[i]->ShutdownInitiated(); |
437 } |
462 CSIPConcreteProfile::TStatus status; |
|
463 iPluginDirector->State(status, iProfileCache[i]->UsedProfile()); |
|
464 if(status != CSIPConcreteProfile::EUnregistered) |
|
465 waitForDeregistration = ETrue; |
|
466 } |
|
467 if(!waitForDeregistration) |
|
468 { |
|
469 ConfirmSystemstateMonitor(CSipSystemStateMonitor::ESystemState); |
|
470 } |
438 } |
471 } |
439 //If the System State is Online, register all the profiles in always on mode |
472 //If the System State is Online, register all the profiles in always on mode |
440 else if(aVariable == CSipSystemStateMonitor::ESystemState && |
473 else if(aVariable == CSipSystemStateMonitor::ESystemState && |
441 aValue == CSipSystemStateMonitor::ESystemOnline) |
474 aValue == CSipSystemStateMonitor::ESystemOnline) |
442 { |
475 { |
443 iOfflineEventReceived = EFalse; |
476 iOfflineEventReceived = EFalse; |
444 for (TInt i = 0; i < iProfileCache.Count(); i++) |
477 for (TInt i = 0; i < iProfileCache.Count(); i++) |
445 { |
478 { |
446 iProfileCache[i]->ResetShutdownvariable(); |
479 iProfileCache[i]->ResetShutdownvariable(); |
447 CSIPProfileCacheItem* item = iProfileCache[i]; |
480 CSIPProfileCacheItem* item = iProfileCache[i]; |
448 if (item->Profile().IsAutoRegistrationEnabled()) |
481 if (iProfileCache[i]->IsReferred()) |
449 { |
482 { |
450 TRAPD(err, item->StartRegisterL(*iWaitForIAP, *iRegInProg, ETrue)); |
483 TRAPD(err, item->StartRegisterL(*iWaitForIAP, *iRegInProg, ETrue)); |
451 if (err != KErrNone) |
484 if (err != KErrNone) |
452 { |
485 { |
453 HandleAsyncError(*item,CSIPConcreteProfile::ERegistrationInProgress,err); |
486 HandleAsyncError(*item,CSIPConcreteProfile::ERegistrationInProgress,err); |
490 { |
532 { |
491 iProfileCache[i]->RfsInprogress(EFalse); |
533 iProfileCache[i]->RfsInprogress(EFalse); |
492 } |
534 } |
493 } |
535 } |
494 } |
536 } |
495 } |
537 // Perform de/re-registration for VPN. |
|
538 else if( FeatureManager::FeatureSupported( KFeatureIdFfImsDeregistrationInVpn ) |
|
539 && ( aVariable == CSipSystemStateMonitor::EVpnState ) ) |
|
540 { |
|
541 // If VPN session is about to start, SIP should be deregistered. |
|
542 if( aValue == CSipSystemStateMonitor::EVpnInitiating ) |
|
543 { |
|
544 PROFILE_DEBUG1("VPN Initiated , de-registering the profiles") |
|
545 TBool waitForDeregistration = EFalse; |
|
546 for (TInt i = 0; i < iProfileCache.Count(); i++) |
|
547 { |
|
548 iProfileCache[i]->VpnInUse( ETrue ); |
|
549 iProfileCache[i]->ShutdownInitiated(); |
|
550 CSIPConcreteProfile::TStatus status; |
|
551 iPluginDirector->State(status, iProfileCache[i]->UsedProfile()); |
|
552 if (status != CSIPConcreteProfile::EUnregistered) |
|
553 waitForDeregistration = ETrue; |
|
554 } |
|
555 if (!waitForDeregistration) |
|
556 { |
|
557 ConfirmSystemstateMonitor(CSipSystemStateMonitor::EVpnState); |
|
558 } |
|
559 } |
|
560 // If VPN session ended, SIP should be re-registered. |
|
561 else if( aValue == CSipSystemStateMonitor::EVpnTerminated ) |
|
562 { |
|
563 PROFILE_DEBUG1("VPN Terminated , re-registering the profiles") |
|
564 for (TInt i = 0; i < iProfileCache.Count(); i++) |
|
565 { |
|
566 iProfileCache[i]->VpnInUse(EFalse); |
|
567 if ( iProfileCache[i]->IsReferred() ) |
|
568 { |
|
569 TRAPD(err, iProfileCache[i]->StartRegisterL(*iWaitForIAP, *iRegInProg, ETrue)); |
|
570 if (err != KErrNone) |
|
571 { |
|
572 HandleAsyncError( *iProfileCache[i], |
|
573 CSIPConcreteProfile::ERegistrationInProgress, |
|
574 err); |
|
575 } |
|
576 } |
|
577 } |
|
578 } |
|
579 } |
|
580 } |
496 |
581 |
497 // ----------------------------------------------------------------------------- |
582 // ----------------------------------------------------------------------------- |
498 // CSIPProfileServerCore::SessionRegisterL |
583 // CSIPProfileServerCore::SessionRegisterL |
499 // ----------------------------------------------------------------------------- |
584 // ----------------------------------------------------------------------------- |
500 // |
585 // |
898 // |
988 // |
899 void CSIPProfileServerCore::UpdateRegistrationL(TUint32 aProfileId, |
989 void CSIPProfileServerCore::UpdateRegistrationL(TUint32 aProfileId, |
900 const MSIPExtendedConcreteProfileObserver& aObserver) |
990 const MSIPExtendedConcreteProfileObserver& aObserver) |
901 { |
991 { |
902 CSIPProfileCacheItem* item = ProfileCacheItemL(aProfileId); |
992 CSIPProfileCacheItem* item = ProfileCacheItemL(aProfileId); |
|
993 TInt err(KErrNone); |
903 CSIPConcreteProfile::TStatus |
994 CSIPConcreteProfile::TStatus |
904 status(CSIPConcreteProfile::ERegistrationInProgress); |
995 status(CSIPConcreteProfile::ERegistrationInProgress); |
|
996 |
905 if (item->Profile().Status() == CSIPConcreteProfile::ERegistered) |
997 if (item->Profile().Status() == CSIPConcreteProfile::ERegistered) |
906 { |
998 { |
907 status = CSIPConcreteProfile::EUnregistrationInProgress; |
999 status = CSIPConcreteProfile::EUnregistrationInProgress; |
908 } |
1000 } |
909 |
1001 if(FeatureManager::FeatureSupported( KFeatureIdFfSipApnSwitching)) |
910 TRAPD(err, item->UpdateRegistrationL(aObserver)); |
1002 { |
|
1003 if(item->LatestProfile().IapId()!= item->UsedProfile().IapId()) |
|
1004 { |
|
1005 item->SetApnSelected(EFalse); |
|
1006 } |
|
1007 |
|
1008 item->SetApnSwitchStatus(EFalse); |
|
1009 if(CheckApnSwitchEnabledL(item->LatestProfile())) |
|
1010 { |
|
1011 const TDesC8* primaryApn( NULL ); |
|
1012 const TDesC8* secondaryApn( NULL ); |
|
1013 const TDesC8* latestprimaryApn( NULL ); |
|
1014 const TDesC8* latestsecondaryApn( NULL ); |
|
1015 |
|
1016 TInt err1 = item->LatestProfile().ExtensionParameter(KPrimaryAPN,latestprimaryApn); |
|
1017 TInt err2 = item->UsedProfile().ExtensionParameter(KPrimaryAPN,primaryApn); |
|
1018 |
|
1019 TInt err3 = item->LatestProfile().ExtensionParameter(KSecondaryAPN,latestsecondaryApn); |
|
1020 TInt err4 = item->UsedProfile().ExtensionParameter(KSecondaryAPN,secondaryApn); |
|
1021 if((err1 == KErrNone && err2 == KErrNone && latestprimaryApn->Compare(*primaryApn)!= 0)|| |
|
1022 (err3 == KErrNone && err4 == KErrNone && |
|
1023 latestsecondaryApn->Compare(*secondaryApn)!= 0)) |
|
1024 { |
|
1025 item->SetApnSelected(EFalse); |
|
1026 } |
|
1027 } |
|
1028 } |
|
1029 |
|
1030 |
|
1031 if(FeatureManager::FeatureSupported( KFeatureIdFfSipApnSwitching) |
|
1032 && item->IsApnSwitchEnabled()) |
|
1033 { |
|
1034 PROFILE_DEBUG1("CSIPProfileServerCore::UpdateRegistrationL, SwichEnabled") |
|
1035 if(CheckIapSettings( item->LatestProfile().Id())) |
|
1036 { |
|
1037 PROFILE_DEBUG1("CSIPProfileServerCore::UpdateRegistrationL, Settings are correct") |
|
1038 if(IsRegistrationAllowedWithCurrentApnSettings(item->LatestProfile().IapId())) |
|
1039 { |
|
1040 PROFILE_DEBUG1("CSIPProfileServerCore::UpdateRegistrationL, Registration is allowed") |
|
1041 TRAP(err, item->UpdateRegistrationL(aObserver)); |
|
1042 } |
|
1043 else |
|
1044 { |
|
1045 PROFILE_DEBUG1("CSIPProfileServerCore::UpdateRegistrationL, Appending into Array") |
|
1046 TStoreSwitchEnabledProfile updateProfile; |
|
1047 updateProfile.iObserver = &aObserver; |
|
1048 updateProfile.iProfile = &item->LatestProfile(); |
|
1049 updateProfile.operation = TStoreSwitchEnabledProfile::Update; |
|
1050 iWaitForApnSettings.AppendL(updateProfile); |
|
1051 } |
|
1052 } |
|
1053 else |
|
1054 User::LeaveIfError(KErrNotSupported); |
|
1055 } |
|
1056 else |
|
1057 { |
|
1058 TRAP(err, item->UpdateRegistrationL(aObserver)); |
|
1059 } |
911 if (err != KErrNone) |
1060 if (err != KErrNone) |
912 { |
1061 { |
913 HandleAsyncError(*item, status, err); |
1062 HandleAsyncError(*item, status, err); |
914 } |
1063 } |
915 } |
1064 } |
982 // |
1166 // |
983 void CSIPProfileServerCore::RegisterProfiles() |
1167 void CSIPProfileServerCore::RegisterProfiles() |
984 { |
1168 { |
985 for (TInt i = 0; i < iProfileCache.Count(); i++) |
1169 for (TInt i = 0; i < iProfileCache.Count(); i++) |
986 { |
1170 { |
|
1171 TInt err(KErrNone); |
987 CSIPProfileCacheItem* item = iProfileCache[i]; |
1172 CSIPProfileCacheItem* item = iProfileCache[i]; |
988 if (item->Profile().IsAutoRegistrationEnabled()) |
1173 if (item->Profile().IsAutoRegistrationEnabled()) |
989 { |
1174 { |
990 TRAPD(err, item->StartRegisterL(*iWaitForIAP, *iRegInProg, ETrue)); |
1175 TBool enabled(EFalse); |
|
1176 TRAPD(error, enabled = CheckApnSwitchEnabledL(item->Profile())) |
|
1177 if(FeatureManager::FeatureSupported( KFeatureIdFfSipApnSwitching ) |
|
1178 &&enabled && !error) |
|
1179 { |
|
1180 PROFILE_DEBUG1("CSIPProfileServerCore::RegisterProfiles, SwichEnabled") |
|
1181 if(CheckIapSettings( item->Profile().Id())) |
|
1182 { |
|
1183 PROFILE_DEBUG1("CSIPProfileServerCore::RegisterProfiles, Settings are correct") |
|
1184 if(IsRegistrationAllowedWithCurrentApnSettings(item->Profile().IapId())) |
|
1185 { |
|
1186 PROFILE_DEBUG1("CSIPProfileServerCore::RegisterProfiles, Registration is allowed") |
|
1187 TRAP(err, item->StartRegisterL(*iWaitForIAP, *iRegInProg, ETrue)); |
|
1188 } |
|
1189 else |
|
1190 { |
|
1191 PROFILE_DEBUG1("CSIPProfileServerCore::RegisterProfiles, Appending into Array") |
|
1192 TStoreSwitchEnabledProfile registerProfile; |
|
1193 registerProfile.iProfile = &item->Profile(); |
|
1194 registerProfile.iObserver = NULL; |
|
1195 registerProfile.operation = TStoreSwitchEnabledProfile::Register; |
|
1196 TRAP_IGNORE(iWaitForApnSettings.AppendL(registerProfile)) |
|
1197 } |
|
1198 } |
|
1199 } |
|
1200 else |
|
1201 { |
|
1202 TRAP(err, item->StartRegisterL(*iWaitForIAP, *iRegInProg, ETrue)); |
|
1203 } |
|
1204 |
991 if (err != KErrNone) |
1205 if (err != KErrNone) |
992 { |
1206 { |
993 HandleAsyncError(*item, |
1207 HandleAsyncError(*item, |
994 CSIPConcreteProfile::ERegistrationInProgress, |
1208 CSIPConcreteProfile::ERegistrationInProgress, |
995 err); |
1209 err); |
1769 // ----------------------------------------------------------------------------- |
1994 // ----------------------------------------------------------------------------- |
1770 // |
1995 // |
1771 TBool CSIPProfileServerCore::ShouldChangeIap(CSIPConcreteProfile& aProfile, TInt aError) const |
1996 TBool CSIPProfileServerCore::ShouldChangeIap(CSIPConcreteProfile& aProfile, TInt aError) const |
1772 { |
1997 { |
1773 PROFILE_DEBUG3("CSIPProfileServerCore::ShouldChangeIap, error", aError) |
1998 PROFILE_DEBUG3("CSIPProfileServerCore::ShouldChangeIap, error", aError) |
1774 TUint32 dummySnapId(0); |
1999 TUint32 snapId(0); |
1775 if ( aProfile.ExtensionParameter(KSIPSnapId, dummySnapId) == KErrNone && |
2000 if ( aProfile.ExtensionParameter(KSIPSnapId, snapId) == KErrNone |
1776 !AnyRegisteredProfileUsesIap(aProfile.IapId()) ) |
2001 && !AnyRegisteredProfileUsesIap(aProfile.IapId()) ) |
1777 { |
2002 { |
1778 PROFILE_DEBUG1("CSIPProfileServerCore::ShouldChangeIap, snap is in use") |
2003 PROFILE_DEBUG1("CSIPProfileServerCore::ShouldChangeIap, snap is in use") |
1779 |
2004 |
1780 // This profile uses a SNAP. |
2005 // This profile uses a SNAP. |
1781 // There are no registered profiles using the same IAP as this profile. |
2006 // There are no registered profiles using the same IAP as this profile. |
1782 |
2007 |
1783 if ( aError == KErrTimedOut || |
2008 TUint iapCount(0); |
1784 aError == KErrSIPResolvingFailure ) |
2009 TRAPD(err, iapCount = IAPCountL(snapId)); |
1785 { |
2010 if(KErrNone == err) |
1786 PROFILE_DEBUG1("CSIPProfileServerCore::ShouldChangeIap returns True") |
2011 { |
1787 return ETrue; |
2012 if ( (aError == KErrTimedOut || |
1788 } |
2013 aError == KErrSIPResolvingFailure) |
1789 } |
2014 && iapCount > 1) |
|
2015 { |
|
2016 PROFILE_DEBUG1("CSIPProfileServerCore::ShouldChangeIap returns True") |
|
2017 return ETrue; |
|
2018 } |
|
2019 } |
|
2020 |
|
2021 } |
1790 PROFILE_DEBUG1("CSIPProfileServerCore::ShouldChangeIap returns false") |
2022 PROFILE_DEBUG1("CSIPProfileServerCore::ShouldChangeIap returns false") |
1791 return EFalse; |
2023 return EFalse; |
1792 } |
2024 } |
1793 |
2025 |
|
2026 // ----------------------------------------------------------------------------- |
|
2027 // CSIPProfileServerCore::AnyRegisteredProfileUsesIap |
|
2028 // ----------------------------------------------------------------------------- |
|
2029 // |
1794 TBool CSIPProfileServerCore::AnyRegisteredProfileUsesIap(TUint aIap) const |
2030 TBool CSIPProfileServerCore::AnyRegisteredProfileUsesIap(TUint aIap) const |
1795 { |
2031 { |
1796 |
2032 |
1797 for ( TInt i = 0; i < iProfileCache.Count(); i++ ) |
2033 for ( TInt i = 0; i < iProfileCache.Count(); i++ ) |
1798 { |
2034 { |
1837 { |
2073 { |
1838 TRAP_IGNORE(obs[i]->RegistrationStatusChangedL(aItem.ProfileId(), |
2074 TRAP_IGNORE(obs[i]->RegistrationStatusChangedL(aItem.ProfileId(), |
1839 aItem.Profile().Status(), ESipProfileItcOpProfileForciblyDisabled)); |
2075 aItem.Profile().Status(), ESipProfileItcOpProfileForciblyDisabled)); |
1840 } |
2076 } |
1841 } |
2077 } |
|
2078 |
|
2079 |
|
2080 // ----------------------------------------------------------------------------- |
|
2081 // CSIPProfileServerCore::IAPCount |
|
2082 // ----------------------------------------------------------------------------- |
|
2083 // |
|
2084 TInt CSIPProfileServerCore::IAPCountL(TUint32 aSnapId) const |
|
2085 { |
|
2086 const TUint KRecordId = aSnapId; |
|
2087 TUint32 count(0); |
|
2088 CMDBSession* db = CMDBSession::NewLC( KCDVersion1_2); |
|
2089 db->SetAttributeMask( ECDHidden ); |
|
2090 |
|
2091 //Load the Selection Policy record |
|
2092 CCDIAPPrioritySelectionPolicyRecord *selPolRecord = (CCDIAPPrioritySelectionPolicyRecord *)CCDRecordBase::RecordFactoryL(KCDTIdIapPrioritySelectionPolicyRecord); |
|
2093 |
|
2094 CleanupStack::PushL(selPolRecord); |
|
2095 selPolRecord->SetRecordId(KRecordId); |
|
2096 |
|
2097 selPolRecord->LoadL( *db ); |
|
2098 count = selPolRecord->iIapCount; |
|
2099 PROFILE_DEBUG3("CSIPProfileServerCore::IAPCount, IAP Count", count) |
|
2100 |
|
2101 CleanupStack::PopAndDestroy(selPolRecord); |
|
2102 CleanupStack::PopAndDestroy( db ); |
|
2103 return count; |
|
2104 } |
|
2105 |
|
2106 // ----------------------------------------------------------------------------- |
|
2107 // CSIPProfileServerCore::StartConnectionCloseTimer |
|
2108 // ----------------------------------------------------------------------------- |
|
2109 // |
|
2110 void CSIPProfileServerCore::StartConnectionCloseTimer() |
|
2111 { |
|
2112 PROFILE_DEBUG1("CSIPProfileServerCore::StartConnectionCloseTimer") |
|
2113 iDeltaTimer->Remove(iDeltaTimerEntry); |
|
2114 TTimeIntervalMicroSeconds32 interval(KMicroSecInSec * KIdleTimer); |
|
2115 iDeltaTimer->Queue(interval, iDeltaTimerEntry); |
|
2116 } |
|
2117 |
|
2118 // ----------------------------------------------------------------------------- |
|
2119 // CSIPProfileServerCore::ConnectionCloseTimerExpired |
|
2120 // ----------------------------------------------------------------------------- |
|
2121 // |
|
2122 TInt CSIPProfileServerCore::ConnectionCloseTimerExpired(TAny* aPtr) |
|
2123 { |
|
2124 PROFILE_DEBUG1("CSIPProfileServerCore::ConnectionCloseTimerExpired") |
|
2125 CSIPProfileServerCore* self = reinterpret_cast<CSIPProfileServerCore*>(aPtr); |
|
2126 self->ConfirmSystemstateMonitor(CSipSystemStateMonitor::ERfsState); |
|
2127 return ETrue; |
|
2128 } |
|
2129 |
|
2130 // ----------------------------------------------------------------------------- |
|
2131 // CSIPProfileServerCore::ConfirmSystemstateMonitor |
|
2132 // ----------------------------------------------------------------------------- |
|
2133 // |
|
2134 void CSIPProfileServerCore::ConfirmSystemstateMonitor( |
|
2135 CSipSystemStateMonitor::TSystemVariable aVariable) |
|
2136 { |
|
2137 iSystemStateMonitor->EventProcessingCompleted( |
|
2138 aVariable, 0, *this); |
|
2139 } |
|
2140 |
|
2141 // ---------------------------------------------------------------------------- |
|
2142 //CSIPProfileServerCore::ApnChanged |
|
2143 // ---------------------------------------------------------------------------- |
|
2144 void CSIPProfileServerCore::ApnChanged( const TDesC8& /*aApn*/, TUint32 aIapId, TInt aError ) |
|
2145 { |
|
2146 PROFILE_DEBUG3( "CSIPProfileServerCore::ApnChanged, err:", aError ) |
|
2147 // Check if there is any profile waiting for correct Apn settings for IapId aIapId |
|
2148 |
|
2149 if ( IsRegistrationAllowedWithCurrentApnSettings( aIapId ) || aError != KErrNone ) |
|
2150 { |
|
2151 PROFILE_DEBUG1("CSIPProfileServerCore::ApnChanged, settings are correct") |
|
2152 CSIPConcreteProfile* profile = NULL; |
|
2153 TInt count = iWaitForApnSettings.Count(); |
|
2154 for (TInt i =0; i < count; i++) |
|
2155 { |
|
2156 TStoreSwitchEnabledProfile switchEnabledProfile = iWaitForApnSettings[i]; |
|
2157 if(switchEnabledProfile.iProfile->IapId()==aIapId) |
|
2158 { |
|
2159 profile = switchEnabledProfile.iProfile; |
|
2160 iWaitForApnSettings.Remove(i); |
|
2161 iWaitForApnSettings.Compress(); |
|
2162 i--; |
|
2163 count = iWaitForApnSettings.Count(); |
|
2164 PROFILE_DEBUG1("CSIPProfileServerCore::ApnChanged, Profile IapId matches") |
|
2165 |
|
2166 TInt err( aError ); |
|
2167 TInt error(KErrNone); |
|
2168 PROFILE_DEBUG3("CSIPProfileServerCore::ApnChanged, Profile Id", profile->Id()) |
|
2169 CSIPProfileCacheItem* item = ProfileCacheItem(profile->Id()); |
|
2170 TBool isVpnInUse = (FeatureManager::FeatureSupported( KFeatureIdFfImsDeregistrationInVpn ) |
|
2171 && item->IsVpnInUse()); |
|
2172 if ( err == KErrNone && CheckIapSettings(profile->Id())) |
|
2173 { |
|
2174 if(switchEnabledProfile.operation == TStoreSwitchEnabledProfile::Update) |
|
2175 { |
|
2176 TRAP(error, item->UpdateRegistrationL(*(switchEnabledProfile.iObserver))); |
|
2177 } |
|
2178 else if(switchEnabledProfile.operation == TStoreSwitchEnabledProfile::Enable && !item->IsRfsInprogress() && !isVpnInUse) |
|
2179 { |
|
2180 TRAP(error, iAlrHandler->EnableProfileL(*item, *(switchEnabledProfile.iObserver))); |
|
2181 } |
|
2182 else if(switchEnabledProfile.operation == TStoreSwitchEnabledProfile::Register) |
|
2183 { |
|
2184 TRAP(error, item->StartRegisterL(*iWaitForIAP, *iRegInProg, ETrue)); |
|
2185 } |
|
2186 } |
|
2187 if ( err != KErrNone || error) |
|
2188 { |
|
2189 PROFILE_DEBUG1("CSIPProfileServerCore::ApnChanged, error handling") |
|
2190 HandleAsyncError(*item, profile->Status(), err); |
|
2191 } |
|
2192 } |
|
2193 } |
|
2194 } |
|
2195 PROFILE_DEBUG1("CSIPProfileServerCore::ApnChanged, exit") |
|
2196 } |
|
2197 |
|
2198 // ----------------------------------------------------------------------------- |
|
2199 // CSIPProfileServerCore::IsRegistrationAllowedWithCurrentApnSettings |
|
2200 // ----------------------------------------------------------------------------- |
|
2201 // |
|
2202 TBool CSIPProfileServerCore::IsRegistrationAllowedWithCurrentApnSettings( TUint32 aIapId ) |
|
2203 { |
|
2204 return ( iApnManager && iApnManager->IsPrimaryApnInUse( aIapId ) ); |
|
2205 } |
|
2206 |
|
2207 // ----------------------------------------------------------------------------- |
|
2208 // CSIPProfileServerCore::SelectInitialApnL |
|
2209 // ----------------------------------------------------------------------------- |
|
2210 // |
|
2211 void CSIPProfileServerCore::SelectInitialApnL( const CSIPConcreteProfile& aProfile ) |
|
2212 { |
|
2213 PROFILE_DEBUG1("CSIPProfileServerCore::SelectInitialApnL" ) |
|
2214 CSIPProfileCacheItem* item = ProfileCacheItem(aProfile.Id()); |
|
2215 |
|
2216 if ( item && !item->IsInitialApnSelected()) |
|
2217 { |
|
2218 // If profile has stored APNs, use them |
|
2219 const TDesC8* primaryApn( NULL ); |
|
2220 if ( aProfile.ExtensionParameter( KPrimaryAPN, primaryApn ) == KErrNone ) |
|
2221 { |
|
2222 PROFILE_DEBUG1("UpdateApnL ETrue" ) |
|
2223 iApnManager->UpdateApnL( aProfile.IapId(), ETrue, *primaryApn ); |
|
2224 } |
|
2225 const TDesC8* secondaryApn( NULL ); |
|
2226 if ( aProfile.ExtensionParameter( KSecondaryAPN, secondaryApn ) == KErrNone ) |
|
2227 { |
|
2228 PROFILE_DEBUG1("UpdateApnL EFalse" ) |
|
2229 iApnManager->UpdateApnL( aProfile.IapId(), EFalse, *secondaryApn ); |
|
2230 } |
|
2231 |
|
2232 PROFILE_DEBUG1("SelectInitialApnL - WriteApnL, Primary APN" ) |
|
2233 iApnManager->WriteApnL( aProfile.IapId(), ETrue, primaryApn); |
|
2234 item->SetApnSelected(ETrue); |
|
2235 } |
|
2236 } |
|
2237 |
|
2238 // ----------------------------------------------------------------------------- |
|
2239 // CSIPProfileServerCore::CheckApnSwitchEnabledL |
|
2240 // ----------------------------------------------------------------------------- |
|
2241 // |
|
2242 TBool CSIPProfileServerCore::CheckApnSwitchEnabledL( const CSIPConcreteProfile& aProfile ) |
|
2243 { |
|
2244 PROFILE_DEBUG1("CSIPProfileServerCore::CheckApnSwitchEnabledL" ) |
|
2245 TUint32 profileId = aProfile.Id(); |
|
2246 |
|
2247 PROFILE_DEBUG3("CSIPProfileServerCore::CheckApnSwitchEnabledL, IapId", profileId ) |
|
2248 |
|
2249 CSIPProfileCacheItem* item = ProfileCacheItem(profileId); |
|
2250 TUint32 snapId; |
|
2251 if(item && !item->IsSNAPConfigured( snapId )&& !item->IsApnSwitchEnabled()) |
|
2252 { |
|
2253 // If profile has stored APNs, use them |
|
2254 const TDesC8* primaryApn( NULL ); |
|
2255 const TDesC8* secondaryApn( NULL ); |
|
2256 TInt err = aProfile.ExtensionParameter( KPrimaryAPN, primaryApn ); |
|
2257 TInt error = aProfile.ExtensionParameter( KSecondaryAPN, secondaryApn ); |
|
2258 |
|
2259 if(err == KErrNone && error == KErrNone && primaryApn && secondaryApn) |
|
2260 { |
|
2261 TBool isIapGPRS = iApnManager->IsIapGPRSL( aProfile.IapId() ); |
|
2262 if (isIapGPRS) |
|
2263 item->SetApnSwitchStatus(ETrue); // Set Switch APN Enabled |
|
2264 } |
|
2265 } |
|
2266 PROFILE_DEBUG3("CSIPProfileServerCore::CheckApnSwitchEnabledL returns" |
|
2267 ,item->IsApnSwitchEnabled()) |
|
2268 return item->IsApnSwitchEnabled(); |
|
2269 } |
|
2270 |
|
2271 // ----------------------------------------------------------------------------- |
|
2272 // CSIPProfileServerCore::CheckIapSettings |
|
2273 // ----------------------------------------------------------------------------- |
|
2274 // |
|
2275 TBool CSIPProfileServerCore::CheckIapSettings(TUint32 aProfileId) |
|
2276 { |
|
2277 PROFILE_DEBUG1("CSIPProfileServerCore::CheckIapSettings") |
|
2278 |
|
2279 const CSIPConcreteProfile* profile = Profile( aProfileId ); |
|
2280 CSIPProfileCacheItem* item = ProfileCacheItem( aProfileId ); |
|
2281 TInt err(KErrNone); |
|
2282 if(profile && item) |
|
2283 { |
|
2284 if(!iApnManager->IsFailed(profile->IapId())) |
|
2285 { |
|
2286 TRAP(err, SelectInitialApnL( *profile )); |
|
2287 UsePrimaryApn(profile->IapId()); |
|
2288 PROFILE_DEBUG1("CSIPProfileServerCore::CheckIapSettings returns ETrue") |
|
2289 return ETrue; |
|
2290 } |
|
2291 else |
|
2292 if(err || iApnManager->IsFailed(profile->IapId()) ) |
|
2293 { |
|
2294 PROFILE_DEBUG1("CSIPProfileServerCore::CheckIapSettings returns EFalse") |
|
2295 |
|
2296 item->SetApnSelected(ETrue); |
|
2297 return EFalse; |
|
2298 } |
|
2299 } |
|
2300 PROFILE_DEBUG1("CSIPProfileServerCore::CheckIapSettings, profile or item is NULL") |
|
2301 return EFalse; |
|
2302 } |
|
2303 |
|
2304 // ---------------------------------------------------------------------------- |
|
2305 // CSIPProfileServerCore::UsePrimaryApn |
|
2306 // ---------------------------------------------------------------------------- |
|
2307 // |
|
2308 void CSIPProfileServerCore::UsePrimaryApn(TUint32 aIapId) |
|
2309 { |
|
2310 PROFILE_DEBUG1("CSIPProfileServerCore::UsePrimaryApn") |
|
2311 |
|
2312 if (!iApnManager->IsPrimaryApnInUse( aIapId )) |
|
2313 { |
|
2314 iApnManager->SetFailed( aIapId, EFalse, EFalse ); |
|
2315 } |
|
2316 |
|
2317 PROFILE_DEBUG1("CSIPProfileServerCore::UsePrimaryApn, exit") |
|
2318 } |
|
2319 |
|
2320 // ---------------------------------------------------------------------------- |
|
2321 // CSIPProfileServerCore::UseBackupApn |
|
2322 // ---------------------------------------------------------------------------- |
|
2323 // |
|
2324 void CSIPProfileServerCore::UseBackupApn( TUint32 aIapId, TBool aFatalFailure ) |
|
2325 { |
|
2326 PROFILE_DEBUG1("CSIPProfileServerCore::UseBackupApn") |
|
2327 |
|
2328 if ( iApnManager->IsFailed( aIapId ) || aFatalFailure ) |
|
2329 { |
|
2330 iApnManager->SetFailed( aIapId, ETrue, aFatalFailure ); |
|
2331 } |
|
2332 |
|
2333 PROFILE_DEBUG1("CSIPIMSProfileAgent::UseBackupApn, exit") |
|
2334 } |
|
2335 |
|
2336 // ---------------------------------------------------------------------------- |
|
2337 // CSIPProfileServerCore::IsUpdateAllowed |
|
2338 // ---------------------------------------------------------------------------- |
|
2339 // |
|
2340 TBool CSIPProfileServerCore::IsUpdateAllowed( CSIPConcreteProfile *aProfile ) |
|
2341 { |
|
2342 PROFILE_DEBUG1("CSIPIMSProfileAgent::IsUpdateAllowed, enter") |
|
2343 return !(iApnManager->IsFailed(aProfile->IapId())); |
|
2344 } |