|
1 /* |
|
2 * Copyright (c) 2007 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: Calendar settings container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //debug |
|
20 #include "calendarui_debug.h" |
|
21 |
|
22 // INCLUDES |
|
23 #include "calensettingsuicontainer.h" |
|
24 |
|
25 #include "CalenFileListSettingItem.h" |
|
26 #include "calenglobaldata.h" |
|
27 #include "CalenInterimUtils2.h" |
|
28 #include "CalenSliderSettingItem.h" |
|
29 #include "CalenUid.h" |
|
30 #include "RImplInfoPtrArrayOwn.inl" |
|
31 #include "CleanupResetAndDestroy.h" |
|
32 #include "calencheckboxsettingitem.h" |
|
33 #include "calennestedsettingitem.h" |
|
34 #include "calenbooleansettingitem.h" |
|
35 #include "calenviewinfo.h" |
|
36 |
|
37 #include <Calendar.rsg> |
|
38 #include <csxhelp/cale.hlp.hrh> |
|
39 #include "calencustomisationmanager.h" |
|
40 //#include <CalenUiPluginInterface.h> |
|
41 |
|
42 #include <utf.h> |
|
43 #include <aknlists.h> // for CAknSettingStyleListBox |
|
44 #include <eikclbd.h> // CColumnListBoxData |
|
45 #include <StringLoader.h> |
|
46 #include <bacntf.h> // CEnvironmentChangeNotifier |
|
47 #include <centralrepository.h> // CRepository |
|
48 #include <CalendarInternalCRKeys.h> // KCRUidCalendar |
|
49 |
|
50 |
|
51 #ifdef RD_CALEN_EXTERNAL_CAL |
|
52 #include <aiwservicehandler.h> |
|
53 |
|
54 // MIME types |
|
55 _LIT8(KContentTypeCalendar, "text/calendar"); |
|
56 |
|
57 #endif //RD_CALEN_EXTERNAL_CAL |
|
58 |
|
59 |
|
60 #include <AknUtils.h> |
|
61 |
|
62 |
|
63 |
|
64 const TInt KDisablePluginEnablement = 2; |
|
65 |
|
66 void ListMailboxesL( |
|
67 CMRMailboxUtils& aMbUtils, |
|
68 RArray<CMRMailboxUtils::TMailboxInfo>& aMailBoxes ) |
|
69 { |
|
70 aMbUtils.ListMailBoxesL( aMailBoxes ); |
|
71 |
|
72 // Get MR Viewer implementations |
|
73 RImplInfoPtrArrayOwn implArray; |
|
74 CleanupClosePushL( implArray ); |
|
75 const TUid mrViewersIface = {KMRViewersInterfaceUID}; |
|
76 REComSession::ListImplementationsL( mrViewersIface, implArray ); |
|
77 TBuf16<KMaxUidName> mbName; |
|
78 |
|
79 TInt index(0); |
|
80 while (index < aMailBoxes.Count() ) |
|
81 { |
|
82 TBool matchingMRViewerFound( EFalse ); |
|
83 TInt mrviewerImplCount( implArray.Count() ); |
|
84 for( TInt j=0; j < mrviewerImplCount && !matchingMRViewerFound; ++j ) |
|
85 { |
|
86 CnvUtfConverter::ConvertToUnicodeFromUtf8( mbName, implArray[j]->DataType() ); |
|
87 if( aMailBoxes[index].iMtmUid.Name().CompareF(mbName) == 0 ) |
|
88 { |
|
89 // Found a match. This mailbox would have been shown in the settings list. |
|
90 matchingMRViewerFound = ETrue; |
|
91 } |
|
92 } |
|
93 |
|
94 if ( !matchingMRViewerFound ) |
|
95 { |
|
96 aMailBoxes.Remove( index ); |
|
97 } |
|
98 else |
|
99 { |
|
100 ++index; |
|
101 } |
|
102 } |
|
103 CleanupStack::PopAndDestroy(); // implArray |
|
104 } |
|
105 |
|
106 // ========================= MEMBER FUNCTIONS ================================ |
|
107 |
|
108 |
|
109 // ---------------------------------------------------------------------------- |
|
110 // CCalenSettingsUiContainer::NewL |
|
111 // Symbian two-phased constructor. |
|
112 // Two-phased constructor. Does NOT take ownership of aParentControl or aListBox. |
|
113 // (other items were commented in a header). |
|
114 // ---------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C CCalenSettingsUiContainer* CCalenSettingsUiContainer::NewL( |
|
117 CCoeControl* aParentControl, |
|
118 CAknSettingStyleListBox& aListBox, |
|
119 CCalenGlobalData& aGlobalData, |
|
120 CCalenCustomisationManager& aCustomisationManager ) |
|
121 { |
|
122 TRACE_ENTRY_POINT; |
|
123 |
|
124 CCalenSettingsUiContainer* self = new(ELeave) CCalenSettingsUiContainer( aParentControl, |
|
125 aListBox, |
|
126 aGlobalData, |
|
127 aCustomisationManager ); |
|
128 CleanupStack::PushL( self ); |
|
129 self->ConstructL(); |
|
130 CleanupStack::Pop( self ); |
|
131 |
|
132 TRACE_EXIT_POINT; |
|
133 return self; |
|
134 } |
|
135 |
|
136 // ---------------------------------------------------------------------------- |
|
137 // CCalenSettingsUiContainer::ConstructL |
|
138 // Symbian OS default constructor |
|
139 // ---------------------------------------------------------------------------- |
|
140 // |
|
141 void CCalenSettingsUiContainer::ConstructL() |
|
142 { |
|
143 TRACE_ENTRY_POINT; |
|
144 |
|
145 iSetting = CCalenSetting::InstanceL(); |
|
146 |
|
147 // Initialize TLocale watcher |
|
148 TCallBack callback( LocaleCallbackL, this ); |
|
149 iLocaleChangeNotifier = |
|
150 CEnvironmentChangeNotifier::NewL( EActivePriorityLogonA, callback ); |
|
151 |
|
152 // Initialize Central Repository watcher |
|
153 iRepository = CRepository::NewL( KCRUidCalendar ); |
|
154 iCenRepNotifyHandler = CCenRepNotifyHandler::NewL( *this, *iRepository ); |
|
155 |
|
156 iSettingItemArray = new( ELeave )CAknSettingItemArray( 2, 0, 0 ); |
|
157 |
|
158 if( iGlobalData.InterimUtilsL().MRViewersEnabledL() ) |
|
159 { |
|
160 LoadMailboxSettingsL(); |
|
161 } |
|
162 |
|
163 iLocaleChangeNotifier->Start(); |
|
164 iCenRepNotifyHandler->StartListeningL(); |
|
165 |
|
166 iPageStatus = EFalse; |
|
167 TRACE_EXIT_POINT; |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------------------------------- |
|
171 // CCalenSettingsUiContainer::~CCalenSettingsUiContainer |
|
172 // Destructor |
|
173 // ---------------------------------------------------------------------------- |
|
174 // |
|
175 CCalenSettingsUiContainer::~CCalenSettingsUiContainer() |
|
176 { |
|
177 TRACE_ENTRY_POINT; |
|
178 |
|
179 delete iLocaleChangeNotifier; |
|
180 if( iCenRepNotifyHandler ) |
|
181 { |
|
182 iCenRepNotifyHandler->StopListening(); |
|
183 delete iCenRepNotifyHandler; |
|
184 } |
|
185 |
|
186 delete iRepository; |
|
187 |
|
188 iMailBoxes.Close(); |
|
189 if( iSettingItemArray ) |
|
190 { |
|
191 iSettingItemArray->ResetAndDestroy(); |
|
192 delete iSettingItemArray; |
|
193 } |
|
194 |
|
195 if ( iSetting ) |
|
196 { |
|
197 iSetting->Release(); |
|
198 } |
|
199 |
|
200 #ifdef RD_CALEN_EXTERNAL_CAL |
|
201 delete iServiceHandler; |
|
202 #endif //RD_CALEN_EXTERNAL_CAL |
|
203 |
|
204 TRACE_EXIT_POINT; |
|
205 } |
|
206 |
|
207 // ---------------------------------------------------------------------------- |
|
208 // CCalenSettingsUiContainer::CCalenSettingsUiContainer |
|
209 // Default constructor |
|
210 // ---------------------------------------------------------------------------- |
|
211 // |
|
212 CCalenSettingsUiContainer::CCalenSettingsUiContainer( CCoeControl* aParentControl, |
|
213 CAknSettingStyleListBox& aListBox, |
|
214 CCalenGlobalData& aGlobalData, |
|
215 CCalenCustomisationManager& aCustomisationManager ) |
|
216 : iGlobalData( aGlobalData ), |
|
217 iParentControl( aParentControl ), |
|
218 iListBox( aListBox ), |
|
219 iCustomisationManager( aCustomisationManager ), |
|
220 iIgnoreNextSettingsNotification( EFalse ), |
|
221 iIgnoreFirstLocaleChange( ETrue ) |
|
222 { |
|
223 TRACE_ENTRY_POINT; |
|
224 TRACE_EXIT_POINT; |
|
225 } |
|
226 |
|
227 // ---------------------------------------------------------------------------- |
|
228 // CCalenSettingsUiContainer::AddCustomSettingsWithLinkL |
|
229 // Adds all settings from customisations. This will get a link from the front |
|
230 // settings page. Removes items from the array when ownership transferred |
|
231 // away from the array. |
|
232 // ---------------------------------------------------------------------------- |
|
233 // |
|
234 void CCalenSettingsUiContainer::AddCustomSettingsWithLinkL( RPointerArray<CAknSettingItem>& aSettings, |
|
235 const TDesC& aName, |
|
236 TInt aOrdinal ) |
|
237 { |
|
238 TRACE_ENTRY_POINT; |
|
239 |
|
240 // CCalenNestedSettingItem will take items out of aSettings array and |
|
241 // take ownership of removed items. |
|
242 CCalenNestedSettingItem* item = new( ELeave )CCalenNestedSettingItem( 0, |
|
243 aSettings, |
|
244 aName ); |
|
245 CleanupStack::PushL( item ); |
|
246 |
|
247 // The followng text should never actually be displayed on screen |
|
248 item->SetEmptyItemTextL( KNullDesC ); |
|
249 |
|
250 // Construct setting item with parametrized values |
|
251 item->ConstructL( EFalse, aOrdinal, aName, NULL, |
|
252 R_CALEN_EMPTY_SETTING_PAGE, EAknSetListBox, |
|
253 NULL, R_CALEN_EMPTY_POPUP_SETTING_TEXTS ); |
|
254 |
|
255 iSettingItemArray->InsertL( aOrdinal, item ); |
|
256 |
|
257 CleanupStack::Pop( item ); |
|
258 |
|
259 TRACE_EXIT_POINT; |
|
260 } |
|
261 |
|
262 // ---------------------------------------------------------------------------- |
|
263 // CCalenSettingsUiContainer::AddSingleCustomSettingL |
|
264 // Adds a setting from customisations. This will go directly into the front |
|
265 // settings page. Takes ownership of aSetting when the function completes. |
|
266 // ---------------------------------------------------------------------------- |
|
267 // |
|
268 void CCalenSettingsUiContainer::AddSingleCustomSettingL( CAknSettingItem* aSetting, |
|
269 TInt aOrdinal ) |
|
270 { |
|
271 TRACE_ENTRY_POINT; |
|
272 |
|
273 iSettingItemArray->InsertL( aOrdinal, aSetting ); // Takes ownership of aSetting. |
|
274 |
|
275 TRACE_EXIT_POINT; |
|
276 } |
|
277 |
|
278 // ---------------------------------------------------------------------------- |
|
279 // CCalenSettingsUiContainer::AddCustomSettingsItemsL |
|
280 // Adds all settings from customisations. |
|
281 // ---------------------------------------------------------------------------- |
|
282 // |
|
283 void CCalenSettingsUiContainer::AddCustomSettingsItemsL( TInt& aOrdinal ) |
|
284 { |
|
285 TRACE_ENTRY_POINT; |
|
286 |
|
287 const RArray<TUid>& plugins = iCustomisationManager.ActivePlugins(); |
|
288 |
|
289 RPointerArray<CAknSettingItem> settings; |
|
290 CleanupResetAndDestroyPushL( settings ); |
|
291 |
|
292 for ( TInt i( 0 ); i<plugins.Count(); ++i ) |
|
293 { |
|
294 iCustomisationManager.GetPluginSettingsL( plugins[i], |
|
295 settings ); |
|
296 // We have ownership of settings items now. |
|
297 |
|
298 // If there is more than one setting per plugin, it gets a link in the main |
|
299 // setting page. If there is only one, it goes directly into the main page. |
|
300 if ( settings.Count() > 1 ) |
|
301 { |
|
302 const RImplInfoPtrArray& pluginInfo = iCustomisationManager.PluginInfoArray(); |
|
303 TInt pluginIndex = KErrNotFound; |
|
304 |
|
305 for ( TInt j( 0 ); j<pluginInfo.Count(); ++j ) |
|
306 { |
|
307 if ( pluginInfo[j]->ImplementationUid() == plugins[i] ) |
|
308 { |
|
309 pluginIndex = j; |
|
310 break; |
|
311 } |
|
312 } |
|
313 |
|
314 ASSERT( pluginIndex != KErrNotFound ); |
|
315 const TDesC& pluginName = pluginInfo[pluginIndex]->DisplayName(); |
|
316 |
|
317 AddCustomSettingsWithLinkL( settings, pluginName, aOrdinal++ ); |
|
318 } |
|
319 else if ( settings.Count() == 1 ) |
|
320 { |
|
321 // This function takes ownership of the setting item we pass it, |
|
322 // when the function completes. |
|
323 AddSingleCustomSettingL( settings[0], aOrdinal++ ); |
|
324 settings.Remove( 0 ); |
|
325 } |
|
326 |
|
327 ASSERT( settings.Count() == 0 ); |
|
328 } |
|
329 |
|
330 CleanupStack::PopAndDestroy( &settings ); |
|
331 |
|
332 TRACE_EXIT_POINT; |
|
333 } |
|
334 |
|
335 // ---------------------------------------------------------------------------- |
|
336 // CCalenSettingsUiContainer::AddPluginSettingItemL |
|
337 // Adds a settings item allowing the user to enable/disable plugins and |
|
338 // change their priority. |
|
339 // ---------------------------------------------------------------------------- |
|
340 // |
|
341 void CCalenSettingsUiContainer::AddPluginSettingItemL( TInt& aOrdinal ) |
|
342 { |
|
343 TRACE_ENTRY_POINT; |
|
344 |
|
345 const RImplInfoPtrArray& plugins = iCustomisationManager.PluginInfoArray(); |
|
346 TInt pluginCount = plugins.Count(); |
|
347 |
|
348 if ( pluginCount > 0 ) |
|
349 { |
|
350 // Check to see if any of the plugins are able to be be enable or |
|
351 // disabled |
|
352 TBool pluginFound( EFalse ); |
|
353 TBuf<100> displayName; |
|
354 for ( TInt index(0); index < pluginCount && !pluginFound; ++index ) |
|
355 { |
|
356 // if the display name is empty and the plugin is in ROM the |
|
357 // plugin can not be disabled |
|
358 TInt version = plugins[index]->Version(); |
|
359 TBool romBased = plugins[index]->RomBased(); |
|
360 displayName = plugins[index]->DisplayName(); |
|
361 |
|
362 if ( ( version != KDisablePluginEnablement ) || !romBased ) |
|
363 { |
|
364 pluginFound = ETrue; |
|
365 } |
|
366 } |
|
367 |
|
368 |
|
369 |
|
370 if ( pluginFound ) |
|
371 { |
|
372 //There will not be any sort of settings item for plugins which are not part of settings |
|
373 TInt countOfAvailability = iSetting->PluginAvailability().Count(); |
|
374 |
|
375 if(countOfAvailability) |
|
376 { |
|
377 //If available plugins(which has settings) count is > 1 its check box or toggle button. |
|
378 if(countOfAvailability > 1 ) |
|
379 { |
|
380 CCalenCheckboxSettingItem* settingItem |
|
381 = new( ELeave )CCalenCheckboxSettingItem( ECalenPluginListItemId, |
|
382 iCustomisationManager ); |
|
383 |
|
384 CleanupStack::PushL( settingItem ); |
|
385 |
|
386 // The followng text should never actually be displayed on screen |
|
387 settingItem->SetEmptyItemTextL( KNullDesC ); |
|
388 |
|
389 |
|
390 // Construct setting item with parametrized values |
|
391 HBufC* itemTitle = StringLoader::LoadLC( R_CALEN_SETTING_PLUGINLIST_TITLE ); |
|
392 settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, |
|
393 R_CALEN_SETTING_PLUGINLIST, EAknSetListBox, |
|
394 NULL, R_CALEN_EMPTY_POPUP_SETTING_TEXTS ); |
|
395 |
|
396 iSettingItemArray->InsertL( aOrdinal, settingItem ); |
|
397 |
|
398 CleanupStack::PopAndDestroy( itemTitle ); |
|
399 CleanupStack::Pop( settingItem ); |
|
400 aOrdinal++; |
|
401 } |
|
402 else |
|
403 { |
|
404 CCalenBooleanSettingItem* settingItem = |
|
405 CCalenBooleanSettingItem::NewLC(ECalenPluginListItemId,aOrdinal,iCustomisationManager); |
|
406 iSettingItemArray->InsertL( aOrdinal, settingItem ); |
|
407 CleanupStack::Pop( settingItem ); |
|
408 aOrdinal++; |
|
409 } |
|
410 } |
|
411 } |
|
412 } |
|
413 |
|
414 TRACE_EXIT_POINT; |
|
415 } |
|
416 |
|
417 // ---------------------------------------------------------------------------- |
|
418 // CCalenSettingsUiContainer::AddDefaultViewItemL |
|
419 // Adds a setting item to allow selection of the default view. Includes custom |
|
420 // views in the view cycle array. |
|
421 // (other items were commented in a header). |
|
422 // ---------------------------------------------------------------------------- |
|
423 // |
|
424 void CCalenSettingsUiContainer::AddDefaultViewItemL( TInt& aBuffer, |
|
425 TInt aId, |
|
426 TInt aTitleResource, |
|
427 TInt aSettingPageResource, |
|
428 TInt aOrdinal ) |
|
429 { |
|
430 TRACE_ENTRY_POINT; |
|
431 |
|
432 // Create new setting item |
|
433 CAknEnumeratedTextPopupSettingItem* settingItem = |
|
434 new( ELeave )CAknEnumeratedTextPopupSettingItem( aId, aBuffer ); |
|
435 CleanupStack::PushL( settingItem ); |
|
436 |
|
437 // The followng text should never actually be displayed on screen |
|
438 _LIT( KNone, "None" ); |
|
439 settingItem->SetEmptyItemTextL( KNone ); |
|
440 |
|
441 // Construct setting item with parametrized values |
|
442 HBufC* itemTitle = StringLoader::LoadLC( aTitleResource ); |
|
443 settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, |
|
444 aSettingPageResource, EAknCtPopupSettingList, |
|
445 NULL, R_CALEN_EMPTY_POPUP_SETTING_TEXTS ); |
|
446 |
|
447 CArrayPtr<CAknEnumeratedText>* items = settingItem->EnumeratedTextArray(); |
|
448 |
|
449 const RPointerArray<CCalenViewInfo>& views = iCustomisationManager.Views(); |
|
450 const RArray<TUid>& activePlugins = iCustomisationManager.ActivePlugins(); |
|
451 |
|
452 TBool isDefViewValid( EFalse ); |
|
453 |
|
454 TInt numViews = views.Count(); |
|
455 for ( TInt i( 0 ); i<numViews; ++i ) |
|
456 { |
|
457 CCalenViewInfo* view = views[i]; |
|
458 TUid pluginUid = view->PluginUid(); |
|
459 TInt position = activePlugins.Find( pluginUid ); |
|
460 |
|
461 // If the view is from plugin or native view with cycle position, |
|
462 // then add it to the default view list |
|
463 if((position != KErrNotFound) || |
|
464 ( view->CyclePosition() != CCalenView::ENoCyclePosition )) |
|
465 { |
|
466 TInt viewUidInt = view->ViewUid().iUid; |
|
467 |
|
468 if ( viewUidInt == iDefView ) |
|
469 { |
|
470 isDefViewValid = ETrue; |
|
471 } |
|
472 |
|
473 CAknEnumeratedText* item = new( ELeave )CAknEnumeratedText( viewUidInt, |
|
474 view->SettingsName().AllocL() ); |
|
475 items->AppendL( item ); |
|
476 } |
|
477 } |
|
478 |
|
479 if ( !isDefViewValid ) |
|
480 { |
|
481 // Default view is no longer valid (could be first ever load, or could be |
|
482 // a 3rd party plugin's view used to be the default but is not removed). |
|
483 // Set default to the first in the view cycle array. |
|
484 TInt defViewIndex( 0 ); |
|
485 while ( views[defViewIndex]->CyclePosition() == CCalenView::ENoCyclePosition ) |
|
486 { |
|
487 defViewIndex++; |
|
488 } |
|
489 |
|
490 iDefView = views[defViewIndex]->ViewUid().iUid; |
|
491 iSetting->SetDefaultView( TUid::Uid( iDefView ) ); |
|
492 } |
|
493 |
|
494 settingItem->HandleTextArrayUpdateL(); |
|
495 |
|
496 // Append item to settingitem-array |
|
497 iSettingItemArray->InsertL( aOrdinal, settingItem ); |
|
498 |
|
499 CleanupStack::PopAndDestroy( itemTitle ); |
|
500 CleanupStack::Pop( settingItem ); |
|
501 |
|
502 TRACE_EXIT_POINT; |
|
503 } |
|
504 |
|
505 // ---------------------------------------------------------------------------- |
|
506 // CCalenSettingsUiContainer::AddSnoozeTimeItemL |
|
507 // Adds an alarm snooze time item |
|
508 // (other items were commented in a header). |
|
509 // ---------------------------------------------------------------------------- |
|
510 // |
|
511 void CCalenSettingsUiContainer::AddSnoozeTimeItemL( TInt aOrdinal, |
|
512 CArrayPtr<CGulIcon>* aIconArray, |
|
513 TInt& aSnoozeTime) |
|
514 { |
|
515 TRACE_ENTRY_POINT; |
|
516 |
|
517 CCalenSliderSettingItem* settingItem = |
|
518 new( ELeave )CCalenSliderSettingItem( ECalenSnoozeTimeItemId, |
|
519 aSnoozeTime, |
|
520 R_SNOOZE_TIME_SLIDER ); |
|
521 CleanupStack::PushL( settingItem ); |
|
522 |
|
523 HBufC* itemTitle = StringLoader::LoadLC( R_QTN_CALE_SET_SNOOZE_TIME ); |
|
524 |
|
525 settingItem->ConstructL( EFalse, |
|
526 aOrdinal, |
|
527 *itemTitle, |
|
528 aIconArray, |
|
529 R_SNOOZE_TIME_SETTING_PAGE, |
|
530 EAknCtSlider ); |
|
531 |
|
532 iSettingItemArray->InsertL( aOrdinal, settingItem ); |
|
533 |
|
534 CleanupStack::PopAndDestroy( itemTitle ); |
|
535 CleanupStack::Pop( settingItem ); |
|
536 |
|
537 TRACE_EXIT_POINT; |
|
538 } |
|
539 |
|
540 // ---------------------------------------------------------------------------- |
|
541 // AddEnumerationItemL() |
|
542 // Add integer type of settings item |
|
543 // Integer type item can have multiple choices shown as radiobutton list. |
|
544 // (other items were commented in a header). |
|
545 // ---------------------------------------------------------------------------- |
|
546 // |
|
547 void CCalenSettingsUiContainer::AddEnumerationItemL( TInt& aBuffer, |
|
548 TInt aId, |
|
549 TInt aTitleResource, |
|
550 TInt aSettingPageResource, |
|
551 TInt aAssociatedResource, |
|
552 TInt aOrdinal ) |
|
553 { |
|
554 TRACE_ENTRY_POINT; |
|
555 |
|
556 // Create new setting item |
|
557 CAknSettingItem* settingItem = |
|
558 new ( ELeave ) CAknEnumeratedTextPopupSettingItem( aId, aBuffer ); |
|
559 CleanupStack::PushL( settingItem ); |
|
560 |
|
561 // Construct setting item with parametrized values |
|
562 HBufC* itemTitle = StringLoader::LoadLC( aTitleResource ); |
|
563 settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, |
|
564 aSettingPageResource, EAknCtPopupSettingList, |
|
565 NULL, aAssociatedResource ); |
|
566 |
|
567 // Append item to settingitem-array |
|
568 iSettingItemArray->InsertL( aOrdinal, settingItem ); |
|
569 |
|
570 CleanupStack::PopAndDestroy( itemTitle ); |
|
571 CleanupStack::Pop( settingItem ); |
|
572 |
|
573 TRACE_EXIT_POINT; |
|
574 } |
|
575 |
|
576 // ----------------------------------------------------------------------------- |
|
577 // CCalenSettingsUiContainer::AddBinaryItemL() |
|
578 // Add binary type (true/false) settings item |
|
579 // (other items were commented in a header). |
|
580 // ----------------------------------------------------------------------------- |
|
581 // |
|
582 void CCalenSettingsUiContainer::AddBinaryItemL( TBool& aBuffer, |
|
583 TInt aId, |
|
584 TInt aTitleResource, |
|
585 TInt aSettingPageResource, |
|
586 TInt aAssociatedResource, |
|
587 TInt aOrdinal ) |
|
588 { |
|
589 TRACE_ENTRY_POINT; |
|
590 |
|
591 // Create new setting item |
|
592 CAknSettingItem* settingItem = |
|
593 new ( ELeave ) CAknBinaryPopupSettingItem( aId, aBuffer ); |
|
594 CleanupStack::PushL( settingItem ); |
|
595 |
|
596 // Construct setting item with parametrized values |
|
597 HBufC* itemTitle = StringLoader::LoadLC( aTitleResource ); |
|
598 settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, |
|
599 aSettingPageResource, EAknCtPopupSettingList, |
|
600 NULL, aAssociatedResource ); |
|
601 |
|
602 // Append item to settingitem-array |
|
603 iSettingItemArray->InsertL( aOrdinal, settingItem ); |
|
604 |
|
605 CleanupStack::PopAndDestroy( itemTitle ); |
|
606 CleanupStack::Pop( settingItem ); |
|
607 |
|
608 TRACE_EXIT_POINT; |
|
609 } |
|
610 |
|
611 // ---------------------------------------------------------------------------- |
|
612 // CCalenSettingsUiContainer::AddAlarmToneItemL |
|
613 // Adds an item to the settings page which contains information about |
|
614 // which tone should be played when an alarm expires. |
|
615 // (other items were commented in a header). |
|
616 // ---------------------------------------------------------------------------- |
|
617 // |
|
618 void CCalenSettingsUiContainer::AddAlarmToneItemL( TInt aOrdinal ) |
|
619 { |
|
620 TRACE_ENTRY_POINT; |
|
621 |
|
622 CCalenFileListSettingItem* settingItem = |
|
623 new ( ELeave ) CCalenFileListSettingItem( ECalenAlarmToneItemId ); |
|
624 CleanupStack::PushL( settingItem ); |
|
625 |
|
626 // Construct setting item with parametrized values |
|
627 HBufC* itemTitle = StringLoader::LoadLC( R_CALEN_SETTING_ALARMTONE_TITLE ); |
|
628 settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, |
|
629 NULL, NULL, NULL, NULL ); |
|
630 |
|
631 // Append item to settingitem-array |
|
632 iSettingItemArray->InsertL( aOrdinal, settingItem ); |
|
633 |
|
634 CleanupStack::PopAndDestroy( itemTitle ); |
|
635 CleanupStack::Pop( settingItem ); |
|
636 |
|
637 TRACE_EXIT_POINT; |
|
638 } |
|
639 |
|
640 // ---------------------------------------------------------------------------- |
|
641 // CCalenSettingsUiContainer::CreateMailboxSettingsItemL |
|
642 // Creates the settings item for selection of the default meeting request |
|
643 // mailbox. This should only be called when MR viewers are enabled. |
|
644 // (other items were commented in a header). |
|
645 // ---------------------------------------------------------------------------- |
|
646 // |
|
647 void CCalenSettingsUiContainer::CreateMailboxSettingsItemL( TInt aOrdinal ) |
|
648 { |
|
649 TRACE_ENTRY_POINT; |
|
650 |
|
651 // Mailbox settings are shown when we have a MR viewers implementation. |
|
652 ASSERT( iGlobalData.InterimUtilsL().MRViewersEnabledL() ); |
|
653 CMRMailboxUtils& mailboxUtils = iGlobalData.MRMailboxUtilsL(); |
|
654 CAknEnumeratedTextPopupSettingItem* settingItem = |
|
655 new ( ELeave ) CAknEnumeratedTextPopupSettingItem( ECalenDefaultMailboxId, |
|
656 iDefMailbox ); |
|
657 CleanupStack::PushL( settingItem ); |
|
658 |
|
659 // Construct setting item with parametrized values |
|
660 HBufC* itemTitle = StringLoader::LoadLC( R_CALEN_SETTING_DEFAULTMAILBOX_TITLE ); |
|
661 // The resources loaded up here are empty as the items need to be dynamically updated. |
|
662 |
|
663 settingItem->SetEmptyItemTextL( KNullDesC ); |
|
664 |
|
665 settingItem->ConstructL( EFalse, aOrdinal, *itemTitle, NULL, |
|
666 R_CALEN_SETTING_DEFAULTMAILBOX, EAknCtPopupSettingList, |
|
667 NULL, R_CALEN_EMPTY_POPUP_SETTING_TEXTS ); |
|
668 |
|
669 CArrayPtr<CAknEnumeratedText>* items = settingItem->EnumeratedTextArray(); |
|
670 |
|
671 RImplInfoPtrArrayOwn implArray; |
|
672 CleanupClosePushL( implArray ); |
|
673 //Get all MRViewers Implementation |
|
674 CMRMailboxUtils::TMailboxInfo defaultMailbox; |
|
675 const TUid mrViewersIface = {KMRViewersInterfaceUID}; |
|
676 REComSession::ListImplementationsL( mrViewersIface, implArray ); |
|
677 |
|
678 TBuf16<KMaxUidName> mbName; |
|
679 TInt enumerationCounter = 0; |
|
680 |
|
681 for( TInt i=0; i < iMailBoxes.Count(); ++i ) |
|
682 { |
|
683 for( TInt j=0; j < implArray.Count(); ++j ) |
|
684 { |
|
685 CnvUtfConverter::ConvertToUnicodeFromUtf8( mbName, implArray[j]->DataType() ); |
|
686 if( iMailBoxes[i].iMtmUid.Name().CompareF(mbName) == 0 ) |
|
687 { |
|
688 // Found a match |
|
689 CAknEnumeratedText* item = new(ELeave) CAknEnumeratedText( enumerationCounter, |
|
690 iMailBoxes[i].iName.AllocL() ); |
|
691 items->AppendL( item ); |
|
692 ++enumerationCounter; |
|
693 } |
|
694 } |
|
695 } |
|
696 |
|
697 CleanupStack::PopAndDestroy(); //implArray |
|
698 |
|
699 settingItem->HandleTextArrayUpdateL(); |
|
700 |
|
701 // Append item to settingitem-array |
|
702 iSettingItemArray->InsertL( aOrdinal, settingItem ); |
|
703 |
|
704 CleanupStack::PopAndDestroy( itemTitle ); |
|
705 CleanupStack::Pop( settingItem ); |
|
706 |
|
707 TRACE_EXIT_POINT; |
|
708 } |
|
709 |
|
710 // ---------------------------------------------------------------------------- |
|
711 // CCalenSettingsUiContainer::UpdateListBoxL |
|
712 // Update listbox item |
|
713 // ---------------------------------------------------------------------------- |
|
714 // |
|
715 EXPORT_C void CCalenSettingsUiContainer::UpdateListBoxL() |
|
716 { |
|
717 TRACE_ENTRY_POINT; |
|
718 |
|
719 iListBox.HandleItemAdditionL(); |
|
720 |
|
721 TRACE_EXIT_POINT; |
|
722 } |
|
723 |
|
724 // ---------------------------------------------------------------------------- |
|
725 // CCalenSettingsUiContainer::ConstructListBoxL |
|
726 // Update listbox item |
|
727 // Items are added manually, instead of loading them from resources |
|
728 // ---------------------------------------------------------------------------- |
|
729 // |
|
730 EXPORT_C void CCalenSettingsUiContainer::ConstructListBoxL() |
|
731 { |
|
732 TRACE_ENTRY_POINT; |
|
733 |
|
734 iListBox.ConstructL( iParentControl, EAknListBoxSelectionList ); |
|
735 |
|
736 LoadCurrentValuesL(); |
|
737 |
|
738 // Create items to array |
|
739 CreateListBoxItemsL(); |
|
740 |
|
741 // Set array to listbox |
|
742 CTextListBoxModel* model = iListBox.Model(); |
|
743 model->SetItemTextArray( iSettingItemArray ); |
|
744 // Ownership retained by us |
|
745 model->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
746 |
|
747 iSettingItemArray->RecalculateVisibleIndicesL(); |
|
748 iListBox.CreateScrollBarFrameL(); |
|
749 iListBox.ScrollBarFrame()->SetScrollBarVisibilityL( |
|
750 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
751 |
|
752 TRACE_EXIT_POINT; |
|
753 } |
|
754 |
|
755 // ---------------------------------------------------------------------------- |
|
756 // CCalenSettingsUiContainer::CreateListBoxItemsL |
|
757 // Update listbox item |
|
758 // ---------------------------------------------------------------------------- |
|
759 // |
|
760 void CCalenSettingsUiContainer::CreateListBoxItemsL() |
|
761 { |
|
762 TRACE_ENTRY_POINT; |
|
763 |
|
764 TInt ordinal = 0; |
|
765 |
|
766 AddAlarmToneItemL( ordinal++ ); |
|
767 |
|
768 CArrayPtr<CGulIcon>* iconArray = iListBox.ItemDrawer()->ColumnData()->IconArray(); |
|
769 |
|
770 if( !iconArray ) |
|
771 { |
|
772 iconArray = new( ELeave )CArrayPtrFlat<CGulIcon>( 1 ); |
|
773 iListBox.ItemDrawer()->ColumnData()->SetIconArrayL( iconArray ); // ownership transfered |
|
774 } |
|
775 |
|
776 AddSnoozeTimeItemL( ordinal++, iconArray, iSnoozeTime ); |
|
777 |
|
778 AddDefaultViewItemL( iDefView, |
|
779 ECalenDefaultViewItemId, |
|
780 R_CALEN_SETTING_DEFAULTVIEW_TITLE, |
|
781 R_CALEN_SETTING_DEFAULTVIEW, |
|
782 ordinal++ ); |
|
783 |
|
784 AddEnumerationItemL( iWeekFormat, |
|
785 ECalenWeekFormatItemId, |
|
786 R_CALEN_SETTING_WEEKFORMAT_TITLE, |
|
787 R_CALEN_SETTING_WEEKFORMAT, |
|
788 R_CALEN_WEEKFORMAT_TEXTS, |
|
789 ordinal++ ); |
|
790 |
|
791 |
|
792 // Always add this in. We will set it hidden when it's not needed (i.e. when the |
|
793 // week start is set to anything other than "Monday") at the bottom of this function. |
|
794 AddEnumerationItemL( iWeekTitle, |
|
795 ECalenWeekTitleItemId, |
|
796 R_CALEN_SETTING_WEEKTITLE_TITLE, |
|
797 R_CALEN_SETTING_WEEKTITLE, |
|
798 R_CALEN_WEEKTITLE_TEXTS, |
|
799 ordinal++ ); |
|
800 |
|
801 |
|
802 #ifdef RD_CALEN_EXTERNAL_CAL |
|
803 // add external calendar support if available. |
|
804 TBool isExt=ExtCalendarAvailableL(); |
|
805 if (isExt) |
|
806 { |
|
807 AddEnumerationItemL( iExtCalendar, |
|
808 ECalenExtCalendarItemId, |
|
809 R_CALEN_SETTING_EXT_CALENDAR_TITLE, |
|
810 R_CALEN_EXT_CALENDAR_SETTING_PAGE, |
|
811 R_CALEN_EXT_CALENDAR_SETTING_TEXTS, |
|
812 ordinal++ ); |
|
813 } |
|
814 |
|
815 #endif //RD_CALEN_EXTERNAL_CAL |
|
816 |
|
817 // Only add the mailbox choice when the Meeting Request functionality is there. |
|
818 if( iGlobalData.InterimUtilsL().MRViewersEnabledL() ) |
|
819 { |
|
820 CreateMailboxSettingsItemL( ordinal++ ); // increments ordinal |
|
821 } |
|
822 |
|
823 #ifdef RD_SCALABLE_UI_V2_NO_TOOLBAR_SETTING |
|
824 if( AknLayoutUtils::PenEnabled() ) |
|
825 { |
|
826 AddBinaryItemL( iToolbar, |
|
827 ECalenToolbarItemId, |
|
828 R_CALEN_SETTING_TOOLBAR_TITLE, |
|
829 R_CALEN_SETTING_TOOLBAR, |
|
830 R_CALEN_TOOLBAR_TEXTS, |
|
831 ordinal++ ); |
|
832 } |
|
833 #endif // RD_SCALABLE_UI_V2_NO_TOOLBAR_SETTING |
|
834 |
|
835 AddPluginSettingItemL( ordinal ); |
|
836 |
|
837 AddCustomSettingsItemsL( ordinal ); |
|
838 ++ordinal; |
|
839 |
|
840 // Hide the week title setting if the week start is anything other than Monday. |
|
841 Item( ECalenWeekTitleItemId )->SetHidden( !ShouldShowWeekTitleItem() ); |
|
842 |
|
843 TRACE_EXIT_POINT; |
|
844 } |
|
845 |
|
846 // ---------------------------------------------------------------------------- |
|
847 // CCalenSettingsUiContainer::CurrentFeatureId |
|
848 // Get the currently selected feature |
|
849 // ---------------------------------------------------------------------------- |
|
850 // |
|
851 EXPORT_C TInt CCalenSettingsUiContainer::CurrentFeatureId() const |
|
852 { |
|
853 TRACE_ENTRY_POINT; |
|
854 |
|
855 if ( iSettingItemArray ) |
|
856 { |
|
857 TRACE_EXIT_POINT; |
|
858 return iSettingItemArray->MdcaCount(); |
|
859 } |
|
860 else |
|
861 { |
|
862 TRACE_EXIT_POINT; |
|
863 return 0; |
|
864 } |
|
865 } |
|
866 |
|
867 // ---------------------------------------------------------------------------- |
|
868 // CCalenSettingsUiContainer::GetHelpContext |
|
869 // Get help for this view |
|
870 // ---------------------------------------------------------------------------- |
|
871 // |
|
872 void CCalenSettingsUiContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
873 { |
|
874 TRACE_ENTRY_POINT; |
|
875 |
|
876 aContext.iMajor = KUidCalendar; |
|
877 // This is specified in HRH file. |
|
878 aContext.iContext = KCALE_HLP_SETTINGS; |
|
879 |
|
880 TRACE_EXIT_POINT; |
|
881 } |
|
882 |
|
883 // ---------------------------------------------------------------------------- |
|
884 // CCalenSettingsUiContainer::ShouldShowWeekTitleItem |
|
885 // Returns ETrue if the start of the week is set to Monday. |
|
886 // (other items were commented in a header). |
|
887 // ---------------------------------------------------------------------------- |
|
888 // |
|
889 TBool CCalenSettingsUiContainer::ShouldShowWeekTitleItem() const |
|
890 { |
|
891 TRACE_ENTRY_POINT; |
|
892 TDay day = static_cast<TDay>( iWeekFormat ); |
|
893 TRACE_EXIT_POINT; |
|
894 return ( day == EMonday ); |
|
895 } |
|
896 |
|
897 // ---------------------------------------------------------------------------- |
|
898 // CCalenSettingsUiContainer::Item |
|
899 // Returns the settings item associated with the given setting list item id. |
|
900 // (other items were commented in a header). |
|
901 // ---------------------------------------------------------------------------- |
|
902 // |
|
903 CAknSettingItem* CCalenSettingsUiContainer::Item( TSettingListItemId aId ) |
|
904 { |
|
905 TRACE_ENTRY_POINT; |
|
906 for( TInt i = 0; i < iSettingItemArray->Count(); ++i ) |
|
907 { |
|
908 if( iSettingItemArray->At(i)->Identifier() == aId ) |
|
909 { |
|
910 TRACE_EXIT_POINT; |
|
911 return iSettingItemArray->At( i ); |
|
912 } |
|
913 } |
|
914 ASSERT( EFalse ); |
|
915 TRACE_EXIT_POINT; |
|
916 return NULL; |
|
917 } |
|
918 |
|
919 // ---------------------------------------------------------------------------- |
|
920 // CCalenSettingsUiContainer::ValidateWeekTitleItemL |
|
921 // Hides or shows the week title item based on whether the beginning of the |
|
922 // week is set to Monday or not. This should only be called on the week format item. |
|
923 // (other items were commented in a header). |
|
924 // ---------------------------------------------------------------------------- |
|
925 // |
|
926 void CCalenSettingsUiContainer::ValidateWeekTitleItemL( CAknSettingItem *aItem ) |
|
927 { |
|
928 TRACE_ENTRY_POINT; |
|
929 |
|
930 ASSERT( aItem->Identifier() == ECalenWeekFormatItemId ); |
|
931 TBool wasShown = ShouldShowWeekTitleItem(); |
|
932 aItem->StoreL(); // Updates iWeekFormat variable |
|
933 TBool doShow = ShouldShowWeekTitleItem(); |
|
934 |
|
935 if ( wasShown != doShow ) |
|
936 { |
|
937 Item( ECalenWeekTitleItemId )->SetHidden( !doShow ); |
|
938 |
|
939 if ( !doShow ) |
|
940 { |
|
941 Item( ECalenWeekTitleItemId )->LoadL(); |
|
942 } |
|
943 |
|
944 iSettingItemArray->RecalculateVisibleIndicesL(); |
|
945 iListBox.HandleItemAdditionL(); |
|
946 iListBox.UpdateScrollBarsL(); |
|
947 } |
|
948 TRACE_EXIT_POINT; |
|
949 } |
|
950 |
|
951 // ---------------------------------------------------------------------------- |
|
952 // CCalenSettingsUiContainer::ShowOrHideWeekTitleL |
|
953 // Shows or hides the week title setting as appropriate. |
|
954 // (other items were commented in a header). |
|
955 // ---------------------------------------------------------------------------- |
|
956 // |
|
957 void CCalenSettingsUiContainer::ShowOrHideWeekTitleL() |
|
958 { |
|
959 TRACE_ENTRY_POINT; |
|
960 |
|
961 CAknSettingItem* wkTitle = Item( ECalenWeekTitleItemId ); |
|
962 const TInt currentIndex( iListBox.CurrentItemIndex() ); |
|
963 |
|
964 const TBool wasLookingAtWeekTitle( currentIndex == wkTitle->VisibleIndex() ); |
|
965 const TBool doShow( ShouldShowWeekTitleItem() ); |
|
966 |
|
967 wkTitle->SetHidden( !doShow ); |
|
968 |
|
969 // Make sure we're still looking at a setting item after one was removed. |
|
970 if ( !doShow && wasLookingAtWeekTitle ) |
|
971 { |
|
972 iListBox.SetCurrentItemIndex( Item( ECalenWeekFormatItemId )->VisibleIndex() ); |
|
973 } |
|
974 |
|
975 iSettingItemArray->RecalculateVisibleIndicesL(); |
|
976 iListBox.HandleItemAdditionL(); |
|
977 iListBox.UpdateScrollBarsL(); |
|
978 |
|
979 TRACE_EXIT_POINT; |
|
980 } |
|
981 |
|
982 // ---------------------------------------------------------------------------- |
|
983 // CCalenSettingsUiContainer::HandleListBoxSelectionL |
|
984 // Handles list box selection events. |
|
985 // (other items were commented in a header). |
|
986 // ---------------------------------------------------------------------------- |
|
987 // |
|
988 EXPORT_C void CCalenSettingsUiContainer::HandleListBoxSelectionL( TInt aCommand ,TBool& aPageStatus) |
|
989 { |
|
990 TRACE_ENTRY_POINT; |
|
991 |
|
992 TInt index( iListBox.CurrentItemIndex() ); |
|
993 |
|
994 if ( index >= 0 ) // index is -1 if there are no items in the list |
|
995 { |
|
996 CAknSettingItem* item; |
|
997 TDay day = static_cast<TDay>( iWeekFormat ); |
|
998 |
|
999 // If the starting day of a week is other than Monday, "Title of week view" setting item |
|
1000 // is not displayed. For the item below "Week Format", the index in iSettingItemArray |
|
1001 // is one more than CurrentItemIndex(). |
|
1002 if( ( day != EMonday && index >= 4 ) ) |
|
1003 { |
|
1004 item = iSettingItemArray->At( index + 1); |
|
1005 } |
|
1006 else |
|
1007 { |
|
1008 item = iSettingItemArray->At( index ); |
|
1009 } |
|
1010 // Open edit dialog if EAknCmdOpen, invert the value otherwise |
|
1011 aPageStatus = ETrue; |
|
1012 iPageStatus = aPageStatus; |
|
1013 item->EditItemL( aCommand == EAknCmdOpen ); |
|
1014 aPageStatus = EFalse; |
|
1015 iPageStatus = aPageStatus; |
|
1016 TBool isNativeSettingChange = ETrue; |
|
1017 |
|
1018 if(item->Identifier() > 0 ) |
|
1019 { |
|
1020 // Save the settings change, so if we have two settings windows open |
|
1021 // the background one can be updated. |
|
1022 switch( item->Identifier() ) |
|
1023 { |
|
1024 case ECalenWeekFormatItemId: |
|
1025 // item->StoreL() gets called in ValidateWeekTitleItemL |
|
1026 ValidateWeekTitleItemL( item ); |
|
1027 iSetting->SetWeekFormat( static_cast<TDay>( iWeekFormat ) ); |
|
1028 break; |
|
1029 case ECalenAlarmToneItemId: |
|
1030 item->StoreL(); |
|
1031 // CCalenFileListSettingItem::StoreL saves the filename to cenrep. |
|
1032 break; |
|
1033 case ECalenSnoozeTimeItemId: |
|
1034 item->StoreL(); |
|
1035 iSetting->SetSnoozeTime( iSnoozeTime ); |
|
1036 break; |
|
1037 case ECalenDefaultViewItemId: |
|
1038 item->StoreL(); |
|
1039 iSetting->SetDefaultView( TUid::Uid( iDefView ) ); |
|
1040 break; |
|
1041 case ECalenWeekTitleItemId: |
|
1042 item->StoreL(); |
|
1043 iSetting->SetWeekTitle( static_cast<TCalenWeekTitle>( iWeekTitle ) ); |
|
1044 break; |
|
1045 case ECalenDefaultMailboxId: |
|
1046 item->StoreL(); |
|
1047 StoreMailboxSettingsL(); |
|
1048 break; |
|
1049 #ifdef RD_CALEN_EXTERNAL_CAL |
|
1050 case ECalenExtCalendarItemId: |
|
1051 item->StoreL(); |
|
1052 iSetting->SetExtCalendar( iExtCalendar); |
|
1053 break; |
|
1054 #endif // RD_CALEN_EXTERNAL_CAL |
|
1055 #ifdef RD_SCALABLE_UI_V2_NO_TOOLBAR_SETTING |
|
1056 case ECalenToolbarItemId: |
|
1057 item->StoreL(); |
|
1058 iSetting->SetToolbar( iToolbar ); |
|
1059 break; |
|
1060 #endif // RD_SCALABLE_UI_V2_NO_TOOLBAR_SETTING |
|
1061 case ECalenPluginListItemId: |
|
1062 // No item to store, CCalenCheckboxSettingItem updated |
|
1063 // the customisation manager and CCalenSetting. Need to |
|
1064 // redraw the listboc |
|
1065 item->StoreL(); |
|
1066 PluginListChangedL(); |
|
1067 |
|
1068 break; |
|
1069 default: // Custom setting. |
|
1070 item->StoreL(); |
|
1071 // Custom settings won't generate a repository change, so keep listening. |
|
1072 isNativeSettingChange = EFalse; |
|
1073 break; |
|
1074 } |
|
1075 |
|
1076 if ( isNativeSettingChange ) |
|
1077 |
|
1078 { |
|
1079 // Don't listen for changes to cenrep/TLocale for this settings change. |
|
1080 iIgnoreNextSettingsNotification = ETrue; |
|
1081 iSetting->SaveL(); |
|
1082 } |
|
1083 |
|
1084 |
|
1085 iListBox.DrawItem( index ); |
|
1086 } |
|
1087 } |
|
1088 TRACE_EXIT_POINT; |
|
1089 } |
|
1090 |
|
1091 // ---------------------------------------------------------------------------- |
|
1092 // CCalenSettingsUiContainer::PluginListChangedL() |
|
1093 // Cenrep watcher callback |
|
1094 // ---------------------------------------------------------------------------- |
|
1095 // |
|
1096 void CCalenSettingsUiContainer::PluginListChangedL() |
|
1097 { |
|
1098 iSettingItemArray->ResetAndDestroy(); |
|
1099 |
|
1100 // Update the default view as it would have changed after enabling/disabling plugins |
|
1101 iDefView = iSetting->DefaultView().iUid; |
|
1102 iWeekFormat = iSetting->WeekFormat(); |
|
1103 iWeekTitle = iSetting->WeekTitle(); |
|
1104 iSnoozeTime = iSetting->SnoozeTime(); |
|
1105 CreateListBoxItemsL(); |
|
1106 |
|
1107 iSettingItemArray->RecalculateVisibleIndicesL(); |
|
1108 iListBox.HandleItemAdditionL(); |
|
1109 iListBox.UpdateScrollBarsL(); |
|
1110 } |
|
1111 |
|
1112 // ---------------------------------------------------------------------------- |
|
1113 // CCalenSettingsUiContainer::HandleNotifyGeneric |
|
1114 // Cenrep watcher callback |
|
1115 // ---------------------------------------------------------------------------- |
|
1116 // |
|
1117 void CCalenSettingsUiContainer::HandleNotifyGeneric( TUint32 aId ) |
|
1118 { |
|
1119 TRACE_ENTRY_POINT; |
|
1120 |
|
1121 // Make sure it wasn't this object that generated the settings change. |
|
1122 if ( iIgnoreNextSettingsNotification ) |
|
1123 { |
|
1124 iIgnoreNextSettingsNotification = EFalse; |
|
1125 } |
|
1126 else |
|
1127 { |
|
1128 PIM_TRAPD_HANDLE( HandleExternalSettingsChangedL(aId)); |
|
1129 } |
|
1130 |
|
1131 // Use another trap to make sure we start listening again, regardless |
|
1132 // of whether the previous function left or not. |
|
1133 PIM_TRAPD_HANDLE( iCenRepNotifyHandler->StartListeningL() ); |
|
1134 |
|
1135 TRACE_EXIT_POINT |
|
1136 } |
|
1137 |
|
1138 // ---------------------------------------------------------------------------- |
|
1139 // CCalenSettingsUiContainer::HandleNotifyError |
|
1140 // Cenrep watcher error callback |
|
1141 // ---------------------------------------------------------------------------- |
|
1142 // |
|
1143 void CCalenSettingsUiContainer::HandleNotifyError( TUint32 /*aId*/, |
|
1144 TInt /*aError*/, |
|
1145 CCenRepNotifyHandler* /*aHandler*/ ) |
|
1146 { |
|
1147 TRACE_ENTRY_POINT; |
|
1148 |
|
1149 PIM_TRAPD_HANDLE( iCenRepNotifyHandler->StartListeningL() ); |
|
1150 |
|
1151 TRACE_EXIT_POINT; |
|
1152 } |
|
1153 |
|
1154 // ---------------------------------------------------------------------------- |
|
1155 // CCalenSettingsUiContainer::LocaleCallbackL |
|
1156 // Locale watcher callback |
|
1157 // ---------------------------------------------------------------------------- |
|
1158 // |
|
1159 TInt CCalenSettingsUiContainer::LocaleCallbackL( TAny* aThisPtr ) |
|
1160 { |
|
1161 TRACE_ENTRY_POINT; |
|
1162 |
|
1163 CCalenSettingsUiContainer* ptr = static_cast<CCalenSettingsUiContainer*>( aThisPtr ); |
|
1164 ptr->DoLocaleCallbackL(); |
|
1165 |
|
1166 TRACE_EXIT_POINT; |
|
1167 return FALSE; |
|
1168 } |
|
1169 |
|
1170 // ---------------------------------------------------------------------------- |
|
1171 // CCalenSettingsUiContainer::DoLocaleCallbackL |
|
1172 // Implementation of locale watcher callback |
|
1173 // ---------------------------------------------------------------------------- |
|
1174 // |
|
1175 void CCalenSettingsUiContainer::DoLocaleCallbackL() |
|
1176 { |
|
1177 TRACE_ENTRY_POINT; |
|
1178 |
|
1179 if ( iLocaleChangeNotifier->Change() & EChangesLocale ) |
|
1180 { |
|
1181 if( iIgnoreFirstLocaleChange ) |
|
1182 { |
|
1183 // When initialising the locale change observer, we get a notification |
|
1184 // when observing starts. We ignore this as we don't need to act on it. |
|
1185 iIgnoreFirstLocaleChange = EFalse; |
|
1186 } |
|
1187 else |
|
1188 { |
|
1189 // Make sure it wasn't this object that generated the settings change. |
|
1190 if ( iIgnoreNextSettingsNotification ) |
|
1191 { |
|
1192 iIgnoreNextSettingsNotification = EFalse; |
|
1193 } |
|
1194 else |
|
1195 { |
|
1196 HandleExternalSettingsChangedL(); |
|
1197 ShowOrHideWeekTitleL(); |
|
1198 // ValidateWeekTitleItemL( Item( ECalenWeekFormatItemId ) ); |
|
1199 } |
|
1200 } |
|
1201 } |
|
1202 |
|
1203 TRACE_EXIT_POINT; |
|
1204 } |
|
1205 |
|
1206 // ---------------------------------------------------------------------------- |
|
1207 // CCalenSettingsUiContainer::HandleExternalSettingsChangedL |
|
1208 // Called when something else changed our settings |
|
1209 // ---------------------------------------------------------------------------- |
|
1210 // |
|
1211 void CCalenSettingsUiContainer::HandleExternalSettingsChangedL(TUint32 aId) |
|
1212 { |
|
1213 TRACE_ENTRY_POINT; |
|
1214 // Load from cenrep to member data. |
|
1215 LoadCurrentValuesL(); |
|
1216 |
|
1217 switch(aId) |
|
1218 { |
|
1219 case KCalendarPluginAvailability: |
|
1220 { |
|
1221 HandlePluginChange(); |
|
1222 if(!iPageStatus) |
|
1223 { |
|
1224 PluginListChangedL(); |
|
1225 } |
|
1226 } |
|
1227 break; |
|
1228 |
|
1229 default: |
|
1230 { |
|
1231 // If the starting day of a week is Monday, "Title of week view" setting item |
|
1232 // is also displayed. so the number of default items will be 5. |
|
1233 TInt maxDefaultSettingItems = ShouldShowWeekTitleItem()?5:4; |
|
1234 |
|
1235 for( TInt i=0; i<maxDefaultSettingItems; ++i ) |
|
1236 { |
|
1237 iSettingItemArray->At( i )->LoadL(); |
|
1238 iSettingItemArray->At( i )->UpdateListBoxTextL(); |
|
1239 } |
|
1240 } |
|
1241 } |
|
1242 iListBox.HandleItemAdditionL(); |
|
1243 |
|
1244 TRACE_EXIT_POINT; |
|
1245 } |
|
1246 |
|
1247 // ---------------------------------------------------------------------------- |
|
1248 // CCalenSettingsUiContainer::LoadCurrentValuesL |
|
1249 // Loads current values from cenrep. |
|
1250 // ---------------------------------------------------------------------------- |
|
1251 // |
|
1252 void CCalenSettingsUiContainer::LoadCurrentValuesL() |
|
1253 { |
|
1254 TRACE_ENTRY_POINT; |
|
1255 iSetting->LoadL(); |
|
1256 |
|
1257 iDefView = iSetting->DefaultView().iUid; |
|
1258 iWeekFormat = iSetting->WeekFormat(); |
|
1259 iWeekTitle = iSetting->WeekTitle(); |
|
1260 iSnoozeTime = iSetting->SnoozeTime(); |
|
1261 #ifdef RD_SCALABLE_UI_V2_NO_TOOLBAR_SETTING |
|
1262 iToolbar = iSetting->Toolbar(); |
|
1263 #endif |
|
1264 |
|
1265 #ifdef RD_CALEN_EXTERNAL_CAL |
|
1266 iExtCalendar = iSetting->ExtCalendar(); |
|
1267 #endif |
|
1268 |
|
1269 TRACE_EXIT_POINT; |
|
1270 } |
|
1271 |
|
1272 // ---------------------------------------------------------------------------- |
|
1273 // CCalenSettingsUiContainer::StoreMailboxSettingsL |
|
1274 // Stores the mailbox settings. |
|
1275 // ---------------------------------------------------------------------------- |
|
1276 // |
|
1277 void CCalenSettingsUiContainer::StoreMailboxSettingsL() |
|
1278 { |
|
1279 TRACE_ENTRY_POINT; |
|
1280 |
|
1281 if( iGlobalData.InterimUtilsL().MRViewersEnabledL() ) |
|
1282 { |
|
1283 // iHasSelectedMailbox will be EFalse if we didn't select a MR MB previously. |
|
1284 // However, they might have selected one this time. |
|
1285 if( !iHasSelectedMailbox && iDefMailbox != 0 ) |
|
1286 { |
|
1287 iHasSelectedMailbox = ETrue; |
|
1288 --iDefMailbox; // This gets decremented as the first menu item was a blank, unselected choice. |
|
1289 } |
|
1290 |
|
1291 if( iHasSelectedMailbox ) |
|
1292 { |
|
1293 CMRMailboxUtils& mbUtils = iGlobalData.MRMailboxUtilsL(); |
|
1294 |
|
1295 ListMailboxesL( mbUtils, iMailBoxes ); |
|
1296 |
|
1297 RImplInfoPtrArrayOwn implArray; |
|
1298 CleanupClosePushL( implArray ); |
|
1299 const TUid mrViewersIface = {KMRViewersInterfaceUID}; |
|
1300 REComSession::ListImplementationsL( mrViewersIface, implArray ); |
|
1301 TBuf16<KMaxUidName> mbName; |
|
1302 |
|
1303 TInt enumValue = 0; // How many mailboxes we have been through so far that are visible to the user. |
|
1304 // Convert from the enumeration to the default mailbox id. |
|
1305 for( TInt i=0; i < iMailBoxes.Count(); ++i ) |
|
1306 { |
|
1307 for( TInt j=0; j<implArray.Count(); ++j ) |
|
1308 { |
|
1309 CnvUtfConverter::ConvertToUnicodeFromUtf8( mbName, implArray[j]->DataType() ); |
|
1310 if( iMailBoxes[i].iMtmUid.Name().CompareF(mbName) == 0 ) |
|
1311 { |
|
1312 // Found a match. This mailbox would have been shown in the settings list. |
|
1313 if( enumValue == iDefMailbox ) |
|
1314 { |
|
1315 User::LeaveIfError( mbUtils.SetDefaultMRMailBoxL( iMailBoxes[iDefMailbox].iEntryId ) ); |
|
1316 break; |
|
1317 } |
|
1318 ++enumValue; |
|
1319 } |
|
1320 } |
|
1321 } |
|
1322 CleanupStack::PopAndDestroy(); // implArray |
|
1323 } |
|
1324 } |
|
1325 |
|
1326 TRACE_EXIT_POINT; |
|
1327 } |
|
1328 |
|
1329 // ---------------------------------------------------------------------------- |
|
1330 // CCalenSettingsUiContainer::LoadMailboxSettingsL |
|
1331 // Loads the MR mailbox settings, if MR functionality is enabled. |
|
1332 // ---------------------------------------------------------------------------- |
|
1333 // |
|
1334 void CCalenSettingsUiContainer::LoadMailboxSettingsL() |
|
1335 { |
|
1336 TRACE_ENTRY_POINT; |
|
1337 |
|
1338 if( iGlobalData.InterimUtilsL().MRViewersEnabledL() ) |
|
1339 { |
|
1340 iHasSelectedMailbox = EFalse; |
|
1341 CMRMailboxUtils::TMailboxInfo defaultMailbox; |
|
1342 CMRMailboxUtils& mbUtils = iGlobalData.MRMailboxUtilsL(); |
|
1343 |
|
1344 ListMailboxesL( mbUtils, iMailBoxes ); |
|
1345 |
|
1346 TInt res = KErrNone; |
|
1347 TRAPD( err, res = mbUtils.GetDefaultMRMailBoxL( defaultMailbox ) ); |
|
1348 if( res == KErrNone && err == KErrNone ) |
|
1349 { |
|
1350 // Convert from the default mailbox to an enumeration. |
|
1351 for( TInt i=0; i<iMailBoxes.Count(); ++i ) |
|
1352 { |
|
1353 if( iMailBoxes[i].iEntryId == defaultMailbox.iEntryId ) |
|
1354 { |
|
1355 iDefMailbox = i; |
|
1356 iHasSelectedMailbox = ETrue; |
|
1357 break; |
|
1358 } |
|
1359 } |
|
1360 } |
|
1361 else if ( err != KErrNotFound || err != KErrGeneral ) |
|
1362 { |
|
1363 // KErrNotFound and KErrGeneral are thrown when no mailbox is selected. |
|
1364 // This is OK as iHasSelectedMailbox is EFalse, so we will show the blank option |
|
1365 // and allow the user to choose. Any other error needs to leave. |
|
1366 User::LeaveIfError( err ); |
|
1367 } |
|
1368 } |
|
1369 |
|
1370 TRACE_EXIT_POINT; |
|
1371 } |
|
1372 |
|
1373 #ifdef RD_CALEN_EXTERNAL_CAL |
|
1374 // ---------------------------------------------------------------------------- |
|
1375 // CCalenSettingViewDlg::ExtCalendarAvailableL() |
|
1376 // Return ETrue if we have service handler |
|
1377 // (other items were commented in a header). |
|
1378 // ---------------------------------------------------------------------------- |
|
1379 // |
|
1380 TBool CCalenSettingsUiContainer::ExtCalendarAvailableL() |
|
1381 { |
|
1382 TRACE_ENTRY_POINT; |
|
1383 |
|
1384 // Create service handler instance. |
|
1385 if ( !iServiceHandler ) |
|
1386 { |
|
1387 iServiceHandler = CAiwServiceHandler::NewL(); |
|
1388 } |
|
1389 |
|
1390 // create criteria item, this is used to specify which provider we are interested in. |
|
1391 CAiwCriteriaItem* crit = CAiwCriteriaItem::NewLC( ECalenExtAiwCommandId, |
|
1392 KAiwCmdView, |
|
1393 KContentTypeCalendar ); |
|
1394 |
|
1395 // we have a base service just for finding out if there is our provider available |
|
1396 // this should be fixed by AIW framework in the future so that we don't need extra service. |
|
1397 crit->SetServiceClass( TUid::Uid( KAiwClassBase ) ); |
|
1398 crit->SetMaxProviders( 1 ); |
|
1399 //crit->SetId(0x10282e42); |
|
1400 RCriteriaArray array; |
|
1401 array.Append( crit ); |
|
1402 // attach to the service provider if available, owenership of array is not transferred. |
|
1403 iServiceHandler->AttachL( array ); |
|
1404 |
|
1405 // if there is a provider here is count of suitable ones, if not it is zero |
|
1406 TInt num=iServiceHandler->NbrOfProviders( crit ); |
|
1407 |
|
1408 // if we detach, dll is unloaded, we don't want that as it is likely that we need it again. |
|
1409 // iServiceHandler->DetachL( array ); |
|
1410 array.ResetAndDestroy(); |
|
1411 CleanupStack::Pop( crit ); |
|
1412 |
|
1413 TBool res = EFalse; |
|
1414 |
|
1415 if ( num > 0 ) |
|
1416 { |
|
1417 res = ETrue; |
|
1418 } |
|
1419 |
|
1420 TRACE_EXIT_POINT; |
|
1421 return res; |
|
1422 } |
|
1423 |
|
1424 #endif //RD_CALEN_EXTERNAL_CAL |
|
1425 |
|
1426 // ---------------------------------------------------------------------------- |
|
1427 // CCalenSettingsUiContainer::PluginUidFinder |
|
1428 // Matches a uid and a plugin uid. Used by when finding a uid to match the |
|
1429 // setting's array against the customisation manager's array. |
|
1430 // (other items were commented in a header). |
|
1431 // ---------------------------------------------------------------------------- |
|
1432 // |
|
1433 TBool CCalenSettingsUiContainer::PluginUidFinder( const TUid* aUid, |
|
1434 const CImplementationInformation& aArrayItem ) |
|
1435 { |
|
1436 TRACE_ENTRY_POINT; |
|
1437 TRACE_EXIT_POINT; |
|
1438 return ( *aUid == aArrayItem.ImplementationUid() ); |
|
1439 } |
|
1440 |
|
1441 void CCalenSettingsUiContainer::HandlePluginChange() |
|
1442 { |
|
1443 TRACE_ENTRY_POINT; |
|
1444 |
|
1445 pluginAvail& pluginAvailablity = iSetting->PluginAvailability(); |
|
1446 for(TInt index = 0;index < pluginAvailablity.Count(); index++) |
|
1447 { |
|
1448 TRAP_IGNORE(iCustomisationManager.SetPluginAvailabilityL(pluginAvailablity[index].iUid, |
|
1449 pluginAvailablity[index].iEnabled)); |
|
1450 } |
|
1451 TRACE_EXIT_POINT; |
|
1452 } |
|
1453 |
|
1454 // End of file |
|
1455 |