|
1 /* |
|
2 * Copyright (c) 2002-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 // INCLUDE FILES |
|
20 #include "AspContentDialog.h" |
|
21 #include "AspUtil.h" |
|
22 #include "AspDefines.h" |
|
23 #include "AspDialogUtil.h" |
|
24 #include "AspResHandler.h" |
|
25 #include "AspDebug.h" |
|
26 #include "AspSyncUtil.rh" |
|
27 #include <csxhelp/ds.hlp.hrh> |
|
28 |
|
29 #include <aspsyncutil.mbg> // for bitmap enumerations |
|
30 #include <AknIconArray.h> // for GulArray |
|
31 #include <featmgr.h> // FeatureManager |
|
32 #include "AspSchedule.h" |
|
33 |
|
34 const TInt KMSKControlId( CEikButtonGroupContainer::EMiddleSoftkeyPosition ); |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CAspContentDialog::ShowDialogL |
|
38 // |
|
39 // ----------------------------------------------------------------------------- |
|
40 TBool CAspContentDialog::ShowDialogL(TAspParam& aParam) |
|
41 { |
|
42 CAspContentDialog* dialog = CAspContentDialog::NewL(aParam); |
|
43 |
|
44 return dialog->ExecuteLD(R_ASP_CONTENT_DIALOG); |
|
45 } |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CAspContentDialog::NewL |
|
50 // |
|
51 // ----------------------------------------------------------------------------- |
|
52 CAspContentDialog* CAspContentDialog::NewL(TAspParam& aParam) |
|
53 { |
|
54 FLOG( _L("CAspContentDialog::NewL START") ); |
|
55 |
|
56 CAspContentDialog* self = new (ELeave) CAspContentDialog(aParam); |
|
57 CleanupStack::PushL(self); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop(self); |
|
60 |
|
61 FLOG( _L("CAspContentDialog::NewL END") ); |
|
62 return(self); |
|
63 } |
|
64 |
|
65 |
|
66 //------------------------------------------------------------------------------ |
|
67 // CAspContentDialog::CAspContentDialog |
|
68 // |
|
69 //------------------------------------------------------------------------------ |
|
70 // |
|
71 CAspContentDialog::CAspContentDialog(TAspParam& aParam) |
|
72 { |
|
73 iApplicationId = aParam.iApplicationId; |
|
74 iProfile = aParam.iProfile; |
|
75 iSyncSession = aParam.iSyncSession; |
|
76 iContentList = aParam.iContentList; |
|
77 iDialogParam = &aParam; |
|
78 iDataProviderId = aParam.iDataProviderId; |
|
79 |
|
80 iDataStoreChanged = EFalse; |
|
81 iMskEmpty = EFalse; |
|
82 |
|
83 __ASSERT_ALWAYS(iDataProviderId != KErrNotFound, TUtil::Panic(KErrGeneral)); |
|
84 __ASSERT_ALWAYS(iProfile, TUtil::Panic(KErrGeneral)); |
|
85 __ASSERT_ALWAYS(iContentList, TUtil::Panic(KErrGeneral)); |
|
86 __ASSERT_ALWAYS(iSyncSession, TUtil::Panic(KErrGeneral)); |
|
87 } |
|
88 |
|
89 |
|
90 //------------------------------------------------------------------------------ |
|
91 // Destructor |
|
92 // |
|
93 //------------------------------------------------------------------------------ |
|
94 // |
|
95 CAspContentDialog::~CAspContentDialog() |
|
96 { |
|
97 FLOG( _L("CAspContentDialog::~CAspContentDialog START") ); |
|
98 |
|
99 if (iSettingList) |
|
100 { |
|
101 iSettingList->ResetAndDestroy(); |
|
102 delete iSettingList; |
|
103 } |
|
104 |
|
105 delete iStatusPaneHandler; |
|
106 delete iLocalDataStores; |
|
107 |
|
108 if (iAvkonAppUi) |
|
109 { |
|
110 iAvkonAppUi->RemoveFromStack(this); |
|
111 } |
|
112 |
|
113 FLOG( _L("CAspContentDialog::~CAspContentDialog END") ); |
|
114 } |
|
115 |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CAspContentDialog::ConstructL |
|
119 // |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CAspContentDialog::ConstructL() |
|
123 { |
|
124 FLOG( _L("CAspContentDialog::ConstructL START") ); |
|
125 |
|
126 CAknDialog::ConstructL(R_ASP_CONTENT_DIALOG_MENU); |
|
127 |
|
128 iSettingEnforcement = TUtil::SettingEnforcementState(); |
|
129 |
|
130 iSettingList = new (ELeave) CArrayPtrFlat<CAspListItemData>(KDefaultArraySize); |
|
131 |
|
132 iLocalDataStores = new (ELeave) CDesCArrayFlat(KDefaultArraySize); |
|
133 iContentList->GetLocalDatabaseList(iDataProviderId, iLocalDataStores); |
|
134 |
|
135 TInt count = iLocalDataStores->Count(); |
|
136 if (count == 0) |
|
137 { |
|
138 if (iDataProviderId == KUidNSmlAdapterEMail.iUid) |
|
139 { |
|
140 TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES); |
|
141 } |
|
142 else |
|
143 { |
|
144 TDialogUtil::ShowErrorNoteL(R_ASP_LOG_ERR_LOCALDATABASE); |
|
145 User::Leave(KErrNotFound); |
|
146 } |
|
147 } |
|
148 |
|
149 InitTaskDataL(); |
|
150 |
|
151 // get previous title so it can be restored |
|
152 iStatusPaneHandler = CStatusPaneHandler::NewL(iAvkonAppUi); |
|
153 iStatusPaneHandler->StoreOriginalTitleL(); |
|
154 |
|
155 // store current navi pane |
|
156 iStatusPaneHandler->StoreNavipaneL(); |
|
157 |
|
158 FLOG( _L("CAspContentDialog::ConstructL END") ); |
|
159 } |
|
160 |
|
161 |
|
162 //------------------------------------------------------------------------------ |
|
163 // CAspContentDialog::ActivateL (from CCoeControl) |
|
164 // |
|
165 // Called by system when dialog is activated |
|
166 //------------------------------------------------------------------------------ |
|
167 // |
|
168 void CAspContentDialog::ActivateL() |
|
169 { |
|
170 CAknDialog::ActivateL(); |
|
171 |
|
172 // this cannot be in ConstructL which is executed before dialog is launched |
|
173 iAvkonAppUi->AddToStackL(this); |
|
174 } |
|
175 |
|
176 //------------------------------------------------------------------------------ |
|
177 // CAspContentDialog::CheckContentSettingL |
|
178 // |
|
179 // Check if the MSK label is correct for the context |
|
180 //------------------------------------------------------------------------------ |
|
181 |
|
182 void CAspContentDialog::CheckContentSettingL(const TKeyEvent& aKeyEvent) |
|
183 { |
|
184 |
|
185 TInt curIndex = iListBox->CurrentItemIndex(); |
|
186 TInt count = iSettingList->Count(); |
|
187 CAspListItemData* lastItem = (*iSettingList)[--count]; |
|
188 |
|
189 switch (aKeyEvent.iCode) |
|
190 { |
|
191 case EKeyUpArrow: |
|
192 { |
|
193 if (curIndex) |
|
194 { |
|
195 curIndex--; |
|
196 } |
|
197 else |
|
198 { |
|
199 curIndex = lastItem->iIndex; |
|
200 } |
|
201 break; |
|
202 } |
|
203 case EKeyDownArrow: |
|
204 { |
|
205 if (curIndex == lastItem->iIndex) |
|
206 { |
|
207 curIndex = 0; |
|
208 } |
|
209 else |
|
210 { |
|
211 curIndex++; |
|
212 } |
|
213 break; |
|
214 } |
|
215 } |
|
216 CAspListItemData* curItem = GetItemForIndex(curIndex); |
|
217 if(curItem->iHidden == EVisibilityReadOnly) |
|
218 { |
|
219 UpdateMiddleSoftKeyLabelL(EAknSoftkeyOpen,R_TEXT_SOFTKEY_EMPTY); |
|
220 iMskEmpty = ETrue; |
|
221 return; |
|
222 } |
|
223 if(iMskEmpty) |
|
224 { |
|
225 UpdateMiddleSoftKeyLabelL(EAknSoftkeyEmpty,R_QTN_MSK_CHANGE); |
|
226 iMskEmpty = EFalse; |
|
227 } |
|
228 |
|
229 } |
|
230 |
|
231 //------------------------------------------------------------------------------ |
|
232 // CAspContentDialog::UpdateMiddleSoftKeyLabelL |
|
233 // |
|
234 // Update the MSK |
|
235 //------------------------------------------------------------------------------ |
|
236 void CAspContentDialog::UpdateMiddleSoftKeyLabelL(TInt aCommandId,TInt aResourceId) |
|
237 { |
|
238 ButtonGroupContainer().RemoveCommandFromStack(KMSKControlId,aCommandId ); |
|
239 HBufC* middleSKText = StringLoader::LoadLC( aResourceId ); |
|
240 |
|
241 ButtonGroupContainer().AddCommandToStackL( |
|
242 KMSKControlId, |
|
243 aCommandId, |
|
244 *middleSKText ); |
|
245 CleanupStack::PopAndDestroy( middleSKText ); |
|
246 } |
|
247 |
|
248 |
|
249 //------------------------------------------------------------------------------ |
|
250 // CAspContentDialog::GetHelpContext |
|
251 // |
|
252 //------------------------------------------------------------------------------ |
|
253 // |
|
254 void CAspContentDialog::GetHelpContext(TCoeHelpContext& aContext) const |
|
255 { |
|
256 aContext.iMajor = KUidSmlSyncApp; |
|
257 |
|
258 TInt dataProvider = DataProviderType(); |
|
259 if (dataProvider == EApplicationIdContact) |
|
260 { |
|
261 aContext.iContext = KDS_HLP_SETTINGS_CNT; |
|
262 } |
|
263 else if (dataProvider == EApplicationIdCalendar) |
|
264 { |
|
265 aContext.iContext = KDS_HLP_SETTINGS_CAL; |
|
266 } |
|
267 else if (dataProvider == EApplicationIdNote) |
|
268 { |
|
269 aContext.iContext = KDS_HLP_SETTINGS_NOTES; |
|
270 } |
|
271 else if (dataProvider == EApplicationIdSms) |
|
272 { |
|
273 aContext.iContext = KDS_HLP_SETTINGS_SMS; |
|
274 } |
|
275 else |
|
276 { |
|
277 aContext.iContext = KDS_HLP_MAIN_VIEW; // unknown application |
|
278 } |
|
279 } |
|
280 |
|
281 |
|
282 //------------------------------------------------------------------------------ |
|
283 // CAspContentDialog::ProcessCommandL |
|
284 // |
|
285 // Handle menu commands. |
|
286 //------------------------------------------------------------------------------ |
|
287 // |
|
288 void CAspContentDialog::ProcessCommandL( TInt aCommandId ) |
|
289 { |
|
290 HideMenu(); |
|
291 |
|
292 switch (aCommandId) |
|
293 { |
|
294 |
|
295 case EAknCmdHelp: |
|
296 { |
|
297 TUtil::LaunchHelpAppL(iEikonEnv); |
|
298 break; |
|
299 } |
|
300 |
|
301 case EAspMenuCmdChange: |
|
302 { |
|
303 HandleOKL(); |
|
304 |
|
305 break; |
|
306 } |
|
307 |
|
308 case EAspMenuCmdExit: |
|
309 case EAknCmdExit: |
|
310 case EEikCmdExit: |
|
311 { |
|
312 // close dialog and exit calling application |
|
313 iAvkonAppUi->ProcessCommandL(EAknCmdExit); |
|
314 break; |
|
315 } |
|
316 |
|
317 |
|
318 default: |
|
319 break; |
|
320 } |
|
321 } |
|
322 |
|
323 |
|
324 //------------------------------------------------------------------------------ |
|
325 // CAspContentDialog::OfferKeyEventL |
|
326 // |
|
327 // Handle key events. |
|
328 //------------------------------------------------------------------------------ |
|
329 // |
|
330 TKeyResponse CAspContentDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
331 { |
|
332 if (aType == EEventKey) |
|
333 { |
|
334 switch (aKeyEvent.iCode) |
|
335 { |
|
336 case EKeyEscape: // framework calls this when dialog must shut down |
|
337 { |
|
338 return CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
339 } |
|
340 |
|
341 case EKeyEnter: |
|
342 case EKeyOK: // OK button |
|
343 { |
|
344 HandleOKL(); |
|
345 return EKeyWasConsumed; |
|
346 } |
|
347 case EKeyUpArrow: |
|
348 case EKeyDownArrow: |
|
349 { |
|
350 if(!iSettingEnforcement) |
|
351 { |
|
352 TRAPD(err ,CheckContentSettingL(aKeyEvent)); |
|
353 User::LeaveIfError(err); |
|
354 } |
|
355 break; |
|
356 } |
|
357 } |
|
358 } |
|
359 |
|
360 return CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
361 } |
|
362 |
|
363 |
|
364 //------------------------------------------------------------------------------ |
|
365 // CAspContentDialog::OkToExitL |
|
366 // |
|
367 //------------------------------------------------------------------------------ |
|
368 // |
|
369 TBool CAspContentDialog::OkToExitL(TInt aButtonId) |
|
370 { |
|
371 if (aButtonId == EEikBidCancel) |
|
372 { |
|
373 // save silently and quit application |
|
374 TRAP_IGNORE(SaveSettingsL()); |
|
375 return ETrue; |
|
376 } |
|
377 |
|
378 if (aButtonId == EAknSoftkeyBack) |
|
379 { |
|
380 TInt index = CheckMandatoryFields(); |
|
381 if (index != KErrNotFound) |
|
382 { |
|
383 if (!TDialogUtil::ShowConfirmationQueryL(R_ASP_EXIT_ANYWAY)) |
|
384 { |
|
385 iListBox->SetCurrentItemIndexAndDraw(index); |
|
386 return EFalse; // leave dialog open |
|
387 } |
|
388 } |
|
389 |
|
390 TRAP_IGNORE(SaveSettingsL()); |
|
391 |
|
392 return ETrue; |
|
393 } |
|
394 |
|
395 if (aButtonId == EAknSoftkeyOpen||aButtonId == EAknSoftkeyEmpty ) // MSK |
|
396 { |
|
397 HandleOKL(); |
|
398 return EFalse; // leave dialog open |
|
399 } |
|
400 |
|
401 |
|
402 return CAknDialog::OkToExitL(aButtonId); |
|
403 } |
|
404 |
|
405 |
|
406 //------------------------------------------------------------------------------ |
|
407 // CAspContentDialog::PreLayoutDynInitL |
|
408 // |
|
409 // Called by system before the dialog is shown. |
|
410 //------------------------------------------------------------------------------ |
|
411 // |
|
412 void CAspContentDialog::PreLayoutDynInitL() |
|
413 { |
|
414 iListBox = (CAknSettingStyleListBox*)Control(EAspContentDialog); |
|
415 |
|
416 __ASSERT_ALWAYS(iListBox, TUtil::Panic(KErrGeneral)); |
|
417 |
|
418 iListBox->SetListBoxObserver(this); |
|
419 iListBox->CreateScrollBarFrameL(ETrue); |
|
420 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
421 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto); |
|
422 |
|
423 SetIconsL(); |
|
424 |
|
425 CreateSettingsListL(); |
|
426 UpdateListBoxL(iListBox, iSettingList); |
|
427 TInt curIndex = iListBox->CurrentItemIndex(); |
|
428 |
|
429 CAspListItemData* curItem = GetItemForIndex(curIndex); |
|
430 TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile); |
|
431 |
|
432 if(iSettingEnforcement || curItem->iHidden == EVisibilityReadOnly) |
|
433 { |
|
434 UpdateMiddleSoftKeyLabelL(EAknSoftkeyOpen,R_TEXT_SOFTKEY_EMPTY); |
|
435 |
|
436 } |
|
437 |
|
438 //Set title pane text |
|
439 TInt index = iContentList->FindProviderIndex(iDataProviderId); |
|
440 if (index != KErrNotFound) |
|
441 { |
|
442 TAspProviderItem& item = iContentList->ProviderItem(index); |
|
443 HBufC* hBuf = CAspResHandler::GetContentTitleLC(iDataProviderId, |
|
444 item.iDisplayName); |
|
445 iStatusPaneHandler->SetTitleL(hBuf->Des()); |
|
446 CleanupStack::PopAndDestroy(hBuf); |
|
447 } |
|
448 } |
|
449 |
|
450 |
|
451 // ---------------------------------------------------------------------------- |
|
452 // CAspContentDialog::SetIconsL |
|
453 // |
|
454 // ---------------------------------------------------------------------------- |
|
455 // |
|
456 void CAspContentDialog::SetIconsL() |
|
457 { |
|
458 if (!iListBox) |
|
459 { |
|
460 return; |
|
461 } |
|
462 |
|
463 TFileName bitmapName; |
|
464 CAspResHandler::GetBitmapFileName(bitmapName); |
|
465 CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray(KDefaultArraySize); |
|
466 CleanupStack::PushL(icons); |
|
467 |
|
468 icons->AppendL(IconL(KAknsIIDQgnIndiSettProtectedAdd, bitmapName, |
|
469 EMbmAspsyncutilQgn_indi_sett_protected_add, |
|
470 EMbmAspsyncutilQgn_indi_sett_protected_add_mask)); |
|
471 |
|
472 // delete old icons |
|
473 CArrayPtr<CGulIcon>* arr = iListBox->ItemDrawer()->FormattedCellData()->IconArray(); |
|
474 if (arr) |
|
475 { |
|
476 arr->ResetAndDestroy(); |
|
477 delete arr; |
|
478 arr = NULL; |
|
479 } |
|
480 |
|
481 iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons); |
|
482 CleanupStack::Pop(icons); |
|
483 } |
|
484 |
|
485 |
|
486 // ----------------------------------------------------------------------------- |
|
487 // CAspContentDialog::IconL |
|
488 // |
|
489 // ----------------------------------------------------------------------------- |
|
490 // |
|
491 CGulIcon* CAspContentDialog::IconL(TAknsItemID aId, const TDesC& aFileName, |
|
492 TInt aFileIndex, TInt aFileMaskIndex) |
|
493 { |
|
494 return TDialogUtil::CreateIconL(aId, aFileName, aFileIndex, aFileMaskIndex); |
|
495 } |
|
496 |
|
497 |
|
498 //------------------------------------------------------------------------------ |
|
499 // CAspContentDialog::DynInitMenuPaneL |
|
500 // |
|
501 // Called by system before menu is shown. |
|
502 //------------------------------------------------------------------------------ |
|
503 // |
|
504 void CAspContentDialog::DynInitMenuPaneL( TInt aResourceID, CEikMenuPane* aMenuPane) |
|
505 { |
|
506 if (aResourceID != R_ASP_CONTENT_DIALOG_MENU_PANE) |
|
507 { |
|
508 return; |
|
509 } |
|
510 |
|
511 if (iListBox->Model()->NumberOfItems() == 0) |
|
512 { |
|
513 TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange); |
|
514 } |
|
515 |
|
516 CAspListItemData* item = GetItemForIndex(iListBox->CurrentItemIndex()); |
|
517 |
|
518 if (item->iHidden == EVisibilityReadOnly) |
|
519 { |
|
520 TDialogUtil::DeleteMenuItem(aMenuPane, EAspMenuCmdChange); |
|
521 } |
|
522 |
|
523 TInt provider = DataProviderType(); |
|
524 |
|
525 if (provider == KErrNotFound) |
|
526 { |
|
527 TDialogUtil::DeleteMenuItem(aMenuPane, EAknCmdHelp); |
|
528 } |
|
529 |
|
530 if (!FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
531 { |
|
532 TDialogUtil::DeleteMenuItem(aMenuPane, EAknCmdHelp); |
|
533 } |
|
534 |
|
535 } |
|
536 |
|
537 |
|
538 //------------------------------------------------------------------------------ |
|
539 // CAspContentDialog::HandleListBoxEventL |
|
540 // |
|
541 // Handle listbox events. |
|
542 //------------------------------------------------------------------------------ |
|
543 // |
|
544 void CAspContentDialog::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
545 TListBoxEvent aEventType) |
|
546 { |
|
547 switch ( aEventType ) |
|
548 { |
|
549 case EEventItemDoubleClicked: |
|
550 HandleOKL(); |
|
551 break; |
|
552 default: |
|
553 break; |
|
554 } |
|
555 } |
|
556 |
|
557 |
|
558 //----------------------------------------------------------------------------- |
|
559 // CAspContentDialog::HandleOKL |
|
560 // |
|
561 // Handle content parameter editing. |
|
562 //----------------------------------------------------------------------------- |
|
563 // |
|
564 void CAspContentDialog::HandleOKL() |
|
565 { |
|
566 CAspListItemData* item = GetItemForIndex(iListBox->CurrentItemIndex()); |
|
567 if (item->iHidden == EVisibilityReadOnly) |
|
568 { |
|
569 if(!iSettingEnforcement) |
|
570 { |
|
571 TDialogUtil::ShowInformationNoteL(R_ASP_NOTE_READ_ONLY); |
|
572 } |
|
573 else |
|
574 { |
|
575 TDialogUtil::ShowInformationNoteL(R_ASP_PROTECTED_SETTING); |
|
576 } |
|
577 return; |
|
578 } |
|
579 |
|
580 if (EditSettingItemL(*item)) |
|
581 { |
|
582 SetVisibility(); |
|
583 UpdateListBoxL(iListBox, iSettingList); |
|
584 } |
|
585 } |
|
586 |
|
587 |
|
588 // ---------------------------------------------------------------------------- |
|
589 // CAspContentDialog::HandleResourceChange |
|
590 // |
|
591 // ---------------------------------------------------------------------------- |
|
592 // |
|
593 void CAspContentDialog::HandleResourceChange(TInt aType) |
|
594 { |
|
595 if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation |
|
596 { |
|
597 TRect mainPaneRect; |
|
598 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
599 SetRect(mainPaneRect); |
|
600 iListBox->SetSize(mainPaneRect.Size()); |
|
601 CCoeControl::HandleResourceChange(aType); |
|
602 DrawDeferred(); |
|
603 return; |
|
604 } |
|
605 |
|
606 if (aType == KAknsMessageSkinChange) |
|
607 { |
|
608 TRAP_IGNORE(SetIconsL()); |
|
609 } |
|
610 |
|
611 |
|
612 CCoeControl::HandleResourceChange(aType); |
|
613 } |
|
614 |
|
615 |
|
616 //------------------------------------------------------------------------------ |
|
617 // CAspContentDialog::InitTaskDataL |
|
618 // |
|
619 //------------------------------------------------------------------------------ |
|
620 // |
|
621 void CAspContentDialog::InitTaskDataL() |
|
622 { |
|
623 iContentList->ReadTaskL(iDataProviderId, iLocalDatabase, iRemoteDatabase, |
|
624 iTaskEnabled, iSyncDirection); |
|
625 |
|
626 if (iSettingEnforcement) |
|
627 { |
|
628 return; |
|
629 } |
|
630 |
|
631 // check that local database exists |
|
632 if (iLocalDatabase.Length() > 0) |
|
633 { |
|
634 TInt pos = 0; |
|
635 if (iLocalDataStores->Find(iLocalDatabase, pos) != 0) |
|
636 { |
|
637 iLocalDatabase = KNullDesC; // local database not found |
|
638 iDataStoreChanged = ETrue; |
|
639 } |
|
640 } |
|
641 |
|
642 if (iLocalDatabase.Length() == 0) |
|
643 { |
|
644 if (iDataProviderId == KUidNSmlAdapterEMail.iUid) |
|
645 { |
|
646 iContentList->UpdateDataProviderL(iDataProviderId); |
|
647 } |
|
648 |
|
649 TInt index = iContentList->FindProviderIndex(iDataProviderId); |
|
650 if (index != KErrNotFound) |
|
651 { |
|
652 TAspProviderItem& item = iContentList->ProviderItem(index); |
|
653 if (item.iDefaultDataStore.Length() > 0) |
|
654 { |
|
655 iLocalDatabase = item.iDefaultDataStore; |
|
656 iDataStoreChanged = ETrue; |
|
657 } |
|
658 } |
|
659 } |
|
660 } |
|
661 |
|
662 |
|
663 // ---------------------------------------------------------------------------- |
|
664 // CAspContentDialog::UpdateListBoxL |
|
665 // |
|
666 // Add settings headers into listbox. |
|
667 // ---------------------------------------------------------------------------- |
|
668 // |
|
669 void CAspContentDialog::UpdateListBoxL(CEikTextListBox* aListBox, |
|
670 CAspSettingList* aItemList) |
|
671 { |
|
672 CDesCArray* arr = (CDesCArray*)aListBox->Model()->ItemTextArray(); |
|
673 arr->Reset(); |
|
674 |
|
675 TInt count = aItemList->Count(); |
|
676 for (TInt index=0; index<count; index++ ) |
|
677 { |
|
678 TBool convert = ETrue; |
|
679 TBool isPCSuite=CAspProfile::IsPCSuiteProfile(iProfile); |
|
680 TBool readOnly = iProfile->DeleteAllowed(); |
|
681 |
|
682 CAspListItemData* item = (*aItemList)[index]; |
|
683 TInt id=item->iItemId; |
|
684 if(iSettingEnforcement) |
|
685 { |
|
686 if(id==EAspLocalDatabase ||id==EAspRemoteDatabase ) |
|
687 convert=EFalse; |
|
688 } |
|
689 else |
|
690 { |
|
691 if(isPCSuite|| !readOnly) |
|
692 { |
|
693 if(id==EAspRemoteDatabase) |
|
694 convert=EFalse; |
|
695 } |
|
696 |
|
697 } |
|
698 if (item->iHidden != EVisibilityHidden) |
|
699 { |
|
700 HBufC* hBuf = item->ListItemTextL(convert); |
|
701 CleanupStack::PushL(hBuf); |
|
702 |
|
703 arr->AppendL(hBuf->Des()); |
|
704 |
|
705 // store listbox index (from zero up) into setting item |
|
706 item->iIndex = arr->Count() - 1; |
|
707 |
|
708 CleanupStack::PopAndDestroy(hBuf); |
|
709 } |
|
710 else |
|
711 { |
|
712 item->iIndex = KErrNotFound; |
|
713 } |
|
714 } |
|
715 |
|
716 aListBox->HandleItemAdditionL(); |
|
717 } |
|
718 |
|
719 |
|
720 // ---------------------------------------------------------------------------- |
|
721 // CAspContentDialog::CreateSettingsListL |
|
722 // |
|
723 // ---------------------------------------------------------------------------- |
|
724 // |
|
725 void CAspContentDialog::CreateSettingsListL() |
|
726 { |
|
727 AddItemL(EAspLocalDatabase, R_ASP_SETT_LOCAL_DATABASE); |
|
728 AddRemoteDatabaseL(iDataProviderId); |
|
729 |
|
730 // write setting data into each CAspListItemData |
|
731 TInt count = iSettingList->Count(); |
|
732 for (TInt i=0; i<count; i++) |
|
733 { |
|
734 InitSettingItemL((*iSettingList)[i]); |
|
735 } |
|
736 |
|
737 SetVisibility(); |
|
738 } |
|
739 |
|
740 |
|
741 // ---------------------------------------------------------------------------- |
|
742 // CAspContentDialog::AddItemL |
|
743 // |
|
744 // ---------------------------------------------------------------------------- |
|
745 // |
|
746 void CAspContentDialog::AddItemL(TInt aItemId, TInt aResourceId) |
|
747 { |
|
748 CAspListItemData* item = CAspListItemData::NewLC(); |
|
749 item->SetHeaderL(aResourceId); |
|
750 item->iItemId = aItemId; |
|
751 iSettingList->AppendL(item); |
|
752 CleanupStack::Pop(item); |
|
753 } |
|
754 |
|
755 |
|
756 // ---------------------------------------------------------------------------- |
|
757 // CAspContentDialog::AddRemoteDatabaseL |
|
758 // |
|
759 // ---------------------------------------------------------------------------- |
|
760 // |
|
761 void CAspContentDialog::AddRemoteDatabaseL(TInt aDataProviderId) |
|
762 { |
|
763 CAspListItemData* item = CAspListItemData::NewLC(); |
|
764 TInt resId = CAspResHandler::RemoteDatabaseHeaderId(aDataProviderId); |
|
765 item->SetHeaderL(resId); |
|
766 item->iItemId = EAspRemoteDatabase; |
|
767 iSettingList->AppendL(item); |
|
768 CleanupStack::Pop(item); |
|
769 } |
|
770 |
|
771 |
|
772 // ----------------------------------------------------------------------------- |
|
773 // CAspContentDialog::SetVisibility |
|
774 // |
|
775 // ----------------------------------------------------------------------------- |
|
776 // |
|
777 void CAspContentDialog::SetVisibility() |
|
778 { |
|
779 TBool isPCSuite = CAspProfile::IsPCSuiteProfile(iProfile); |
|
780 TBool readOnly = iProfile->DeleteAllowed(); |
|
781 |
|
782 Item(EAspLocalDatabase)->iHidden = EVisibilityNormal; |
|
783 if (iLocalDataStores->Count() < 2) |
|
784 { |
|
785 if (iDialogParam->iDataProviderId != KUidNSmlAdapterEMail.iUid) |
|
786 { |
|
787 Item(EAspLocalDatabase)->iHidden = EVisibilityHidden; |
|
788 } |
|
789 } |
|
790 |
|
791 if (isPCSuite) |
|
792 { |
|
793 if (Item(EAspLocalDatabase)->iHidden == EVisibilityNormal) |
|
794 { |
|
795 if (iDialogParam->iDataProviderId != KUidNSmlAdapterEMail.iUid) |
|
796 { |
|
797 Item(EAspLocalDatabase)->iHidden = EVisibilityReadOnly; |
|
798 } |
|
799 } |
|
800 |
|
801 TInt provider = DataProviderType(); |
|
802 if (provider != KErrNotFound) |
|
803 { |
|
804 Item(EAspRemoteDatabase)->iHidden = EVisibilityReadOnly; |
|
805 } |
|
806 } |
|
807 |
|
808 if(!readOnly) |
|
809 { |
|
810 TInt provider = DataProviderType(); |
|
811 if (provider != KErrNotFound) |
|
812 { |
|
813 Item(EAspRemoteDatabase)->iHidden = EVisibilityReadOnly; |
|
814 } |
|
815 } |
|
816 |
|
817 if (iSettingEnforcement) |
|
818 { |
|
819 SetAllReadOnly(); // profile database is locked |
|
820 } |
|
821 } |
|
822 |
|
823 |
|
824 // ----------------------------------------------------------------------------- |
|
825 // CAspContentDialog::SetAllReadOnly |
|
826 // |
|
827 // ----------------------------------------------------------------------------- |
|
828 // |
|
829 void CAspContentDialog::SetAllReadOnly() |
|
830 { |
|
831 TInt count = iSettingList->Count(); |
|
832 |
|
833 for (TInt i=0; i<count; i++ ) |
|
834 { |
|
835 CAspListItemData* item = (*iSettingList)[i]; |
|
836 if (item->iHidden != EVisibilityHidden) |
|
837 { |
|
838 item->iHidden = EVisibilityReadOnly; |
|
839 } |
|
840 } |
|
841 } |
|
842 |
|
843 |
|
844 // ----------------------------------------------------------------------------- |
|
845 // CAspContentDialog::InitSettingItemL |
|
846 // |
|
847 // Constructs CAspListItemData for one setting. |
|
848 // ----------------------------------------------------------------------------- |
|
849 // |
|
850 void CAspContentDialog::InitSettingItemL(CAspListItemData* aItem) |
|
851 { |
|
852 iBuf = KNullDesC; // reset common buffer |
|
853 |
|
854 switch (aItem->iItemId) |
|
855 { |
|
856 case EAspLocalDatabase: |
|
857 { |
|
858 aItem->SetValueL(iLocalDatabase); |
|
859 aItem->SetDisplayValueL(R_ASP_SETTING_VALUE_NONE); |
|
860 |
|
861 aItem->iMaxLength = KAspMaxLocalNameLength; |
|
862 aItem->iLatinInput = ETrue; |
|
863 aItem->iItemType = CAspListItemData::ETypeLocalDatabase; |
|
864 break; |
|
865 } |
|
866 |
|
867 case EAspRemoteDatabase: |
|
868 { |
|
869 aItem->SetValueL(iRemoteDatabase); |
|
870 aItem->SetDisplayValueL(R_ASP_MUST_BE_DEFINED); |
|
871 |
|
872 aItem->iMaxLength = KAspMaxRemoteNameLength; |
|
873 aItem->iLatinInput = ETrue; |
|
874 aItem->iMandatory = ETrue; |
|
875 aItem->iItemType = CAspListItemData::ETypeText; |
|
876 break; |
|
877 } |
|
878 |
|
879 default: |
|
880 break; |
|
881 } |
|
882 } |
|
883 |
|
884 |
|
885 //------------------------------------------------------------------------------ |
|
886 // CAspContentDialog::SaveSettingsL |
|
887 // |
|
888 // Save content settings. |
|
889 //------------------------------------------------------------------------------ |
|
890 // |
|
891 void CAspContentDialog::SaveSettingsL() |
|
892 { |
|
893 if (iSettingEnforcement) |
|
894 { |
|
895 return; |
|
896 } |
|
897 |
|
898 TBool localDatabaseChanged = EFalse; |
|
899 TBool remoteDatabaseChanged = EFalse; |
|
900 |
|
901 TPtrC ptr1 = Item(EAspLocalDatabase)->Value(); |
|
902 if (ptr1.Compare(iLocalDatabase) != 0) |
|
903 { |
|
904 localDatabaseChanged = ETrue; |
|
905 } |
|
906 |
|
907 TPtrC ptr2 = Item(EAspRemoteDatabase)->Value(); |
|
908 if (ptr2.Compare(iRemoteDatabase) != 0) |
|
909 { |
|
910 remoteDatabaseChanged = ETrue; |
|
911 } |
|
912 |
|
913 if (remoteDatabaseChanged || localDatabaseChanged || iDataStoreChanged) |
|
914 { |
|
915 iLocalDatabase = Item(EAspLocalDatabase)->Value(); |
|
916 iRemoteDatabase = Item(EAspRemoteDatabase)->Value(); |
|
917 |
|
918 iContentList->CreateTaskL(iDataProviderId, iLocalDatabase, iRemoteDatabase, |
|
919 iTaskEnabled, iSyncDirection); |
|
920 |
|
921 iContentList->InitAllTasksL(); // iContentList comes from main view |
|
922 } |
|
923 |
|
924 #ifdef RD_DSUI_TIMEDSYNC |
|
925 CAspSchedule* schedule = CAspSchedule::NewLC(); |
|
926 TInt profileId = schedule->ProfileId(); |
|
927 if (profileId == iProfile->ProfileId()) |
|
928 { |
|
929 schedule->UpdateProfileSettingsL(); |
|
930 } |
|
931 CleanupStack::PopAndDestroy(schedule); |
|
932 #endif |
|
933 } |
|
934 |
|
935 |
|
936 //------------------------------------------------------------------------------ |
|
937 // CAspContentDialog::CheckMandatoryFields |
|
938 // |
|
939 // Check that mandatory fields are filled correctly. |
|
940 //------------------------------------------------------------------------------ |
|
941 // |
|
942 TInt CAspContentDialog::CheckMandatoryFields() |
|
943 { |
|
944 if (iSettingEnforcement) |
|
945 { |
|
946 return KErrNotFound; |
|
947 } |
|
948 |
|
949 if (!iContentList->TaskEnabled(iDataProviderId)) |
|
950 { |
|
951 return KErrNotFound; // not part of sync - no need to check mandatory |
|
952 } |
|
953 |
|
954 TInt count = iSettingList->Count(); |
|
955 for (TInt i=0; i<count; i++) |
|
956 { |
|
957 CAspListItemData* item = (*iSettingList)[i]; |
|
958 if (item->iMandatory && item->IsEmpty() && (item->iHidden == EVisibilityNormal)) |
|
959 { |
|
960 return item->iIndex; |
|
961 } |
|
962 } |
|
963 |
|
964 return KErrNotFound; |
|
965 } |
|
966 |
|
967 |
|
968 //------------------------------------------------------------------------------ |
|
969 // CAspContentDialog::EditSettingItemL |
|
970 // |
|
971 // Calls setting editing functions. |
|
972 //------------------------------------------------------------------------------ |
|
973 // |
|
974 TBool CAspContentDialog::EditSettingItemL(CAspListItemData& aItem) |
|
975 { |
|
976 TBool ret = EFalse; |
|
977 |
|
978 switch (aItem.iItemType) |
|
979 { |
|
980 case CAspListItemData::ETypeText: |
|
981 ret = EditSettingItemTextL(aItem); |
|
982 break; |
|
983 |
|
984 case CAspListItemData::ETypeList: |
|
985 ret = EditSettingItemListL(aItem); |
|
986 break; |
|
987 |
|
988 case CAspListItemData::ETypeLocalDatabase: |
|
989 ret = EditSettingItemLocalDatabaseL(aItem); |
|
990 break; |
|
991 |
|
992 default: |
|
993 break; |
|
994 |
|
995 } |
|
996 |
|
997 return ret; |
|
998 } |
|
999 |
|
1000 |
|
1001 //------------------------------------------------------------------------------ |
|
1002 // CAspContentDialog::EditSettingItemListL |
|
1003 // |
|
1004 //------------------------------------------------------------------------------ |
|
1005 // |
|
1006 TBool CAspContentDialog::EditSettingItemListL(CAspListItemData& aItem) |
|
1007 { |
|
1008 TInt curSelection = aItem.iNumberData; |
|
1009 CDesCArray* arr = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource); |
|
1010 |
|
1011 TBool ret = TDialogUtil::ShowListEditorL(arr, aItem.Header(), curSelection); |
|
1012 if (ret) |
|
1013 { |
|
1014 aItem.iNumberData = curSelection; |
|
1015 aItem.SetValueL((*arr)[curSelection]); |
|
1016 } |
|
1017 |
|
1018 CleanupStack::PopAndDestroy(arr); |
|
1019 return ret; |
|
1020 } |
|
1021 |
|
1022 |
|
1023 //------------------------------------------------------------------------------ |
|
1024 // CAspContentDialog::EditSettingItemTextL |
|
1025 // |
|
1026 // Edit text setting item. |
|
1027 //------------------------------------------------------------------------------ |
|
1028 // |
|
1029 TBool CAspContentDialog::EditSettingItemTextL(CAspListItemData& aItem) |
|
1030 { |
|
1031 TUtil::StrCopy(iBuf, aItem.Value()); |
|
1032 |
|
1033 TBool ret = TDialogUtil::ShowTextEditorL(iBuf, aItem.Header(), |
|
1034 aItem.iMandatory, aItem.iLatinInput, aItem.iMaxLength); |
|
1035 if (ret) |
|
1036 { |
|
1037 aItem.SetValueL(iBuf); |
|
1038 } |
|
1039 |
|
1040 return ret; |
|
1041 } |
|
1042 |
|
1043 |
|
1044 //------------------------------------------------------------------------------ |
|
1045 // CAspContentDialog::EditSettingItemLocalDatabaseL |
|
1046 // |
|
1047 //------------------------------------------------------------------------------ |
|
1048 // |
|
1049 TBool CAspContentDialog::EditSettingItemLocalDatabaseL(CAspListItemData& aItem) |
|
1050 { |
|
1051 if (iLocalDataStores->Count() < 1) |
|
1052 { |
|
1053 if (iDataProviderId == KUidNSmlAdapterEMail.iUid) |
|
1054 { |
|
1055 TDialogUtil::ShowErrorNoteL(R_ASP_NO_MAILBOXES); |
|
1056 } |
|
1057 |
|
1058 return EFalse; |
|
1059 } |
|
1060 |
|
1061 TInt curSelection = 0; |
|
1062 TInt countDatabase = iLocalDataStores->Count(); |
|
1063 |
|
1064 while (iLocalDataStores->Find(iLocalDatabase, curSelection) && (curSelection < countDatabase)) |
|
1065 { |
|
1066 curSelection++; |
|
1067 } |
|
1068 if (TDialogUtil::ShowListEditorL(iLocalDataStores, aItem.Header(), curSelection)) |
|
1069 { |
|
1070 aItem.SetValueL((*iLocalDataStores)[curSelection]); |
|
1071 return ETrue; |
|
1072 } |
|
1073 |
|
1074 return EFalse; |
|
1075 } |
|
1076 |
|
1077 |
|
1078 //------------------------------------------------------------------------------ |
|
1079 // CAspContentDialog::EditSettingItemYesNoL |
|
1080 // |
|
1081 // Change Yes/No value straight if ok key is pressed. |
|
1082 //------------------------------------------------------------------------------ |
|
1083 // |
|
1084 TBool CAspContentDialog::EditSettingItemYesNoL(CAspListItemData& aItem) |
|
1085 { |
|
1086 CDesCArray* arr = CAspResHandler::ReadDesArrayStaticLC(aItem.iResource); |
|
1087 |
|
1088 if (aItem.iNumberData == EAspSettingDisabled) |
|
1089 { |
|
1090 aItem.iNumberData = EAspSettingEnabled; |
|
1091 } |
|
1092 else |
|
1093 { |
|
1094 aItem.iNumberData = EAspSettingDisabled; |
|
1095 } |
|
1096 |
|
1097 |
|
1098 // store localized setting text (Yes/No) |
|
1099 aItem.SetValueL( (*arr)[aItem.iNumberData] ); |
|
1100 |
|
1101 CleanupStack::PopAndDestroy(arr); |
|
1102 return ETrue; |
|
1103 } |
|
1104 |
|
1105 |
|
1106 //----------------------------------------------------------------------------- |
|
1107 // CAspContentDialog::GetItemForIndex |
|
1108 // |
|
1109 // Find item in list position aIndex. |
|
1110 //----------------------------------------------------------------------------- |
|
1111 // |
|
1112 CAspListItemData* CAspContentDialog::GetItemForIndex(TInt aIndex) |
|
1113 { |
|
1114 CAspListItemData* item = NULL; |
|
1115 |
|
1116 TInt count = iSettingList->Count(); |
|
1117 for (TInt i=0; i<count; i++) |
|
1118 { |
|
1119 CAspListItemData* temp = (*iSettingList)[i]; |
|
1120 if (temp->iIndex == aIndex) |
|
1121 { |
|
1122 item = temp; |
|
1123 break; |
|
1124 } |
|
1125 } |
|
1126 |
|
1127 __ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral)); |
|
1128 |
|
1129 return item; |
|
1130 } |
|
1131 |
|
1132 |
|
1133 //----------------------------------------------------------------------------- |
|
1134 // CAspContentDialog::Item |
|
1135 // |
|
1136 // Find item with aItemId (TAspConnectionSettingItem). |
|
1137 //----------------------------------------------------------------------------- |
|
1138 // |
|
1139 CAspListItemData* CAspContentDialog::Item(TInt aItemId) |
|
1140 { |
|
1141 CAspListItemData* item = NULL; |
|
1142 |
|
1143 TInt count = iSettingList->Count(); |
|
1144 for (TInt i=0; i<count; i++) |
|
1145 { |
|
1146 CAspListItemData* temp = (*iSettingList)[i]; |
|
1147 if (temp->iItemId == aItemId) |
|
1148 { |
|
1149 item = temp; |
|
1150 break; |
|
1151 } |
|
1152 } |
|
1153 |
|
1154 __ASSERT_ALWAYS(item, TUtil::Panic(KErrGeneral)); |
|
1155 |
|
1156 return item; |
|
1157 } |
|
1158 |
|
1159 |
|
1160 // ----------------------------------------------------------------------------- |
|
1161 // CAspContentDialog::DataProviderType |
|
1162 // |
|
1163 // ----------------------------------------------------------------------------- |
|
1164 // |
|
1165 TInt CAspContentDialog::DataProviderType() const |
|
1166 { |
|
1167 if (iDialogParam->iDataProviderId == KUidNSmlAdapterContact.iUid) |
|
1168 { |
|
1169 return EApplicationIdContact; |
|
1170 } |
|
1171 if (iDialogParam->iDataProviderId == KUidNSmlAdapterCalendar.iUid) |
|
1172 { |
|
1173 return EApplicationIdCalendar; |
|
1174 } |
|
1175 if (iDialogParam->iDataProviderId == KUidNSmlAdapterEMail.iUid) |
|
1176 { |
|
1177 return EApplicationIdEmail; |
|
1178 } |
|
1179 if (iDialogParam->iDataProviderId == KUidNSmlAdapterNote.iUid) |
|
1180 { |
|
1181 return EApplicationIdNote; |
|
1182 } |
|
1183 if (iDialogParam->iDataProviderId == KUidNSmlAdapterSms.iUid) |
|
1184 { |
|
1185 return EApplicationIdSms; |
|
1186 } |
|
1187 if (iDialogParam->iDataProviderId == KUidNSmlAdapterMMS.iUid) |
|
1188 { |
|
1189 return EApplicationIdMms; |
|
1190 } |
|
1191 if (iDialogParam->iDataProviderId == KUidNSmlAdapterBookmarks.iUid) |
|
1192 { |
|
1193 return EApplicationIdBookmarks; |
|
1194 } |
|
1195 |
|
1196 return KErrNotFound; |
|
1197 } |
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 // End of file |
|
1203 |