|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "AspAdvanceSettingsDialog.h" |
|
23 #include "AspContentDialog.h" |
|
24 #include "AspSyncUtil.rh" |
|
25 #include "AspDebug.h" |
|
26 #include <csxhelp/ds.hlp.hrh> |
|
27 |
|
28 #include <aspsyncutil.mbg> // for bitmap enumerations |
|
29 #include <AknIconArray.h> // for GulArray |
|
30 #include <aknpasswordsettingpage.h> // CAknAlphaPasswordSettingPage |
|
31 #include <ConnectionUiUtilities.h> // CConnectionUiUtilities |
|
32 #include <featmgr.h> // FeatureManager |
|
33 #include <AspDefines.h> //For enum TRoamingSettings |
|
34 #include <centralrepository.h> //For central Repository |
|
35 #include "CPreSyncPlugin.h" |
|
36 |
|
37 const TInt KMSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition ); |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 |
|
41 |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CAspProfileDialog::ShowDialogL |
|
45 // |
|
46 // ----------------------------------------------------------------------------- |
|
47 TBool CAspAdvanceSettingsDialog::ShowDialogL() |
|
48 { |
|
49 CAspAdvanceSettingsDialog* dialog = CAspAdvanceSettingsDialog::NewL(); |
|
50 |
|
51 TBool ret = dialog->ExecuteLD(R_ASP_ADVANCE_SETTINGS_DIALOG); |
|
52 |
|
53 return ret; |
|
54 } |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CAspAdvanceSettingsDialog::NewL |
|
59 // |
|
60 // ----------------------------------------------------------------------------- |
|
61 CAspAdvanceSettingsDialog* CAspAdvanceSettingsDialog::NewL() |
|
62 { |
|
63 FLOG( _L("CAspAdvanceSettingsDialog::NewL START") ); |
|
64 |
|
65 CAspAdvanceSettingsDialog* self = new ( ELeave ) CAspAdvanceSettingsDialog(); |
|
66 CleanupStack::PushL(self); |
|
67 self->ConstructL(); |
|
68 CleanupStack::Pop(self); |
|
69 |
|
70 FLOG( _L("CAspAdvanceSettingsDialog::NewL END") ); |
|
71 return self; |
|
72 } |
|
73 |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CAspAdvanceSettingsDialog::CAspAdvanceSettingsDialog |
|
77 // |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CAspAdvanceSettingsDialog::CAspAdvanceSettingsDialog() |
|
81 { |
|
82 } |
|
83 |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CAspAdvanceSettingsDialog::ConstructL |
|
87 // |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CAspAdvanceSettingsDialog::ConstructL() |
|
91 { |
|
92 FLOG( _L("CAspAdvanceSettingsDialog::ConstructL START") ); |
|
93 |
|
94 // contruct menu for our dialog |
|
95 CAknDialog::ConstructL(R_ADVANCE_SETTINGS_DIALOG_MENU); |
|
96 |
|
97 iResHandler = CAspResHandler::NewL(); |
|
98 |
|
99 iSettingList = new (ELeave) CArrayPtrFlat<CAspListItemData>(1); |
|
100 |
|
101 // get previous title so it can be restored |
|
102 iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi); |
|
103 iStatusPaneHandler->StoreOriginalTitleL(); |
|
104 |
|
105 // store current navi pane |
|
106 iStatusPaneHandler->StoreNavipaneL(); |
|
107 |
|
108 FLOG( _L("CAspAdvanceSettingsDialog::ConstructL END") ); |
|
109 } |
|
110 |
|
111 |
|
112 // ---------------------------------------------------------------------------- |
|
113 // Destructor |
|
114 // |
|
115 // ---------------------------------------------------------------------------- |
|
116 // |
|
117 CAspAdvanceSettingsDialog::~CAspAdvanceSettingsDialog() |
|
118 { |
|
119 FLOG( _L("CAspAdvanceSettingsDialog::~CAspAdvanceSettingsDialog START") ); |
|
120 |
|
121 delete iResHandler; |
|
122 |
|
123 if (iSettingList) |
|
124 { |
|
125 iSettingList->ResetAndDestroy(); |
|
126 delete iSettingList; |
|
127 } |
|
128 |
|
129 delete iStatusPaneHandler; |
|
130 |
|
131 if (iAvkonAppUi) |
|
132 { |
|
133 iAvkonAppUi->RemoveFromStack(this); |
|
134 } |
|
135 |
|
136 FLOG( _L("CAspAdvanceSettingsDialog::~CAspAdvanceSettingsDialog END") ); |
|
137 } |
|
138 |
|
139 |
|
140 //------------------------------------------------------------------------------ |
|
141 // CAspAdvanceSettingsDialog::ActivateL |
|
142 // |
|
143 // Called by system when dialog is activated. |
|
144 //------------------------------------------------------------------------------ |
|
145 // |
|
146 void CAspAdvanceSettingsDialog::ActivateL() |
|
147 { |
|
148 CAknDialog::ActivateL(); |
|
149 |
|
150 // this cannot be in ConstructL which is executed before dialog is launched |
|
151 iAvkonAppUi->AddToStackL(this); |
|
152 } |
|
153 |
|
154 |
|
155 //------------------------------------------------------------------------------ |
|
156 // CAspContentListDialog::GetHelpContext |
|
157 // |
|
158 //------------------------------------------------------------------------------ |
|
159 // |
|
160 void CAspAdvanceSettingsDialog::GetHelpContext(TCoeHelpContext& aContext) const |
|
161 { |
|
162 aContext.iMajor = KUidSmlSyncApp; |
|
163 aContext.iContext = KDS_HLP_MAIN_VIEW; |
|
164 } |
|
165 |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CAspAdvanceSettingsDialog::HandleListBoxEventL |
|
169 // |
|
170 // ----------------------------------------------------------------------------- |
|
171 #ifdef RD_SCALABLE_UI_V2 |
|
172 void CAspAdvanceSettingsDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
173 TListBoxEvent aEventType) |
|
174 { |
|
175 if( AknLayoutUtils::PenEnabled() ) |
|
176 { |
|
177 switch ( aEventType ) |
|
178 { |
|
179 case EEventItemDoubleClicked: |
|
180 HandleOKL(); |
|
181 break; |
|
182 case EEventEnterKeyPressed : |
|
183 case EEventItemClicked : |
|
184 case EEventItemDraggingActioned : |
|
185 case EEventPenDownOnItem : |
|
186 if(iEditMode != EDialogModeSettingEnforcement) |
|
187 { |
|
188 TRAPD(err ,CheckContentSettingL());//folder |
|
189 User::LeaveIfError(err); |
|
190 } |
|
191 break; |
|
192 default: |
|
193 break; |
|
194 } |
|
195 |
|
196 } |
|
197 |
|
198 } |
|
199 #else |
|
200 void CAspAdvanceSettingsDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
201 TListBoxEvent /*aEventType*/) |
|
202 { |
|
203 |
|
204 } |
|
205 #endif |
|
206 |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CAspAdvanceSettingsDialog::PreLayoutDynInitL |
|
210 // |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void CAspAdvanceSettingsDialog::PreLayoutDynInitL() |
|
214 { |
|
215 iSettingListBox = (CAknSettingStyleListBox*) ControlOrNull (EAdvanceSettingsDialogList); |
|
216 |
|
217 __ASSERT_ALWAYS(iSettingListBox, TUtil::Panic(KErrGeneral)); |
|
218 |
|
219 iSettingListBox->SetListBoxObserver(this); |
|
220 iSettingListBox->CreateScrollBarFrameL(ETrue); |
|
221 iSettingListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
222 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto); |
|
223 |
|
224 SetIconsL(); |
|
225 |
|
226 // create array of setting items (iSettingList) |
|
227 CreateSettingsListL(); |
|
228 |
|
229 // add setting headers into listbox |
|
230 UpdateListBoxL(iSettingListBox, iSettingList); |
|
231 |
|
232 iStatusPaneHandler->SetNaviPaneTitleL(R_ASP_TITLE_ADVANCED_SETTINGS); |
|
233 } |
|
234 |
|
235 |
|
236 // ---------------------------------------------------------------------------- |
|
237 // CAspAdvanceSettingsDialog::SetMiddleSoftKeyLabelL |
|
238 // |
|
239 // ---------------------------------------------------------------------------- |
|
240 // |
|
241 void CAspAdvanceSettingsDialog::SetEmptyMiddleSoftKeyLabelL() |
|
242 { |
|
243 ButtonGroupContainer().RemoveCommandFromStack(KMSKControlId,EAknSoftkeyOpen ); |
|
244 HBufC* middleSKText = StringLoader::LoadLC( R_TEXT_SOFTKEY_EMPTY ); |
|
245 |
|
246 ButtonGroupContainer().AddCommandToStackL( |
|
247 KMSKControlId, |
|
248 EAknSoftkeyEmpty, |
|
249 *middleSKText ); |
|
250 iMSKEmpty= ETrue; |
|
251 CleanupStack::PopAndDestroy( middleSKText ); |
|
252 } |
|
253 // ---------------------------------------------------------------------------- |
|
254 // CAspAdvanceSettingsDialog::SetIconsL |
|
255 // |
|
256 // ---------------------------------------------------------------------------- |
|
257 // |
|
258 void CAspAdvanceSettingsDialog::SetIconsL() |
|
259 { |
|
260 if (!iSettingListBox) |
|
261 { |
|
262 return; |
|
263 } |
|
264 |
|
265 TFileName bitmapName; |
|
266 CAspResHandler::GetBitmapFileName(bitmapName); |
|
267 CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize); |
|
268 CleanupStack::PushL(icons); |
|
269 |
|
270 icons->AppendL(IconL(KAknsIIDQgnIndiSettProtectedAdd, bitmapName, |
|
271 EMbmAspsyncutilQgn_indi_sett_protected_add, |
|
272 EMbmAspsyncutilQgn_indi_sett_protected_add_mask)); |
|
273 |
|
274 // delete old icons |
|
275 CArrayPtr<CGulIcon>* arr = |
|
276 iSettingListBox->ItemDrawer()->FormattedCellData()->IconArray(); |
|
277 |
|
278 if (arr) |
|
279 { |
|
280 arr->ResetAndDestroy(); |
|
281 delete arr; |
|
282 arr = NULL; |
|
283 } |
|
284 |
|
285 iSettingListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons); |
|
286 CleanupStack::Pop(icons); |
|
287 } |
|
288 |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // CAspAdvanceSettingsDialog::IconL |
|
292 // |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 CGulIcon* CAspAdvanceSettingsDialog::IconL(TAknsItemID aId, const TDesC& aFileName, TInt aFileIndex, TInt aFileMaskIndex) |
|
296 { |
|
297 return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex); |
|
298 } |
|
299 |
|
300 |
|
301 //------------------------------------------------------------------------------ |
|
302 // CAspAdvanceSettingsDialog::DynInitMenuPaneL |
|
303 // |
|
304 // Called by system before menu is shown. |
|
305 //------------------------------------------------------------------------------ |
|
306 // |
|
307 void CAspAdvanceSettingsDialog::DynInitMenuPaneL(TInt /*aResourceID*/, CEikMenuPane* aMenuPane) |
|
308 { |
|
309 CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex()); |
|
310 if (item->iHidden == EVisibilityReadOnly) |
|
311 { |
|
312 TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange); |
|
313 } |
|
314 |
|
315 if (!FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
316 { |
|
317 TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdHelp); |
|
318 } |
|
319 } |
|
320 |
|
321 |
|
322 //------------------------------------------------------------------------------ |
|
323 // CAspAdvanceSettingsDialog::ProcessCommandL |
|
324 // |
|
325 // Handle commands from menu. |
|
326 //------------------------------------------------------------------------------ |
|
327 // |
|
328 void CAspAdvanceSettingsDialog::ProcessCommandL(TInt aCommandId) |
|
329 { |
|
330 HideMenu(); |
|
331 |
|
332 switch (aCommandId) |
|
333 { |
|
334 case EAspMenuCmdHelp: |
|
335 { |
|
336 TUtil::LaunchHelpAppL(iEikonEnv); |
|
337 break; |
|
338 } |
|
339 |
|
340 case EAspMenuCmdChange: |
|
341 case EAspMenuCmdOpen: |
|
342 { |
|
343 CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex()); |
|
344 |
|
345 if (item->iItemType == CAspListItemData::ETypeListYesNo) |
|
346 { |
|
347 // open editor for Yes/No setting |
|
348 if (EditSettingItemListL(*item)) |
|
349 { |
|
350 SetVisibility(); |
|
351 UpdateListBoxL(ListBox(), iSettingList); |
|
352 } |
|
353 } |
|
354 else |
|
355 { |
|
356 HandleOKL(); |
|
357 } |
|
358 |
|
359 break; |
|
360 } |
|
361 |
|
362 case EAspMenuCmdExit: |
|
363 case EAknCmdExit: |
|
364 case EEikCmdExit: |
|
365 { |
|
366 // close dialog and exit calling application |
|
367 iAvkonAppUi->ProcessCommandL(EAknCmdExit); |
|
368 break; |
|
369 } |
|
370 |
|
371 default: |
|
372 break; |
|
373 } |
|
374 } |
|
375 |
|
376 |
|
377 //------------------------------------------------------------------------------ |
|
378 // CAspAdvanceSettingsDialog::OkToExitL |
|
379 // |
|
380 //------------------------------------------------------------------------------ |
|
381 // |
|
382 TBool CAspAdvanceSettingsDialog::OkToExitL(TInt aButtonId) |
|
383 { |
|
384 if (aButtonId == EEikBidCancel) |
|
385 { |
|
386 // save silently and close dialog |
|
387 |
|
388 CheckSettingValues(aButtonId); |
|
389 |
|
390 return ETrue; // close dialog |
|
391 } |
|
392 |
|
393 if (aButtonId == EAknSoftkeyBack) |
|
394 { |
|
395 TBool ret = CheckSettingValues(aButtonId); |
|
396 if (!ret) |
|
397 { |
|
398 return EFalse; // leave dialog open |
|
399 } |
|
400 |
|
401 return ETrue; // close dialog |
|
402 } |
|
403 |
|
404 if (aButtonId == EAknSoftkeyOpen || aButtonId == EAknSoftkeyEmpty) // MSK |
|
405 { |
|
406 CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex()); |
|
407 if (item->iHidden == EVisibilityReadOnly) |
|
408 { |
|
409 if(iEditMode == EDialogModeSettingEnforcement) |
|
410 { |
|
411 TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING); |
|
412 } |
|
413 else |
|
414 { |
|
415 TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY); |
|
416 } |
|
417 return EFalse; |
|
418 } |
|
419 |
|
420 HandleOKL(); |
|
421 return EFalse; // leave dialog open |
|
422 } |
|
423 |
|
424 if (aButtonId == EAknSoftkeyOptions) |
|
425 { |
|
426 if (iCommandSetId == R_ASP_CBA_OPTIONS_BACK_OPEN) |
|
427 { |
|
428 UpdateMenuL(R_ADVANCE_SETTINGS_DIALOG_MENU); |
|
429 } |
|
430 else |
|
431 { |
|
432 UpdateMenuL(R_ASP_PROFILE_DIALOG_MENU); |
|
433 } |
|
434 return EFalse; |
|
435 } |
|
436 return CAknDialog::OkToExitL(aButtonId); |
|
437 } |
|
438 |
|
439 |
|
440 //------------------------------------------------------------------------------ |
|
441 // CAspAdvanceSettingsDialog::CheckSettingValuesL |
|
442 // |
|
443 //------------------------------------------------------------------------------ |
|
444 // |
|
445 TBool CAspAdvanceSettingsDialog::CheckSettingValuesL(TInt /* aButtonId */) |
|
446 { |
|
447 |
|
448 if (iEditMode == EDialogModeReadOnly || |
|
449 iEditMode == EDialogModeSettingEnforcement) |
|
450 { |
|
451 return ETrue; |
|
452 } |
|
453 |
|
454 return ETrue; |
|
455 } |
|
456 |
|
457 |
|
458 //------------------------------------------------------------------------------ |
|
459 // CAspAdvanceSettingsDialog::CheckSettingValues |
|
460 // |
|
461 //------------------------------------------------------------------------------ |
|
462 // |
|
463 TBool CAspAdvanceSettingsDialog::CheckSettingValues(TInt aButtonId) |
|
464 { |
|
465 TBool ret = EFalse; |
|
466 |
|
467 TRAPD(err, ret = CheckSettingValuesL(aButtonId)); |
|
468 if (err != KErrNone) |
|
469 { |
|
470 return ETrue; |
|
471 } |
|
472 |
|
473 return ret; |
|
474 } |
|
475 |
|
476 |
|
477 // ---------------------------------------------------------------------------- |
|
478 // CAspAdvanceSettingsDialog::OfferKeyEventL |
|
479 // |
|
480 // ---------------------------------------------------------------------------- |
|
481 // |
|
482 TKeyResponse CAspAdvanceSettingsDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
483 { |
|
484 if (aType == EEventKey) |
|
485 { |
|
486 switch (aKeyEvent.iCode) |
|
487 { |
|
488 case EKeyEnter: |
|
489 case EKeyOK: |
|
490 { |
|
491 OkToExitL(EAknSoftkeyOpen); |
|
492 return EKeyWasConsumed; |
|
493 } |
|
494 case EKeyEscape: // framework calls this when dialog must shut down |
|
495 { |
|
496 return CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
497 } |
|
498 case EKeyUpArrow: |
|
499 case EKeyDownArrow: |
|
500 { |
|
501 if(iEditMode != EDialogModeSettingEnforcement) |
|
502 { |
|
503 TRAPD(err ,CheckContentSettingL(aKeyEvent));//folder |
|
504 User::LeaveIfError(err); |
|
505 } |
|
506 break; |
|
507 } |
|
508 default: |
|
509 { |
|
510 break; |
|
511 } |
|
512 } |
|
513 } |
|
514 |
|
515 return CAknDialog::OfferKeyEventL( aKeyEvent, aType); |
|
516 } |
|
517 |
|
518 // --------------------------------------------------------------------------------------------- |
|
519 // CAspAdvanceSettingsDialog::CheckContentSetting |
|
520 // modifies MSK and menu item depending on the item in the list box when touch events are handled |
|
521 // ---------------------------------------------------------------------------------------------- |
|
522 // |
|
523 |
|
524 void CAspAdvanceSettingsDialog::CheckContentSettingL() |
|
525 { |
|
526 TInt curIndex = ListBox()->CurrentItemIndex(); |
|
527 TInt count = iSettingList->Count(); |
|
528 CAspListItemData* lastItem = (*iSettingList)[--count]; |
|
529 |
|
530 |
|
531 |
|
532 CAspListItemData* curItem = GetItemForIndex(curIndex); |
|
533 //TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile); |
|
534 //if(isPCSuite && (curItem->iHidden == EVisibilityReadOnly)) |
|
535 if(curItem->iHidden == EVisibilityReadOnly) |
|
536 { |
|
537 SetEmptyMiddleSoftKeyLabelL(); |
|
538 return; |
|
539 } |
|
540 if(curItem->iItemId != EAspSyncContent) |
|
541 { |
|
542 if(iCommandSetId != R_ASP_CBA_OPTIONS_BACK_CHANGE || iMSKEmpty) |
|
543 { |
|
544 UpdateCbaL(R_ASP_CBA_OPTIONS_BACK_CHANGE); |
|
545 |
|
546 } |
|
547 return; |
|
548 } |
|
549 UpdateCbaL( R_ASP_CBA_OPTIONS_BACK_OPEN); |
|
550 |
|
551 } |
|
552 |
|
553 // ---------------------------------------------------------------------------- |
|
554 // CAspAdvanceSettingsDialog::CheckContentSetting |
|
555 // modifies MSK based on the item |
|
556 // ---------------------------------------------------------------------------- |
|
557 // |
|
558 |
|
559 void CAspAdvanceSettingsDialog::CheckContentSettingL(const TKeyEvent& aKeyEvent) |
|
560 { |
|
561 |
|
562 TInt curIndex = ListBox()->CurrentItemIndex(); |
|
563 TInt count = iSettingList->Count(); |
|
564 CAspListItemData* lastItem = (*iSettingList)[--count]; |
|
565 |
|
566 switch (aKeyEvent.iCode) |
|
567 { |
|
568 case EKeyUpArrow: |
|
569 { |
|
570 if (curIndex) |
|
571 { |
|
572 curIndex--; |
|
573 } |
|
574 else |
|
575 { |
|
576 curIndex = lastItem->iIndex; |
|
577 } |
|
578 break; |
|
579 } |
|
580 case EKeyDownArrow: |
|
581 { |
|
582 if (curIndex == lastItem->iIndex) |
|
583 { |
|
584 curIndex = 0; |
|
585 } |
|
586 else |
|
587 { |
|
588 curIndex++; |
|
589 } |
|
590 break; |
|
591 } |
|
592 } |
|
593 |
|
594 CAspListItemData* curItem = GetItemForIndex(curIndex); |
|
595 //TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile); |
|
596 //if(isPCSuite && (curItem->iHidden == EVisibilityReadOnly)) |
|
597 if(curItem->iHidden == EVisibilityReadOnly) |
|
598 { |
|
599 SetEmptyMiddleSoftKeyLabelL(); |
|
600 return; |
|
601 } |
|
602 if(curItem->iItemId != EAspSyncContent) |
|
603 { |
|
604 if(iCommandSetId != R_ASP_CBA_OPTIONS_BACK_CHANGE || iMSKEmpty) |
|
605 { |
|
606 UpdateCbaL(R_ASP_CBA_OPTIONS_BACK_CHANGE); |
|
607 |
|
608 } |
|
609 return; |
|
610 } |
|
611 UpdateCbaL( R_ASP_CBA_OPTIONS_BACK_OPEN); |
|
612 |
|
613 } |
|
614 |
|
615 // ---------------------------------------------------------------------------- |
|
616 // CAspAdvanceSettingsDialog::HandleResourceChange |
|
617 // |
|
618 // ---------------------------------------------------------------------------- |
|
619 // |
|
620 void CAspAdvanceSettingsDialog::HandleResourceChange(TInt aType) |
|
621 { |
|
622 if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation |
|
623 { |
|
624 TRect mainPaneRect; |
|
625 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
626 SetRect(mainPaneRect); |
|
627 iSettingListBox->SetSize(mainPaneRect.Size()); |
|
628 CCoeControl::HandleResourceChange(aType); |
|
629 DrawDeferred(); |
|
630 return; |
|
631 } |
|
632 |
|
633 if (aType == KAknsMessageSkinChange) |
|
634 { |
|
635 TRAP_IGNORE(SetIconsL()); |
|
636 } |
|
637 |
|
638 CCoeControl::HandleResourceChange(aType); |
|
639 } |
|
640 |
|
641 //------------------------------------------------------------------------------ |
|
642 // CAspAdvanceSettingsDialog::HandleOKL |
|
643 // |
|
644 //------------------------------------------------------------------------------ |
|
645 // |
|
646 void CAspAdvanceSettingsDialog::HandleOKL() |
|
647 { |
|
648 |
|
649 CAspListItemData* item = GetItemForIndex(ListBox()->CurrentItemIndex()); |
|
650 |
|
651 if (item->iHidden == EVisibilityReadOnly) |
|
652 { |
|
653 if(iEditMode == EDialogModeSettingEnforcement) |
|
654 { |
|
655 TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING); |
|
656 } |
|
657 else |
|
658 { |
|
659 TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY); |
|
660 } |
|
661 return; |
|
662 } |
|
663 |
|
664 if (EditSettingItemL(*item)) |
|
665 { |
|
666 SetVisibility(); |
|
667 UpdateListBoxL(ListBox(), iSettingList); |
|
668 } |
|
669 |
|
670 } |
|
671 |
|
672 |
|
673 // ---------------------------------------------------------------------------- |
|
674 // CAspAdvanceSettingsDialog::CreateSettingsListL |
|
675 // |
|
676 // Function creates setting list array (iSettingsList). |
|
677 // Note: enum TAspConnectionSettings must match with string array |
|
678 // (R_ASP_CONNECTION_DIALOG_SETTING_ITEMS). |
|
679 // ---------------------------------------------------------------------------- |
|
680 // |
|
681 void CAspAdvanceSettingsDialog::CreateSettingsListL() |
|
682 { |
|
683 // read setting headers from resource |
|
684 CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ADVANCE_SETTINGS_DIALOG_ITEMS); |
|
685 |
|
686 // add one CAspListItemData for each setting |
|
687 AddItemL(ERoamingSettings, arr); |
|
688 |
|
689 // write setting data into each CAspListItemData |
|
690 TInt count=iSettingList->Count(); |
|
691 for (TInt i=0; i<count; i++) |
|
692 { |
|
693 InitSettingItemL((*iSettingList)[i]); |
|
694 } |
|
695 |
|
696 SetVisibility(); // find out what setting appear on UI |
|
697 |
|
698 CleanupStack::PopAndDestroy(arr); |
|
699 } |
|
700 |
|
701 |
|
702 // ---------------------------------------------------------------------------- |
|
703 // CAspAdvanceSettingsDialog::AddItemL |
|
704 // |
|
705 // ---------------------------------------------------------------------------- |
|
706 // |
|
707 void CAspAdvanceSettingsDialog::AddItemL(TInt aItemId, CDesCArray* aHeaders) |
|
708 { |
|
709 CAspListItemData* item = CAspListItemData::NewLC(); |
|
710 item->SetHeaderL((*aHeaders)[aItemId]); |
|
711 item->iItemId = aItemId; |
|
712 iSettingList->AppendL(item); |
|
713 CleanupStack::Pop(item); |
|
714 } |
|
715 // ---------------------------------------------------------------------------- |
|
716 // CAspAdvanceSettingsDialog::AddItemL |
|
717 // |
|
718 // ---------------------------------------------------------------------------- |
|
719 // |
|
720 void CAspAdvanceSettingsDialog::AddItemL(TInt aItemId, TInt aResourceId) |
|
721 { |
|
722 CAspListItemData* item = CAspListItemData::NewLC(); |
|
723 item->SetHeaderL(aResourceId); |
|
724 item->iItemId = aItemId; |
|
725 iSettingList->AppendL(item); |
|
726 CleanupStack::Pop(item); |
|
727 } |
|
728 |
|
729 // ---------------------------------------------------------------------------- |
|
730 // CAspAdvanceSettingsDialog::UpdateListBoxL |
|
731 // |
|
732 // Add settings headers into listbox. |
|
733 // ---------------------------------------------------------------------------- |
|
734 // |
|
735 void CAspAdvanceSettingsDialog::UpdateListBoxL(CEikTextListBox* aListBox, |
|
736 CAspSettingList* aItemList) |
|
737 { |
|
738 CDesCArray* arr = (CDesCArray*)aListBox->Model()->ItemTextArray(); |
|
739 arr->Reset(); |
|
740 |
|
741 TInt count = aItemList->Count(); |
|
742 for (TInt i=0; i<count; i++ ) |
|
743 { |
|
744 CAspListItemData* item = (*aItemList)[i]; |
|
745 TInt aValue = 0; |
|
746 ReadRepositoryL(KNSmlRoamingSettingKey, aValue); |
|
747 if(aValue != ERoamingSettingBlock) |
|
748 { |
|
749 WriteRepositoryL(KNSmlRoamingSettingKey, item->iNumberData); |
|
750 } |
|
751 else |
|
752 { |
|
753 SetEmptyMiddleSoftKeyLabelL(); |
|
754 } |
|
755 |
|
756 TBool convert = ETrue; |
|
757 if (item->iHidden != EVisibilityHidden) |
|
758 { |
|
759 HBufC* hBuf = item->ListItemTextL(convert); |
|
760 CleanupStack::PushL(hBuf); |
|
761 |
|
762 arr->AppendL(hBuf->Des()); |
|
763 |
|
764 // store listbox index (from zero up) into setting item |
|
765 item->iIndex = arr->Count() - 1; |
|
766 |
|
767 CleanupStack::PopAndDestroy(hBuf); |
|
768 } |
|
769 else |
|
770 { |
|
771 item->iIndex = KErrNotFound; |
|
772 } |
|
773 } |
|
774 |
|
775 ListBox()->HandleItemAdditionL(); |
|
776 } |
|
777 |
|
778 |
|
779 // ----------------------------------------------------------------------------- |
|
780 // CAspAdvanceSettingsDialog::SetVisibility |
|
781 // |
|
782 // ----------------------------------------------------------------------------- |
|
783 // |
|
784 void CAspAdvanceSettingsDialog::SetVisibility() |
|
785 { |
|
786 TInt aValue(0); |
|
787 TRAPD(err ,ReadRepositoryL(KNSmlRoamingSettingKey, aValue)); |
|
788 if(aValue == ERoamingSettingBlock) |
|
789 { |
|
790 Item(ERoamingSettings)->iHidden = EVisibilityReadOnly; |
|
791 } |
|
792 else |
|
793 { |
|
794 Item(ERoamingSettings)->iHidden = EVisibilityNormal; |
|
795 } |
|
796 } |
|
797 |
|
798 void CAspAdvanceSettingsDialog::ReadRepositoryL(TInt aKey, TInt& aValue) |
|
799 { |
|
800 CRepository* rep = CRepository::NewLC(KCRUidNSmlDSApp); |
|
801 TInt err = rep->Get(aKey, aValue); |
|
802 User::LeaveIfError(err); |
|
803 |
|
804 CleanupStack::PopAndDestroy(rep); |
|
805 } |
|
806 |
|
807 // ----------------------------------------------------------------------------- |
|
808 // CAspAdvanceSettingsDialog::InitSettingItemL |
|
809 // |
|
810 // Constructs CAspListItemData for one connection setting. |
|
811 // ----------------------------------------------------------------------------- |
|
812 // |
|
813 void CAspAdvanceSettingsDialog::InitSettingItemL(CAspListItemData* aItem) |
|
814 { |
|
815 __ASSERT_ALWAYS(aItem, TUtil::Panic(KErrGeneral)); |
|
816 |
|
817 iBuf = KNullDesC; // reset common buffer |
|
818 |
|
819 switch (aItem->iItemId) |
|
820 { |
|
821 case ERoamingSettings: |
|
822 { |
|
823 CDesCArray* arr = iResHandler->ReadDesArrayLC(R_ASP_ROAMING_SETTINGS); |
|
824 TInt aValue(0); |
|
825 ReadRepositoryL(KNSmlRoamingSettingKey, aValue); |
|
826 |
|
827 if(aValue == ERoamingSettingBlock) |
|
828 { |
|
829 aItem->iNumberData = ERoamingSettingAlwaysAsk; |
|
830 } |
|
831 else |
|
832 { |
|
833 aItem->iNumberData = aValue; |
|
834 } |
|
835 //aItem->iNumberData = iProfile->SASyncState(); |
|
836 aItem->iResource = R_ASP_ROAMING_SETTINGS; |
|
837 aItem->SetValueL((*arr)[aItem->iNumberData]); |
|
838 aItem->iItemType = CAspListItemData::ETypeList; |
|
839 |
|
840 CleanupStack::PopAndDestroy(arr); |
|
841 break; |
|
842 } |
|
843 |
|
844 default: |
|
845 __ASSERT_DEBUG(EFalse, TUtil::Panic(KErrGeneral)); |
|
846 break; |
|
847 |
|
848 } |
|
849 } |
|
850 |
|
851 //------------------------------------------------------------------------------ |
|
852 // CAspAdvanceSettingsDialog::EditSettingItemL |
|
853 // |
|
854 // Calls setting editing functions. |
|
855 //------------------------------------------------------------------------------ |
|
856 // |
|
857 TBool CAspAdvanceSettingsDialog::EditSettingItemL(CAspListItemData& aItem) |
|
858 { |
|
859 TInt ret = EFalse; |
|
860 |
|
861 switch (aItem.iItemType) |
|
862 { |
|
863 |
|
864 case CAspListItemData::ETypeList: |
|
865 ret = EditSettingItemListL(aItem); |
|
866 break; |
|
867 |
|
868 |
|
869 default: |
|
870 break; |
|
871 } |
|
872 |
|
873 return ret; |
|
874 } |
|
875 |
|
876 //------------------------------------------------------------------------------ |
|
877 // CAspAdvanceSettingsDialog::EditSettingItemListL |
|
878 // |
|
879 //------------------------------------------------------------------------------ |
|
880 // |
|
881 TBool CAspAdvanceSettingsDialog::EditSettingItemListL(CAspListItemData& aItem) |
|
882 { |
|
883 TInt curSelection = aItem.iNumberData; |
|
884 CDesCArray* arr = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource); |
|
885 |
|
886 TBool ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection); |
|
887 if (ret) |
|
888 { |
|
889 aItem.iNumberData = curSelection; |
|
890 aItem.SetValueL((*arr)[curSelection]); |
|
891 } |
|
892 |
|
893 CleanupStack::PopAndDestroy(arr); |
|
894 return ret; |
|
895 } |
|
896 |
|
897 //----------------------------------------------------------------------------- |
|
898 // CAspAdvanceSettingsDialog::GetItemForIndex |
|
899 // |
|
900 // Find item in list position aIndex. |
|
901 //----------------------------------------------------------------------------- |
|
902 // |
|
903 CAspListItemData* CAspAdvanceSettingsDialog::GetItemForIndex(TInt aIndex) |
|
904 { |
|
905 CAspListItemData* item = NULL; |
|
906 |
|
907 TInt count = iSettingList->Count(); |
|
908 for (TInt i=0; i<count; i++) |
|
909 { |
|
910 CAspListItemData* temp = (*iSettingList)[i]; |
|
911 if (temp->iIndex == aIndex) |
|
912 { |
|
913 item = temp; |
|
914 break; |
|
915 } |
|
916 } |
|
917 |
|
918 __ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral)); |
|
919 |
|
920 return item; |
|
921 } |
|
922 |
|
923 |
|
924 //----------------------------------------------------------------------------- |
|
925 // CAspAdvanceSettingsDialog::Item |
|
926 // |
|
927 // Find item with aItemId (TAspConnectionSettingItem). |
|
928 //----------------------------------------------------------------------------- |
|
929 // |
|
930 CAspListItemData* CAspAdvanceSettingsDialog::Item(TInt aItemId) |
|
931 { |
|
932 CAspListItemData* item = NULL; |
|
933 |
|
934 TInt count = iSettingList->Count(); |
|
935 for (TInt i=0; i<count; i++) |
|
936 { |
|
937 CAspListItemData* temp = (*iSettingList)[i]; |
|
938 if (temp->iItemId == aItemId) |
|
939 { |
|
940 item = temp; |
|
941 break; |
|
942 } |
|
943 } |
|
944 |
|
945 __ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral)); |
|
946 |
|
947 return item; |
|
948 } |
|
949 |
|
950 |
|
951 // ----------------------------------------------------------------------------- |
|
952 // CAspAdvanceSettingsDialog::ListBox |
|
953 // |
|
954 // ----------------------------------------------------------------------------- |
|
955 // |
|
956 CAknSettingStyleListBox* CAspAdvanceSettingsDialog::ListBox() |
|
957 { |
|
958 return iSettingListBox; |
|
959 } |
|
960 |
|
961 |
|
962 // ----------------------------------------------------------------------------- |
|
963 // CAspAdvanceSettingsDialog::UpdateCbaL |
|
964 // |
|
965 // ----------------------------------------------------------------------------- |
|
966 // |
|
967 void CAspAdvanceSettingsDialog::UpdateCbaL(TInt aResourceId) |
|
968 { |
|
969 CEikButtonGroupContainer& cba = ButtonGroupContainer(); |
|
970 cba.SetCommandSetL(aResourceId); |
|
971 iCommandSetId = aResourceId; |
|
972 iMSKEmpty = EFalse; |
|
973 cba.DrawDeferred(); |
|
974 } |
|
975 |
|
976 // ----------------------------------------------------------------------------- |
|
977 // CAspAdvanceSettingsDialog::UpdateMenuL |
|
978 // |
|
979 // ----------------------------------------------------------------------------- |
|
980 // |
|
981 |
|
982 void CAspAdvanceSettingsDialog::UpdateMenuL(TInt aResource) |
|
983 { |
|
984 CEikMenuBar* menuBar = iMenuBar; // from CAknDialog |
|
985 menuBar->SetMenuTitleResourceId(aResource); |
|
986 |
|
987 TRAPD(err, menuBar->TryDisplayMenuBarL()); |
|
988 |
|
989 User::LeaveIfError(err); |
|
990 |
|
991 |
|
992 } |
|
993 |
|
994 // ----------------------------------------------------------------------------- |
|
995 // CAspAdvanceSettingsDialog::UpdateMenuL |
|
996 // |
|
997 // ----------------------------------------------------------------------------- |
|
998 // |
|
999 void CAspAdvanceSettingsDialog::WriteRepositoryL(TInt aKey, const TInt& aValue) |
|
1000 { |
|
1001 const TUid KCRRoamingSettingUID = {0x101F9A1D}; |
|
1002 const TUid KRepositoryId = KCRRoamingSettingUID; |
|
1003 |
|
1004 CRepository* rep = CRepository::NewLC(KRepositoryId); |
|
1005 TInt err = rep->Set(aKey, aValue); |
|
1006 User::LeaveIfError(err); |
|
1007 |
|
1008 CleanupStack::PopAndDestroy(rep); |
|
1009 } |
|
1010 // End of File |