calendarui/controller/src/calenmapstate.cpp
changeset 0 f979ecb2b13e
child 13 1984aceb8774
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2007 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:   Map state for Calendar
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // includes
       
    21 #include "calenmapstate.h"
       
    22 #include "calendarui_debug.h"           // Debug macros
       
    23 #include "calencontroller.h"
       
    24 #include "calenstatemachine.h"
       
    25 #include "calennotifier.h"
       
    26 
       
    27 // ----------------------------------------------------------------------------
       
    28 // CCalenMapState::NewLC
       
    29 // First stage construction
       
    30 // ----------------------------------------------------------------------------
       
    31 CCalenMapState* CCalenMapState::NewLC( CCalenController& aController,
       
    32                                        RHashSet<TCalenNotification>& aOutstandingNotifications )
       
    33     {
       
    34     TRACE_ENTRY_POINT;
       
    35 
       
    36     CCalenMapState* self = new ( ELeave ) CCalenMapState( aController,
       
    37                                                           aOutstandingNotifications );
       
    38     CleanupStack::PushL( self );
       
    39     self->ConstructL();
       
    40 
       
    41     TRACE_EXIT_POINT;
       
    42     return self;
       
    43     }
       
    44 
       
    45 // ----------------------------------------------------------------------------
       
    46 // CCalenMapState::ConstructL
       
    47 // Second stage construction
       
    48 // ----------------------------------------------------------------------------
       
    49 void CCalenMapState::ConstructL()
       
    50     {
       
    51     TRACE_ENTRY_POINT;
       
    52     BaseConstructL();
       
    53     
       
    54     TRACE_EXIT_POINT;
       
    55     }
       
    56     
       
    57 // ----------------------------------------------------------------------------
       
    58 // CCalenMapState::CCalenMapState
       
    59 // C++ Constructor
       
    60 // ----------------------------------------------------------------------------
       
    61 CCalenMapState::CCalenMapState( CCalenController& aController, RHashSet<TCalenNotification>& aOutstandingNotifications )
       
    62     : CCalenState( aController, aOutstandingNotifications )
       
    63     {
       
    64     TRACE_ENTRY_POINT;
       
    65     
       
    66     TRACE_EXIT_POINT;
       
    67     }
       
    68     
       
    69 // ----------------------------------------------------------------------------
       
    70 // CCalenMapState::CCalenMapState
       
    71 // Destructor
       
    72 // ----------------------------------------------------------------------------    
       
    73 CCalenMapState::~CCalenMapState()
       
    74     {
       
    75     TRACE_ENTRY_POINT;
       
    76     
       
    77     TRACE_EXIT_POINT;
       
    78     }
       
    79 
       
    80 // ----------------------------------------------------------------------------
       
    81 // CCalenMapState::HandleCommandL
       
    82 // From CCalenState
       
    83 // ----------------------------------------------------------------------------    
       
    84 TBool CCalenMapState::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 ECalenFasterAppExit:
       
    98 		{
       
    99 		// Issue map launch cancel notification
       
   100 		iController.BroadcastNotification(ECalenNotifyCancelMapLaunch);
       
   101         SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
       
   102         ActivateCurrentStateL(aStateMachine);
       
   103         cmdUsed = ETrue;
       
   104         break;
       
   105    		}
       
   106     case ECalenMissedEventViewFromIdle:
       
   107         {
       
   108         // Issue map launch cancel notification
       
   109         iController.BroadcastNotification(ECalenNotifyCancelMapLaunch);
       
   110         SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
       
   111         ActivateCurrentStateL(aStateMachine);
       
   112         cmdUsed = ETrue;
       
   113         break;
       
   114         }
       
   115         
       
   116     case ECalenEventViewFromAlarm:
       
   117     case ECalenEventViewFromAlarmStopOnly:
       
   118         {
       
   119         // Issue map launch cancel notification
       
   120         iController.BroadcastNotification(ECalenNotifyCancelMapLaunch);
       
   121         SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
       
   122         ActivateCurrentStateL(aStateMachine);
       
   123         cmdUsed = ETrue;
       
   124         break;
       
   125         }
       
   126         
       
   127     default:
       
   128     		break;
       
   129     }
       
   130     
       
   131     if(cmdUsed)
       
   132 		RequestCallbackL( handler, aCommand );
       
   133 	
       
   134     TRACE_EXIT_POINT;
       
   135     
       
   136     return cmdUsed;
       
   137     }
       
   138 
       
   139 // ----------------------------------------------------------------------------
       
   140 // CCalenMapState::HandleNotificationL
       
   141 // From CCalenState
       
   142 // ----------------------------------------------------------------------------        
       
   143 void CCalenMapState::HandleNotificationL(const TCalenNotification& aNotification,
       
   144                                                  CCalenStateMachine& aStateMachine )
       
   145     {
       
   146     TRACE_ENTRY_POINT;
       
   147     
       
   148     switch( aNotification )
       
   149         {
       
   150         case ECalenNotifyMapClosed:
       
   151         case ECalenNotifyAppForegrounded:
       
   152         	{
       
   153         	SetCurrentState( aStateMachine, iPreviousState );
       
   154         	// We set iOutstandingNotifications for two reasons.
       
   155         	// 1. The new state i.e. the state we are moving back can have notification info.
       
   156         	// 2. When we move to newstate we broadcast all notification from iOutstandingNotifications
       
   157         	//     and inform the registered notifiers.
       
   158         	iOutstandingNotifications.InsertL(aNotification);
       
   159             ActivateCurrentStateL(aStateMachine);
       
   160         	}
       
   161             break;
       
   162         default:
       
   163             CCalenState::HandleNotificationL( aNotification, aStateMachine );
       
   164             break;
       
   165         }
       
   166     
       
   167     TRACE_EXIT_POINT;
       
   168     }
       
   169 
       
   170 
       
   171 // ----------------------------------------------------------------------------
       
   172 // CCalenMapState::HandleStateActivationL
       
   173 // Behavior when state is activated.
       
   174 // ----------------------------------------------------------------------------
       
   175 void CCalenMapState::HandleStateActivationL(CCalenStateMachine& /*aStateMachine*/)
       
   176     {
       
   177     TRACE_ENTRY_POINT;
       
   178     
       
   179     TRACE_EXIT_POINT;
       
   180     }
       
   181 
       
   182  // end of file