gssettingsuis/Gs/GSNetworkPlugin/Src/PSMNetworkPlugin.cpp
changeset 0 8c5d936e5675
child 12 bdac6c462392
equal deleted inserted replaced
-1:000000000000 0:8c5d936e5675
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Stub imlementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <psmsettingsprovider.h>
       
    21 #include <psmsrvdomaincrkeys.h>
       
    22 #include <featmgr.h>
       
    23 #include <CoreApplicationUIsSDKCRKeys.h> // KCRUidCoreApplicationUIs, TCoreAppUIsNetworkConnectionAllowed
       
    24 #include "PSMNetworkPlugin.h"
       
    25 #include "GSNetworkPluginModel.h"
       
    26 #include "GsLogger.h"
       
    27 
       
    28 // CONSTANT DEFINITIONS
       
    29 const TUint32 KPSMNetworkPluginStorageId = 0x2000B593;
       
    30 
       
    31 enum TPSMNetworkPluginKeys
       
    32     {
       
    33     ENetworkMode = 1,
       
    34     };
       
    35 
       
    36 //
       
    37 // ----------------------------------------------------------------------------------
       
    38 // CPSMNetworkPlugin::CPSMNetworkPlugin()
       
    39 // ----------------------------------------------------------------------------------
       
    40 //
       
    41 CPSMNetworkPlugin::CPSMNetworkPlugin( TPsmPluginCTorParams& aInitParams ) :
       
    42     CPsmPluginBase( aInitParams )
       
    43 	{
       
    44 	}
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CPSMNetworkPlugin::ConstructL()
       
    48 // Symbian 2nd phase constructor can leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CPSMNetworkPlugin::ConstructL()
       
    52     {
       
    53     __GSLOGSTRING( "[GS]-->[CPSMNetworkPlugin::ConstructL]" );
       
    54     
       
    55     iModel = CGSNetworkPluginModel::NewL( NULL,NULL );
       
    56     
       
    57     __GSLOGSTRING( "[GS]<--[CPSMNetworkPlugin::ConstructL]" );
       
    58     }
       
    59 
       
    60 //
       
    61 // ----------------------------------------------------------------------------------
       
    62 // CPSMNetworkPlugin::NewL()
       
    63 // ----------------------------------------------------------------------------------
       
    64 //
       
    65 // Two-phased constructor.
       
    66 CPSMNetworkPlugin* CPSMNetworkPlugin::NewL( TPsmPluginCTorParams& aInitParams )
       
    67 	{
       
    68 	CPSMNetworkPlugin* self = new ( ELeave ) CPSMNetworkPlugin( aInitParams );
       
    69 
       
    70 	CleanupStack::PushL( self );
       
    71     self->ConstructL();
       
    72     CleanupStack::Pop( self );
       
    73 
       
    74     return self;
       
    75 	}
       
    76 
       
    77 // ----------------------------------------------------------------------------------
       
    78 // CPSMNetworkPlugin::~CPSMNetworkPlugin()
       
    79 // ----------------------------------------------------------------------------------
       
    80 //
       
    81 // Destructor.
       
    82 CPSMNetworkPlugin::~CPSMNetworkPlugin()
       
    83 	{
       
    84     __GSLOGSTRING( "[CPSMNetworkPlugin::~CPSMNetworkPlugin]" );
       
    85     delete iModel;
       
    86     iModel = NULL;
       
    87 	}
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // CPSMNetworkPlugin::IsPhoneOfflineL
       
    91 //
       
    92 // Checks if phone is in offline mode or not.
       
    93 // Return ETrue if phone is in offline mode.
       
    94 // Return EFalse if phone is not in offline mode.
       
    95 // ---------------------------------------------------------
       
    96 //
       
    97 TBool CPSMNetworkPlugin::IsPhoneOfflineL() const
       
    98     {
       
    99     if ( FeatureManager::FeatureSupported( KFeatureIdOfflineMode ) )
       
   100         {
       
   101         CRepository* repository = CRepository::NewLC( KCRUidCoreApplicationUIs );
       
   102         TInt connAllowed = 1;
       
   103         repository->Get( KCoreAppUIsNetworkConnectionAllowed, connAllowed );
       
   104         CleanupStack::PopAndDestroy();  // repository
       
   105         if ( !connAllowed )
       
   106             {
       
   107             return ETrue;
       
   108             }
       
   109         }
       
   110     return EFalse;
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------------
       
   114 // CPSMNetworkPlugin::NotifyModeChange()
       
   115 // ----------------------------------------------------------------------------------
       
   116 //
       
   117 void CPSMNetworkPlugin::NotifyModeChange( const TInt aMode )
       
   118     {
       
   119     TInt err = KErrNone;
       
   120     TRAP( err, DoModeChangeL( aMode ) );
       
   121     if ( KErrNone != err)
       
   122         {}
       
   123     __GSLOGSTRING2( "[CPSMNetworkPlugin::NotifyModeChange]: Mode:%d Err:%d", aMode, err );
       
   124     }
       
   125 
       
   126 
       
   127 // ----------------------------------------------------------------------------------
       
   128 // CPSMNetworkPlugin::NotifyModeChange()
       
   129 // ----------------------------------------------------------------------------------
       
   130 //
       
   131 void CPSMNetworkPlugin::DoModeChangeL( const TInt aMode )
       
   132     {
       
   133     if ( !IsPhoneOfflineL() && 
       
   134          FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ) &&
       
   135          iModel->IsNetworkModeVisible() )
       
   136         {
       
   137         RConfigInfoArray infoArray;
       
   138     
       
   139         TPsmsrvConfigInfo info1;
       
   140         info1.iConfigId = ENetworkMode;
       
   141         info1.iConfigType = EConfigTypeInt;
       
   142         info1.iIntValue = iModel->GetNetworkMode();
       
   143         infoArray.Append( info1 );
       
   144     
       
   145         __GSLOGSTRING1( "[CPSMNetworkPlugin::NotifyModeChangeL] Switching to mode:%d", aMode );
       
   146     
       
   147         __GSLOGSTRING1( "[CPSMNetworkPlugin::NotifyModeChangeL]: oldValue info1: %d", infoArray[0].iIntValue );
       
   148     
       
   149         iSettingsProvider.BackupAndGetSettingsL( infoArray, KPSMNetworkPluginStorageId );
       
   150         
       
   151         __GSLOGSTRING1( "[CPSMNetworkPlugin::NotifyModeChangeL]: newValue info1: %d", infoArray[0].iIntValue );
       
   152     
       
   153         // Don't change the network mode if there is ongoing phone call
       
   154         // since this will disconnect it
       
   155         if ( !iModel->IsCallActive() )
       
   156             {
       
   157             iModel->SetNetworkModeL ( infoArray[0].iIntValue  );
       
   158             }
       
   159         
       
   160         infoArray.Reset();       
       
   161         }
       
   162     }
       
   163 
       
   164 //End of File
       
   165 
       
   166