13 * |
13 * |
14 * Description: Calendar state machine |
14 * Description: Calendar state machine |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 #include <avkon.hrh> |
|
19 #include <coemain.h> |
|
20 #include <aknappui.h> |
18 |
21 |
19 // includes |
22 // includes |
20 #include "calendarui_debug.h" // Debug macros |
23 #include "calendarui_debug.h" // Debug macros |
21 |
|
22 #include "calenstatemachine.h" |
24 #include "calenstatemachine.h" |
23 #include "calenstate.h" |
25 #include "calenstate.h" |
24 #include "calenidlestate.h" |
26 #include "calenidlestate.h" |
25 #include "calenpopulationstate.h" |
27 #include "calenbackgroundstate.h" |
26 #include "calendeletingstate.h" |
28 #include "calendeletingstate.h" |
27 #include "calenbackgroundstate.h" |
|
28 #include "caleneditingstate.h" |
29 #include "caleneditingstate.h" |
29 #include "calenexitingstate.h" |
30 #include "calenexitingstate.h" |
30 #include "calenhelpstate.h" |
31 #include "calenhelpstate.h" |
|
32 #include "calenpopulationstate.h" |
31 #include "calenprintingstate.h" |
33 #include "calenprintingstate.h" |
32 #include "calensendingstate.h" |
34 #include "calensendingstate.h" |
33 #include "calensettingsstate.h" |
35 #include "calensettingsstate.h" |
34 #include "calenviewingstate.h" |
36 #include "calenviewingstate.h" |
35 #include "OstTraceDefinitions.h" |
37 #include "calenmapstate.h" |
36 #ifdef OST_TRACE_COMPILER_IN_USE |
38 #include "calenattachmentstate.h" |
37 #include "calenstatemachineTraces.h" |
39 #include "calenalarmstate.h" |
38 #endif |
|
39 |
|
40 |
40 |
41 const TInt KHashLength = 64; |
41 const TInt KHashLength = 64; |
|
42 |
42 // ---------------------------------------------------------------------------- |
43 // ---------------------------------------------------------------------------- |
43 // CCalenStateMachine::NewL |
44 // CCalenStateMachine::NewL |
44 // Two phased constructor. |
45 // Two phased constructor. |
45 // (other items were commented in a header). |
46 // (other items were commented in a header). |
46 // ---------------------------------------------------------------------------- |
47 // ---------------------------------------------------------------------------- |
47 // |
48 // |
48 CCalenStateMachine* CCalenStateMachine::NewL( CCalenController& aController ) |
49 CCalenStateMachine* CCalenStateMachine::NewL( CCalenController& aController ) |
49 { |
50 { |
50 OstTraceFunctionEntry0( CCALENSTATEMACHINE_NEWL_ENTRY ); |
51 TRACE_ENTRY_POINT; |
51 |
52 |
52 CCalenStateMachine* self = new ( ELeave ) CCalenStateMachine( aController ); |
53 CCalenStateMachine* self = new ( ELeave ) CCalenStateMachine( aController ); |
53 CleanupStack::PushL( self ); |
54 CleanupStack::PushL( self ); |
54 self->ConstructL(); |
55 self->ConstructL(); |
55 CleanupStack::Pop( self ); |
56 CleanupStack::Pop( self ); |
56 |
57 |
57 OstTraceFunctionExit0( CCALENSTATEMACHINE_NEWL_EXIT ); |
58 TRACE_EXIT_POINT; |
58 return self; |
59 return self; |
59 } |
60 } |
60 |
61 |
61 // ---------------------------------------------------------------------------- |
62 // ---------------------------------------------------------------------------- |
62 // CCalenStateMachine::CCalenStateMachine |
63 // CCalenStateMachine::CCalenStateMachine |
66 // |
67 // |
67 CCalenStateMachine::CCalenStateMachine( CCalenController& aController ) |
68 CCalenStateMachine::CCalenStateMachine( CCalenController& aController ) |
68 : iController( aController ) , |
69 : iController( aController ) , |
69 iOutstandingNotifications(&::HashCalenNotificationFunction,&::HashCalenNotificationIdentityRelation) |
70 iOutstandingNotifications(&::HashCalenNotificationFunction,&::HashCalenNotificationIdentityRelation) |
70 { |
71 { |
71 OstTraceFunctionEntry0( CCALENSTATEMACHINE_CCALENSTATEMACHINE_ENTRY ); |
72 TRACE_ENTRY_POINT; |
72 |
73 TRACE_EXIT_POINT; |
73 OstTraceFunctionExit0( CCALENSTATEMACHINE_CCALENSTATEMACHINE_EXIT ); |
|
74 } |
74 } |
75 |
75 |
76 // ---------------------------------------------------------------------------- |
76 // ---------------------------------------------------------------------------- |
77 // CCalenStateMachine::ConstructL |
77 // CCalenStateMachine::ConstructL |
78 // Second phase of construction. |
78 // Second phase of construction. |
79 // (other items were commented in a header). |
79 // (other items were commented in a header). |
80 // ---------------------------------------------------------------------------- |
80 // ---------------------------------------------------------------------------- |
81 // |
81 // |
82 void CCalenStateMachine::ConstructL() |
82 void CCalenStateMachine::ConstructL() |
83 { |
83 { |
84 OstTraceFunctionEntry0( CCALENSTATEMACHINE_CONSTRUCTL_ENTRY ); |
84 TRACE_ENTRY_POINT; |
85 |
85 |
86 CCalenState* state = NULL; |
86 CCalenState* state = NULL; |
87 |
87 |
88 iOutstandingNotifications.ReserveL(KHashLength); |
88 iOutstandingNotifications.ReserveL(KHashLength); |
89 state = CCalenIdleState::NewLC( iController, iOutstandingNotifications ); |
89 state = CCalenIdleState::NewLC( iController, iOutstandingNotifications ); |
90 iStates.InsertL( state, ECalenIdleState ); |
90 iStates.InsertL( state, ECalenIdleState ); |
127 CleanupStack::Pop( state ); |
127 CleanupStack::Pop( state ); |
128 |
128 |
129 state = CCalenExitingState::NewLC( iController, iOutstandingNotifications ); |
129 state = CCalenExitingState::NewLC( iController, iOutstandingNotifications ); |
130 iStates.InsertL( state, ECalenExitingState ); |
130 iStates.InsertL( state, ECalenExitingState ); |
131 CleanupStack::Pop( state ); |
131 CleanupStack::Pop( state ); |
|
132 |
|
133 state = CCalenMapState::NewLC( iController, iOutstandingNotifications ); |
|
134 iStates.InsertL( state, ECalenMapState ); |
|
135 CleanupStack::Pop( state ); |
|
136 |
|
137 state = CCalenAttachmentState::NewLC( iController, iOutstandingNotifications ); |
|
138 iStates.InsertL( state, ECalenAttachmentState ); |
|
139 CleanupStack::Pop( state ); |
|
140 |
|
141 state = CCalenAlarmState::NewLC( iController, iOutstandingNotifications ); |
|
142 iStates.InsertL( state, ECalenAlarmState ); |
|
143 CleanupStack::Pop( state ); |
|
144 |
132 |
145 |
133 ASSERT( iStates.Count() == KCalenLastState ); |
146 ASSERT( iStates.Count() == KCalenLastState ); |
134 |
147 |
135 OstTraceFunctionExit0( CCALENSTATEMACHINE_CONSTRUCTL_EXIT ); |
148 TRACE_EXIT_POINT; |
136 } |
149 } |
137 |
150 |
138 // ---------------------------------------------------------------------------- |
151 // ---------------------------------------------------------------------------- |
139 // CCalenStateMachine::~CCalenStateMachine |
152 // CCalenStateMachine::~CCalenStateMachine |
140 // Destructor. |
153 // Destructor. |
141 // (other items were commented in a header). |
154 // (other items were commented in a header). |
142 // ---------------------------------------------------------------------------- |
155 // ---------------------------------------------------------------------------- |
143 // |
156 // |
144 CCalenStateMachine::~CCalenStateMachine() |
157 CCalenStateMachine::~CCalenStateMachine() |
145 { |
158 { |
146 OstTraceFunctionEntry0( DUP1_CCALENSTATEMACHINE_CCALENSTATEMACHINE_ENTRY ); |
159 TRACE_ENTRY_POINT; |
147 |
160 |
148 iOutstandingNotifications.Close(); |
161 iOutstandingNotifications.Close(); |
149 iStates.ResetAndDestroy(); |
162 iStates.ResetAndDestroy(); |
150 |
163 |
151 OstTraceFunctionExit0( DUP1_CCALENSTATEMACHINE_CCALENSTATEMACHINE_EXIT ); |
164 TRACE_EXIT_POINT; |
152 } |
165 } |
153 |
166 |
154 // ---------------------------------------------------------------------------- |
167 // ---------------------------------------------------------------------------- |
155 // CCalenStateMachine::HandleNotification |
168 // CCalenStateMachine::HandleNotification |
156 // Notification handler interface. |
169 // Notification handler interface. |
157 // (other items were commented in a header). |
170 // (other items were commented in a header). |
158 // ---------------------------------------------------------------------------- |
171 // ---------------------------------------------------------------------------- |
159 // |
172 // |
160 void CCalenStateMachine::HandleNotification(const TCalenNotification aNotification ) |
173 void CCalenStateMachine::HandleNotification(const TCalenNotification aNotification ) |
161 { |
174 { |
162 OstTraceFunctionEntry0( CCALENSTATEMACHINE_HANDLENOTIFICATION_ENTRY ); |
175 TRACE_ENTRY_POINT; |
163 |
176 |
164 TRAP_IGNORE(iStates[iCurrentState]->HandleNotificationL( aNotification, *this)); |
177 TRAPD(error,iStates[iCurrentState]->HandleNotificationL( aNotification, *this)); |
165 |
178 if(error!=KErrNone) |
166 OstTraceFunctionExit0( CCALENSTATEMACHINE_HANDLENOTIFICATION_EXIT ); |
179 { |
167 } |
180 // do avoid warning |
168 |
181 } |
169 // ---------------------------------------------------------------------------- |
182 |
170 // CCalenStateMachine::CurrentState |
183 TRACE_EXIT_POINT; |
171 // Returns the current state in which calendar is. |
184 } |
172 // (other items were commented in a header). |
|
173 // ---------------------------------------------------------------------------- |
|
174 // |
|
175 CCalenStateMachine::TCalenStateIndex CCalenStateMachine::CurrentState() |
|
176 { |
|
177 OstTraceFunctionEntry0( CCALENSTATEMACHINE_CURRENTSTATE_ENTRY ); |
|
178 |
|
179 OstTraceFunctionExit0( CCALENSTATEMACHINE_CURRENTSTATE_EXIT ); |
|
180 return iCurrentState; |
|
181 } |
|
182 |
185 |
183 // ---------------------------------------------------------------------------- |
186 // ---------------------------------------------------------------------------- |
184 // CCalenStateMachine::HandleCommandL |
187 // CCalenStateMachine::HandleCommandL |
185 // Command handler interface. |
188 // Command handler interface. |
186 // (other items were commented in a header). |
189 // (other items were commented in a header). |
187 // ---------------------------------------------------------------------------- |
190 // ---------------------------------------------------------------------------- |
188 // |
191 // |
189 TBool CCalenStateMachine::HandleCommandL( const TCalenCommand& aCommand ) |
192 TBool CCalenStateMachine::HandleCommandL( const TCalenCommand& aCommand ) |
190 { |
193 { |
191 OstTraceFunctionEntry0( CCALENSTATEMACHINE_HANDLECOMMANDL_ENTRY ); |
194 TRACE_ENTRY_POINT; |
|
195 |
|
196 if( aCommand.Command() == EAknSoftkeyExit |
|
197 || aCommand.Command() == EAknCmdExit |
|
198 || aCommand.Command() == EEikCmdExit ) |
|
199 { |
|
200 iAvkonAppUi->Exit(); |
|
201 } |
192 |
202 |
193 TBool cmdUsed = iStates[iCurrentState]->HandleCommandL( aCommand, *this); |
203 TBool cmdUsed = iStates[iCurrentState]->HandleCommandL( aCommand, *this); |
194 |
204 |
195 OstTraceFunctionExit0( CCALENSTATEMACHINE_HANDLECOMMANDL_EXIT ); |
205 TRACE_EXIT_POINT; |
196 return cmdUsed; |
206 return cmdUsed; |
197 } |
207 } |
198 |
208 |
199 // ---------------------------------------------------------------------------- |
209 // ---------------------------------------------------------------------------- |
200 // CCalenStateMachine::CancelPreviousCmd |
210 // CCalenStateMachine::CancelPreviousCmd |
202 // (other items were commented in a header). |
212 // (other items were commented in a header). |
203 // ---------------------------------------------------------------------------- |
213 // ---------------------------------------------------------------------------- |
204 // |
214 // |
205 void CCalenStateMachine::CancelPreviousCmd() |
215 void CCalenStateMachine::CancelPreviousCmd() |
206 { |
216 { |
207 OstTraceFunctionEntry0( CCALENSTATEMACHINE_CANCELPREVIOUSCMD_ENTRY ); |
217 TRACE_ENTRY_POINT; |
208 |
218 |
209 TCalenStateIndex previousState = iStates[iCurrentState]->PreviousState(); |
219 TCalenStateIndex previousState = iStates[iCurrentState]->PreviousState(); |
210 iStates[iCurrentState]->CancelExecutingCmd(); |
220 iStates[iCurrentState]->CancelExecutingCmd(); |
211 |
221 |
212 if(previousState != iCurrentState) |
222 if(previousState != iCurrentState) |
213 { |
223 { |
214 iCurrentState = previousState; |
224 iCurrentState = previousState; |
215 } |
225 } |
216 |
226 |
217 OstTraceFunctionExit0( CCALENSTATEMACHINE_CANCELPREVIOUSCMD_EXIT ); |
227 TRACE_EXIT_POINT; |
218 } |
228 } |
219 |
229 |
220 // ---------------------------------------------------------------------------- |
230 // ---------------------------------------------------------------------------- |
221 // CCalenStateMachine::GetCurrentState |
231 // CCalenStateMachine::GetCurrentState |
222 // Interface to get the current state |
232 // Interface to get the current state |
223 // (other items were commented in a header). |
233 // (other items were commented in a header). |
224 // ---------------------------------------------------------------------------- |
234 // ---------------------------------------------------------------------------- |
225 // |
235 // |
226 CCalenStateMachine::TCalenStateIndex CCalenStateMachine::GetCurrentState() |
236 CCalenStateMachine::TCalenStateIndex CCalenStateMachine::GetCurrentState() |
227 { |
237 { |
228 OstTraceFunctionEntry0( CCALENSTATEMACHINE_GETCURRENTSTATE_ENTRY ); |
238 TRACE_ENTRY_POINT; |
229 |
239 TRACE_EXIT_POINT; |
230 OstTraceFunctionExit0( CCALENSTATEMACHINE_GETCURRENTSTATE_EXIT ); |
240 |
231 return iCurrentState; |
241 return iCurrentState; |
232 } |
242 } |
233 |
243 |
234 // ---------------------------------------------------------------------------- |
244 // ---------------------------------------------------------------------------- |
235 // CCalenStateMachine::SetCurrentState |
245 // CCalenStateMachine::SetCurrentState |
236 // Interface to set the current state |
246 // Interface to set the current state |
237 // (other items were commented in a header). |
247 // (other items were commented in a header). |
238 // ---------------------------------------------------------------------------- |
248 // ---------------------------------------------------------------------------- |
239 // |
249 // |
240 void CCalenStateMachine::SetCurrentState(const TCalenStateIndex& aState) |
250 void CCalenStateMachine::SetCurrentState(const TCalenStateIndex& aState) |
241 { |
251 { |
242 OstTraceFunctionEntry0( CCALENSTATEMACHINE_SETCURRENTSTATE_ENTRY ); |
252 TRACE_ENTRY_POINT; |
243 |
253 |
244 iCurrentState = aState; |
254 iCurrentState = aState; |
245 |
255 |
246 OstTraceFunctionExit0( CCALENSTATEMACHINE_SETCURRENTSTATE_EXIT ); |
256 TRACE_EXIT_POINT; |
247 } |
257 } |
248 |
258 |
249 // ---------------------------------------------------------------------------- |
259 // ---------------------------------------------------------------------------- |
250 // CCalenStateMachine::SetPreviousState |
260 // CCalenStateMachine::SetPreviousState |
251 // Interface to set previous state |
261 // Interface to set previous state |
252 // (other items were commented in a header). |
262 // (other items were commented in a header). |
253 // ---------------------------------------------------------------------------- |
263 // ---------------------------------------------------------------------------- |
254 // |
264 // |
255 void CCalenStateMachine::SetCurrentPreviousState(const TCalenStateIndex& aState) |
265 void CCalenStateMachine::SetCurrentPreviousState(const TCalenStateIndex& aState) |
256 { |
266 { |
257 OstTraceFunctionEntry0( CCALENSTATEMACHINE_SETCURRENTPREVIOUSSTATE_ENTRY ); |
267 TRACE_ENTRY_POINT; |
258 |
268 |
259 iStates[iCurrentState]->SetPreviousState(aState); |
269 iStates[iCurrentState]->SetPreviousState(aState); |
260 |
270 |
261 OstTraceFunctionExit0( CCALENSTATEMACHINE_SETCURRENTPREVIOUSSTATE_EXIT ); |
271 TRACE_EXIT_POINT; |
262 } |
272 } |
263 |
273 |
264 // ---------------------------------------------------------------------------- |
274 // ---------------------------------------------------------------------------- |
265 // CCalenStateMachine::ActivateCurrentStateL |
275 // CCalenStateMachine::ActivateCurrentStateL |
266 // Interface to activate the current state |
276 // Interface to activate the current state |
267 // (other items were commented in a header). |
277 // (other items were commented in a header). |
268 // ---------------------------------------------------------------------------- |
278 // ---------------------------------------------------------------------------- |
269 // |
279 // |
270 void CCalenStateMachine::ActivateCurrentStateL() |
280 void CCalenStateMachine::ActivateCurrentStateL() |
271 { |
281 { |
272 OstTraceFunctionEntry0( CCALENSTATEMACHINE_ACTIVATECURRENTSTATEL_ENTRY ); |
282 TRACE_ENTRY_POINT; |
273 |
283 |
274 iStates[iCurrentState]->HandleStateActivationL(*this); |
284 iStates[iCurrentState]->HandleStateActivationL(*this); |
275 |
285 |
276 OstTraceFunctionExit0( CCALENSTATEMACHINE_ACTIVATECURRENTSTATEL_EXIT ); |
286 TRACE_EXIT_POINT; |
277 } |
287 } |
278 // End of file |
288 // End of file |