calendarui/controller/src/caleneditingstate.cpp
branchRCL_3
changeset 30 bd7edf625bdd
parent 29 12af337248b1
equal deleted inserted replaced
29:12af337248b1 30:bd7edf625bdd
    20 #include "caleneditingstate.h"
    20 #include "caleneditingstate.h"
    21 #include "calendarui_debug.h"           // Debug macros
    21 #include "calendarui_debug.h"           // Debug macros
    22 #include "calencontroller.h"
    22 #include "calencontroller.h"
    23 #include "calenstatemachine.h"
    23 #include "calenstatemachine.h"
    24 #include "calennotifier.h"
    24 #include "calennotifier.h"
    25 #include "OstTraceDefinitions.h"
       
    26 #ifdef OST_TRACE_COMPILER_IN_USE
       
    27 #include "caleneditingstateTraces.h"
       
    28 #endif
       
    29 
    25 
    30 // ----------------------------------------------------------------------------
    26 // ----------------------------------------------------------------------------
    31 // CCalenEditingState::NewLC
    27 // CCalenEditingState::NewLC
    32 // First stage construction
    28 // First stage construction
    33 // ----------------------------------------------------------------------------
    29 // ----------------------------------------------------------------------------
    34 CCalenEditingState* CCalenEditingState::NewLC( CCalenController& aController,
    30 CCalenEditingState* CCalenEditingState::NewLC( CCalenController& aController,
    35                                                             RHashSet<TCalenNotification>& aOutstandingNotifications )
    31                     RHashSet<TCalenNotification>& aOutstandingNotifications )
    36     {
    32     {
    37     OstTraceFunctionEntry0( CCALENEDITINGSTATE_NEWLC_ENTRY );
    33     TRACE_ENTRY_POINT;
    38     
    34 
    39     CCalenEditingState* self = new( ELeave ) CCalenEditingState( aController, aOutstandingNotifications );
    35     CCalenEditingState* self = new( ELeave ) CCalenEditingState( aController,
       
    36                                                     aOutstandingNotifications );
    40     CleanupStack::PushL( self );
    37     CleanupStack::PushL( self );
    41     self->ConstructL();
    38     self->ConstructL();
    42 
    39 
    43     OstTraceFunctionExit0( CCALENEDITINGSTATE_NEWLC_EXIT );
    40     TRACE_EXIT_POINT;
    44     return self;
    41     return self;
    45     }
    42     }
    46 
    43 
    47 // ----------------------------------------------------------------------------
    44 // ----------------------------------------------------------------------------
    48 // CCalenEditingState::ConstructL
    45 // CCalenEditingState::ConstructL
    49 // Second stage construction
    46 // Second stage construction
    50 // ----------------------------------------------------------------------------
    47 // ----------------------------------------------------------------------------
    51 void CCalenEditingState::ConstructL()
    48 void CCalenEditingState::ConstructL()
    52     {
    49     {
    53     OstTraceFunctionEntry0( CCALENEDITINGSTATE_CONSTRUCTL_ENTRY );
    50     TRACE_ENTRY_POINT;
    54     
       
    55     BaseConstructL();
    51     BaseConstructL();
    56     
    52     
    57     OstTraceFunctionExit0( CCALENEDITINGSTATE_CONSTRUCTL_EXIT );
    53     TRACE_EXIT_POINT;
    58     }
    54     }
    59     
    55     
    60 // ----------------------------------------------------------------------------
    56 // ----------------------------------------------------------------------------
    61 // CCalenEditingState::CCalenEditingState
    57 // CCalenEditingState::CCalenEditingState
    62 // C++ Constructor
    58 // C++ Constructor
    63 // ----------------------------------------------------------------------------
    59 // ----------------------------------------------------------------------------
    64 CCalenEditingState::CCalenEditingState( CCalenController& aController,
    60 CCalenEditingState::CCalenEditingState( CCalenController& aController,
    65                                                         RHashSet<TCalenNotification>& aOutstandingNotifications )
    61             RHashSet<TCalenNotification>& aOutstandingNotifications )
    66     : CCalenState( aController, aOutstandingNotifications )
    62     : CCalenState( aController, aOutstandingNotifications )
    67     {
    63     {
    68     OstTraceFunctionEntry0( CCALENEDITINGSTATE_CCALENEDITINGSTATE_ENTRY );
    64     TRACE_ENTRY_POINT;
    69     
    65 
    70     OstTraceFunctionExit0( CCALENEDITINGSTATE_CCALENEDITINGSTATE_EXIT );
    66     TRACE_EXIT_POINT;
    71     }
    67     }
    72     
    68     
    73 // ----------------------------------------------------------------------------
    69 // ----------------------------------------------------------------------------
    74 // CCalenEditingState::CCalenEditingState
    70 // CCalenEditingState::CCalenEditingState
    75 // Destructor
    71 // Destructor
    76 // ----------------------------------------------------------------------------    
    72 // ----------------------------------------------------------------------------    
    77 CCalenEditingState::~CCalenEditingState()
    73 CCalenEditingState::~CCalenEditingState()
    78     {
    74     {
    79     OstTraceFunctionEntry0( DUP1_CCALENEDITINGSTATE_CCALENEDITINGSTATE_ENTRY );
    75     TRACE_ENTRY_POINT;
    80     
    76     
    81     OstTraceFunctionExit0( DUP1_CCALENEDITINGSTATE_CCALENEDITINGSTATE_EXIT );
    77     TRACE_EXIT_POINT;
    82     }
    78     }
    83 
    79 
    84 // ----------------------------------------------------------------------------
    80 // ----------------------------------------------------------------------------
    85 // CCalenEditingState::HandleCommandL
    81 // CCalenEditingState::HandleCommandL
    86 // From CCalenState
    82 // From CCalenState
    87 // ----------------------------------------------------------------------------    
    83 // ----------------------------------------------------------------------------    
    88 TBool CCalenEditingState::HandleCommandL( const TCalenCommand& aCommand,
    84 TBool CCalenEditingState::HandleCommandL( const TCalenCommand& aCommand,
    89                               CCalenStateMachine& aStateMachine )
    85                               CCalenStateMachine& aStateMachine )
    90     {
    86     {
    91     OstTraceFunctionEntry0( CCALENEDITINGSTATE_HANDLECOMMANDL_ENTRY );
    87     TRACE_ENTRY_POINT
    92     
    88     
    93     TInt cmd = aCommand.Command();
    89     TInt cmd = aCommand.Command();
    94     MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd );
    90     MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd );
    95 	    
    91 	    
    96 	ASSERT( handler );
    92 	ASSERT( handler );
    97      
    93      
    98     TBool cmdUsed = EFalse;
    94     TBool cmdUsed = EFalse;
    99     switch( cmd )
    95     switch( cmd )
   100     {
    96         {
   101     	case ECalenDeleteCurrentEntry:
    97     	case ECalenDeleteCurrentEntry:
   102     	case ECalenDeleteSeries:
    98     	case ECalenDeleteSeries:
   103     	case ECalenDeleteCurrentOccurrence:
    99     	case ECalenDeleteCurrentOccurrence:
   104     		{
   100     		{
   105     		CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
   101     		CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
   108 	        ActivateCurrentStateL(aStateMachine);
   104 	        ActivateCurrentStateL(aStateMachine);
   109 	        
   105 	        
   110 	        cmdUsed = ETrue;
   106 	        cmdUsed = ETrue;
   111 	        break;
   107 	        break;
   112     		}
   108     		}
   113     		
       
   114     	case ECalenSend: // For handling send in viewer
   109     	case ECalenSend: // For handling send in viewer
   115     		{
   110     		{
   116     		CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
   111     		CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
   117 	        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenSendingState );
   112 	        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenSendingState );
   118 	        SetCurrentPreviousState( aStateMachine, cachedState );
   113 	        SetCurrentPreviousState( aStateMachine, cachedState );
   119 	        ActivateCurrentStateL(aStateMachine);        
   114 	        ActivateCurrentStateL(aStateMachine);        
   120 	        
   115 	        
   121 	        cmdUsed = ETrue;
   116 	        cmdUsed = ETrue;
   122 	        break;	
   117 	        break;	
   123     		}
   118     		}
   124     		
       
   125     	case ECalenFasterAppExit:
   119     	case ECalenFasterAppExit:
   126     		{
   120     		{
   127 	        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
   121 	        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
   128 	        ActivateCurrentStateL(aStateMachine);
   122 	        ActivateCurrentStateL(aStateMachine);
   129 	        cmdUsed = ETrue;
   123 	        cmdUsed = ETrue;
   130 	        break;
   124 	        break;
   131         	}
   125         	}
   132         	
       
   133     	case ECalenGetLocation:
   126     	case ECalenGetLocation:
   134     	case ECalenShowLocation:
   127     	case ECalenShowLocation:
   135     		{       	
   128     		{
   136     		}	
   129     		CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
   137 	
   130 	        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenMapState );
       
   131 	        SetCurrentPreviousState( aStateMachine, cachedState );
       
   132 	        ActivateCurrentStateL(aStateMachine);        
       
   133 	        cmdUsed = ETrue;
       
   134 	        break;	
       
   135     		}
       
   136     	case ECalenAddAttachment:
       
   137     	case ECalenRemoveAttachment:
       
   138     	case ECalenViewAttachmentList:
       
   139     	case ECalenAddAttachmentFromViewer:
       
   140             {
       
   141             CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
       
   142             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenAttachmentState );
       
   143             SetCurrentPreviousState( aStateMachine, cachedState );
       
   144             ActivateCurrentStateL(aStateMachine);        
       
   145             cmdUsed = ETrue;
       
   146             }
       
   147             break;
       
   148     	case ECalenMissedEventViewFromIdle:
       
   149     	    {
       
   150     	    cmdUsed = ETrue;
       
   151     	    break;
       
   152     	    }
       
   153     	case ECalenEventViewFromAlarm:
       
   154     	case ECalenEventViewFromAlarmStopOnly:
       
   155     	    {
       
   156     	    cmdUsed = ETrue;
       
   157     	    break;
       
   158     	    }   
   138     	default:
   159     	default:
   139     		break;
   160     		break;
   140     		
   161     		
   141     }
   162         }
   142     
   163     
   143 	if(cmdUsed)
   164 	if(cmdUsed)
   144 		RequestCallbackL( handler, aCommand );
   165 	    {
       
   166 	    RequestCallbackL( handler, aCommand );
       
   167 	    }
   145 	
   168 	
   146     
   169     TRACE_EXIT_POINT;
   147     OstTraceFunctionExit0( CCALENEDITINGSTATE_HANDLECOMMANDL_EXIT );
   170     
   148     return cmdUsed;
   171     return cmdUsed;
   149     }
   172     }
   150 
   173 
   151 // ----------------------------------------------------------------------------
   174 // ----------------------------------------------------------------------------
   152 // CCalenEditingState::HandleNotificationL
   175 // CCalenEditingState::HandleNotificationL
   153 // From CCalenState
   176 // From CCalenState
   154 // ----------------------------------------------------------------------------        
   177 // ----------------------------------------------------------------------------        
   155 void CCalenEditingState::HandleNotificationL(const TCalenNotification& aNotification,
   178 void CCalenEditingState::HandleNotificationL(const TCalenNotification& aNotification,
   156                                               CCalenStateMachine& aStateMachine )
   179                                               CCalenStateMachine& aStateMachine )
   157     {
   180     {
   158     OstTraceFunctionEntry0( CCALENEDITINGSTATE_HANDLENOTIFICATIONL_ENTRY );
   181     TRACE_ENTRY_POINT;
   159     
   182     
   160     switch( aNotification )
   183     switch( aNotification )
   161         {
   184         {
   162         case ECalenNotifyEntryClosed:  // issued when new entry dialog is cancelled
   185         case ECalenNotifyEntryClosed:  // issued when new entry dialog is cancelled
   163         case ECalenNotifyEntrySaved:
   186         case ECalenNotifyEntrySaved:
   164         case ECalenNotifyInstanceSaved:
   187         case ECalenNotifyInstanceSaved:
   165         case ECalenNotifyDialogClosed:
   188         case ECalenNotifyDialogClosed:
   166         case ECalenNotifyEntryDeleted:
   189         case ECalenNotifyEntryDeleted:
   167         case ECalenNotifyEditorClosedFromViewer:
   190         case ECalenNotifyMarkedEntryCompleted:
   168             {
   191             {
   169             SetCurrentState( aStateMachine, iPreviousState );
   192             SetCurrentState( aStateMachine, iPreviousState );
   170             // Let new state does the broadcast
   193             // Let new state does the broadcast
   171             iOutstandingNotifications.InsertL(aNotification);
   194             iOutstandingNotifications.InsertL(aNotification);
   172 			ActivateCurrentStateL(aStateMachine);
   195 			ActivateCurrentStateL(aStateMachine);
   173             }
   196             }
   174             break;
   197             break;
       
   198         case ECalenNotifyCancelStatusUpdation:
       
   199               {
       
   200               SetCurrentState( aStateMachine, iPreviousState);
       
   201               SetCurrentPreviousState( aStateMachine, GetCurrentState(aStateMachine) );
       
   202 
       
   203               iOutstandingNotifications.InsertL(aNotification);
       
   204               ActivateCurrentStateL(aStateMachine);
       
   205               
       
   206               CancelPreviousCmd(aStateMachine);
       
   207               }
       
   208             break;
   175         default:
   209         default:
   176         	iOutstandingNotifications.InsertL(aNotification);
   210            CCalenState::HandleNotificationL( aNotification, aStateMachine );
   177 			break;
   211             break;
   178         }
   212         }
   179     	
   213         
   180     OstTraceFunctionExit0( CCALENEDITINGSTATE_HANDLENOTIFICATIONL_EXIT );
   214     TRACE_EXIT_POINT;
   181     }
   215     }
   182 
   216 
   183 // end of file
   217 // end of file