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