calendarui/controller/src/calenidlestate.cpp
changeset 89 b57382753122
parent 51 0b38fc5b94c6
equal deleted inserted replaced
83:5aadd1120515 89:b57382753122
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // includes
    19 // includes
       
    20 #include <featmgr.h>
    20 #include "calenidlestate.h"
    21 #include "calenidlestate.h"
    21 #include "calendarui_debug.h"           // Debug macros
    22 #include "calendarui_debug.h"           // Debug macros
    22 #include "calencontroller.h"
    23 #include "calencontroller.h"
    23 #include "calenstatemachine.h"
    24 #include "calenstatemachine.h"
    24 #include "calennotifier.h"
    25 #include "calennotifier.h"
    25 #include "OstTraceDefinitions.h"
    26 #include "calenviewmanager.h"
    26 #ifdef OST_TRACE_COMPILER_IN_USE
    27 
    27 #include "calenidlestateTraces.h"
    28 // ----------------------------------------------------------------------------
    28 #endif
    29 // CCalenIdleState::NewLC
    29 
       
    30 // ----------------------------------------------------------------------------
       
    31 // CalenIdleState::NewLC
       
    32 // First stage construction
    30 // First stage construction
    33 // ----------------------------------------------------------------------------
    31 // ----------------------------------------------------------------------------
    34 CCalenIdleState* CCalenIdleState::NewLC( CCalenController& aController, 
    32 CCalenIdleState* CCalenIdleState::NewLC( CCalenController& aController, 
    35                     RHashSet<TCalenNotification>&  aOutstandingNotifications  )
    33                     RHashSet<TCalenNotification>&  aOutstandingNotifications  )
    36     {
    34     {
    37     OstTraceFunctionEntry0( CCALENIDLESTATE_NEWLC_ENTRY );
    35     TRACE_ENTRY_POINT;
    38     
    36 
    39     CCalenIdleState* self = new ( ELeave ) CCalenIdleState( aController, 
    37     CCalenIdleState* self = new ( ELeave ) CCalenIdleState( aController, 
    40                                                     aOutstandingNotifications );
    38                                                     aOutstandingNotifications );
    41     CleanupStack::PushL( self );
    39     CleanupStack::PushL( self );
    42     self->ConstructL();
    40     self->ConstructL();
    43 
    41 
    44     OstTraceFunctionExit0( CCALENIDLESTATE_NEWLC_EXIT );
    42     TRACE_EXIT_POINT;
    45     return self;
    43     return self;
    46     }
    44     }
    47 
    45 
    48 // ----------------------------------------------------------------------------
    46 // ----------------------------------------------------------------------------
    49 // CCalenIdleState::ConstructL
    47 // CCalenIdleState::ConstructL
    50 // Second stage construction
    48 // Second stage construction
    51 // ----------------------------------------------------------------------------
    49 // ----------------------------------------------------------------------------
    52 void CCalenIdleState::ConstructL()
    50 void CCalenIdleState::ConstructL()
    53     {
    51     {
    54     OstTraceFunctionEntry0( CCALENIDLESTATE_CONSTRUCTL_ENTRY );
    52     TRACE_ENTRY_POINT;
    55     
       
    56     BaseConstructL();
    53     BaseConstructL();
    57     
    54     
    58     OstTraceFunctionExit0( CCALENIDLESTATE_CONSTRUCTL_EXIT );
    55     TRACE_EXIT_POINT;
    59     }
    56     }
    60     
    57     
    61 // ----------------------------------------------------------------------------
    58 // ----------------------------------------------------------------------------
    62 // CCalenIdleState::CCalenIdleState
    59 // CCalenIdleState::CCalenIdleState
    63 // C++ Constructor
    60 // C++ Constructor
    64 // ----------------------------------------------------------------------------
    61 // ----------------------------------------------------------------------------
    65 CCalenIdleState::CCalenIdleState( CCalenController& aController,
    62 CCalenIdleState::CCalenIdleState( CCalenController& aController,
    66                     RHashSet<TCalenNotification>&  aOutstandingNotifications )
    63                     RHashSet<TCalenNotification>&  aOutstandingNotifications )
    67     : CCalenState( aController, aOutstandingNotifications )
    64     : CCalenState( aController, aOutstandingNotifications )
    68     {
    65     {
    69     OstTraceFunctionEntry0( CCALENIDLESTATE_CCALENIDLESTATE_ENTRY );
    66     TRACE_ENTRY_POINT;
    70     
    67     
    71     OstTraceFunctionExit0( CCALENIDLESTATE_CCALENIDLESTATE_EXIT );
    68     TRACE_EXIT_POINT;
    72     }
    69     }
    73     
    70     
    74 // ----------------------------------------------------------------------------
    71 // ----------------------------------------------------------------------------
    75 // CCalenIdleState::CCalenIdleState
    72 // CCalenIdleState::CCalenIdleState
    76 // Destructor
    73 // Destructor
    77 // ----------------------------------------------------------------------------    
    74 // ----------------------------------------------------------------------------    
    78 CCalenIdleState::~CCalenIdleState()
    75 CCalenIdleState::~CCalenIdleState()
    79     {
    76     {
    80     OstTraceFunctionEntry0( DUP1_CCALENIDLESTATE_CCALENIDLESTATE_ENTRY );
    77     TRACE_ENTRY_POINT;
    81     
    78     
    82     OstTraceFunctionExit0( DUP1_CCALENIDLESTATE_CCALENIDLESTATE_EXIT );
    79     TRACE_EXIT_POINT;
    83     }
    80     }
    84 
    81 
    85 // ----------------------------------------------------------------------------
    82 // ----------------------------------------------------------------------------
    86 // CCalenIdleState::HandleCommandL
    83 // CCalenIdleState::HandleCommandL
    87 // From CCalenState
    84 // From CCalenState
    88 // ----------------------------------------------------------------------------    
    85 // ----------------------------------------------------------------------------    
    89 TBool CCalenIdleState::HandleCommandL( const TCalenCommand& aCommand,
    86 TBool CCalenIdleState::HandleCommandL( const TCalenCommand& aCommand,
    90                                        CCalenStateMachine& aStateMachine )
    87                                        CCalenStateMachine& aStateMachine )
    91     {
    88     {
    92     OstTraceFunctionEntry0( CCALENIDLESTATE_HANDLECOMMANDL_ENTRY );
    89     TRACE_ENTRY_POINT;
    93     
    90     
    94     TInt cmd = aCommand.Command();
    91     TInt cmd = aCommand.Command();
    95     MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd );
    92     MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd );
    96     
    93     
    97     ASSERT( handler ); // FIXME: error ui
    94     ASSERT( handler ); // FIXME: error ui
    99     TBool cmdUsed = EFalse;
    96     TBool cmdUsed = EFalse;
   100 
    97 
   101     switch( cmd )
    98     switch( cmd )
   102         {
    99         {
   103         case ECalenMonthView:
   100         case ECalenMonthView:
       
   101         case ECalenWeekView:
   104         case ECalenDayView:
   102         case ECalenDayView:
   105         case ECalenAgendaView:
   103         case ECalenTodoView:
   106         case ECalenStartActiveStep:
       
   107             {
       
   108             // set previous state to idle
       
   109             CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
       
   110             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenPopulationState );
       
   111             SetCurrentPreviousState( aStateMachine, cachedState );
       
   112             ActivateCurrentStateL(aStateMachine);               
       
   113             cmdUsed = ETrue;
       
   114             }
       
   115             break;
       
   116         case ECalenTodoEditor:
       
   117         case ECalenTodoEditorDone:
       
   118         case ECalenForwardsToDayView:
   104         case ECalenForwardsToDayView:
       
   105         case ECalenForwardsToWeekView:
   119         case ECalenNextView:
   106         case ECalenNextView:
   120         case ECalenPrevView:
   107         case ECalenPrevView:
   121         case ECalenSwitchView:
   108         case ECalenSwitchView:
   122         case ECalenHidePreview:
   109         case ECalenHidePreview:
   123         case ECalenShowPreview:
   110         case ECalenShowPreview:
   124         case ECalenGotoToday:
   111         case ECalenGotoToday:
   125         case ECalenGotoDate:
   112         case ECalenGotoDate:
       
   113         case ECalenGotoNextDay:
       
   114         case ECalenGotoPrevDay:    
   126         case ECalenNotifyFocusChange:
   115         case ECalenNotifyFocusChange:
   127         case ECalenCompleteTodo:
   116         case ECalenCompleteTodo:
   128         case ECalenRestoreTodo:
   117         case ECalenRestoreTodo:
   129         case ECalenMissedAlarmsView:
   118         case ECalenMissedAlarmsView:
   130         case ECalenCmdClear:
   119         case ECalenCmdClear:
   133         case ECalenMissedEventViewFromIdle:
   122         case ECalenMissedEventViewFromIdle:
   134         case ECalenMissedAlarmsViewFromIdle:    
   123         case ECalenMissedAlarmsViewFromIdle:    
   135         	 cmdUsed = ETrue;
   124         	 cmdUsed = ETrue;
   136              break;
   125              break;
   137         
   126         
   138         
   127         case ECalenStartActiveStep:
       
   128         	{
       
   129         	// set previous state to idle
       
   130             CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
       
   131             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenPopulationState );
       
   132            	SetCurrentPreviousState( aStateMachine, cachedState );
       
   133             ActivateCurrentStateL(aStateMachine);           	
       
   134            	cmdUsed = ETrue;
       
   135            	}
       
   136            	break;
   139         case ECalenEventView: 
   137         case ECalenEventView: 
   140         case ECalenMissedEventView: 
   138         case ECalenMissedEventView: 
   141             {
   139             {       	
   142         	// set previous state to idle
   140             //update the previous before going to the eventview
   143             CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
   141             if ( FeatureManager::FeatureSupported( KFeatureIdFfEnhancedCalendarEventUi  ) )
       
   142                 {
       
   143                 iController.ViewManager().SetPreviousViewUid(iController.ViewManager().CurrentView());
       
   144                 }
       
   145             // set previous state to idle
       
   146 			CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
   144             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenViewingState);
   147             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenViewingState);
   145             SetCurrentPreviousState( aStateMachine, cachedState );
   148             SetCurrentPreviousState( aStateMachine, cachedState );
   146             ActivateCurrentStateL(aStateMachine);            
   149             ActivateCurrentStateL(aStateMachine);            
   147             cmdUsed = ETrue;
   150             cmdUsed = ETrue;
   148         	}
   151         	}
   149         	break;
   152         	break;
   150         case ECalenNewMeeting:
   153         case ECalenNewMeeting:
       
   154         case ECalenNewTodo:
   151         case ECalenNewAnniv:
   155         case ECalenNewAnniv:
   152         case ECalenNewDayNote:
   156         case ECalenNewDayNote:
   153         case ECalenNewReminder:
   157         case ECalenNewReminder:
   154         case ECalenNewMeetingRequest:
   158         case ECalenNewMeetingRequest:
   155         case ECalenNewEntry:
   159         case ECalenNewMeetingTimeSpan:
   156         case ECalenEditCurrentEntry:
   160         case ECalenEditCurrentEntry:
   157         case ECalenEditSeries:
   161         case ECalenEditSeries:
   158         case ECalenEditOccurrence:
   162         case ECalenEditOccurrence:
   159         case ECalenViewCurrentEntry:
   163         case ECalenViewCurrentEntry:
   160             {
   164             {
       
   165             //update the previous before going to the new event
       
   166             if ( FeatureManager::FeatureSupported( KFeatureIdFfEnhancedCalendarEventUi  ) )
       
   167                 {
       
   168                 iController.ViewManager().SetPreviousViewUid(iController.ViewManager().CurrentView());
       
   169                 }
   161             // set previous state to idle
   170             // set previous state to idle
   162             CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
   171             CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
   163             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenEditingState);
   172             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenEditingState);
   164             SetCurrentPreviousState( aStateMachine, cachedState );
   173             SetCurrentPreviousState( aStateMachine, cachedState );
   165             ActivateCurrentStateL(aStateMachine);            
   174             ActivateCurrentStateL(aStateMachine);            
   211         	} 
   220         	} 
   212         	break;       
   221         	break;       
   213         case ECalenGetLocation:
   222         case ECalenGetLocation:
   214     	case ECalenShowLocation:
   223     	case ECalenShowLocation:
   215     	case ECalenGetLocationAndSave:
   224     	case ECalenGetLocationAndSave:
   216     		{    		
   225     		{
   217     		}       
   226     		CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
       
   227 	        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenMapState );
       
   228 	        SetCurrentPreviousState( aStateMachine, cachedState );
       
   229 	        ActivateCurrentStateL(aStateMachine);        
       
   230 	        cmdUsed = ETrue;
       
   231     		}
       
   232 			break;
       
   233 		case ECalenEventViewFromAlarm:
       
   234         case ECalenEventViewFromAlarmStopOnly:	
       
   235 			{
       
   236 			CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
       
   237             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenAlarmState);
       
   238             SetCurrentPreviousState( aStateMachine, cachedState );
       
   239             ActivateCurrentStateL(aStateMachine);            
       
   240             cmdUsed = ETrue;
       
   241 			}
       
   242 			break;
       
   243     	case ECalenAddAttachment:
       
   244     	case ECalenRemoveAttachment:
       
   245     	case ECalenViewAttachmentList:    
       
   246     	    {
       
   247     	    CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
       
   248     	    SetCurrentState( aStateMachine, CCalenStateMachine::ECalenAttachmentState );
       
   249             SetCurrentPreviousState( aStateMachine, cachedState );
       
   250             ActivateCurrentStateL(aStateMachine);        
       
   251             cmdUsed = ETrue;
       
   252     	    }
       
   253     	    break;
   218         default:
   254         default:
   219             // This a valid custom command as there is a command handler
   255             // This a valid custom command as there is a command handler
   220             // do not modify the new start and remain in idle.
   256             // do not modify the new start and remain in idle.
   221             // remain in idle
   257             // remain in idle
   222             // don't modify aNewState.
   258             // don't modify aNewState.
   223             break;
   259             break;
   224         }
   260         }
   225         
   261         
   226     RequestCallbackL( handler, aCommand );
   262     RequestCallbackL( handler, aCommand );
   227 
   263 
   228     OstTraceFunctionExit0( CCALENIDLESTATE_HANDLECOMMANDL_EXIT );
   264     TRACE_EXIT_POINT;
   229     return cmdUsed;
   265     return cmdUsed;
   230     }
   266     }
   231 
   267 
   232 // ----------------------------------------------------------------------------
   268 // ----------------------------------------------------------------------------
   233 // CCalenIdleState::HandleNotificationL
   269 // CCalenIdleState::HandleNotificationL
   234 // From CCalenState
   270 // From CCalenState
   235 // ----------------------------------------------------------------------------        
   271 // ----------------------------------------------------------------------------        
   236 void CCalenIdleState::HandleNotificationL(const TCalenNotification& aNotification,
   272 void CCalenIdleState::HandleNotificationL(const TCalenNotification& aNotification,
   237                                           CCalenStateMachine& aStateMachine)
   273                                           CCalenStateMachine& aStateMachine)
   238     {
   274     {
   239     OstTraceFunctionEntry0( CCALENIDLESTATE_HANDLENOTIFICATIONL_ENTRY );
   275     TRACE_ENTRY_POINT;
   240     
   276     
   241     CCalenState::HandleNotificationL( aNotification, aStateMachine );
   277     CCalenState::HandleNotificationL( aNotification, aStateMachine );
   242     
   278     
   243     OstTraceFunctionExit0( CCALENIDLESTATE_HANDLENOTIFICATIONL_EXIT );
   279     TRACE_EXIT_POINT;
   244     }
   280     }
   245 
   281 
   246 // end of file
   282 // end of file
   247 
   283