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