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