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