calendarui/controller/src/calenalarmmanager.cpp
branchRCL_3
changeset 48 bf573002ff72
parent 27 55d60436f00b
child 59 aba12c885d83
equal deleted inserted replaced
36:9c5b1510919f 48:bf573002ff72
    47 #include "calencontextfwlistener.h"
    47 #include "calencontextfwlistener.h"
    48 #include "CleanupResetAndDestroy.h"
    48 #include "CleanupResetAndDestroy.h"
    49 #include "calenattachmentmodel.h"
    49 #include "calenattachmentmodel.h"
    50 
    50 
    51 static const TUint32 KMaxMissedAlarms = 10;
    51 static const TUint32 KMaxMissedAlarms = 10;
       
    52 // Order of calendar window(at front) after Stop/Snooze of alarm from event viewer.
       
    53 static const TInt KCalendarWindowOnFront(0);
    52 
    54 
    53 // ----------------------------------------------------------------------------
    55 // ----------------------------------------------------------------------------
    54 // CCalenAlarmManager::NewL
    56 // CCalenAlarmManager::NewL
    55 // 1st phase of construction
    57 // 1st phase of construction
    56 // ----------------------------------------------------------------------------
    58 // ----------------------------------------------------------------------------
   101         iCenRepChangeNotifier->StopListening();
   103         iCenRepChangeNotifier->StopListening();
   102         delete iCenRepChangeNotifier;
   104         delete iCenRepChangeNotifier;
   103         }
   105         }
   104     delete iMissedAlarmStore;
   106     delete iMissedAlarmStore;
   105     
   107     
   106     if(iMissedAlarmList.Count())
   108       
   107         {
   109 	iMissedAlarmList.Close();
   108         iMissedAlarmList.Close();
   110      
   109         }
       
   110  
   111  
   111     TRACE_EXIT_POINT;
   112     TRACE_EXIT_POINT;
   112     }
   113     }
   113 
   114 
   114 // ----------------------------------------------------------------------------
   115 // ----------------------------------------------------------------------------
   286         case ECalenNotifyMissedAlarmViewClosed:
   287         case ECalenNotifyMissedAlarmViewClosed:
   287             {
   288             {
   288             HandleMissedAlarmViewClosedL();
   289             HandleMissedAlarmViewClosedL();
   289             }
   290             }
   290             break;
   291             break;
       
   292         case ECalenNotifyClearMissedAlarms:
       
   293             {
       
   294             TVwsViewId activeView;
       
   295             iController.AppUi().GetActiveViewId(activeView);
       
   296             if(activeView.iViewUid == KUidCalenMissedAlarmsView)
       
   297                 {
       
   298                 OnCmdClearAllMissedAlarmsL();
       
   299                 }
       
   300             }
       
   301             break;
   291         case ECalenNotifyMissedEventViewClosed:
   302         case ECalenNotifyMissedEventViewClosed:
   292             {
   303             {
   293             HandleMissedEventViewClosedL();
   304             HandleMissedEventViewClosedL();
   294             }
   305             }
   295             break;
   306             break;
   446     {
   457     {
   447     TRACE_ENTRY_POINT;
   458     TRACE_ENTRY_POINT;
   448     
   459     
   449     // restore window group priority
   460     // restore window group priority
   450     RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
   461     RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
   451     PIM_ASSERT( windowGroup.SetOrdinalPositionErr( iOrigWGPos, iOrigWGPrio ) );  
   462 	PIM_ASSERT( windowGroup.SetOrdinalPositionErr( KCalendarWindowOnFront, iOrigWGPrio ) );  
   452 
   463 
   453     //Close Event View
   464     //Close Event View
   454     if(aCloseEventView)
   465     if(aCloseEventView)
   455     	{
   466     	{
   456     	MCalenToolbar* toolbarImpl = iController.ViewManager().ToolbarOrNull();
   467     	MCalenToolbar* toolbarImpl = iController.ViewManager().ToolbarOrNull();
   478     {
   489     {
   479     TRACE_ENTRY_POINT;
   490     TRACE_ENTRY_POINT;
   480     
   491     
   481     // restore window group priority
   492     // restore window group priority
   482     RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
   493     RWindowGroup& windowGroup = CCoeEnv::Static()->RootWin();
   483     PIM_ASSERT( windowGroup.SetOrdinalPositionErr( iOrigWGPos, iOrigWGPrio ) );  
   494 	PIM_ASSERT( windowGroup.SetOrdinalPositionErr( KCalendarWindowOnFront, iOrigWGPrio ) );  
   484     
   495     
   485     // After auto snooze, stop the alarm and open the event viewer in normal mode.
   496     // After auto snooze, stop the alarm and open the event viewer in normal mode.
   486     iController.BroadcastNotification( ECalenNotifyStopAlarm );    
   497     iController.BroadcastNotification( ECalenNotifyStopAlarm );    
   487     
   498     
   488     TRACE_EXIT_POINT;
   499     TRACE_EXIT_POINT;
   605 void CCalenAlarmManager::OnCmdClearAllMissedAlarmsL()
   616 void CCalenAlarmManager::OnCmdClearAllMissedAlarmsL()
   606     {
   617     {
   607     TRACE_ENTRY_POINT;
   618     TRACE_ENTRY_POINT;
   608     
   619     
   609     // Clear all the missed alarm events from cenrep
   620     // Clear all the missed alarm events from cenrep
   610     iMissedAlarmStore->RemoveAllL();
   621     
   611    
   622     RPointerArray<CMissedAlarm> missedAlarmArray;      
       
   623     CleanupResetAndDestroyPushL( missedAlarmArray );   
       
   624     iMissedAlarmStore->GetL(missedAlarmArray);
       
   625     for(TInt index = 0;index < missedAlarmArray.Count();index++)
       
   626         {
       
   627         // remove from cenrep
       
   628         iMissedAlarmStore->RemoveL(*missedAlarmArray[index]);
       
   629         }
       
   630     
       
   631     CleanupStack::PopAndDestroy(); // aMissedAlarmArray
       
   632     
   612     if(iMissedAlarmList.Count())
   633     if(iMissedAlarmList.Count())
   613         {
   634         {
   614         iMissedAlarmList.Close();
   635         iMissedAlarmList.Close();
   615         }
   636         }
   616     
   637     
   729 //
   750 //
   730 void CCalenAlarmManager::HandleMissedAlarmViewClosedL()
   751 void CCalenAlarmManager::HandleMissedAlarmViewClosedL()
   731     {
   752     {
   732     TRACE_ENTRY_POINT;
   753     TRACE_ENTRY_POINT;
   733     
   754     
   734     // remove all the viewed events
   755     // remove all the missed alarms
   735     RemoveAllViewedEventsL();
   756    OnCmdClearAllMissedAlarmsL();
   736     
   757     
   737     if(iPreviousToMissedAlarmView.iViewUid!=KNullUid)
   758     if(iPreviousToMissedAlarmView.iViewUid!=KNullUid)
   738         {
   759         {
   739         iViewManager.RequestActivationL( iPreviousToMissedAlarmView.iViewUid );
   760         iViewManager.RequestActivationL( iPreviousToMissedAlarmView.iViewUid );
   740         iPreviousToMissedAlarmView.iViewUid = KNullUid;
   761         iPreviousToMissedAlarmView.iViewUid = KNullUid;
   914 //
   935 //
   915 TBool CCalenAlarmManager::ClearOneMissedAlarmL( TInt aEntryLocalUid, TCalCollectionId aColid )
   936 TBool CCalenAlarmManager::ClearOneMissedAlarmL( TInt aEntryLocalUid, TCalCollectionId aColid )
   916     {
   937     {
   917     TRACE_ENTRY_POINT;
   938     TRACE_ENTRY_POINT;
   918     
   939     
   919     RPointerArray<CMissedAlarm> aMissedAlarmArray;      
   940     RPointerArray<CMissedAlarm> missedAlarmArray;      
   920     CleanupResetAndDestroyPushL( aMissedAlarmArray );   
   941     CleanupResetAndDestroyPushL( missedAlarmArray );   
   921     iMissedAlarmStore->GetL(aMissedAlarmArray);
   942     iMissedAlarmStore->GetL(missedAlarmArray);
   922     TBool retValue = EFalse;
   943     TBool retValue = EFalse;
   923     for(TInt index = 0;index < aMissedAlarmArray.Count();index++)
   944     for(TInt index = 0;index < missedAlarmArray.Count();index++)
   924         {
   945         {
   925         if( aEntryLocalUid == aMissedAlarmArray[index]->iLuid )
   946         if( aEntryLocalUid == missedAlarmArray[index]->iLuid )
   926             {
   947             {
   927             CCalSession &session = iController.Services().SessionL( aMissedAlarmArray[index]->iCalFileName );
   948             CCalSession &session = iController.Services().SessionL( missedAlarmArray[index]->iCalFileName );
   928            TCalCollectionId colid = session.CollectionIdL();
   949            TCalCollectionId colid = session.CollectionIdL();
   929             if( colid == aColid)
   950             if( colid == aColid)
   930                 {
   951                 {
   931                 // remove from cenrep
   952                 // remove from cenrep
   932                 iMissedAlarmStore->RemoveL(*aMissedAlarmArray[index]);
   953                 iMissedAlarmStore->RemoveL(*missedAlarmArray[index]);
   933                 retValue = ETrue;
   954                 retValue = ETrue;
   934                 break;
   955                 break;
   935                 }
   956                 }
   936             }
   957             }
   937         }
   958         }