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