wlansecuritysettings/wlaneapsettingsui/EapMschapv2/ConfigUi/src/EapMschapv2UiSettingArray.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 MsChapv2 UI settings array
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "EapMschapv2UiSettingArray.h"
       
    22 #include "EapMschapv2Ui.hrh"
       
    23 #include <aknsettingitemlist.h>
       
    24 #include <akntextsettingpage.h>
       
    25 
       
    26 // CONSTANTS
       
    27 
       
    28 // String representing an empty password field on the UI
       
    29 _LIT( KEmptyPassword, "****" );
       
    30 
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CEapMsChapV2SettingItemArray::CEapMsChapV2SettingItemArray
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CEapMsChapV2SettingItemArray::CEapMsChapV2SettingItemArray()
       
    39     {
       
    40     }
       
    41 
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CEapMsChapV2SettingItemArray::NewL
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CEapMsChapV2SettingItemArray* CEapMsChapV2SettingItemArray::NewL() 
       
    48     {
       
    49     CEapMsChapV2SettingItemArray* self = 
       
    50                                 new( ELeave ) CEapMsChapV2SettingItemArray();
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop( self ); 
       
    54     return self;
       
    55     }
       
    56 
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CEapMsChapV2SettingItemArray::ConstructL
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CEapMsChapV2SettingItemArray::ConstructL() 
       
    63     {
       
    64     iArray = new( ELeave ) CAknSettingItemArray( 2, EFalse, 0 );
       
    65     }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CEapMsChapV2SettingItemArray::~CEapMsChapV2SettingItemArray
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CEapMsChapV2SettingItemArray::~CEapMsChapV2SettingItemArray()
       
    73     {
       
    74     if( iArray ) 
       
    75         {
       
    76         // ResetAndDestroy()
       
    77         iArray->ResetAndDestroy();
       
    78         }    
       
    79     delete iArray;   
       
    80     iArray = NULL;
       
    81     }
       
    82 
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CEapMsChapV2SettingItemArray::Item
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 CAknSettingItem* CEapMsChapV2SettingItemArray::Item( 
       
    89                                                 TEapMschapv2SettingItemId aId )
       
    90     {
       
    91     for( TInt i = 0; i < iArray->Count(); i++ )
       
    92     {
       
    93     if( iArray->At( i )->Identifier() == aId )
       
    94         {
       
    95         return iArray->At( i );
       
    96         }
       
    97     }
       
    98     __ASSERT_DEBUG( EFalse, User::Invariant() );
       
    99 
       
   100     return NULL;
       
   101     }
       
   102 
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CEapMsChapV2SettingItemArray::Array
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 CAknSettingItemArray* CEapMsChapV2SettingItemArray::Array()
       
   109     {
       
   110     return iArray;
       
   111     }
       
   112 
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CEapMsChapV2SettingItemArray::StoreSettingsL
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CEapMsChapV2SettingItemArray::StoreSettingsL()
       
   119     {
       
   120     // Do what SettingItemList::StoreSettings would do. 
       
   121     for( TInt i( 0 ); i < iArray->Count(); ++i )
       
   122         {
       
   123         iArray->At( i )->StoreL();
       
   124         }
       
   125     }
       
   126 
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CEapMsChapV2SettingItemArray::AddTextItemL
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 void CEapMsChapV2SettingItemArray::AddTextItemL( TDes& aBuffer, 
       
   133                                                  TInt aId, 
       
   134                                                  TInt aTitleResource, 
       
   135                                                  TInt aSettingPageResource,
       
   136                                                  TInt aAssociatedResource, 
       
   137                                                  TInt aOrdinal)
       
   138     {
       
   139     // Create new setting item
       
   140     CAknSettingItem* settingItem = 
       
   141                             new( ELeave ) CAknTextSettingItem( aId,  aBuffer );
       
   142     CleanupStack::PushL( settingItem );
       
   143     settingItem->SetEmptyItemTextL( KNullDesC );
       
   144     settingItem->SetSettingPageFlags( 
       
   145                                     CAknTextSettingPage::EZeroLengthAllowed );
       
   146     
       
   147     // Construct setting item with parametrized values
       
   148     HBufC* itemTitle = CEikonEnv::Static()->AllocReadResourceLC( 
       
   149                                                             aTitleResource );
       
   150     settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, 
       
   151                              aSettingPageResource, EAknCtPopupSettingList, 
       
   152                              NULL, aAssociatedResource );
       
   153     
       
   154     // Append item to settingitem-array
       
   155     iArray->InsertL( aOrdinal, settingItem );
       
   156     
       
   157     CleanupStack::PopAndDestroy( itemTitle );
       
   158 
       
   159     // Items are destroyed in destructor when resetting array
       
   160     CleanupStack::Pop( settingItem ); 
       
   161     }
       
   162 
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CEapMsChapV2SettingItemArray::AddPasswordItemL
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CEapMsChapV2SettingItemArray::AddPasswordItemL( TDes& aPassword, 
       
   169                                                      TInt aId, 
       
   170                                                      TInt aTitleResource, 
       
   171                                                      TInt aSettingPageResource,
       
   172                                                      TInt aAssociatedResource, 
       
   173                                                      TInt aOrdinal)
       
   174     {
       
   175     // Create new setting item
       
   176     CAknSettingItem* settingItem = new ( ELeave ) CAknPasswordSettingItem( aId,
       
   177                                             CAknPasswordSettingItem::EAlpha,
       
   178                                             aPassword );
       
   179     CleanupStack::PushL( settingItem );
       
   180     settingItem->SetEmptyItemTextL( KEmptyPassword );
       
   181     
       
   182     // Construct setting item with parametrized values
       
   183     HBufC* itemTitle = CEikonEnv::Static()->AllocReadResourceLC( 
       
   184                                                             aTitleResource );
       
   185    
       
   186     settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, 
       
   187                              aSettingPageResource, EAknCtPopupSettingList, 
       
   188                              NULL, aAssociatedResource );
       
   189     
       
   190     // Append item to settingitem-array
       
   191     iArray->InsertL( aOrdinal, settingItem );
       
   192     
       
   193     CleanupStack::PopAndDestroy( itemTitle );
       
   194     CleanupStack::Pop( settingItem );
       
   195     }     
       
   196 
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CEapMsChapV2SettingItemArray::AddBinarySettingItemL
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 void CEapMsChapV2SettingItemArray::AddBinarySettingItemL( 
       
   203                                                 TInt aSettingPageResourceId,
       
   204                                                 TInt aTitleResourceId, 
       
   205                                                 TInt aAssociatedResourceId,
       
   206                                                 TInt aOrdinal, 
       
   207                                                 TBool& aModifiedValue )
       
   208     {
       
   209     CAknSettingItem* settingItem = 
       
   210                 new( ELeave ) CAknBinaryPopupSettingItem( 0, aModifiedValue );
       
   211     CleanupStack::PushL( settingItem );
       
   212 
       
   213     HBufC* itemTitle = CEikonEnv::Static()->AllocReadResourceLC( 
       
   214                                                             aTitleResourceId );
       
   215     settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, 
       
   216                              aSettingPageResourceId, EAknCtPopupSettingList, 
       
   217                              NULL, aAssociatedResourceId );
       
   218     iArray->AppendL( settingItem );
       
   219 
       
   220     CleanupStack::PopAndDestroy( itemTitle );
       
   221     CleanupStack::Pop( settingItem );
       
   222     }
       
   223 
       
   224 
       
   225 //  End of File