diff -r 000000000000 -r f979ecb2b13e calendarui/controller/inc/calenstate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/calendarui/controller/inc/calenstate.h Tue Feb 02 10:12:19 2010 +0200 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Calendar state machine +* +*/ + + +#ifndef CALENSTATE_H +#define CALENSTATE_H + +// INCLUDES +#include +#include +#include // TCalenNotification +#include "calenstatemachine.h" // TCalenStateIndex + +class CCalenController; +class CCalenAsyncCallBack; +class CCalenCallbackPackage; + +// CLASS DEFINITIONS + +/** +* Calendar state +*/ +class CCalenState : public CBase + { + public: + virtual TBool HandleCommandL( const TCalenCommand& aCommand, + CCalenStateMachine& aStateMachine ) = 0; + virtual void HandleNotificationL(const TCalenNotification& aNotification, + CCalenStateMachine& aStateMachine ); + + virtual void HandleStateActivationL(CCalenStateMachine& aStateMachine); + + void CancelExecutingCmd(); + + CCalenStateMachine::TCalenStateIndex PreviousState(); + + void SetPreviousState(const CCalenStateMachine::TCalenStateIndex& aPreviousState ); + + ~CCalenState(); + + protected: + + /** + * Interface to set the current state + */ + void SetCurrentState( CCalenStateMachine& aStateMachine, + const CCalenStateMachine::TCalenStateIndex& aState ); + /** + * Interface to get the current state + */ + CCalenStateMachine::TCalenStateIndex CCalenState::GetCurrentState( + CCalenStateMachine& aStateMachine); + + /** + * Interface to set the previous state through state machine + */ + void SetCurrentPreviousState(CCalenStateMachine& aStateMachine, + const CCalenStateMachine::TCalenStateIndex& aState); + + /** + * Interface to activate the current state + */ + void ActivateCurrentStateL(CCalenStateMachine& aStateMachine); + + /** + * Interface to cancel the previous command + */ + void CancelPreviousCmd(CCalenStateMachine& aStateMachine); + + protected: + virtual void CommandExecuting(); + void RequestCallbackL( MCalenCommandHandler* aCommandHandler, const TCalenCommand& aCommand ); + + protected: + void BaseConstructL(); + CCalenState( CCalenController& aController, RHashSet& aOutstandingNotifications ); + + private: + class CCalenCallbackPackage : public CBase // going on heap + { + public: + CCalenCallbackPackage( CCalenState* aSelf, + TCalenCommand aCommand, + MCalenCommandHandler* aCommandHandler); + + TBool HandleCallBack(); + void SetCommandHandler( CCalenState* aSelf, + TCalenCommand aCommand, + MCalenCommandHandler* aCommandHandler); + private: + CCalenState* iSelf; // not own + TCalenCommand iCommand; + MCalenCommandHandler* iCommandHandler; // not own + }; + static TInt CommandCallback( TAny* aCommandStruct ); + CCalenCallbackPackage* iCallBackPackage; + + protected: + CCalenController& iController; + RHashSet& iOutstandingNotifications; + CCalenStateMachine::TCalenStateIndex iPreviousState; + + private: + CCalenAsyncCallBack* iCmdCallback; + }; + + +#endif // CALENSTATE_H + +// End of file