calendarui/controller/src/caleneditingstate.cpp
changeset 0 f979ecb2b13e
child 18 c198609911f9
child 65 12af337248b1
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Calendar state machine
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // includes
       
    20 #include "caleneditingstate.h"
       
    21 #include "calendarui_debug.h"           // Debug macros
       
    22 #include "calencontroller.h"
       
    23 #include "calenstatemachine.h"
       
    24 #include "calennotifier.h"
       
    25 
       
    26 // ----------------------------------------------------------------------------
       
    27 // CCalenEditingState::NewLC
       
    28 // First stage construction
       
    29 // ----------------------------------------------------------------------------
       
    30 CCalenEditingState* CCalenEditingState::NewLC( CCalenController& aController,
       
    31                     RHashSet<TCalenNotification>& aOutstandingNotifications )
       
    32     {
       
    33     TRACE_ENTRY_POINT;
       
    34 
       
    35     CCalenEditingState* self = new( ELeave ) CCalenEditingState( aController,
       
    36                                                     aOutstandingNotifications );
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL();
       
    39 
       
    40     TRACE_EXIT_POINT;
       
    41     return self;
       
    42     }
       
    43 
       
    44 // ----------------------------------------------------------------------------
       
    45 // CCalenEditingState::ConstructL
       
    46 // Second stage construction
       
    47 // ----------------------------------------------------------------------------
       
    48 void CCalenEditingState::ConstructL()
       
    49     {
       
    50     TRACE_ENTRY_POINT;
       
    51     BaseConstructL();
       
    52     
       
    53     TRACE_EXIT_POINT;
       
    54     }
       
    55     
       
    56 // ----------------------------------------------------------------------------
       
    57 // CCalenEditingState::CCalenEditingState
       
    58 // C++ Constructor
       
    59 // ----------------------------------------------------------------------------
       
    60 CCalenEditingState::CCalenEditingState( CCalenController& aController,
       
    61             RHashSet<TCalenNotification>& aOutstandingNotifications )
       
    62     : CCalenState( aController, aOutstandingNotifications )
       
    63     {
       
    64     TRACE_ENTRY_POINT;
       
    65 
       
    66     TRACE_EXIT_POINT;
       
    67     }
       
    68     
       
    69 // ----------------------------------------------------------------------------
       
    70 // CCalenEditingState::CCalenEditingState
       
    71 // Destructor
       
    72 // ----------------------------------------------------------------------------    
       
    73 CCalenEditingState::~CCalenEditingState()
       
    74     {
       
    75     TRACE_ENTRY_POINT;
       
    76     
       
    77     TRACE_EXIT_POINT;
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // CCalenEditingState::HandleCommandL
       
    82 // From CCalenState
       
    83 // ----------------------------------------------------------------------------    
       
    84 TBool CCalenEditingState::HandleCommandL( const TCalenCommand& aCommand,
       
    85                               CCalenStateMachine& aStateMachine )
       
    86     {
       
    87     TRACE_ENTRY_POINT
       
    88     
       
    89     TInt cmd = aCommand.Command();
       
    90     MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd );
       
    91 	    
       
    92 	ASSERT( handler );
       
    93      
       
    94     TBool cmdUsed = EFalse;
       
    95     switch( cmd )
       
    96         {
       
    97     	case ECalenDeleteCurrentEntry:
       
    98     	case ECalenDeleteSeries:
       
    99     	case ECalenDeleteCurrentOccurrence:
       
   100     		{
       
   101     		CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
       
   102 	        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenDeletingState);
       
   103 	        SetCurrentPreviousState( aStateMachine, cachedState );
       
   104 	        ActivateCurrentStateL(aStateMachine);
       
   105 	        
       
   106 	        cmdUsed = ETrue;
       
   107 	        break;
       
   108     		}
       
   109     	case ECalenSend: // For handling send in viewer
       
   110     		{
       
   111     		CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
       
   112 	        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenSendingState );
       
   113 	        SetCurrentPreviousState( aStateMachine, cachedState );
       
   114 	        ActivateCurrentStateL(aStateMachine);        
       
   115 	        
       
   116 	        cmdUsed = ETrue;
       
   117 	        break;	
       
   118     		}
       
   119     	case ECalenFasterAppExit:
       
   120     		{
       
   121 	        SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
       
   122 	        ActivateCurrentStateL(aStateMachine);
       
   123 	        cmdUsed = ETrue;
       
   124 	        break;
       
   125         	}
       
   126     	case ECalenGetLocation:
       
   127     	case ECalenShowLocation:
       
   128     		{
       
   129     		CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine);
       
   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     	    }   
       
   159     	default:
       
   160     		break;
       
   161     		
       
   162         }
       
   163     
       
   164 	if(cmdUsed)
       
   165 	    {
       
   166 	    RequestCallbackL( handler, aCommand );
       
   167 	    }
       
   168 	
       
   169     TRACE_EXIT_POINT;
       
   170     
       
   171     return cmdUsed;
       
   172     }
       
   173 
       
   174 // ----------------------------------------------------------------------------
       
   175 // CCalenEditingState::HandleNotificationL
       
   176 // From CCalenState
       
   177 // ----------------------------------------------------------------------------        
       
   178 void CCalenEditingState::HandleNotificationL(const TCalenNotification& aNotification,
       
   179                                               CCalenStateMachine& aStateMachine )
       
   180     {
       
   181     TRACE_ENTRY_POINT;
       
   182     
       
   183     switch( aNotification )
       
   184         {
       
   185         case ECalenNotifyEntryClosed:  // issued when new entry dialog is cancelled
       
   186         case ECalenNotifyEntrySaved:
       
   187         case ECalenNotifyInstanceSaved:
       
   188         case ECalenNotifyDialogClosed:
       
   189         case ECalenNotifyEntryDeleted:
       
   190         case ECalenNotifyMarkedEntryCompleted:
       
   191             {
       
   192             SetCurrentState( aStateMachine, iPreviousState );
       
   193             // Let new state does the broadcast
       
   194             iOutstandingNotifications.InsertL(aNotification);
       
   195 			ActivateCurrentStateL(aStateMachine);
       
   196             }
       
   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;
       
   209         default:
       
   210            CCalenState::HandleNotificationL( aNotification, aStateMachine );
       
   211             break;
       
   212         }
       
   213         
       
   214     TRACE_EXIT_POINT;
       
   215     }
       
   216 
       
   217 // end of file