wlansecuritysettings/wlaneapsettingsui/EapAka/ConfigUi/src/EapAkaUiSettingArray.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 AKA UI settings array
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "EapAkaUiSettingArray.h"
       
    22 #include "EapAkaUi.hrh"
       
    23 #include <aknsettingitemlist.h>
       
    24 #include <akntextsettingpage.h>
       
    25 
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CEapAkaSettingItemArray::CEapAkaSettingItemArray
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CEapAkaSettingItemArray::CEapAkaSettingItemArray()
       
    34     {
       
    35     }
       
    36 
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CEapAkaSettingItemArray::NewL
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CEapAkaSettingItemArray* CEapAkaSettingItemArray::NewL() 
       
    43     {
       
    44     CEapAkaSettingItemArray* self = new( ELeave ) CEapAkaSettingItemArray();
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     CleanupStack::Pop( self ); 
       
    48     return self;
       
    49     }
       
    50 
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // CEapAkaSettingItemArray::~CEapAkaSettingItemArray
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CEapAkaSettingItemArray::~CEapAkaSettingItemArray()
       
    57     {
       
    58     if( iArray ) 
       
    59         {
       
    60         // ResetAndDestroy()
       
    61         iArray->ResetAndDestroy();
       
    62         }    
       
    63     delete iArray;   
       
    64     iArray = NULL;
       
    65     }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CEapAkaSettingItemArray::Item
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CAknSettingItem* CEapAkaSettingItemArray::Item( TEapAkaUiSettingPageIds 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 // CEapAkaSettingItemArray::Array
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 CAknSettingItemArray* CEapAkaSettingItemArray::Array() 
       
    92     {
       
    93     return iArray;
       
    94     }
       
    95 
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CEapAkaSettingItemArray::StoreSettingsL
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void CEapAkaSettingItemArray::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 // CEapAkaSettingItemArray::ConstructL
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CEapAkaSettingItemArray::ConstructL() 
       
   116     {
       
   117     iArray = new( ELeave ) CAknSettingItemArray( 2, EFalse, 0 );
       
   118     }
       
   119 
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CEapAkaSettingItemArray::AddTextItemL
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 void CEapAkaSettingItemArray::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 // CEapAkaSettingItemArray::AddBinarySettingItemL
       
   159 // -----------------------------------------------------------------------------
       
   160 //
       
   161 void CEapAkaSettingItemArray::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     HBufC* itemTitle = CEikonEnv::Static()->AllocReadResourceLC( 
       
   172                                                             aTitleResourceId );
       
   173     settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, 
       
   174                              aSettingPageResourceId, EAknCtPopupSettingList, 
       
   175                              NULL, aAssociatedResourceId );
       
   176 
       
   177     iArray->AppendL( settingItem );
       
   178     CleanupStack::PopAndDestroy( itemTitle );
       
   179     CleanupStack::Pop( settingItem );
       
   180     }
       
   181 
       
   182 
       
   183 //  End of File