|
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: Calendar state machine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CALENSTATE_H |
|
20 #define CALENSTATE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <e32hashtab.h> |
|
25 #include <calennotificationhandler.h> // TCalenNotification |
|
26 #include "calenstatemachine.h" // TCalenStateIndex |
|
27 |
|
28 class CCalenController; |
|
29 class CCalenAsyncCallBack; |
|
30 class CCalenCallbackPackage; |
|
31 |
|
32 // CLASS DEFINITIONS |
|
33 |
|
34 /** |
|
35 * Calendar state |
|
36 */ |
|
37 class CCalenState : public CBase |
|
38 { |
|
39 public: |
|
40 virtual TBool HandleCommandL( const TCalenCommand& aCommand, |
|
41 CCalenStateMachine& aStateMachine ) = 0; |
|
42 virtual void HandleNotificationL(const TCalenNotification& aNotification, |
|
43 CCalenStateMachine& aStateMachine ); |
|
44 |
|
45 virtual void HandleStateActivationL(CCalenStateMachine& aStateMachine); |
|
46 |
|
47 void CancelExecutingCmd(); |
|
48 |
|
49 CCalenStateMachine::TCalenStateIndex PreviousState(); |
|
50 |
|
51 void SetPreviousState(const CCalenStateMachine::TCalenStateIndex& aPreviousState ); |
|
52 |
|
53 ~CCalenState(); |
|
54 |
|
55 protected: |
|
56 |
|
57 /** |
|
58 * Interface to set the current state |
|
59 */ |
|
60 void SetCurrentState( CCalenStateMachine& aStateMachine, |
|
61 const CCalenStateMachine::TCalenStateIndex& aState ); |
|
62 /** |
|
63 * Interface to get the current state |
|
64 */ |
|
65 CCalenStateMachine::TCalenStateIndex CCalenState::GetCurrentState( |
|
66 CCalenStateMachine& aStateMachine); |
|
67 |
|
68 /** |
|
69 * Interface to set the previous state through state machine |
|
70 */ |
|
71 void SetCurrentPreviousState(CCalenStateMachine& aStateMachine, |
|
72 const CCalenStateMachine::TCalenStateIndex& aState); |
|
73 |
|
74 /** |
|
75 * Interface to activate the current state |
|
76 */ |
|
77 void ActivateCurrentStateL(CCalenStateMachine& aStateMachine); |
|
78 |
|
79 /** |
|
80 * Interface to cancel the previous command |
|
81 */ |
|
82 void CancelPreviousCmd(CCalenStateMachine& aStateMachine); |
|
83 |
|
84 protected: |
|
85 virtual void CommandExecuting(); |
|
86 void RequestCallbackL( MCalenCommandHandler* aCommandHandler, const TCalenCommand& aCommand ); |
|
87 |
|
88 protected: |
|
89 void BaseConstructL(); |
|
90 CCalenState( CCalenController& aController, RHashSet<TCalenNotification>& aOutstandingNotifications ); |
|
91 |
|
92 private: |
|
93 class CCalenCallbackPackage : public CBase // going on heap |
|
94 { |
|
95 public: |
|
96 CCalenCallbackPackage( CCalenState* aSelf, |
|
97 TCalenCommand aCommand, |
|
98 MCalenCommandHandler* aCommandHandler); |
|
99 |
|
100 TBool HandleCallBack(); |
|
101 void SetCommandHandler( CCalenState* aSelf, |
|
102 TCalenCommand aCommand, |
|
103 MCalenCommandHandler* aCommandHandler); |
|
104 private: |
|
105 CCalenState* iSelf; // not own |
|
106 TCalenCommand iCommand; |
|
107 MCalenCommandHandler* iCommandHandler; // not own |
|
108 }; |
|
109 static TInt CommandCallback( TAny* aCommandStruct ); |
|
110 CCalenCallbackPackage* iCallBackPackage; |
|
111 |
|
112 protected: |
|
113 CCalenController& iController; |
|
114 RHashSet<TCalenNotification>& iOutstandingNotifications; |
|
115 CCalenStateMachine::TCalenStateIndex iPreviousState; |
|
116 |
|
117 private: |
|
118 CCalenAsyncCallBack* iCmdCallback; |
|
119 }; |
|
120 |
|
121 |
|
122 #endif // CALENSTATE_H |
|
123 |
|
124 // End of file |