coreapplicationuis/SysAp/Src/OfflineModeController/SysApOfflineModeControllerImpl.cpp
branchRCL_3
changeset 20 c2c61fdca848
parent 19 924385140d98
--- a/coreapplicationuis/SysAp/Src/OfflineModeController/SysApOfflineModeControllerImpl.cpp	Tue Aug 31 15:24:25 2010 +0300
+++ b/coreapplicationuis/SysAp/Src/OfflineModeController/SysApOfflineModeControllerImpl.cpp	Wed Sep 01 12:24:48 2010 +0100
@@ -1,22 +1,19 @@
 /*
- * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
- * All rights reserved.
- * This component and the accompanying materials are made available
- * under the terms of "Eclipse Public License v1.0"
- * which accompanies this distribution, and is available
- * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CSysApOfflineModeController implementation
  *
- * Initial Contributors:
- * Nokia Corporation - initial contribution.
- *
- * Contributors:
- *
- * Description:
- * CSysApOfflineModeController controls the offline mode.
- * It turns OFF RF, BT and WLAN when offline mode is enabled and turns them ON when
- * Offline mode is disabled
- *
- */
+*/
 
 
 // INCLUDES
@@ -26,10 +23,8 @@
 #include "SysAp.hrh"
 #include "DosSvrServices.h"
 #include "SysApCenRepController.h"
-#include "sysapcenrepofflinemodeobserver.h"
 #include <startupdomainpskeys.h>
 #include <PSVariables.h>
-#include <wlandevicesettingsinternalcrkeys.h> // For Turning ON/OFF WLAN
 
 
 MSysApOfflineModeController* CreateSysApOfflineModeControllerL( CSysApAppUi& aSysApAppUi )
@@ -58,18 +53,22 @@
 void CSysApOfflineModeController::ConstructL()
     {
     TRACES( RDebug::Print( _L("CSysApOfflineModeController::ConstructL") ) ); 
-    
-    // create an observer for Offline Mode
-    TRACES( RDebug::Print( _L("CSysApOfflineModeController::ConstructL: trying CSysApCenRepOfflineModeObserver::NewL") ) );
-    iSysApCenRepOfflineModeObserver = CSysApCenRepOfflineModeObserver::NewL(*this );         
-    iOfflineModeActive = iSysApCenRepOfflineModeObserver->IsOffline();
+    // Check the active profile
+    TInt activeProfile( iSysApAppUi.ActiveProfileId() );
+    activeProfile = iSysApAppUi.ActiveProfileId();
+    if ( activeProfile == KOfflineModeProfileId )
+        {
+        iOfflineModeActive = ETrue;
+        }
     }
 
 // ----------------------------------------------------------------------------
 // CSysApOfflineModeController::CSysApOfflineModeController() 
 // ----------------------------------------------------------------------------
 CSysApOfflineModeController::CSysApOfflineModeController( CSysApAppUi& aSysApAppUi ) :
-  iSysApAppUi( aSysApAppUi )
+  iSysApAppUi( aSysApAppUi ),
+  iOfflineModeActive( EFalse ),
+  iDoNotActivateRF( EFalse )
     {
 
     }
@@ -80,7 +79,6 @@
 
 CSysApOfflineModeController::~CSysApOfflineModeController()
     {
-    delete iSysApCenRepOfflineModeObserver;
     }
 
 // ----------------------------------------------------------------------------
@@ -89,7 +87,6 @@
 
 TBool CSysApOfflineModeController::OfflineModeActive()
     {
-    TRACES( RDebug::Print( _L("CSysApOfflineModeController::OfflineModeActive returns %d"), iOfflineModeActive ) );
     return iOfflineModeActive;
     }
 
