calendarui/controller/src/calenalarmmanager.cpp
changeset 0 f979ecb2b13e
child 12 38571fd2a704
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2008 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 alarm manager
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <calalarm.h>
       
    20 #include <calentry.h>
       
    21 #include <StringLoader.h>
       
    22 #include <centralrepository.h>
       
    23 #include <apgtask.h>
       
    24 #include <aknViewAppUi.h>
       
    25 #include <aknbutton.h>
       
    26 #include <akntoolbar.h>
       
    27 #include <missedalarm.h>
       
    28 #include <missedalarmstore.h>
       
    29 #include <missedalarmstorecrkeys.h>
       
    30 #include <calenagendautils.h>
       
    31 #include <calencommonui.rsg>
       
    32 #include <CalendarInternalCRKeys.h>
       
    33 #include <calendateutils.h>
       
    34 #include <calencommands.hrh>            // Calendar commands
       
    35 #include <calencontext.h>
       
    36 #include <calenservices.h>
       
    37 #include <calentoolbar.h> 
       
    38 #include <GlobalWindowPriorities.h>
       
    39 
       
    40 #include "calendarui_debug.h"
       
    41 #include "calenalarmmanager.h"
       
    42 #include "CalenUid.h"
       
    43 #include "calencontroller.h"
       
    44 #include "calendar.hrh"
       
    45 #include "calenviewmanager.h"
       
    46 #include "calensetting.h"
       
    47 #include "calencontextfwlistener.h"
       
    48 #include "CleanupResetAndDestroy.h"
       
    49 
       
    50 static const TUint32 KMaxMissedAlarms = 10;
       
    51 
       
    52 // ----------------------------------------------------------------------------
       
    53 // CCalenAlarmManager::NewL
       
    54 // 1st phase of construction
       
    55 // ----------------------------------------------------------------------------
       
    56 //
       
    57 CCalenAlarmManager* CCalenAlarmManager::NewL(CCalenController& aController)                                          
       
    58     {
       
    59     TRACE_ENTRY_POINT;
       
    60 
       
    61     CCalenAlarmManager* self = new( ELeave ) CCalenAlarmManager( aController );
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     CleanupStack::Pop( self );
       
    65 
       
    66     TRACE_EXIT_POINT;
       
    67     return self;
       
    68     }
       
    69 
       
    70 // ----------------------------------------------------------------------------
       
    71 // CCalenAlarmManager::CCalenAlarmManager
       
    72 // C++ default Constructor.
       
    73 // ----------------------------------------------------------------------------
       
    74 //
       
    75 CCalenAlarmManager::CCalenAlarmManager( CCalenController& aController )
       
    76     : iController( aController ),iViewManager(aController.ViewManager()),
       
    77 	  iContextFWListener(NULL) 
       
    78     {
       
    79     TRACE_ENTRY_POINT;
       
    80     TRACE_EXIT_POINT;
       
    81     }
       
    82 
       
    83 // ----------------------------------------------------------------------------
       
    84 // CCalenAlarmManager::~CCalenAlarmManager
       
    85 // Destructor.
       
    86 // ----------------------------------------------------------------------------
       
    87 //
       
    88 CCalenAlarmManager::~CCalenAlarmManager()
       
    89     {
       
    90     TRACE_ENTRY_POINT;
       
    91 
       
    92 	if(iContextFWListener)
       
    93 		{
       
    94 		delete iContextFWListener;
       
    95 		iContextFWListener = NULL;
       
    96 		}
       
    97 
       
    98     if(iCenRepChangeNotifier)
       
    99         {
       
   100         iCenRepChangeNotifier->StopListening();
       
   101         delete iCenRepChangeNotifier;
       
   102         }
       
   103     delete iMissedAlarmStore;
       
   104     
       
   105     if(iMissedAlarmList.Count())
       
   106         {
       
   107         iMissedAlarmList.Close();
       
   108         }
       
   109  
       
   110     TRACE_EXIT_POINT;
       
   111     }
       
   112 
       
   113 // ----------------------------------------------------------------------------
       
   114 // CCalenAlarmManager::ConstructL
       
   115 // 2nd phase of construction.
       
   116 // (other items were commented in a header).
       
   117 // ----------------------------------------------------------------------------
       
   118 //
       
   119 void CCalenAlarmManager::ConstructL()
       
   120     {
       
   121     TRACE_ENTRY_POINT;
       
   122     
       
   123     iMissedAlarmStoreRepository = CRepository::NewL( KCRUidMissedAlarmStore );
       
   124     
       
   125     // Create missed alarm store
       
   126     iMissedAlarmStore = CMissedAlarmStore::NewL(*iMissedAlarmStoreRepository);
       
   127     
       
   128     iCenRepChangeNotifier = CCenRepNotifyHandler::NewL( *this, *iMissedAlarmStoreRepository );
       
   129     iCenRepChangeNotifier->StartListeningL();
       
   130     
       
   131     iMissedAlarmStore->CountL(iMissedAlarmsCount);
       
   132     if(iMissedAlarmsCount)
       
   133         {
       
   134         CreateMissedAlarmsListL();
       
   135         }
       
   136  
       
   137     TRACE_EXIT_POINT;
       
   138     }
       
   139 
       
   140 // ----------------------------------------------------------------------------
       
   141 // CCalenAlarmManager::HandleCommandL
       
   142 // Handles alarm manager commands.
       
   143 // ----------------------------------------------------------------------------
       
   144 //
       
   145 TBool CCalenAlarmManager::HandleCommandL( const TCalenCommand& aCommand )
       
   146     {
       
   147     TRACE_ENTRY_POINT;
       
   148     
       
   149     TBool continueCommand(EFalse);    
       
   150     switch( aCommand.Command() )
       
   151         {
       
   152         case ECalenMissedAlarmsView:
       
   153             {
       
   154             OnCmdMissedAlarmViewL();
       
   155             }
       
   156             break;
       
   157         case ECalenMissedEventView:
       
   158             {
       
   159             OnCmdMissedEventViewL();
       
   160             }
       
   161             break;
       
   162         case ECalenCmdClear:
       
   163             {
       
   164             OnCmdClearMissedAlarmL();
       
   165             }
       
   166             break;
       
   167         case ECalenCmdClearAll:
       
   168             {
       
   169             OnCmdClearAllMissedAlarmsL();
       
   170             }
       
   171             break;
       
   172         case ECalenCmdGotoCalendar:
       
   173             {
       
   174             // Handling of this command may be moved to viewmanager in future,
       
   175             // as it is a general command not specific to missed alarms
       
   176             OnCmdGoToCalendarL();
       
   177             }
       
   178             break;
       
   179         case ECalenMissedAlarmsViewFromIdle:
       
   180             {
       
   181             iViewManager.StartActiveStepL();
       
   182             }
       
   183             break;
       
   184         case ECalenMissedEventViewFromIdle:
       
   185             {
       
   186             iLaunchedFromIdle = ETrue;
       
   187             OnCmdLaunchFromIdleL();
       
   188             }
       
   189             break;
       
   190         case ECalenEventViewFromAlarm:
       
   191             {
       
   192             LaunchEventViewerL();
       
   193             iViewManager.SetRepopulation(EFalse);
       
   194             iController.ViewManager().RequestActivationL( KUidCalenEventView, KUidCalenShowAlarmCba );
       
   195             }
       
   196             break;
       
   197         case ECalenEventViewFromAlarmStopOnly:
       
   198             {
       
   199             LaunchEventViewerL();
       
   200             iViewManager.SetRepopulation(EFalse);
       
   201             iController.ViewManager().RequestActivationL( KUidCalenEventView, KUidCalenShowAlarmStopOnlyCba );
       
   202             }
       
   203             break;    
       
   204         default:
       
   205             break;
       
   206         }
       
   207 
       
   208     TRACE_EXIT_POINT;
       
   209     return continueCommand;
       
   210     }
       
   211 
       
   212 // ----------------------------------------------------------------------------
       
   213 // CCalenAlarmManager::CalenCommandHandlerExtensionL
       
   214 // Dummy implementation.
       
   215 // (other items were commented in a header).
       
   216 // ----------------------------------------------------------------------------
       
   217 //
       
   218 TAny* CCalenAlarmManager::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ )
       
   219     {
       
   220     TRACE_ENTRY_POINT;
       
   221     TRACE_EXIT_POINT;
       
   222     return NULL;
       
   223     }
       
   224 
       
   225 // ----------------------------------------------------------------------------
       
   226 // CCalenAlarmManager::HandleNotification
       
   227 // Calls back when notifications that it has been registered for are broadcast
       
   228 // ----------------------------------------------------------------------------
       
   229 //
       
   230 void CCalenAlarmManager::HandleNotification(const TCalenNotification aNotification )
       
   231     {
       
   232     TRACE_ENTRY_POINT;
       
   233     
       
   234     PIM_TRAPD_HANDLE( HandleNotificationL( aNotification ) );
       
   235     
       
   236     TRACE_EXIT_POINT;
       
   237     }
       
   238 
       
   239 // ----------------------------------------------------------------------------
       
   240 // CCalenAlarmManager::HandleNotificationL
       
   241 // Called from HandleNotification() when notifications that it has been
       
   242 //  registered for are broadcast
       
   243 // ----------------------------------------------------------------------------
       
   244 //
       
   245 void CCalenAlarmManager::HandleNotificationL( TCalenNotification aNotification )
       
   246     {
       
   247     TRACE_ENTRY_POINT;
       
   248     
       
   249     switch(aNotification)
       
   250         {
       
   251         case ECalenNotifyLostAlarms:
       
   252             {
       
   253             HandleNotifyLostAlarmsL();
       
   254             }
       
   255             break;
       
   256         case ECalenNotifyEntryDeleted:
       
   257         case ECalenNotifyInstanceDeleted:
       
   258             {
       
   259             HandleBackEventL();
       
   260             HandleEntryDeleteNotificationL();
       
   261             }
       
   262             break;
       
   263         case ECalenNotifyEntrySaved:
       
   264             {
       
   265             HandleEntryDeleteNotificationL();
       
   266             }
       
   267             break;
       
   268         case ECalenNotifyMultipleEntriesDeleted:
       
   269             {
       
   270             // clear all the missed alarms from central repository
       
   271             iMissedAlarmStore->RemoveAllL();
       
   272             
       
   273             // clear the missed alarms list
       
   274             if(iMissedAlarmList.Count())
       
   275                 {
       
   276                 iMissedAlarmList.Close();
       
   277                 }
       
   278             }
       
   279             break;
       
   280         case ECalenNotifyMissedAlarmViewClosed:
       
   281             {
       
   282             HandleMissedAlarmViewClosedL();
       
   283             }
       
   284             break;
       
   285         case ECalenNotifyMissedEventViewClosed:
       
   286             {
       
   287             HandleMissedEventViewClosedL();
       
   288             }
       
   289             break;
       
   290         case ECalenNotifySystemTimeChanged:
       
   291             {
       
   292             if(iMissedAlarmList.Count())
       
   293                 {
       
   294                 HandleSystemTimeChangedL();
       
   295                 }
       
   296             }
       
   297             break;
       
   298         case ECalenNotifyAlarmStopped:
       
   299             {
       
   300             // notify alarmui through the context framework          
       
   301             iContextFWListener->AlarmStopL();
       
   302             }
       
   303             break;      
       
   304         case ECalenNotifyAlarmSnoozed: 
       
   305             {
       
   306             // notify alarmui through the context framework           
       
   307           	iContextFWListener->AlarmSnoozeL();
       
   308             }
       
   309             break;        
       
   310         case ECalenNotifyEntryClosed:
       
   311             {
       
   312             HandleBackEventL();
       
   313             }
       
   314             break;
       
   315             
       
   316         case ECalenNotifyAppForegrounded:
       
   317             {
       
   318             if( iController.IsFasterAppFlagEnabled() )
       
   319                 {
       
   320                 iController.SetFasterAppFlag( EFalse );
       
   321                 }
       
   322             }
       
   323             break;
       
   324         default:
       
   325             break;
       
   326         }
       
   327 
       
   328     TRACE_EXIT_POINT;
       
   329     }
       
   330 
       
   331 // ----------------------------------------------------------------------------
       
   332 // CCalenAlarmManager::HandleNotifyGeneric
       
   333 // From MCenRepNotifyHandlerCallback
       
   334 // Generic notification that one of our central repository keys has changed
       
   335 // If any keys change we broadcast a settings changed notification
       
   336 // (other items were commented in a header).
       
   337 // ----------------------------------------------------------------------------
       
   338 //
       
   339 void CCalenAlarmManager::HandleNotifyGeneric( TUint32 aCenrepKeyId )
       
   340     {
       
   341     TRACE_ENTRY_POINT;
       
   342     
       
   343     if( aCenrepKeyId <= KMissedAlarmsMaxValue)
       
   344         {
       
   345         iController.BroadcastNotification(ECalenNotifyLostAlarms);
       
   346         }
       
   347     
       
   348     TRACE_EXIT_POINT;
       
   349     }   
       
   350 
       
   351 // ----------------------------------------------------------------------------
       
   352 // CCalenAlarmManager::CreateMissedAlarmsListL
       
   353 // Creates missed alarms list
       
   354 // ----------------------------------------------------------------------------
       
   355 void CCalenAlarmManager::CreateMissedAlarmsListL()
       
   356     {
       
   357     TRACE_ENTRY_POINT;
       
   358     
       
   359     if(iMissedAlarmList.Count())
       
   360         {
       
   361         iMissedAlarmList.Reset();
       
   362         }
       
   363     
       
   364     RPointerArray<CMissedAlarm> missedAlarmStorelist;      
       
   365     CleanupResetAndDestroyPushL( missedAlarmStorelist );   
       
   366     
       
   367     iMissedAlarmStore->GetL(missedAlarmStorelist); 
       
   368     
       
   369     TCalenInstanceId instanceId;
       
   370     TInt entryLocalUid;
       
   371     TTime instanceTime;
       
   372     
       
   373     for(TInt index=0;index < missedAlarmStorelist.Count();index++)
       
   374         {
       
   375         CMissedAlarm* missedAlarm = missedAlarmStorelist[index];
       
   376         entryLocalUid = missedAlarm->iLuid;
       
   377         instanceTime = missedAlarm->iInstanceTime;
       
   378 
       
   379         
       
   380         CCalSession &session = iController.Services().SessionL( missedAlarm->iCalFileName );
       
   381        
       
   382         // pack instance ids of the missed alarm instances
       
   383         TRAP_IGNORE(instanceId = TCalenInstanceId::CreateL( entryLocalUid, instanceTime, 0 ));
       
   384         instanceId.iColId = session.CollectionIdL();
       
   385 
       
   386         iMissedAlarmList.Append(instanceId);
       
   387         }
       
   388 
       
   389     CleanupStack::PopAndDestroy(); // missedAlarmStorelist
       
   390     
       
   391     TRACE_EXIT_POINT;
       
   392     }
       
   393 
       
   394 // ----------------------------------------------------------------------------
       
   395 // CCalenAlarmManager::GetMissedAlarmsList
       
   396 // Get Missed alarms list with viewed inf
       
   397 // ----------------------------------------------------------------------------
       
   398 void CCalenAlarmManager::GetMissedAlarmsList(RArray<TCalenInstanceId>& aMissedAlarmsList)
       
   399     {
       
   400     TRACE_ENTRY_POINT;
       
   401     
       
   402     if(!iMissedAlarmList.Count())
       
   403         {
       
   404         TRAP_IGNORE(CreateMissedAlarmsListL());
       
   405         }
       
   406     
       
   407      for(TInt index=0;index<iMissedAlarmList.Count();index++)
       
   408         {
       
   409         aMissedAlarmsList.Append(iMissedAlarmList[index]); 
       
   410         }
       
   411     
       
   412     TRACE_EXIT_POINT;
       
   413     }
       
   414 
       
   415 // ----------------------------------------------------------------------------
       
   416 // CCalenAlarmManager::StartAlarmContextListener
       
   417 // Creates CCalenContextFWListener object for Alarm
       
   418 // ----------------------------------------------------------------------------
       
   419 void CCalenAlarmManager::StartAlarmContextListenerL()
       
   420     {
       
   421     TRACE_ENTRY_POINT;
       
   422     
       
   423     //if in alarm viewer mode: 
       
   424     iContextFWListener = CCalenContextFWListener::NewL(*this);
       
   425     // raise calendar priority as the topmost window (alarmui is left at the background)
       
   426     RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
       
   427     iOrigWGPos = windowGroup.OrdinalPosition();
       
   428     iOrigWGPrio = windowGroup.OrdinalPriority();
       
   429     // move the window on top of the alarm notification window!
       
   430     PIM_ASSERT( windowGroup.SetOrdinalPositionErr( 0, ECoeWinPriorityAlwaysAtFront +KGlobalWindowPriority_Alarm +1 ) );    
       
   431     
       
   432     TRACE_EXIT_POINT;
       
   433     }
       
   434     
       
   435 // ----------------------------------------------------------------------------
       
   436 // CCalenAlarmManager::StopAlarmContextListener
       
   437 // Destroys CCalenContextFWListener object for Alarm
       
   438 // ----------------------------------------------------------------------------
       
   439 void CCalenAlarmManager::StopAlarmContextListener(TBool aCloseEventView)
       
   440     {
       
   441     TRACE_ENTRY_POINT;
       
   442     
       
   443     // restore window group priority
       
   444     RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
       
   445     PIM_ASSERT( windowGroup.SetOrdinalPositionErr( iOrigWGPos, iOrigWGPrio ) );  
       
   446 
       
   447     //Close Event View
       
   448     if(aCloseEventView)
       
   449     	{
       
   450     	MCalenToolbar* toolbarImpl = iController.ViewManager().ToolbarOrNull();
       
   451     	if(toolbarImpl) // If toolbar exists
       
   452     	    {
       
   453     	    CAknToolbar& toolbar = toolbarImpl->Toolbar();
       
   454 
       
   455     	    // Remove the viewer toolbar buttons
       
   456     	    toolbar.RemoveItem(ECalenDeleteCurrentEntry); // Delete button
       
   457     	    toolbar.RemoveItem(ECalenEditCurrentEntry);  // Edit button
       
   458     	    toolbar.RemoveItem(ECalenSend);  // Send button
       
   459     	    }
       
   460     	iController.BroadcastNotification( ECalenNotifyEntryClosed );
       
   461     	}
       
   462     	
       
   463 	TRACE_EXIT_POINT;
       
   464     }
       
   465 
       
   466 //---------------------------------------------------------
       
   467 // CCalenAlarmManager::StopContextListenerForAutoSnooze
       
   468 // Destroys CCalenContextFWListener object for autosnooze case
       
   469 //---------------------------------------------------------
       
   470 //
       
   471 void CCalenAlarmManager::StopContextListenerForAutoSnooze()
       
   472     {
       
   473     TRACE_ENTRY_POINT;
       
   474     
       
   475     // restore window group priority
       
   476     RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
       
   477     PIM_ASSERT( windowGroup.SetOrdinalPositionErr( iOrigWGPos, iOrigWGPrio ) );  
       
   478     
       
   479     // After auto snooze, stop the alarm and open the event viewer in normal mode.
       
   480     iController.BroadcastNotification( ECalenNotifyStopAlarm );    
       
   481     
       
   482     TRACE_EXIT_POINT;
       
   483     }
       
   484 
       
   485 // ----------------------------------------------------------------------------
       
   486 // CCalenAlarmManager::MissedAlarmStore
       
   487 // Returns a reference to the Missed Alarm Store
       
   488 // ----------------------------------------------------------------------------
       
   489 CMissedAlarmStore* CCalenAlarmManager::MissedAlarmStore()
       
   490     {
       
   491     TRACE_ENTRY_POINT;
       
   492     TRACE_EXIT_POINT;
       
   493 
       
   494     return iMissedAlarmStore;
       
   495     }   
       
   496 
       
   497 //---------------------------------------------------------
       
   498 // CCalenAlarmManager::OnCmdMissedAlarmViewL
       
   499 // Handles the command ECalenMissedAlarmsView
       
   500 //---------------------------------------------------------
       
   501 //
       
   502 void CCalenAlarmManager::OnCmdMissedAlarmViewL()
       
   503     {
       
   504     TRACE_ENTRY_POINT;
       
   505     
       
   506     iViewManager.SetRepopulation(EFalse);
       
   507     
       
   508      if(iMissedAlarmsCount == 1)
       
   509          {
       
   510          //Set the Context for missed event view
       
   511          SetContextForMissedEventViewL();
       
   512          
       
   513          iMissedAlarmStore->RemoveAllL();
       
   514 
       
   515          iMissedAlarmList.Close();
       
   516          
       
   517          iPreviousToMissedEventView.iViewUid = iViewManager.CurrentView();
       
   518          
       
   519          // activate missed event view
       
   520          iViewManager.RequestActivationL( KUidCalenMissedEventView );
       
   521          }
       
   522      else if(iMissedAlarmsCount > 1)
       
   523          {
       
   524          iPreviousToMissedAlarmView.iViewUid = iViewManager.CurrentView();
       
   525          
       
   526          // activate missed alarms view
       
   527          iViewManager.RequestActivationL( KUidCalenMissedAlarmsView, 
       
   528                                           KUidCalenShowBackCba );
       
   529          }
       
   530     
       
   531     TRACE_EXIT_POINT
       
   532     }
       
   533 
       
   534 //---------------------------------------------------------
       
   535 // CCalenAlarmManager::OnCmdMissedEventViewL
       
   536 // Handles the command ECalenMissedEventView
       
   537 //---------------------------------------------------------
       
   538 //
       
   539 void CCalenAlarmManager::OnCmdMissedEventViewL()
       
   540     {
       
   541     TRACE_ENTRY_POINT;
       
   542     
       
   543     //get the context
       
   544     MCalenContext &context = iController.Services().Context();
       
   545     TInt missedAlarmEntryUid = context.InstanceId().iEntryLocalUid;
       
   546     TCalCollectionId colid = context.InstanceId().iColId;
       
   547     
       
   548     ClearOneMissedAlarmL(missedAlarmEntryUid, colid);
       
   549     SetMissedAlarmEventAsViewed();
       
   550     
       
   551     iPreviousToMissedEventView.iViewUid = iViewManager.CurrentView();
       
   552     
       
   553     iViewManager.SetRepopulation(EFalse);
       
   554     
       
   555     // activate missed event view
       
   556     iViewManager.RequestActivationL( KUidCalenMissedEventView, KUidCalenShowBackCba );
       
   557     
       
   558     TRACE_EXIT_POINT;
       
   559     }
       
   560 
       
   561 //---------------------------------------------------------
       
   562 // CCalenAlarmManager::OnCmdClearMissedAlarmL
       
   563 // Clears a missed alarm
       
   564 //---------------------------------------------------------
       
   565 //
       
   566 void CCalenAlarmManager::OnCmdClearMissedAlarmL()
       
   567     {
       
   568     TRACE_ENTRY_POINT;
       
   569     
       
   570     // get the context
       
   571     MCalenContext &context = iController.Services().Context();
       
   572     TInt missedAlarmEntryUid = context.InstanceId().iEntryLocalUid;
       
   573     TCalCollectionId colid = context.InstanceId().iColId;
       
   574     // clear missed alarm from cenrep
       
   575     if( EFalse == ClearOneMissedAlarmL( missedAlarmEntryUid, colid ) )
       
   576         {
       
   577         TRACE_EXIT_POINT;
       
   578         return;
       
   579         }
       
   580     for(TInt index = 0;index < iMissedAlarmList.Count();index++)
       
   581         {
       
   582         if( ( missedAlarmEntryUid == iMissedAlarmList[index].iEntryLocalUid ) &&
       
   583              ( colid == iMissedAlarmList[index].iColId ) )
       
   584             {
       
   585             // remove from missed alarms list 
       
   586             iMissedAlarmList.Remove(index);
       
   587             break;
       
   588             }
       
   589         }
       
   590     
       
   591     // Refresh the missed alarm view
       
   592     iViewManager.StartActiveStepL();
       
   593     
       
   594     TRACE_EXIT_POINT;
       
   595     }
       
   596 
       
   597 //---------------------------------------------------------
       
   598 // CCalenAlarmManager::OnCmdClearAllMissedAlarmsL
       
   599 // Clears all missed alarms
       
   600 //---------------------------------------------------------
       
   601 //
       
   602 void CCalenAlarmManager::OnCmdClearAllMissedAlarmsL()
       
   603     {
       
   604     TRACE_ENTRY_POINT;
       
   605     
       
   606     // Clear all the missed alarm events from cenrep
       
   607     iMissedAlarmStore->RemoveAllL();
       
   608    
       
   609     if(iMissedAlarmList.Count())
       
   610         {
       
   611         iMissedAlarmList.Close();
       
   612         }
       
   613     
       
   614     // Refresh the missed alarm view
       
   615     iViewManager.StartActiveStepL();
       
   616     
       
   617     TRACE_EXIT_POINT;
       
   618     }
       
   619 
       
   620 //---------------------------------------------------------
       
   621 // CCalenAlarmManager::OnCmdGoToCalendar
       
   622 // Handles goto calendar command in Missed alarm View
       
   623 //---------------------------------------------------------
       
   624 //
       
   625 void CCalenAlarmManager::OnCmdGoToCalendarL()
       
   626     {
       
   627     TRACE_ENTRY_POINT;
       
   628     
       
   629     iViewManager.SetRepopulation(EFalse);
       
   630     
       
   631     // remove all the viewed events
       
   632     RemoveAllViewedEventsL();
       
   633     
       
   634     // if previous view set,activate the previous view
       
   635     if(iPreviousToMissedAlarmView.iViewUid != KNullUid)
       
   636         {
       
   637         iViewManager.RequestActivationL(iPreviousToMissedAlarmView.iViewUid);    
       
   638         }
       
   639     else
       
   640         {
       
   641         // if previous view is not set,activate the default view of the calendar
       
   642         TUid defViewUid = iController.Settings().DefaultView();
       
   643         iViewManager.RequestActivationL(defViewUid);
       
   644         }
       
   645 
       
   646     TRACE_EXIT_POINT;
       
   647     }
       
   648 
       
   649 // ----------------------------------------------------------------------------
       
   650 // CCalenAlarmManager::OnCmdLaunchFromIdleL
       
   651 // Handles the command ECalenMissedEventViewFromIdle
       
   652 // for intialising the data before launching the
       
   653 // missed event view from Idle(soft notification/indicator 
       
   654 // ----------------------------------------------------------------------------
       
   655 //
       
   656 void CCalenAlarmManager::OnCmdLaunchFromIdleL()
       
   657     {
       
   658     TRACE_ENTRY_POINT;
       
   659     
       
   660     //get the missed alarms list from store
       
   661     RPointerArray<CMissedAlarm> aMissedAlarmArray;      
       
   662     CleanupResetAndDestroyPushL( aMissedAlarmArray );   
       
   663     iMissedAlarmStore->GetL(aMissedAlarmArray);
       
   664     CCalSession &session = iController.Services().SessionL(aMissedAlarmArray[0]->iCalFileName);
       
   665     CCalEntry* entry = iController.Services().EntryViewL(session.CollectionIdL())->FetchL(
       
   666             aMissedAlarmArray[0]->iLuid);
       
   667     User::LeaveIfNull( entry );
       
   668     CleanupStack::PushL( entry );
       
   669     
       
   670     TTime instanceTime;
       
   671     TCalTime inscaltime;
       
   672     instanceTime = CalenAgendaUtils::EntryTimeL( *entry );
       
   673     inscaltime.SetTimeLocalL( instanceTime );
       
   674     
       
   675     // set the context
       
   676     MCalenContext &context = iController.Services().Context();
       
   677     TCalenInstanceId id = TCalenInstanceId::CreateL( *entry, inscaltime );
       
   678     id.iColId = session.CollectionIdL();
       
   679     context.SetInstanceIdL( id, context.ViewId() ); 
       
   680 		CleanupStack::PopAndDestroy( entry );
       
   681     iMissedAlarmStore->RemoveL(*aMissedAlarmArray[0]);
       
   682     CleanupStack::PopAndDestroy(); // aMissedAlarmArray
       
   683     
       
   684     iViewManager.StartActiveStepL();
       
   685   
       
   686     TRACE_EXIT_POINT
       
   687     }
       
   688 
       
   689 // ----------------------------------------------------------------------------
       
   690 // CCalenAlarmManager::HandleNotifyLostAlarmsL
       
   691 // For handling notification ECalenNotifyLostAlarms
       
   692 // which updates missed alarms list and missed alarms count
       
   693 // ----------------------------------------------------------------------------
       
   694 //
       
   695 void CCalenAlarmManager::HandleNotifyLostAlarmsL()
       
   696     {
       
   697     TRACE_ENTRY_POINT;
       
   698     
       
   699     TUint32 newCount;
       
   700     // update the missed alarms count
       
   701     iMissedAlarmStore->CountL(newCount);
       
   702     
       
   703     if(newCount>=iMissedAlarmsCount)
       
   704         {
       
   705         UpdateMissedAlarmsListL();
       
   706         }
       
   707     
       
   708     iMissedAlarmsCount = newCount;
       
   709     // refresh the missed alarm view if it is current view
       
   710     TUid currentViewId(iViewManager.CurrentView());
       
   711     if(currentViewId == KUidCalenMissedAlarmsView)
       
   712         {
       
   713         iViewManager.StartActiveStepL();
       
   714         }
       
   715     
       
   716     TRACE_EXIT_POINT;
       
   717     }
       
   718 
       
   719 // ----------------------------------------------------------------------------
       
   720 // CCalenAlarmManager::HandleMissedAlarmViewClosedL
       
   721 // For handling notification ECalenNotifyMissedAlarmsViewClosed
       
   722 // which activates the previous view or exits the application 
       
   723 // if launched from Idle 
       
   724 // ----------------------------------------------------------------------------
       
   725 //
       
   726 void CCalenAlarmManager::HandleMissedAlarmViewClosedL()
       
   727     {
       
   728     TRACE_ENTRY_POINT;
       
   729     
       
   730     // remove all the viewed events
       
   731     RemoveAllViewedEventsL();
       
   732     
       
   733     if(iPreviousToMissedAlarmView.iViewUid!=KNullUid)
       
   734         {
       
   735         iViewManager.RequestActivationL( iPreviousToMissedAlarmView.iViewUid );
       
   736         iPreviousToMissedAlarmView.iViewUid = KNullUid;
       
   737 				iPreviousToMissedEventView.iViewUid = KNullUid;
       
   738 				
       
   739         // set the default context of the view
       
   740         MCalenContext &context = iController.Services().Context();
       
   741         context.SetFocusDateAndTimeL( context.DefaultCalTimeForViewsL(),
       
   742                                       iPreviousToMissedAlarmView );
       
   743         }
       
   744     else
       
   745         {
       
   746         iController.AppUi().ProcessCommandL(EAknSoftkeyExit);
       
   747         }
       
   748     
       
   749     TRACE_EXIT_POINT;
       
   750     }
       
   751 
       
   752 // ----------------------------------------------------------------------------
       
   753 // CCalenAlarmManager::HandleMissedEventViewClosedL
       
   754 // For handling notification ECalenNotifyMissedEventViewClosed
       
   755 // which activates the previous view or exits the application 
       
   756 // if launched from Idle 
       
   757 // ----------------------------------------------------------------------------
       
   758 //
       
   759 void CCalenAlarmManager::HandleMissedEventViewClosedL()
       
   760     {
       
   761     TRACE_ENTRY_POINT;
       
   762     
       
   763     if(iLaunchedFromIdle)
       
   764         {
       
   765         iLaunchedFromIdle = EFalse;
       
   766         }
       
   767     
       
   768     if(iPreviousToMissedEventView.iViewUid!=KNullUid)
       
   769         {
       
   770         // if MAV is launched from soft notification/status pane indicator
       
   771         // activate the missed alarms view with close as RSK
       
   772         if(iPreviousToMissedEventView.iViewUid== KUidCalenMissedAlarmsView
       
   773             && iPreviousToMissedAlarmView.iViewUid == KNullUid )
       
   774             {
       
   775             iViewManager.RequestActivationL( iPreviousToMissedEventView.iViewUid ,
       
   776                                              KUidCalenShowCloseCba );
       
   777             }
       
   778         else
       
   779             {
       
   780             iViewManager.RequestActivationL(iPreviousToMissedEventView.iViewUid);
       
   781             }
       
   782         iPreviousToMissedEventView.iViewUid = KNullUid;
       
   783         }
       
   784     else
       
   785         {
       
   786         iController.AppUi().ProcessCommandL(EAknSoftkeyExit);
       
   787         }
       
   788     
       
   789     TRACE_EXIT_POINT;
       
   790     }
       
   791 
       
   792 
       
   793 //---------------------------------------------------------
       
   794 // CCalenViewManager::HandleEntryDeleteNotificationL
       
   795 // Handle entry delete notification
       
   796 //---------------------------------------------------------
       
   797 //
       
   798 void CCalenAlarmManager::HandleEntryDeleteNotificationL()
       
   799     {
       
   800     TRACE_ENTRY_POINT;
       
   801     
       
   802     UpdateMissedAlarmsListOnDeleteL();
       
   803     
       
   804     // if launched from soft notification/indicator
       
   805     if(iLaunchedFromIdle)
       
   806         {
       
   807         iController.AppUi().ProcessCommandL(EAknSoftkeyExit);
       
   808         iLaunchedFromIdle = EFalse;
       
   809         }
       
   810     else if(iPreviousToMissedEventView.iViewUid != KNullUid)
       
   811         {
       
   812         // from mav -> missed event view -> delete.....
       
   813         // from native view -> missed event view -> delete
       
   814         // activate iPreviousToMissedEventView
       
   815         iViewManager.RequestActivationL(iPreviousToMissedEventView.iViewUid);
       
   816         iPreviousToMissedEventView.iViewUid = KNullUid;
       
   817         }
       
   818     
       
   819     TRACE_EXIT_POINT;
       
   820     }
       
   821 
       
   822 //---------------------------------------------------------
       
   823 // CCalenViewManager::SetContextForMissedEventViewL
       
   824 // Sets the context before launching missed event view
       
   825 //---------------------------------------------------------
       
   826 //
       
   827 void CCalenAlarmManager::SetContextForMissedEventViewL()
       
   828     {
       
   829     TRACE_ENTRY_POINT;
       
   830     
       
   831     CCalEntry* entry = iController.Services().EntryViewL(iMissedAlarmList[0].iColId)->FetchL(
       
   832                                 iMissedAlarmList[0].iEntryLocalUid);
       
   833     User::LeaveIfNull( entry );
       
   834     CleanupStack::PushL( entry );
       
   835     
       
   836     TTime instanceTime;
       
   837     TCalTime inscaltime;
       
   838     
       
   839     instanceTime = CalenAgendaUtils::EntryTimeL( *entry );
       
   840     inscaltime.SetTimeLocalL( instanceTime );
       
   841     
       
   842     // set the context
       
   843     MCalenContext &context = iController.Services().Context();
       
   844     TCalenInstanceId id = TCalenInstanceId::CreateL( *entry, inscaltime );
       
   845     id.iColId = iMissedAlarmList[0].iColId;
       
   846     context.SetInstanceIdL( id, context.ViewId() ); 
       
   847     
       
   848     CleanupStack::PopAndDestroy( entry );
       
   849     
       
   850     TRACE_EXIT_POINT;
       
   851     }
       
   852 
       
   853 //---------------------------------------------------------
       
   854 // CCalenViewManager::SetMissedAlarmEventAsViewed
       
   855 // Mark the missed alarm event as Viewed
       
   856 //---------------------------------------------------------
       
   857 //
       
   858 void CCalenAlarmManager::SetMissedAlarmEventAsViewed()
       
   859     {
       
   860     TRACE_ENTRY_POINT;
       
   861     
       
   862     // get the context
       
   863     MCalenContext &context = iController.Services().Context();
       
   864     TInt missedAlarmEntryUid = context.InstanceId().iEntryLocalUid;
       
   865     
       
   866     for(TInt index = 0;index < iMissedAlarmList.Count();index++)
       
   867         {
       
   868         if(missedAlarmEntryUid == iMissedAlarmList[index].iEntryLocalUid )
       
   869             {
       
   870             // mark the missed alarm event as viewed 
       
   871             iMissedAlarmList[index].iInstanceViewed = 1;
       
   872             break;
       
   873             }
       
   874         }
       
   875     
       
   876     TRACE_EXIT_POINT;
       
   877     }
       
   878 
       
   879 //---------------------------------------------------------
       
   880 // CCalenViewManager::RemoveAllViewedEventsL
       
   881 // Remove all viewed events
       
   882 //---------------------------------------------------------
       
   883 //
       
   884 void CCalenAlarmManager::RemoveAllViewedEventsL()
       
   885     {
       
   886     TRACE_ENTRY_POINT;
       
   887     
       
   888     for(TInt index=0;index<iMissedAlarmList.Count();index++)
       
   889         {
       
   890         if(iMissedAlarmList[index].iInstanceViewed)
       
   891             {
       
   892             iMissedAlarmList.Remove(index);
       
   893             }
       
   894         }
       
   895     
       
   896     TRACE_EXIT_POINT;
       
   897     }
       
   898 
       
   899 //---------------------------------------------------------
       
   900 // CCalenViewManager::ClearOneMissedAlarmL
       
   901 // Clear one missed alarm
       
   902 //---------------------------------------------------------
       
   903 //
       
   904 TBool CCalenAlarmManager::ClearOneMissedAlarmL( TInt aEntryLocalUid, TCalCollectionId aColid )
       
   905     {
       
   906     TRACE_ENTRY_POINT;
       
   907     
       
   908     RPointerArray<CMissedAlarm> aMissedAlarmArray;      
       
   909     CleanupResetAndDestroyPushL( aMissedAlarmArray );   
       
   910     iMissedAlarmStore->GetL(aMissedAlarmArray);
       
   911     TBool retValue = EFalse;
       
   912     for(TInt index = 0;index < aMissedAlarmArray.Count();index++)
       
   913         {
       
   914         if( aEntryLocalUid == aMissedAlarmArray[index]->iLuid )
       
   915             {
       
   916             CCalSession &session = iController.Services().SessionL( aMissedAlarmArray[index]->iCalFileName );
       
   917            TCalCollectionId colid = session.CollectionIdL();
       
   918             if( colid == aColid)
       
   919                 {
       
   920                 // remove from cenrep
       
   921                 iMissedAlarmStore->RemoveL(*aMissedAlarmArray[index]);
       
   922                 retValue = ETrue;
       
   923                 break;
       
   924                 }
       
   925             }
       
   926         }
       
   927     
       
   928     CleanupStack::PopAndDestroy(); // aMissedAlarmArray
       
   929     TRACE_EXIT_POINT;
       
   930     return retValue;
       
   931     }
       
   932 
       
   933 //---------------------------------------------------------
       
   934 // CCalenViewManager::UpdateMissedAlarmsListL
       
   935 // Update missed alarms list
       
   936 //---------------------------------------------------------
       
   937 //
       
   938 void CCalenAlarmManager::UpdateMissedAlarmsListL()
       
   939     {
       
   940     TRACE_ENTRY_POINT;
       
   941     
       
   942     RPointerArray<CMissedAlarm> missedAlarmStorelist;      
       
   943     CleanupResetAndDestroyPushL( missedAlarmStorelist );   
       
   944     iMissedAlarmStore->GetL(missedAlarmStorelist); 
       
   945     
       
   946     TUint32 newCount;
       
   947     // update the missed alarms count
       
   948     iMissedAlarmStore->CountL(newCount);
       
   949     
       
   950     TCalenInstanceId instanceId;
       
   951     TInt entryLocalUid;
       
   952     TTime instanceTime;
       
   953     
       
   954     //Retreiving the latest missed alarm array entry
       
   955     CMissedAlarm* missedAlarm = missedAlarmStorelist[newCount-1];             
       
   956     entryLocalUid = missedAlarm->iLuid;
       
   957     instanceTime = missedAlarm->iInstanceTime;
       
   958     
       
   959     CCalSession &session = iController.Services().SessionL( missedAlarm->iCalFileName );
       
   960     // pack instance ids of the missed alarm instances
       
   961     TRAP_IGNORE(instanceId = TCalenInstanceId::CreateL( entryLocalUid,
       
   962                                                     instanceTime, 0 ));
       
   963     instanceId.iColId = session.CollectionIdL();
       
   964     iMissedAlarmList.Append(instanceId);
       
   965     CleanupStack::PopAndDestroy(); // missedAlarmStorelist
       
   966     
       
   967     // if iMissedAlarmList count is greater than maximum missed alarms(10)
       
   968     // remove the old missed alarm(index = 0) from the list
       
   969     if(iMissedAlarmList.Count()>KMaxMissedAlarms)
       
   970         {
       
   971         iMissedAlarmList.Remove(0);
       
   972         }
       
   973     
       
   974     TRACE_EXIT_POINT;
       
   975     }
       
   976 
       
   977 // ----------------------------------------------------------------------------
       
   978 // CCalenAlarmManager::UpdateMissedAlarmsListOnDeleteL
       
   979 // For updating the missed alarms list when an entry is deleted
       
   980 // ----------------------------------------------------------------------------
       
   981 void CCalenAlarmManager::UpdateMissedAlarmsListOnDeleteL()
       
   982     {
       
   983     TRACE_ENTRY_POINT;
       
   984     // get the context
       
   985     MCalenContext &context = iController.Services().Context();
       
   986     TInt deletedEntryUid = context.InstanceId().iEntryLocalUid;
       
   987     
       
   988     TCalCollectionId colidFromContext = context.InstanceId().iColId;
       
   989     
       
   990     if( EFalse == ClearOneMissedAlarmL( deletedEntryUid, colidFromContext ) )
       
   991         {
       
   992         TRACE_EXIT_POINT;
       
   993         return;
       
   994         }
       
   995     for(TInt index = 0;index < iMissedAlarmList.Count();index++)
       
   996         {
       
   997         if( ( deletedEntryUid == iMissedAlarmList[index].iEntryLocalUid )  && ( colidFromContext == iMissedAlarmList[index].iColId ) )
       
   998             {
       
   999             iMissedAlarmList.Remove(index);
       
  1000             if(!iMissedAlarmList.Count())
       
  1001                 {
       
  1002                 iMissedAlarmList.Close();
       
  1003                 }
       
  1004                 break;
       
  1005             }
       
  1006         }
       
  1007     TRACE_EXIT_POINT;
       
  1008     }
       
  1009 
       
  1010 // ----------------------------------------------------------------------------
       
  1011 // CCalenAlarmManager::HandleSystemTimeChangedL
       
  1012 // For updating the missed alarms list/cenrep when time is changed
       
  1013 // ----------------------------------------------------------------------------
       
  1014 void CCalenAlarmManager::HandleSystemTimeChangedL()
       
  1015     {
       
  1016     TRACE_ENTRY_POINT;
       
  1017 
       
  1018     TTime currentTime = CalenDateUtils::Now();
       
  1019     TTime entryAlarmTime; 
       
  1020     RArray<TCalLocalUid> foundlocalUids;
       
  1021     RArray<TCalCollectionId> foundColIds;
       
  1022     TCalLocalUid entryLocalUid;
       
  1023     
       
  1024     for(TInt i = 0;i<iMissedAlarmList.Count();i++)
       
  1025         {
       
  1026         entryLocalUid = iMissedAlarmList[i].iEntryLocalUid;
       
  1027         TCalCollectionId colid = iMissedAlarmList[i].iColId;
       
  1028         CCalEntry* entry = iController.Services().EntryViewL( colid )->FetchL(entryLocalUid);
       
  1029         User::LeaveIfNull( entry );
       
  1030         CleanupStack::PushL( entry );
       
  1031         
       
  1032         GetAlarmDateTimeL( *entry, entryAlarmTime );
       
  1033        
       
  1034         // clear future alarm
       
  1035         if(entryAlarmTime>currentTime)
       
  1036             {
       
  1037             // clear missed alarm from cenrep
       
  1038             if( ClearOneMissedAlarmL(entryLocalUid, colid ) )
       
  1039                 {
       
  1040                 foundlocalUids.Append(entryLocalUid);
       
  1041                 foundColIds.Append(colid);
       
  1042                 }
       
  1043             }
       
  1044         CleanupStack::PopAndDestroy( entry );
       
  1045         }
       
  1046     
       
  1047     for(TInt index = 0;index<foundlocalUids.Count();index++)
       
  1048         {
       
  1049         for(TInt j=0;j<iMissedAlarmList.Count();j++)
       
  1050             {
       
  1051             if( foundlocalUids[index]==iMissedAlarmList[j].iEntryLocalUid && foundColIds[index] == iMissedAlarmList[j].iColId )
       
  1052                 {
       
  1053 	            // remove from local missed alarms list
       
  1054 	            iMissedAlarmList.Remove(j);
       
  1055                 }
       
  1056             break;
       
  1057             }
       
  1058         }
       
  1059     foundlocalUids.Close();
       
  1060    
       
  1061     // refresh the missed alarm view if it is current view
       
  1062     TUid currentViewId(iViewManager.CurrentView());
       
  1063     if(currentViewId == KUidCalenMissedAlarmsView)
       
  1064         {
       
  1065         iViewManager.StartActiveStepL();
       
  1066         }
       
  1067 
       
  1068     TRACE_EXIT_POINT;
       
  1069     }
       
  1070 
       
  1071 // ----------------------------------------------------------------------------
       
  1072 // CCalenAlarmManager::GetAlarmDateTimeL
       
  1073 // Get the alarm time for the entry
       
  1074 // ----------------------------------------------------------------------------
       
  1075 void CCalenAlarmManager::GetAlarmDateTimeL( const CCalEntry& aEntry,
       
  1076                                             TTime& aAlarmDateTime)
       
  1077     {
       
  1078     TRACE_ENTRY_POINT;
       
  1079     
       
  1080     // FIXME: leaving!
       
  1081     CCalAlarm* alarm = aEntry.AlarmL();
       
  1082     CleanupStack::PushL( alarm );
       
  1083 
       
  1084     switch( aEntry.EntryTypeL() )
       
  1085         {
       
  1086         case CCalEntry::ETodo:
       
  1087             aAlarmDateTime = aEntry.EndTimeL().TimeLocalL();
       
  1088             break;
       
  1089 
       
  1090         case CCalEntry::EAppt:
       
  1091         case CCalEntry::EEvent:
       
  1092         case CCalEntry::EAnniv:
       
  1093         default:
       
  1094             aAlarmDateTime = aEntry.StartTimeL().TimeLocalL();
       
  1095             break;
       
  1096         }
       
  1097     aAlarmDateTime -= alarm->TimeOffset();
       
  1098     
       
  1099     CleanupStack::PopAndDestroy( alarm );
       
  1100 
       
  1101     TRACE_EXIT_POINT;
       
  1102     }
       
  1103 
       
  1104 // ----------------------------------------------------------------------------
       
  1105 // CCalenAlarmManager::LaunchEventViewerL
       
  1106 // Rest of the detail are commented in header.
       
  1107 // ----------------------------------------------------------------------------
       
  1108 void CCalenAlarmManager::LaunchEventViewerL()
       
  1109     {
       
  1110     TRACE_ENTRY_POINT;
       
  1111     
       
  1112     // launching Event View from alarm
       
  1113     StartAlarmContextListenerL();
       
  1114 
       
  1115     if(iController.IsFasterAppFlagEnabled())
       
  1116         {
       
  1117         iViewerLaunchedFromIdle = ETrue;
       
  1118         iController.SetFasterAppFlag( EFalse );
       
  1119         }
       
  1120     else
       
  1121         {
       
  1122         iPreviousToEventViewUid = iViewManager.CurrentView();
       
  1123         if(iPreviousToEventViewUid == KUidCalenEventView || 
       
  1124                 iPreviousToEventViewUid == KUidCalenMissedEventView )
       
  1125             {
       
  1126             iPreviousToEventViewUid = iViewManager.GetPreviousViewUid();
       
  1127             }
       
  1128         iController.SetExitOnDialogFlag( EFalse );
       
  1129         }
       
  1130 
       
  1131     TRACE_EXIT_POINT;
       
  1132     }
       
  1133 
       
  1134 // ----------------------------------------------------------------------------
       
  1135 // CCalenAlarmManager::HandleBackEventL
       
  1136 // Rest of the detail are commented in header.
       
  1137 // ----------------------------------------------------------------------------
       
  1138 void CCalenAlarmManager::HandleBackEventL()
       
  1139     {
       
  1140     TRACE_ENTRY_POINT;
       
  1141     
       
  1142     MCalenToolbar* toolbarImpl = iController.ViewManager().ToolbarOrNull();
       
  1143     if(toolbarImpl) // If toolbar exists
       
  1144         {
       
  1145         CAknToolbar& toolbar = toolbarImpl->Toolbar();
       
  1146 
       
  1147         // Remove the viewer toolbar buttons
       
  1148         toolbar.RemoveItem(ECalenDeleteCurrentEntry); // Delete button
       
  1149         toolbar.RemoveItem(ECalenEditCurrentEntry);  // Edit button
       
  1150         toolbar.RemoveItem(ECalenSend);  // Send button
       
  1151         }
       
  1152     if( iViewerLaunchedFromIdle )
       
  1153         {
       
  1154         iController.AppUi().ProcessCommandL(EAknSoftkeyExit);
       
  1155         iViewerLaunchedFromIdle = EFalse;
       
  1156         }
       
  1157     else if( iPreviousToEventViewUid!=KNullUid && 
       
  1158             ( iPreviousToEventViewUid!= KUidCalenEventView || iPreviousToEventViewUid != KUidCalenMissedEventView ) )
       
  1159         {
       
  1160         TVwsViewId previousViewId(KUidCalendar, iPreviousToEventViewUid) ;
       
  1161         iController.ViewManager().RequestActivationL(previousViewId);
       
  1162         iPreviousToEventViewUid = KNullUid;
       
  1163         }
       
  1164 	else
       
  1165 		{
       
  1166 		
       
  1167 		}	
       
  1168     
       
  1169     TRACE_EXIT_POINT;
       
  1170     }
       
  1171 
       
  1172 // End of file