30 #include "calenhelpstate.h" |
30 #include "calenhelpstate.h" |
31 #include "calenprintingstate.h" |
31 #include "calenprintingstate.h" |
32 #include "calensendingstate.h" |
32 #include "calensendingstate.h" |
33 #include "calensettingsstate.h" |
33 #include "calensettingsstate.h" |
34 #include "calenviewingstate.h" |
34 #include "calenviewingstate.h" |
|
35 #include "OstTraceDefinitions.h" |
|
36 #ifdef OST_TRACE_COMPILER_IN_USE |
|
37 #include "calenstatemachineTraces.h" |
|
38 #endif |
35 |
39 |
36 |
40 |
37 const TInt KHashLength = 64; |
41 const TInt KHashLength = 64; |
38 // ---------------------------------------------------------------------------- |
42 // ---------------------------------------------------------------------------- |
39 // CCalenStateMachine::NewL |
43 // CCalenStateMachine::NewL |
41 // (other items were commented in a header). |
45 // (other items were commented in a header). |
42 // ---------------------------------------------------------------------------- |
46 // ---------------------------------------------------------------------------- |
43 // |
47 // |
44 CCalenStateMachine* CCalenStateMachine::NewL( CCalenController& aController ) |
48 CCalenStateMachine* CCalenStateMachine::NewL( CCalenController& aController ) |
45 { |
49 { |
46 TRACE_ENTRY_POINT; |
50 OstTraceFunctionEntry0( CCALENSTATEMACHINE_NEWL_ENTRY ); |
47 |
51 |
48 CCalenStateMachine* self = new ( ELeave ) CCalenStateMachine( aController ); |
52 CCalenStateMachine* self = new ( ELeave ) CCalenStateMachine( aController ); |
49 CleanupStack::PushL( self ); |
53 CleanupStack::PushL( self ); |
50 self->ConstructL(); |
54 self->ConstructL(); |
51 CleanupStack::Pop( self ); |
55 CleanupStack::Pop( self ); |
52 |
56 |
53 TRACE_EXIT_POINT; |
57 OstTraceFunctionExit0( CCALENSTATEMACHINE_NEWL_EXIT ); |
54 return self; |
58 return self; |
55 } |
59 } |
56 |
60 |
57 // ---------------------------------------------------------------------------- |
61 // ---------------------------------------------------------------------------- |
58 // CCalenStateMachine::CCalenStateMachine |
62 // CCalenStateMachine::CCalenStateMachine |
62 // |
66 // |
63 CCalenStateMachine::CCalenStateMachine( CCalenController& aController ) |
67 CCalenStateMachine::CCalenStateMachine( CCalenController& aController ) |
64 : iController( aController ) , |
68 : iController( aController ) , |
65 iOutstandingNotifications(&::HashCalenNotificationFunction,&::HashCalenNotificationIdentityRelation) |
69 iOutstandingNotifications(&::HashCalenNotificationFunction,&::HashCalenNotificationIdentityRelation) |
66 { |
70 { |
67 TRACE_ENTRY_POINT; |
71 OstTraceFunctionEntry0( CCALENSTATEMACHINE_CCALENSTATEMACHINE_ENTRY ); |
68 TRACE_EXIT_POINT; |
72 |
|
73 OstTraceFunctionExit0( CCALENSTATEMACHINE_CCALENSTATEMACHINE_EXIT ); |
69 } |
74 } |
70 |
75 |
71 // ---------------------------------------------------------------------------- |
76 // ---------------------------------------------------------------------------- |
72 // CCalenStateMachine::ConstructL |
77 // CCalenStateMachine::ConstructL |
73 // Second phase of construction. |
78 // Second phase of construction. |
74 // (other items were commented in a header). |
79 // (other items were commented in a header). |
75 // ---------------------------------------------------------------------------- |
80 // ---------------------------------------------------------------------------- |
76 // |
81 // |
77 void CCalenStateMachine::ConstructL() |
82 void CCalenStateMachine::ConstructL() |
78 { |
83 { |
79 TRACE_ENTRY_POINT; |
84 OstTraceFunctionEntry0( CCALENSTATEMACHINE_CONSTRUCTL_ENTRY ); |
80 |
85 |
81 CCalenState* state = NULL; |
86 CCalenState* state = NULL; |
82 |
87 |
83 iOutstandingNotifications.ReserveL(KHashLength); |
88 iOutstandingNotifications.ReserveL(KHashLength); |
84 state = CCalenIdleState::NewLC( iController, iOutstandingNotifications ); |
89 state = CCalenIdleState::NewLC( iController, iOutstandingNotifications ); |
85 iStates.InsertL( state, ECalenIdleState ); |
90 iStates.InsertL( state, ECalenIdleState ); |
125 iStates.InsertL( state, ECalenExitingState ); |
130 iStates.InsertL( state, ECalenExitingState ); |
126 CleanupStack::Pop( state ); |
131 CleanupStack::Pop( state ); |
127 |
132 |
128 ASSERT( iStates.Count() == KCalenLastState ); |
133 ASSERT( iStates.Count() == KCalenLastState ); |
129 |
134 |
130 TRACE_EXIT_POINT; |
135 OstTraceFunctionExit0( CCALENSTATEMACHINE_CONSTRUCTL_EXIT ); |
131 } |
136 } |
132 |
137 |
133 // ---------------------------------------------------------------------------- |
138 // ---------------------------------------------------------------------------- |
134 // CCalenStateMachine::~CCalenStateMachine |
139 // CCalenStateMachine::~CCalenStateMachine |
135 // Destructor. |
140 // Destructor. |
136 // (other items were commented in a header). |
141 // (other items were commented in a header). |
137 // ---------------------------------------------------------------------------- |
142 // ---------------------------------------------------------------------------- |
138 // |
143 // |
139 CCalenStateMachine::~CCalenStateMachine() |
144 CCalenStateMachine::~CCalenStateMachine() |
140 { |
145 { |
141 TRACE_ENTRY_POINT; |
146 OstTraceFunctionEntry0( DUP1_CCALENSTATEMACHINE_CCALENSTATEMACHINE_ENTRY ); |
142 |
147 |
143 iOutstandingNotifications.Close(); |
148 iOutstandingNotifications.Close(); |
144 iStates.ResetAndDestroy(); |
149 iStates.ResetAndDestroy(); |
145 |
150 |
146 TRACE_EXIT_POINT; |
151 OstTraceFunctionExit0( DUP1_CCALENSTATEMACHINE_CCALENSTATEMACHINE_EXIT ); |
147 } |
152 } |
148 |
153 |
149 // ---------------------------------------------------------------------------- |
154 // ---------------------------------------------------------------------------- |
150 // CCalenStateMachine::HandleNotification |
155 // CCalenStateMachine::HandleNotification |
151 // Notification handler interface. |
156 // Notification handler interface. |
152 // (other items were commented in a header). |
157 // (other items were commented in a header). |
153 // ---------------------------------------------------------------------------- |
158 // ---------------------------------------------------------------------------- |
154 // |
159 // |
155 void CCalenStateMachine::HandleNotification(const TCalenNotification aNotification ) |
160 void CCalenStateMachine::HandleNotification(const TCalenNotification aNotification ) |
156 { |
161 { |
157 TRACE_ENTRY_POINT; |
162 OstTraceFunctionEntry0( CCALENSTATEMACHINE_HANDLENOTIFICATION_ENTRY ); |
158 |
163 |
159 TRAP_IGNORE(iStates[iCurrentState]->HandleNotificationL( aNotification, *this)); |
164 TRAP_IGNORE(iStates[iCurrentState]->HandleNotificationL( aNotification, *this)); |
160 |
165 |
161 TRACE_EXIT_POINT; |
166 OstTraceFunctionExit0( CCALENSTATEMACHINE_HANDLENOTIFICATION_EXIT ); |
162 } |
167 } |
163 |
168 |
164 // ---------------------------------------------------------------------------- |
169 // ---------------------------------------------------------------------------- |
165 // CCalenStateMachine::CurrentState |
170 // CCalenStateMachine::CurrentState |
166 // Returns the current state in which calendar is. |
171 // Returns the current state in which calendar is. |
167 // (other items were commented in a header). |
172 // (other items were commented in a header). |
168 // ---------------------------------------------------------------------------- |
173 // ---------------------------------------------------------------------------- |
169 // |
174 // |
170 CCalenStateMachine::TCalenStateIndex CCalenStateMachine::CurrentState() |
175 CCalenStateMachine::TCalenStateIndex CCalenStateMachine::CurrentState() |
171 { |
176 { |
|
177 OstTraceFunctionEntry0( CCALENSTATEMACHINE_CURRENTSTATE_ENTRY ); |
|
178 |
|
179 OstTraceFunctionExit0( CCALENSTATEMACHINE_CURRENTSTATE_EXIT ); |
172 return iCurrentState; |
180 return iCurrentState; |
173 } |
181 } |
174 |
182 |
175 // ---------------------------------------------------------------------------- |
183 // ---------------------------------------------------------------------------- |
176 // CCalenStateMachine::HandleCommandL |
184 // CCalenStateMachine::HandleCommandL |
194 // (other items were commented in a header). |
202 // (other items were commented in a header). |
195 // ---------------------------------------------------------------------------- |
203 // ---------------------------------------------------------------------------- |
196 // |
204 // |
197 void CCalenStateMachine::CancelPreviousCmd() |
205 void CCalenStateMachine::CancelPreviousCmd() |
198 { |
206 { |
199 TRACE_ENTRY_POINT; |
207 OstTraceFunctionEntry0( CCALENSTATEMACHINE_CANCELPREVIOUSCMD_ENTRY ); |
200 |
208 |
201 TCalenStateIndex previousState = iStates[iCurrentState]->PreviousState(); |
209 TCalenStateIndex previousState = iStates[iCurrentState]->PreviousState(); |
202 iStates[iCurrentState]->CancelExecutingCmd(); |
210 iStates[iCurrentState]->CancelExecutingCmd(); |
203 |
211 |
204 if(previousState != iCurrentState) |
212 if(previousState != iCurrentState) |
205 { |
213 { |
206 iCurrentState = previousState; |
214 iCurrentState = previousState; |
207 } |
215 } |
208 |
216 |
209 TRACE_EXIT_POINT; |
217 OstTraceFunctionExit0( CCALENSTATEMACHINE_CANCELPREVIOUSCMD_EXIT ); |
210 } |
218 } |
211 |
219 |
212 // ---------------------------------------------------------------------------- |
220 // ---------------------------------------------------------------------------- |
213 // CCalenStateMachine::GetCurrentState |
221 // CCalenStateMachine::GetCurrentState |
214 // Interface to get the current state |
222 // Interface to get the current state |
215 // (other items were commented in a header). |
223 // (other items were commented in a header). |
216 // ---------------------------------------------------------------------------- |
224 // ---------------------------------------------------------------------------- |
217 // |
225 // |
218 CCalenStateMachine::TCalenStateIndex CCalenStateMachine::GetCurrentState() |
226 CCalenStateMachine::TCalenStateIndex CCalenStateMachine::GetCurrentState() |
219 { |
227 { |
220 TRACE_ENTRY_POINT; |
228 OstTraceFunctionEntry0( CCALENSTATEMACHINE_GETCURRENTSTATE_ENTRY ); |
221 TRACE_EXIT_POINT; |
229 |
222 |
230 OstTraceFunctionExit0( CCALENSTATEMACHINE_GETCURRENTSTATE_EXIT ); |
223 return iCurrentState; |
231 return iCurrentState; |
224 } |
232 } |
225 |
233 |
226 // ---------------------------------------------------------------------------- |
234 // ---------------------------------------------------------------------------- |
227 // CCalenStateMachine::SetCurrentState |
235 // CCalenStateMachine::SetCurrentState |
228 // Interface to set the current state |
236 // Interface to set the current state |
229 // (other items were commented in a header). |
237 // (other items were commented in a header). |
230 // ---------------------------------------------------------------------------- |
238 // ---------------------------------------------------------------------------- |
231 // |
239 // |
232 void CCalenStateMachine::SetCurrentState(const TCalenStateIndex& aState) |
240 void CCalenStateMachine::SetCurrentState(const TCalenStateIndex& aState) |
233 { |
241 { |
234 TRACE_ENTRY_POINT; |
242 OstTraceFunctionEntry0( CCALENSTATEMACHINE_SETCURRENTSTATE_ENTRY ); |
235 |
243 |
236 iCurrentState = aState; |
244 iCurrentState = aState; |
237 |
245 |
238 TRACE_EXIT_POINT; |
246 OstTraceFunctionExit0( CCALENSTATEMACHINE_SETCURRENTSTATE_EXIT ); |
239 } |
247 } |
240 |
248 |
241 // ---------------------------------------------------------------------------- |
249 // ---------------------------------------------------------------------------- |
242 // CCalenStateMachine::SetPreviousState |
250 // CCalenStateMachine::SetPreviousState |
243 // Interface to set previous state |
251 // Interface to set previous state |
244 // (other items were commented in a header). |
252 // (other items were commented in a header). |
245 // ---------------------------------------------------------------------------- |
253 // ---------------------------------------------------------------------------- |
246 // |
254 // |
247 void CCalenStateMachine::SetCurrentPreviousState(const TCalenStateIndex& aState) |
255 void CCalenStateMachine::SetCurrentPreviousState(const TCalenStateIndex& aState) |
248 { |
256 { |
249 TRACE_ENTRY_POINT; |
257 OstTraceFunctionEntry0( CCALENSTATEMACHINE_SETCURRENTPREVIOUSSTATE_ENTRY ); |
250 |
258 |
251 iStates[iCurrentState]->SetPreviousState(aState); |
259 iStates[iCurrentState]->SetPreviousState(aState); |
252 |
260 |
253 TRACE_EXIT_POINT; |
261 OstTraceFunctionExit0( CCALENSTATEMACHINE_SETCURRENTPREVIOUSSTATE_EXIT ); |
254 } |
262 } |
255 |
263 |
256 // ---------------------------------------------------------------------------- |
264 // ---------------------------------------------------------------------------- |
257 // CCalenStateMachine::ActivateCurrentStateL |
265 // CCalenStateMachine::ActivateCurrentStateL |
258 // Interface to activate the current state |
266 // Interface to activate the current state |
259 // (other items were commented in a header). |
267 // (other items were commented in a header). |
260 // ---------------------------------------------------------------------------- |
268 // ---------------------------------------------------------------------------- |
261 // |
269 // |
262 void CCalenStateMachine::ActivateCurrentStateL() |
270 void CCalenStateMachine::ActivateCurrentStateL() |
263 { |
271 { |
264 TRACE_ENTRY_POINT; |
272 OstTraceFunctionEntry0( CCALENSTATEMACHINE_ACTIVATECURRENTSTATEL_ENTRY ); |
265 |
273 |
266 iStates[iCurrentState]->HandleStateActivationL(*this); |
274 iStates[iCurrentState]->HandleStateActivationL(*this); |
267 |
275 |
268 TRACE_EXIT_POINT; |
276 OstTraceFunctionExit0( CCALENSTATEMACHINE_ACTIVATECURRENTSTATEL_EXIT ); |
269 } |
277 } |
270 // End of file |
278 // End of file |