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