wlansecuritysettings/wlaneapsettingsui/EapSim/ConfigUi/src/EapSimUiView.cpp
branchRCL_3
changeset 46 c74b3d9f6b9e
equal deleted inserted replaced
45:bad0cc58d154 46:c74b3d9f6b9e
       
     1 /*
       
     2 * Copyright (c) 2001-2010 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: Implementation of EAP SIM UI settings dialog
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 29 %
       
    20 */
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <eikdialg.h>
       
    24 #include <AknDialog.h>
       
    25 #include <aknlists.h>
       
    26 #include "EapSimUiView.h"
       
    27 #include "EapSimUi.hrh"
       
    28 #include <eapsimui.rsg>
       
    29 #include <akntextsettingpage.h>
       
    30 #include <aknsettingitemlist.h>
       
    31 #include "EapSimUiSettingArray.h"
       
    32 #include <aknnotewrappers.h> // For info message
       
    33 #include <aknnavide.h>
       
    34 #include <EapSimUiConnection.h>
       
    35 #include <EapSimUiDataConnection.h>
       
    36 #include <EapSimUiSimData.h>
       
    37 
       
    38 #include <featmgr.h>
       
    39 #include <hlplch.h>
       
    40 #include <csxhelp/cp.hlp.hrh>
       
    41 
       
    42 
       
    43 // CONSTANTS
       
    44 // UID of general settings app, in which help texts are included
       
    45 const TUid KHelpUidPlugin = { 0x100058EC };
       
    46 
       
    47 _LIT( KEmptyString, "" );
       
    48 
       
    49 // MODULE DATA STRUCTURES
       
    50 enum 
       
    51     {
       
    52     EUsernameInUseItem = 0,
       
    53     EUsernameItem,
       
    54     ERealmInUseItem,
       
    55     ERealmItem
       
    56     };
       
    57 
       
    58 
       
    59 // ============================ MEMBER FUNCTIONS ===============================
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CEapSimUiDialog::CEapSimUiDialog
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CEapSimUiDialog::CEapSimUiDialog( CEapSimUiConnection* aConnection, 
       
    66 								  TInt& aButtonId ) 
       
    67 : CAknDialog(),
       
    68   iConnection( aConnection ),
       
    69   iUiData( 0 ), 
       
    70   iDataConnection( 0 ), 
       
    71   iSettingArray( 0 ), 
       
    72   iSettingListBox( 0 ), 
       
    73   iSettingListItemDrawer( 0 ), 
       
    74   iNaviPane( 0 ), 
       
    75   iNaviDecorator( 0 ), 
       
    76   iPreviousText( 0 ), 
       
    77   iButtonId( &aButtonId ),
       
    78   iIsUIConstructionCompleted( EFalse )
       
    79     {
       
    80     }
       
    81 
       
    82 
       
    83 // ---------------------------------------------------------
       
    84 // CEapSimUiDialog::ConstructAndRunLD
       
    85 // ---------------------------------------------------------
       
    86 //
       
    87 TInt CEapSimUiDialog::ConstructAndRunLD( TInt aResourceId )
       
    88     {
       
    89     CleanupStack::PushL( this );
       
    90 
       
    91     iSettingArray = CEapSimSettingItemArray::NewL();
       
    92 
       
    93     User::LeaveIfError( iConnection->Connect() );
       
    94     iDataConnection = iConnection->GetDataConnection();
       
    95     if ( iDataConnection == 0 )
       
    96         {
       
    97         User::Leave( KErrNoMemory );
       
    98         }
       
    99 
       
   100     User::LeaveIfError( iDataConnection->Open() );
       
   101     User::LeaveIfError( iDataConnection->GetData( &iUiData ) );
       
   102 
       
   103     FeatureManager::InitializeLibL();
       
   104     
       
   105     ConstructL( R_SIM_MENUBAR );
       
   106     
       
   107     // ExecuteLD will PushL( this ), so we have to Pop it...
       
   108     CleanupStack::Pop( this ); // this
       
   109     
       
   110     return CAknDialog::ExecuteLD( aResourceId );
       
   111     }
       
   112 
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CEapSimUiDialog::~CEapSimUiDialog
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 CEapSimUiDialog::~CEapSimUiDialog()
       
   119     {
       
   120     if ( iNaviDecorator )
       
   121         {
       
   122         delete iNaviDecorator;
       
   123         iNaviDecorator = NULL;
       
   124         }
       
   125 
       
   126     if ( iSettingArray )
       
   127         {
       
   128         iSettingArray->Array()->ResetAndDestroy();
       
   129         delete iSettingArray;
       
   130         }
       
   131 
       
   132     if ( iSettingListBox )
       
   133         {
       
   134         iSettingListBox = 0;
       
   135         }
       
   136 
       
   137     if ( iSettingListItemDrawer )
       
   138         {
       
   139         iSettingListItemDrawer = 0;
       
   140         }
       
   141 
       
   142     if ( iDataConnection )
       
   143         {
       
   144         iDataConnection->Close();
       
   145         delete iDataConnection;
       
   146         }
       
   147 
       
   148     if ( iConnection )
       
   149         {
       
   150         iConnection->Close();
       
   151         }
       
   152 
       
   153     delete iPreviousText;
       
   154     
       
   155     FeatureManager::UnInitializeLib();
       
   156     }
       
   157 
       
   158 // ---------------------------------------------------------
       
   159 // CEapSimUiDialog::HandleListBoxEventL
       
   160 // ---------------------------------------------------------
       
   161 //
       
   162 void CEapSimUiDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/,
       
   163                                                    TListBoxEvent aEventType )
       
   164     {
       
   165     switch ( aEventType )
       
   166         {
       
   167         case EEventEnterKeyPressed:
       
   168         case EEventItemSingleClicked:
       
   169             {
       
   170             OkToExitL( ESimUiCmdChange );         
       
   171             break;
       
   172             }
       
   173 
       
   174         case EEventItemActioned:
       
   175         case EEventEditingStarted:
       
   176         case EEventEditingStopped:
       
   177         case EEventPenDownOnItem:
       
   178         case EEventItemDraggingActioned:
       
   179             {
       
   180             break;
       
   181             }
       
   182 
       
   183         default:
       
   184             {
       
   185             break;
       
   186             };
       
   187         };
       
   188     }    
       
   189 
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CEapSimUiDialog::PreLayoutDynInitL
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 void CEapSimUiDialog::PreLayoutDynInitL()
       
   196     {
       
   197     ChangeTitleL( ETrue );
       
   198     
       
   199     TUid naviPaneUid;
       
   200     naviPaneUid.iUid = EEikStatusPaneUidNavi;
       
   201     CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   202     CEikStatusPaneBase::TPaneCapabilities subPane = 
       
   203                                 statusPane->PaneCapabilities( naviPaneUid );
       
   204     if ( subPane.IsPresent()&&subPane.IsAppOwned() )
       
   205         {
       
   206         iNaviPane = static_cast<CAknNavigationControlContainer*>( 
       
   207                                         statusPane->ControlL( naviPaneUid ) );
       
   208 
       
   209         // Set empty text to hide tabs.
       
   210         iNaviDecorator = iNaviPane->CreateNavigationLabelL( KEmptyString );
       
   211         iNaviPane->PushL( *iNaviDecorator );
       
   212         }            
       
   213         
       
   214     iSettingListBox = static_cast<CAknSettingStyleListBox*>( 
       
   215                                         ControlOrNull( ESimSettingsListBox ) );
       
   216     iSettingListItemDrawer=static_cast<CSettingsListBoxItemDrawer*>( 
       
   217                                             iSettingListBox->ItemDrawer() );
       
   218     iSettingListBox->SetMopParent( this );
       
   219     iSettingListBox->CreateScrollBarFrameL( ETrue );
       
   220     iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   221                                                 CEikScrollBarFrame::EOff,
       
   222                                                 CEikScrollBarFrame::EAuto );
       
   223     iSettingListBox->SetListBoxObserver( this );                                                
       
   224     DrawSettingsListL();
       
   225     
       
   226     iIsUIConstructionCompleted = ETrue;
       
   227     }
       
   228 
       
   229 
       
   230 // -----------------------------------------------------------------------------
       
   231 // CEapSimUiDialog::ShowSettingPageL
       
   232 // -----------------------------------------------------------------------------
       
   233 //
       
   234 void CEapSimUiDialog::ShowSettingPageL( TInt aCalledFromMenu ) 
       
   235     {
       
   236     TInt index = iSettingListBox->CurrentItemIndex();
       
   237     CAknSettingItem* item = iSettingArray->Array()->At( index );
       
   238     item->EditItemL( aCalledFromMenu );
       
   239     item->StoreL();
       
   240     DrawNow();
       
   241     }
       
   242 
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // CEapSimUiDialog::OkToExitL
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 TBool CEapSimUiDialog::OkToExitL( TInt aButtonId )
       
   249     {
       
   250     TBool ret( EFalse );
       
   251     switch ( aButtonId )
       
   252         {
       
   253         case EEikBidOk:
       
   254             {
       
   255             if( iIsUIConstructionCompleted )
       
   256                 {
       
   257                 if ( iSettingListBox->IsFocused() )
       
   258                     {
       
   259                     ShowSettingPageL( EFalse );
       
   260                     }
       
   261                 }
       
   262             else
       
   263                 {
       
   264                 #if defined(_DEBUG) || defined(DEBUG)
       
   265 				RDebug::Print(_L("CEapSimUiDialog::OkToExitL - UI not ready - Ignoring key press.\n") );
       
   266 				#endif
       
   267                 }
       
   268             break;
       
   269             }
       
   270 
       
   271         case EAknSoftkeyOptions:
       
   272             {
       
   273             DisplayMenuL();
       
   274             break;
       
   275             }
       
   276 
       
   277         case EAknSoftkeyBack:
       
   278         case EAknCmdExit:
       
   279             {
       
   280             if( iIsUIConstructionCompleted )
       
   281                 {
       
   282                 iDataConnection->Update();
       
   283                 ChangeTitleL( EFalse );
       
   284                 ret = ETrue;
       
   285                 }
       
   286             break;
       
   287             }
       
   288         
       
   289         case ESimUiCmdChange:
       
   290             {
       
   291             if( iIsUIConstructionCompleted )
       
   292 				{
       
   293     			ShowSettingPageL( EFalse );
       
   294 				}
       
   295 			else
       
   296 			    {
       
   297 				#if defined(_DEBUG) || defined(DEBUG)
       
   298 				RDebug::Print(_L("CEapSimUiDialog::ProcessCommandL - UI not ready - Ignoring key press.\n") );
       
   299 				#endif						
       
   300 			    }
       
   301             break;
       
   302             }
       
   303 
       
   304         default:
       
   305             {
       
   306             break;
       
   307             }
       
   308         }
       
   309 
       
   310     if ( ret )
       
   311         {
       
   312         *iButtonId = aButtonId;
       
   313         }
       
   314 
       
   315     return ret;
       
   316     }
       
   317 
       
   318 
       
   319 // -----------------------------------------------------------------------------
       
   320 // CEapSimUiDialog::DrawSettingsListL
       
   321 // -----------------------------------------------------------------------------
       
   322 //
       
   323 void CEapSimUiDialog::DrawSettingsListL()
       
   324     {  
       
   325     iSettingArray->Array()->ResetAndDestroy();
       
   326     TInt ordinal = 0;
       
   327     iSettingArray->AddBinarySettingItemL( R_SIM_DISPLAY_AUTOUSECONF_PAGE,
       
   328                                           R_SIM_USERNAME_INUSESTRING, 
       
   329                                           R_SIM_USERNAME_AUTOUSECONF_TEXTS,
       
   330                                           ordinal++,
       
   331                                           *iUiData->GetUseManualUsername() );
       
   332 
       
   333     iSettingArray->AddTextItemL( iUiData->GetManualUsername(),
       
   334                                  ESimSettingPageUsername,
       
   335                                  R_SIM_USERNAME_STRING,
       
   336                                  R_SIM_USERNAME_PAGE,
       
   337                                  NULL,
       
   338                                  ordinal++ );
       
   339 
       
   340     iSettingArray->AddBinarySettingItemL( R_SIM_DISPLAY_AUTOUSECONF_PAGE,
       
   341                                           R_SIM_REALM_INUSESTRING, 
       
   342                                           R_SIM_REALM_AUTOUSECONF_TEXTS,
       
   343                                           ordinal++,
       
   344                                           *iUiData->GetUseManualRealm() );
       
   345 
       
   346     iSettingArray->AddTextItemL( iUiData->GetManualRealm(),
       
   347                                  ESimSettingUsernameSettingId,
       
   348                                  R_SIM_REALM_STRING,
       
   349                                  R_SIM_REALM_PAGE,
       
   350                                  NULL,
       
   351                                  ordinal++ );
       
   352 
       
   353     iSettingListBox->Model()->SetItemTextArray( iSettingArray->Array() );
       
   354     iSettingListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   355     iSettingArray->Array()->RecalculateVisibleIndicesL();
       
   356     iSettingListBox->HandleItemAdditionL();
       
   357     iSettingListBox->UpdateScrollBarsL();
       
   358     }
       
   359 
       
   360 
       
   361 // -----------------------------------------------------------------------------
       
   362 // CEapSimUiDialog::ChangeTitleL
       
   363 // -----------------------------------------------------------------------------
       
   364 //
       
   365 void CEapSimUiDialog::ChangeTitleL( TBool aIsStarted )
       
   366     {
       
   367     TUid titlePaneUid;
       
   368     titlePaneUid.iUid = EEikStatusPaneUidTitle;
       
   369 
       
   370     CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   371     CEikStatusPaneBase::TPaneCapabilities subPane = 
       
   372                                 statusPane->PaneCapabilities( titlePaneUid );
       
   373     
       
   374     if ( subPane.IsPresent() && subPane.IsAppOwned() )
       
   375         {
       
   376         CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( 
       
   377                                         statusPane->ControlL( titlePaneUid ) );
       
   378         if ( aIsStarted )
       
   379             {
       
   380             // Store previous application title text
       
   381             const TDesC* prevText = titlePane->Text();    
       
   382 
       
   383             iPreviousText = HBufC::NewL( prevText->Length() );
       
   384             iPreviousText->Des().Append( *prevText );
       
   385             TDesC* titleText = iEikonEnv->AllocReadResourceLC( 
       
   386                                                         R_SIM_SETTINGS_TITLE );
       
   387             titlePane->SetTextL( *titleText );
       
   388             CleanupStack::PopAndDestroy( titleText ); 
       
   389             }
       
   390         else
       
   391             {
       
   392             // Set calling application title text back
       
   393             titlePane->SetTextL( *iPreviousText );
       
   394             // pop navidecorator when exiting
       
   395             iNaviPane->Pop( iNaviDecorator );    
       
   396             }    
       
   397         }
       
   398     }
       
   399 
       
   400 
       
   401 // -----------------------------------------------------------------------------
       
   402 // CEapSimUiDialog::DynInitMenuPaneL
       
   403 // -----------------------------------------------------------------------------
       
   404 //
       
   405 void CEapSimUiDialog::DynInitMenuPaneL( TInt aResourceId, 
       
   406                                          CEikMenuPane* aMenuPane )
       
   407     {
       
   408     CAknDialog::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   409 
       
   410     if ( aResourceId == R_SIM_MENU_PANE )
       
   411         {
       
   412         if ( aMenuPane && !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   413             {
       
   414             aMenuPane->DeleteMenuItem( EAknCmdHelp );
       
   415             }
       
   416         }
       
   417     }
       
   418 
       
   419 
       
   420 // -----------------------------------------------------------------------------
       
   421 // CEapSimUiDialog::ProcessCommandL
       
   422 // -----------------------------------------------------------------------------
       
   423 //
       
   424 void CEapSimUiDialog::ProcessCommandL( TInt aCommand )
       
   425     {
       
   426     if ( MenuShowing() )
       
   427         {
       
   428         HideMenu();
       
   429         }
       
   430 
       
   431     switch( aCommand )
       
   432         {
       
   433         case EAknCmdExit:
       
   434             {
       
   435             TryExitL( aCommand );
       
   436             break;
       
   437             }
       
   438 
       
   439         case EAknCmdHelp:
       
   440             {
       
   441             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   442                                     iEikonEnv->EikAppUi()->AppHelpContextL() );
       
   443             break;
       
   444             }
       
   445 
       
   446         case ESimUiCmdChange:
       
   447             {
       
   448             if( iIsUIConstructionCompleted )
       
   449 				{
       
   450     			ShowSettingPageL( ETrue );
       
   451 				}
       
   452 			else
       
   453 			    {
       
   454 				#if defined(_DEBUG) || defined(DEBUG)
       
   455 				RDebug::Print(_L("CEapSimUiDialog::ProcessCommandL - UI not ready - Ignoring key press.\n") );
       
   456 				#endif						
       
   457 			    }
       
   458             break;
       
   459             }
       
   460 
       
   461         default:
       
   462             {
       
   463             break;
       
   464             }
       
   465         }
       
   466     }
       
   467 
       
   468 
       
   469 // -----------------------------------------------------------------------------
       
   470 // CEapSimUiDialog::GetHelpContext
       
   471 // -----------------------------------------------------------------------------
       
   472 //
       
   473 void CEapSimUiDialog::GetHelpContext( TCoeHelpContext& aContext ) const
       
   474     {
       
   475     aContext.iMajor = KHelpUidPlugin;
       
   476     aContext.iContext = KSET_HLP_WLAN_EAP_SIM;
       
   477     }
       
   478     
       
   479 
       
   480 //  End of File