@@ -100,7 +97,6 @@
 void CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL()
     {
     TRACES( RDebug::Print( _L("CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL") ) ); 
-        
     TInt err ( 0 );
 
     // Set state to starter. Note that if state is same as the current state, then nothing happens.
@@ -108,6 +104,7 @@
 
     if ( err )
         {
+        iSysApAppUi.RestoreProfileL( EFalse );
         iSysApAppUi.ShowUiNoteL( ECannotActivateOfflineModeNote );
         }
     else
@@ -122,22 +119,8 @@
             SetBtActiveBeforeOfflineMode( ETrue );       // Update "BT active" setting
             TRACES( RDebug::Print( _L("CSysApOfflineModeController SetBtPowerStateL returned %d"), err ) );
             }
-        /* Turn OFF WLAN */        
-        TInt err( KErrNone );
-        CRepository* repository = CRepository::NewL( KCRUidWlanDeviceSettingsRegistryId );
-        err = repository->Set(KWlanOnOff, 0);
-        delete repository;
-        if(err) 
-		{
-           TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL Could not disable WLAN") );
-		    User::Leave(err);
-        }
-        else 
-		{
-            TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOnlineToOfflineModeL WLAN Disabled" ) );
-        }
-		
-		iSysApAppUi.OfflineModeChangedL();
+        
+        iSysApAppUi.OfflineModeChangedL();
         }
     }
 
@@ -161,6 +144,7 @@
         
     if ( err )
         {
+        iSysApAppUi.RestoreProfileL( ETrue );
         iSysApAppUi.ShowUiNoteL( ECannotDeactivateOfflineModeNote );
         }
     else
@@ -175,25 +159,11 @@
             TRACES( RDebug::Print( _L("CSysApOfflineModeController SetBtPowerStateL returned %d"), err ) );
             }
         
-		        /* Turn ON WLAN */    
-           TInt err( KErrNone );
-           CRepository* repository = CRepository::NewL( KCRUidWlanDeviceSettingsRegistryId );
-           err = repository->Set(KWlanOnOff, 1);
-           delete repository;
-           if(err)
-		   {
-               TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOfflineToOnlineModeL Could not enable WLAN") );
-		       User::Leave(err);
-           }
-           else
-		   {
-               TRACES( RDebug::Printf("CSysApOfflineModeController::SwitchFromOfflineToOnlineModeL WLAN Enabled") );
-           }
+        iSysApAppUi.OfflineModeChangedL();
 
-        iSysApAppUi.OfflineModeChangedL();
-		iSysApAppUi.SetNetworkConnectionAllowed( ECoreAppUIsNetworkConnectionAllowed );
-		}
-	}
+        iSysApAppUi.SetNetworkConnectionAllowed( ECoreAppUIsNetworkConnectionAllowed );
+        }
+    }
 
 // ----------------------------------------------------------------------------
 // CSysApOfflineModeController::CheckOfflineModeInitialStatusesL()
@@ -234,12 +204,10 @@
          ( iSysApAppUi.BtSapEnabled() && simStatus != ESimNotPresent ) ||     
          simStatus == ESimUsable )
         {
-        TRACES( RDebug::Printf("CSysApOfflineModeController::GoOnlineIfOkL SIM check PASSED") );
-        SwitchFromOfflineToOnlineModeL();
+        iSysApAppUi.ShowQueryL( ESysApLeaveOfflineModeQuery );
         }
     else    
         {
-        TRACES( RDebug::Printf("CSysApOfflineModeController::GoOnlineIfOkL SIM check FALIED" ) );
         iSysApAppUi.ShowUiNoteL( EInsertSimNote );
         }
     }
@@ -265,7 +233,6 @@
     TInt btToBeActivated = iSysApAppUi.CenRepController().GetInt( KCRUidCoreApplicationUIsSysAp,
                                                                   KSysApBtStatusBeforeOfflineMode,
                                                                   &err );
-
     if ( err )
         {
         TRACES( RDebug::Print( _L("CSysApOfflineModeController::BtActiveBeforeOfflineMode: ERROR: %d" ), err ) );
@@ -274,7 +241,6 @@
     else
         {
         return ( TBool ) btToBeActivated;
-        //return ETrue;
         }
 
     }
@@ -287,7 +253,6 @@
     return BtActiveBeforeOfflineMode();
     }
 
-
 // End of File