calendarui/controller/src/calenbackgroundstate.cpp
branchRCL_3
changeset 65 12af337248b1
parent 30 d68a4b5d5885
child 66 bd7edf625bdd
equal deleted inserted replaced
60:96907930389d 65:12af337248b1
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:   Calendar state machine
    14 * Description:  Calendar state machine
    15 *
    15 *
    16 */
    16 */
    17 
       
    18 
    17 
    19 
    18 
    20 // includes
    19 // includes
    21 #include "calenbackgroundstate.h"
    20 #include "calenbackgroundstate.h"
    22 #include "calendarui_debug.h"           // Debug macros
    21 #include "calendarui_debug.h"           // Debug macros
    23 #include "calencontroller.h"
    22 #include "calencontroller.h"
    24 #include "calenstatemachine.h"
    23 #include "calenstatemachine.h"
    25 #include "calennotifier.h"
    24 #include "calennotifier.h"
       
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "calenbackgroundstateTraces.h"
       
    28 #endif
    26 
    29 
    27 // ----------------------------------------------------------------------------
    30 // ----------------------------------------------------------------------------
    28 // CCalenBackgroundState::NewLC
    31 // CCalenBackgroundState::NewLC
    29 // First stage construction
    32 // First stage construction
    30 // ----------------------------------------------------------------------------
    33 // ----------------------------------------------------------------------------
    31 CCalenBackgroundState* CCalenBackgroundState::NewLC( CCalenController& aController,
    34 CCalenBackgroundState* CCalenBackgroundState::NewLC( CCalenController& aController,
    32                                                             RHashSet<TCalenNotification>&  aOutstandingNotifications )
    35                                                             RHashSet<TCalenNotification>&  aOutstandingNotifications )
    33     {
    36     {
    34     TRACE_ENTRY_POINT;
    37     OstTraceFunctionEntry0( CCALENBACKGROUNDSTATE_NEWLC_ENTRY );
    35 
    38     
    36     CCalenBackgroundState* self = new ( ELeave ) CCalenBackgroundState( aController,aOutstandingNotifications );
    39     CCalenBackgroundState* self = new ( ELeave ) CCalenBackgroundState( aController,aOutstandingNotifications );
    37     CleanupStack::PushL( self );
    40     CleanupStack::PushL( self );
    38     self->ConstructL();
    41     self->ConstructL();
    39 
    42 
    40     TRACE_EXIT_POINT;
    43     OstTraceFunctionExit0( CCALENBACKGROUNDSTATE_NEWLC_EXIT );
    41     return self;
    44     return self;
    42     }
    45     }
    43 
    46 
    44 // ----------------------------------------------------------------------------
    47 // ----------------------------------------------------------------------------
    45 // CCalenBackgroundState::ConstructL
    48 // CCalenBackgroundState::ConstructL
    46 // Second stage construction
    49 // Second stage construction
    47 // ----------------------------------------------------------------------------
    50 // ----------------------------------------------------------------------------
    48 void CCalenBackgroundState::ConstructL()
    51 void CCalenBackgroundState::ConstructL()
    49     {
    52     {
    50     TRACE_ENTRY_POINT;
    53     OstTraceFunctionEntry0( CCALENBACKGROUNDSTATE_CONSTRUCTL_ENTRY );
       
    54     
    51     BaseConstructL();
    55     BaseConstructL();
    52     
    56     
    53     TRACE_EXIT_POINT;
    57     OstTraceFunctionExit0( CCALENBACKGROUNDSTATE_CONSTRUCTL_EXIT );
    54     }
    58     }
    55     
    59     
    56 // ----------------------------------------------------------------------------
    60 // ----------------------------------------------------------------------------
    57 // CCalenBackgroundState::CCalenBackgroundState
    61 // CCalenBackgroundState::CCalenBackgroundState
    58 // C++ Constructor
    62 // C++ Constructor
    59 // ----------------------------------------------------------------------------
    63 // ----------------------------------------------------------------------------
    60 CCalenBackgroundState::CCalenBackgroundState( CCalenController& aController, 
    64 CCalenBackgroundState::CCalenBackgroundState( CCalenController& aController, 
    61                                                                 RHashSet<TCalenNotification>&  aOutstandingNotifications )
    65                                                                 RHashSet<TCalenNotification>&  aOutstandingNotifications )
    62     : CCalenState( aController, aOutstandingNotifications )
    66     : CCalenState( aController, aOutstandingNotifications )
    63     {
    67     {
    64     TRACE_ENTRY_POINT;
    68     OstTraceFunctionEntry0( CCALENBACKGROUNDSTATE_CCALENBACKGROUNDSTATE_ENTRY );
    65     
    69     
    66     TRACE_EXIT_POINT;
    70     OstTraceFunctionExit0( CCALENBACKGROUNDSTATE_CCALENBACKGROUNDSTATE_EXIT );
    67     }
    71     }
    68     
    72     
    69 // ----------------------------------------------------------------------------
    73 // ----------------------------------------------------------------------------
    70 // CCalenBackgroundState::CCalenBackgroundState
    74 // CCalenBackgroundState::CCalenBackgroundState
    71 // Destructor
    75 // Destructor
    72 // ----------------------------------------------------------------------------    
    76 // ----------------------------------------------------------------------------    
    73 CCalenBackgroundState::~CCalenBackgroundState()
    77 CCalenBackgroundState::~CCalenBackgroundState()
    74     {
    78     {
    75     TRACE_ENTRY_POINT;
    79     OstTraceFunctionEntry0( DUP1_CCALENBACKGROUNDSTATE_CCALENBACKGROUNDSTATE_ENTRY );
    76     
    80     
    77     TRACE_EXIT_POINT;
    81     OstTraceFunctionExit0( DUP1_CCALENBACKGROUNDSTATE_CCALENBACKGROUNDSTATE_EXIT );
    78     }
    82     }
    79 
    83 
    80 // ----------------------------------------------------------------------------
    84 // ----------------------------------------------------------------------------
    81 // CCalenBackgroundState::HandleCommandL
    85 // CCalenBackgroundState::HandleCommandL
    82 // From CCalenState
    86 // From CCalenState
    83 // ----------------------------------------------------------------------------    
    87 // ----------------------------------------------------------------------------    
    84 TBool CCalenBackgroundState::HandleCommandL( const TCalenCommand& aCommand,
    88 TBool CCalenBackgroundState::HandleCommandL( const TCalenCommand& aCommand,
    85                                            CCalenStateMachine& aStateMachine )
    89                                            CCalenStateMachine& aStateMachine )
    86     {
    90     {
    87     TRACE_ENTRY_POINT;  
    91     OstTraceFunctionEntry0( CCALENBACKGROUNDSTATE_HANDLECOMMANDL_ENTRY );
       
    92       
    88     
    93     
    89     //When application is pushed background
    94     //When application is pushed background
    90     //1,when launched from active idle ,( AI screen or missed alarm softnotification/small indicator),
    95     //1,when launched from active idle ,( AI screen or missed alarm softnotification/small indicator),
    91     //  multiple entires -> Day view
    96     //  multiple entires -> Day view
    92     //2,when launched from active idle ( AI screen or missed alarm softnotification/small indicator),
    97     //2,when launched from active idle ( AI screen or missed alarm softnotification/small indicator),
    99     
   104     
   100     TBool cmdUsed = EFalse;
   105     TBool cmdUsed = EFalse;
   101 
   106 
   102     switch( cmd )
   107     switch( cmd )
   103         {
   108         {
       
   109         case ECalenAgendaView:
   104         case ECalenDayView:
   110         case ECalenDayView:
   105         case ECalenTodoView:
       
   106         case ECalenMonthView:
       
   107         case ECalenWeekView:
       
   108             SetCurrentState(aStateMachine,CCalenStateMachine::ECalenIdleState);
   111             SetCurrentState(aStateMachine,CCalenStateMachine::ECalenIdleState);
   109             cmdUsed = ETrue;
   112             cmdUsed = ETrue;
   110             break;
   113             break;
   111         case ECalenEventView:
   114         case ECalenEventView:
   112             SetCurrentState(aStateMachine,CCalenStateMachine::ECalenViewingState);
   115             SetCurrentState(aStateMachine,CCalenStateMachine::ECalenViewingState);
   113             cmdUsed = ETrue;
   116             cmdUsed = ETrue;
   114             break;
   117             break;
   115         case ECalenEventViewFromAlarm:
   118         case ECalenFasterAppExit:        	
   116         case ECalenEventViewFromAlarmStopOnly:
   119 			if(iPreviousState == CCalenStateMachine::ECalenDeletingState)
   117             SetCurrentState(aStateMachine,CCalenStateMachine::ECalenAlarmState);
       
   118             cmdUsed = ETrue;
       
   119             break;
       
   120         case ECalenFasterAppExit:
       
   121         	if(iPreviousState == CCalenStateMachine::ECalenMapState)
       
   122 				{
       
   123 				// Issue map launch cancel notification
       
   124 				iController.BroadcastNotification(ECalenNotifyCancelMapLaunch);
       
   125 		        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
       
   126 		        ActivateCurrentStateL(aStateMachine);
       
   127 		        cmdUsed = ETrue;
       
   128 		        break;
       
   129 		   		}
       
   130         	else if(iPreviousState == CCalenStateMachine::ECalenDeletingState)
       
   131         	    {
   120         	    {
   132                 // Issue ECalenNotifyDeleteFailed notification to cancel the delete
   121                 // Issue ECalenNotifyDeleteFailed notification to cancel the delete
   133                 iController.BroadcastNotification(ECalenNotifyDeleteFailed);
   122                 iController.BroadcastNotification(ECalenNotifyDeleteFailed);
   134                 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
   123                 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
   135                 ActivateCurrentStateL(aStateMachine);
   124                 ActivateCurrentStateL(aStateMachine);
   136                 cmdUsed = ETrue;                 
   125                 cmdUsed = ETrue;                 
   137         	    }
   126         	    }
   138         	else if( iPreviousState == CCalenStateMachine::ECalenSettingsState
   127         	else
       
   128 				{
       
   129 				if( iPreviousState == CCalenStateMachine::ECalenSettingsState
   139         	       || iPreviousState == CCalenStateMachine::ECalenEditingState
   130         	       || iPreviousState == CCalenStateMachine::ECalenEditingState
   140         	       || iPreviousState == CCalenStateMachine::ECalenSendingState 
   131         	       || iPreviousState == CCalenStateMachine::ECalenSendingState )
   141         	       || iPreviousState == CCalenStateMachine::ECalenIdleState 
   132 	        	    {
   142                    || iPreviousState == CCalenStateMachine::ECalenViewingState
   133 	                SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
   143                    || iPreviousState == CCalenStateMachine::ECalenAttachmentState)
   134 	                ActivateCurrentStateL(aStateMachine);
   144         	    {
   135 	                cmdUsed = ETrue;                 
   145                 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
   136 	        	    }
   146                 ActivateCurrentStateL(aStateMachine);
   137 				}
   147                 cmdUsed = ETrue;                 
       
   148         	    }
       
   149         default:
   138         default:
   150             break;
   139             break;
   151         }
   140         }
   152     if(cmdUsed)
   141     
   153     RequestCallbackL( handler, aCommand );
   142     RequestCallbackL( handler, aCommand );
   154     
   143     
   155     TRACE_EXIT_POINT;
   144     OstTraceFunctionExit0( CCALENBACKGROUNDSTATE_HANDLECOMMANDL_EXIT );
   156     return cmdUsed;
   145     return cmdUsed;
   157     }
   146     }
   158 
   147 
   159 // ----------------------------------------------------------------------------
   148 // ----------------------------------------------------------------------------
   160 // CCalenBackgroundState::HandleNotificationL
   149 // CCalenBackgroundState::HandleNotificationL
   161 // From CCalenState
   150 // From CCalenState
   162 // ----------------------------------------------------------------------------        
   151 // ----------------------------------------------------------------------------        
   163 void CCalenBackgroundState::HandleNotificationL(const TCalenNotification& aNotification,
   152 void CCalenBackgroundState::HandleNotificationL(const TCalenNotification& aNotification,
   164                                                  CCalenStateMachine& aStateMachine )
   153                                                  CCalenStateMachine& aStateMachine )
   165     {
   154     {
   166     TRACE_ENTRY_POINT;
   155     OstTraceFunctionEntry0( CCALENBACKGROUNDSTATE_HANDLENOTIFICATIONL_ENTRY );
   167     
   156     
   168     switch( aNotification )
   157     switch( aNotification )
   169         {
   158         {
   170         case ECalenNotifyAppForegrounded:
   159         case ECalenNotifyAppForegrounded:
   171         	{
   160         	{
   172         	if( iPreviousState == CCalenStateMachine::ECalenSendingState )
   161         	SetCurrentState( aStateMachine, iPreviousState );
   173         	    {
       
   174         	    SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
       
   175         	    }
       
   176         	else
       
   177         	    {
       
   178                 SetCurrentState( aStateMachine, iPreviousState );
       
   179         	    }
       
   180         	// We set iOutstandingNotifications for two reasons.
   162         	// We set iOutstandingNotifications for two reasons.
   181         	// 1. The new state i.e. the state we are moving back can have notification info.
   163         	// 1. The new state i.e. the state we are moving back can have notification info.
   182         	// 2. When we move to newstate we broadcast all notification from iOutstandingNotifications
   164         	// 2. When we move to newstate we broadcast all notification from iOutstandingNotifications
   183         	//     and inform the registered notifiers.
   165         	//     and inform the registered notifiers.
   184         	iOutstandingNotifications.InsertL(aNotification);
   166         	iOutstandingNotifications.InsertL(aNotification);
   193             // iOutstandingNotifications.InsertL(aNotification);
   175             // iOutstandingNotifications.InsertL(aNotification);
   194             iController.Notifier().BroadcastApprovedNotification( aNotification );
   176             iController.Notifier().BroadcastApprovedNotification( aNotification );
   195             break;
   177             break;
   196         }
   178         }
   197     
   179     
   198     TRACE_EXIT_POINT;
   180     OstTraceFunctionExit0( CCALENBACKGROUNDSTATE_HANDLENOTIFICATIONL_EXIT );
   199     }
   181     }
   200 
   182 
   201 // ----------------------------------------------------------------------------
   183 // ----------------------------------------------------------------------------
   202 // CCalenBackgroundState::HandleStateActivationL
   184 // CCalenBackgroundState::HandleStateActivationL
   203 // Behavior when state is activated.
   185 // Behavior when state is activated.
   204 // ----------------------------------------------------------------------------
   186 // ----------------------------------------------------------------------------
   205 void CCalenBackgroundState::HandleStateActivationL(CCalenStateMachine& aStateMachine)
   187 void CCalenBackgroundState::HandleStateActivationL(CCalenStateMachine& aStateMachine)
   206     {
   188     {
   207     TRACE_ENTRY_POINT;
   189     OstTraceFunctionEntry0( CCALENBACKGROUNDSTATE_HANDLESTATEACTIVATIONL_ENTRY );
       
   190     
   208     if(iOutstandingNotifications.Find(ECalenNotifyAppBackgrounded))
   191     if(iOutstandingNotifications.Find(ECalenNotifyAppBackgrounded))
   209         {
   192         {
   210         CCalenState::HandleStateActivationL(aStateMachine);
   193         CCalenState::HandleStateActivationL(aStateMachine);
   211         }
   194         }
   212     
   195     
   213     TRACE_EXIT_POINT;
   196     OstTraceFunctionExit0( CCALENBACKGROUNDSTATE_HANDLESTATEACTIVATIONL_EXIT );
   214     }
   197     }
   215 
   198 
   216  // end of file
   199  // end of file