wlansecuritysettings/wlaneapsettingsui/pap/configui/src/papuisettingarray.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 PAP UI settings array
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "papuisettingarray.h"
       
    22 #include "papui.hrh"
       
    23 #include "papuipwsettingitem.h"
       
    24 #include <papui.rsg>
       
    25 #include <aknsettingitemlist.h>
       
    26 #include <akntextsettingpage.h>
       
    27 
       
    28 // CONSTANTS
       
    29 _LIT( KEmptyPassword, "****" );
       
    30 
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // CPapSettingItemArray::CPapSettingItemArray
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CPapSettingItemArray::CPapSettingItemArray()
       
    39     {
       
    40     iEnv = CEikonEnv::Static();
       
    41     }
       
    42 
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CPapSettingItemArray::NewL
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CPapSettingItemArray* CPapSettingItemArray::NewL() 
       
    49     {
       
    50     CPapSettingItemArray* self = new( ELeave ) CPapSettingItemArray();
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     CleanupStack::Pop( self ); // self
       
    54     return self;
       
    55     }
       
    56 
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CPapSettingItemArray::ConstructL
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 void CPapSettingItemArray::ConstructL() 
       
    63     {
       
    64     iArray = new( ELeave ) CAknSettingItemArray( 2, EFalse, 0 );
       
    65     }
       
    66 
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CPapSettingItemArray::~CPapSettingItemArray
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 CPapSettingItemArray::~CPapSettingItemArray()
       
    73     {
       
    74     if( iArray ) 
       
    75         {
       
    76         // ResetAndDestroy()
       
    77         iArray->ResetAndDestroy();
       
    78         }    
       
    79     delete iArray;   
       
    80     iArray = NULL;
       
    81     }
       
    82 
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CPapSettingItemArray::Item
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 CAknSettingItem* CPapSettingItemArray::Item( TPapSettingItemId aId )
       
    89     {
       
    90     for( TInt i = 0; i < iArray->Count(); i++ )
       
    91         {
       
    92         if( iArray->At( i )->Identifier() == aId )
       
    93             {
       
    94             return iArray->At( i );
       
    95             }
       
    96         }
       
    97 
       
    98     __ASSERT_DEBUG( EFalse, User::Invariant() );
       
    99     return NULL;
       
   100     }
       
   101 
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CEapFastSettingItemArray::Array
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 CAknSettingItemArray* CPapSettingItemArray::Array() 
       
   108     {
       
   109     return iArray;
       
   110     }
       
   111 
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CPapSettingItemArray::StoreSettingsL
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 void CPapSettingItemArray::StoreSettingsL()
       
   118     {
       
   119     // Do what SettingItemList::StoreSettings would do. 
       
   120     for( TInt i( 0 ); i < iArray->Count(); ++i ) 
       
   121         {
       
   122         iArray->At( i )->StoreL();
       
   123         }
       
   124     }
       
   125 
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CPapSettingItemArray::AddTextItemL
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 void CPapSettingItemArray::AddTextItemL( TDes& aBuffer, 
       
   132                                              TInt aId, 
       
   133                                              TInt aTitleResource, 
       
   134                                              TInt aSettingPageResource, 
       
   135                                              TInt aAssociatedResource, 
       
   136                                              TInt aOrdinal)
       
   137     {
       
   138     // Create new setting item
       
   139     CAknTextSettingItem* settingItem = 
       
   140                             new( ELeave ) CAknTextSettingItem( aId, aBuffer );
       
   141     CleanupStack::PushL( settingItem );
       
   142     
       
   143     HBufC* usernameNotDefinedText = iEnv->AllocReadResourceLC(
       
   144         R_PAP_USERNAME_NOT_DEFINED );
       
   145     settingItem->SetEmptyItemTextL( *usernameNotDefinedText );
       
   146     CleanupStack::PopAndDestroy( usernameNotDefinedText );
       
   147 
       
   148     settingItem->SetSettingPageFlags(
       
   149         CAknTextSettingPage::EZeroLengthNotOffered );
       
   150 
       
   151     // Construct setting item with parametrized values
       
   152     HBufC* itemTitle = iEnv->AllocReadResourceLC( aTitleResource );
       
   153     settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, 
       
   154                              aSettingPageResource, EAknCtPopupSettingList,
       
   155                              NULL, aAssociatedResource );
       
   156     
       
   157     // Append item to settingitem-array
       
   158     iArray->InsertL( aOrdinal, settingItem );
       
   159     
       
   160     CleanupStack::PopAndDestroy( itemTitle );
       
   161     // Items are destroyed in destructor when resetting array
       
   162     CleanupStack::Pop( settingItem ); 
       
   163     }
       
   164 
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CPapSettingItemArray::AddBinarySettingItemL
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 void CPapSettingItemArray::AddBinarySettingItemL( 
       
   171                                                 TInt aSettingPageResourceId,
       
   172                                                 TInt aTitleResourceId, 
       
   173                                                 TInt aAssociatedResourceId,
       
   174                                                 TInt aOrdinal, 
       
   175                                                 TBool& aModifiedValue )
       
   176     {
       
   177     CAknSettingItem* settingItem = new ( ELeave ) 
       
   178         CAknBinaryPopupSettingItem( 0, aModifiedValue );
       
   179     CleanupStack::PushL( settingItem );
       
   180 
       
   181     HBufC* itemTitle = iEnv->AllocReadResourceLC( aTitleResourceId );
       
   182     settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, 
       
   183                              aSettingPageResourceId, EAknCtPopupSettingList, 
       
   184                              NULL, aAssociatedResourceId );
       
   185     iArray->AppendL( settingItem );
       
   186 
       
   187     CleanupStack::PopAndDestroy( itemTitle );
       
   188     CleanupStack::Pop( settingItem );
       
   189     }
       
   190     
       
   191 // -----------------------------------------------------------------------------
       
   192 // CPapSettingItemArray::AddPasswordItemL
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 void CPapSettingItemArray::AddPasswordItemL( TDes& aPassword, 
       
   196                                TInt aId, 
       
   197                                TInt aTitleResource, 
       
   198                                TInt aSettingPageResource, 
       
   199                                TInt aAssociatedResource, 
       
   200                                TInt aOrdinal )
       
   201     {
       
   202     // Create new setting item    
       
   203     CPapUiPwSettingItem* settingItem = new( ELeave ) CPapUiPwSettingItem( aId,
       
   204                                             CAknPasswordSettingItem::EAlpha,
       
   205                                             aPassword, this ); 
       
   206     CleanupStack::PushL( settingItem );
       
   207     settingItem->SetEmptyItemTextL( KEmptyPassword );
       
   208     
       
   209     settingItem->SetSettingPageFlags( 
       
   210                                     CAknTextSettingPage::EZeroLengthAllowed );
       
   211     
       
   212     // Construct setting item with parametrized values
       
   213     HBufC* itemTitle = iEnv->AllocReadResourceLC( aTitleResource );
       
   214    
       
   215 
       
   216     settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, 
       
   217                              aSettingPageResource, EAknCtPopupSettingList, 
       
   218                              NULL, aAssociatedResource );
       
   219     
       
   220     // Append item to settingitem-array
       
   221     iArray->InsertL( aOrdinal, settingItem );
       
   222     
       
   223     CleanupStack::PopAndDestroy( itemTitle );
       
   224     CleanupStack::Pop( settingItem );
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CPapSettingItemArray::PwItemCancelled
       
   229 // -----------------------------------------------------------------------------
       
   230 //    
       
   231 void CPapSettingItemArray::PwItemCancelled( TBool aIsCancelled )                       
       
   232     {
       
   233     iPwItemCancelled = aIsCancelled;
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CPapSettingItemArray::IsPwItemCancelled
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 TBool CPapSettingItemArray::IsPwItemCancelled()
       
   241     {
       
   242     return iPwItemCancelled;
       
   243     }
       
   244  
       
   245 //  End of File