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