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