|
1 /* |
|
2 * Copyright (c) 2007-2009 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 view manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aknViewAppUi.h> |
|
20 #include <centralrepository.h> |
|
21 #include <AknQueryDialog.h> |
|
22 #include <Calendar.rsg> |
|
23 #include <calencommonui.rsg> |
|
24 #include <akntoolbar.h> |
|
25 #include <calendateutils.h> |
|
26 #include <calencommandhandler.h> |
|
27 #include <calencommands.hrh> // Calendar commands |
|
28 #include <calentoolbar.h> |
|
29 #include <akntoolbarextension.h> |
|
30 #include <calenactionuiutils.h> |
|
31 |
|
32 #include "calendarui_debug.h" |
|
33 #include "calenviewmanager.h" |
|
34 #include "CalenUid.h" |
|
35 #include "calencontroller.h" |
|
36 #include "calenviewpopulator.h" |
|
37 #include "calenglobaldata.h" |
|
38 #include "CalendarPrivateCRKeys.h" // includes CalendarInternalCRKeys.h |
|
39 #include "calenmonthview.h" // Native month view |
|
40 #include "calenweekview.h" // Native week view |
|
41 #include "calendayview.h" // Native day view |
|
42 #include "calentodoview.h" // Native todo view |
|
43 #include "caleneventview.h" // Event View |
|
44 #include "calenmissedalarmsview.h" // Missed alarms view |
|
45 #include "calenmissedeventview.h" // Missed event view |
|
46 #include "calensetting.h" // CCalenSetting::TViewType |
|
47 #include "calencmdlinelauncher.h" // Command line launcher |
|
48 #include "calenservicesimpl.h" |
|
49 #include "CleanupResetAndDestroy.h" |
|
50 #include "calentoolbarimpl.h" |
|
51 #include "calencustomisationmanager.h" |
|
52 #include "calenviewinfo.h" |
|
53 #include "calentitlepane.h" |
|
54 #include "calenicons.h" |
|
55 #include "calendummyview.h" |
|
56 |
|
57 const TInt KArrayGranularity = 5; |
|
58 |
|
59 // ---------------------------------------------------------------------------- |
|
60 // CCalenViewManager::NewL |
|
61 // 1st phase of construction |
|
62 // (other items were commented in a header). |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 CCalenViewManager* CCalenViewManager::NewL( CAknViewAppUi& aAppUi, |
|
66 CCalenController& aController ) |
|
67 { |
|
68 TRACE_ENTRY_POINT; |
|
69 |
|
70 CCalenViewManager* self = new( ELeave ) CCalenViewManager( aAppUi,aController ); |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL(); |
|
73 CleanupStack::Pop( self ); |
|
74 |
|
75 TRACE_EXIT_POINT; |
|
76 return self; |
|
77 } |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // CCalenViewManager::CCalenViewManager |
|
81 // C++ default Constructor. |
|
82 // (other items were commented in a header). |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 CCalenViewManager::CCalenViewManager( CAknViewAppUi& aAppUi, |
|
86 CCalenController& aController ) |
|
87 : iAppUi( aAppUi ), iController( aController ) |
|
88 { |
|
89 TRACE_ENTRY_POINT; |
|
90 TRACE_EXIT_POINT; |
|
91 } |
|
92 |
|
93 // ---------------------------------------------------------------------------- |
|
94 // CCalenViewManager::~CCalenViewManager |
|
95 // Destructor. |
|
96 // (other items were commented in a header). |
|
97 // ---------------------------------------------------------------------------- |
|
98 // |
|
99 CCalenViewManager::~CCalenViewManager() |
|
100 { |
|
101 TRACE_ENTRY_POINT; |
|
102 |
|
103 delete iPopulator; |
|
104 delete iToolbar; |
|
105 |
|
106 if( iSetting ) |
|
107 { |
|
108 iSetting->Release(); |
|
109 } |
|
110 |
|
111 if( iGlobalData ) |
|
112 { |
|
113 iGlobalData->Release(); |
|
114 } |
|
115 |
|
116 iViewInfoArray.ResetAndDestroy(); |
|
117 iKnownPlugins.Reset(); |
|
118 |
|
119 delete iRemovedActiveView; |
|
120 delete iViewRemovalCallback; |
|
121 delete iIcons; |
|
122 |
|
123 TRACE_EXIT_POINT; |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------------------------------- |
|
127 // CCalenViewManager::ConstructL |
|
128 // 2nd phase of construction. |
|
129 // (other items were commented in a header). |
|
130 // ---------------------------------------------------------------------------- |
|
131 // |
|
132 void CCalenViewManager::ConstructL() |
|
133 { |
|
134 TRACE_ENTRY_POINT; |
|
135 |
|
136 iGlobalData = CCalenGlobalData::InstanceL(); |
|
137 iPopulator = CCalenViewPopulator::NewL( iController ); |
|
138 |
|
139 // Only create a toolbar impl if touch is enabled and a CAknToolbar exists |
|
140 if( AknLayoutUtils::PenEnabled() ) |
|
141 { |
|
142 CAknAppUi* appUi = static_cast<CAknAppUi*>( CEikonEnv::Static()->EikAppUi() ); |
|
143 if (appUi->CurrentFixedToolbar()) |
|
144 { |
|
145 iToolbar = CCalenToolbarImpl::NewL( iController ); |
|
146 } |
|
147 } |
|
148 |
|
149 iSetting = CCalenSetting::InstanceL(); |
|
150 iPreviousViewId.iViewUid = KNullUid; |
|
151 iAvoidRepopulation = EFalse; |
|
152 iStartupComplete = ETrue; |
|
153 |
|
154 TRACE_EXIT_POINT; |
|
155 } |
|
156 |
|
157 // ---------------------------------------------------------------------------- |
|
158 // CCalenViewManager::SetCustomisationManagerL |
|
159 // Creates custom views. |
|
160 // (other items were commented in a header). |
|
161 // ---------------------------------------------------------------------------- |
|
162 // |
|
163 void CCalenViewManager::ConstructCustomViewsL( |
|
164 CCalenCustomisationManager& aCustomisationManager ) |
|
165 { |
|
166 TRACE_ENTRY_POINT; |
|
167 |
|
168 iCustomisationManager = &aCustomisationManager; |
|
169 ConstructCustomViewsL(); |
|
170 ConstructNativeViewsL(); |
|
171 |
|
172 TUid defViewUid = iSetting->DefaultView(); |
|
173 ActivateDefaultViewL( defViewUid ); |
|
174 |
|
175 // Register for view activation events |
|
176 iAppUi.AddViewActivationObserverL( this ); |
|
177 |
|
178 TRACE_EXIT_POINT; |
|
179 } |
|
180 |
|
181 // ---------------------------------------------------------------------------- |
|
182 // CCalenViewManager::ViewInfoArray |
|
183 // Get info array |
|
184 // (other items were commented in a header). |
|
185 // ---------------------------------------------------------------------------- |
|
186 // |
|
187 RPointerArray<CCalenViewInfo>& CCalenViewManager::ViewInfoArray() |
|
188 { |
|
189 TRACE_ENTRY_POINT; |
|
190 TRACE_EXIT_POINT; |
|
191 return iViewInfoArray; |
|
192 } |
|
193 |
|
194 // ---------------------------------------------------------------------------- |
|
195 // CCalenViewManager::CustomiszationManager |
|
196 // Return reference to the customisation manager |
|
197 // (other items were commented in a header). |
|
198 // ---------------------------------------------------------------------------- |
|
199 // |
|
200 CCalenCustomisationManager& CCalenViewManager::CustomisationManager() |
|
201 { |
|
202 TRACE_ENTRY_POINT; |
|
203 |
|
204 ASSERT( iCustomisationManager ); |
|
205 |
|
206 TRACE_EXIT_POINT; |
|
207 return *iCustomisationManager; |
|
208 } |
|
209 |
|
210 // ---------------------------------------------------------------------------- |
|
211 // CCalenViewManager::ConstructNativeViewsL |
|
212 // Constructs the S60 native views and registers them with the view server |
|
213 // (other items were commented in a header). |
|
214 // ---------------------------------------------------------------------------- |
|
215 // |
|
216 void CCalenViewManager::ConstructNativeViewsL() |
|
217 { |
|
218 TRACE_ENTRY_POINT; |
|
219 |
|
220 CCalenTitlePane::NewAndSwapL(iAppUi.StatusPane()); |
|
221 MCalenServices& services = iController.Services(); |
|
222 |
|
223 |
|
224 // Add the native views for the todo view, week view, day view , month |
|
225 // view and event view unless they are already provided by custom views |
|
226 // in ROM.This is enforced by the customisation manager rejecting any |
|
227 // views that try to replace the native views but are not in ROM. |
|
228 |
|
229 if (CreateNativeViewL(KUidCalenMonthView)) |
|
230 { |
|
231 // Views take ownership of services object instantly. |
|
232 // No need for cleanup stack. |
|
233 CCalenMonthView* monthView = CCalenMonthView::NewL(services); |
|
234 AddNativeViewL(monthView); // takes ownership immediately. |
|
235 } |
|
236 |
|
237 if (CreateNativeViewL(KUidCalenWeekView)) |
|
238 { |
|
239 // Views take ownership of services object instantly. |
|
240 // No need for cleanup stack. |
|
241 CCalenWeekView* weekView = CCalenWeekView::NewL(services); |
|
242 AddNativeViewL(weekView); // takes ownership immediately. |
|
243 } |
|
244 |
|
245 if (CreateNativeViewL(KUidCalenDayView)) |
|
246 { |
|
247 // Views take ownership of services object instantly. |
|
248 // No need for cleanup stack. |
|
249 CCalenDayView* dayView = CCalenDayView::NewL(services); |
|
250 AddNativeViewL(dayView); // takes ownership immediately. |
|
251 } |
|
252 |
|
253 if (CreateNativeViewL(KUidCalenTodoView)) |
|
254 { |
|
255 // Views take ownership of services object instantly. |
|
256 // No need for cleanup stack. |
|
257 CCalenTodoView* todoView = CCalenTodoView::NewL(services); |
|
258 AddNativeViewL(todoView); // takes ownership immediately. |
|
259 } |
|
260 |
|
261 if( CreateNativeViewL(KUidCalenEventView)) |
|
262 { |
|
263 // Views take ownership of services object instantly. |
|
264 // No need for cleanup stack. |
|
265 CCalenEventView* eventView = CCalenEventView::NewL(services); |
|
266 AddNativeViewL(eventView); // takes ownership immediately. |
|
267 } |
|
268 |
|
269 if( CreateNativeViewL(KUidCalenMissedAlarmsView)) |
|
270 { |
|
271 // Views take ownership of services object instantly. |
|
272 // No need for cleanup stack. |
|
273 CCalenMissedAlarmsView* missedAlarmsView = CCalenMissedAlarmsView::NewL(services); |
|
274 AddNativeViewL(missedAlarmsView); // takes ownership immediately. |
|
275 } |
|
276 |
|
277 if( CreateNativeViewL(KUidCalenMissedEventView)) |
|
278 { |
|
279 // Views take ownership of services object instantly. |
|
280 // No need for cleanup stack. |
|
281 CCalenMissedEventView* missedEventView = CCalenMissedEventView::NewL(services); |
|
282 AddNativeViewL(missedEventView); // takes ownership immediately. |
|
283 } |
|
284 |
|
285 if(CreateNativeViewL(KUidCalenDummyView)) |
|
286 { |
|
287 CCalenDummyView* dummyView = CCalenDummyView::NewL(services); |
|
288 AddNativeViewL(dummyView); |
|
289 } |
|
290 TRACE_EXIT_POINT; |
|
291 } |
|
292 |
|
293 // ---------------------------------------------------------------------------- |
|
294 // CCalenViewManager::CreateNativeViewL |
|
295 // Checks to see if the native view needs to created. |
|
296 // (other items were commented in a header). |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 TBool CCalenViewManager::CreateNativeViewL(TUid aViewUid) |
|
300 { |
|
301 TRACE_ENTRY_POINT; |
|
302 |
|
303 TBool createNativeView = ETrue; |
|
304 TBool (*compareFn)(const TUid*, const CCalenViewInfo&) |
|
305 = CCalenViewInfo::ViewInfoIdentifier; |
|
306 |
|
307 TInt position = iViewInfoArray.Find( aViewUid, compareFn ); |
|
308 if ( position != KErrNotFound ) |
|
309 { |
|
310 // A plugin is trying to replace a native view, find if it is rom |
|
311 // based or not |
|
312 TBool romBased = CustomisationManager().IsViewRomBased( aViewUid ); |
|
313 if ( romBased ) |
|
314 { |
|
315 createNativeView = EFalse; |
|
316 } |
|
317 else |
|
318 { |
|
319 // A non-rom plugin cannot replace the native views, so the view is |
|
320 // removed |
|
321 iAppUi.RemoveView( aViewUid ); |
|
322 |
|
323 // Remove the entry from the view info array |
|
324 iViewInfoArray.Remove( position ); |
|
325 |
|
326 createNativeView = ETrue; |
|
327 } |
|
328 } |
|
329 |
|
330 TRACE_EXIT_POINT; |
|
331 return createNativeView; |
|
332 } |
|
333 |
|
334 // ---------------------------------------------------------------------------- |
|
335 // CCalenViewManager::ConstructCustomViewsL |
|
336 // Constructs any custom views from all the plugins and registers them |
|
337 // with the view server |
|
338 // (other items were commented in a header). |
|
339 // ---------------------------------------------------------------------------- |
|
340 // |
|
341 void CCalenViewManager::ConstructCustomViewsL() |
|
342 { |
|
343 TRACE_ENTRY_POINT; |
|
344 |
|
345 // Get the array of active plugins |
|
346 const RArray<TUid>& plugins = CustomisationManager().ActivePlugins(); |
|
347 |
|
348 // For every active plugin, discover if it offers any customised views |
|
349 // and adds them to the view server. |
|
350 TInt numPlugins = plugins.Count(); |
|
351 for( TInt pluginIndex( 0 ); pluginIndex < numPlugins; ++pluginIndex ) |
|
352 { |
|
353 TUid pluginUid = plugins[pluginIndex]; |
|
354 ConstructCustomViewL( pluginUid ); |
|
355 } |
|
356 |
|
357 TRACE_EXIT_POINT; |
|
358 } |
|
359 |
|
360 // ---------------------------------------------------------------------------- |
|
361 // CCalenViewManager::ConstructCustomViewsL |
|
362 // Constructs the custom views from a particular plugin and registers them |
|
363 // with the view server |
|
364 // (other items were commented in a header). |
|
365 // ---------------------------------------------------------------------------- |
|
366 // |
|
367 void CCalenViewManager::ConstructCustomViewL( TUid aPluginUid ) |
|
368 { |
|
369 TRACE_ENTRY_POINT; |
|
370 |
|
371 iKnownPlugins.AppendL( aPluginUid ); |
|
372 |
|
373 RPointerArray<CCalenView> customViews; |
|
374 CleanupResetAndDestroyPushL( customViews ); |
|
375 |
|
376 CustomisationManager().GetCustomViewsL( aPluginUid, customViews ); |
|
377 for( TInt viewIndex( customViews.Count()-1 ); viewIndex >= 0; --viewIndex ) |
|
378 { |
|
379 CCalenView* customView = customViews[viewIndex]; |
|
380 iAppUi.AddViewL( customView ); |
|
381 customViews.Remove( viewIndex ); |
|
382 } |
|
383 CleanupStack::PopAndDestroy(); // customViews |
|
384 |
|
385 TRACE_EXIT_POINT; |
|
386 } |
|
387 |
|
388 // ---------------------------------------------------------------------------- |
|
389 // CCalenViewManager::ActivateDefaultViewL |
|
390 // Activates the default view (retrieved from settings). |
|
391 // ---------------------------------------------------------------------------- |
|
392 // |
|
393 void CCalenViewManager::ActivateDefaultViewL( TUid aDefaultView ) |
|
394 { |
|
395 TRACE_ENTRY_POINT; |
|
396 |
|
397 // Find the default view in the view cycle list |
|
398 TInt position = iViewInfoArray.Find( |
|
399 aDefaultView, CCalenViewInfo::ViewInfoIdentifier ); |
|
400 if( position != KErrNotFound ) |
|
401 { |
|
402 iAppUi.SetDefaultViewL( *iAppUi.View( aDefaultView ) ); |
|
403 iViewCycleIndex = position; |
|
404 } |
|
405 else |
|
406 { |
|
407 CRepository* repository = CRepository::NewL( KCRUidCalendar ); |
|
408 CleanupStack::PushL(repository); |
|
409 TInt tmp( static_cast<TInt>( KUidCalenMonthView.iUid ) ); |
|
410 TInt position = iViewInfoArray.Find( KUidCalenMonthView, CCalenViewInfo::ViewInfoIdentifier ); |
|
411 User::LeaveIfError( repository->Set( KCalendarDefaultStartView, tmp ) ); |
|
412 iAppUi.SetDefaultViewL( *iAppUi.View( KUidCalenMonthView ) ); |
|
413 iViewCycleIndex = position; |
|
414 CleanupStack::PopAndDestroy(repository); |
|
415 } |
|
416 TRACE_EXIT_POINT; |
|
417 |
|
418 } |
|
419 |
|
420 // ---------------------------------------------------------------------------- |
|
421 // CCalenViewManager::InterruptPopulationL |
|
422 // Interrupts the population of the current view. When the editors are launched |
|
423 // the view population is interrupted as it will be repopulated when the |
|
424 // the editor closes. |
|
425 // ---------------------------------------------------------------------------- |
|
426 // |
|
427 void CCalenViewManager::InterruptPopulationL() |
|
428 { |
|
429 TRACE_ENTRY_POINT; |
|
430 |
|
431 // Cancel population of current view, if it's ongoing. |
|
432 iPopulator->InterruptPopulationL(); |
|
433 |
|
434 TRACE_EXIT_POINT; |
|
435 } |
|
436 |
|
437 // ---------------------------------------------------------------------------- |
|
438 // CCalenViewManager::RemoveCurrentViewFromMenu |
|
439 // Removes the current view from the cascading view switch menu |
|
440 // (other items were commented in a header). |
|
441 // ---------------------------------------------------------------------------- |
|
442 // |
|
443 void CCalenViewManager::RemoveCurrentViewFromMenu( CEikMenuPane* aMenuPane ) |
|
444 { |
|
445 TRACE_ENTRY_POINT; |
|
446 |
|
447 TUid uid = CurrentView(); |
|
448 |
|
449 if( uid == KUidCalenMonthView ) |
|
450 { |
|
451 aMenuPane->DeleteMenuItem( ECalenMonthView ); |
|
452 } |
|
453 else if( uid == KUidCalenWeekView ) |
|
454 { |
|
455 aMenuPane->DeleteMenuItem( ECalenWeekView ); |
|
456 } |
|
457 else if( uid == KUidCalenDayView ) |
|
458 { |
|
459 aMenuPane->DeleteMenuItem( ECalenDayView ); |
|
460 } |
|
461 else if( uid == KUidCalenTodoView ) |
|
462 { |
|
463 aMenuPane->DeleteMenuItem( ECalenTodoView ); |
|
464 } |
|
465 else |
|
466 { |
|
467 // Assert as this point should never be reached |
|
468 ASSERT( 0 ); |
|
469 } |
|
470 |
|
471 TRACE_EXIT_POINT; |
|
472 } |
|
473 |
|
474 // ---------------------------------------------------------------------------- |
|
475 // CCalenViewManager::AddNativeViewL |
|
476 // Adds a view to the array. |
|
477 // (other items were commented in a header). |
|
478 // ---------------------------------------------------------------------------- |
|
479 // |
|
480 void CCalenViewManager::AddNativeViewL( CCalenView* aView ) |
|
481 { |
|
482 TRACE_ENTRY_POINT; |
|
483 |
|
484 CleanupStack::PushL( aView ); |
|
485 iAppUi.AddViewL( aView ); |
|
486 CleanupStack::Pop( aView ); |
|
487 |
|
488 const TDesC& menuName = aView->LocalisedViewNameL( CCalenView::EMenuName ); |
|
489 const TDesC& settingsName = aView->LocalisedViewNameL( CCalenView::ESettingsName ); |
|
490 |
|
491 TUid viewUid = aView->Id(); |
|
492 |
|
493 |
|
494 CCalenViewInfo* viewInfo = CCalenViewInfo::NewL( aView->Id(), |
|
495 KUidCalendar, |
|
496 menuName, |
|
497 settingsName, |
|
498 aView->CyclePosition() ); |
|
499 |
|
500 // Discover if a native view has been hidden by a plugin. |
|
501 TBool hidden = iCustomisationManager->HiddenView( viewUid ); |
|
502 viewInfo->Hide( hidden ); |
|
503 |
|
504 // Append to view info array |
|
505 iViewInfoArray.InsertInOrderAllowRepeatsL( viewInfo, |
|
506 CCalenViewInfo::CyclePositionComparison ); |
|
507 |
|
508 TRACE_EXIT_POINT; |
|
509 } |
|
510 |
|
511 // ---------------------------------------------------------------------------- |
|
512 // CCalenViewManager::HandleCommandL |
|
513 // Handles view manager commands. |
|
514 // (other items were commented in a header). |
|
515 // ---------------------------------------------------------------------------- |
|
516 // |
|
517 TBool CCalenViewManager::HandleCommandL( const TCalenCommand& aCommand ) |
|
518 { |
|
519 TRACE_ENTRY_POINT; |
|
520 |
|
521 TBool commandUsed(EFalse); |
|
522 |
|
523 switch( aCommand.Command() ) |
|
524 { |
|
525 case ECalenMonthView: |
|
526 { |
|
527 RequestActivationL( KUidCalenMonthView ); |
|
528 } |
|
529 break; |
|
530 case ECalenWeekView: |
|
531 { |
|
532 RequestActivationL( KUidCalenWeekView ); |
|
533 } |
|
534 break; |
|
535 case ECalenDayView: |
|
536 { |
|
537 // reset the flag iForwardedToDayView as view switching is active |
|
538 if(iPreviousToDayView.iViewUid!=KNullUid) |
|
539 { |
|
540 iPreviousToDayView.iViewUid = KNullUid; |
|
541 } |
|
542 RequestActivationL( KUidCalenDayView, KCalenDummyUid, KNullDesC8() ); |
|
543 } |
|
544 break; |
|
545 case ECalenTodoView: |
|
546 { |
|
547 if (iAvoidRepopulation) |
|
548 { |
|
549 iAvoidRepopulation = EFalse; |
|
550 } |
|
551 RequestActivationL( KUidCalenTodoView ); |
|
552 } |
|
553 break; |
|
554 case ECalenEventView: |
|
555 { |
|
556 // Fix for EJCU-7LKC2C :: to prevent the display of blank view, |
|
557 // just set the iAvoidRepopulation to EFalse, |
|
558 // so that view is populated properly |
|
559 |
|
560 if (iAvoidRepopulation) |
|
561 { |
|
562 iAvoidRepopulation = EFalse; |
|
563 } |
|
564 |
|
565 RequestActivationL( KUidCalenEventView ); |
|
566 } |
|
567 break; |
|
568 case ECalenForwardsToDayView: |
|
569 { |
|
570 // set the view iPreviousToDayView to handle the day view's cba |
|
571 // when returning from event view. |
|
572 // From month/week view -> day view -> event view -> day view |
|
573 iPreviousToDayView = iCurrentViewId; |
|
574 RequestActivationL( KUidCalenDayView, KUidCalenShowBackCba ); |
|
575 } |
|
576 break; |
|
577 case ECalenNextView: |
|
578 { |
|
579 CycleNextViewL(); |
|
580 } |
|
581 break; |
|
582 case ECalenPrevView: |
|
583 { |
|
584 CyclePrevViewL(); |
|
585 } |
|
586 break; |
|
587 case ECalenSwitchView: |
|
588 { |
|
589 ShowSwitchViewQueryL(); |
|
590 } |
|
591 break; |
|
592 case ECalenStartActiveStep: |
|
593 { |
|
594 StartActiveStepL(); |
|
595 } |
|
596 break; |
|
597 case ECalenFasterAppExit: |
|
598 { |
|
599 HandleFasterAppExitCommandL(); |
|
600 } |
|
601 break; |
|
602 case ECalenGotoToday: |
|
603 { |
|
604 // get today's date |
|
605 TTime today = CalenDateUtils::Today(); |
|
606 |
|
607 // get the context |
|
608 MCalenContext& context = iController.Services().Context(); |
|
609 TCalTime todayCalTime; |
|
610 todayCalTime.SetTimeLocalL( today ); |
|
611 // set today's date to the context |
|
612 context.SetFocusDateAndTimeL( todayCalTime, iCurrentViewId ); |
|
613 |
|
614 SetRepopulation(EFalse); |
|
615 // reactivate the current view |
|
616 RequestActivationL(iCurrentViewId.iViewUid); |
|
617 |
|
618 // dim "today" toolbar item since focus is on today |
|
619 iToolbar->Toolbar().SetItemDimmed( ECalenGotoToday, ETrue, ETrue); |
|
620 } |
|
621 break; |
|
622 |
|
623 default: |
|
624 break; |
|
625 } |
|
626 |
|
627 TRACE_EXIT_POINT; |
|
628 return commandUsed; |
|
629 } |
|
630 |
|
631 // ---------------------------------------------------------------------------- |
|
632 // CCalenViewManager::CalenCommandHandlerExtensionL |
|
633 // Dummy implementation. |
|
634 // (other items were commented in a header). |
|
635 // ---------------------------------------------------------------------------- |
|
636 // |
|
637 TAny* CCalenViewManager::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ ) |
|
638 { |
|
639 TRACE_ENTRY_POINT; |
|
640 TRACE_EXIT_POINT; |
|
641 return NULL; |
|
642 } |
|
643 |
|
644 // ---------------------------------------------------------------------------- |
|
645 // CCalenViewManager::CurrentView |
|
646 // Returns the current view's view uid. |
|
647 // (other items were commented in a header). |
|
648 // ---------------------------------------------------------------------------- |
|
649 // |
|
650 TUid CCalenViewManager::CurrentView() const |
|
651 { |
|
652 TRACE_ENTRY_POINT; |
|
653 TRACE_EXIT_POINT; |
|
654 return iCurrentViewId.iViewUid; |
|
655 } |
|
656 |
|
657 // ---------------------------------------------------------------------------- |
|
658 // CCalenViewManager::HandleViewActivation |
|
659 // From MCoeViewActivationObserver |
|
660 // Called just before a view in this application is activated by the view server |
|
661 // (other items were commented in a header). |
|
662 // ---------------------------------------------------------------------------- |
|
663 // |
|
664 void CCalenViewManager::HandleViewActivation( const TVwsViewId& aNewlyActivatedViewId, |
|
665 const TVwsViewId& aViewIdToBeDeactivated ) |
|
666 { |
|
667 TRACE_ENTRY_POINT; |
|
668 |
|
669 TBool externalViewSwitch( EFalse ); |
|
670 // See if this is an internal or external view switch request |
|
671 if( aViewIdToBeDeactivated.iAppUid != KUidCalendar ) |
|
672 { |
|
673 externalViewSwitch = ETrue; |
|
674 } |
|
675 |
|
676 // If this is an internal view switch (view cycling from the '*' key) |
|
677 // then ActivateLocalViewL will handle any necessary state changes. |
|
678 // If this is an external view switch then we need to find out if Calendar was already |
|
679 // running or if it is being launched to a specific view by another application |
|
680 // calling ActivateViewL with Calendars UID and the UID of one of the standard views. |
|
681 // In this case we need to set the current view in the state or we would get the |
|
682 // default view (from the settings) activated instead of the requested view. |
|
683 if( externalViewSwitch ) |
|
684 { |
|
685 // Check that the view being activated belongs to Calendar. Although I don't see |
|
686 // how this would be called if this was false anyway. |
|
687 if( aNewlyActivatedViewId.iAppUid == KUidCalendar ) |
|
688 { |
|
689 // Make sure that any when any open dialogs are closed Calendar will not close as well. |
|
690 // This could be true if Calendar was originally launched directly to the editor, and |
|
691 // so should be closed when the dialog is closed. If an external view switch request |
|
692 // arrives, we want the dialog to close but Calendar to remain open. |
|
693 // Otherwise we get a CONE 44 panic. |
|
694 //iIsExitOnDlgClose = EFalse; |
|
695 |
|
696 iCurrentViewId = aNewlyActivatedViewId; |
|
697 } |
|
698 } |
|
699 |
|
700 iViewsActivated = ETrue; |
|
701 |
|
702 // check for iAvoidRepopulation to avoid repopulation whenever |
|
703 // 1) Application comes to foreground |
|
704 // 2) Applictaion is opened after fake exit |
|
705 if(!iAvoidRepopulation) |
|
706 { |
|
707 TRAPD(error,StartActiveStepL()); |
|
708 if(error!=KErrNone) |
|
709 { |
|
710 // do avoid warning |
|
711 } |
|
712 } |
|
713 |
|
714 // Reset the flag iAvoidRepopulation |
|
715 if (iAvoidRepopulation) |
|
716 { |
|
717 iAvoidRepopulation = EFalse; |
|
718 } |
|
719 TRACE_EXIT_POINT; |
|
720 } |
|
721 |
|
722 // ---------------------------------------------------------------------------- |
|
723 // CCalenViewManager::RemoveDeActivatedView |
|
724 // Asyncronous callback function to remove the current view after it has been |
|
725 // disabled. |
|
726 // (other items were commented in a header). |
|
727 // ---------------------------------------------------------------------------- |
|
728 // |
|
729 TInt CCalenViewManager::RemoveDeActivatedView( TAny* aObject ) |
|
730 { |
|
731 TRACE_ENTRY_POINT; |
|
732 |
|
733 CCalenViewManager* thisPtr( static_cast<CCalenViewManager*>( aObject ) ); |
|
734 TRAP_IGNORE( thisPtr->RemoveDeActivatedViewL() ); |
|
735 |
|
736 TRACE_EXIT_POINT; |
|
737 return 0; |
|
738 } |
|
739 |
|
740 // ---------------------------------------------------------------------------- |
|
741 // CCalenViewManager::RemoveDeActivatedViewL. |
|
742 // (Leaving version) |
|
743 // Asyncronous callback function to remove the current view after it has been |
|
744 // disabled. |
|
745 // (other items were commented in a header). |
|
746 // ---------------------------------------------------------------------------- |
|
747 // |
|
748 void CCalenViewManager::RemoveDeActivatedViewL() |
|
749 { |
|
750 TRACE_ENTRY_POINT; |
|
751 |
|
752 TUid removedViewUid = iRemovedActiveView->ViewUid(); |
|
753 TUid removedPluginUid = iRemovedActiveView->PluginUid(); |
|
754 |
|
755 // The view isn't the current view, so we |
|
756 // can remove it directly from the view server |
|
757 iAppUi.RemoveView( removedViewUid ); |
|
758 |
|
759 // Delete the view info |
|
760 delete iRemovedActiveView;; |
|
761 iRemovedActiveView = NULL; |
|
762 |
|
763 // Unload the plugin. |
|
764 RArray<TUid> pluginArray; |
|
765 CleanupClosePushL( pluginArray ); |
|
766 |
|
767 pluginArray.AppendL( removedPluginUid ); |
|
768 iCustomisationManager->UnloadPluginsL( pluginArray ); |
|
769 CleanupStack::PopAndDestroy(); // pluginArray |
|
770 |
|
771 if(!iController.IsFasterAppFlagEnabled()) |
|
772 { |
|
773 // Refresh the current view by simulating a settings close |
|
774 iController.BroadcastNotification( ECalenNotifySettingsClosed ); |
|
775 } |
|
776 else |
|
777 { |
|
778 iController.BroadcastNotification( ECalenNotifyCheckPluginUnloading ); |
|
779 } |
|
780 |
|
781 TRACE_EXIT_POINT; |
|
782 } |
|
783 |
|
784 // ---------------------------------------------------------------------------- |
|
785 // CCalenViewManager::CycleNextViewL |
|
786 // Requests activation for the next view in the view cycle |
|
787 // (other items were commented in a header). |
|
788 // ---------------------------------------------------------------------------- |
|
789 // |
|
790 void CCalenViewManager::CycleNextViewL() |
|
791 { |
|
792 TRACE_ENTRY_POINT; |
|
793 |
|
794 // Increment until we get to a valid view. |
|
795 do{ |
|
796 ++iViewCycleIndex; |
|
797 |
|
798 if( iViewCycleIndex >= iViewInfoArray.Count() ) |
|
799 { |
|
800 iViewCycleIndex = 0; |
|
801 } |
|
802 } |
|
803 while( iViewInfoArray[iViewCycleIndex]->CyclePosition() == CCalenView::ENoCyclePosition ); |
|
804 |
|
805 RequestActivationL( iViewInfoArray[iViewCycleIndex]->ViewUid() ); |
|
806 |
|
807 TRACE_EXIT_POINT; |
|
808 } |
|
809 |
|
810 // ---------------------------------------------------------------------------- |
|
811 // CCalenViewManager::CyclePrevViewL |
|
812 // Requests activation for the previous view in the view cycle |
|
813 // (other items were commented in a header). |
|
814 // ---------------------------------------------------------------------------- |
|
815 // |
|
816 void CCalenViewManager::CyclePrevViewL() |
|
817 { |
|
818 TRACE_ENTRY_POINT; |
|
819 |
|
820 // Decrement until we get to a valid view. |
|
821 do{ |
|
822 --iViewCycleIndex; |
|
823 |
|
824 if( iViewCycleIndex < 0 ) |
|
825 { |
|
826 iViewCycleIndex = iViewInfoArray.Count()-1; |
|
827 } |
|
828 } |
|
829 while ( iViewInfoArray[iViewCycleIndex]->CyclePosition() == CCalenView::ENoCyclePosition ); |
|
830 |
|
831 RequestActivationL( iViewInfoArray[iViewCycleIndex]->ViewUid() ); |
|
832 |
|
833 TRACE_EXIT_POINT; |
|
834 } |
|
835 |
|
836 // ---------------------------------------------------------------------------- |
|
837 // CCalenViewManager::RequestActivationL |
|
838 // Request activation of a specific view. |
|
839 // (other items were commented in a header). |
|
840 // ---------------------------------------------------------------------------- |
|
841 // |
|
842 void CCalenViewManager::RequestActivationL( const TVwsViewId& aViewId ) |
|
843 { |
|
844 TRACE_ENTRY_POINT; |
|
845 |
|
846 RequestActivationL( aViewId.iViewUid ); |
|
847 |
|
848 TRACE_EXIT_POINT; |
|
849 } |
|
850 |
|
851 // ---------------------------------------------------------------------------- |
|
852 // CCalenViewManager::RequestActivationL |
|
853 // Call this to try to activate a view |
|
854 // (other items were commented in a header). |
|
855 // ---------------------------------------------------------------------------- |
|
856 // |
|
857 void CCalenViewManager::RequestActivationL( const TUid& aViewUid, |
|
858 const TUid& aMessageId, |
|
859 const TDesC8& aMessage ) |
|
860 { |
|
861 TRACE_ENTRY_POINT; |
|
862 |
|
863 // Cancel population of current view, if it's ongoing. |
|
864 iPopulator->InterruptPopulationL(); |
|
865 // We start population of the newly activated view in HandleViewActivationL. |
|
866 |
|
867 // cache the previousviewid as we are getting aViewUid as reference. |
|
868 TUid cachePreviousViewId = iCurrentViewId.iViewUid; |
|
869 |
|
870 iCurrentViewId.iViewUid = aViewUid; |
|
871 // Update the view cycle index as iViewInfoArray would have changed |
|
872 iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, |
|
873 CCalenViewInfo::ViewInfoIdentifier ); |
|
874 |
|
875 if( iController.IsFasterAppFlagEnabled() ) |
|
876 { |
|
877 // Leave the application in background |
|
878 iAppUi.HideInBackground(); |
|
879 // Disable bring-to-foreground on view activation |
|
880 iAppUi.SetCustomControl(1); |
|
881 |
|
882 // activate the view |
|
883 iAppUi.ActivateLocalViewL( aViewUid, KCalenHideInBackGround, KNullDesC8() ); |
|
884 |
|
885 // Enable bring-to-foreground on view activation. |
|
886 iAppUi.SetCustomControl(0); |
|
887 } |
|
888 else |
|
889 { |
|
890 iAppUi.ActivateLocalViewL( aViewUid, aMessageId, aMessage ); |
|
891 } |
|
892 |
|
893 // set the previous view id |
|
894 iPreviousViewId.iViewUid = cachePreviousViewId; |
|
895 |
|
896 TRACE_EXIT_POINT; |
|
897 } |
|
898 |
|
899 // ---------------------------------------------------------------------------- |
|
900 // CCalenViewManager::StartActiveStepL |
|
901 // Starts population of the current view. |
|
902 // ---------------------------------------------------------------------------- |
|
903 // |
|
904 void CCalenViewManager::StartActiveStepL() |
|
905 { |
|
906 TRACE_ENTRY_POINT; |
|
907 |
|
908 // check for current viewid |
|
909 // populate the view only if iCurrentViewId is set |
|
910 if(iCurrentViewId.iViewUid != KNullUid) |
|
911 { |
|
912 iPopulator->InterruptPopulationL(); |
|
913 iPopulator->BeginPopulationL(reinterpret_cast<CCalenView*>(iAppUi.View(CurrentView()))); |
|
914 } |
|
915 |
|
916 TRACE_EXIT_POINT; |
|
917 } |
|
918 |
|
919 // ---------------------------------------------------------------------------- |
|
920 // CCalenViewManager::ShowSwitchViewQueryL |
|
921 // Prompts the user to chose a view to switch to. If cancelled, returns |
|
922 // KErrCancel, otherwise one of ECalen*view. |
|
923 // (other items were commented in a header). |
|
924 // ---------------------------------------------------------------------------- |
|
925 // |
|
926 void CCalenViewManager::ShowSwitchViewQueryL() |
|
927 { |
|
928 TRACE_ENTRY_POINT; |
|
929 |
|
930 // Create list of view names and uids |
|
931 CDesCArrayFlat* viewNames = new( ELeave ) CDesCArrayFlat( KArrayGranularity ); |
|
932 CleanupStack::PushL( viewNames ); |
|
933 |
|
934 RArray<TUid> viewUids; |
|
935 CleanupClosePushL( viewUids ); |
|
936 |
|
937 const RArray<TUid>& activePlugins = CustomisationManager().ActivePlugins(); |
|
938 |
|
939 for( TInt index( 0 ); index < iViewInfoArray.Count(); ++index ) |
|
940 { |
|
941 CCalenViewInfo& viewInfo = *( iViewInfoArray[index] ); |
|
942 if( index != iViewCycleIndex ) |
|
943 { |
|
944 TUid pluginUid = viewInfo.PluginUid(); |
|
945 TInt position = activePlugins.Find( pluginUid ); |
|
946 |
|
947 // If the view is from plugin or native view with cycle position, |
|
948 // then add it to the switch view list |
|
949 if(( position != KErrNotFound ) || |
|
950 ( viewInfo.CyclePosition() != CCalenView::ENoCyclePosition )) |
|
951 { |
|
952 // Fetch the view name |
|
953 TUid viewUid = viewInfo.ViewUid(); |
|
954 const TDesC& viewName = viewInfo.MenuName(); |
|
955 viewNames->AppendL( viewName ); |
|
956 viewUids.AppendL(viewUid ); |
|
957 } |
|
958 } |
|
959 } |
|
960 |
|
961 // Show list query. |
|
962 TInt choice = KErrCancel; //KErrNotFound; |
|
963 CAknListQueryDialog* dlg = new( ELeave ) CAknListQueryDialog( &choice ); |
|
964 dlg->PrepareLC( R_CALENDAR_SWITCH_VIEW_QUERY ); // pushes dlg to CS |
|
965 dlg->SetItemTextArray( viewNames ); |
|
966 dlg->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
967 |
|
968 // Set title |
|
969 CAknPopupHeadingPane* heading = dlg->Heading(); |
|
970 HBufC* title = NULL; |
|
971 title = CCoeEnv::Static()->AllocReadResourceLC( R_CALENDAR_SWITCH_VIEW_QUERY_TITLE ); |
|
972 heading->SetTextL( *title ); |
|
973 CleanupStack::PopAndDestroy( title ); |
|
974 |
|
975 if( dlg->RunLD() ) |
|
976 { |
|
977 // user made a choice |
|
978 TUid viewUid = viewUids[choice]; |
|
979 RequestActivationL( viewUid ); |
|
980 } |
|
981 |
|
982 CleanupStack::PopAndDestroy(); // viewUids |
|
983 CleanupStack::PopAndDestroy( viewNames ); |
|
984 |
|
985 TRACE_EXIT_POINT; |
|
986 } |
|
987 |
|
988 // ---------------------------------------------------------------------------- |
|
989 // CCalenViewManager::HandleNotification |
|
990 // Calls back when notifications that it has been registered for are broadcast |
|
991 // (other items were commented in a header). |
|
992 // ---------------------------------------------------------------------------- |
|
993 // |
|
994 void CCalenViewManager::HandleNotification(const TCalenNotification aNotification ) |
|
995 { |
|
996 TRACE_ENTRY_POINT; |
|
997 |
|
998 PIM_TRAPD_HANDLE( HandleNotificationL( aNotification ) ); |
|
999 |
|
1000 TRACE_EXIT_POINT; |
|
1001 } |
|
1002 |
|
1003 // ---------------------------------------------------------------------------- |
|
1004 // CCalenViewManager::HandleNotificationL |
|
1005 // Called from HandleNotification() when notifications that it has been |
|
1006 // registered for are broadcast |
|
1007 // (other items were commented in a header). |
|
1008 // ---------------------------------------------------------------------------- |
|
1009 // |
|
1010 void CCalenViewManager::HandleNotificationL( TCalenNotification aNotification ) |
|
1011 { |
|
1012 TRACE_ENTRY_POINT; |
|
1013 |
|
1014 switch( aNotification ) |
|
1015 { |
|
1016 case ECalenNotifyPluginEnabledDisabled: |
|
1017 { |
|
1018 UpdatePluginListL(); |
|
1019 } |
|
1020 break; |
|
1021 case ECalenNotifySettingsClosed: |
|
1022 { |
|
1023 // Nothing has changed, refresh statuspane only. |
|
1024 iAppUi.StatusPane()->DrawNow(); |
|
1025 } |
|
1026 break; |
|
1027 case ECalenNotifySettingsChanged: |
|
1028 { |
|
1029 HandleSettingsChangeNotificationL(); |
|
1030 } |
|
1031 break; |
|
1032 case ECalenNotifyEntryDeleted: |
|
1033 case ECalenNotifyInstanceDeleted: |
|
1034 { |
|
1035 HandleEntryDeleteNotificationL(); |
|
1036 } |
|
1037 break; |
|
1038 case ECalenNotifySystemLocaleChanged: |
|
1039 case ECalenNotifyEntrySaved: |
|
1040 case ECalenNotifyMultipleEntriesDeleted: |
|
1041 case ECalenNotifyExternalDatabaseChanged: |
|
1042 case ECalenNotifyCancelDelete: |
|
1043 case ECalenNotifyCalendarFieldChanged: |
|
1044 case ECalenNotifyMarkedEntryCompleted: |
|
1045 case ECalenNotifyCalendarInfoCreated: |
|
1046 case ECalenNotifyCalendarInfoUpdated: |
|
1047 { |
|
1048 StartActiveStepL(); |
|
1049 } |
|
1050 break; |
|
1051 case ECalenNotifyCalendarFileDeleted: |
|
1052 { |
|
1053 if(iCurrentViewId.iViewUid==KUidCalenEventView) |
|
1054 { |
|
1055 //If the entry which is being viewed belongs to a calendar |
|
1056 //that is deleted we check for collection ids of entry and |
|
1057 //calendar session if they are same return to previous view |
|
1058 TPtrC calFileName = iGlobalData->Context().GetCalendarFileNameL(); |
|
1059 TPtrC calFileNameForColId = |
|
1060 iGlobalData->GetCalFileNameForCollectionId(iGlobalData->Context().InstanceId().iColId); |
|
1061 if(!calFileNameForColId.CompareF(calFileName)) |
|
1062 { |
|
1063 ActivateDefaultViewL(iPreviousToDayView.iViewUid); |
|
1064 } |
|
1065 } |
|
1066 else |
|
1067 { |
|
1068 // refresh the current view |
|
1069 StartActiveStepL(); |
|
1070 } |
|
1071 } |
|
1072 break; |
|
1073 case ECalenNotifyEntryClosed: |
|
1074 { |
|
1075 HandleEntryClosedNotificationL(); |
|
1076 } |
|
1077 break; |
|
1078 case ECalenNotifySystemTimeChanged: |
|
1079 { |
|
1080 HandleSystemTimeChangeNotificationL(); |
|
1081 } |
|
1082 break; |
|
1083 case ECalenNotifyAppForegrounded: |
|
1084 { |
|
1085 // check for system time change whenever fake exit is done |
|
1086 // or application comes to foreground |
|
1087 if(!iStartupComplete) |
|
1088 { |
|
1089 iController.CheckSystemTimeAtStartUpL(); |
|
1090 } |
|
1091 |
|
1092 if( iController.IsFasterAppFlagEnabled() ) |
|
1093 { |
|
1094 iAppUi.HideApplicationFromFSW(EFalse); |
|
1095 iController.SetFasterAppFlag( EFalse ); |
|
1096 |
|
1097 ReloadAllPluginsL(); |
|
1098 } |
|
1099 } |
|
1100 break; |
|
1101 case ECalenNotifyDayViewClosed: |
|
1102 { |
|
1103 if(iPreviousToDayView.iViewUid!= KNullUid) |
|
1104 { |
|
1105 // activate the previous view from where day view is launched |
|
1106 // From month/week view -> day view |
|
1107 RequestActivationL(iPreviousToDayView.iViewUid); |
|
1108 } |
|
1109 } |
|
1110 break; |
|
1111 case ECalenNotifyAppBackgrounded: |
|
1112 { |
|
1113 // set the flag iAvoidRepopulation to prevent repopulation |
|
1114 // whenever application is brought to foreground |
|
1115 iAvoidRepopulation = ETrue; |
|
1116 |
|
1117 if( iController.IsFasterAppFlagEnabled() ) |
|
1118 { |
|
1119 iController.RemoveDeadCalendarsL(); |
|
1120 } |
|
1121 } |
|
1122 break; |
|
1123 case ECalenNotifyViewPopulationComplete: |
|
1124 { |
|
1125 if(iStartupComplete) |
|
1126 { |
|
1127 iController.CheckSystemTimeAtStartUpL(); |
|
1128 iStartupComplete = EFalse; |
|
1129 } |
|
1130 break; |
|
1131 } |
|
1132 case ECalenNotifyAttachmentViewerClosed: |
|
1133 { |
|
1134 if( iCurrentViewId.iViewUid==KUidCalenEventView) |
|
1135 { |
|
1136 StartActiveStepL(); |
|
1137 } |
|
1138 } |
|
1139 case ECalenNotifyAttachmentRemoved: |
|
1140 case ECalenNotifyAttachmentAdded: |
|
1141 { |
|
1142 if( iCurrentViewId.iViewUid==KUidCalenEventView && |
|
1143 !iAvoidRepopulation ) |
|
1144 { |
|
1145 StartActiveStepL(); |
|
1146 } |
|
1147 } |
|
1148 case ECalenNotifyDeleteFailed: |
|
1149 // Do nothing on deletion failed |
|
1150 default: |
|
1151 break; |
|
1152 } |
|
1153 |
|
1154 TRACE_EXIT_POINT; |
|
1155 } |
|
1156 |
|
1157 // ---------------------------------------------------------------------------- |
|
1158 // CCalenViewManager::UpdatePluginListL |
|
1159 // Discovers if a plugin has been enabled or disabled |
|
1160 // (other items were commented in a header). |
|
1161 // ---------------------------------------------------------------------------- |
|
1162 // |
|
1163 void CCalenViewManager::UpdatePluginListL() |
|
1164 { |
|
1165 TRACE_ENTRY_POINT; |
|
1166 |
|
1167 const RArray<TUid>& activePlugins = CustomisationManager().ActivePlugins(); |
|
1168 |
|
1169 // Check for any new plugins |
|
1170 TInt activeCount = activePlugins.Count(); |
|
1171 for( TInt index( 0 ); index < activeCount; ++index ) |
|
1172 { |
|
1173 // For every active plugin, check to see if it is in the known list, |
|
1174 // if it isn't construct any custom views. |
|
1175 TUid pluginUid = activePlugins[index]; |
|
1176 TInt position = iKnownPlugins.Find( pluginUid ); |
|
1177 if( position == KErrNotFound ) |
|
1178 { |
|
1179 ConstructCustomViewL( pluginUid ); |
|
1180 } |
|
1181 } |
|
1182 |
|
1183 RArray<TUid> disabledPlugins; |
|
1184 CleanupClosePushL( disabledPlugins ); |
|
1185 |
|
1186 // Check for any disabled plugins |
|
1187 TInt knownCount = iKnownPlugins.Count(); |
|
1188 for( TInt index( knownCount - 1 ); index >= 0; --index ) |
|
1189 { |
|
1190 // For every known plugin, check to see if it is in the active list, |
|
1191 // if it isn't add to the disable plugin list, and remove from the |
|
1192 // known list. |
|
1193 TUid pluginUid = iKnownPlugins[index]; |
|
1194 TInt position = activePlugins.Find( pluginUid ); |
|
1195 if ( position == KErrNotFound ) |
|
1196 { |
|
1197 disabledPlugins.AppendL( pluginUid ); |
|
1198 iKnownPlugins.Remove( index ); |
|
1199 } |
|
1200 } |
|
1201 |
|
1202 TInt disabledPluginCount = disabledPlugins.Count(); |
|
1203 if( disabledPluginCount != 0 ) |
|
1204 { |
|
1205 RemoveDisabledPluginsViewsL( disabledPlugins ); |
|
1206 // Re sort the view info array |
|
1207 iViewInfoArray.Sort( CCalenViewInfo::CyclePositionComparison ); |
|
1208 } |
|
1209 else |
|
1210 { |
|
1211 // Update the view cycle index as iViewInfoArray would have changed |
|
1212 iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1213 } |
|
1214 UpdateToolbarNextViewIconL(iCurrentViewId.iViewUid); |
|
1215 |
|
1216 CleanupStack::PopAndDestroy(); // disabledPlugins |
|
1217 TRACE_EXIT_POINT; |
|
1218 } |
|
1219 |
|
1220 // ---------------------------------------------------------------------------- |
|
1221 // CCalenViewManager::RemoveDisabledPluginsViewsL |
|
1222 // Removes any custom views provided by disabled plugins |
|
1223 // from the view server. |
|
1224 // (other items were commented in a header). |
|
1225 // ---------------------------------------------------------------------------- |
|
1226 // |
|
1227 void CCalenViewManager::RemoveDisabledPluginsViewsL( RArray<TUid>& aDisabledPlugins ) |
|
1228 { |
|
1229 TRACE_ENTRY_POINT; |
|
1230 |
|
1231 // Find what views are provided by the disabled plugins |
|
1232 TInt disabledPluginCount = aDisabledPlugins.Count(); |
|
1233 RArray<TUid> removedViews; |
|
1234 CleanupClosePushL( removedViews ); |
|
1235 |
|
1236 TUid activeViewUid = CurrentView(); |
|
1237 |
|
1238 for( TInt index( disabledPluginCount - 1 ); index >= 0; --index ) |
|
1239 { |
|
1240 TUid pluginUid = aDisabledPlugins[index]; |
|
1241 |
|
1242 // Does this plugin offer any views |
|
1243 TInt position = iViewInfoArray.Find( pluginUid, |
|
1244 CCalenViewInfo::ViewPluginIdentifier ); |
|
1245 TBool alreadySet = EFalse; |
|
1246 while( position != KErrNotFound ) |
|
1247 { |
|
1248 CCalenViewInfo* view = iViewInfoArray[position]; |
|
1249 TUid viewUid = view->ViewUid(); |
|
1250 |
|
1251 // Remove from the view cycle list |
|
1252 iViewInfoArray.Remove( position ); |
|
1253 |
|
1254 RArray<TInt> hiddenViews; |
|
1255 iCustomisationManager->GetHiddenViewIdL(pluginUid, hiddenViews); |
|
1256 |
|
1257 if( viewUid == activeViewUid ) |
|
1258 { |
|
1259 // Removing the active view is done in three parts |
|
1260 // 1) It is removed from the viewInfo list |
|
1261 // 2) When settings is closed, the view is switched |
|
1262 // to the next view in the view cycle list. |
|
1263 // 3) When the view is deactivated it can be deleted. |
|
1264 |
|
1265 // Store the information about the current view. |
|
1266 iRemovedActiveView = view; |
|
1267 |
|
1268 // Update the view cycle index so that hidden view is launched while cycling next view |
|
1269 if(hiddenViews.Count()) |
|
1270 { |
|
1271 // Find the index of teh hidden view |
|
1272 TInt viewInfoIndex = iViewInfoArray.Find(TUid::Uid(hiddenViews[0]), CCalenViewInfo::ViewInfoIdentifier); |
|
1273 iViewCycleIndex = viewInfoIndex - 1; // Decrementing it as CycleNextView() funciton will increment it |
|
1274 } |
|
1275 else if(!alreadySet) |
|
1276 { |
|
1277 TInt nextViewCycleIndex = iViewCycleIndex - 1; // To update the view cycle index in plugin disable case |
|
1278 |
|
1279 // Update the view cycle index as iViewInfoArray would have changed |
|
1280 iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1281 |
|
1282 // If the current active view has been removed, |
|
1283 if(iViewCycleIndex == -1) |
|
1284 { |
|
1285 iViewCycleIndex = nextViewCycleIndex; |
|
1286 } |
|
1287 alreadySet = ETrue; |
|
1288 } |
|
1289 |
|
1290 hiddenViews.Reset(); |
|
1291 // Remove the plugin from the disabled plugin list |
|
1292 // to stop the plugin being deleted. |
|
1293 aDisabledPlugins.Remove( index ); |
|
1294 } |
|
1295 else |
|
1296 { |
|
1297 // The view isn't the current view, so we |
|
1298 // can remove it directly from the view server |
|
1299 iAppUi.RemoveView( viewUid ); |
|
1300 |
|
1301 // Delete the view info |
|
1302 delete view; |
|
1303 if(!alreadySet) |
|
1304 { |
|
1305 TInt nextViewCycleIndex = iViewCycleIndex - 1; // To update the view cycle index in plugin disable case |
|
1306 |
|
1307 // Update the view cycle index as iViewInfoArray would have changed |
|
1308 iViewCycleIndex = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1309 |
|
1310 // If the current active view has been removed, |
|
1311 if(iViewCycleIndex == -1) |
|
1312 { |
|
1313 iViewCycleIndex = nextViewCycleIndex; |
|
1314 } |
|
1315 alreadySet = ETrue; |
|
1316 } |
|
1317 |
|
1318 } |
|
1319 |
|
1320 position = iViewInfoArray.Find( pluginUid, |
|
1321 CCalenViewInfo::ViewPluginIdentifier ); |
|
1322 } |
|
1323 } |
|
1324 |
|
1325 // Unload the disabled plugins |
|
1326 iCustomisationManager->UnloadPluginsL( aDisabledPlugins ); |
|
1327 |
|
1328 CleanupStack::PopAndDestroy(); // removedViews |
|
1329 |
|
1330 TRACE_EXIT_POINT; |
|
1331 } |
|
1332 |
|
1333 // ---------------------------------------------------------------------------- |
|
1334 // CCalenViewManager::ToolbarOrNull |
|
1335 // Provides access to the calendar toolbar if one is available |
|
1336 // ---------------------------------------------------------------------------- |
|
1337 MCalenToolbar* CCalenViewManager::ToolbarOrNull() |
|
1338 { |
|
1339 TRACE_ENTRY_POINT; |
|
1340 TRACE_EXIT_POINT; |
|
1341 return iToolbar; |
|
1342 } |
|
1343 |
|
1344 // ---------------------------------------------------------------------------- |
|
1345 // CCalenViewManager::ViewsActivated |
|
1346 // Returns if the first view activation on start-up has taken place |
|
1347 // ---------------------------------------------------------------------------- |
|
1348 TBool CCalenViewManager::ViewsActivated() const |
|
1349 { |
|
1350 TRACE_ENTRY_POINT; |
|
1351 TRACE_EXIT_POINT; |
|
1352 return iViewsActivated; |
|
1353 } |
|
1354 |
|
1355 // ---------------------------------------------------------------------------- |
|
1356 // CCalenViewManager::UpdateToolbarNextViewIconL |
|
1357 // Updates the nextview icon on the toolbar when default view is not month view |
|
1358 // ---------------------------------------------------------------------------- |
|
1359 void CCalenViewManager::UpdateToolbarNextViewIconL(TUid aViewUid) |
|
1360 { |
|
1361 // Set the view cycle index based on the newly activated view, |
|
1362 // if the view is in the cycle array. |
|
1363 TInt index = iViewInfoArray.Find( aViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1364 if( index != KErrNotFound ) |
|
1365 { |
|
1366 iViewCycleIndex = index; |
|
1367 if( iToolbar ) |
|
1368 { |
|
1369 TInt nextVwIndex = iViewCycleIndex; |
|
1370 do{ |
|
1371 nextVwIndex = ( nextVwIndex + 1 )%(iViewInfoArray.Count()); |
|
1372 } |
|
1373 while( iViewInfoArray[nextVwIndex]->CyclePosition() == CCalenView::ENoCyclePosition ); |
|
1374 |
|
1375 CCalenView* nextview = static_cast<CCalenView*>( |
|
1376 iAppUi.View( iViewInfoArray[nextVwIndex]->ViewUid() ) ); |
|
1377 iToolbar->SetNextViewIcon( nextview->ViewIconL() ); |
|
1378 } |
|
1379 } |
|
1380 } |
|
1381 |
|
1382 // ---------------------------------------------------------------------------- |
|
1383 // CCalenViewManager::HandleFasterAppExitCommandL |
|
1384 // Handles ECalenFasterAppExit command |
|
1385 // ---------------------------------------------------------------------------- |
|
1386 void CCalenViewManager::HandleFasterAppExitCommandL() |
|
1387 { |
|
1388 TRACE_ENTRY_POINT; |
|
1389 |
|
1390 if(iToolbar) |
|
1391 { |
|
1392 iToolbar->SetToolbarExtensionFocus(EFalse); |
|
1393 } |
|
1394 |
|
1395 // For Handling : When the default view is changed keeping that view open, |
|
1396 // from day view changing the default view from month view to day view, |
|
1397 // we need to reset the previous view id. |
|
1398 if(iPreviousToDayView.iViewUid!=KNullUid) |
|
1399 { |
|
1400 iPreviousToDayView.iViewUid = KNullUid; |
|
1401 } |
|
1402 |
|
1403 // For handling specific case::Calendar exited from FSW |
|
1404 // iAvoidRepopulation is set when app backgrounded. |
|
1405 // Reset the flag for activating the view in background |
|
1406 if(iAvoidRepopulation) |
|
1407 { |
|
1408 iAvoidRepopulation = EFalse; |
|
1409 } |
|
1410 |
|
1411 // In case of fasterapp exit, first activate the dummy view before deleting the plugin views |
|
1412 // Get the default view before we remove plugins |
|
1413 iPreviousViewId.iViewUid = KNullUid; |
|
1414 |
|
1415 iController.SetExitOnDialogFlag( EFalse ); // for making iisexitondialogclose EFalse. |
|
1416 |
|
1417 TUid defView = iSetting->DefaultView(); |
|
1418 |
|
1419 // unload all plugins |
|
1420 iCustomisationManager->DisableAllPluginsL(); |
|
1421 ActivateViewOnFakeExitL(defView); |
|
1422 // Though the current view is active view, there is no need to issue a callback as we are exiting the whole application. |
|
1423 if( iRemovedActiveView ) |
|
1424 { |
|
1425 |
|
1426 if( !iViewRemovalCallback ) |
|
1427 { |
|
1428 TCallBack callback( RemoveDeActivatedView, this ); |
|
1429 iViewRemovalCallback = new( ELeave ) CAsyncCallBack( callback, |
|
1430 CActive::EPriorityStandard ); |
|
1431 } |
|
1432 iViewRemovalCallback->CallBack(); |
|
1433 } |
|
1434 |
|
1435 TRACE_EXIT_POINT; |
|
1436 } |
|
1437 // ---------------------------------------------------------------------------- |
|
1438 // CCalenViewManager::HandleSettingsChangeNotificationL |
|
1439 // Handles ECalenNotifySettingsChanged notification |
|
1440 // ---------------------------------------------------------------------------- |
|
1441 void CCalenViewManager::HandleSettingsChangeNotificationL() |
|
1442 { |
|
1443 TRACE_ENTRY_POINT; |
|
1444 |
|
1445 if( iController.IsFasterAppFlagEnabled() ) |
|
1446 { |
|
1447 TUid newViewUid = iSetting->DefaultView(); |
|
1448 if(IsNativeView(newViewUid)) |
|
1449 { |
|
1450 TUid oldViewUid = CurrentView(); |
|
1451 if( newViewUid.iUid != oldViewUid.iUid ) |
|
1452 { |
|
1453 RequestActivationL( newViewUid ); |
|
1454 } |
|
1455 } |
|
1456 |
|
1457 // If the plugins are activated using general settings. |
|
1458 // unload all plugins.Only load the plugins when application |
|
1459 // comes to foreground |
|
1460 const RArray<TUid>& plugins = CustomisationManager().ActivePlugins(); |
|
1461 if(plugins.Count()) |
|
1462 { |
|
1463 // unload all plugins |
|
1464 iCustomisationManager->DisableAllPluginsL(); |
|
1465 } |
|
1466 } |
|
1467 |
|
1468 if( iRemovedActiveView ) |
|
1469 { |
|
1470 // If the active view has been disabled, the next view in |
|
1471 // the view cycle list is activated and the current view |
|
1472 // is removed asyncronously. |
|
1473 CycleNextViewL(); |
|
1474 |
|
1475 if( !iViewRemovalCallback ) |
|
1476 { |
|
1477 TCallBack callback( RemoveDeActivatedView, this ); |
|
1478 iViewRemovalCallback = new( ELeave ) CAsyncCallBack( callback, |
|
1479 CActive::EPriorityStandard ); |
|
1480 } |
|
1481 |
|
1482 iViewRemovalCallback->CallBack(); |
|
1483 } |
|
1484 else if(iCustomisationManager->HiddenView(iCurrentViewId.iViewUid)) |
|
1485 { |
|
1486 // Get the uid of the plugin view that is hiding the current view |
|
1487 TUid viewUid = iCustomisationManager->GetReplacePluginViewIdL(iCurrentViewId.iViewUid); |
|
1488 |
|
1489 // update the view cycle index before activating the plugin view |
|
1490 iViewCycleIndex = iViewInfoArray.Find( viewUid, |
|
1491 CCalenViewInfo::ViewInfoIdentifier ); |
|
1492 RequestActivationL(viewUid); |
|
1493 } |
|
1494 else |
|
1495 { |
|
1496 StartActiveStepL(); |
|
1497 } |
|
1498 |
|
1499 TRACE_EXIT_POINT; |
|
1500 } |
|
1501 |
|
1502 // ---------------------------------------------------------------------------- |
|
1503 // CCalenViewManager::HandleEntryDeleteNotificationL |
|
1504 // Handles ECalenNotifyEntryDeleted and ECalenNotifyInstanceDeleted |
|
1505 // notifications |
|
1506 // ---------------------------------------------------------------------------- |
|
1507 void CCalenViewManager::HandleEntryDeleteNotificationL() |
|
1508 { |
|
1509 TRACE_ENTRY_POINT; |
|
1510 |
|
1511 if(iCurrentViewId.iViewUid == KUidCalenEventView) |
|
1512 { |
|
1513 // Activate the previous view when an event is deleted from |
|
1514 // the event view |
|
1515 if(iPreviousViewId.iViewUid != KNullUid) |
|
1516 { |
|
1517 RequestActivationL(iPreviousViewId.iViewUid); |
|
1518 } |
|
1519 } |
|
1520 else |
|
1521 { |
|
1522 // refresh the current view |
|
1523 StartActiveStepL(); |
|
1524 } |
|
1525 |
|
1526 TRACE_EXIT_POINT; |
|
1527 } |
|
1528 |
|
1529 // ---------------------------------------------------------------------------- |
|
1530 // CCalenViewManager::HandleEntryClosedNotificationL |
|
1531 // Handles ECalenNotifyEntryClosed notification |
|
1532 // ---------------------------------------------------------------------------- |
|
1533 void CCalenViewManager::HandleEntryClosedNotificationL() |
|
1534 { |
|
1535 TRACE_ENTRY_POINT; |
|
1536 |
|
1537 // reset tha flag iAvoidRepopulation to refresh the view. |
|
1538 iAvoidRepopulation = EFalse; |
|
1539 |
|
1540 // if previous view is native view activate that view |
|
1541 // otherwise commandlauncher will handle |
|
1542 if(iPreviousViewId.iViewUid != KNullUid) |
|
1543 { |
|
1544 // if iPreviousToDayView is active activate the day view with "Back" cba. |
|
1545 if(iPreviousToDayView.iViewUid!=KNullUid) |
|
1546 { |
|
1547 RequestActivationL(iPreviousViewId.iViewUid, KUidCalenShowBackCba); |
|
1548 } |
|
1549 else |
|
1550 { |
|
1551 if( !iController.GetExitOnDialogFlag() ) |
|
1552 { |
|
1553 RequestActivationL(iPreviousViewId.iViewUid); |
|
1554 } |
|
1555 } |
|
1556 } |
|
1557 |
|
1558 // reset tha flag iAvoidRepopulation to avoid the repopulation. |
|
1559 iAvoidRepopulation = ETrue; |
|
1560 |
|
1561 TRACE_EXIT_POINT; |
|
1562 } |
|
1563 |
|
1564 // ---------------------------------------------------------------------------- |
|
1565 // CCalenViewManager::HandleSystemTimeChangeNotificationL |
|
1566 // Handles ECalenNotifySystemTimeChanged notification |
|
1567 // ---------------------------------------------------------------------------- |
|
1568 void CCalenViewManager::HandleSystemTimeChangeNotificationL() |
|
1569 { |
|
1570 TRACE_ENTRY_POINT; |
|
1571 |
|
1572 if( iController.IsFasterAppFlagEnabled() ) |
|
1573 { |
|
1574 //Set the context whenever system time is changed |
|
1575 TUid newViewUid = iSetting->DefaultView(); |
|
1576 MCalenContext& context = iController.Services().Context(); |
|
1577 TCalTime focusTime = context.DefaultCalTimeForViewsL(); |
|
1578 context.SetFocusDateAndTimeL( focusTime, |
|
1579 TVwsViewId( KUidCalendar, newViewUid )); |
|
1580 |
|
1581 // reset tha flag iAvoidRepopulation to refresh the view whenever |
|
1582 // system time is changed |
|
1583 iAvoidRepopulation = EFalse; |
|
1584 |
|
1585 if(IsNativeView(newViewUid)) |
|
1586 { |
|
1587 // activate the default view in background |
|
1588 RequestActivationL( newViewUid ); |
|
1589 } |
|
1590 |
|
1591 // set the flag iAvoidRepopulation to avoid repopulation |
|
1592 iAvoidRepopulation = ETrue; |
|
1593 } |
|
1594 else |
|
1595 { |
|
1596 // refresh the current view |
|
1597 StartActiveStepL(); |
|
1598 } |
|
1599 |
|
1600 TRACE_EXIT_POINT; |
|
1601 } |
|
1602 |
|
1603 // ----------------------------------------------------------------------------- |
|
1604 // CCalenViewManager::IconsL |
|
1605 // Create a CCalenIcons object if neccessary and return a reference |
|
1606 // (other items were commented in a header). |
|
1607 // ----------------------------------------------------------------------------- |
|
1608 CCalenIcons& CCalenViewManager::IconsL() |
|
1609 { |
|
1610 TRACE_ENTRY_POINT; |
|
1611 |
|
1612 if (!iIcons) |
|
1613 { |
|
1614 // Icons |
|
1615 iIcons = CCalenIcons::NewL(); |
|
1616 } |
|
1617 |
|
1618 TRACE_EXIT_POINT; |
|
1619 return *iIcons; |
|
1620 } |
|
1621 |
|
1622 // ----------------------------------------------------------------------------- |
|
1623 // CCalenViewManager::GetNextViewIconL |
|
1624 // Gets next view icon |
|
1625 // ----------------------------------------------------------------------------- |
|
1626 CGulIcon* CCalenViewManager::GetNextViewIconL() |
|
1627 { |
|
1628 TRACE_ENTRY_POINT; |
|
1629 |
|
1630 // Set the view cycle index based on the newly activated view, |
|
1631 // if the view is in the cycle array. |
|
1632 TInt index = iViewInfoArray.Find( iCurrentViewId.iViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1633 if( index != KErrNotFound ) |
|
1634 { |
|
1635 iViewCycleIndex = index; |
|
1636 TInt nextVwIndex = iViewCycleIndex; |
|
1637 do |
|
1638 { |
|
1639 nextVwIndex = ( nextVwIndex + 1 )%(iViewInfoArray.Count()); |
|
1640 }while( iViewInfoArray[nextVwIndex]->CyclePosition() == CCalenView::ENoCyclePosition ); |
|
1641 |
|
1642 // Get the next view icon |
|
1643 CCalenView* nextview = static_cast<CCalenView*>( iAppUi.View( iViewInfoArray[nextVwIndex]->ViewUid() ) ); |
|
1644 return( nextview->ViewIconL() ); |
|
1645 } |
|
1646 |
|
1647 TRACE_EXIT_POINT; |
|
1648 return NULL; |
|
1649 } |
|
1650 |
|
1651 // ----------------------------------------------------------------------------- |
|
1652 // CCalenViewManager::SetRepopulation |
|
1653 // Resets the flag iAvoidRepopulation to activate the view. |
|
1654 // ----------------------------------------------------------------------------- |
|
1655 void CCalenViewManager::SetRepopulation(TBool aRePopulate) |
|
1656 { |
|
1657 TRACE_ENTRY_POINT; |
|
1658 // to prevent the display of blank view, |
|
1659 // set the iAvoidRepopulation to EFalse, |
|
1660 // so that view is populated properly |
|
1661 |
|
1662 iAvoidRepopulation = aRePopulate; |
|
1663 |
|
1664 TRACE_EXIT_POINT; |
|
1665 } |
|
1666 |
|
1667 // ----------------------------------------------------------------------------- |
|
1668 // CCalenViewManager::CalenToolbar |
|
1669 // Returns calendar toolbar |
|
1670 // ----------------------------------------------------------------------------- |
|
1671 CCalenToolbarImpl* CCalenViewManager::CalenToolbar() |
|
1672 { |
|
1673 TRACE_ENTRY_POINT; |
|
1674 TRACE_EXIT_POINT; |
|
1675 return iToolbar; |
|
1676 } |
|
1677 |
|
1678 // ----------------------------------------------------------------------------- |
|
1679 // CCalenViewManager::ReloadAllPluginsL |
|
1680 // Reload all plugins |
|
1681 // ----------------------------------------------------------------------------- |
|
1682 void CCalenViewManager::ReloadAllPluginsL() |
|
1683 { |
|
1684 TRACE_ENTRY_POINT; |
|
1685 |
|
1686 // load all plugins |
|
1687 iCustomisationManager->DoPluginLoadingL(); |
|
1688 UpdatePluginListL(); |
|
1689 |
|
1690 // only activate plugin view if it is default view |
|
1691 TUid defaultViewUid = iSetting->DefaultView(); |
|
1692 if(!IsNativeView(defaultViewUid)) |
|
1693 { |
|
1694 iAvoidRepopulation = EFalse; |
|
1695 |
|
1696 // Find the default view in the view cycle list |
|
1697 TInt position = iViewInfoArray.Find( |
|
1698 defaultViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1699 if( position != KErrNotFound ) |
|
1700 { |
|
1701 TVwsViewId targetViewId( KUidCalendar, defaultViewUid); |
|
1702 RequestActivationL(targetViewId); |
|
1703 iViewCycleIndex = position; |
|
1704 } |
|
1705 else |
|
1706 { |
|
1707 // if plugin providing default view is already uninstalled |
|
1708 // activate month view as default view |
|
1709 CRepository* repository = CRepository::NewL( KCRUidCalendar ); |
|
1710 CleanupStack::PushL(repository); |
|
1711 TInt tmp( static_cast<TInt>( KUidCalenMonthView.iUid ) ); |
|
1712 TInt position = iViewInfoArray.Find( KUidCalenMonthView, CCalenViewInfo::ViewInfoIdentifier ); |
|
1713 User::LeaveIfError( repository->Set( KCalendarDefaultStartView, tmp ) ); |
|
1714 iAppUi.SetDefaultViewL( *iAppUi.View( KUidCalenMonthView ) ); |
|
1715 TVwsViewId targetViewId( KUidCalendar, KUidCalenMonthView); |
|
1716 RequestActivationL(targetViewId); |
|
1717 iViewCycleIndex = position; |
|
1718 CleanupStack::PopAndDestroy(repository); |
|
1719 } |
|
1720 } |
|
1721 else // If default view is native view, then activate it |
|
1722 { |
|
1723 iAvoidRepopulation = EFalse; |
|
1724 // In case of launching missed event view or missed alarms view, there |
|
1725 // is no need to activate default view. |
|
1726 if( ( iCurrentViewId.iViewUid.iUid != KCalenMissedEventViewUidValue ) && |
|
1727 ( iCurrentViewId.iViewUid.iUid != KCalenMissedAlarmsViewUidValue ) ) |
|
1728 { |
|
1729 // Find the default view in the view cycle list |
|
1730 TInt position = iViewInfoArray.Find( |
|
1731 defaultViewUid, CCalenViewInfo::ViewInfoIdentifier ); |
|
1732 if( position != KErrNotFound ) |
|
1733 { |
|
1734 TVwsViewId targetViewId( KUidCalendar, defaultViewUid); |
|
1735 RequestActivationL(targetViewId); |
|
1736 iViewCycleIndex = position; |
|
1737 } |
|
1738 } |
|
1739 } |
|
1740 |
|
1741 TRACE_EXIT_POINT; |
|
1742 } |
|
1743 |
|
1744 // ----------------------------------------------------------------------------- |
|
1745 // CCalenViewManager::GetPreviousViewUid |
|
1746 // Rest of the details are commented in header. |
|
1747 // ----------------------------------------------------------------------------- |
|
1748 TUid CCalenViewManager::GetPreviousViewUid() |
|
1749 { |
|
1750 return iPreviousViewId.iViewUid; |
|
1751 } |
|
1752 |
|
1753 // ----------------------------------------------------------------------------- |
|
1754 // CCalenViewManager::IsNativeView |
|
1755 // Check for native view |
|
1756 // ----------------------------------------------------------------------------- |
|
1757 TBool CCalenViewManager::IsNativeView(TUid aViewUid) |
|
1758 { |
|
1759 TRACE_ENTRY_POINT; |
|
1760 |
|
1761 if( (aViewUid == KUidCalenMonthView)|| |
|
1762 (aViewUid == KUidCalenWeekView) || |
|
1763 (aViewUid == KUidCalenDayView) || |
|
1764 (aViewUid == KUidCalenTodoView) ) |
|
1765 { |
|
1766 TRACE_EXIT_POINT; |
|
1767 return ETrue; |
|
1768 } |
|
1769 TRACE_EXIT_POINT; |
|
1770 return EFalse; |
|
1771 } |
|
1772 |
|
1773 // ----------------------------------------------------------------------------- |
|
1774 // CCalenViewManager::ActivateViewOnFakeExitL |
|
1775 // Check for native view |
|
1776 // ----------------------------------------------------------------------------- |
|
1777 void CCalenViewManager::ActivateViewOnFakeExitL(TUid aDefView) |
|
1778 { |
|
1779 TRACE_ENTRY_POINT; |
|
1780 |
|
1781 if(IsNativeView(aDefView)) |
|
1782 { |
|
1783 // activate the view in background |
|
1784 RequestActivationL( aDefView, KCalenHideInBackGround, KNullDesC8() ); |
|
1785 } |
|
1786 else |
|
1787 { |
|
1788 RequestActivationL( KUidCalenDummyView, KCalenHideInBackGround, KNullDesC8() ); |
|
1789 } |
|
1790 |
|
1791 // set the flag to avoid repopulation when application is |
|
1792 // opened after faster exit |
|
1793 iAvoidRepopulation = ETrue; |
|
1794 |
|
1795 // set the context |
|
1796 MCalenContext& context = iController.Services().Context(); |
|
1797 TCalTime focusTime = context.DefaultCalTimeForViewsL(); |
|
1798 context.SetFocusDateAndTimeL( focusTime, |
|
1799 TVwsViewId( KUidCalendar, aDefView) ); |
|
1800 |
|
1801 TRACE_EXIT_POINT; |
|
1802 } |
|
1803 // End of file |