bearermanagement/mpm/src/mpmserver.cpp
branchRCL_3
changeset 26 0a9e01492035
parent 19 22c3c67e5001
child 36 04408506c6e0
--- a/bearermanagement/mpm/src/mpmserver.cpp	Tue May 11 16:35:05 2010 +0300
+++ b/bearermanagement/mpm/src/mpmserver.cpp	Tue May 25 13:08:02 2010 +0300
@@ -301,6 +301,11 @@
 //
 CMPMServer::~CMPMServer()
     {
+	if ( iRoamingToWlanPeriodic )
+        {
+        iRoamingToWlanPeriodic->Cancel();
+		delete iRoamingToWlanPeriodic;
+        }
     if ( iDisconnectQueue )
         {
         iDisconnectQueue->ResetAndDestroy();
@@ -984,7 +989,32 @@
     TCmUsageOfWlan usageOfWlan = CommsDatAccess()->ForcedRoamingL();
     if ( usageOfWlan == ECmUsageOfWlanKnown || usageOfWlan == ECmUsageOfWlanKnownAndNew )
         {
-        StartForcedRoamingToWlanL( iapInfo );
+        if ( IsWlanConnectionStartedL( CommsDatAccess() ) )
+            {
+            iConnMonIapInfo = aIapInfo;
+                
+            if ( iRoamingToWlanPeriodic )
+                {
+                iRoamingToWlanPeriodic->Cancel();
+                }
+            else
+                {
+                iRoamingToWlanPeriodic = CPeriodic::NewL( 
+                                                   CActive::EPriorityStandard );
+                }
+            // start periodic object that calls StartForcedRoamingToWlanL after 10s. 
+            // this handles the case when new wlan connection is 
+            // started from e.g. wlan sniffer but IAP is not yet in Internet SNAP 
+            iRoamingToWlanPeriodic->Start( 
+                   TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), 
+                   TTimeIntervalMicroSeconds32( KRoamingToWlanUpdateInterval ), 
+                   TCallBack( StartForcedRoamingToConnectedWlanL, this ) );
+            }
+        else
+            {
+            StartForcedRoamingToWlanL( iapInfo );
+            }
+
         StartForcedRoamingFromWlanL( iapInfo );
         }
     
@@ -1804,12 +1834,11 @@
 void CMPMServer::StartForcedRoamingToWlanL( const TConnMonIapInfo& aIapInfo )
     {
     MPMLOGSTRING( "CMPMServer::StartForcedRoamingToWlan" )
-
-    // First check that there is no active wlan connection
-    if ( IsWlanConnectionStartedL( CommsDatAccess() ) )
+    
+    // cancel the periodic object
+    if ( iRoamingToWlanPeriodic != NULL )
         {
-        // Wlan already active can't roam to it
-        return;
+        iRoamingToWlanPeriodic->Cancel();
         }
 
     // Copy all available wlan iap ids to own array
@@ -1869,6 +1898,20 @@
     CleanupStack::PopAndDestroy( &wlanIapIds );
     }
 
+
+// ---------------------------------------------------------------------------
+// CMPMServer::StartForcedRoamingToConnectedWlanL
+// ---------------------------------------------------------------------------
+//    
+TInt CMPMServer::StartForcedRoamingToConnectedWlanL( TAny* aUpdater )
+    {
+    MPMLOGSTRING( "CMPMServer::StartForcedRoamingToConnectedWlanL" );
+    static_cast<CMPMServer*>( aUpdater )->StartForcedRoamingToWlanL( 
+            static_cast<CMPMServer*>( aUpdater )->iConnMonIapInfo );
+    return 0;
+    }
+
+
 // -----------------------------------------------------------------------------
 // CMPMServer::StartForcedRoamingFromWlanL
 // -----------------------------------------------------------------------------