calendarui/controller/src/calenmapstate.cpp
changeset 89 b57382753122
child 67 1539a383d7b6
equal deleted inserted replaced
83:5aadd1120515 89:b57382753122
       
     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     case ECalenDayView:    
       
    99     case ECalenMissedEventViewFromIdle: 
       
   100     case ECalenEventViewFromAlarm:
       
   101     case ECalenEventViewFromAlarmStopOnly:
       
   102         {
       
   103         // Issue map launch cancel notification
       
   104         iController.BroadcastNotification(ECalenNotifyCancelMapLaunch);
       
   105         SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
       
   106         ActivateCurrentStateL(aStateMachine);
       
   107         cmdUsed = ETrue;
       
   108         break;
       
   109         }
       
   110         
       
   111     default:
       
   112     		break;
       
   113     }
       
   114     
       
   115     if(cmdUsed)
       
   116 		RequestCallbackL( handler, aCommand );
       
   117 	
       
   118     TRACE_EXIT_POINT;
       
   119     
       
   120     return cmdUsed;
       
   121     }
       
   122 
       
   123 // ----------------------------------------------------------------------------
       
   124 // CCalenMapState::HandleNotificationL
       
   125 // From CCalenState
       
   126 // ----------------------------------------------------------------------------        
       
   127 void CCalenMapState::HandleNotificationL(const TCalenNotification& aNotification,
       
   128                                                  CCalenStateMachine& aStateMachine )
       
   129     {
       
   130     TRACE_ENTRY_POINT;
       
   131     
       
   132     switch( aNotification )
       
   133         {
       
   134         case ECalenNotifyMapClosed:
       
   135         case ECalenNotifyAppForegrounded:
       
   136         	{
       
   137         	SetCurrentState( aStateMachine, iPreviousState );
       
   138         	// We set iOutstandingNotifications for two reasons.
       
   139         	// 1. The new state i.e. the state we are moving back can have notification info.
       
   140         	// 2. When we move to newstate we broadcast all notification from iOutstandingNotifications
       
   141         	//     and inform the registered notifiers.
       
   142         	iOutstandingNotifications.InsertL(aNotification);
       
   143             ActivateCurrentStateL(aStateMachine);
       
   144         	}
       
   145             break;
       
   146         default:
       
   147             CCalenState::HandleNotificationL( aNotification, aStateMachine );
       
   148             break;
       
   149         }
       
   150     
       
   151     TRACE_EXIT_POINT;
       
   152     }
       
   153 
       
   154 
       
   155 // ----------------------------------------------------------------------------
       
   156 // CCalenMapState::HandleStateActivationL
       
   157 // Behavior when state is activated.
       
   158 // ----------------------------------------------------------------------------
       
   159 void CCalenMapState::HandleStateActivationL(CCalenStateMachine& /*aStateMachine*/)
       
   160     {
       
   161     TRACE_ENTRY_POINT;
       
   162     
       
   163     TRACE_EXIT_POINT;
       
   164     }
       
   165 
       
   166  // end of file