--- a/realtimenetprots/sipfw/ProfileAgent/Server/Src/SipProfileServerCore.cpp Tue May 11 16:32:45 2010 +0300
+++ b/realtimenetprots/sipfw/ProfileAgent/Server/Src/SipProfileServerCore.cpp Tue May 25 13:04:58 2010 +0300
@@ -57,6 +57,7 @@
const TInt KMicroSecInSec = 1000000;
const TInt KIdleTimer = 2;
+const TInt KOfflineTimer = 5;
// ============================ MEMBER FUNCTIONS ===============================
@@ -171,8 +172,6 @@
iNotify = CSIPProfileStorageSecureBackup::NewL(this);
iServer = CSIPProfileCSServer::NewL(*this);
-
- iOfflineEventReceived = EFalse;
PROFILE_DEBUG1("ProfileServer started")
}
@@ -291,8 +290,11 @@
}
}
+
+ //For Profiles which were in RegInProgress and has moved to Registered State,
+ //needs to be deregistered if Offline or RFs or Vpn if in Use has been triggered.
TBool eventCompleted = EFalse;
- if(item && (item->IsRfsInprogress() || iOfflineEventReceived ||
+ if(item && (item->IsRfsInprogress() || item->IsOfflineInitiated() ||
(FeatureManager::FeatureSupported( KFeatureIdFfImsDeregistrationInVpn )&&
item->IsVpnInUse())))
{
@@ -305,19 +307,30 @@
{
count--;
}
- else if (status == CSIPConcreteProfile::ERegistered )
+ else if (status == CSIPConcreteProfile::ERegistered)
{
- iProfileCache[i]->ShutdownInitiated();
- }
- }
+ if(item->IsOfflineInitiated())
+ {
+ //Don't do anything. If the ProfileStatusEvent = Registered in Offline, it
+ //will only be for WLAN so don't deregister it. If ProfileStatusEvent = Deregistered
+ //means application triggered deregistration so ProfileAgent should not attempt registering it.
+ }
+ else
+ {
+ iProfileCache[i]->ShutdownInitiated();
+ }
+ } //end if unregistered
if ( !count )
eventCompleted = ETrue;
- }
+ } //end for
+ } //end outer if
+
+
if(eventCompleted)
{
if (item->IsRfsInprogress())
- StartConnectionCloseTimer();
- else if(iOfflineEventReceived)
+ StartConnectionCloseTimer(KIdleTimer);
+ else if(item->IsOfflineInitiated() )
ConfirmSystemstateMonitor(CSipSystemStateMonitor::ESystemState);
else if((FeatureManager::FeatureSupported( KFeatureIdFfImsDeregistrationInVpn )&&
item->IsVpnInUse()))
@@ -444,50 +457,56 @@
{
PROFILE_DEBUG3("CSIPProfileServerCore::SystemVariableUpdated System State changed to value", aValue)
- //If the SystemState is Offline, turn the boolean variable to true so that Profile-Server
- //can indicate System State monitor that event processing is completed, provided all the
- //profiles have got deregistered
- if (CSipSystemStateMonitor::ESystemOffline == aValue)
- iOfflineEventReceived = ETrue;
-
- if ( aVariable == CSipSystemStateMonitor::ESystemState &&
- (aValue == CSipSystemStateMonitor::ESystemShuttingDown ||
- aValue == CSipSystemStateMonitor::ESystemOffline
- ))
+ if ( aVariable == CSipSystemStateMonitor::ESystemState )
{
- TBool waitForDeregistration = EFalse;
- for (TInt i = 0; i < iProfileCache.Count(); i++)
- {
- iProfileCache[i]->ShutdownInitiated();
- CSIPConcreteProfile::TStatus status;
- iPluginDirector->State(status, iProfileCache[i]->UsedProfile());
- if(status != CSIPConcreteProfile::EUnregistered)
- waitForDeregistration = ETrue;
- }
- if(!waitForDeregistration)
- {
- ConfirmSystemstateMonitor(CSipSystemStateMonitor::ESystemState);
- }
- }
- //If the System State is Online, register all the profiles in always on mode
- else if(aVariable == CSipSystemStateMonitor::ESystemState &&
- aValue == CSipSystemStateMonitor::ESystemOnline)
- {
- iOfflineEventReceived = EFalse;
- for (TInt i = 0; i < iProfileCache.Count(); i++)
- {
- iProfileCache[i]->ResetShutdownvariable();
- CSIPProfileCacheItem* item = iProfileCache[i];
- if (iProfileCache[i]->IsReferred())
- {
- TRAPD(err, item->StartRegisterL(*iWaitForIAP, *iRegInProg, ETrue));
- if (err != KErrNone)
- {
- HandleAsyncError(*item,CSIPConcreteProfile::ERegistrationInProgress,err);
- }
- }
- }
- }
+ // If the System is Shutting down
+ if(aValue == CSipSystemStateMonitor::ESystemShuttingDown)
+ {
+ for (TInt i = 0; i < iProfileCache.Count(); i++)
+ {
+ iProfileCache[i]->ShutdownInitiated();
+ }
+ } //end if Shutdown
+
+ //If the System receives Offline event
+ if(aValue == CSipSystemStateMonitor::ESystemOffline)
+ {
+ StartConnectionCloseTimer(KOfflineTimer);
+ TBool waitForDeregistration = EFalse;
+ for (TInt i = 0; i < iProfileCache.Count(); i++)
+ {
+ iProfileCache[i]->OfflineInitiated(ETrue);
+ CSIPConcreteProfile::TStatus status;
+ iPluginDirector->State(status, iProfileCache[i]->UsedProfile());
+ if(status != CSIPConcreteProfile::EUnregistered)
+ waitForDeregistration = ETrue;
+ }
+ if(!waitForDeregistration)
+ {
+ ConfirmSystemstateMonitor(CSipSystemStateMonitor::ESystemState);
+ }
+ } //end if Offline
+
+ //If the System receives Online event
+ if(aValue == CSipSystemStateMonitor::ESystemOnline)
+ {
+ for (TInt i = 0; i < iProfileCache.Count(); i++)
+ {
+ CSIPProfileCacheItem* item = iProfileCache[i];
+ item->OfflineInitiated(EFalse);
+ CSIPConcreteProfile::TStatus status;
+ iPluginDirector->State(status, item->UsedProfile());
+ if (item->IsReferred() && status == CSIPConcreteProfile::EUnregistered)
+ {
+ TRAPD(err, item->StartRegisterL(*iWaitForIAP, *iRegInProg, ETrue));
+ if (err != KErrNone)
+ {
+ HandleAsyncError(*item,CSIPConcreteProfile::ERegistrationInProgress,err);
+ }
+ }
+ }
+ } //end if Online
+ } //end if SystemState
else if(aVariable == CSipSystemStateMonitor::ERfsState)
{
if(aValue == CSipSystemStateMonitor::ERfsStarted)
@@ -2136,11 +2155,11 @@
// CSIPProfileServerCore::StartConnectionCloseTimer
// -----------------------------------------------------------------------------
//
-void CSIPProfileServerCore::StartConnectionCloseTimer()
+void CSIPProfileServerCore::StartConnectionCloseTimer(TInt aValue)
{
PROFILE_DEBUG1("CSIPProfileServerCore::StartConnectionCloseTimer")
iDeltaTimer->Remove(iDeltaTimerEntry);
- TTimeIntervalMicroSeconds32 interval(KMicroSecInSec * KIdleTimer);
+ TTimeIntervalMicroSeconds32 interval(KMicroSecInSec * aValue);
iDeltaTimer->Queue(interval, iDeltaTimerEntry);
}
@@ -2152,7 +2171,33 @@
{
PROFILE_DEBUG1("CSIPProfileServerCore::ConnectionCloseTimerExpired")
CSIPProfileServerCore* self = reinterpret_cast<CSIPProfileServerCore*>(aPtr);
- self->ConfirmSystemstateMonitor(CSipSystemStateMonitor::ERfsState);
+
+ TBool IsOffline = self->iProfileCache[0]->IsOfflineInitiated();
+ if(IsOffline)
+ {
+ self->ConfirmSystemstateMonitor(CSipSystemStateMonitor::ESystemState);
+ for (TInt i = 0; i < self->iProfileCache.Count(); i++)
+ {
+ CSIPProfileCacheItem* item = self->iProfileCache[i];
+ CSIPConcreteProfile::TStatus status;
+ self->iPluginDirector->State( status, self->iProfileCache[i]->UsedProfile() );
+ item->OfflineInitiated(EFalse);
+ if (item->IsReferred() && (!self->iApnManager->IsIapGPRSL(item->Profile().IapId()))
+ && status == CSIPConcreteProfile::EUnregistered)
+ {
+ TRAPD(err, item->StartRegisterL(*(self->iWaitForIAP), *(self->iRegInProg), ETrue));
+ if (err != KErrNone)
+ {
+ self->HandleAsyncError(*item,CSIPConcreteProfile::ERegistrationInProgress,err);
+ }
+ }
+ else
+ {}
+ } //end for
+ }//end Outer If
+ else
+ self->ConfirmSystemstateMonitor(CSipSystemStateMonitor::ERfsState);
+
return ETrue;
}
@@ -2162,9 +2207,8 @@
//
void CSIPProfileServerCore::ConfirmSystemstateMonitor(
CSipSystemStateMonitor::TSystemVariable aVariable)
- {
- iSystemStateMonitor->EventProcessingCompleted(
- aVariable, 0, *this);
+ {
+ iSystemStateMonitor->EventProcessingCompleted(aVariable, 0, *this);
}
// ----------------------------------------------------------------------------