|
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: Defines common UI methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <aknlists.h> // CAknDoubleLargeGraphicPopupMenuStyleListBox |
|
19 #include <aknPopup.h> // CAknPopupList |
|
20 #include <AknQueryDialog.h> |
|
21 #include <aknnotedialog.h> |
|
22 #include <badesca.h> // CDesCArray |
|
23 #include <e32def.h> |
|
24 #include <e32std.h> |
|
25 #include <eikfrlb.h> // CEikFormattedCellListBox |
|
26 #include <eiklbm.h> // ELbmDoesNotOwnItemArray |
|
27 #include <gulicon.h> |
|
28 #include <StringLoader.h> |
|
29 #include <cmmanager.rsg> |
|
30 |
|
31 #include <cmcommonconstants.h> |
|
32 #include <cmcommonui.h> |
|
33 #include "cmlogger.h" |
|
34 #include "cmmanagerimpl.h" |
|
35 #include "cmmanager.hrh" |
|
36 #include <cmconnectionmethoddef.h> |
|
37 |
|
38 using namespace CMManager; |
|
39 |
|
40 const TInt KDefaultListBoxFlags = 0; |
|
41 |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // TCmCommonUi::CCmDesCArray::CCmDesCArray |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 TCmCommonUi::CCmDesCArray::CCmDesCArray() |
|
48 : CDesCArrayFlat( KCmArraySmallGranularity ) |
|
49 , iUids( KCmArraySmallGranularity ) |
|
50 { |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // TCmCommonUi::CCmDesCArray::~CCmDesCArray |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 TCmCommonUi::CCmDesCArray::~CCmDesCArray() |
|
58 { |
|
59 iUids.Close(); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // TCmCommonUi::CCmDesCArray::AppendL |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 void TCmCommonUi::CCmDesCArray::AppendL( TUint aUid, const TDesC& aItem ) |
|
67 { |
|
68 iUids.AppendL( aUid ); |
|
69 CDesCArray::AppendL( aItem ); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // TCmCommonUi::CCmDesCArray::Uid |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 TUint TCmCommonUi::CCmDesCArray::Uid( TInt aIndex ) const |
|
77 { |
|
78 return iUids[ aIndex ]; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // TCmCommonUi::ShowConfirmationQueryWithInputL |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C TInt TCmCommonUi::ShowConfirmationQueryWithInputL( TInt aResId, |
|
86 TDes& aInput ) |
|
87 { |
|
88 CLOG_ENTERFN_PTR( "ShowConfirmationQueryWithInputL" ); |
|
89 HBufC* prompt = CEikonEnv::Static()->AllocReadResourceAsDes16LC( aResId ); |
|
90 |
|
91 CAknTextQueryDialog* dlg = |
|
92 CAknTextQueryDialog::NewL( aInput, CAknQueryDialog::ENoTone ); |
|
93 |
|
94 // Handle the allowable enterable length of the text |
|
95 CLOG_WRITE_1_PTR( NULL, "max length input: [%d ]", aInput.MaxLength() ); |
|
96 dlg->SetMaxLength( aInput.MaxLength() ); |
|
97 |
|
98 TInt retval = dlg->ExecuteLD( R_TEXT_QUERY, *prompt ); |
|
99 |
|
100 CleanupStack::PopAndDestroy( prompt ); |
|
101 |
|
102 return retval; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // TCmCommonUi::ShowConfirmationQueryL |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 EXPORT_C TInt TCmCommonUi::ShowConfirmationQueryL( TInt aResId ) |
|
110 { |
|
111 CLOG_ENTERFN_PTR( "ShowConfirmationQueryL" ); |
|
112 HBufC* prompt = CEikonEnv::Static()->AllocReadResourceL( aResId ); |
|
113 |
|
114 // Ownership (of 'prompt') is handed over to callee. That's why we don't |
|
115 // bother with cleanup stack either - let it be the callee's problem. |
|
116 return ShowConfirmationQueryL( prompt ); |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // TCmCommonUi::ShowConfirmationQueryL |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C TInt TCmCommonUi::ShowConfirmationQueryL( TInt aResId, |
|
124 const TDesC& aString ) |
|
125 { |
|
126 CLOG_ENTERFN_PTR( "ShowConfirmationQueryL" ); |
|
127 HBufC* prompt = StringLoader::LoadL( aResId, aString ); |
|
128 |
|
129 // Ownership (of 'prompt') is handed over to callee. |
|
130 return ShowConfirmationQueryL( prompt ); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // TCmCommonUi::ShowAvailableMethodsL |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 TUint32 TCmCommonUi::ShowAvailableMethodsL( |
|
138 const RArray<TUint32>& aAvailableBearers, |
|
139 const CCmManagerImpl& aCmManager ) |
|
140 { |
|
141 CLOG_ENTERFN_PTR( "ShowAvailableMethodsL" ); |
|
142 |
|
143 TUint32 retval = 0; |
|
144 |
|
145 // Create listbox and popup list and perform some initialization on them. |
|
146 CEikFormattedCellListBox* listBox = |
|
147 new (ELeave) CAknDoubleLargeGraphicPopupMenuStyleListBox(); |
|
148 CleanupStack::PushL( listBox ); |
|
149 |
|
150 CAknPopupList* popupList = |
|
151 CAknPopupList::NewL( listBox, |
|
152 R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, |
|
153 AknPopupLayouts::EMenuDoubleLargeGraphicWindow ); |
|
154 CleanupStack::PushL( popupList ); |
|
155 |
|
156 listBox->ConstructL( popupList, KDefaultListBoxFlags ); |
|
157 listBox->CreateScrollBarFrameL( ETrue ); |
|
158 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
159 CEikScrollBarFrame::EOff, |
|
160 CEikScrollBarFrame::EAuto ); |
|
161 |
|
162 // Create the icon and item text arrays. |
|
163 CArrayPtr<CGulIcon>* icons = |
|
164 new(ELeave) CArrayPtrFlat<CGulIcon>( KCmArraySmallGranularity ); |
|
165 CleanupStack::PushL( icons ); |
|
166 |
|
167 CCmDesCArray* itemArray = new (ELeave) CCmDesCArray(); |
|
168 listBox->Model()->SetItemTextArray( itemArray ); |
|
169 // just to be on the safe side: next line is not mandatory, but advisable |
|
170 listBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
171 |
|
172 // Note: we don't have to put 'itemArray' on to the cleanup stack, as the |
|
173 // model has already taken this object over. |
|
174 |
|
175 // Fill up the arrays |
|
176 for ( TInt i = 0; i < aAvailableBearers.Count(); i++ ) |
|
177 { |
|
178 TUint32 bearerUid = aAvailableBearers[i]; |
|
179 |
|
180 // Add icons to the icon array |
|
181 CGulIcon* icon = (CGulIcon*)(aCmManager.GetBearerInfoIntL( |
|
182 bearerUid, |
|
183 ECmBearerAvailableIcon ) ); |
|
184 |
|
185 if( !icon ) |
|
186 { |
|
187 continue; |
|
188 } |
|
189 |
|
190 CleanupStack::PushL( icon ); |
|
191 icons->AppendL( icon ); |
|
192 CleanupStack::Pop( icon ); // icon array took over ownership |
|
193 |
|
194 // Add item text to the array. |
|
195 // Query the name of the bearer first. |
|
196 HBufC* firstLine = aCmManager.GetBearerInfoStringL( |
|
197 bearerUid, |
|
198 ECmBearerAvailableName ); |
|
199 CleanupStack::PushL( firstLine ); |
|
200 |
|
201 // Query the availability string of the bearer second. |
|
202 HBufC* secondLine = aCmManager.GetBearerInfoStringL( |
|
203 bearerUid, |
|
204 ECmBearerAvailableText ); |
|
205 CleanupStack::PushL( secondLine ); |
|
206 |
|
207 // Third, combine these two strings along with an icon index. |
|
208 HBufC* listBoxLine = FormattedTextForListBoxLC( i, |
|
209 *firstLine, |
|
210 *secondLine ); |
|
211 |
|
212 // Finally add the resulting string to the item array. |
|
213 itemArray->AppendL( bearerUid, *listBoxLine ); |
|
214 |
|
215 CLOG_WRITE_1_PTR( NULL, |
|
216 "ShowAvailableMethodsL new listbox item: [%S]", |
|
217 listBoxLine ); |
|
218 |
|
219 // Clean-up: firstLine, secondLine, listBoxLine. |
|
220 CleanupStack::PopAndDestroy( 3, firstLine ); |
|
221 } |
|
222 |
|
223 // Handing over the ownership of the icon array to the listbox |
|
224 listBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); |
|
225 |
|
226 CleanupStack::Pop( icons ); // ownership already handed over |
|
227 |
|
228 // Set title |
|
229 HBufC* title = StringLoader::LoadLC( R_CMWIZARD_AVAILABLE_METHODS ); |
|
230 popupList->SetTitleL( *title ); |
|
231 CleanupStack::PopAndDestroy( title ); |
|
232 |
|
233 if ( popupList->ExecuteLD() ) |
|
234 { |
|
235 retval = itemArray->Uid( listBox->CurrentItemIndex() ); |
|
236 } |
|
237 |
|
238 CleanupStack::Pop( popupList ); // ExecuteLD has already destroyed it |
|
239 CleanupStack::PopAndDestroy( listBox ); |
|
240 |
|
241 CLOG_WRITE_1_PTR( NULL, "ShowAvailableMethodsL exit, retval: [%d]", retval ); |
|
242 |
|
243 return retval; |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------------------------- |
|
247 // TCmCommonUi::SelectBearerL |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 TUint32 TCmCommonUi::SelectBearerL( const CCmManagerImpl& aCmManager ) |
|
251 { |
|
252 CLOG_ENTERFN_PTR( "SelectBearerL" ); |
|
253 TUint32 retval = 0; |
|
254 |
|
255 CEikFormattedCellListBox* listBox = |
|
256 new (ELeave) CAknSingleGraphicPopupMenuStyleListBox(); |
|
257 CleanupStack::PushL( listBox ); |
|
258 |
|
259 CAknPopupList* popupList = |
|
260 CAknPopupList::NewL( listBox, |
|
261 R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, |
|
262 AknPopupLayouts::EMenuGraphicWindow ); |
|
263 CleanupStack::PushL( popupList ); |
|
264 |
|
265 listBox->ConstructL( popupList, KDefaultListBoxFlags ); |
|
266 listBox->CreateScrollBarFrameL( ETrue ); |
|
267 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
268 CEikScrollBarFrame::EOff, |
|
269 CEikScrollBarFrame::EAuto ); |
|
270 |
|
271 RArray<TUint32> bearers( KCmArrayMediumGranularity ); |
|
272 CleanupClosePushL( bearers ); |
|
273 aCmManager.SupportedBearersL( bearers ); |
|
274 |
|
275 TInt i; |
|
276 |
|
277 for ( i = 0; i < bearers.Count(); ++i ) |
|
278 { |
|
279 if( !aCmManager.GetBearerInfoBoolL( bearers[i], |
|
280 ECmBearerHasUi ) ) |
|
281 { |
|
282 bearers.Remove( i ); |
|
283 --i; |
|
284 } |
|
285 |
|
286 } |
|
287 |
|
288 CArrayPtr<CGulIcon>* icons = |
|
289 new(ELeave) CArrayPtrFlat<CGulIcon>( KCmArrayMediumGranularity ); |
|
290 CleanupStack::PushL( icons ); |
|
291 |
|
292 // Note: it's interesting that we, in fact, set up an *ordered* list of |
|
293 // icons. Ordering of the icon array is based on the order of supported |
|
294 // bearers. |
|
295 for ( i = 0; i < bearers.Count(); ++i ) |
|
296 { |
|
297 CGulIcon* icon = (CGulIcon*)(aCmManager.GetBearerInfoIntL( |
|
298 bearers[i], |
|
299 ECmBearerIcon ) ); |
|
300 |
|
301 if( !icon ) |
|
302 { |
|
303 bearers.Remove( i ); |
|
304 --i; |
|
305 continue; |
|
306 } |
|
307 |
|
308 CleanupStack::PushL( icon ); |
|
309 |
|
310 icons->AppendL( icon ); |
|
311 |
|
312 CleanupStack::Pop( icon ); // icon array took over ownership |
|
313 } |
|
314 |
|
315 // Handing over the ownership of the icon array to the listbox |
|
316 listBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons ); |
|
317 |
|
318 CleanupStack::Pop( icons ); // ownership already handed over |
|
319 |
|
320 CCmDesCArray* itemArray = new (ELeave) CCmDesCArray(); |
|
321 listBox->Model()->SetItemTextArray( itemArray ); |
|
322 // just to be on the safe side: next line is not mandatory, but advisable |
|
323 listBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
324 |
|
325 // Note: we don't have to put 'itemArray' on to the cleanup stack, as the |
|
326 // model has already taken this object over. |
|
327 |
|
328 for ( TInt i = 0; i < bearers.Count(); i++ ) |
|
329 { |
|
330 // Here we take advantage of the fact that our icon array is ordered. |
|
331 // That is, the indices of the icons in the array will always be |
|
332 // in sync with those in the item text array (i.e. each bearer will |
|
333 // have the right icon associated with it). |
|
334 HBufC* bearerName = aCmManager.GetBearerInfoStringL( bearers[i], |
|
335 ECmBearerSupportedName ); |
|
336 CleanupStack::PushL( bearerName ); |
|
337 |
|
338 HBufC* lineText = FormattedTextForListBoxLC( i, *bearerName ); |
|
339 |
|
340 itemArray->AppendL( bearers[i], *lineText ); |
|
341 |
|
342 CLOG_WRITE_1_PTR( NULL, "SelectBearerL new listbox item: [%S]", |
|
343 lineText ); |
|
344 |
|
345 CleanupStack::PopAndDestroy( 2, bearerName ); // lineText, bearerName |
|
346 } |
|
347 |
|
348 CleanupStack::PopAndDestroy( &bearers ); |
|
349 |
|
350 // Set title |
|
351 HBufC* title = StringLoader::LoadLC( R_CMWIZARD_SELECT_CONN_METHOD ); |
|
352 popupList->SetTitleL( *title ); |
|
353 CleanupStack::PopAndDestroy( title ); |
|
354 |
|
355 if ( popupList->ExecuteLD() ) |
|
356 { |
|
357 retval = itemArray->Uid( listBox->CurrentItemIndex() ); |
|
358 } |
|
359 |
|
360 CleanupStack::Pop( popupList ); // ExecuteLD has already destroyed it |
|
361 CleanupStack::PopAndDestroy( listBox ); |
|
362 |
|
363 CLOG_WRITE_1_PTR( NULL, "SelectBearerL exit, retval: [%d]", retval ); |
|
364 |
|
365 return retval; |
|
366 } |
|
367 |
|
368 // --------------------------------------------------------------------------- |
|
369 // TCmCommonUi::ShowConfirmationQueryL |
|
370 // --------------------------------------------------------------------------- |
|
371 // |
|
372 TInt TCmCommonUi::ShowConfirmationQueryL( HBufC* aPrompt ) |
|
373 { |
|
374 CLOG_ENTERFN_PTR( "ShowConfirmationQueryL" ); |
|
375 |
|
376 CleanupStack::PushL( aPrompt ); |
|
377 |
|
378 CAknQueryDialog* dlg = |
|
379 CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone ); |
|
380 TInt retval = dlg->ExecuteLD( R_CONFIRMATION_QUERY, *aPrompt ); |
|
381 |
|
382 CleanupStack::PopAndDestroy( aPrompt ); |
|
383 |
|
384 return retval; |
|
385 } |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // TCmCommonUi::ShowMemoryFullConfirmationQueryL |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 TInt TCmCommonUi::ShowMemoryFullConfirmationQueryL() |
|
392 { |
|
393 CLOG_ENTERFN_PTR( "ShowMemoryFullConfirmationQueryL" ); |
|
394 |
|
395 // need to check if EikonEnv exists in this context |
|
396 CEikonEnv* eikPtr = CEikonEnv::Static(); |
|
397 TInt retval( KErrNone ); |
|
398 if( eikPtr ) |
|
399 { |
|
400 HBufC* prompt = eikPtr->AllocReadResourceL( R_QTN_MEMLO_MEMORY_FULL ); |
|
401 CleanupStack::PushL( prompt ); |
|
402 CAknQueryDialog* dlg = |
|
403 CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone ); |
|
404 retval = dlg->ExecuteLD( R_MEMORY_FULL_CONFIRMATION_QUERY, *prompt ); |
|
405 CleanupStack::PopAndDestroy( prompt ); |
|
406 } |
|
407 |
|
408 return retval; |
|
409 } |
|
410 |
|
411 // --------------------------------------------------------------------------- |
|
412 // TCmCommonUi::ShowNoteL |
|
413 // --------------------------------------------------------------------------- |
|
414 // |
|
415 EXPORT_C TInt TCmCommonUi::ShowNoteL( TInt aResId, TCmNoteType aNoteType ) |
|
416 { |
|
417 CLOG_ENTERFN_PTR( "ShowNoteL" ); |
|
418 HBufC* prompt = CEikonEnv::Static()->AllocReadResourceLC( aResId ); |
|
419 |
|
420 TInt result = ShowNoteL( *prompt, aNoteType ); |
|
421 |
|
422 CleanupStack::PopAndDestroy( prompt ); |
|
423 |
|
424 return result; |
|
425 } |
|
426 |
|
427 // --------------------------------------------------------------------------- |
|
428 // TCmCommonUi::ShowNoteL |
|
429 // --------------------------------------------------------------------------- |
|
430 // |
|
431 EXPORT_C TInt TCmCommonUi::ShowNoteL( TInt aResId, const TDesC& aString, |
|
432 TCmNoteType aNoteType ) |
|
433 { |
|
434 CLOG_ENTERFN_PTR( "ShowNoteL" ); |
|
435 HBufC* prompt = StringLoader::LoadLC( aResId, aString ); |
|
436 |
|
437 TInt result = ShowNoteL( *prompt, aNoteType ); |
|
438 |
|
439 CleanupStack::PopAndDestroy( prompt ); |
|
440 |
|
441 return result; |
|
442 } |
|
443 |
|
444 // --------------------------------------------------------------------------- |
|
445 // TCmCommonUi::ShowNoteL |
|
446 // --------------------------------------------------------------------------- |
|
447 // |
|
448 EXPORT_C TInt TCmCommonUi::ShowNoteL( const TDesC& aPrompt, TCmNoteType aNoteType ) |
|
449 { |
|
450 CLOG_ENTERFN_PTR( "ShowNoteL" ); |
|
451 |
|
452 CAknNoteDialog* dlg = new (ELeave) CAknNoteDialog( |
|
453 CAknNoteDialog::ENoTone, |
|
454 CAknNoteDialog::ELongTimeout ); |
|
455 |
|
456 TInt resId; |
|
457 switch ( aNoteType ) |
|
458 { |
|
459 case ECmOkNote: |
|
460 { |
|
461 resId = R_OK_NOTE; |
|
462 break; |
|
463 } |
|
464 case ECmWarningNote: |
|
465 { |
|
466 resId = R_WARNING_NOTE; |
|
467 break; |
|
468 } |
|
469 case ECmErrorNote: |
|
470 { |
|
471 resId = R_ERROR_NOTE; |
|
472 break; |
|
473 } |
|
474 default: |
|
475 { |
|
476 resId = R_INFO_NOTE; |
|
477 } |
|
478 } |
|
479 |
|
480 // no need to worry about LC (PrepareLC), RunLD takes care of it |
|
481 dlg->PrepareLC( resId ); |
|
482 dlg->SetTextL( aPrompt ); |
|
483 |
|
484 return dlg->RunLD(); |
|
485 } |
|
486 |
|
487 // --------------------------------------------------------------------------- |
|
488 // TCmCommonUi::FormattedTextForListBoxLC |
|
489 // --------------------------------------------------------------------------- |
|
490 // |
|
491 HBufC* TCmCommonUi::FormattedTextForListBoxLC( TInt aIconIndex, |
|
492 const TDesC& aLineText ) |
|
493 { |
|
494 HBufC* formattedString = |
|
495 HBufC::NewL( KNumberOfStaticCharsIn1LineFormattedString + |
|
496 aLineText.Length() ); |
|
497 |
|
498 TPtr des = formattedString->Des(); |
|
499 des.AppendFormat( KSingleNumberAsString, aIconIndex ); |
|
500 des.Append( TChar( KSettingsListBoxItemPrefix ) ); |
|
501 des.Append( aLineText ); |
|
502 |
|
503 CleanupStack::PushL( formattedString ); |
|
504 |
|
505 return formattedString; |
|
506 } |
|
507 |
|
508 // --------------------------------------------------------------------------- |
|
509 // TCmCommonUi::FormattedTextForListBoxLC |
|
510 // --------------------------------------------------------------------------- |
|
511 // |
|
512 HBufC* TCmCommonUi::FormattedTextForListBoxLC( TInt aIconIndex, |
|
513 const TDesC& aFirstLine, |
|
514 const TDesC& aSecondLine ) |
|
515 { |
|
516 HBufC* formattedString = |
|
517 HBufC::NewL( KNumberOfStaticCharsIn2LineFormattedString + |
|
518 aFirstLine.Length() + |
|
519 aSecondLine.Length() ); |
|
520 |
|
521 TPtr des = formattedString->Des(); |
|
522 des.AppendFormat( KSingleNumberAsString, aIconIndex ); |
|
523 des.Append( TChar( KSettingsListBoxItemPrefix ) ); |
|
524 des.Append( aFirstLine ); |
|
525 des.Append( TChar( KSettingsListBoxItemPrefix ) ); |
|
526 des.Append( aSecondLine ); |
|
527 |
|
528 CleanupStack::PushL( formattedString ); |
|
529 |
|
530 return formattedString; |
|
531 } |
|
532 |
|
533 // --------------------------------------------------------------------------- |
|
534 // TCmCommonUi::FormattedTextForListBoxLC |
|
535 // --------------------------------------------------------------------------- |
|
536 // |
|
537 HBufC* TCmCommonUi::FormattedTextForListBoxLC( TInt aIconIndex, |
|
538 TInt aFirstLineResId, |
|
539 TInt aSecondLineResId ) |
|
540 { |
|
541 HBufC* secondLine = StringLoader::LoadLC( aSecondLineResId ); |
|
542 |
|
543 HBufC* formattedString = FormattedTextForListBoxL( aIconIndex, |
|
544 aFirstLineResId, |
|
545 *secondLine ); |
|
546 |
|
547 CleanupStack::PopAndDestroy( secondLine ); |
|
548 |
|
549 CleanupStack::PushL( formattedString ); |
|
550 |
|
551 return formattedString; |
|
552 } |
|
553 |
|
554 |
|
555 // --------------------------------------------------------------------------- |
|
556 // TCmCommonUi::FormattedTextForListBoxLC |
|
557 // --------------------------------------------------------------------------- |
|
558 // |
|
559 HBufC* TCmCommonUi::FormattedTextForListBoxLC( TInt aIconIndex, |
|
560 TInt aFirstLineResId, |
|
561 TInt aSecondLineResId, |
|
562 TInt aReplacementInSecondLine ) |
|
563 { |
|
564 HBufC* secondLine = StringLoader::LoadLC( aSecondLineResId, |
|
565 aReplacementInSecondLine ); |
|
566 |
|
567 HBufC* formattedString = FormattedTextForListBoxL( aIconIndex, |
|
568 aFirstLineResId, |
|
569 *secondLine ); |
|
570 |
|
571 CleanupStack::PopAndDestroy( secondLine ); |
|
572 |
|
573 CleanupStack::PushL( formattedString ); |
|
574 |
|
575 return formattedString; |
|
576 } |
|
577 |
|
578 |
|
579 // --------------------------------------------------------------------------- |
|
580 // TCmCommonUi::FormattedTextForListBoxL |
|
581 // --------------------------------------------------------------------------- |
|
582 // |
|
583 HBufC* TCmCommonUi::FormattedTextForListBoxL( TInt aIconIndex, |
|
584 TInt aFirstLineResId, |
|
585 const TDesC& aSecondLine ) |
|
586 { |
|
587 HBufC* firstLine = StringLoader::LoadLC( aFirstLineResId ); |
|
588 |
|
589 HBufC* formattedString = |
|
590 HBufC::NewL( KNumberOfStaticCharsIn2LineFormattedString + |
|
591 firstLine->Length() + |
|
592 aSecondLine.Length() ); |
|
593 |
|
594 TPtr des = formattedString->Des(); |
|
595 des.AppendFormat( KSingleNumberAsString, aIconIndex ); |
|
596 des.Append( TChar( KSettingsListBoxItemPrefix ) ); |
|
597 des.Append( *firstLine ); |
|
598 des.Append( TChar( KSettingsListBoxItemPrefix ) ); |
|
599 des.Append( aSecondLine ); |
|
600 |
|
601 CleanupStack::PopAndDestroy( firstLine ); |
|
602 |
|
603 return formattedString; |
|
604 } |
|
605 |
|
606 |
|
607 // -------------------------------------------------------------------------- |
|
608 // TCmCommonUi::ShowPopupListL |
|
609 // -------------------------------------------------------------------------- |
|
610 // |
|
611 EXPORT_C TBool TCmCommonUi::ShowPopupListL( const TDesC& aTitle, |
|
612 CDesCArrayFlat* aTextItems, |
|
613 CArrayPtr<CGulIcon>* aIconArray, |
|
614 const TUint aSoftKeys, |
|
615 TInt& aSelection ) |
|
616 { |
|
617 TBool retVal ( EFalse ); |
|
618 |
|
619 // Prepare the dialog |
|
620 CEikFormattedCellListBox* list = NULL; |
|
621 if ( aIconArray ) |
|
622 { |
|
623 list = new ( ELeave ) CAknSingleGraphicPopupMenuStyleListBox; |
|
624 } |
|
625 else |
|
626 { |
|
627 list = new ( ELeave ) CAknSinglePopupMenuStyleListBox; |
|
628 } |
|
629 |
|
630 CleanupStack::PushL( list ); |
|
631 |
|
632 CAknPopupList* popupList = CAknPopupList::NewL( |
|
633 list, aSoftKeys, |
|
634 AknPopupLayouts::EMenuWindow ); |
|
635 CleanupStack::PushL( popupList ); |
|
636 |
|
637 // initialise listbox. |
|
638 list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect ); |
|
639 list->CreateScrollBarFrameL( ETrue ); |
|
640 list->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
641 CEikScrollBarFrame::EOff, |
|
642 CEikScrollBarFrame::EAuto ); |
|
643 |
|
644 // Handing over the ownership of the icon array to the listbox |
|
645 if ( aIconArray ) |
|
646 { |
|
647 list->ItemDrawer()->FormattedCellData()->SetIconArrayL( aIconArray ); |
|
648 } |
|
649 |
|
650 // Items |
|
651 list->Model()->SetItemTextArray( aTextItems ); |
|
652 |
|
653 // Title |
|
654 popupList->SetTitleL( aTitle ); |
|
655 |
|
656 // Show the dialog |
|
657 if ( popupList->ExecuteLD() ) |
|
658 { |
|
659 aSelection = list->CurrentItemIndex(); |
|
660 retVal = ETrue; |
|
661 } |
|
662 |
|
663 CleanupStack::Pop( popupList ); |
|
664 CleanupStack::PopAndDestroy( list ); |
|
665 |
|
666 return retVal; |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // TCmCommonUi::ShowAlwaysAskNoteL |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 TBool TCmCommonUi::ShowAlwaysAskNoteL( TCmDefConnValue aOldDefConn, |
|
674 CCmManagerImpl& aCmManagerImpl ) |
|
675 { |
|
676 TCmDefConnValue newConn; |
|
677 aCmManagerImpl.ReadDefConnL( newConn ); |
|
678 if ( newConn != aOldDefConn ) |
|
679 { |
|
680 ShowNoteL( R_CMMANAGERUI_CONF_DEFAULT_ALWAYS_ASK, |
|
681 TCmCommonUi::ECmOkNote ); |
|
682 return ETrue; |
|
683 } |
|
684 return EFalse; |
|
685 } |
|
686 |
|
687 |