wlansecuritysettings/wlaneapsettingsui/EapTtls/ConfigUi/src/EapTtlsUiView.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 TTLS 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 "EapTtlsUiView.h"
       
    25 #include "EapTtlsUi.hrh"
       
    26 #include <EapTtlsUi.rsg>
       
    27 #include <akntextsettingpage.h>
       
    28 #include <aknsettingitemlist.h>
       
    29 #include "EapTtlsUiSettingArray.h"
       
    30 #include <aknnavi.h>
       
    31 #include <akntabgrp.h>
       
    32 #include <aknnavide.h>
       
    33 #include <aknradiobuttonsettingpage.h>
       
    34 #include <StringLoader.h>
       
    35 #include <aknnotewrappers.h>
       
    36 #include <EapTlsPeapUiCipherSuites.h>
       
    37 #include <EapTlsPeapUiEapTypes.h>
       
    38 #include <EapTlsPeapUiCertificates.h>
       
    39 #include <EapType.h>
       
    40 #include <EapTypeInfo.h> 
       
    41 #include <AknIconArray.h>
       
    42 #include <AknsUtils.h>
       
    43 
       
    44 #include <FeatMgr.h>
       
    45 #include <hlplch.h>
       
    46 #include <csxhelp/cp.hlp.hrh>
       
    47 
       
    48 
       
    49 // CONSTANTS
       
    50 // UID of general settings app, in which help texts are included
       
    51 const TUid KHelpUidPlugin = { 0x100058EC };
       
    52 
       
    53 static const TInt KSettingArrayGranularity = 4;    
       
    54 static const TInt KSuiteArrayGranularity = 5;
       
    55 static const TInt KMaxLengthOfEapLine = 270;
       
    56 static const TInt KCertificateArrayGranularity = 5;
       
    57 static const TInt KMaxLengthOfSuiteName = 255;
       
    58 static const TInt KEapTtlsId = 21;
       
    59 
       
    60 _LIT( KNameSeparator, " " );
       
    61 _LIT( KEmptyString, "" );
       
    62 const TUint KFirstElement = 0;
       
    63 const TUint KSecondElement = 1;
       
    64 const TUint KMinEnabledCount = 1;
       
    65 
       
    66 /* This is the maximum length of a certificate's full name, includes
       
    67 label, primary and secondary names */
       
    68 const TUint32 KMaxFullCertLabelLength = KMaxCertLabelLength + 2 * 
       
    69                                     KMaxNameLength + 1; // 1 is for separator.
       
    70 
       
    71 // MODULE DATA STRUCTURES
       
    72 enum TPageIds
       
    73     {
       
    74     ESettingsPage = 0,
       
    75     EEapTypePage,
       
    76     ECipherSuitePage
       
    77     };
       
    78 
       
    79 enum TSettingIds
       
    80     {
       
    81     EUserCertificateItem = 0,
       
    82     ECaCertificateItem,
       
    83     EUsernameInUseItem,
       
    84     EUsernameItem,
       
    85     ERealmInUseItem,
       
    86     ERealmItem
       
    87     };
       
    88 
       
    89 
       
    90 // ============================ MEMBER FUNCTIONS ===============================
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CEapTtlsUiDialog::CEapTtlsUiDialog
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 CEapTtlsUiDialog::CEapTtlsUiDialog( CEapTlsPeapUiConnection* aConnection,
       
    97                                     TIndexType aIndexType, TInt aIndex, 
       
    98 								    TInt& aButtonId ) 
       
    99 : CAknDialog(), 
       
   100   iConnection( aConnection ),
       
   101   iIndexType( aIndexType ), 
       
   102   iIndex( aIndex ), 
       
   103   iButtonId( &aButtonId ),
       
   104   iIsUIConstructionCompleted( EFalse ),
       
   105   iExiting( EFalse )
       
   106     {
       
   107     }
       
   108 
       
   109 
       
   110 // ---------------------------------------------------------
       
   111 // CEapTtlsUiDialog::ConstructAndRunLD
       
   112 // ---------------------------------------------------------
       
   113 //
       
   114 TInt CEapTtlsUiDialog::ConstructAndRunLD( TInt aResourceId )
       
   115     {
       
   116     CleanupStack::PushL( this );
       
   117 
       
   118     iSettingArray = CEapTtlsSettingItemArray::NewL();
       
   119 
       
   120     User::LeaveIfError( iConnection->Connect() );
       
   121 
       
   122     // Basic data
       
   123     iDataConnection = iConnection->GetDataConnection();
       
   124     if ( iDataConnection == 0 )
       
   125         {
       
   126         User::Leave( KErrNoMemory );
       
   127         }
       
   128     User::LeaveIfError( iDataConnection->Open() );
       
   129     User::LeaveIfError( iDataConnection->GetData( &iUiData ) );
       
   130     
       
   131     // Cipher suites
       
   132     iCipherSuites = iConnection->GetCipherSuiteConnection();
       
   133     if ( iCipherSuites == 0 )
       
   134         {
       
   135         User::Leave( KErrNoMemory );
       
   136         }
       
   137 
       
   138     User::LeaveIfError( iCipherSuites->Open() );
       
   139     User::LeaveIfError( iCipherSuites->GetCipherSuites( &iUiCipherSuites ) );
       
   140 
       
   141     iCipherSuitesViewArray = new( ELeave ) CDesCArrayFlat( 
       
   142                                                     KSuiteArrayGranularity );
       
   143     //EAP types 
       
   144     iEapTypes = iConnection->GetEapTypeConnection();
       
   145     if ( iEapTypes == 0 )
       
   146         {
       
   147         User::Leave( KErrNoMemory );
       
   148         }
       
   149     User::LeaveIfError( iEapTypes->Open() );
       
   150     User::LeaveIfError( iEapTypes->GetEapTypes( &iUiEapTypes ) );
       
   151     if ( iUiEapTypes->Count() == 0 )
       
   152         {
       
   153         CreateEapTypeDataBaseL();
       
   154         }
       
   155 
       
   156     iEapTypeViewArray = new( ELeave ) CDesCArrayFlat( 
       
   157                                                     KSettingArrayGranularity );
       
   158 
       
   159     FeatureManager::InitializeLibL();
       
   160 
       
   161     ConstructL( R_TTLS_MENUBAR );
       
   162     
       
   163     // ExecuteLD will PushL( this ), so we have to Pop it...
       
   164     CleanupStack::Pop( this ); // this
       
   165     
       
   166     return CAknDialog::ExecuteLD( aResourceId );
       
   167     }
       
   168 
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CEapTtlsUiDialog::OfferKeyEventL
       
   172 // -----------------------------------------------------------------------------
       
   173 //
       
   174 TKeyResponse CEapTtlsUiDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   175                                                      TEventCode aType )
       
   176     {
       
   177     TKeyResponse result( EKeyWasNotConsumed );
       
   178     
       
   179     // gently handle impatient users
       
   180 	if ( !iIsUIConstructionCompleted )
       
   181         {
       
   182         return CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   183         }
       
   184     
       
   185     TInt pageId = ActivePageId();
       
   186     if ( aType == EEventKey && pageId == KEAPTTLSCIPHERPAGE )
       
   187         {
       
   188         TInt indexBefore = iCipherSuiteListBox->CurrentItemIndex();
       
   189         
       
   190         if ( aKeyEvent.iCode == EKeyEnter )
       
   191             {
       
   192             if ( ( *iUiCipherSuites )[indexBefore].iIsEnabled )
       
   193                 {
       
   194                 OkToExitL( ETtlsUiCmdDisable );
       
   195                 }
       
   196             else
       
   197                 {
       
   198                 OkToExitL( ETtlsUiCmdEnable );
       
   199                 }
       
   200                 
       
   201             result = EKeyWasConsumed;
       
   202             }
       
   203         else
       
   204             {        
       
   205             result = CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   206             }
       
   207             
       
   208         TInt indexAfter = iCipherSuiteListBox->CurrentItemIndex();
       
   209 
       
   210         if ( indexBefore != indexAfter )
       
   211             {
       
   212             CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
   213             if( ( *iUiCipherSuites )[ indexAfter ].iIsEnabled )
       
   214                 {
       
   215                 cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_DISABLE );
       
   216                 }
       
   217             else
       
   218                 {
       
   219                 cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_ENABLE );
       
   220                 }
       
   221             
       
   222             cba.DrawDeferred();
       
   223             }
       
   224         }
       
   225     else if ( aType == EEventKey && pageId == KEAPTTLSEAPPAGE )
       
   226         {
       
   227         TInt indexBefore = iEapTypesListBox->CurrentItemIndex();
       
   228         
       
   229         if ( aKeyEvent.iCode == EKeyEnter )
       
   230             {
       
   231             if ( ( *iUiEapTypes )[indexBefore].iIsEnabled )
       
   232                 {
       
   233                 OkToExitL( ETtlsUiCmdConfigure );
       
   234                 }
       
   235             else
       
   236                 {
       
   237                 OkToExitL( ETtlsUiCmdEnable );
       
   238                 }
       
   239                 
       
   240             result = EKeyWasConsumed;
       
   241             }
       
   242         else
       
   243             {        
       
   244             result = CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   245             }
       
   246             
       
   247         TInt indexAfter = iEapTypesListBox->CurrentItemIndex();
       
   248 
       
   249         if ( indexBefore != indexAfter )
       
   250             {
       
   251             CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
   252             if( ( *iUiEapTypes )[indexAfter].iIsEnabled )
       
   253                 {
       
   254                 cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_CONFIGURE );
       
   255                 }
       
   256             else
       
   257                 {
       
   258                 cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_ENABLE );
       
   259                 }
       
   260             
       
   261             cba.DrawDeferred();
       
   262             }        
       
   263         }
       
   264     else
       
   265         {
       
   266         result = CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   267         }
       
   268 
       
   269     return result;
       
   270     }
       
   271 
       
   272 
       
   273 // -----------------------------------------------------------------------------
       
   274 // CEapTtlsUiDialog::~CEapTtlsUiDialog
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 CEapTtlsUiDialog::~CEapTtlsUiDialog()
       
   278     {
       
   279      if ( iSettingArray )
       
   280         {
       
   281         iSettingArray->Array()->ResetAndDestroy();
       
   282         }
       
   283 
       
   284     delete iSettingArray;
       
   285 
       
   286     iSettingListBox = NULL;
       
   287     
       
   288     iDataConnection->Close();
       
   289     delete iDataConnection;
       
   290 
       
   291     iCipherSuitesViewArray->Reset();
       
   292     delete iCipherSuitesViewArray;    
       
   293 
       
   294     iEapTypeViewArray->Reset();
       
   295     delete iEapTypeViewArray;
       
   296 
       
   297 	iCertificates->Close();
       
   298 	delete iCertificates;
       
   299 
       
   300 	iCipherSuites->Close();
       
   301 	delete iCipherSuites;
       
   302 
       
   303 	iEapTypes->Close();
       
   304 	delete iEapTypes;
       
   305 
       
   306 	iConnection->Close();
       
   307     
       
   308     delete iPreviousText;
       
   309     
       
   310     FeatureManager::UnInitializeLib();
       
   311     }
       
   312     
       
   313     
       
   314 // ---------------------------------------------------------
       
   315 // CEapTtlsUiDialog::HandleListBoxEventL
       
   316 // ---------------------------------------------------------
       
   317 //
       
   318 void CEapTtlsUiDialog::HandleListBoxEventL( CEikListBox* aListBox,
       
   319                                             TListBoxEvent aEventType )
       
   320     {
       
   321     switch ( aEventType )
       
   322         {
       
   323         case EEventEnterKeyPressed:
       
   324         case EEventItemSingleClicked:
       
   325             {
       
   326             if ( aListBox == iSettingListBox )
       
   327                 {
       
   328                 OkToExitL( ETtlsUiCmdChange );                    
       
   329                 }
       
   330                 
       
   331             else if ( aListBox == iEapTypesListBox )
       
   332                 {
       
   333                 TInt index = iEapTypesListBox->CurrentItemIndex();
       
   334                 if ( iUiEapTypes->At( index ).iIsEnabled )
       
   335                     {
       
   336                     ConfigureL(ETrue);   
       
   337                     }
       
   338                 else
       
   339                     {
       
   340                     OkToExitL( ETtlsUiCmdEnable );
       
   341                     }                    
       
   342                 }
       
   343                                      
       
   344             else if ( aListBox == iCipherSuiteListBox )
       
   345                 {
       
   346                 TInt index = iCipherSuiteListBox->CurrentItemIndex();
       
   347                 if ( iUiCipherSuites->At( index ).iIsEnabled )
       
   348                     {
       
   349                     OkToExitL( ETtlsUiCmdDisable );
       
   350                     }
       
   351                 else
       
   352                     {
       
   353                     OkToExitL( ETtlsUiCmdEnable );
       
   354                     }
       
   355                 }
       
   356                 
       
   357             else
       
   358                 {
       
   359                 // Do nothing; we should never end up here
       
   360                 }
       
   361                         
       
   362             break;
       
   363             }
       
   364 
       
   365         case EEventItemActioned:
       
   366         case EEventEditingStarted:
       
   367         case EEventEditingStopped:
       
   368         case EEventPenDownOnItem:
       
   369         case EEventItemDraggingActioned:
       
   370             {
       
   371             break;
       
   372             }
       
   373 
       
   374         default:
       
   375             {
       
   376             break;
       
   377             };
       
   378         };
       
   379     }   
       
   380 
       
   381 
       
   382 // ---------------------------------------------------------
       
   383 // CEapTtlsUiDialog::HandleDialogPageEventL
       
   384 // ---------------------------------------------------------
       
   385 //
       
   386 void CEapTtlsUiDialog::HandleDialogPageEventL( TInt aEventID )
       
   387     {
       
   388      CAknDialog::HandleDialogPageEventL( aEventID );
       
   389          if( iExiting )
       
   390              {        
       
   391              // Exit requested. 
       
   392              TryExitL( EAknCmdExit );
       
   393              }   
       
   394      }
       
   395 
       
   396 
       
   397 // ---------------------------------------------------------
       
   398 // CEapTtlsUiDialog::ConfigureL
       
   399 // ---------------------------------------------------------
       
   400 //
       
   401 void CEapTtlsUiDialog::ConfigureL( TBool aQuick )
       
   402     {
       
   403     RImplInfoPtrArray eapArray;
       
   404     eapArray.Reset();
       
   405     REComSession::ListImplementationsL( KEapTypeInterfaceUid,
       
   406             eapArray );
       
   407     TInt itemIndex = iEapTypesListBox->CurrentItemIndex(); 
       
   408     TInt eapIndex( 0 );
       
   409     for ( TInt i = 0; i < eapArray.Count(); ++i )
       
   410         {
       
   411         CImplementationInformation* tempInfo = eapArray[i];
       
   412         if ( iUiEapTypes->At( itemIndex ).iEapType == 
       
   413         tempInfo->DataType() )
       
   414             {
       
   415             eapIndex = i;
       
   416             break;            
       
   417             }
       
   418         }   
       
   419 
       
   420     CEapType* eapType;
       
   421     eapType = CEapType::NewL( eapArray[eapIndex]->DataType(), 
       
   422             iIndexType, iIndex );
       
   423     eapArray.ResetAndDestroy();
       
   424     eapType->SetTunnelingType( KEapTtlsId );
       
   425     CleanupStack::PushL( eapType );
       
   426     TInt buttonId = eapType->InvokeUiL();
       
   427     CleanupStack::PopAndDestroy( eapType );
       
   428     if ( buttonId == EAknCmdExit || buttonId == EEikCmdExit )
       
   429         {
       
   430         if (aQuick == EFalse)
       
   431             {
       
   432             TryExitL( buttonId );
       
   433             }
       
   434         else
       
   435             {
       
   436             iExiting = ETrue;
       
   437             // Don't exit here. Framework command chain will
       
   438             // cause a KERN-EXEC 3 panic. Handle the exit in 
       
   439             // HandleDialogPageEventL(). 
       
   440             }
       
   441         }
       
   442     }
       
   443 
       
   444 
       
   445 // -----------------------------------------------------------------------------
       
   446 // CEapTtlsUiDialog::PreLayoutDynInitL
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 void CEapTtlsUiDialog::PreLayoutDynInitL()
       
   450     {
       
   451     // Change title
       
   452     ChangeTitleL( ETrue );
       
   453     
       
   454     iSettingListBox = static_cast<CAknSettingStyleListBox*>( 
       
   455                               ControlOrNull( ETtlsSettingsListbox ) );
       
   456     iSettingListBox->SetComponentsToInheritVisibility( ETrue );
       
   457     
       
   458     iEapTypesListBox = static_cast<CAknSingleNumberStyleListBox*>(
       
   459                               ControlOrNull( ETtlsSettingsEapTypeListbox ) );
       
   460     iEapTypesListBox->SetComponentsToInheritVisibility( ETrue );
       
   461 
       
   462     iCipherSuiteListBox = static_cast<CAknSingleNumberStyleListBox*>(
       
   463                                ControlOrNull( ETtlsSettingsCipherSuiteListbox ) );
       
   464     iCipherSuiteListBox->SetComponentsToInheritVisibility( ETrue );
       
   465     
       
   466     // Get certificates before building the UI. 
       
   467     // Will continue when certificates are received
       
   468     iCertificates = iConnection->GetCertificateConnection( this );
       
   469     User::LeaveIfError( iCertificates->Open() );
       
   470     iCertificates->GetCertificates( &iUiUserCertificates, &iUiCACertificates );
       
   471     }
       
   472 
       
   473 
       
   474 // -----------------------------------------------------------------------------
       
   475 // CEapTtlsUiDialog::CompleteReadCertificates
       
   476 // -----------------------------------------------------------------------------
       
   477 //
       
   478 void CEapTtlsUiDialog::CompleteReadCertificates( const TInt aResult )
       
   479     {
       
   480     if ( aResult == KErrNone ) // Certifiocates are received from core
       
   481         {
       
   482         TRAPD( err, CompleteUiConstructionL() );
       
   483         if ( err != KErrNone )
       
   484             {
       
   485             TRAP_IGNORE( TryExitL( KErrCancel ) );        
       
   486             }        
       
   487         }
       
   488     else
       
   489         {
       
   490         TRAP_IGNORE( TryExitL( KErrCancel ) );
       
   491         }
       
   492     }
       
   493 
       
   494 
       
   495 // -----------------------------------------------------------------------------
       
   496 // CEapTtlsUiDialog::CompleteUiConstructionL
       
   497 // -----------------------------------------------------------------------------
       
   498 //
       
   499 void CEapTtlsUiDialog::CompleteUiConstructionL()
       
   500     {
       
   501     // Initialize setting page 
       
   502     iSettingListBox = static_cast<CAknSettingStyleListBox*>( 
       
   503                                     ControlOrNull( ETtlsSettingsListbox ) );
       
   504     iSettingListBox->SetMopParent( this );
       
   505     iSettingListBox->CreateScrollBarFrameL( ETrue );
       
   506     iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   507                                                 CEikScrollBarFrame::EOff,
       
   508                                                 CEikScrollBarFrame::EAuto );
       
   509     iSettingListBox->SetListBoxObserver( this );                                                 
       
   510     DrawSettingsListL();
       
   511 
       
   512     // Initialize EAP types page
       
   513     iEapTypesListBox = static_cast<CAknSingleNumberStyleListBox*>( 
       
   514                                 ControlOrNull( ETtlsSettingsEapTypeListbox ) );
       
   515     iEapTypesListBox->SetMopParent( this );
       
   516     iEapTypesListBox->CreateScrollBarFrameL( ETrue );
       
   517     iEapTypesListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   518                                                 CEikScrollBarFrame::EOff,
       
   519                                                 CEikScrollBarFrame::EAuto );
       
   520     iEapTypesListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   521     iEapTypesListBox->SetListBoxObserver( this );     
       
   522     
       
   523     // Following deletes internal array created from resources. 
       
   524     // To prevent memory leak.
       
   525     MDesCArray* internalArray1 = iEapTypesListBox->Model()->ItemTextArray();
       
   526     delete internalArray1;
       
   527 
       
   528     // Initialize cipher suites page
       
   529     iCipherSuiteListBox = static_cast<CAknSingleNumberStyleListBox*>( 
       
   530                             ControlOrNull( ETtlsSettingsCipherSuiteListbox ) );
       
   531     iCipherSuiteListBox->CreateScrollBarFrameL( ETrue );
       
   532     iCipherSuiteListBox->ScrollBarFrame()->SetScrollBarVisibilityL( 
       
   533                                                 CEikScrollBarFrame::EOff,
       
   534                                                 CEikScrollBarFrame::EAuto );
       
   535     iCipherSuiteListBox->UpdateScrollBarsL();
       
   536     iCipherSuiteListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   537     iCipherSuiteListBox->SetListBoxObserver( this );   
       
   538         
       
   539     //Following deletes internal array created from resources. 
       
   540     // To prevent memory leak.
       
   541     MDesCArray* internalArray2 = iCipherSuiteListBox->Model()->ItemTextArray();
       
   542     delete internalArray2;
       
   543 
       
   544     SetEapIconsL();
       
   545     DrawEapListL( 0 );
       
   546 
       
   547     SetCipherIconsL();
       
   548     DrawCipherSuitesL();
       
   549     
       
   550     iIsUIConstructionCompleted = ETrue;
       
   551     }
       
   552 
       
   553 
       
   554 // -----------------------------------------------------------------------------
       
   555 // CEapTtlsUiDialog::PostLayoutDynInitL
       
   556 // -----------------------------------------------------------------------------
       
   557 //
       
   558 void CEapTtlsUiDialog::PostLayoutDynInitL()
       
   559     {
       
   560     TUid naviPaneUid;
       
   561     naviPaneUid.iUid = EEikStatusPaneUidNavi;
       
   562     CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   563     CEikStatusPaneBase::TPaneCapabilities subPane = 
       
   564                                 statusPane->PaneCapabilities( naviPaneUid );
       
   565     if ( subPane.IsPresent() && subPane.IsAppOwned() )
       
   566         {
       
   567         CAknNavigationControlContainer* naviPane = 
       
   568                                 static_cast<CAknNavigationControlContainer*>(
       
   569                                         statusPane->ControlL( naviPaneUid ) );
       
   570         CAknNavigationDecorator* naviDecorator = naviPane->ResourceDecorator();
       
   571         if ( naviDecorator )
       
   572             {
       
   573             CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>( 
       
   574                                         naviDecorator->DecoratedControl() );
       
   575             tabGroup->SetActiveTabById( 0 ); 
       
   576             tabGroup->SetTabFixedWidthL( KTabWidthWithOneTab );
       
   577             }
       
   578         }
       
   579     }
       
   580 
       
   581 
       
   582 // -----------------------------------------------------------------------------
       
   583 // CEapTtlsUiDialog::ChangeTitleL
       
   584 // -----------------------------------------------------------------------------
       
   585 //
       
   586 void CEapTtlsUiDialog::ChangeTitleL( TBool aIsStarted )
       
   587     {
       
   588     TUid titlePaneUid;
       
   589     titlePaneUid.iUid = EEikStatusPaneUidTitle;
       
   590 
       
   591     CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane();
       
   592     CEikStatusPaneBase::TPaneCapabilities subPane = 
       
   593                                 statusPane->PaneCapabilities( titlePaneUid );
       
   594     
       
   595     if ( subPane.IsPresent()&&subPane.IsAppOwned() )
       
   596         {
       
   597         CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( 
       
   598                                         statusPane->ControlL( titlePaneUid ) );
       
   599         if ( aIsStarted )
       
   600             {
       
   601             // Store previous application title text
       
   602             const TDesC* prevText = titlePane->Text();    
       
   603             iPreviousText = HBufC::NewL( prevText->Length() );
       
   604             iPreviousText->Des().Append( *prevText );
       
   605             TDesC* titleText = iEikonEnv->AllocReadResourceLC( 
       
   606                                                     R_TTLS_SETTINGS_TITLE );
       
   607             titlePane->SetTextL( *titleText );
       
   608             CleanupStack::PopAndDestroy( titleText ); 
       
   609             }
       
   610         else
       
   611             {
       
   612             // Set calling application title text back
       
   613             titlePane->SetTextL( *iPreviousText );    
       
   614             }    
       
   615         }
       
   616     }
       
   617 
       
   618 
       
   619 // -----------------------------------------------------------------------------
       
   620 // CEapTtlsUiDialog::OkToExitL
       
   621 // -----------------------------------------------------------------------------
       
   622 //
       
   623 TBool CEapTtlsUiDialog::OkToExitL( TInt aButtonId )
       
   624     {
       
   625     TBool ret( EFalse );
       
   626     switch ( aButtonId )
       
   627         {
       
   628         case EEikBidOk:
       
   629             {
       
   630             if( iIsUIConstructionCompleted )
       
   631                 {
       
   632                 TPageIds index = static_cast<TPageIds>( ActivePageIndex() );
       
   633                 if ( index == ESettingsPage )
       
   634                     {
       
   635                     ShowSettingPageL( EFalse );
       
   636                     }    
       
   637                 else if ( index == EEapTypePage )
       
   638                     {
       
   639                     ProcessCommandL( ETtlsUiCmdConfigure );
       
   640                     }
       
   641                 }
       
   642             else
       
   643                 {
       
   644                 #if defined(_DEBUG) || defined(DEBUG)
       
   645 				RDebug::Print(_L("CEapTtlsUiDialog::OkToExitL - UI not ready - Ignoring key press.\n") );
       
   646 				#endif
       
   647                 }
       
   648             break;
       
   649             }
       
   650 
       
   651         case EAknSoftkeyOptions:
       
   652             {
       
   653             DisplayMenuL();
       
   654             break;
       
   655             }
       
   656 
       
   657         case EAknSoftkeyBack:
       
   658         case EAknCmdExit:
       
   659             {
       
   660             if( ( GetEnabledEapTypeCount() > KMinEnabledCount ) &&
       
   661                   ( IsPlainMschapv2Enabled() || IsPapEnabled() ) )
       
   662                 {
       
   663                 HBufC* stringLabel;
       
   664 
       
   665                 if ( IsPlainMschapv2Enabled() )
       
   666                     {
       
   667                     stringLabel = StringLoader::LoadL(
       
   668                             R_TTLS_INFO_PLAIN_MSCHAP_CANNOT_ENABLE_ALONG,
       
   669                                                    iEikonEnv );
       
   670                     }
       
   671                 else
       
   672                     {
       
   673                     stringLabel = StringLoader::LoadL(
       
   674                             R_TTLS_INFO_PAP_CANNOT_ENABLE_ALONG,
       
   675                                                    iEikonEnv );
       
   676                     }
       
   677                 CleanupStack::PushL( stringLabel );
       
   678                 CAknInformationNote* dialog = new ( ELeave )
       
   679                                             CAknInformationNote( ETrue );
       
   680                 dialog->ExecuteLD( *stringLabel );
       
   681                 CleanupStack::PopAndDestroy( stringLabel );
       
   682                 
       
   683                 // after showing the info note, EAP settings page
       
   684                 // must be shown
       
   685                 if( ActivePageId() == KEAPTTLSSETTINGSPAGE )
       
   686                     {
       
   687                     TKeyEvent keyRight = 
       
   688                         {
       
   689                             EKeyRightArrow,
       
   690                             EStdKeyRightArrow,
       
   691                             EModifierPureKeycode,
       
   692                             0
       
   693                         };
       
   694                     CAknDialog::OfferKeyEventL
       
   695                                             ( keyRight,
       
   696                                               EEventKey );
       
   697                     }
       
   698                 if( ActivePageId() == KEAPTTLSCIPHERPAGE )
       
   699                     {
       
   700                     TKeyEvent keyLeft = 
       
   701                         {
       
   702                             EKeyLeftArrow,
       
   703                             EStdKeyLeftArrow,
       
   704                             EModifierPureKeycode,
       
   705                             0
       
   706                         };
       
   707                     CAknDialog::OfferKeyEventL
       
   708                                             ( keyLeft,
       
   709                                               EEventKey );
       
   710                     }
       
   711 
       
   712                 iExiting = EFalse;    
       
   713                 ret = EFalse;
       
   714                 }
       
   715             else
       
   716                 {
       
   717                 if( iIsUIConstructionCompleted )
       
   718                     {
       
   719                     iDataConnection->Update();
       
   720                     ChangeTitleL( EFalse );
       
   721                     ret = ETrue;
       
   722                     }
       
   723                 }
       
   724             break;
       
   725             }
       
   726             
       
   727         case ETtlsUiCmdChange:
       
   728             {
       
   729             TPageIds index = static_cast<TPageIds>( ActivePageIndex() );
       
   730             if ( index == ESettingsPage )
       
   731                 {
       
   732                 if( iIsUIConstructionCompleted )
       
   733     				{
       
   734         			ShowSettingPageL( EFalse );
       
   735     				}
       
   736     			else
       
   737     			    {
       
   738     				#if defined(_DEBUG) || defined(DEBUG)
       
   739     				RDebug::Print(_L("CEapPeapUiDialog::ProcessCommandL - UI not ready - Ignoring key press.\n") );
       
   740     				#endif
       
   741     			    }
       
   742                 }
       
   743             break;
       
   744             }
       
   745             
       
   746         case ETtlsUiCmdConfigure:
       
   747         case ETtlsUiCmdEnable:
       
   748         case ETtlsUiCmdDisable:
       
   749             {
       
   750             ProcessCommandL( aButtonId );
       
   751             ret = EFalse;
       
   752             break;
       
   753             }
       
   754 
       
   755         default:
       
   756             {
       
   757             break;
       
   758             }
       
   759         }
       
   760 
       
   761     if ( ret )
       
   762         {
       
   763         *iButtonId = aButtonId;
       
   764         }
       
   765 
       
   766     return ret;
       
   767     }
       
   768 
       
   769 
       
   770 // -----------------------------------------------------------------------------
       
   771 // CEapTtlsUiDialog::DrawSettingsListL
       
   772 // -----------------------------------------------------------------------------
       
   773 //
       
   774 void CEapTtlsUiDialog::DrawSettingsListL()
       
   775     {  
       
   776     iSettingArray->Array()->ResetAndDestroy();
       
   777     TInt ordinal = 0;
       
   778     TInt activeUserCertificate = CheckActiveUserCertificate();
       
   779     TBuf<KMaxFullCertLabelLength> aActiveuserCertificateName = KEmptyString();
       
   780     if ( activeUserCertificate != KErrNotFound )
       
   781         {
       
   782 		TBuf<KMaxFullCertLabelLength> text;
       
   783 		GetFullCertLabelL( 
       
   784                 iUiUserCertificates->At( activeUserCertificate ).iCertEntry,
       
   785                 text );
       
   786 		aActiveuserCertificateName.Copy( text );		
       
   787         }
       
   788     else
       
   789         {
       
   790         TDesC* notDefinedText = iEikonEnv->AllocReadResourceLC( 
       
   791                                                         R_TTLS_NOT_DEFINED );
       
   792         aActiveuserCertificateName.Copy( *notDefinedText );
       
   793         CleanupStack::PopAndDestroy( notDefinedText );
       
   794         }
       
   795 
       
   796     iSettingArray->AddTextItemL( aActiveuserCertificateName,
       
   797                                  ETtlsSettingUserCert,
       
   798                                  R_TTLS_USER_CERT_STRING,
       
   799                                  R_TTLS_USERNAME_PAGE,
       
   800                                  NULL,
       
   801                                  ordinal++ );
       
   802 
       
   803     TInt activeCaCertificate = CheckActiveCaCertificate();
       
   804     TBuf<KMaxFullCertLabelLength> aActiveCaCertificateName = KEmptyString();
       
   805     if ( activeCaCertificate != KErrNotFound )
       
   806         {
       
   807 		TBuf<KMaxFullCertLabelLength> text;
       
   808 		GetFullCertLabelL(
       
   809                     iUiCACertificates->At( activeCaCertificate ).iCertEntry,
       
   810                     text );
       
   811 		aActiveCaCertificateName.Copy( text );				
       
   812         }
       
   813     else
       
   814         {
       
   815         TDesC* notDefinedText = iEikonEnv->AllocReadResourceLC( 
       
   816                                                         R_TTLS_NOT_DEFINED );
       
   817         aActiveCaCertificateName.Copy( *notDefinedText );
       
   818         CleanupStack::PopAndDestroy( notDefinedText );                
       
   819         }
       
   820 
       
   821     iSettingArray->AddTextItemL( aActiveCaCertificateName,
       
   822                                  ETtlsSettingCaCert,
       
   823                                  R_TTLS_CA_CERT_STRING,
       
   824                                  R_TTLS_USERNAME_PAGE,
       
   825                                  NULL,
       
   826                                  ordinal++ );
       
   827       
       
   828     iSettingArray->AddBinarySettingItemL( R_TTLS_DISPLAY_AUTOUSECONF_PAGE, 
       
   829                                           R_TTLS_USERNAME_INUSESTRING, 
       
   830                                           R_TTLS_USERNAME_AUTOUSECONF_TEXTS,
       
   831                                           ordinal++,
       
   832                                           *iUiData->GetUseManualUsername() );
       
   833 
       
   834     iSettingArray->AddTextItemL( iUiData->GetManualUsername(),
       
   835                                  ETtlsTabSheetSettingsUsername,
       
   836                                  R_TTLS_USERNAME_STRING,
       
   837                                  R_TTLS_USERNAME_PAGE,
       
   838                                  NULL,
       
   839                                  ordinal++ );
       
   840 
       
   841     iSettingArray->AddBinarySettingItemL( R_TTLS_DISPLAY_AUTOUSECONF_PAGE,
       
   842                                           R_TTLS_REALM_INUSESTRING, 
       
   843                                           R_TTLS_REALM_AUTOUSECONF_TEXTS,
       
   844                                           ordinal++,
       
   845                                           *iUiData->GetUseManualRealm() );    
       
   846 
       
   847     iSettingArray->AddTextItemL( iUiData->GetManualRealm(),
       
   848                                  ETtlsTabSheetSettingsRealm,
       
   849                                  R_TTLS_REALM_STRING,
       
   850                                  R_TTLS_REALM_PAGE,
       
   851                                  NULL,
       
   852                                  ordinal++ );
       
   853     
       
   854     iSettingArray->AddBinarySettingItemL( R_TTLS_DISPLAY_AUTOUSECONF_PAGE,
       
   855                                           R_TTLS_TLS_PRIVACY_STRING, 
       
   856                                           R_TTLS_TLS_PRIVACY_AUTOUSECONF_TEXTS,
       
   857                                           ordinal++,
       
   858                                           *iUiData->GetTlsPrivacy() );
       
   859         
       
   860     iSettingListBox->Model()->SetItemTextArray( iSettingArray->Array() );    
       
   861     iSettingListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   862     iSettingArray->Array()->RecalculateVisibleIndicesL();
       
   863     iSettingListBox->HandleItemAdditionL();
       
   864     iSettingListBox->UpdateScrollBarsL();  
       
   865     }
       
   866 
       
   867 
       
   868 // -----------------------------------------------------------------------------
       
   869 // CEapTtlsUiDialog::DynInitMenuPaneL
       
   870 // -----------------------------------------------------------------------------
       
   871 //
       
   872 void CEapTtlsUiDialog::DynInitMenuPaneL( TInt aResourceId, 
       
   873                                          CEikMenuPane* aMenuPane )
       
   874     {
       
   875     CAknDialog::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   876 
       
   877     if ( aMenuPane && aResourceId == R_TTLS_MENU_PANE )
       
   878         {
       
   879         if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   880             {
       
   881             aMenuPane->DeleteMenuItem( EAknCmdHelp );
       
   882             }
       
   883 
       
   884         TPageIds index = static_cast<TPageIds>( ActivePageIndex() );
       
   885         if ( index == ESettingsPage )
       
   886             {
       
   887             aMenuPane->SetItemDimmed( ETtlsUiCmdEnable,    ETrue );
       
   888             aMenuPane->SetItemDimmed( ETtlsUiCmdDisable,   ETrue );
       
   889             aMenuPane->SetItemDimmed( ETtlsUiCmdConfigure, ETrue );
       
   890             aMenuPane->SetItemDimmed( ETtlsUiCmdMoveUp,    ETrue );
       
   891             aMenuPane->SetItemDimmed( ETtlsUiCmdMoveDown,  ETrue );
       
   892             }
       
   893         else if ( index == EEapTypePage )
       
   894             {
       
   895             aMenuPane->SetItemDimmed( ETtlsUiCmdChange, ETrue );
       
   896 
       
   897             if ( iEapTypeViewArray->Count() > 0 )
       
   898                 {
       
   899                 TInt currentIndex = iEapTypesListBox->CurrentItemIndex();
       
   900                 TBool enabled = iUiEapTypes->At( currentIndex ).iIsEnabled;
       
   901                 
       
   902                 // Hide either "Enable" or "Disable", as appropriate.
       
   903                 aMenuPane->SetItemDimmed( ETtlsUiCmdEnable,  enabled );
       
   904                 aMenuPane->SetItemDimmed( ETtlsUiCmdDisable, !enabled );
       
   905 
       
   906                 // Don't display "Configure" for disabled items
       
   907                 aMenuPane->SetItemDimmed( ETtlsUiCmdConfigure, !enabled );
       
   908 
       
   909                 // Don't display "Raise priority" nor "Lower priority" for 
       
   910                 // disabled items
       
   911                 aMenuPane->SetItemDimmed( ETtlsUiCmdMoveUp, !enabled );
       
   912                 aMenuPane->SetItemDimmed( ETtlsUiCmdMoveDown, !enabled );
       
   913 
       
   914                 if ( enabled )
       
   915                     {
       
   916                     if ( currentIndex == 0 )
       
   917                         {
       
   918                         // Can't go higher than top.
       
   919                         aMenuPane->SetItemDimmed( ETtlsUiCmdMoveUp, ETrue );
       
   920                         }
       
   921                     else if ( currentIndex == iEapTypeViewArray->Count()-1 ||
       
   922                          ( currentIndex < iEapTypeViewArray->Count()-1 && 
       
   923                          !iUiEapTypes->At( currentIndex + 1 ).iIsEnabled ) ) 
       
   924                         {
       
   925                         // Can't go lower than the last enabled item
       
   926                         aMenuPane->SetItemDimmed( ETtlsUiCmdMoveDown, ETrue );
       
   927                         }
       
   928                     }
       
   929 
       
   930                 }
       
   931             else
       
   932                 {
       
   933                 aMenuPane->SetItemDimmed( ETtlsUiCmdEnable,    ETrue );
       
   934                 aMenuPane->SetItemDimmed( ETtlsUiCmdDisable,   ETrue );
       
   935                 aMenuPane->SetItemDimmed( ETtlsUiCmdConfigure, ETrue );
       
   936                 aMenuPane->SetItemDimmed( ETtlsUiCmdMoveUp,    ETrue );
       
   937                 aMenuPane->SetItemDimmed( ETtlsUiCmdMoveDown,  ETrue );
       
   938                 aMenuPane->SetItemDimmed( ETtlsUiCmdChange,    ETrue );
       
   939                 }
       
   940             }
       
   941         else if ( index == ECipherSuitePage )
       
   942             {
       
   943             aMenuPane->SetItemDimmed( ETtlsUiCmdConfigure, ETrue );
       
   944             aMenuPane->SetItemDimmed( ETtlsUiCmdMoveUp,    ETrue );
       
   945             aMenuPane->SetItemDimmed( ETtlsUiCmdMoveDown,  ETrue );
       
   946             aMenuPane->SetItemDimmed( ETtlsUiCmdChange,    ETrue );
       
   947 
       
   948             if ( iCipherSuitesViewArray->Count() > 0 )
       
   949                 {
       
   950                 TInt currIndex = iCipherSuiteListBox->CurrentItemIndex();
       
   951                 TBool enabled = iUiCipherSuites->At( currIndex ).iIsEnabled;
       
   952 
       
   953                 // Hide either "Enable" or "Disable", as appropriate.
       
   954                 aMenuPane->SetItemDimmed( ETtlsUiCmdEnable,  enabled );
       
   955                 aMenuPane->SetItemDimmed( ETtlsUiCmdDisable, !enabled );
       
   956                 }
       
   957             else
       
   958                 {
       
   959                 aMenuPane->SetItemDimmed( ETtlsUiCmdEnable,  ETrue );
       
   960                 aMenuPane->SetItemDimmed( ETtlsUiCmdDisable, ETrue );
       
   961                 }
       
   962             }
       
   963         }
       
   964     }
       
   965 
       
   966 
       
   967 // -----------------------------------------------------------------------------
       
   968 // CEapTtlsUiDialog::ProcessCommandL
       
   969 // -----------------------------------------------------------------------------
       
   970 //
       
   971 void CEapTtlsUiDialog::ProcessCommandL( TInt aCommand )
       
   972     {
       
   973     if ( MenuShowing() )
       
   974         {
       
   975         HideMenu();
       
   976         }
       
   977 
       
   978     TPageIds pageIndex = static_cast<TPageIds>( ActivePageIndex() );
       
   979     switch( aCommand )
       
   980         {
       
   981         case EAknCmdExit:
       
   982             {
       
   983             TryExitL( aCommand );
       
   984             break;
       
   985             }
       
   986 
       
   987         case EAknCmdHelp:
       
   988             {
       
   989             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   990                                     iEikonEnv->EikAppUi()->AppHelpContextL() );
       
   991             break;
       
   992             }
       
   993 
       
   994         case ETtlsUiCmdChange:
       
   995             {
       
   996             if ( pageIndex == ESettingsPage )
       
   997                 {
       
   998                 if( iIsUIConstructionCompleted )
       
   999     				{
       
  1000         			ShowSettingPageL( ETrue );
       
  1001     				}
       
  1002     			else
       
  1003     			    {
       
  1004     				#if defined(_DEBUG) || defined(DEBUG)
       
  1005     				RDebug::Print(_L("CEapTtlsUiDialog::ProcessCommandL - UI not ready - Ignoring key press.\n") );
       
  1006     				#endif						
       
  1007     			    }
       
  1008                 }    
       
  1009             break;
       
  1010             }
       
  1011 
       
  1012         case ETtlsUiCmdMoveUp:
       
  1013             {
       
  1014             if ( pageIndex == EEapTypePage )
       
  1015                 {
       
  1016                 TInt cur = iEapTypesListBox->CurrentItemIndex();
       
  1017                 MoveEapTypeL( cur, cur - 1 );
       
  1018                 }
       
  1019             break;
       
  1020             }
       
  1021 
       
  1022         case ETtlsUiCmdMoveDown:
       
  1023             {
       
  1024             if ( pageIndex == EEapTypePage )
       
  1025                 {
       
  1026                 TInt cur = iEapTypesListBox->CurrentItemIndex();
       
  1027                 MoveEapTypeL( cur, cur + 1 );
       
  1028                 }
       
  1029             break;
       
  1030             }
       
  1031 
       
  1032         case ETtlsUiCmdEnable:
       
  1033             {
       
  1034             if ( pageIndex == ECipherSuitePage )
       
  1035                 {
       
  1036                 TInt index = iCipherSuiteListBox->CurrentItemIndex();
       
  1037                 iUiCipherSuites->At( index ).iIsEnabled = ETrue;
       
  1038                 iCipherSuites->Update();
       
  1039                 DrawCipherSuitesL();
       
  1040                 CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
  1041                 cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_DISABLE );
       
  1042                 cba.DrawDeferred();
       
  1043                 }
       
  1044             else if ( pageIndex == EEapTypePage )
       
  1045                 {
       
  1046                 TInt cur = iEapTypesListBox->CurrentItemIndex();
       
  1047                 iUiEapTypes->At( cur ).iIsEnabled = ETrue;
       
  1048 
       
  1049                 iEapTypes->Update();
       
  1050 
       
  1051                 // enabling moves item to the top of the list
       
  1052                 MoveEapTypeL( cur, 0 );                
       
  1053 
       
  1054                 // load the new CBA from resource
       
  1055                 CEikButtonGroupContainer& cba = ButtonGroupContainer();                
       
  1056                 cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_CONFIGURE );
       
  1057                 cba.DrawDeferred();
       
  1058                 }                
       
  1059             break;
       
  1060             }
       
  1061 
       
  1062         case ETtlsUiCmdDisable:
       
  1063             {
       
  1064             if ( pageIndex == ECipherSuitePage )
       
  1065                 {
       
  1066                 TInt index = iCipherSuiteListBox->CurrentItemIndex();
       
  1067                 iUiCipherSuites->At( index ).iIsEnabled = EFalse;
       
  1068                 iCipherSuites->Update();
       
  1069                 DrawCipherSuitesL();    
       
  1070                 CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
  1071                 cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_ENABLE );
       
  1072                 cba.DrawDeferred();        
       
  1073                 }            
       
  1074             else if ( pageIndex == EEapTypePage )
       
  1075                 {
       
  1076                 TInt itemIndex = iEapTypesListBox->CurrentItemIndex();
       
  1077 
       
  1078                 if( GetEnabledEapTypeCount() > KMinEnabledCount )
       
  1079                     {
       
  1080                     // disabling moves item just after the last enabled one,
       
  1081                     // so find that position
       
  1082                     TInt next = itemIndex;
       
  1083                     
       
  1084                     while ( next < iUiEapTypes->Count() - 1 &&
       
  1085                             iUiEapTypes->At( next ).iIsEnabled )
       
  1086                         {
       
  1087                         ++next;
       
  1088                         }
       
  1089 
       
  1090                     if ( next > itemIndex && 
       
  1091                          !iUiEapTypes->At( next ).iIsEnabled ) 
       
  1092                         {
       
  1093                         --next;
       
  1094                         }
       
  1095 
       
  1096 
       
  1097                     iUiEapTypes->At( itemIndex ).iIsEnabled = EFalse;
       
  1098 
       
  1099                     // move item if needed
       
  1100                     MoveEapTypeL( itemIndex, next );
       
  1101                     iEapTypes->Update();                
       
  1102 
       
  1103                     // Highlight follows movement.
       
  1104                     //iEapTypesListBox->SetCurrentItemIndex( next );
       
  1105                     
       
  1106                     // load the new CBA from resource
       
  1107                     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
  1108                     cba.SetCommandSetL( 
       
  1109                                      R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_ENABLE );
       
  1110                     cba.DrawDeferred();
       
  1111                     }
       
  1112                 else
       
  1113                     {
       
  1114                     HBufC* stringLabel;
       
  1115                     stringLabel = StringLoader::LoadL(
       
  1116                                 R_TTLS_INFO_CANNOT_DISABLE_ALL_EAP_PLUGINS,
       
  1117                                                        iEikonEnv );
       
  1118                     CleanupStack::PushL( stringLabel );
       
  1119                     CAknInformationNote* dialog = new ( ELeave )
       
  1120                                                 CAknInformationNote( ETrue );
       
  1121                     dialog->ExecuteLD( *stringLabel );
       
  1122                     CleanupStack::PopAndDestroy( stringLabel );
       
  1123                     }
       
  1124                 }
       
  1125             break;
       
  1126             }
       
  1127 
       
  1128         case ETtlsUiCmdConfigure:
       
  1129             {
       
  1130             if ( pageIndex == EEapTypePage )
       
  1131                 {
       
  1132                 ConfigureL(EFalse);
       
  1133                 }
       
  1134             break;
       
  1135             }
       
  1136 
       
  1137         default:
       
  1138             {
       
  1139             break;
       
  1140             }
       
  1141         }
       
  1142     }
       
  1143 
       
  1144 
       
  1145 // -----------------------------------------------------------------------------
       
  1146 // CEapTtlsUiDialog::PageChangedL
       
  1147 // -----------------------------------------------------------------------------
       
  1148 //
       
  1149 void CEapTtlsUiDialog::PageChangedL( TInt aPageId )
       
  1150     {
       
  1151     if ( !iIsUIConstructionCompleted )
       
  1152         {
       
  1153         return;
       
  1154         }
       
  1155 
       
  1156     if ( aPageId == KEAPTTLSSETTINGSPAGE )
       
  1157         {
       
  1158         if (iSettingListBox->ScrollBarFrame())
       
  1159             {
       
  1160             iSettingListBox->ScrollBarFrame()->ComponentControl(0)->MakeVisible(ETrue);
       
  1161             }
       
  1162         if (iEapTypesListBox->ScrollBarFrame())
       
  1163             {
       
  1164             iEapTypesListBox->ScrollBarFrame()->ComponentControl(0)->MakeVisible(EFalse);
       
  1165             }
       
  1166         if (iCipherSuiteListBox->ScrollBarFrame())
       
  1167             {
       
  1168             iCipherSuiteListBox->ScrollBarFrame()->ComponentControl(0)->MakeVisible(EFalse);
       
  1169             }
       
  1170         }
       
  1171      else if ( aPageId == KEAPTTLSEAPPAGE )
       
  1172         {
       
  1173         if (iSettingListBox->ScrollBarFrame())
       
  1174             {
       
  1175             iSettingListBox->ScrollBarFrame()->ComponentControl(0)->MakeVisible(EFalse);
       
  1176             }
       
  1177         if (iEapTypesListBox->ScrollBarFrame())
       
  1178             {
       
  1179             iEapTypesListBox->ScrollBarFrame()->ComponentControl(0)->MakeVisible(ETrue);
       
  1180             }
       
  1181         if (iCipherSuiteListBox->ScrollBarFrame())
       
  1182             {
       
  1183             iCipherSuiteListBox->ScrollBarFrame()->ComponentControl(0)->MakeVisible(EFalse);
       
  1184             }
       
  1185         }
       
  1186     else if ( aPageId == KEAPTTLSCIPHERPAGE )
       
  1187         {
       
  1188         if (iSettingListBox->ScrollBarFrame())
       
  1189             {
       
  1190             iSettingListBox->ScrollBarFrame()->ComponentControl(0)->MakeVisible(EFalse);
       
  1191             }
       
  1192         if (iEapTypesListBox->ScrollBarFrame())
       
  1193             {
       
  1194             iEapTypesListBox->ScrollBarFrame()->ComponentControl(0)->MakeVisible(EFalse);
       
  1195             }
       
  1196         if (iCipherSuiteListBox->ScrollBarFrame())
       
  1197             {
       
  1198             iCipherSuiteListBox->ScrollBarFrame()->ComponentControl(0)->MakeVisible(ETrue);
       
  1199             }
       
  1200         }
       
  1201         
       
  1202     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
  1203     if( aPageId == KEAPTTLSSETTINGSPAGE )
       
  1204         {
       
  1205         cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_EDIT );
       
  1206         }
       
  1207     else if( aPageId == KEAPTTLSEAPPAGE )
       
  1208         {
       
  1209         cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_CONFIGURE );
       
  1210         }
       
  1211     else if( aPageId == KEAPTTLSCIPHERPAGE )
       
  1212         {
       
  1213         TInt index = iCipherSuiteListBox->CurrentItemIndex();
       
  1214         if( ( *iUiCipherSuites )[ index ].iIsEnabled )
       
  1215             {
       
  1216             cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_DISABLE );
       
  1217             }
       
  1218         else
       
  1219             {
       
  1220             cba.SetCommandSetL( R_TTLS_UI_SOFTKEYS_OPTIONS_BACK_ENABLE );
       
  1221             }
       
  1222         }
       
  1223     cba.DrawDeferred();
       
  1224     }
       
  1225     
       
  1226 
       
  1227 // -----------------------------------------------------------------------------
       
  1228 // CEapTtlsUiDialog::ShowSettingPageL
       
  1229 // -----------------------------------------------------------------------------
       
  1230 //
       
  1231 void CEapTtlsUiDialog::ShowSettingPageL( TInt aCalledFromMenu )
       
  1232     {
       
  1233     TInt index = iSettingListBox->CurrentItemIndex();
       
  1234     if ( index == EUserCertificateItem )
       
  1235         {
       
  1236         TInt activeUserCertificate = CheckActiveUserCertificate();
       
  1237         CDesCArrayFlat* tempArray = new( ELeave )CDesCArrayFlat( 
       
  1238                                                 KCertificateArrayGranularity );
       
  1239         CleanupStack::PushL( tempArray );
       
  1240     
       
  1241         TDesC* noneText = iEikonEnv->AllocReadResourceLC( 
       
  1242                                                     R_TTLS_NONE_SELECTION );
       
  1243         tempArray->InsertL( 0, *noneText );
       
  1244         CleanupStack::PopAndDestroy( noneText );
       
  1245     
       
  1246         for ( TInt i = 0; i < iUiUserCertificates->Count() ; i++ )
       
  1247             {
       
  1248             TEapTlsPeapUiCertificate certificate = 
       
  1249                                                 iUiUserCertificates->At( i );
       
  1250             SCertEntry entry = certificate.iCertEntry;
       
  1251 			TBuf<KMaxFullCertLabelLength> text;
       
  1252 			GetFullCertLabelL( entry, text);
       
  1253 			tempArray->InsertL( i+1, text );
       
  1254             }
       
  1255         TInt selected( 0 );    
       
  1256         if ( activeUserCertificate == KErrNotFound )
       
  1257             {
       
  1258             selected = ShowRadioButtonSettingPageL( R_TTLS_USER_CERT_STRING, 
       
  1259                                                     tempArray, 0 );
       
  1260             }
       
  1261         else 
       
  1262             {
       
  1263             selected = ShowRadioButtonSettingPageL( R_TTLS_USER_CERT_STRING, 
       
  1264                                                     tempArray, 
       
  1265                                                     activeUserCertificate+1 );
       
  1266                                     //Plus 1 cause we added 'none' selection
       
  1267             }
       
  1268 
       
  1269         CleanupStack::PopAndDestroy( tempArray );
       
  1270         UserCertificateHouseKeeping( selected );    
       
  1271         iCertificates->Update();
       
  1272         DrawSettingsListL(); // List must be drawn again at this stage
       
  1273         }
       
  1274     else if ( index == ECaCertificateItem )
       
  1275         {
       
  1276         TInt activeCaCertificate = CheckActiveCaCertificate();
       
  1277 
       
  1278         CDesCArrayFlat* tempArray = new( ELeave )CDesCArrayFlat( 
       
  1279                                                 KCertificateArrayGranularity );
       
  1280         CleanupStack::PushL( tempArray );
       
  1281 
       
  1282         TDesC* noneText = iEikonEnv->AllocReadResourceLC( 
       
  1283                                                     R_TTLS_NONE_SELECTION );
       
  1284         tempArray->InsertL( 0, *noneText );
       
  1285         CleanupStack::PopAndDestroy( noneText );
       
  1286 
       
  1287         for ( TInt i = 0; i < iUiCACertificates->Count(); i++ )
       
  1288             {
       
  1289             TEapTlsPeapUiCertificate certificate = iUiCACertificates->At( i );
       
  1290             SCertEntry entry = certificate.iCertEntry;
       
  1291             TBuf<KMaxFullCertLabelLength> text;
       
  1292 			GetFullCertLabelL( entry, text );
       
  1293 			tempArray->InsertL( i+1, text );
       
  1294             }
       
  1295 
       
  1296         TInt selected( 0 );
       
  1297         if ( activeCaCertificate == KErrNotFound )
       
  1298             {
       
  1299             selected = ShowRadioButtonSettingPageL( R_TTLS_CA_CERT_STRING, 
       
  1300                                                     tempArray, 0 );        
       
  1301             }
       
  1302         else
       
  1303             {
       
  1304             selected = ShowRadioButtonSettingPageL( R_TTLS_CA_CERT_STRING, 
       
  1305                                                     tempArray, 
       
  1306                                                     activeCaCertificate+1 );
       
  1307                                     //Plus 1 cause we added 'none' selection
       
  1308             }
       
  1309         CleanupStack::PopAndDestroy( tempArray );
       
  1310         CaCertificateHouseKeeping( selected );
       
  1311         iCertificates->Update();
       
  1312         DrawSettingsListL(); // List must be drawn again at this stage
       
  1313         }
       
  1314     else
       
  1315         {
       
  1316         CAknSettingItem* item = iSettingArray->Array()->At( index );
       
  1317         item->EditItemL( aCalledFromMenu );
       
  1318         item->StoreL();
       
  1319         }
       
  1320 
       
  1321     DrawNow();
       
  1322     }
       
  1323 
       
  1324 
       
  1325 // -----------------------------------------------------------------------------
       
  1326 // CEapPeapUiDialog::MoveEapTypeL
       
  1327 // -----------------------------------------------------------------------------
       
  1328 //
       
  1329 void CEapTtlsUiDialog::MoveEapTypeL( TInt aOldPos, TInt aNewPos )
       
  1330     {
       
  1331     TEapTlsPeapUiEapType originalUpper = iUiEapTypes->At( aOldPos );
       
  1332     iUiEapTypes->Delete( aOldPos );
       
  1333     iUiEapTypes->InsertL( aNewPos, originalUpper );
       
  1334     iUiEapTypes->Compress();    // Might not be needed
       
  1335     iEapTypes->Update();
       
  1336     DrawEapListL( aNewPos );
       
  1337     }
       
  1338     
       
  1339     
       
  1340 // -----------------------------------------------------------------------------
       
  1341 // CEapTtlsUiDialog::DrawEapListL
       
  1342 // -----------------------------------------------------------------------------
       
  1343 //
       
  1344 void CEapTtlsUiDialog::DrawEapListL( TInt aWantedIndex )
       
  1345     {    
       
  1346     iEapTypeViewArray->Reset();
       
  1347     RImplInfoPtrArray eapArray;
       
  1348     eapArray.Reset();
       
  1349 
       
  1350     REComSession::ListImplementationsL( KEapTypeInterfaceUid, eapArray );
       
  1351     for ( TInt i = 0; i < iUiEapTypes->Count(); i++ )
       
  1352         {
       
  1353         TBuf<KMaxLengthOfEapLine> tempLine;
       
  1354         
       
  1355         if ( iUiEapTypes->At( i ).iIsEnabled )
       
  1356             {
       
  1357             _LIT( KNumTab, "%d\t" );
       
  1358             tempLine.AppendFormat( KNumTab, i+1 );
       
  1359             }
       
  1360         else
       
  1361             {
       
  1362             _LIT( KTab, "\t" );
       
  1363             tempLine.Append( KTab );
       
  1364             }
       
  1365         
       
  1366         for ( TInt index = 0; index < eapArray.Count(); index++ )
       
  1367             {
       
  1368             if ( eapArray[index]->DataType() == iUiEapTypes->At( i ).iEapType )
       
  1369                 {
       
  1370                 tempLine.Append( eapArray[index]->DisplayName() );
       
  1371                 break;
       
  1372                 }
       
  1373             }
       
  1374 
       
  1375         if ( iUiEapTypes->At( i ).iIsEnabled )
       
  1376             {       // Add mark icon to indicate that the eap type is enabled
       
  1377             _LIT( KTab0, "\t0" );
       
  1378             tempLine.Append( KTab0 );
       
  1379             }
       
  1380 
       
  1381         iEapTypeViewArray->InsertL( i, tempLine );
       
  1382         }
       
  1383 
       
  1384     eapArray.ResetAndDestroy();
       
  1385     iEapTypesListBox->Model()->SetItemTextArray( iEapTypeViewArray );
       
  1386     iEapTypesListBox->HandleItemAdditionL();
       
  1387     iEapTypesListBox->SetCurrentItemIndex( aWantedIndex );
       
  1388     iEapTypesListBox->DrawDeferred();
       
  1389     iEapTypesListBox->UpdateScrollBarsL();
       
  1390     }
       
  1391 
       
  1392 
       
  1393 // -----------------------------------------------------------------------------
       
  1394 // CEapTtlsUiDialog::ShowRadioButtonSettingPageL
       
  1395 // -----------------------------------------------------------------------------
       
  1396 //
       
  1397 TInt CEapTtlsUiDialog::ShowRadioButtonSettingPageL( TInt aTitle, 
       
  1398                                                     CDesCArrayFlat* aValues, 
       
  1399                                                     TInt aCurrentItem )
       
  1400     {
       
  1401     // title of the dialog
       
  1402     HBufC* title = iCoeEnv->AllocReadResourceLC( aTitle );
       
  1403 
       
  1404     // We have everything to create dialog
       
  1405     CAknRadioButtonSettingPage* dlg = new( ELeave )CAknRadioButtonSettingPage(
       
  1406                                                 R_RADIO_BUTTON_SETTING_PAGE,
       
  1407                                                 aCurrentItem, 
       
  1408                                                 aValues );
       
  1409     CleanupStack::PushL( dlg );
       
  1410     dlg->SetSettingTextL( *title ); 
       
  1411     CleanupStack::Pop( dlg );
       
  1412     dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
  1413     CleanupStack::PopAndDestroy( title ); // title
       
  1414     // index must be re-turned upside down, because options list is upside down
       
  1415     return aCurrentItem;
       
  1416     }
       
  1417 
       
  1418 
       
  1419 // -----------------------------------------------------------------------------
       
  1420 // CEapTtlsUiDialog::DrawCipherSuitesL
       
  1421 // -----------------------------------------------------------------------------
       
  1422 //
       
  1423 void CEapTtlsUiDialog::DrawCipherSuitesL()
       
  1424     {
       
  1425     iCipherSuitesViewArray->Reset();
       
  1426     TInt listCount( 0 );
       
  1427     TBuf<KMaxLengthOfSuiteName> temp;
       
  1428     for ( TInt i = 0; i < iUiCipherSuites->Count(); i++ )
       
  1429         {
       
  1430         temp.Zero();
       
  1431         _LIT( KTab, "\t" );
       
  1432         temp.Append( KTab ); 
       
  1433 
       
  1434         TEapTlsPeapUiCipherSuite suite = iUiCipherSuites->At( i );
       
  1435         TUint32 suiteId = suite.iCipherSuite;
       
  1436 
       
  1437         switch( suiteId )
       
  1438             {
       
  1439             case 0x0004:
       
  1440                 {
       
  1441                 HBufC* suite = iCoeEnv->AllocReadResourceLC( 
       
  1442                                                 R_TTLS_SUITE_RSARC4MD5 );
       
  1443                 temp.Append( *suite );
       
  1444                 CleanupStack::PopAndDestroy( suite );
       
  1445                 break;
       
  1446                 }
       
  1447 
       
  1448             case 0x0005:
       
  1449                 {
       
  1450                 HBufC* suite = iCoeEnv->AllocReadResourceLC( 
       
  1451                                                 R_TTLS_SUITE_RSARC4SHA );
       
  1452                 temp.Append( *suite );
       
  1453                 CleanupStack::PopAndDestroy( suite );
       
  1454                 break;
       
  1455                 }
       
  1456 
       
  1457             case 0x000a:
       
  1458                 {
       
  1459                 HBufC* suite = iCoeEnv->AllocReadResourceLC( 
       
  1460                                                 R_TTLS_SUITE_RSA3DESSHA );
       
  1461                 temp.Append( *suite );
       
  1462                 CleanupStack::PopAndDestroy( suite );
       
  1463                 break;
       
  1464                 }
       
  1465 
       
  1466             case 0x0016:
       
  1467                 {
       
  1468                 HBufC* suite = iCoeEnv->AllocReadResourceLC( 
       
  1469                                                 R_TTLS_SUITE_DHERSA3DESSHA );
       
  1470                 temp.Append( *suite );
       
  1471                 CleanupStack::PopAndDestroy( suite );            
       
  1472                 break;
       
  1473                 }
       
  1474 
       
  1475             case 0x0013:
       
  1476                 {
       
  1477                 HBufC* suite = iCoeEnv->AllocReadResourceLC( 
       
  1478                                                 R_TTLS_SUITE_DHEDSS3DESSHA );
       
  1479                 temp.Append( *suite );
       
  1480                 CleanupStack::PopAndDestroy( suite );        
       
  1481                 break;
       
  1482                 }
       
  1483 
       
  1484             case 0x002F:
       
  1485                 {
       
  1486                 HBufC* suite = iCoeEnv->AllocReadResourceLC( 
       
  1487                                                 R_TTLS_SUITE_RSAAESSHA );
       
  1488                 temp.Append( *suite );
       
  1489                 CleanupStack::PopAndDestroy( suite );                
       
  1490                 break;
       
  1491                 }
       
  1492 
       
  1493             case 0x0032:
       
  1494                 {
       
  1495                 HBufC* suite = iCoeEnv->AllocReadResourceLC( 
       
  1496                                                 R_TTLS_SUITE_DHERSAAESSHA );
       
  1497                 temp.Append( *suite );
       
  1498                 CleanupStack::PopAndDestroy( suite );        
       
  1499                 break;
       
  1500                 }
       
  1501 
       
  1502             case 0x0033:
       
  1503                 {
       
  1504                 HBufC* suite = iCoeEnv->AllocReadResourceLC( 
       
  1505                                                 R_TTLS_SUITE_DHEDSSAESSHA );
       
  1506                 temp.Append( *suite );
       
  1507                 CleanupStack::PopAndDestroy( suite );                     
       
  1508                 break;
       
  1509                 }
       
  1510 
       
  1511             default:
       
  1512                 {
       
  1513                 temp.Append( KEmptyString );
       
  1514                 break;
       
  1515                 }
       
  1516              }
       
  1517 
       
  1518         if ( iUiCipherSuites->At( i ).iIsEnabled )
       
  1519             {       // Add mark icon to indicate that the suite is enabled
       
  1520             _LIT( KTab0, "\t0" );
       
  1521             temp.Append( KTab0 );
       
  1522             }
       
  1523 
       
  1524         iCipherSuitesViewArray->InsertL( listCount, temp );
       
  1525         listCount++;                
       
  1526         }
       
  1527 
       
  1528     iCipherSuiteListBox->Model()->SetItemTextArray( iCipherSuitesViewArray );
       
  1529     iCipherSuiteListBox->HandleItemAdditionL();
       
  1530     iCipherSuiteListBox->DrawDeferred();
       
  1531     iCipherSuiteListBox->UpdateScrollBarsL();        
       
  1532     }
       
  1533 
       
  1534 
       
  1535 // -----------------------------------------------------------------------------
       
  1536 // CEapTtlsUiDialog::CheckActiveUserCertificate
       
  1537 // -----------------------------------------------------------------------------
       
  1538 //
       
  1539 TInt CEapTtlsUiDialog::CheckActiveUserCertificate()
       
  1540     {
       
  1541     for ( TInt i = 0; i < iUiUserCertificates->Count(); i++ )
       
  1542         {
       
  1543         if ( iUiUserCertificates->At( i ).iIsEnabled )
       
  1544             {
       
  1545             return i;
       
  1546             }
       
  1547         }
       
  1548     
       
  1549     return KErrNotFound;
       
  1550     }
       
  1551 
       
  1552 
       
  1553 // -----------------------------------------------------------------------------
       
  1554 // CEapTtlsUiDialog::CheckActiveCaCertificate
       
  1555 // -----------------------------------------------------------------------------
       
  1556 //
       
  1557 TInt CEapTtlsUiDialog::CheckActiveCaCertificate()
       
  1558     {
       
  1559     for ( TInt i = 0; i < iUiCACertificates->Count(); i++ )
       
  1560         {
       
  1561         if ( iUiCACertificates->At( i ).iIsEnabled )
       
  1562             {
       
  1563             return i;
       
  1564             }
       
  1565         }
       
  1566 
       
  1567     return KErrNotFound;
       
  1568     }
       
  1569 
       
  1570 
       
  1571 // -----------------------------------------------------------------------------
       
  1572 // CEapTtlsUiDialog::UserCertificateHouseKeeping
       
  1573 // -----------------------------------------------------------------------------
       
  1574 //
       
  1575 void CEapTtlsUiDialog::UserCertificateHouseKeeping( TInt aSelected )
       
  1576     {
       
  1577     for ( TInt i = 0; i < iUiUserCertificates->Count(); i++ )
       
  1578         {
       
  1579         iUiUserCertificates->At( i ).iIsEnabled = EFalse;
       
  1580         }
       
  1581 
       
  1582     if ( aSelected != 0 ) // Zero index is none
       
  1583         {
       
  1584         iUiUserCertificates->At( aSelected-1 ).iIsEnabled = ETrue;
       
  1585         }
       
  1586     }
       
  1587 
       
  1588 
       
  1589 // -----------------------------------------------------------------------------
       
  1590 // CEapTtlsUiDialog::CaCertificateHouseKeeping
       
  1591 // -----------------------------------------------------------------------------
       
  1592 //
       
  1593 void CEapTtlsUiDialog::CaCertificateHouseKeeping( TInt aSelected )
       
  1594     {
       
  1595     for ( TInt i = 0; i < iUiCACertificates->Count(); i++ )
       
  1596         {
       
  1597         iUiCACertificates->At( i ).iIsEnabled = EFalse;
       
  1598         }
       
  1599 
       
  1600     if ( aSelected != 0 ) // Zero index is none
       
  1601         {        
       
  1602         iUiCACertificates->At( aSelected-1 ).iIsEnabled = ETrue;    
       
  1603         }
       
  1604     }
       
  1605 
       
  1606 
       
  1607 // -----------------------------------------------------------------------------
       
  1608 // CEapTtlsUiDialog::CreateEapTypeDataBaseL
       
  1609 // -----------------------------------------------------------------------------
       
  1610 //
       
  1611 void CEapTtlsUiDialog::CreateEapTypeDataBaseL()
       
  1612     {
       
  1613     RImplInfoPtrArray eapArray;
       
  1614     eapArray.Reset();
       
  1615 
       
  1616     REComSession::ListImplementationsL( KEapTypeInterfaceUid, eapArray );
       
  1617     TInt allowedInTtlsCount( 0 );
       
  1618     for ( TInt i = 0; i < eapArray.Count(); i++ )
       
  1619         {
       
  1620         if ( !CEapType::IsDisallowedInsideTTLS(*eapArray[i]) )
       
  1621             {
       
  1622             CImplementationInformation* info = eapArray[i];
       
  1623             TEapTlsPeapUiEapType tempEapType;
       
  1624             tempEapType.iEapType = info->DataType();
       
  1625             
       
  1626             // BINARY RESOURCE DATA
       
  1627             
       
  1628             // [FE] [00 00 00] [TEapType_bigendian]
       
  1629             // OR
       
  1630             // [FE] [FF FF FF] [MSCHAPv2_bigendian]
       
  1631             
       
  1632             _LIT8( KExpEapFirstQuad, "\xFE\0\0\0" );
       
  1633             TPtrC8 firstQuad( tempEapType.iEapType.Ptr(), 4 );
       
  1634             // TUint32 dataType = BigEndian::Get32( tempEapType.iEapType.Ptr()+4 );
       
  1635             TUint32 dataType = ( tempEapType.iEapType[4] << 24 ) |
       
  1636                                ( tempEapType.iEapType[5] << 16 ) |
       
  1637                                ( tempEapType.iEapType[6] << 8 ) |
       
  1638                                tempEapType.iEapType[7];
       
  1639             
       
  1640     
       
  1641             if ( !firstQuad.Compare( KExpEapFirstQuad ) && 
       
  1642                  ( dataType == EAPSettings::EEapSim || 
       
  1643                    dataType == EAPSettings::EEapAka ) )
       
  1644                 {
       
  1645                 tempEapType.iIsEnabled = ETrue;
       
  1646                 iUiEapTypes->InsertL( KFirstElement, tempEapType );
       
  1647                 }
       
  1648             else
       
  1649                 {
       
  1650                 tempEapType.iIsEnabled = EFalse;
       
  1651                 iUiEapTypes->InsertL( allowedInTtlsCount, tempEapType );
       
  1652                 }
       
  1653 
       
  1654             allowedInTtlsCount++;
       
  1655             }
       
  1656         }
       
  1657 
       
  1658     __ASSERT_DEBUG( iUiEapTypes->Count() >= 2, User::Panic( _L("EAP-SIM/AKA missing"), 1) );
       
  1659     
       
  1660     // Check if EAP-SIM and EAP-AKA are in correct order
       
  1661     
       
  1662     // BINARY RESOURCE DATA
       
  1663     const TDesC8& firstEap = iUiEapTypes->At( KFirstElement ).iEapType;
       
  1664     const TDesC8& secondEap = iUiEapTypes->At( KSecondElement ).iEapType;
       
  1665     
       
  1666     TUint32 dataTypeFirst = ( firstEap[4] << 24 ) |
       
  1667                             ( firstEap[5] << 16 ) |
       
  1668                             ( firstEap[6] << 8 ) |
       
  1669                             firstEap[7];
       
  1670     TUint32 dataTypeSecond = ( secondEap[4] << 24 ) |
       
  1671                              ( secondEap[5] << 16 ) |
       
  1672                              ( secondEap[6] << 8 ) |
       
  1673                              secondEap[7];
       
  1674 
       
  1675     // If not, switch them
       
  1676     if ( dataTypeFirst == EAPSettings::EEapAka &&
       
  1677         dataTypeSecond == EAPSettings::EEapSim )
       
  1678         {
       
  1679         TEapTlsPeapUiEapType tempEapType = iUiEapTypes->At( KFirstElement );
       
  1680         iUiEapTypes->Delete( KFirstElement );
       
  1681         iUiEapTypes->InsertL( KSecondElement, tempEapType );
       
  1682         }
       
  1683     
       
  1684     iEapTypes->Update();
       
  1685     eapArray.ResetAndDestroy();        
       
  1686     }
       
  1687 
       
  1688 
       
  1689 // -----------------------------------------------------------------------------
       
  1690 // CEapTtlsUiDialog::SetCipherIconsL
       
  1691 // -----------------------------------------------------------------------------
       
  1692 //
       
  1693 void CEapTtlsUiDialog::SetCipherIconsL()
       
  1694     {
       
  1695     CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( 1 );
       
  1696     CleanupStack::PushL( icons );
       
  1697 
       
  1698     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
  1699 
       
  1700     CGulIcon* icon = CGulIcon::NewLC();
       
  1701     CFbsBitmap* bitmap = NULL;
       
  1702     CFbsBitmap* mask = NULL;    
       
  1703     AknsUtils::CreateColorIconL( skinInstance,
       
  1704                                  KAknsIIDQgnIndiMarkedAdd, 
       
  1705                                  KAknsIIDQsnIconColors, 
       
  1706                                  EAknsCIQsnIconColorsCG13, 
       
  1707                                  bitmap, 
       
  1708                                  mask, 
       
  1709                                  AknIconUtils::AvkonIconFileName(),
       
  1710                                  EMbmAvkonQgn_indi_marked_add, 
       
  1711                                  EMbmAvkonQgn_indi_marked_add_mask,
       
  1712                                  KRgbBlack );
       
  1713     icon->SetBitmap( bitmap );
       
  1714     icon->SetMask( mask );    
       
  1715     icons->AppendL( icon );
       
  1716                 
       
  1717     CleanupStack::Pop( icon ); 
       
  1718     CleanupStack::Pop( icons ); // icons
       
  1719     
       
  1720     iCipherSuiteListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
       
  1721   
       
  1722     }
       
  1723 
       
  1724 
       
  1725 // -----------------------------------------------------------------------------
       
  1726 // CEapTtlsUiDialog::SetEapIconsL
       
  1727 // -----------------------------------------------------------------------------
       
  1728 //
       
  1729 void CEapTtlsUiDialog::SetEapIconsL()
       
  1730     {
       
  1731     CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( 1 );
       
  1732     CleanupStack::PushL( icons );
       
  1733 
       
  1734     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
  1735 
       
  1736     CGulIcon* icon = CGulIcon::NewLC();
       
  1737     CFbsBitmap* bitmap = NULL;
       
  1738     CFbsBitmap* mask = NULL;    
       
  1739     AknsUtils::CreateColorIconL( skinInstance,
       
  1740                                  KAknsIIDQgnIndiMarkedAdd, 
       
  1741                                  KAknsIIDQsnIconColors, 
       
  1742                                  EAknsCIQsnIconColorsCG13, 
       
  1743                                  bitmap, 
       
  1744                                  mask, 
       
  1745                                  AknIconUtils::AvkonIconFileName(),
       
  1746                                  EMbmAvkonQgn_indi_marked_add, 
       
  1747                                  EMbmAvkonQgn_indi_marked_add_mask,
       
  1748                                  KRgbBlack );
       
  1749     icon->SetBitmap( bitmap );
       
  1750     icon->SetMask( mask );    
       
  1751     icons->AppendL( icon );
       
  1752                 
       
  1753     CleanupStack::Pop( icon ); 
       
  1754     CleanupStack::Pop( icons ); // icons
       
  1755 
       
  1756     iEapTypesListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
       
  1757     }
       
  1758 
       
  1759 
       
  1760 // -----------------------------------------------------------------------------
       
  1761 // CEapTtlsUiDialog::GetEnabledEapTypeCount
       
  1762 // -----------------------------------------------------------------------------
       
  1763 //
       
  1764 TUint CEapTtlsUiDialog::GetEnabledEapTypeCount()
       
  1765     {
       
  1766     TUint itemCount( 0 );
       
  1767     for( TInt i( 0 ); i < iUiEapTypes->Count(); ++i )
       
  1768         {
       
  1769         if( iUiEapTypes->At( i ).iIsEnabled )
       
  1770             {
       
  1771             ++itemCount;
       
  1772             }
       
  1773         }
       
  1774     return itemCount;
       
  1775     }
       
  1776 
       
  1777 
       
  1778 // -----------------------------------------------------------------------------
       
  1779 // CEapTtlsUiDialog::IsPlainMschapv2Enabled
       
  1780 // -----------------------------------------------------------------------------
       
  1781 //
       
  1782 TBool CEapTtlsUiDialog::IsPlainMschapv2Enabled()
       
  1783     {
       
  1784     TBool isEnabled( EFalse );
       
  1785     for( TUint i( 0 ); i < iUiEapTypes->Count(); ++i )
       
  1786         {
       
  1787         // was: _LIT8( KPlainMsChapV2ExpandedId, "\xFE\xFF\xFF\xFF\0\0\0\x1A" );
       
  1788         // workaround:
       
  1789         _LIT8( KPlainMsChapV2ExpandedId, "\xFE\xFF\xFF\xFF\0\0\0\x63" );
       
  1790 
       
  1791         const TDesC8& currEap = iUiEapTypes->At( i ).iEapType;
       
  1792 
       
  1793         if ( !currEap.Compare( KPlainMsChapV2ExpandedId ) )
       
  1794             {
       
  1795             isEnabled = iUiEapTypes->At( i ).iIsEnabled;
       
  1796             break;
       
  1797             }
       
  1798 
       
  1799         }
       
  1800     return isEnabled;
       
  1801     }
       
  1802 
       
  1803 // -----------------------------------------------------------------------------
       
  1804 // CEapTtlsUiDialog::IsPapEnabled
       
  1805 // -----------------------------------------------------------------------------
       
  1806 //
       
  1807 TBool CEapTtlsUiDialog::IsPapEnabled()
       
  1808     {
       
  1809     TBool isEnabled( EFalse );
       
  1810     for( TUint i( 0 ); i < iUiEapTypes->Count(); ++i )
       
  1811         {
       
  1812         _LIT8( KPapExpandedId, "\xFE\xFF\xFF\xFF\0\0\0\x62" );
       
  1813         const TDesC8& currEap = iUiEapTypes->At( i ).iEapType;
       
  1814         if ( !currEap.Compare( KPapExpandedId ) )
       
  1815             {
       
  1816             isEnabled = iUiEapTypes->At( i ).iIsEnabled;
       
  1817             break;
       
  1818             }
       
  1819         }
       
  1820     return isEnabled;
       
  1821     }
       
  1822     
       
  1823 
       
  1824 // -----------------------------------------------------------------------------
       
  1825 // CEapTtlsUiDialog::GetHelpContext
       
  1826 // -----------------------------------------------------------------------------
       
  1827 //
       
  1828 void CEapTtlsUiDialog::GetHelpContext( TCoeHelpContext& aContext ) const
       
  1829     {
       
  1830     aContext.iMajor = KHelpUidPlugin;
       
  1831     TPageIds index = static_cast<TPageIds>( ActivePageIndex() );
       
  1832     switch ( index )
       
  1833         {
       
  1834         case EEapTypePage:
       
  1835             {
       
  1836             aContext.iContext = KSET_HLP_WLAN_EAP_TTLS_TYPES;
       
  1837             break;
       
  1838             }
       
  1839 
       
  1840         case ECipherSuitePage:
       
  1841             {
       
  1842             aContext.iContext = KSET_HLP_WLAN_EAP_TTLS_SUITES;
       
  1843             break;
       
  1844             }
       
  1845 
       
  1846         default:
       
  1847             {
       
  1848             aContext.iContext = KSET_HLP_WLAN_EAP_TTLS_SETT;
       
  1849             break;
       
  1850             }
       
  1851         }
       
  1852     }
       
  1853 
       
  1854 
       
  1855 void CEapTtlsUiDialog::GetFullCertLabelL( const SCertEntry& aCert, 
       
  1856                                          TDes& aFullLabel )
       
  1857     {
       
  1858     TInt length = 0;
       
  1859 
       
  1860 	// For label.
       
  1861     length += aCert.iLabel.Length();
       
  1862 
       
  1863 	// For separator between label and primary name.    
       
  1864     length += KNameSeparator.iTypeLength;    
       
  1865     
       
  1866     // For primary name.
       
  1867     length += aCert.iPrimaryName.Length();
       
  1868 
       
  1869     if ( !( aCert.iLabel.Length() ) )
       
  1870         {	
       
  1871     	// For secondary name.
       
  1872 	    length += aCert.iSecondaryName.Length();
       
  1873         }
       
  1874     
       
  1875     if( length > aFullLabel.MaxLength() )
       
  1876         {
       
  1877 #if defined(_DEBUG) || defined(DEBUG)
       
  1878 		RDebug::Print(_L("CEapTtlsUiDialog::GetFullCertLabelL - ERROR! Length Mismatch in Certificate's full name\n") );
       
  1879 #endif
       
  1880         }
       
  1881 
       
  1882     HBufC* label = HBufC::NewL( length );
       
  1883     label->Des().Append( aCert.iLabel );
       
  1884 
       
  1885     label->Des().Append( KNameSeparator );
       
  1886     label->Des().Append( aCert.iPrimaryName );
       
  1887 
       
  1888     if ( !( aCert.iLabel.Length() ) )
       
  1889         {
       
  1890     	// Secondary name, only if no label. Certificate manager does the same way.
       
  1891 	    label->Des().Append( aCert.iSecondaryName );
       
  1892         }
       
  1893             
       
  1894 	aFullLabel.Copy( label->Des().Left( aFullLabel.MaxLength() ) );   
       
  1895     
       
  1896     delete label;
       
  1897     label = NULL;
       
  1898     }
       
  1899 
       
  1900 
       
  1901 // End of file