cmmanager/gsconnsettingsplugin/src/gsconnsettingspluginmodel.cpp
branchRCL_3
changeset 57 05bc53fe583b
parent 55 fc7b30ed2058
child 58 83ca720e2b9a
equal deleted inserted replaced
55:fc7b30ed2058 57:05bc53fe583b
     1 /*
       
     2 * Copyright (c) 2005-2007 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:  Connectivity Settings Plugin model implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <featmgr.h>
       
    22 #include "gsconnsettingsplugincontainer.h"
       
    23 #include "gsconnsettingspluginmodel.h"
       
    24 #include "cmmanager.h"
       
    25 #include "gsconnsettingsplugin.hrh"
       
    26 
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "gsconnsettingspluginmodelTraces.h"
       
    30 #endif
       
    31 
       
    32 
       
    33 // EXTERNAL DATA STRUCTURES
       
    34 
       
    35 // EXTERNAL FUNCTION PROTOTYPES
       
    36 
       
    37 // CONSTANTS
       
    38 
       
    39 // MACROS
       
    40 
       
    41 // LOCAL CONSTANTS AND MACROS
       
    42 
       
    43 // MODULE DATA STRUCTURES
       
    44 
       
    45 // LOCAL FUNCTION PROTOTYPES
       
    46 
       
    47 // FORWARD DECLARATIONS
       
    48 
       
    49 // ============================= LOCAL FUNCTIONS ==============================
       
    50 
       
    51 // ========================= MEMBER FUNCTIONS =================================
       
    52 
       
    53 
       
    54 // ----------------------------------------------------------------------------
       
    55 // CGSDisplayPluginModel::NewL
       
    56 //
       
    57 // Symbian OS two-phased constructor
       
    58 // ----------------------------------------------------------------------------
       
    59 //
       
    60 CGSConnSettingsPluginModel* CGSConnSettingsPluginModel::NewL()
       
    61     {
       
    62     CGSConnSettingsPluginModel* self = new( ELeave ) CGSConnSettingsPluginModel;
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL();
       
    65 
       
    66     CleanupStack::Pop( self );
       
    67     return self;
       
    68     }
       
    69 
       
    70 
       
    71 // ----------------------------------------------------------------------------
       
    72 // CGSConnSettingsPluginModel::CGSConnSettingsPluginModel
       
    73 //
       
    74 //
       
    75 // C++ default constructor can NOT contain any code, that might leave.
       
    76 // ----------------------------------------------------------------------------
       
    77 //
       
    78 CGSConnSettingsPluginModel::CGSConnSettingsPluginModel()
       
    79     {
       
    80     }
       
    81 
       
    82 
       
    83 // ----------------------------------------------------------------------------
       
    84 // CGSConnSettingsPluginModel::ConstructL
       
    85 //
       
    86 // EPOC default constructor can leave.
       
    87 // ----------------------------------------------------------------------------
       
    88 //
       
    89 void CGSConnSettingsPluginModel::ConstructL()
       
    90     {
       
    91     FeatureManager::InitializeLibL();
       
    92     iIsWlanSupported = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );
       
    93     FeatureManager::UnInitializeLib();
       
    94     }
       
    95 
       
    96 
       
    97 // ----------------------------------------------------------------------------
       
    98 // CGSConnSettingsPluginModel::~CGSConnSettingsPluginModel
       
    99 //
       
   100 // Destructor
       
   101 // ----------------------------------------------------------------------------
       
   102 //
       
   103 CGSConnSettingsPluginModel::~CGSConnSettingsPluginModel()
       
   104     {
       
   105     }
       
   106 
       
   107 // ----------------------------------------------------------------------------
       
   108 // CGSConnSettingsPluginModel::LoadSettings
       
   109 //
       
   110 // Loads settings by using CMManager's general connection settings API
       
   111 // ----------------------------------------------------------------------------
       
   112 //
       
   113 void CGSConnSettingsPluginModel::LoadSettingsL()
       
   114     {
       
   115     RCmManager CmManager;
       
   116     CmManager.CreateTablesAndOpenL();
       
   117     CleanupClosePushL(CmManager); 
       
   118     CmManager.ReadGenConnSettingsL( iSettings );
       
   119     CleanupStack::PopAndDestroy( 1 );     //CmManager
       
   120 
       
   121     //Print out loaded settings
       
   122     OstTrace1( TRACE_NORMAL, CSP_LOADSETTINGSL_USAGE_OF_NEW_WLAN_PARAM_TRACE, "iSettings.iUsageOfWlan=%d", iSettings.iUsageOfWlan );
       
   123     OstTrace1( TRACE_NORMAL, CSP_LOADSETTINGSL_CELLULAR_DATA_USAGE_VISITOR_PARAM_TRACE, "iSettings.iCellularDataUsageVisitor=%d", iSettings.iCellularDataUsageVisitor );
       
   124     OstTrace1( TRACE_NORMAL, CSP_LOADSETTINGSL_CELLULAR_DATA_USAGE_HOME_PARAM_TRACE, "iSettings.iCellularDataUsageHome=%d", iSettings.iCellularDataUsageHome );
       
   125     }
       
   126 
       
   127 // ----------------------------------------------------------------------------
       
   128 // CGSConnSettingsPluginModel::SaveSettingsL
       
   129 //
       
   130 // Saves settings by using CMManager's general connection settings API
       
   131 // ----------------------------------------------------------------------------
       
   132 //
       
   133 void CGSConnSettingsPluginModel::SaveSettingsL()
       
   134     {
       
   135     RCmManager CmManager;
       
   136     CmManager.CreateTablesAndOpenL();
       
   137     CleanupClosePushL(CmManager); 
       
   138     CmManager.WriteGenConnSettingsL( iSettings );
       
   139     CleanupStack::PopAndDestroy( 1 );     //CmManager
       
   140 
       
   141     //Print out saved settings
       
   142     OstTrace1( TRACE_NORMAL, CSP_SAVESETTINGSL_USAGE_OF_NEW_WLAN_PARAM_TRACE, "iSettings.iUsageOfWlan=%d", iSettings.iUsageOfWlan );
       
   143     OstTrace1( TRACE_NORMAL, CSP_SAVESETTINGSL_CELLULAR_DATA_USAGE_VISITOR_PARAM_TRACE, "iSettings.iCellularDataUsageVisitor=%d", iSettings.iCellularDataUsageVisitor );
       
   144     OstTrace1( TRACE_NORMAL, CSP_SAVESETTINGSL_CELLULAR_DATA_USAGE_HOME_PARAM_TRACE, "iSettings.iCellularDataUsageHome=%d", iSettings.iCellularDataUsageHome );
       
   145     }
       
   146 
       
   147 // ----------------------------------------------------------------------------
       
   148 // CGSConnSettingsPluginModel::UsageOfWlan
       
   149 //
       
   150 // Maps value from general connection settings API to match index in UI
       
   151 // ----------------------------------------------------------------------------
       
   152 //
       
   153 TInt CGSConnSettingsPluginModel::UsageOfWlan()
       
   154     {
       
   155     TInt mappedValue = 0;
       
   156     
       
   157     //Map to correct index    
       
   158     switch ( iSettings.iUsageOfWlan )
       
   159         {
       
   160         case ECmUsageOfWlanKnown: 
       
   161             mappedValue = EUsageOfWlanKnown; //Known
       
   162             break;
       
   163             
       
   164         case ECmUsageOfWlanManual:
       
   165             mappedValue = EUsageOfNewWlanManual; //Manual
       
   166             break;
       
   167                         
       
   168         default:
       
   169             break;
       
   170         }
       
   171     return mappedValue;
       
   172     }
       
   173 
       
   174 // ----------------------------------------------------------------------------
       
   175 // CGSConnSettingsPluginModel::DataUsageAbroad
       
   176 //
       
   177 // Maps value from general connection settings API to match index in UI
       
   178 // ----------------------------------------------------------------------------
       
   179 //
       
   180 TInt CGSConnSettingsPluginModel::DataUsageAbroad()
       
   181     {   
       
   182     TInt mappedValue = 0;
       
   183 
       
   184     //Map to correct index    
       
   185     switch ( iSettings.iCellularDataUsageVisitor )
       
   186         {
       
   187         case ECmCellularDataUsageAutomatic:
       
   188             mappedValue = EDataUsageAbroadAutomatic; // Automatic
       
   189             break;
       
   190 
       
   191         case ECmCellularDataUsageConfirm:
       
   192             mappedValue = EDataUsageAbroadConfirm; // Confirm
       
   193             break;
       
   194 
       
   195         case ECmCellularDataUsageDisabled:
       
   196             if( iIsWlanSupported )
       
   197                 {
       
   198                 mappedValue = EDataUsageAbroadWlanOnly; // Wlan only
       
   199                 }
       
   200             else
       
   201                 {
       
   202                 mappedValue = EDataUsageAbroadDisabled; // Disabled when nowlan
       
   203                 }
       
   204             break;
       
   205 
       
   206         default:
       
   207             break;
       
   208         }
       
   209     return mappedValue;
       
   210     }
       
   211 
       
   212 // ----------------------------------------------------------------------------
       
   213 // CGSConnSettingsPluginModel::DataUsageInHomeNw
       
   214 //
       
   215 // Maps value from general connection settings API to match index in UI
       
   216 // ----------------------------------------------------------------------------
       
   217 //
       
   218 TInt CGSConnSettingsPluginModel::DataUsageInHomeNw()
       
   219     {     
       
   220     TInt mappedValue = 0;
       
   221 
       
   222     //Map to correct index    
       
   223     switch ( iSettings.iCellularDataUsageHome )
       
   224         {
       
   225         case ECmCellularDataUsageAutomatic:
       
   226             mappedValue = EDataUsageHomeNwAutomatic; // Automatic
       
   227             break;
       
   228 
       
   229         case ECmCellularDataUsageConfirm:
       
   230             mappedValue = EDataUsageHomeNwConfirm; // Confirm
       
   231             break;
       
   232 
       
   233         case ECmCellularDataUsageDisabled:
       
   234             if( iIsWlanSupported )
       
   235                 {
       
   236                 mappedValue = EDataUsageHomeNwWlanOnly; // Wlan only
       
   237                 }
       
   238             else
       
   239                 {
       
   240                 mappedValue = EDataUsageHomeNwDisabled; // Disabled when nowlan
       
   241                 }
       
   242             break;
       
   243 
       
   244         default:
       
   245             break;
       
   246         }
       
   247     return mappedValue;
       
   248     }
       
   249 
       
   250 // ----------------------------------------------------------------------------
       
   251 // CGSConnSettingsPluginModel::SetUsageOfNewWlanL
       
   252 //
       
   253 // Maps UI index to according general connection setting API value
       
   254 // ----------------------------------------------------------------------------
       
   255 //
       
   256 void CGSConnSettingsPluginModel::SetUsageOfWlan( TInt aValue )
       
   257     {    
       
   258     //Map to correct index
       
   259     switch ( aValue )
       
   260         {        
       
   261         case EUsageOfWlanKnown: //Join and inform
       
   262             iSettings.iUsageOfWlan = ECmUsageOfWlanKnown;
       
   263             break;
       
   264             
       
   265         case EUsageOfNewWlanManual: //inform
       
   266             iSettings.iUsageOfWlan = ECmUsageOfWlanManual;
       
   267             break;
       
   268                         
       
   269         default:
       
   270             break;
       
   271         }   
       
   272     }
       
   273 
       
   274 // ----------------------------------------------------------------------------
       
   275 // CGSConnSettingsPluginModel::SetDataUsageAbroadL
       
   276 //
       
   277 // Maps UI index to according general connection setting API value
       
   278 // ----------------------------------------------------------------------------
       
   279 //
       
   280 void CGSConnSettingsPluginModel::SetDataUsageAbroad( TInt aValue )
       
   281     {
       
   282     switch ( aValue )
       
   283         {
       
   284         case EDataUsageAbroadAutomatic:  //Automatic
       
   285             iSettings.iCellularDataUsageVisitor = ECmCellularDataUsageAutomatic; 
       
   286             break;
       
   287         case EDataUsageAbroadConfirm: //Confirm
       
   288             iSettings.iCellularDataUsageVisitor = ECmCellularDataUsageConfirm;
       
   289             break;
       
   290 
       
   291         case EDataUsageAbroadWlanOnly: //Wlan only
       
   292         case EDataUsageAbroadDisabled:
       
   293             iSettings.iCellularDataUsageVisitor = ECmCellularDataUsageDisabled;
       
   294             break;
       
   295                         
       
   296         default:
       
   297             break;
       
   298         }
       
   299     }
       
   300 
       
   301 // ----------------------------------------------------------------------------
       
   302 // CGSConnSettingsPluginModel::SetDataUsageInHomeNwL
       
   303 //
       
   304 // Maps UI index to according general connection setting API value
       
   305 // ----------------------------------------------------------------------------
       
   306 //
       
   307 void CGSConnSettingsPluginModel::SetDataUsageInHomeNw( TInt aValue )
       
   308     {
       
   309     switch ( aValue )
       
   310         {
       
   311         case EDataUsageHomeNwAutomatic: //Automatic
       
   312             iSettings.iCellularDataUsageHome = ECmCellularDataUsageAutomatic; 
       
   313             break;
       
   314 
       
   315         case EDataUsageHomeNwConfirm: //Confirm
       
   316             iSettings.iCellularDataUsageHome = ECmCellularDataUsageConfirm;
       
   317             break;
       
   318 
       
   319         case EDataUsageHomeNwWlanOnly: //Wlan only
       
   320         case EDataUsageHomeNwDisabled:
       
   321             iSettings.iCellularDataUsageHome = ECmCellularDataUsageDisabled;
       
   322             break;
       
   323                         
       
   324         default:
       
   325             break;
       
   326         }
       
   327     }
       
   328 
       
   329 // ----------------------------------------------------------------------------
       
   330 // CGSConnSettingsPluginModel::SetOwner
       
   331 //
       
   332 // Sets its owner.
       
   333 // ----------------------------------------------------------------------------
       
   334 //
       
   335 void CGSConnSettingsPluginModel::SetOwner( CGSConnSettingsPluginContainer* aContainer)
       
   336     {
       
   337     iContainer = aContainer;
       
   338     }
       
   339 
       
   340 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   341 
       
   342 // End of File