pushmtm/MtmUiSrc/PushSettingsDialog.cpp
changeset 0 84ad3b177aa3
child 27 481242ead638
equal deleted inserted replaced
-1:000000000000 0:84ad3b177aa3
       
     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:  Member definitions of CPushSettingsDialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //  INCLUDES
       
    21 
       
    22 #include "PushSettingsDialog.h"
       
    23 #include "PushMtmUiDef.h"
       
    24 #include "PushMtmUiPanic.h"
       
    25 #include <PushMtmUi.rsg>
       
    26 #include "PushMtmUi.hrh"
       
    27 #include "PushMtmDef.hrh"
       
    28 #include <akntitle.h>
       
    29 #include <akncontext.h>
       
    30 #include <AknQueryDialog.h>
       
    31 #include <barsread.h>
       
    32 #include <AknRadioButtonSettingPage.h>
       
    33 #include <bldvariant.hrh>
       
    34 #ifdef __SERIES60_HELP
       
    35 // Context-Sensitve Help File
       
    36 #include <hlplch.h>
       
    37 #include <csxhelp/wpush.hlp.hrh>
       
    38 #endif // __SERIES60_HELP
       
    39 #include <msvapi.h>
       
    40 #include <data_caging_path_literals.hrh>
       
    41 #include <f32file.h>
       
    42 
       
    43 // ================= MEMBER FUNCTIONS =======================
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // CPushSettingsDialog::CPushSettingsDialog
       
    47 // ---------------------------------------------------------
       
    48 //
       
    49 CPushSettingsDialog::CPushSettingsDialog( CMsvSession& aMsvSession ) 
       
    50 :   CAknDialog(), 
       
    51     iMsvSession( aMsvSession ), 
       
    52     iResourceLoader( *iCoeEnv ), 
       
    53     iNewTitleTextUsed( EFalse ), 
       
    54     iRestoreSP( ETrue )
       
    55     {
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------
       
    59 // CPushSettingsDialog::ExecuteLD
       
    60 // ---------------------------------------------------------
       
    61 //
       
    62 void CPushSettingsDialog::ExecuteLD()
       
    63     {
       
    64     CleanupStack::PushL( this );
       
    65     ConstructL();
       
    66     CAknDialog::ConstructL( R_PUSHSD_MENU );
       
    67     CleanupStack::Pop( this );
       
    68     CAknDialog::ExecuteLD( R_PUSHSD_DIALOG );
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CPushSettingsDialog::ConstructL
       
    73 // ---------------------------------------------------------
       
    74 //
       
    75 void CPushSettingsDialog::ConstructL()
       
    76     {
       
    77     // Add resource file.
       
    78     TParse* fileParser = new (ELeave) TParse;
       
    79     // Unnecessary to call CleanupStack::PushL( fileParser );
       
    80     fileParser->Set( KPushMtmUiResourceFileAndDrive, &KDC_MTM_RESOURCE_DIR, NULL ); 
       
    81     iResourceFile = fileParser->FullName();
       
    82     delete fileParser;
       
    83     fileParser = NULL;
       
    84     iResourceLoader.OpenL( iResourceFile );
       
    85 
       
    86     // Construct model.
       
    87     ConstructModelL();
       
    88 
       
    89     // Now model is ready for view.
       
    90     const TInt KGranularity( 8 );
       
    91     iSettingType = new (ELeave) CArrayFixFlat<TSettingType>( KGranularity );
       
    92 
       
    93     // Set up Title Pane and Context Pane.
       
    94     SetUpStatusPaneL();
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------
       
    98 // CPushSettingsDialog::~CPushSettingsDialog
       
    99 // ---------------------------------------------------------
       
   100 //
       
   101 CPushSettingsDialog::~CPushSettingsDialog()
       
   102     {
       
   103     if ( iRestoreSP )
       
   104         {
       
   105         TRAP_IGNORE( RestoreStatusPaneL() );
       
   106         }
       
   107     iResourceLoader.Close();
       
   108     delete iPreviousTitleText;
       
   109     delete iModel;
       
   110     delete iSettingType;
       
   111     iSettingListBox = NULL;
       
   112     iSettingListBoxItemTextArray = NULL;
       
   113     }
       
   114 
       
   115 // ---------------------------------------------------------
       
   116 // CPushSettingsDialog::SetUpStatusPaneL
       
   117 // ---------------------------------------------------------
       
   118 //
       
   119 void CPushSettingsDialog::SetUpStatusPaneL()
       
   120     {
       
   121     if ( !iNewTitleTextUsed )
       
   122         {
       
   123         __ASSERT_DEBUG( !iPreviousTitleText, 
       
   124             UiPanic( EPushMtmUiPanAlreadyExistingTitle ) );
       
   125         // Set up Title Pane.
       
   126         CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   127         CAknTitlePane* titlePane = 
       
   128             STATIC_CAST( CAknTitlePane*, 
       
   129             statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   130         // Save content.
       
   131         iPreviousTitleText = titlePane->Text()->AllocL();
       
   132         // Set new content.
       
   133         TResourceReader reader;
       
   134         iCoeEnv->CreateResourceReaderLC( reader, R_PUSHSD_TITLE_PANE );
       
   135         titlePane->SetFromResourceL( reader );
       
   136         CleanupStack::PopAndDestroy(); // reader
       
   137         iNewTitleTextUsed = ETrue;
       
   138         }
       
   139     }
       
   140 
       
   141 // ---------------------------------------------------------
       
   142 // CPushSettingsDialog::RestoreStatusPaneL
       
   143 // ---------------------------------------------------------
       
   144 //
       
   145 void CPushSettingsDialog::RestoreStatusPaneL()
       
   146     {
       
   147     if ( iNewTitleTextUsed )
       
   148         {
       
   149         __ASSERT_DEBUG( iPreviousTitleText, 
       
   150             UiPanic( EPushMtmUiPanMissingTitle ) );
       
   151         // Restore Title Pane.
       
   152         CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   153         CAknTitlePane* titlePane = 
       
   154             STATIC_CAST( CAknTitlePane*, 
       
   155             statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   156         titlePane->SetTextL( *iPreviousTitleText );
       
   157         delete iPreviousTitleText;
       
   158         iPreviousTitleText = NULL;
       
   159         iNewTitleTextUsed = EFalse;
       
   160         }
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------
       
   164 // CPushSettingsDialog::ConstructModelL
       
   165 // ---------------------------------------------------------
       
   166 //
       
   167 void CPushSettingsDialog::ConstructModelL()
       
   168     {
       
   169     __ASSERT_DEBUG( !iModel, UiPanic( EPushMtmUiPanAlreadyExistingModel ) );
       
   170 
       
   171     // This will be the model.
       
   172     iModel = CPushMtmSettings::NewL();
       
   173     }
       
   174 
       
   175 // ---------------------------------------------------------
       
   176 // CPushSettingsDialog::UpdateSettingListBoxModelL
       
   177 // ---------------------------------------------------------
       
   178 //
       
   179 void CPushSettingsDialog::UpdateSettingListBoxModelL()
       
   180     {
       
   181     __ASSERT_DEBUG( iModel && 
       
   182                     iSettingListBox && 
       
   183                     iSettingListBoxItemTextArray && 
       
   184                     iSettingType, UiPanic( EPushMtmUiPanNotInitialized ) );
       
   185 
       
   186     // Reset the list box' item text array and the setting type array.
       
   187     iSettingListBoxItemTextArray->Reset();
       
   188     iSettingType->Reset();
       
   189 
       
   190     // Service reception.
       
   191     ConstructAndAppendItemTextL
       
   192         ( EServiceReception, R_PUSHSD_RECEPT, 
       
   193         iModel->ServiceReception() ? R_PUSHSD_RECEP_ON : R_PUSHSD_RECEP_OFF );
       
   194 
       
   195 #ifdef __SERIES60_PUSH_SL
       
   196 
       
   197     // Service loading (SL specific).
       
   198     ConstructAndAppendItemTextL
       
   199         ( EServiceLoadingType, R_PUSHSD_LOADING, 
       
   200         ( iModel->ServiceLoadingType() == CPushMtmSettings::EAutomatic ) ? 
       
   201         R_PUSHSD_LOAD_AUTOM : R_PUSHSD_LOAD_MAN );
       
   202 
       
   203 #endif //__SERIES60_PUSH_SL
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------
       
   207 // CPushSettingsDialog::UpdateSettingListBoxViewL
       
   208 // ---------------------------------------------------------
       
   209 //
       
   210 void CPushSettingsDialog::UpdateSettingListBoxViewL() const
       
   211     {
       
   212     __ASSERT_DEBUG( iSettingListBox, UiPanic( EPushMtmUiPanMissingListBox ) );
       
   213     //iSettingListBox->DrawItem( iSettingListBox->CurrentItemIndex() );
       
   214     TInt currentItemIndex( iSettingListBox->CurrentItemIndex() );
       
   215     iSettingListBox->DrawNow();
       
   216     iSettingListBox->SetCurrentItemIndex( currentItemIndex );
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------
       
   220 // CPushSettingsDialog::ApplyModelChangesL
       
   221 // ---------------------------------------------------------
       
   222 //
       
   223 void CPushSettingsDialog::ApplyModelChangesL()
       
   224     {
       
   225     UpdateSettingListBoxModelL();
       
   226     UpdateSettingListBoxViewL();
       
   227     }
       
   228 
       
   229 // ---------------------------------------------------------
       
   230 // CPushSettingsDialog::ShowRadioButtonSettingPageL
       
   231 // ---------------------------------------------------------
       
   232 //
       
   233 void CPushSettingsDialog::ShowRadioButtonSettingPageL
       
   234     ( const TSettingType aSettingType )
       
   235 	{
       
   236     __ASSERT_DEBUG( iModel, UiPanic( EPushMtmUiPanMissingModel ) );
       
   237 
       
   238     TInt index;
       
   239     HBufC* settingTitle = ConstructSettingTitleL( aSettingType );
       
   240     CleanupStack::PushL( settingTitle );
       
   241     CDesCArrayFlat* itemArray = 
       
   242         ConstructSettingValueArrayL( aSettingType, index );
       
   243     CleanupStack::PushL( itemArray );
       
   244     CAknRadioButtonSettingPage* settingPage = 
       
   245         new (ELeave) CAknRadioButtonSettingPage
       
   246             ( R_PUSHSD_SP_RADIOBUTTON, index, itemArray );
       
   247     CleanupStack::PushL( settingPage );
       
   248     settingPage->SetSettingTextL( *settingTitle );
       
   249 
       
   250     const TInt previousIndex = index;
       
   251     CleanupStack::Pop(); // settingPage
       
   252     if ( settingPage->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) )
       
   253         {
       
   254         if ( previousIndex != index )
       
   255             {
       
   256             // Set the changes in the model.
       
   257             UpdateSettingL( aSettingType, index );
       
   258             }
       
   259         }
       
   260 
       
   261     CleanupStack::PopAndDestroy( 2 ); // itemArray, settingTitle
       
   262 	}
       
   263 
       
   264 // ---------------------------------------------------------
       
   265 // CPushSettingsDialog::ShowServiceLoadingTypeConfirmationL
       
   266 // ---------------------------------------------------------
       
   267 //
       
   268 TBool CPushSettingsDialog::ShowServiceLoadingTypeConfirmationL() const
       
   269     {
       
   270     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   271     return dlg->ExecuteLD( R_PUSHSD_AUTOLOAD_SETT_CONFIRM ) == EAknSoftkeyYes;
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------
       
   275 // CPushSettingsDialog::ChangeCurrentSettingWithoutSettingPageL
       
   276 // ---------------------------------------------------------
       
   277 //
       
   278 void CPushSettingsDialog::ChangeCurrentSettingWithoutSettingPageL()
       
   279     {
       
   280     __ASSERT_DEBUG( iModel && iSettingListBox, 
       
   281         UiPanic( EPushMtmUiPanNotInitialized ) );
       
   282 
       
   283     switch ( iSettingType->At( iSettingListBox->CurrentItemIndex() ) )
       
   284         {
       
   285         case EServiceReception:
       
   286             {
       
   287             iModel->SetServiceReception( !iModel->ServiceReception() );
       
   288             break;
       
   289             }
       
   290 
       
   291 #ifdef __SERIES60_PUSH_SL
       
   292 
       
   293         case EServiceLoadingType:
       
   294             {
       
   295             if ( iModel->ServiceLoadingType() == CPushMtmSettings::EManual )
       
   296                 {
       
   297                 // Display a confirmation dialog first.
       
   298                 if ( ShowServiceLoadingTypeConfirmationL() )
       
   299                     {
       
   300                     iModel->SetServiceLoadingType
       
   301                         ( CPushMtmSettings::EAutomatic );
       
   302                     }
       
   303                 }
       
   304             else
       
   305                 {
       
   306                 // Do not show confirmation dialog.
       
   307                 iModel->SetServiceLoadingType( CPushMtmSettings::EManual );
       
   308                 }
       
   309             break;
       
   310             }
       
   311 
       
   312 #endif //__SERIES60_PUSH_SL
       
   313 
       
   314         default:
       
   315             {
       
   316             __ASSERT_DEBUG( EFalse, 
       
   317                 UiPanic( EPushMtmUiPanCommandNotSupported ) );
       
   318             break;
       
   319             }
       
   320         }
       
   321 
       
   322     // Apply changes.
       
   323     iModel->SaveL();
       
   324     ApplyModelChangesL();
       
   325     }
       
   326 
       
   327 // ---------------------------------------------------------
       
   328 // CPushSettingsDialog::ChangeCurrentSettingL
       
   329 // ---------------------------------------------------------
       
   330 //
       
   331 void CPushSettingsDialog::ChangeCurrentSettingL()
       
   332     {
       
   333     __ASSERT_DEBUG( iModel && iSettingListBox, 
       
   334         UiPanic( EPushMtmUiPanNotInitialized ) );
       
   335     ShowRadioButtonSettingPageL
       
   336         ( iSettingType->At( iSettingListBox->CurrentItemIndex() ) );
       
   337     // Apply changes.
       
   338     iModel->SaveL();
       
   339     ApplyModelChangesL();
       
   340     }
       
   341 
       
   342 // ---------------------------------------------------------
       
   343 // CPushSettingsDialog::ConstructAndAppendItemTextL
       
   344 // ---------------------------------------------------------
       
   345 //
       
   346 void CPushSettingsDialog::ConstructAndAppendItemTextL
       
   347 ( const TSettingType aSettingType, 
       
   348   const TInt aTitleResId, const TInt aValueResId, 
       
   349   const TDesC& aTitleText, const TDesC& aValueText )
       
   350     {
       
   351     __ASSERT_DEBUG( iSettingListBoxItemTextArray && iSettingType, 
       
   352         UiPanic( EPushMtmUiPanNotInitialized ) );
       
   353 
       
   354     // Define separator text.
       
   355     _LIT( KHeadOfItemText, " \t" );
       
   356     // Define separator text.
       
   357     _LIT( KSeparatorOfItemText, "\t\t" );
       
   358 
       
   359     HBufC* titleText = ( aTitleResId != KErrNotFound ) ? 
       
   360         iEikonEnv->AllocReadResourceLC( aTitleResId ) : aTitleText.AllocLC();
       
   361     HBufC* valueText = ( aValueResId != KErrNotFound ) ? 
       
   362         iEikonEnv->AllocReadResourceLC( aValueResId ) : aValueText.AllocLC();
       
   363 
       
   364     // Define a heap descriptor to hold all the item text.
       
   365     HBufC* itemText = HBufC::NewMaxLC( 
       
   366         KHeadOfItemText().Length() + titleText->Length() + 
       
   367         KSeparatorOfItemText().Length() + valueText->Length() );
       
   368     TPtr itemTextPtr = itemText->Des();
       
   369     itemTextPtr =  KHeadOfItemText;
       
   370     itemTextPtr += *titleText;
       
   371     itemTextPtr += KSeparatorOfItemText;
       
   372     itemTextPtr += *valueText;
       
   373     iSettingListBoxItemTextArray->AppendL( itemTextPtr );
       
   374     iSettingType->AppendL( aSettingType );
       
   375 
       
   376     CleanupStack::PopAndDestroy( 3 ); // itemText, valueText, titleText
       
   377     }
       
   378 
       
   379 // ---------------------------------------------------------
       
   380 // CPushSettingsDialog::ConstructSettingTitleL
       
   381 // ---------------------------------------------------------
       
   382 //
       
   383 HBufC* CPushSettingsDialog::ConstructSettingTitleL
       
   384 ( const TSettingType aSettingType ) const
       
   385     {
       
   386     const TInt titleResId = 
       
   387         aSettingType == EServiceReception           ? R_PUSHSD_RECEPT : 
       
   388 #ifdef __SERIES60_PUSH_SL
       
   389         aSettingType == EServiceLoadingType         ? R_PUSHSD_LOADING : 
       
   390 #endif //__SERIES60_PUSH_SL
       
   391         KErrNotFound;
       
   392 
       
   393     __ASSERT_DEBUG( titleResId != KErrNotFound, 
       
   394         UiPanic( EPushMtmUiPanNotInitialized ) );
       
   395 
       
   396     return iEikonEnv->AllocReadResourceL( titleResId );
       
   397     }
       
   398 
       
   399 // ---------------------------------------------------------
       
   400 // CPushSettingsDialog::ConstructSettingValueArray
       
   401 // ---------------------------------------------------------
       
   402 //
       
   403 void CPushSettingsDialog::ConstructSettingValueArray
       
   404     ( 
       
   405         const TSettingType aSettingType, 
       
   406         TInt& aVal1ResId, 
       
   407         TInt& aVal2ResId 
       
   408     ) const
       
   409     {
       
   410     aVal1ResId = 
       
   411         aSettingType == EServiceReception           ? R_PUSHSD_RECEP_ON : 
       
   412 #ifdef __SERIES60_PUSH_SL
       
   413         aSettingType == EServiceLoadingType         ? R_PUSHSD_LOAD_AUTOM : 
       
   414 #endif //__SERIES60_PUSH_SL
       
   415         KErrNotFound;
       
   416 
       
   417     aVal2ResId = 
       
   418         aSettingType == EServiceReception           ? R_PUSHSD_RECEP_OFF : 
       
   419 #ifdef __SERIES60_PUSH_SL
       
   420         aSettingType == EServiceLoadingType         ? R_PUSHSD_LOAD_MAN : 
       
   421 #endif //__SERIES60_PUSH_SL
       
   422         KErrNotFound;
       
   423 
       
   424     __ASSERT_DEBUG( aVal1ResId != KErrNotFound && 
       
   425                     aVal2ResId != KErrNotFound, 
       
   426         UiPanic( EPushMtmUiPanNotInitialized ) );
       
   427     }
       
   428 
       
   429 // ---------------------------------------------------------
       
   430 // CPushSettingsDialog::CurrentlySelectedSettingValueResId
       
   431 // ---------------------------------------------------------
       
   432 //
       
   433 TInt CPushSettingsDialog::CurrentlySelectedSettingValueResId
       
   434 ( const TSettingType aSettingType, TInt& aIndex ) const
       
   435     {
       
   436     TInt val1ResId( KErrNotFound );
       
   437     TInt val2ResId( KErrNotFound );
       
   438     ConstructSettingValueArray( aSettingType, val1ResId, val2ResId );
       
   439 
       
   440     const TBool firstSelected = 
       
   441         aSettingType == EServiceReception ? iModel->ServiceReception() : 
       
   442 #ifdef __SERIES60_PUSH_SL
       
   443         aSettingType == EServiceLoadingType ? iModel->ServiceLoadingType() == 
       
   444                                               CPushMtmSettings::EAutomatic : 
       
   445 #endif //__SERIES60_PUSH_SL
       
   446         EFalse;
       
   447 
       
   448     aIndex = firstSelected ? 0 : 1;
       
   449     return firstSelected ? val1ResId : val2ResId;
       
   450     }
       
   451 
       
   452 // ---------------------------------------------------------
       
   453 // CPushSettingsDialog::ConstructSettingValueArrayL
       
   454 // ---------------------------------------------------------
       
   455 //
       
   456 CDesCArrayFlat* CPushSettingsDialog::ConstructSettingValueArrayL
       
   457 ( const TSettingType aSettingType, TInt& aIndex ) const
       
   458     {
       
   459     CDesCArrayFlat* valueArray = new (ELeave) CDesCArrayFlat( 2 );
       
   460     CleanupStack::PushL( valueArray );
       
   461 
       
   462     TInt val1ResId( KErrNotFound );
       
   463     TInt val2ResId( KErrNotFound );
       
   464     ConstructSettingValueArray( aSettingType, val1ResId, val2ResId );
       
   465     HBufC* value1Text = iEikonEnv->AllocReadResourceLC( val1ResId );
       
   466     HBufC* value2Text = iEikonEnv->AllocReadResourceLC( val2ResId );
       
   467     valueArray->AppendL( *value1Text );
       
   468     valueArray->AppendL( *value2Text );
       
   469     CleanupStack::PopAndDestroy( 2 ); // value2Text, value1Text
       
   470 
       
   471     // Returned val. is ignored.
       
   472     CurrentlySelectedSettingValueResId( aSettingType, aIndex );
       
   473 
       
   474     CleanupStack::Pop(); // valueArray
       
   475     return valueArray;
       
   476     }
       
   477 
       
   478 // ---------------------------------------------------------
       
   479 // CPushSettingsDialog::UpdateSettingL
       
   480 // ---------------------------------------------------------
       
   481 //
       
   482 void CPushSettingsDialog::UpdateSettingL
       
   483 ( const TSettingType aSettingType, const TInt aIndex ) const
       
   484     {
       
   485     switch ( aSettingType )
       
   486         {
       
   487         case EServiceReception:
       
   488             {
       
   489             iModel->SetServiceReception( aIndex == 0 ? ETrue : EFalse );
       
   490             break;
       
   491             }
       
   492 
       
   493 #ifdef __SERIES60_PUSH_SL
       
   494 
       
   495         case EServiceLoadingType:
       
   496             {
       
   497             if ( aIndex == 0 )
       
   498             // iModel->ServiceLoadingType() == CPushMtmSettings::EManual
       
   499                 {
       
   500                 // Display a confirmation dialog first.
       
   501                 if ( ShowServiceLoadingTypeConfirmationL() )
       
   502                     {
       
   503                     iModel->SetServiceLoadingType
       
   504                         ( CPushMtmSettings::EAutomatic );
       
   505                     }
       
   506                 }
       
   507             else
       
   508                 {
       
   509                 // Do not show confirmation dialog.
       
   510                 iModel->SetServiceLoadingType( CPushMtmSettings::EManual );
       
   511                 }
       
   512             break;
       
   513             }
       
   514 
       
   515 #endif //__SERIES60_PUSH_SL
       
   516 
       
   517         default:
       
   518             {
       
   519             __ASSERT_DEBUG( EFalse, 
       
   520                 UiPanic( EPushMtmUiPanCommandNotSupported ) );
       
   521             break;
       
   522             }
       
   523         }
       
   524     }
       
   525 
       
   526 // ---------------------------------------------------------
       
   527 // CPushSettingsDialog::OfferKeyEventL
       
   528 // ---------------------------------------------------------
       
   529 //
       
   530 TKeyResponse CPushSettingsDialog::OfferKeyEventL
       
   531 ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   532     {
       
   533     if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape )
       
   534 		{
       
   535         // Shutting down. Do not restore SP.
       
   536 		iRestoreSP = EFalse;
       
   537 		}
       
   538     return CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   539     }
       
   540 
       
   541 // ---------------------------------------------------------
       
   542 // CPushSettingsDialog::DynInitMenuPaneL
       
   543 // ---------------------------------------------------------
       
   544 //
       
   545 void CPushSettingsDialog::DynInitMenuPaneL
       
   546     ( TInt /*aResourceId*/, CEikMenuPane* /*aMenuPane*/ )
       
   547     {
       
   548     }
       
   549 
       
   550 // ---------------------------------------------------------
       
   551 // CPushSettingsDialog::PreLayoutDynInitL
       
   552 // ---------------------------------------------------------
       
   553 //
       
   554 void CPushSettingsDialog::PreLayoutDynInitL()
       
   555     {
       
   556     __ASSERT_DEBUG( !iSettingListBox && 
       
   557                     !iSettingListBoxItemTextArray, 
       
   558         UiPanic( EPushMtmUiPanAlreadyInitialized ) );
       
   559 
       
   560     iSettingListBox = STATIC_CAST( CAknSettingStyleListBox*, 
       
   561         Control( EPushSettingsDialogCntrlListBox ) );
       
   562 	iSettingListBoxItemTextArray = STATIC_CAST( CDesCArrayFlat*, 
       
   563         iSettingListBox->Model()->ItemTextArray() );
       
   564     iSettingListBox->SetListBoxObserver( this );
       
   565     TRect rect = Rect();
       
   566     iSettingListBox->SetRect( rect );
       
   567     // Set up scroll bar.
       
   568 	iSettingListBox->CreateScrollBarFrameL( ETrue );
       
   569 	iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL
       
   570         ( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   571 
       
   572     // Update setting list box model.
       
   573     UpdateSettingListBoxModelL();
       
   574     }
       
   575 
       
   576 // ---------------------------------------------------------
       
   577 // CPushSettingsDialog::ProcessCommandL
       
   578 // ---------------------------------------------------------
       
   579 //
       
   580 void CPushSettingsDialog::ProcessCommandL( TInt aCommand )
       
   581     {
       
   582     HideMenu();
       
   583 
       
   584     switch ( aCommand )
       
   585         {
       
   586 	    case EPushSettingsDialogCmdChangeWithoutSettingPage:
       
   587             {
       
   588             ChangeCurrentSettingWithoutSettingPageL();
       
   589 		    break;
       
   590             }
       
   591 
       
   592         case EPushSettingsDialogCmdChange:
       
   593             {
       
   594             ChangeCurrentSettingL();
       
   595 		    break;
       
   596             }
       
   597 
       
   598 #ifdef __SERIES60_HELP
       
   599 
       
   600         case EPushSettingsDialogCmdHelp:
       
   601             {
       
   602             HlpLauncher::LaunchHelpApplicationL
       
   603                 ( iEikonEnv->WsSession(), 
       
   604                 iEikonEnv->EikAppUi()->AppHelpContextL() );
       
   605 		    break;
       
   606             }
       
   607 
       
   608 #endif //__SERIES60_HELP
       
   609 
       
   610         case EPushSettingsDialogCmdBack:
       
   611         case EPushSettingsDialogCmdExit:
       
   612             {
       
   613             TryExitL( EPushSettingsDialogCmdAknExit );
       
   614             break;
       
   615             }
       
   616 
       
   617         case EPushSettingsDialogCmdAknExit:
       
   618             {
       
   619             STATIC_CAST( MEikCommandObserver*, iEikonEnv->EikAppUi() )->
       
   620                 ProcessCommandL( EPushSettingsDialogCmdAknExit );
       
   621             break;
       
   622             }
       
   623 
       
   624         default:
       
   625             {
       
   626             break;
       
   627             }
       
   628         }
       
   629     }
       
   630 
       
   631 // ---------------------------------------------------------
       
   632 // CPushSettingsDialog::OkToExitL
       
   633 // ---------------------------------------------------------
       
   634 //
       
   635 TBool CPushSettingsDialog::OkToExitL( TInt aButtonId )
       
   636     {
       
   637     TBool ret( EFalse );
       
   638 
       
   639     switch ( aButtonId )
       
   640         {
       
   641         case EPushSettingsDialogCmdOptions:
       
   642             {
       
   643             if ( !MenuShowing() )
       
   644                 {
       
   645                 DisplayMenuL();
       
   646                 }
       
   647             break;
       
   648             }
       
   649         case EPushSettingsDialogCmdChangeWithoutSettingPage:
       
   650             {
       
   651             ChangeCurrentSettingWithoutSettingPageL();
       
   652             break;
       
   653             }
       
   654         case EPushSettingsDialogCmdBack:
       
   655         case EPushSettingsDialogCmdExit:
       
   656         case EPushSettingsDialogCmdAknExit:
       
   657             {
       
   658             RestoreStatusPaneL();
       
   659             ret = ETrue;
       
   660             break;
       
   661             }
       
   662         default:
       
   663             {
       
   664             break;
       
   665             }
       
   666         }
       
   667 
       
   668     return ret;
       
   669     }
       
   670 
       
   671 // ---------------------------------------------------------
       
   672 // CPushSettingsDialog::HandleListBoxEventL
       
   673 // ---------------------------------------------------------
       
   674 //
       
   675 void CPushSettingsDialog::HandleListBoxEventL
       
   676 ( CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
   677 	{
       
   678 	// Generate change command only if double tapped/center key is pressed. 
       
   679 	//Removed single tap check from here
       
   680 	if ( aEventType == EEventEnterKeyPressed || 
       
   681          aEventType == EEventItemDoubleClicked )
       
   682         {
       
   683         ProcessCommandL( EPushSettingsDialogCmdChangeWithoutSettingPage );
       
   684         }
       
   685 	}
       
   686 
       
   687 #ifdef __SERIES60_HELP
       
   688 // ---------------------------------------------------------
       
   689 // CPushSettingsDialog::GetHelpContext
       
   690 // ---------------------------------------------------------
       
   691 //
       
   692 void CPushSettingsDialog::GetHelpContext( TCoeHelpContext& aContext ) const
       
   693     {
       
   694     aContext.iMajor = TUid::Uid( EUidPushViewerApp );
       
   695 	aContext.iContext = KWPUSH_HLP_SETTINGS;
       
   696     }
       
   697 #endif //__SERIES60_HELP
       
   698 
       
   699 // End of file.