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