mediasettings/mediasettingsapp/src/MPSettingsAdvancedBwSettingItemList.cpp
changeset 0 96612d01cf9f
child 1 6711b85517b7
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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:   Setting item list class for Advanced bandwidth setting list view.*
       
    15 */
       
    16 
       
    17 
       
    18 // Version : %version: 5 %
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include    <eikappui.h>
       
    25 #include    <MediaSettings.rsg>
       
    26 #include    <barsread.h>
       
    27 #include    <featmgr.h>
       
    28 
       
    29 #include    "mediasettings.hrh"
       
    30 #include    "MPSettingsAdvancedBwSettingItemList.h"
       
    31 #include    "MPSettingsAdvancedBwSettingItem.h"
       
    32 #include    "MPSettingsModelForROP.h"
       
    33 #include	"mpxlog.h"
       
    34 
       
    35 // ============================ MEMBER FUNCTIONS ===============================
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CMPSettingsAdvancedBwSettingItemList::CMPSettingsAdvancedBwSettingItemList
       
    39 // C++ default constructor can NOT contain any code, that
       
    40 // might leave.
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CMPSettingsAdvancedBwSettingItemList::CMPSettingsAdvancedBwSettingItemList(CMPSettingsModelForROP* aModel) 
       
    44 	: iModel( aModel)
       
    45     {
       
    46     MPX_FUNC("#MS# CMPSettingsAdvancedBwSettingItemList::CMPSettingsAdvancedBwSettingItemList()");
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CMPSettingsAdvancedBwSettingItemList::ConstructFromResourceL
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 void CMPSettingsAdvancedBwSettingItemList::ConstructFromResourceL(TInt aResourceId) 
       
    54     {
       
    55 	MPX_DEBUG2(_L("#MS# CMPSettingsAdvancedBwSettingItemList::ConstructFromResourceL(0x%X)"),aResourceId);
       
    56 	TResourceReader reader;
       
    57 	iCoeEnv->CreateResourceReaderLC(reader, aResourceId);
       
    58 	ConstructFromResourceL(reader);
       
    59     CleanupStack::PopAndDestroy(); // reader
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CMPSettingsAdvancedBwSettingItemList::ConstructFromResourceL
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 void CMPSettingsAdvancedBwSettingItemList::ConstructFromResourceL(TResourceReader& aReader) 
       
    67     {
       
    68 	MPX_FUNC("#MS# CMPSettingsAdvancedBwSettingItemList::ConstructFromResourceL()");
       
    69     LoadAllL();
       
    70 
       
    71     iModel->GetMaxBwPresetsL(iGRPSMaxPresets, EBearerGPRS);    
       
    72     iModel->GetMaxBwPresetsL(iEGRPSMaxPresets, EBearerEGPRS);
       
    73     iModel->GetMaxBwPresetsL(iWCDMAMaxPresets, EBearerWCDMA);
       
    74     iModel->GetMaxBwPresetsL(iWLANMaxPresets, EBearerWLAN);
       
    75     iModel->GetMaxBwPresetsL(iHSDPAMaxPresets, EBearerHSDPA);
       
    76 
       
    77     CalculateListPosition(iGPRSBw, iGPRSListValue, iGRPSMaxPresets);
       
    78     CalculateListPosition(iEGPRSBw, iEGPRSListValue, iEGRPSMaxPresets);
       
    79     CalculateListPosition(iWCDMABw, iWCDMAListValue, iWCDMAMaxPresets);
       
    80     CalculateListPosition(iWLANBw, iWLANListValue, iWLANMaxPresets);
       
    81     CalculateListPosition(iHSDPABw, iHSDPAListValue, iHSDPAMaxPresets);
       
    82 
       
    83     CAknSettingItemList::ConstructFromResourceL(aReader);
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CMPSettingsAdvancedBwSettingItemList::~CMPSettingsAdvancedBwSettingItemList
       
    88 // Destructor
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 CMPSettingsAdvancedBwSettingItemList::~CMPSettingsAdvancedBwSettingItemList()
       
    92     {
       
    93     MPX_FUNC("#MS# CMPSettingsAdvancedBwSettingItemList::~CMPSettingsAdvancedBwSettingItemList()");
       
    94     iGRPSMaxPresets.Close();
       
    95     iEGRPSMaxPresets.Close();
       
    96     iWCDMAMaxPresets.Close();
       
    97     iWLANMaxPresets.Close();
       
    98     iHSDPAMaxPresets.Close();
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CMPSettingsAdvancedBwSettingItemList::EditItemL
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CMPSettingsAdvancedBwSettingItemList::EditItemL(TInt aIndex, TBool aCalledFromMenu)
       
   106     {
       
   107 	MPX_DEBUG3(_L("#MS# CMPSettingsAdvancedBwSettingItemList::EditItemL(%d,%d)"),aIndex,aCalledFromMenu);
       
   108     // Call base class' method
       
   109     CAknSettingItemList::EditItemL(aIndex, aCalledFromMenu);
       
   110 
       
   111     // Store setting value to settings model
       
   112     CAknSettingItem* settingItem = SettingItemArray()->At(aIndex);
       
   113     TInt identifier = settingItem->Identifier();
       
   114 
       
   115     settingItem->StoreL();   
       
   116     StoreSettingL(identifier);
       
   117     }
       
   118 
       
   119 // -----------------------------------------------------------------------------
       
   120 // CMPSettingsAdvancedBwSettingItemList::CreateSettingItemL
       
   121 // -----------------------------------------------------------------------------
       
   122 //
       
   123 CAknSettingItem* CMPSettingsAdvancedBwSettingItemList::CreateSettingItemL(TInt aSettingId)
       
   124     {   
       
   125 	MPX_DEBUG2(_L("#MS# CMPSettingsAdvancedBwSettingItemList::CreateSettingItemL(%d)"),aSettingId);
       
   126     CAknSettingItem* settingItem = NULL;
       
   127 
       
   128     switch (aSettingId)
       
   129         {
       
   130         case EMPSettGPRSBwSettingId:
       
   131             settingItem = new(ELeave) CMPSettingsAdvancedBwSettingItem(aSettingId,
       
   132                 iGRPSMaxPresets, iGPRSBw, iGPRSListValue, R_MPSETT_GPRS_BW_QUERY);
       
   133             break;
       
   134         case EMPSettEGPRSBwSettingId:
       
   135             if (FeatureManager::FeatureSupported(KFeatureIdEdgeKnowledge))
       
   136                 {
       
   137                 settingItem = new(ELeave) CMPSettingsAdvancedBwSettingItem(aSettingId,
       
   138                     iEGRPSMaxPresets, iEGPRSBw, iEGPRSListValue, R_MPSETT_EGPRS_BW_QUERY);
       
   139                 }
       
   140             break;
       
   141         case EMPSettWCDMABwSettingId:
       
   142             if (FeatureManager::FeatureSupported(KFeatureIdProtocolWcdma)) 
       
   143                 {
       
   144                 settingItem = new(ELeave) CMPSettingsAdvancedBwSettingItem(aSettingId,
       
   145                     iWCDMAMaxPresets, iWCDMABw, iWCDMAListValue, R_MPSETT_WCDMA_BW_QUERY);
       
   146                 }
       
   147             break;
       
   148         case EMPSettWLANBwSettingId:
       
   149             if (FeatureManager::FeatureSupported(KFeatureIdProtocolWlan)) 
       
   150                 {
       
   151                 settingItem = new(ELeave) CMPSettingsAdvancedBwSettingItem(aSettingId,
       
   152                     iWLANMaxPresets, iWLANBw, iWLANListValue, R_MPSETT_WLAN_BW_QUERY);
       
   153                 }
       
   154             break;
       
   155         case EMPSettHSDPABwSettingId:
       
   156             if (FeatureManager::FeatureSupported(KFeatureIdHsxpaSupport)) 
       
   157                 {
       
   158                 settingItem = new(ELeave) CMPSettingsAdvancedBwSettingItem(aSettingId,
       
   159                     iHSDPAMaxPresets, iHSDPABw, iHSDPAListValue, R_MPSETT_HSDPA_BW_QUERY);
       
   160                 }
       
   161             break;
       
   162         default:
       
   163             break;
       
   164         }
       
   165 
       
   166     return settingItem;   
       
   167     }
       
   168 
       
   169 // -----------------------------------------------------------------------------
       
   170 // CMPSettingsAdvancedBwSettingItemList::LoadAllL
       
   171 // -----------------------------------------------------------------------------
       
   172 //
       
   173 void CMPSettingsAdvancedBwSettingItemList::LoadAllL()
       
   174     {
       
   175     MPX_FUNC("#MS# CMPSettingsAdvancedBwSettingItemList::LoadAllL()");
       
   176     iModel->LoadSettingsL(EConfigUser);
       
   177     LoadSettingL(EMPSettGPRSBwSettingId);
       
   178     LoadSettingL(EMPSettEGPRSBwSettingId);
       
   179     LoadSettingL(EMPSettWCDMABwSettingId);
       
   180     LoadSettingL(EMPSettWLANBwSettingId);
       
   181     LoadSettingL(EMPSettHSDPABwSettingId);
       
   182     }
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CMPSettingsAdvancedBwSettingItemList::LoadSettingL
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 void CMPSettingsAdvancedBwSettingItemList::LoadSettingL(TInt aSettingId)
       
   189     {
       
   190     MPX_DEBUG2(_L("#MS# CMPSettingsAdvancedBwSettingItemList::LoadSettingL(%d)"),aSettingId);
       
   191     switch (aSettingId)
       
   192         {
       
   193         case EMPSettGPRSBwSettingId:
       
   194             iModel->GetMaxBandwidth(iGPRSBw, EBearerGPRS);
       
   195             break;
       
   196         case EMPSettEGPRSBwSettingId:
       
   197             iModel->GetMaxBandwidth(iEGPRSBw, EBearerEGPRS);
       
   198             break;
       
   199         case EMPSettWCDMABwSettingId:
       
   200             iModel->GetMaxBandwidth(iWCDMABw, EBearerWCDMA);
       
   201             break;
       
   202         case EMPSettWLANBwSettingId:
       
   203             iModel->GetMaxBandwidth(iWLANBw, EBearerWLAN);
       
   204             break;
       
   205         case EMPSettHSDPABwSettingId:
       
   206             iModel->GetMaxBandwidth(iHSDPABw, EBearerHSDPA);
       
   207             break;
       
   208         default:
       
   209             break;
       
   210         }
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CMPSettingsAdvancedBwSettingItemList::StoreSettingL
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void CMPSettingsAdvancedBwSettingItemList::StoreSettingL(TInt aSettingId)
       
   218     {
       
   219     MPX_DEBUG2(_L("#MS# CMPSettingsAdvancedBwSettingItemList::StoreSettingL(%d)"),aSettingId);
       
   220 
       
   221     switch (aSettingId)
       
   222         {
       
   223         case EMPSettGPRSBwSettingId:
       
   224             {
       
   225             iModel->SetMaxBandwidth(iGPRSBw, EBearerGPRS);
       
   226             break;
       
   227             }
       
   228         case EMPSettEGPRSBwSettingId:
       
   229             {
       
   230             iModel->SetMaxBandwidth(iEGPRSBw, EBearerEGPRS);
       
   231             break;
       
   232             }
       
   233         case EMPSettWCDMABwSettingId:
       
   234             {
       
   235             iModel->SetMaxBandwidth(iWCDMABw, EBearerWCDMA);
       
   236             break;
       
   237             }
       
   238         case EMPSettWLANBwSettingId:
       
   239             {
       
   240             iModel->SetMaxBandwidth(iWLANBw, EBearerWLAN);
       
   241             break;
       
   242             }
       
   243         case EMPSettHSDPABwSettingId:
       
   244             {
       
   245             iModel->SetMaxBandwidth(iHSDPABw, EBearerHSDPA);
       
   246             break;
       
   247             }
       
   248         default:
       
   249             break;
       
   250         }
       
   251     
       
   252     iModel->StoreSettingsL();
       
   253     }
       
   254 
       
   255 // -----------------------------------------------------------------------------
       
   256 // CMPSettingsAdvancedBwSettingItemList::CalculateListPosition
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 void CMPSettingsAdvancedBwSettingItemList::CalculateListPosition(TInt aValue,
       
   260                                                                  TInt& aListValue,
       
   261                                                                  RArray<TInt>& aArray)
       
   262     {
       
   263     MPX_DEBUG2(_L("#MS# CMPSettingsAdvancedBwSettingItemList::CalculateListPosition(%d)"),aValue);
       
   264     TInt count = aArray.Count();
       
   265     aListValue = count;
       
   266 
       
   267     for (TInt index = 0; index < count; ++index)
       
   268         {
       
   269         if (aArray[index] == aValue)
       
   270             {
       
   271             aListValue = index;
       
   272             break;
       
   273             }
       
   274         }
       
   275     }
       
   276 
       
   277 //  End of File