calendarui/controller/src/calensettingsstate.cpp
changeset 89 b57382753122
parent 51 0b38fc5b94c6
equal deleted inserted replaced
83:5aadd1120515 89:b57382753122
     1 /*
     1 /*
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // includes
    19 // includes
       
    20 #include <calentoolbar.h>
       
    21 
    20 #include "calensettingsstate.h"
    22 #include "calensettingsstate.h"
    21 #include "calendarui_debug.h"           // Debug macros
    23 #include "calendarui_debug.h"           // Debug macros
    22 #include "calencontroller.h"
    24 #include "calencontroller.h"
    23 #include "calenstatemachine.h"
    25 #include "calenstatemachine.h"
    24 #include "calennotifier.h"
    26 #include "calennotifier.h"
    25 #include "calenviewmanager.h"
    27 #include "calenviewmanager.h"
    26 #include "OstTraceDefinitions.h"
       
    27 #ifdef OST_TRACE_COMPILER_IN_USE
       
    28 #include "calensettingsstateTraces.h"
       
    29 #endif
       
    30 
    28 
    31 // ----------------------------------------------------------------------------
    29 // ----------------------------------------------------------------------------
    32 // CCalenSettingsState::NewLC
    30 // CCalenSettingsState::NewLC
    33 // First stage construction
    31 // First stage construction
    34 // ----------------------------------------------------------------------------
    32 // ----------------------------------------------------------------------------
    35 CCalenSettingsState* CCalenSettingsState::NewLC( CCalenController& aController,
    33 CCalenSettingsState* CCalenSettingsState::NewLC( CCalenController& aController,
    36                     RHashSet<TCalenNotification>& aOutstandingNotifications )
    34                     RHashSet<TCalenNotification>& aOutstandingNotifications )
    37     {
    35     {
    38     OstTraceFunctionEntry0( CCALENSETTINGSSTATE_NEWLC_ENTRY );
    36     TRACE_ENTRY_POINT;
    39     
    37 
    40     CCalenSettingsState* self = new ( ELeave ) CCalenSettingsState( aController,
    38     CCalenSettingsState* self = new ( ELeave ) CCalenSettingsState( aController,
    41                                                     aOutstandingNotifications );
    39                                                     aOutstandingNotifications );
    42     CleanupStack::PushL( self );
    40     CleanupStack::PushL( self );
    43     self->ConstructL();
    41     self->ConstructL();
    44 
    42 
    45     OstTraceFunctionExit0( CCALENSETTINGSSTATE_NEWLC_EXIT );
    43     TRACE_EXIT_POINT;
    46     return self;
    44     return self;
    47     }
    45     }
    48 
    46 
    49 // ----------------------------------------------------------------------------
    47 // ----------------------------------------------------------------------------
    50 // CCalenSettingsState::ConstructL
    48 // CCalenSettingsState::ConstructL
    51 // Second stage construction
    49 // Second stage construction
    52 // ----------------------------------------------------------------------------
    50 // ----------------------------------------------------------------------------
    53 void CCalenSettingsState::ConstructL()
    51 void CCalenSettingsState::ConstructL()
    54     {
    52     {
    55     OstTraceFunctionEntry0( CCALENSETTINGSSTATE_CONSTRUCTL_ENTRY );
    53     TRACE_ENTRY_POINT;
    56     
       
    57     BaseConstructL();
    54     BaseConstructL();
    58     
    55     
    59     OstTraceFunctionExit0( CCALENSETTINGSSTATE_CONSTRUCTL_EXIT );
    56     TRACE_EXIT_POINT;
    60     }
    57     }
    61     
    58     
    62 // ----------------------------------------------------------------------------
    59 // ----------------------------------------------------------------------------
    63 // CCalenSettingsState::CCalenSettingsState
    60 // CCalenSettingsState::CCalenSettingsState
    64 // C++ Constructor
    61 // C++ Constructor
    65 // ----------------------------------------------------------------------------
    62 // ----------------------------------------------------------------------------
    66 CCalenSettingsState::CCalenSettingsState( CCalenController& aController,
    63 CCalenSettingsState::CCalenSettingsState( CCalenController& aController,
    67                     RHashSet<TCalenNotification>& aOutstandingNotifications )
    64                     RHashSet<TCalenNotification>& aOutstandingNotifications )
    68     : CCalenState( aController, aOutstandingNotifications )
    65     : CCalenState( aController, aOutstandingNotifications )
    69     {
    66     {
    70     OstTraceFunctionEntry0( CCALENSETTINGSSTATE_CCALENSETTINGSSTATE_ENTRY );
    67     TRACE_ENTRY_POINT;
    71     
    68     
    72     OstTraceFunctionExit0( CCALENSETTINGSSTATE_CCALENSETTINGSSTATE_EXIT );
    69     TRACE_EXIT_POINT;
    73     }
    70     }
    74     
    71     
    75 // ----------------------------------------------------------------------------
    72 // ----------------------------------------------------------------------------
    76 // CCalenSettingsState::CCalenSettingsState
    73 // CCalenSettingsState::CCalenSettingsState
    77 // Destructor
    74 // Destructor
    78 // ----------------------------------------------------------------------------    
    75 // ----------------------------------------------------------------------------    
    79 CCalenSettingsState::~CCalenSettingsState()
    76 CCalenSettingsState::~CCalenSettingsState()
    80     {
    77     {
    81     OstTraceFunctionEntry0( DUP1_CCALENSETTINGSSTATE_CCALENSETTINGSSTATE_ENTRY );
    78     TRACE_ENTRY_POINT;
    82     
    79     
    83     OstTraceFunctionExit0( DUP1_CCALENSETTINGSSTATE_CCALENSETTINGSSTATE_EXIT );
    80     TRACE_EXIT_POINT;
    84     }
    81     }
    85 
    82 
    86 // ----------------------------------------------------------------------------
    83 // ----------------------------------------------------------------------------
    87 // CCalenSettingsState::HandleCommandL
    84 // CCalenSettingsState::HandleCommandL
    88 // From CCalenState
    85 // From CCalenState
    89 // ----------------------------------------------------------------------------    
    86 // ----------------------------------------------------------------------------    
    90 TBool CCalenSettingsState::HandleCommandL( const TCalenCommand& aCommand,
    87 TBool CCalenSettingsState::HandleCommandL( const TCalenCommand& aCommand,
    91                                         CCalenStateMachine& aStateMachine  )
    88                                         CCalenStateMachine& aStateMachine  )
    92     {
    89     {
    93     OstTraceFunctionEntry0( CCALENSETTINGSSTATE_HANDLECOMMANDL_ENTRY );
    90     TRACE_ENTRY_POINT;
    94     
    91 	    
    95     TInt cmd = aCommand.Command();
    92     TInt cmd = aCommand.Command();
    96     MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd );
    93     MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd );
    97 	    
    94 	    
    98     ASSERT( handler ); 
    95     ASSERT( handler ); 
    99     TBool cmdUsed = EFalse;
    96     TBool cmdUsed = EFalse;
   105             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
   102             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState );
   106             ActivateCurrentStateL(aStateMachine);
   103             ActivateCurrentStateL(aStateMachine);
   107             cmdUsed = ETrue;
   104             cmdUsed = ETrue;
   108             }
   105             }
   109             break;
   106             break;
   110         case ECalenMonthView:
   107         case ECalenMissedEventViewFromIdle:
   111         case ECalenAgendaView:
   108             {
       
   109             cmdUsed = ETrue;
       
   110             break;
       
   111             }
       
   112         case ECalenEventViewFromAlarm:
       
   113         case ECalenEventViewFromAlarmStopOnly:
   112         case ECalenDayView:
   114         case ECalenDayView:
   113         case ECalenStartActiveStep:
       
   114             {
   115             {
   115             // set previous state to idle
       
   116             CCalenStateMachine::TCalenStateIndex cachedState = CCalenStateMachine::ECalenIdleState;
       
   117             SetCurrentState( aStateMachine, CCalenStateMachine::ECalenPopulationState );
       
   118             SetCurrentPreviousState( aStateMachine, cachedState );
       
   119             ActivateCurrentStateL(aStateMachine);               
       
   120             cmdUsed = ETrue;
   116             cmdUsed = ETrue;
   121             }
   117             }
   122             break;
   118             break;
   123         default:
   119         default:
   124             break;
   120             break;
   126     if(cmdUsed)
   122     if(cmdUsed)
   127         {
   123         {
   128         RequestCallbackL( handler, aCommand );
   124         RequestCallbackL( handler, aCommand );
   129         }
   125         }
   130 
   126 
   131     OstTraceFunctionExit0( CCALENSETTINGSSTATE_HANDLECOMMANDL_EXIT );
   127     TRACE_EXIT_POINT;
   132     return cmdUsed;
   128     return cmdUsed;
   133     }
   129     }
   134 
   130 
   135 // ----------------------------------------------------------------------------
   131 // ----------------------------------------------------------------------------
   136 // CCalenSettingsState::HandleNotificationL
   132 // CCalenSettingsState::HandleNotificationL
   137 // From CCalenState
   133 // From CCalenState
   138 // ----------------------------------------------------------------------------        
   134 // ----------------------------------------------------------------------------        
   139 void CCalenSettingsState::HandleNotificationL(const TCalenNotification& aNotification,
   135 void CCalenSettingsState::HandleNotificationL(const TCalenNotification& aNotification,
   140                                                CCalenStateMachine& aStateMachine )
   136                                                CCalenStateMachine& aStateMachine )
   141     {
   137     {
   142     OstTraceFunctionEntry0( CCALENSETTINGSSTATE_HANDLENOTIFICATIONL_ENTRY );
   138     TRACE_ENTRY_POINT;
   143     
   139     
   144     switch( aNotification )
   140     switch( aNotification )
   145         {
   141         {
   146         case ECalenNotifyPluginEnabledDisabled:
   142         case ECalenNotifyPluginEnabledDisabled:
       
   143         case ECalenNotifyEComRegistryChanged:    
   147             {
   144             {
   148 			 CCalenState::HandleNotificationL( aNotification, aStateMachine );
   145      		CCalenState::HandleNotificationL( aNotification, aStateMachine );
   149             }
   146             }
   150             break;
   147             break;
   151         case ECalenNotifySettingsClosed:
   148         case ECalenNotifySettingsClosed:
   152             {
   149             {
   153             // Settings closed, go back to previous state.
   150             // Settings closed, go back to previous state.
   154             SetCurrentState( aStateMachine, iPreviousState );
   151             SetCurrentState( aStateMachine, iPreviousState );
   155             iOutstandingNotifications.InsertL(aNotification);
   152             iOutstandingNotifications.InsertL(aNotification);
   156             ActivateCurrentStateL(aStateMachine);
   153             ActivateCurrentStateL(aStateMachine);
   157             }
   154             }
   158             break;
   155             break;
   159         case ECalenNotifySystemLocaleChanged:
   156 
   160             {
       
   161             CCalenState::HandleNotificationL( aNotification, aStateMachine );
       
   162             }
       
   163             break;
       
   164         default:
   157         default:
   165             // default is defer all other notifications when we are in setting state
   158             // default is defer all other notifications when we are in setting state
   166             iOutstandingNotifications.InsertL(aNotification);
   159             iOutstandingNotifications.InsertL(aNotification);
   167             break;
   160             break;
   168         }
   161         }
   169     
   162     
   170     OstTraceFunctionExit0( CCALENSETTINGSSTATE_HANDLENOTIFICATIONL_EXIT );
   163     TRACE_EXIT_POINT;
   171     }
   164     }
   172 
   165 
   173 // ----------------------------------------------------------------------------
   166 // ----------------------------------------------------------------------------
   174 // CCalenSettingsState::HandleStateActivationL
   167 // CCalenSettingsState::HandleStateActivationL
   175 // Behavior when state is activated.
   168 // Behavior when state is activated.
   176 // ----------------------------------------------------------------------------
   169 // ----------------------------------------------------------------------------
   177 void CCalenSettingsState::HandleStateActivationL()
   170 void CCalenSettingsState::HandleStateActivationL()
   178     {
   171     {
   179     OstTraceFunctionEntry0( CCALENSETTINGSSTATE_HANDLESTATEACTIVATIONL_ENTRY );
   172     TRACE_ENTRY_POINT;
   180     
   173     
   181     if( iOutstandingNotifications.FindL(ECalenNotifySettingsCRepKeyChanged) )
   174     if( iOutstandingNotifications.FindL(ECalenNotifySettingsCRepKeyChanged) )
   182         {
   175         {
   183         iController.Notifier().BroadcastApprovedNotification( ECalenNotifySettingsCRepKeyChanged );
   176         iController.Notifier().BroadcastApprovedNotification( ECalenNotifySettingsCRepKeyChanged );
   184         }
   177         }
   185     
   178     
   186     OstTraceFunctionExit0( CCALENSETTINGSSTATE_HANDLESTATEACTIVATIONL_EXIT );
   179     TRACE_EXIT_POINT;
   187     }
   180     }
   188 
   181 
   189  // end of file
   182  // end of file