wlansecuritysettings/wlaneapsettingsui/EapGtc/ConfigUi/src/EapGtcUiView.cpp
branchRCL_3
changeset 18 bad0cc58d154
parent 17 30e048a7b597
child 19 c74b3d9f6b9e
equal deleted inserted replaced
17:30e048a7b597 18:bad0cc58d154
     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 GTC UI settings dialog
       
    15 *
       
    16 */
       
    17 
       
    18 /*
       
    19 * %version: 28 %
       
    20 */
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <eikdialg.h>
       
    24 #include <AknDialog.h>
       
    25 #include <aknlists.h>
       
    26 #include <eapgtcui.rsg>
       
    27 #include <akntextsettingpage.h>
       
    28 #include <aknsettingitemlist.h>
       
    29 #include <aknnavide.h>
       
    30 #include <aknnotewrappers.h> // TEMPORARY, for info message...
       
    31 #include <EapGtcUiConnection.h>
       
    32 #include <EapGtcUiDataConnection.h>
       
    33 #include <EapGtcUiGtcData.h>
       
    34 
       
    35 #include "EapGtcUiView.h"
       
    36 #include "EapGtcUi.hrh"
       
    37 #include "EapGtcUiSettingArray.h"
       
    38 
       
    39 #include <featmgr.h>
       
    40 #include <hlplch.h>
       
    41 #include <csxhelp/cp.hlp.hrh>
       
    42 
       
    43 
       
    44 // CONSTANTS
       
    45 // UID of general settings app, in which help texts are included
       
    46 const TUid KHelpUidPlugin = { 0x100058EC };
       
    47 
       
    48 _LIT( KEmptyString, "" );
       
    49 
       
    50 // MODULE DATA STRUCTURES
       
    51 enum 
       
    52     {
       
    53     EUsernameItem = 0
       
    54     };
       
    55 
       
    56 
       
    57 // ============================ MEMBER FUNCTIONS ===============================
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CEapGtcUiDialog::CEapGtcUiDialog
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CEapGtcUiDialog::CEapGtcUiDialog( CEapGtcUiConnection* aConnection, 
       
    64 								  TInt& aButtonId ) 
       
    65 : CAknDialog(),
       
    66   iConnection( aConnection ),
       
    67   iDataConnection( 0 ), 
       
    68   iSettingArray( 0 ), 
       
    69   iSettingListBox( 0 ), 
       
    70   iSettingListItemDrawer( 0 ), 
       
    71   iNaviPane( 0 ), 
       
    72   iNaviDecorator( 0 ), 
       
    73   iPreviousText( 0 ), 
       
    74   iButtonId( &aButtonId ),
       
    75   iIsUIConstructionCompleted( EFalse )
       
    76     {
       
    77     }
       
    78 
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // CEapGtcUiDialog::ConstructAndRunLD
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 TInt CEapGtcUiDialog::ConstructAndRunLD( TInt aResourceId )
       
    85     {
       
    86     CleanupStack::PushL( this );
       
    87     iSettingArray = CEapGtcSettingItemArray::NewL();
       
    88 
       
    89     User::LeaveIfError( iConnection->Connect() );
       
    90 
       
    91     iDataConnection = iConnection->GetDataConnection();
       
    92     if ( iDataConnection == 0 )
       
    93         {
       
    94         User::Leave( KErrNoMemory );
       
    95         }
       
    96     User::LeaveIfError( iDataConnection->Open() );
       
    97     User::LeaveIfError( iDataConnection->GetData( &iUiData ) );
       
    98 
       
    99     FeatureManager::InitializeLibL();
       
   100 
       
   101     ConstructL( R_GTC_MENUBAR );
       
   102     
       
   103     // ExecuteLD will PushL( this ), so we have to Pop it...
       
   104     CleanupStack::Pop( this ); // this
       
   105     
       
   106     return CAknDialog::ExecuteLD( aResourceId );
       
   107     }
       
   108 
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CEapGtcUiDialog::~CEapGtcUiDialog
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 CEapGtcUiDialog::~CEapGtcUiDialog()
       
   115     {
       
   116     if ( iNaviDecorator )
       
   117         {
       
   118         delete iNaviDecorator;
       
   119         iNaviDecorator = NULL;
       
   120         }
       
   121 
       
   122     if ( iSettingArray )
       
   123         {
       
   124         iSettingArray->Array()->ResetAndDestroy();
       
   125         delete iSettingArray;
       
   126         }
       
   127 
       
   128     if ( iSettingListBox )
       
   129         {
       
   130         iSettingListBox = 0;
       
   131         }
       
   132 
       
   133     if ( iSettingListItemDrawer )
       
   134         {
       
   135         iSettingListItemDrawer = 0;
       
   136         }
       
   137 
       
   138     if ( iDataConnection )
       
   139         {
       
   140         iDataConnection->Close();
       
   141         delete iDataConnection;
       
   142         }
       
   143 
       
   144     if ( iConnection )
       
   145         {
       
   146         iConnection->Close();
       
   147         }
       
   148 
       
   149     delete iPreviousText;
       
   150     
       
   151     FeatureManager::UnInitializeLib();
       
   152     }
       
   153     
       
   154 // ---------------------------------------------------------
       
   155 // CEapGtcUiDialog::HandleListBoxEventL
       
   156 // ---------------------------------------------------------
       
   157 //
       
   158 void CEapGtcUiDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/,
       
   159                                                    TListBoxEvent aEventType )
       
   160     {
       
   161     switch ( aEventType )
       
   162         {
       
   163         case EEventEnterKeyPressed:
       
   164         case EEventItemSingleClicked:
       
   165             {
       
   166             OkToExitL( EGtcUiCmdChange );         
       
   167             break;
       
   168             }
       
   169 
       
   170         case EEventItemActioned:
       
   171         case EEventEditingStarted:
       
   172         case EEventEditingStopped:
       
   173         case EEventPenDownOnItem:
       
   174         case EEventItemDraggingActioned:
       
   175             {
       
   176             break;
       
   177             }
       
   178 
       
   179         default:
       
   180             {
       
   181             break;
       
   182             };
       
   183         };
       
   184     }    
       
   185 
       
   186     
       
   187 // -----------------------------------------------------------------------------
       
   188 // CEapGtcUiDialog::PreLayoutDynInitL
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 void CEapGtcUiDialog::PreLayoutDynInitL()
       
   192     {
       
   193     TUid naviPaneUid;
       
   194     naviPaneUid.iUid = EEikStatusPaneUidNavi;
       
   195     CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   196     CEikStatusPaneBase::TPaneCapabilities subPane = 
       
   197                                 statusPane->PaneCapabilities( naviPaneUid );
       
   198 
       
   199     if ( subPane.IsPresent() && subPane.IsAppOwned() )
       
   200         {
       
   201         iNaviPane = static_cast<CAknNavigationControlContainer*>( 
       
   202                                         statusPane->ControlL( naviPaneUid ) );
       
   203 
       
   204         // Set empty text to hide tabs.
       
   205         iNaviDecorator = iNaviPane->CreateNavigationLabelL( KEmptyString );   
       
   206         iNaviPane->PushL( *iNaviDecorator );
       
   207         }
       
   208 
       
   209     // Change title
       
   210     ChangeTitleL( ETrue );
       
   211 
       
   212     iSettingListBox = static_cast<CAknSettingStyleListBox*>( 
       
   213                                         ControlOrNull( EGtcSettingsListBox ) );
       
   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 // CEapGtcUiDialog::ShowSettingPageL
       
   230 // -----------------------------------------------------------------------------
       
   231 //
       
   232 void CEapGtcUiDialog::ShowSettingPageL( TInt aCalledFromMenu ) 
       
   233     {
       
   234     TInt index = iSettingListBox->CurrentItemIndex();
       
   235     CAknSettingItem* item = iSettingArray->Array()->At( index );
       
   236     item->EditItemL( aCalledFromMenu );
       
   237     item->StoreL();
       
   238     DrawSettingsListL();
       
   239     }
       
   240 
       
   241 
       
   242 // -----------------------------------------------------------------------------
       
   243 // CEapGtcUiDialog::OkToExitL
       
   244 // -----------------------------------------------------------------------------
       
   245 //
       
   246 TBool CEapGtcUiDialog::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("CEapGtcUiDialog::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 EGtcUiCmdChange:
       
   288             {
       
   289             if( iIsUIConstructionCompleted )
       
   290 				{
       
   291     			ShowSettingPageL( EFalse );
       
   292 				}
       
   293 			else
       
   294 			    {
       
   295 				#if defined(_DEBUG) || defined(DEBUG)
       
   296 				RDebug::Print(_L("CEapGtcUiDialog::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 // CEapGtcUiDialog::DrawSettingsListL
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 void CEapGtcUiDialog::DrawSettingsListL()
       
   322     {  
       
   323     iSettingArray->Array()->ResetAndDestroy();
       
   324     TInt ordinal = 0;
       
   325     iSettingArray->AddTextItemL( iUiData->GetIdentity(),
       
   326                                 EGtcSettingPageUsername,
       
   327                                 R_GTC_USERNAME_STRING,
       
   328                                 R_GTC_USERNAME_PAGE,
       
   329                                 NULL,
       
   330                                 ordinal++ );
       
   331 
       
   332     iSettingListBox->Model()->SetItemTextArray( iSettingArray->Array() );    
       
   333     iSettingListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   334     iSettingArray->Array()->RecalculateVisibleIndicesL();
       
   335     iSettingListBox->HandleItemAdditionL();
       
   336     iSettingListBox->UpdateScrollBarsL();
       
   337     }
       
   338 
       
   339 
       
   340 // -----------------------------------------------------------------------------
       
   341 // CEapGtcUiDialog::ChangeTitleL
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 void CEapGtcUiDialog::ChangeTitleL( TBool aIsStarted )
       
   345     {
       
   346     TUid titlePaneUid;
       
   347     titlePaneUid.iUid = EEikStatusPaneUidTitle;
       
   348 
       
   349     CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   350     CEikStatusPaneBase::TPaneCapabilities subPane = 
       
   351                                 statusPane->PaneCapabilities( titlePaneUid );
       
   352 
       
   353     if (subPane.IsPresent()&&subPane.IsAppOwned())
       
   354         {
       
   355         CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( 
       
   356                                         statusPane->ControlL( titlePaneUid ) );
       
   357         if ( aIsStarted )
       
   358             {
       
   359             // Store previous application title text
       
   360             const TDesC* prevText = titlePane->Text();  
       
   361             iPreviousText = HBufC::NewL( prevText->Length() );
       
   362             iPreviousText->Des().Append( *prevText );
       
   363             TDesC* titleText = iEikonEnv->AllocReadResourceLC( 
       
   364                                                         R_GTC_SETTINGS_TITLE );
       
   365             titlePane->SetTextL( *titleText );
       
   366             CleanupStack::PopAndDestroy( titleText ); 
       
   367             }
       
   368         else
       
   369             {
       
   370             // Set calling application title text back
       
   371             titlePane->SetTextL( *iPreviousText );  
       
   372             iNaviPane->Pop( iNaviDecorator );
       
   373             }
       
   374         }
       
   375     }
       
   376 
       
   377 
       
   378 // -----------------------------------------------------------------------------
       
   379 // CEapGtcUiDialog::DynInitMenuPaneL
       
   380 // -----------------------------------------------------------------------------
       
   381 //
       
   382 void CEapGtcUiDialog::DynInitMenuPaneL( TInt aResourceId, 
       
   383                                          CEikMenuPane* aMenuPane )
       
   384     {
       
   385     CAknDialog::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   386 
       
   387     if ( aResourceId == R_GTC_MENU_PANE )
       
   388         {
       
   389         if ( aMenuPane && !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   390             {
       
   391             aMenuPane->DeleteMenuItem( EAknCmdHelp );
       
   392             }
       
   393         }
       
   394     }
       
   395 
       
   396 
       
   397 // -----------------------------------------------------------------------------
       
   398 // CEapGtcUiDialog::ProcessCommandL
       
   399 // -----------------------------------------------------------------------------
       
   400 //
       
   401 void CEapGtcUiDialog::ProcessCommandL( TInt aCommand )
       
   402     {
       
   403     if ( MenuShowing() )
       
   404         {
       
   405         HideMenu();
       
   406         }
       
   407 
       
   408     switch( aCommand )
       
   409         {
       
   410         case EAknCmdExit:
       
   411             {
       
   412             TryExitL( aCommand );
       
   413             break;
       
   414             }
       
   415 
       
   416         case EAknCmdHelp:
       
   417             {
       
   418             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   419                                     iEikonEnv->EikAppUi()->AppHelpContextL() );
       
   420             break;
       
   421             }
       
   422 
       
   423         case EGtcUiCmdChange:
       
   424             {
       
   425             if( iIsUIConstructionCompleted )
       
   426 				{
       
   427     			ShowSettingPageL( ETrue );
       
   428 				}
       
   429 			else
       
   430 			    {
       
   431 				#if defined(_DEBUG) || defined(DEBUG)
       
   432 				RDebug::Print(_L("CEapGtcUiDialog::ProcessCommandL - UI not ready - Ignoring key press.\n") );
       
   433 				#endif						
       
   434 			    }
       
   435             break;
       
   436             }
       
   437 
       
   438         default:
       
   439             {
       
   440             break;
       
   441             }
       
   442         }
       
   443     }
       
   444 
       
   445 
       
   446 // -----------------------------------------------------------------------------
       
   447 // CEapGtcUiDialog::GetHelpContext
       
   448 // -----------------------------------------------------------------------------
       
   449 //
       
   450 void CEapGtcUiDialog::GetHelpContext( TCoeHelpContext& aContext ) const
       
   451     {
       
   452     aContext.iMajor = KHelpUidPlugin;
       
   453     aContext.iContext = KSET_HLP_WLAN_EAP_GTC;
       
   454     }
       
   455 
       
   456 
       
   457 //  End of File