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