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