|
1 /* |
|
2 * Copyright (c) 2006 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 "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: List box for the SUPL Settings UI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Includes |
|
20 #include <e32keys.h> |
|
21 #include <locsuplsettingsui.rsg> |
|
22 #include <avkon.rsg> |
|
23 #include <StringLoader.h> |
|
24 #include <centralrepository.h> |
|
25 #include <epos_csuplsettings.h> |
|
26 |
|
27 |
|
28 // User Include |
|
29 #include "locsuplsettingslbmodel.h" |
|
30 #include "locsuplsettingsuiengine.h" |
|
31 #include "locsuplsettingsprivatecrkeys.h" |
|
32 #include "epos_omasuplconfigurationkeys.h" |
|
33 #include "locsupldebug.h" |
|
34 |
|
35 // Constants |
|
36 |
|
37 const TInt KMaxConversionBufferLength = 0x200; |
|
38 |
|
39 _LIT( KDefaultServerIPAddress, " " ); |
|
40 |
|
41 // ========================= MEMBER FUNCTIONS ================================ |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CLocSUPLSettingsLBModel::CLocSUPLSettingsLBModel |
|
45 // Default Constructor |
|
46 // |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CLocSUPLSettingsLBModel::CLocSUPLSettingsLBModel( |
|
50 CLocSUPLSettingsUiEngine& aEngine ) |
|
51 :iEngine( aEngine ) |
|
52 { |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CLocSUPLSettingsLBModel::~CLocSUPLSettingsLBModel |
|
57 // Destructor |
|
58 // |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 CLocSUPLSettingsLBModel::~CLocSUPLSettingsLBModel() |
|
62 { |
|
63 DEBUG( + CLocSUPLSettingsLBModel::~CLocSUPLSettingsLBModel ); |
|
64 // Delete the Buffers |
|
65 delete iBuffer; |
|
66 iBuffer = NULL; |
|
67 |
|
68 delete iServerDetailTitle; |
|
69 iServerDetailTitle = NULL; |
|
70 |
|
71 delete iSuplUsageTitle; |
|
72 iSuplUsageTitle = NULL; |
|
73 |
|
74 delete iSuplServerDetail; |
|
75 iSuplServerDetail = NULL; |
|
76 |
|
77 delete iDefaultSuplUsage; |
|
78 iDefaultSuplUsage = NULL; |
|
79 DEBUG( - CLocSUPLSettingsLBModel::~CLocSUPLSettingsLBModel ); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CLocSUPLSettingsLBModel* CLocSUPLSettingsLBModel::NewL |
|
84 // Two-phased constructor |
|
85 // |
|
86 // @param aEngine Reference the SUPL Settings Engine |
|
87 // @return CLocSUPLSettingsLBModel* Reference to the object created |
|
88 // |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 CLocSUPLSettingsLBModel* CLocSUPLSettingsLBModel::NewL( |
|
92 CLocSUPLSettingsUiEngine& aEngine ) |
|
93 { |
|
94 DEBUG( + CLocSUPLSettingsLBModel::NewL ); |
|
95 CLocSUPLSettingsLBModel* self = CLocSUPLSettingsLBModel::NewLC( aEngine ); |
|
96 CleanupStack::Pop( self ); |
|
97 DEBUG( - CLocSUPLSettingsLBModel::NewL ); |
|
98 return self; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CLocSUPLSettingsLBModel* CLocSUPLSettingsLBModel::NewLC |
|
103 // Two-phased constructor |
|
104 // |
|
105 // @param aEngine Reference the SUPL Settings Engine |
|
106 // @return CLocSUPLSettingsLBModel* Reference to the object created |
|
107 // |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CLocSUPLSettingsLBModel* CLocSUPLSettingsLBModel::NewLC( |
|
111 CLocSUPLSettingsUiEngine& aEngine ) |
|
112 { |
|
113 CLocSUPLSettingsLBModel* self = |
|
114 new( ELeave )CLocSUPLSettingsLBModel( aEngine ); |
|
115 CleanupStack::PushL( self ); |
|
116 self->ConstructL(); |
|
117 return self; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // void CLocSUPLSettingsLBModel::ConstructL |
|
122 // Second Phase of the two phase constructor. |
|
123 // |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 void CLocSUPLSettingsLBModel::ConstructL() |
|
127 { |
|
128 DEBUG( + CLocSUPLSettingsLBModel::ConstructL ); |
|
129 // Allocate the Conversion Buffer |
|
130 iBuffer = HBufC16::NewL( KMaxConversionBufferLength ); |
|
131 |
|
132 // Read the Local Variation Key and set the Item count |
|
133 TInt flagValue = 0; |
|
134 CRepository* repository = CRepository::NewLC( TUid::Uid( KCRUidLocSuplSettingsUi ) ); |
|
135 repository->Get( KLocSuplSettingsLVFlags, flagValue ); |
|
136 CleanupStack::PopAndDestroy( repository ); |
|
137 repository = NULL; |
|
138 if( flagValue ) |
|
139 { |
|
140 iServerAddressPresent = ETrue; |
|
141 |
|
142 // Allocate and set the server ip address title field |
|
143 iServerDetailTitle = StringLoader::LoadL( R_LOC_SUPL_SERVER_DETAIL ); |
|
144 |
|
145 // Allocate the Default IP address |
|
146 iSuplServerDetail = HBufC16::NewL( KDefaultServerIPAddress().Length() ); |
|
147 TPtr16 ptr( iSuplServerDetail->Des() ); |
|
148 ptr.Copy( KDefaultServerIPAddress ); |
|
149 } |
|
150 |
|
151 // Reinitializing the flag value |
|
152 flagValue = 0; |
|
153 TRAPD( error, repository = CRepository::NewL( KCRUidOMASuplConfiguration ) ); |
|
154 if ( !error ) |
|
155 { |
|
156 error = repository->Get( KOMASuplConfigurationSuplPermissionQueryUsage, flagValue ); |
|
157 if ( error || flagValue < 0 ) |
|
158 { |
|
159 flagValue = 0; |
|
160 } |
|
161 delete repository; |
|
162 repository = NULL; |
|
163 } |
|
164 |
|
165 // Check for SUPL Setting usage variationing. |
|
166 if( flagValue ) |
|
167 { |
|
168 iSuplUsagePresent = ETrue; |
|
169 |
|
170 // Allocate and set the server ip address title field |
|
171 iSuplUsageTitle = StringLoader::LoadL( R_LOC_SUPL_USE ); |
|
172 |
|
173 iDefaultSuplUsage = StringLoader::LoadL( R_AVKON_SELEC_SETT_VAL_FIELD_NONE ); |
|
174 // Default value can be used for this field as well |
|
175 // So no need to have another variable. |
|
176 } |
|
177 |
|
178 DEBUG( - CLocSUPLSettingsLBModel::ConstructL ); |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // TSUPLSettingsItemId CLocSUPLSettingsLBModel::ResolveSettingsItem |
|
183 // Packs the server address to the end of the buffer passed. |
|
184 // |
|
185 // @param aPtr Buffer to which the server address needs to be appended. |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 CLocSUPLSettingsLBModel::TSUPLSettingsItemId |
|
189 CLocSUPLSettingsLBModel::ResolveSettingsItem( TInt aListboxIndex ) const |
|
190 { |
|
191 DEBUG( + CLocSUPLSettingsLBModel::ResolveSettingsItem ); |
|
192 TSUPLSettingsItemId selectedItem = ESUPLSettingsUsage; |
|
193 |
|
194 switch ( aListboxIndex ) |
|
195 { |
|
196 case 0: |
|
197 { |
|
198 selectedItem = ESUPLSettingsUsage; |
|
199 break; |
|
200 } |
|
201 case 1: |
|
202 { |
|
203 selectedItem = ESUPLSettingsServersDetail; |
|
204 break; |
|
205 } |
|
206 case 2: |
|
207 { |
|
208 selectedItem = ESUPLSettingsActiveSessions; |
|
209 break; |
|
210 } |
|
211 default: |
|
212 { |
|
213 break; |
|
214 } |
|
215 } |
|
216 DEBUG( - CLocSUPLSettingsLBModel::ResolveSettingsItem ); |
|
217 return selectedItem; |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // TInt CLocSUPLSettingsLBModel::MdcaCount() const |
|
222 // Inherited from MDesCArray. Returns the total number of items in the |
|
223 // Settings description array |
|
224 // |
|
225 // @return TInt The total number of elements in the Settings Description array |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 TInt CLocSUPLSettingsLBModel::MdcaCount() const |
|
229 { |
|
230 DEBUG( + CLocSUPLSettingsLBModel::MdcaCount ); |
|
231 // Initialize the count to 0 |
|
232 TInt itemCount = 0; |
|
233 |
|
234 // Check for SUPL usage. |
|
235 if ( iSuplUsagePresent ) |
|
236 { |
|
237 itemCount++; |
|
238 // Check if the usage value is disabled |
|
239 if ( iEngine.GetSuplUsage() == CSuplSettings::ESuplUsageDisabled ) |
|
240 { |
|
241 return itemCount; |
|
242 } |
|
243 // Check for Server address |
|
244 iServerAddressPresent ? itemCount++ : itemCount; |
|
245 } |
|
246 itemCount++; // For the third entry "Active sessions" |
|
247 // Check if the SUPL Usage value is Disabled |
|
248 // If that is the case then only SUPL usage will be displayed |
|
249 DEBUG( - CLocSUPLSettingsLBModel::MdcaCount ); |
|
250 return itemCount; |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // TPtrC16 CLocSUPLSettingsLBModel::MdcaPoint() const |
|
255 // Inherited from MDesCArray. Returns the list box entry corresponding to the |
|
256 // index value |
|
257 // |
|
258 // @param aIndex The index whose list box entry needs to be retrieved |
|
259 // @return TPtr16 The list box description |
|
260 // --------------------------------------------------------------------------- |
|
261 // |
|
262 TPtrC16 CLocSUPLSettingsLBModel::MdcaPoint( TInt aIndex ) const |
|
263 { |
|
264 DEBUG( + CLocSUPLSettingsLBModel::MdcaPoint ); |
|
265 // Zero the internal buffer |
|
266 TPtr16 ptr( iBuffer->Des() ); |
|
267 ptr.Zero(); |
|
268 |
|
269 // CAknSettingStyleListBox |
|
270 // Format "\t%S\t\t%S" |
|
271 |
|
272 // Append the first tab |
|
273 ptr.Append( EKeyTab ); |
|
274 |
|
275 TSUPLSettingsItemId index = ResolveSettingsItem( aIndex ); |
|
276 switch( index ) |
|
277 { |
|
278 case ESUPLSettingsUsage: |
|
279 { |
|
280 AppendSuplUsage( ptr ); |
|
281 break; |
|
282 } |
|
283 case ESUPLSettingsServersDetail: |
|
284 { |
|
285 AppendSuplServerDetail( ptr ); |
|
286 break; |
|
287 } |
|
288 case ESUPLSettingsActiveSessions: |
|
289 { |
|
290 TRAP_IGNORE( AppendSuplActiveSessionsDetailL( ptr ) ); |
|
291 break; |
|
292 } |
|
293 default: |
|
294 { |
|
295 // Append the second tab |
|
296 ptr.Append( EKeyTab ); |
|
297 // Append the third tab |
|
298 ptr.Append( EKeyTab ); |
|
299 break; |
|
300 } |
|
301 } |
|
302 DEBUG( - CLocSUPLSettingsLBModel::MdcaPoint ); |
|
303 return iBuffer->Des(); |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // TPtrC16 CLocSUPLSettingsLBModel::AppendSuplServerDetail() |
|
308 // Packs the server address to the end of the buffer passed. |
|
309 // |
|
310 // @param aPtr Buffer to which the server address needs to be appended. |
|
311 // --------------------------------------------------------------------------- |
|
312 // |
|
313 void CLocSUPLSettingsLBModel::AppendSuplUsage( TDes& aPtr ) const |
|
314 { |
|
315 DEBUG( + CLocSUPLSettingsLBModel::AppendSuplUsage ); |
|
316 // Append the Title text |
|
317 aPtr.Append( iSuplUsageTitle->Des() ); |
|
318 |
|
319 // Append the second tab |
|
320 aPtr.Append( EKeyTab ); |
|
321 |
|
322 // Append the third tab |
|
323 aPtr.Append( EKeyTab ); |
|
324 |
|
325 // Obtain the SUPL usage from the SUPL Settings Engine. If |
|
326 // the settings is not set then a Not defined value would be |
|
327 // displayed to the user |
|
328 TPtr16 suplUsagePtr( NULL, 0 ); |
|
329 TRAPD( error, suplUsagePtr.Set( iEngine.GetSuplUsageL() ) ); |
|
330 if( error || !suplUsagePtr.Length() ) |
|
331 { |
|
332 // Using the same string as SUPL settings AP |
|
333 aPtr.Append( iDefaultSuplUsage->Des() ); |
|
334 } |
|
335 else |
|
336 { |
|
337 aPtr.Append( suplUsagePtr ); |
|
338 } |
|
339 DEBUG( - CLocSUPLSettingsLBModel::AppendSuplUsage ); |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // TPtrC16 CLocSUPLSettingsLBModel::AppendSuplServerDetail() |
|
344 // Packs the server address to the end of the buffer passed. |
|
345 // |
|
346 // @param aPtr Buffer to which the server address needs to be appended. |
|
347 // --------------------------------------------------------------------------- |
|
348 // |
|
349 void CLocSUPLSettingsLBModel::AppendSuplServerDetail( TDes& aPtr ) const |
|
350 { |
|
351 DEBUG( + CLocSUPLSettingsLBModel::AppendSuplServerDetail ); |
|
352 // Append the Title text |
|
353 aPtr.Append( iServerDetailTitle->Des() ); |
|
354 |
|
355 // Append the second tab |
|
356 aPtr.Append( EKeyTab ); |
|
357 |
|
358 // Append the third tab |
|
359 aPtr.Append( EKeyTab ); |
|
360 |
|
361 // Append the forth tab |
|
362 aPtr.Append( EKeyTab ); |
|
363 DEBUG( - CLocSUPLSettingsLBModel::AppendSuplServerDetail ); |
|
364 } |
|
365 |
|
366 // --------------------------------------------------------------------------- |
|
367 // TPtrC16 CLocSUPLSettingsLBModel::AppendSuplActiveSessionsDetailL() |
|
368 // Packs the server address to the end of the buffer passed. |
|
369 // |
|
370 // @param aPtr Buffer to which the server address needs to be appended. |
|
371 // --------------------------------------------------------------------------- |
|
372 // |
|
373 void CLocSUPLSettingsLBModel::AppendSuplActiveSessionsDetailL( TDes& aPtr ) const |
|
374 { |
|
375 DEBUG( + CLocSUPLSettingsLBModel::AppendSuplActiveSessionsDetailL ); |
|
376 |
|
377 HBufC16* suplActiveSessionsTitle; |
|
378 |
|
379 TRAPD( error, iEngine.GetActiveSessionsCountL( iSessionCount ) ); |
|
380 |
|
381 if( !error ) |
|
382 { |
|
383 switch( iSessionCount ) |
|
384 { |
|
385 case 0: |
|
386 suplActiveSessionsTitle = StringLoader::LoadL( R_LOC_SUPL_NO_SERVICE ); |
|
387 break; |
|
388 case 1: |
|
389 suplActiveSessionsTitle = StringLoader::LoadL( R_LOC_SUPL_SINGLE_SERVICE ); |
|
390 break; |
|
391 default: |
|
392 suplActiveSessionsTitle = StringLoader::LoadL( R_LOC_SUPL_MULTIPLE_SERVICES, iSessionCount ); |
|
393 break; |
|
394 } |
|
395 |
|
396 if( suplActiveSessionsTitle ) |
|
397 { |
|
398 // Append the Title text |
|
399 aPtr.Append( suplActiveSessionsTitle->Des() ); |
|
400 delete suplActiveSessionsTitle; |
|
401 suplActiveSessionsTitle = NULL; |
|
402 } |
|
403 } |
|
404 |
|
405 // Append the second tab |
|
406 aPtr.Append( EKeyTab ); |
|
407 |
|
408 // Append the third tab |
|
409 aPtr.Append( EKeyTab ); |
|
410 |
|
411 // Append the forth tab |
|
412 aPtr.Append( EKeyTab ); |
|
413 |
|
414 DEBUG( - CLocSUPLSettingsLBModel::AppendSuplActiveSessionsDetailL ); |
|
415 } |
|
416 |
|
417 // --------------------------------------------------------------------------- |
|
418 // TInt CLocSUPLSettingsLBModel::ActiveSessionCount() |
|
419 // Returns the number of Active sessions. |
|
420 // |
|
421 // @return TInt Returns the number of Active sessions count. |
|
422 // --------------------------------------------------------------------------- |
|
423 // |
|
424 TInt CLocSUPLSettingsLBModel::ActiveSessionCount( ) const |
|
425 { |
|
426 return iSessionCount; |
|
427 } |
|
428 |
|
429 |
|
430 // End of file |