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