calendarui/controller/src/calenstatemachine.cpp
changeset 18 c198609911f9
parent 0 f979ecb2b13e
child 45 b6db4fd4947b
equal deleted inserted replaced
0:f979ecb2b13e 18:c198609911f9
    13 *
    13 *
    14 * Description:  Calendar state machine
    14 * Description:  Calendar state machine
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <avkon.hrh>
       
    19 #include <coemain.h>
       
    20 #include <aknappui.h>
       
    21 
    18 
    22 // includes
    19 // includes
    23 #include "calendarui_debug.h"           // Debug macros
    20 #include "calendarui_debug.h"           // Debug macros
       
    21 
    24 #include "calenstatemachine.h"
    22 #include "calenstatemachine.h"
    25 #include "calenstate.h"
    23 #include "calenstate.h"
    26 #include "calenidlestate.h"
    24 #include "calenidlestate.h"
       
    25 #include "calenpopulationstate.h"
       
    26 #include "calendeletingstate.h"
    27 #include "calenbackgroundstate.h"
    27 #include "calenbackgroundstate.h"
    28 #include "calendeletingstate.h"
       
    29 #include "caleneditingstate.h"
    28 #include "caleneditingstate.h"
    30 #include "calenexitingstate.h"
    29 #include "calenexitingstate.h"
    31 #include "calenhelpstate.h"
    30 #include "calenhelpstate.h"
    32 #include "calenpopulationstate.h"
       
    33 #include "calenprintingstate.h"
    31 #include "calenprintingstate.h"
    34 #include "calensendingstate.h"
    32 #include "calensendingstate.h"
    35 #include "calensettingsstate.h"
    33 #include "calensettingsstate.h"
    36 #include "calenviewingstate.h"
    34 #include "calenviewingstate.h"
    37 #include "calenmapstate.h"
    35 
    38 #include "calenattachmentstate.h"
       
    39 #include "calenalarmstate.h"
       
    40 
    36 
    41 const TInt KHashLength = 64;
    37 const TInt KHashLength = 64;
    42 
       
    43 // ----------------------------------------------------------------------------
    38 // ----------------------------------------------------------------------------
    44 // CCalenStateMachine::NewL
    39 // CCalenStateMachine::NewL
    45 // Two phased constructor.
    40 // Two phased constructor.
    46 // (other items were commented in a header).
    41 // (other items were commented in a header).
    47 // ----------------------------------------------------------------------------
    42 // ----------------------------------------------------------------------------
   127     CleanupStack::Pop( state );
   122     CleanupStack::Pop( state );
   128 
   123 
   129     state = CCalenExitingState::NewLC( iController, iOutstandingNotifications );
   124     state = CCalenExitingState::NewLC( iController, iOutstandingNotifications );
   130     iStates.InsertL( state, ECalenExitingState );
   125     iStates.InsertL( state, ECalenExitingState );
   131     CleanupStack::Pop( state );
   126     CleanupStack::Pop( state );
   132     
       
   133     state = CCalenMapState::NewLC( iController, iOutstandingNotifications );
       
   134     iStates.InsertL( state, ECalenMapState );
       
   135     CleanupStack::Pop( state );
       
   136     
       
   137     state = CCalenAttachmentState::NewLC( iController, iOutstandingNotifications );
       
   138     iStates.InsertL( state, ECalenAttachmentState );
       
   139     CleanupStack::Pop( state );
       
   140 	
       
   141 	state = CCalenAlarmState::NewLC( iController, iOutstandingNotifications );
       
   142     iStates.InsertL( state, ECalenAlarmState );
       
   143     CleanupStack::Pop( state );
       
   144 
       
   145 
   127 
   146     ASSERT( iStates.Count() == KCalenLastState );
   128     ASSERT( iStates.Count() == KCalenLastState );
   147 
   129 
   148     TRACE_EXIT_POINT;
   130     TRACE_EXIT_POINT;
   149     }
   131     }
   182 	
   164 	
   183     TRACE_EXIT_POINT;
   165     TRACE_EXIT_POINT;
   184     }
   166     }
   185 
   167 
   186 // ----------------------------------------------------------------------------
   168 // ----------------------------------------------------------------------------
       
   169 // CCalenStateMachine::CurrentState
       
   170 // Returns the current state in which calendar is.
       
   171 // (other items were commented in a header).
       
   172 // ----------------------------------------------------------------------------
       
   173 //
       
   174 CCalenStateMachine::TCalenStateIndex CCalenStateMachine::CurrentState()
       
   175 {
       
   176 	return iCurrentState;
       
   177 }
       
   178 
       
   179 // ----------------------------------------------------------------------------
   187 // CCalenStateMachine::HandleCommandL
   180 // CCalenStateMachine::HandleCommandL
   188 // Command handler interface.
   181 // Command handler interface.
   189 // (other items were commented in a header).
   182 // (other items were commented in a header).
   190 // ----------------------------------------------------------------------------
   183 // ----------------------------------------------------------------------------
   191 //
   184 //
   192 TBool CCalenStateMachine::HandleCommandL( const TCalenCommand& aCommand )
   185 TBool CCalenStateMachine::HandleCommandL( const TCalenCommand& aCommand )
   193     {
   186     {
   194     TRACE_ENTRY_POINT;
   187     TRACE_ENTRY_POINT;  
   195 
       
   196     if( aCommand.Command() == EAknSoftkeyExit 
       
   197         || aCommand.Command() == EAknCmdExit 
       
   198     	|| aCommand.Command() == EEikCmdExit )
       
   199         {
       
   200         iAvkonAppUi->Exit();
       
   201         }
       
   202     
   188     
   203     TBool cmdUsed = iStates[iCurrentState]->HandleCommandL( aCommand, *this);
   189     TBool cmdUsed = iStates[iCurrentState]->HandleCommandL( aCommand, *this);
   204     
   190     
   205     TRACE_EXIT_POINT;
   191     TRACE_EXIT_POINT;
   206     return cmdUsed;
   192     return cmdUsed;