|
1 /* |
|
2 * Copyright (c) 2007-2008 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 // includes |
|
20 #include "calenidlestate.h" |
|
21 #include "calendarui_debug.h" // Debug macros |
|
22 #include "calencontroller.h" |
|
23 #include "calenstatemachine.h" |
|
24 #include "calennotifier.h" |
|
25 |
|
26 // ---------------------------------------------------------------------------- |
|
27 // CCalenIdleState::NewLC |
|
28 // First stage construction |
|
29 // ---------------------------------------------------------------------------- |
|
30 CCalenIdleState* CCalenIdleState::NewLC( CCalenController& aController, |
|
31 RHashSet<TCalenNotification>& aOutstandingNotifications ) |
|
32 { |
|
33 TRACE_ENTRY_POINT; |
|
34 |
|
35 CCalenIdleState* self = new ( ELeave ) CCalenIdleState( aController, |
|
36 aOutstandingNotifications ); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 |
|
40 TRACE_EXIT_POINT; |
|
41 return self; |
|
42 } |
|
43 |
|
44 // ---------------------------------------------------------------------------- |
|
45 // CCalenIdleState::ConstructL |
|
46 // Second stage construction |
|
47 // ---------------------------------------------------------------------------- |
|
48 void CCalenIdleState::ConstructL() |
|
49 { |
|
50 TRACE_ENTRY_POINT; |
|
51 BaseConstructL(); |
|
52 |
|
53 TRACE_EXIT_POINT; |
|
54 } |
|
55 |
|
56 // ---------------------------------------------------------------------------- |
|
57 // CCalenIdleState::CCalenIdleState |
|
58 // C++ Constructor |
|
59 // ---------------------------------------------------------------------------- |
|
60 CCalenIdleState::CCalenIdleState( CCalenController& aController, |
|
61 RHashSet<TCalenNotification>& aOutstandingNotifications ) |
|
62 : CCalenState( aController, aOutstandingNotifications ) |
|
63 { |
|
64 TRACE_ENTRY_POINT; |
|
65 |
|
66 TRACE_EXIT_POINT; |
|
67 } |
|
68 |
|
69 // ---------------------------------------------------------------------------- |
|
70 // CCalenIdleState::CCalenIdleState |
|
71 // Destructor |
|
72 // ---------------------------------------------------------------------------- |
|
73 CCalenIdleState::~CCalenIdleState() |
|
74 { |
|
75 TRACE_ENTRY_POINT; |
|
76 |
|
77 TRACE_EXIT_POINT; |
|
78 } |
|
79 |
|
80 // ---------------------------------------------------------------------------- |
|
81 // CCalenIdleState::HandleCommandL |
|
82 // From CCalenState |
|
83 // ---------------------------------------------------------------------------- |
|
84 TBool CCalenIdleState::HandleCommandL( const TCalenCommand& aCommand, |
|
85 CCalenStateMachine& aStateMachine ) |
|
86 { |
|
87 TRACE_ENTRY_POINT; |
|
88 |
|
89 TInt cmd = aCommand.Command(); |
|
90 MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd ); |
|
91 |
|
92 ASSERT( handler ); // FIXME: error ui |
|
93 |
|
94 TBool cmdUsed = EFalse; |
|
95 |
|
96 switch( cmd ) |
|
97 { |
|
98 case ECalenMonthView: |
|
99 case ECalenWeekView: |
|
100 case ECalenDayView: |
|
101 case ECalenTodoView: |
|
102 case ECalenForwardsToDayView: |
|
103 case ECalenNextView: |
|
104 case ECalenPrevView: |
|
105 case ECalenSwitchView: |
|
106 case ECalenHidePreview: |
|
107 case ECalenShowPreview: |
|
108 case ECalenGotoToday: |
|
109 case ECalenGotoDate: |
|
110 case ECalenNotifyFocusChange: |
|
111 case ECalenCompleteTodo: |
|
112 case ECalenRestoreTodo: |
|
113 case ECalenMissedAlarmsView: |
|
114 case ECalenCmdClear: |
|
115 case ECalenCmdClearAll: |
|
116 case ECalenCmdGotoCalendar: |
|
117 case ECalenMissedEventViewFromIdle: |
|
118 case ECalenMissedAlarmsViewFromIdle: |
|
119 cmdUsed = ETrue; |
|
120 break; |
|
121 |
|
122 case ECalenStartActiveStep: |
|
123 { |
|
124 // set previous state to idle |
|
125 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
126 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenPopulationState ); |
|
127 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
128 ActivateCurrentStateL(aStateMachine); |
|
129 cmdUsed = ETrue; |
|
130 } |
|
131 break; |
|
132 case ECalenEventView: |
|
133 case ECalenMissedEventView: |
|
134 { |
|
135 // set previous state to idle |
|
136 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
137 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenViewingState); |
|
138 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
139 ActivateCurrentStateL(aStateMachine); |
|
140 cmdUsed = ETrue; |
|
141 } |
|
142 break; |
|
143 case ECalenNewMeeting: |
|
144 case ECalenNewTodo: |
|
145 case ECalenNewAnniv: |
|
146 case ECalenNewDayNote: |
|
147 case ECalenNewReminder: |
|
148 case ECalenNewMeetingRequest: |
|
149 case ECalenEditCurrentEntry: |
|
150 case ECalenEditSeries: |
|
151 case ECalenEditOccurrence: |
|
152 case ECalenViewCurrentEntry: |
|
153 { |
|
154 // set previous state to idle |
|
155 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
156 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenEditingState); |
|
157 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
158 ActivateCurrentStateL(aStateMachine); |
|
159 cmdUsed = ETrue; |
|
160 } |
|
161 break; |
|
162 case ECalenSend: |
|
163 { |
|
164 // set previous state to idle |
|
165 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
166 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenSendingState); |
|
167 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
168 ActivateCurrentStateL(aStateMachine); |
|
169 cmdUsed = ETrue; |
|
170 } |
|
171 break; |
|
172 |
|
173 case ECalenDeleteCurrentEntry: |
|
174 case ECalenDeleteEntryWithoutQuery: |
|
175 case ECalenDeleteSeries: |
|
176 case ECalenDeleteCurrentOccurrence: |
|
177 case ECalenDeleteAllEntries: |
|
178 case ECalenDeleteEntriesBeforeDate: |
|
179 { |
|
180 // set previous state to idle |
|
181 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
182 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenDeletingState); |
|
183 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
184 ActivateCurrentStateL(aStateMachine); |
|
185 cmdUsed = ETrue; |
|
186 } |
|
187 break; |
|
188 |
|
189 case ECalenShowSettings: |
|
190 { |
|
191 // set previous state to idle |
|
192 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
193 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenSettingsState); |
|
194 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
195 ActivateCurrentStateL(aStateMachine); |
|
196 cmdUsed = ETrue; |
|
197 } |
|
198 break; |
|
199 case ECalenFasterAppExit: |
|
200 { |
|
201 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState ); |
|
202 ActivateCurrentStateL(aStateMachine); |
|
203 cmdUsed = ETrue; |
|
204 } |
|
205 break; |
|
206 case ECalenGetLocation: |
|
207 case ECalenShowLocation: |
|
208 case ECalenGetLocationAndSave: |
|
209 { |
|
210 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
211 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenMapState ); |
|
212 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
213 ActivateCurrentStateL(aStateMachine); |
|
214 cmdUsed = ETrue; |
|
215 } |
|
216 break; |
|
217 case ECalenEventViewFromAlarm: |
|
218 case ECalenEventViewFromAlarmStopOnly: |
|
219 { |
|
220 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
221 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenAlarmState); |
|
222 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
223 ActivateCurrentStateL(aStateMachine); |
|
224 cmdUsed = ETrue; |
|
225 } |
|
226 break; |
|
227 case ECalenAddAttachment: |
|
228 case ECalenRemoveAttachment: |
|
229 case ECalenViewAttachmentList: |
|
230 { |
|
231 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
232 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenAttachmentState ); |
|
233 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
234 ActivateCurrentStateL(aStateMachine); |
|
235 cmdUsed = ETrue; |
|
236 } |
|
237 break; |
|
238 default: |
|
239 // This a valid custom command as there is a command handler |
|
240 // do not modify the new start and remain in idle. |
|
241 // remain in idle |
|
242 // don't modify aNewState. |
|
243 break; |
|
244 } |
|
245 |
|
246 RequestCallbackL( handler, aCommand ); |
|
247 |
|
248 TRACE_EXIT_POINT; |
|
249 return cmdUsed; |
|
250 } |
|
251 |
|
252 // ---------------------------------------------------------------------------- |
|
253 // CCalenIdleState::HandleNotificationL |
|
254 // From CCalenState |
|
255 // ---------------------------------------------------------------------------- |
|
256 void CCalenIdleState::HandleNotificationL(const TCalenNotification& aNotification, |
|
257 CCalenStateMachine& aStateMachine) |
|
258 { |
|
259 TRACE_ENTRY_POINT; |
|
260 |
|
261 CCalenState::HandleNotificationL( aNotification, aStateMachine ); |
|
262 |
|
263 TRACE_EXIT_POINT; |
|
264 } |
|
265 |
|
266 // end of file |
|
267 |