wlanutilities/wlansettingsui/src/wlansettingsuiscanintervalsettingitem.cpp
branchRCL_3
changeset 24 63be7eb3fc78
parent 23 b852595f5cbe
child 25 f28ada11abbf
equal deleted inserted replaced
23:b852595f5cbe 24:63be7eb3fc78
     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:  Declaration of class CWlanSettingsUiScanIntervalSettingItem.
       
    15 *
       
    16 */
       
    17  
       
    18 // INCLUDE FILES
       
    19 
       
    20 #include "wlansettingsui.hrh"
       
    21 #include "wlansettingsuimodel.h"
       
    22 #include "wlansettingsuiscanintervalsettingitem.h"
       
    23 
       
    24 #include <wlansettingsui.rsg>
       
    25 #include <AknQueryDialog.h>
       
    26 #include <StringLoader.h>
       
    27 #include <aknnotewrappers.h>
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 /**
       
    32 * User defined scan interval minimum
       
    33 */
       
    34 const TInt KScanIntervalMin = EWlanSettingsUiScanNetworkMin;
       
    35 
       
    36 /**
       
    37 * User defined scan interval maximum
       
    38 */
       
    39 const TInt KScanIntervalMax = EWlanSettingsUiScanNetworkMax;
       
    40 
       
    41 
       
    42 // ================= MEMBER FUNCTIONS =======================
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // CWlanSettingsUiScanIntervalSettingItem::
       
    46 //                                      CWlanSettingsUiScanIntervalSettingItem
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CWlanSettingsUiScanIntervalSettingItem::
       
    50     CWlanSettingsUiScanIntervalSettingItem( 
       
    51         TInt aResourceId, TInt& aListValue, TInt& aValue,
       
    52         CWlanSettingsUiModel* aModel ) : 
       
    53     CAknEnumeratedTextPopupSettingItem( aResourceId, aListValue ),
       
    54     iModel( aModel ),
       
    55     iValue( aValue ),
       
    56     iEnv( CEikonEnv::Static() ),
       
    57     iRevertBackToAutomaticScan( EFalse ) 
       
    58     {        
       
    59     };
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CWlanSettingsUiScanIntervalSettingItem::
       
    63 //                                     ~CWlanSettingsUiScanIntervalSettingItem
       
    64 // Destructor
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CWlanSettingsUiScanIntervalSettingItem::
       
    68     ~CWlanSettingsUiScanIntervalSettingItem()
       
    69     {
       
    70     iSettingText.Close();
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CWlanSettingsUiScanIntervalSettingItem::SettingTextL
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 const TDesC& CWlanSettingsUiScanIntervalSettingItem::SettingTextL()
       
    78     {
       
    79     HBufC* tempText;
       
    80     
       
    81     iSettingText.Close();
       
    82     
       
    83     if ( InternalValue() == EWlanSettingsUiScanNetworkAuto )
       
    84         {
       
    85         tempText = iEnv->AllocReadResourceL( R_WLAN_SETT_BG_SCAN_AUTO );
       
    86         }
       
    87     else
       
    88         {
       
    89         if ( iValue == 1 )
       
    90             {
       
    91             tempText = iEnv->AllocReadResourceL( R_WLAN_SETT_BG_SCAN_1_MIN );
       
    92             }
       
    93         else
       
    94             {
       
    95             tempText = StringLoader::LoadL( R_WLAN_SETT_BG_SCAN_X_MIN, iValue, iEnv );
       
    96             }
       
    97         }
       
    98     
       
    99     iSettingText.Assign( tempText );
       
   100     
       
   101     AknTextUtils::LanguageSpecificNumberConversion( iSettingText );
       
   102     
       
   103     return iSettingText;
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // CWlanSettingsUiScanIntervalSettingItem::EditItemL
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 void CWlanSettingsUiScanIntervalSettingItem::EditItemL( TBool aCalledFromMenu )
       
   111     {
       
   112     CAknEnumeratedTextPopupSettingItem::EditItemL( aCalledFromMenu );
       
   113     
       
   114     if ( iRevertBackToAutomaticScan )
       
   115         {
       
   116         // Scan mode needs to be reverted back to automatic because we are
       
   117         // either in power saving mode or user cancelled the user-defined
       
   118         // scan interval query
       
   119         SetInternalValue( EWlanSettingsUiScanNetworkAuto );
       
   120         SetSelectedIndex( IndexFromValue( EWlanSettingsUiScanNetworkAuto ) );
       
   121         UpdateListBoxTextL();
       
   122         iRevertBackToAutomaticScan = EFalse;
       
   123         }
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // CWlanSettingsUiScanIntervalSettingItem::HandleSettingPageEventL
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void CWlanSettingsUiScanIntervalSettingItem::HandleSettingPageEventL(
       
   131         CAknSettingPage* aSettingPage,
       
   132         TAknSettingPageEvent aEventType )
       
   133     {
       
   134     if ( aEventType != EEventSettingCancelled )
       
   135         {
       
   136         CEikListBox* listBox = (CEikListBox*)aSettingPage->EditorControl();
       
   137         TInt index = listBox->CurrentItemIndex();
       
   138         
       
   139         if ( index == IndexFromValue( EWlanSettingsUiScanNetworkUserDef ) )
       
   140             {
       
   141             // User-defined scan interval selected
       
   142             if ( !iModel->PsmModeOn() )
       
   143                 {
       
   144                 if ( iValue == 0 )
       
   145                     {
       
   146                     // Set default scan interval for query dialog
       
   147                     iValue = KWlanSettingsUiDefaultUserDefScanInterval;
       
   148                     }
       
   149                 if ( ShowScanIntervalQueryL() == FALSE )
       
   150                     {
       
   151                     // Dialog was cancelled, revert back to automatic scan?
       
   152                     if ( InternalValue() == EWlanSettingsUiScanNetworkAuto )
       
   153                         {
       
   154                         // Previous selection was automatic, revert back to
       
   155                         // automatic
       
   156                         iRevertBackToAutomaticScan = ETrue;
       
   157                         }
       
   158                     }
       
   159                 }
       
   160             else
       
   161                 {
       
   162                 // We are in power saving mode, user-defined interval not allowed
       
   163                 ShowPowerSavingInfoNoteL();
       
   164                 iRevertBackToAutomaticScan = ETrue;
       
   165                 }
       
   166             }
       
   167         }
       
   168 
       
   169     CAknSettingItem::HandleSettingPageEventL(aSettingPage, aEventType);
       
   170     }
       
   171 
       
   172 // ---------------------------------------------------------------------------
       
   173 // CWlanSettingsUiScanIntervalSettingItem::ShowScanIntervalQueryL
       
   174 // ---------------------------------------------------------------------------
       
   175 //
       
   176 TBool CWlanSettingsUiScanIntervalSettingItem::ShowScanIntervalQueryL()
       
   177     {
       
   178     HBufC* msg = StringLoader::LoadLC( R_WLAN_PRMPT_BG_SCAN_INTERVAL );
       
   179 
       
   180     CAknNumberQueryDialog* dialog = CAknNumberQueryDialog::NewL( iValue );
       
   181     dialog->PrepareLC( R_WLAN_SETTINGS_UI_NUMBER_EDITOR_2 );
       
   182     dialog->SetPromptL( *msg );
       
   183     dialog->SetMinimumAndMaximum( KScanIntervalMin, KScanIntervalMax );
       
   184     TBool result = ( dialog->RunLD() == EAknSoftkeyOk );
       
   185     CleanupStack::PopAndDestroy( msg );
       
   186     return result; 
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // CWlanSettingsUiScanIntervalSettingItem::ShowPowerSavingInfoNoteL
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 void CWlanSettingsUiScanIntervalSettingItem::ShowPowerSavingInfoNoteL()
       
   194     {
       
   195     HBufC* prompt = StringLoader::LoadLC(
       
   196         R_WLAN_SETTINGS_UI_POWER_SAVING_INFONOTE );
       
   197     CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue );
       
   198     note->ExecuteLD( *prompt );
       
   199     CleanupStack::PopAndDestroy( prompt );                    
       
   200     }