|
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 // includes |
|
20 #include "calenviewingstate.h" |
|
21 #include "calendarui_debug.h" // Debug macros |
|
22 #include "calencontroller.h" |
|
23 #include "calenstatemachine.h" |
|
24 #include "calennotifier.h" |
|
25 |
|
26 // ---------------------------------------------------------------------------- |
|
27 // CCalenViewingState::NewLC |
|
28 // First stage construction |
|
29 // ---------------------------------------------------------------------------- |
|
30 CCalenViewingState* CCalenViewingState::NewLC( CCalenController& aController, |
|
31 RHashSet<TCalenNotification>& aOutstandingNotifications ) |
|
32 { |
|
33 TRACE_ENTRY_POINT; |
|
34 |
|
35 CCalenViewingState* self = new ( ELeave ) CCalenViewingState( aController,aOutstandingNotifications ); |
|
36 CleanupStack::PushL( self ); |
|
37 self->ConstructL(); |
|
38 |
|
39 TRACE_EXIT_POINT; |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // CCalenViewingState::ConstructL |
|
45 // Second stage construction |
|
46 // ---------------------------------------------------------------------------- |
|
47 void CCalenViewingState::ConstructL() |
|
48 { |
|
49 TRACE_ENTRY_POINT; |
|
50 BaseConstructL(); |
|
51 |
|
52 TRACE_EXIT_POINT; |
|
53 } |
|
54 |
|
55 // ---------------------------------------------------------------------------- |
|
56 // CCalenIdleState::CCalenIdleState |
|
57 // C++ Constructor |
|
58 // ---------------------------------------------------------------------------- |
|
59 CCalenViewingState::CCalenViewingState( CCalenController& aController, |
|
60 RHashSet<TCalenNotification>& aOutstandingNotifications ) |
|
61 : CCalenState( aController, aOutstandingNotifications ) |
|
62 { |
|
63 TRACE_ENTRY_POINT; |
|
64 |
|
65 TRACE_EXIT_POINT; |
|
66 } |
|
67 |
|
68 // ---------------------------------------------------------------------------- |
|
69 // CCalenViewingState::CCalenViewingState |
|
70 // Destructor |
|
71 // ---------------------------------------------------------------------------- |
|
72 CCalenViewingState::~CCalenViewingState() |
|
73 { |
|
74 TRACE_ENTRY_POINT; |
|
75 |
|
76 TRACE_EXIT_POINT; |
|
77 } |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // CCalenViewingState::HandleCommandL |
|
81 // From CCalenState |
|
82 // ---------------------------------------------------------------------------- |
|
83 TBool CCalenViewingState::HandleCommandL( const TCalenCommand& aCommand, |
|
84 CCalenStateMachine& aStateMachine ) |
|
85 { |
|
86 TRACE_ENTRY_POINT; |
|
87 |
|
88 TInt cmd = aCommand.Command(); |
|
89 MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd ); |
|
90 |
|
91 ASSERT( handler ); // FIXME: error ui |
|
92 |
|
93 TBool cmdUsed = EFalse; |
|
94 |
|
95 switch( cmd ) |
|
96 { |
|
97 case ECalenEditCurrentEntry: |
|
98 case ECalenEditOccurrence: |
|
99 case ECalenEditSeries: |
|
100 case ECalenRestoreTodo: |
|
101 case ECalenCompleteTodo: |
|
102 { |
|
103 // set the previous state as viewing state |
|
104 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
105 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenEditingState); |
|
106 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
107 ActivateCurrentStateL(aStateMachine); |
|
108 cmdUsed = ETrue; |
|
109 } |
|
110 break; |
|
111 case ECalenSend: |
|
112 { |
|
113 // set the previous state as viewing state |
|
114 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
115 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenSendingState); |
|
116 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
117 ActivateCurrentStateL(aStateMachine); |
|
118 cmdUsed = ETrue; |
|
119 } |
|
120 break; |
|
121 case ECalenDeleteCurrentEntry: |
|
122 case ECalenDeleteSeries: |
|
123 case ECalenDeleteCurrentOccurrence: |
|
124 { |
|
125 // set the previous state as viewing state |
|
126 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
127 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenDeletingState); |
|
128 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
129 ActivateCurrentStateL(aStateMachine); |
|
130 cmdUsed = ETrue; |
|
131 } |
|
132 break; |
|
133 case ECalenFasterAppExit: |
|
134 { |
|
135 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState ); |
|
136 ActivateCurrentStateL(aStateMachine); |
|
137 cmdUsed = ETrue; |
|
138 } |
|
139 break; |
|
140 case ECalenGetLocation: |
|
141 case ECalenShowLocation: |
|
142 case ECalenGetLocationAndSave: |
|
143 { |
|
144 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
145 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenMapState ); |
|
146 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
147 ActivateCurrentStateL(aStateMachine); |
|
148 |
|
149 cmdUsed = ETrue; |
|
150 break; |
|
151 } |
|
152 case ECalenViewAttachmentList: |
|
153 case ECalenAddAttachmentFromViewer: |
|
154 { |
|
155 CCalenStateMachine::TCalenStateIndex cachedState = GetCurrentState(aStateMachine); |
|
156 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenAttachmentState ); |
|
157 SetCurrentPreviousState( aStateMachine, cachedState ); |
|
158 ActivateCurrentStateL(aStateMachine); |
|
159 cmdUsed = ETrue; |
|
160 } |
|
161 break; |
|
162 } |
|
163 RequestCallbackL( handler, aCommand ); |
|
164 |
|
165 TRACE_EXIT_POINT; |
|
166 return cmdUsed; |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // CCalenViewingState::HandleNotificationL |
|
171 // From CCalenState |
|
172 // ---------------------------------------------------------------------------- |
|
173 void CCalenViewingState::HandleNotificationL(const TCalenNotification& aNotification, |
|
174 CCalenStateMachine& aStateMachine ) |
|
175 { |
|
176 TRACE_ENTRY_POINT; |
|
177 |
|
178 switch( aNotification ) |
|
179 { |
|
180 case ECalenNotifyEntryClosed: |
|
181 { |
|
182 SetCurrentState( aStateMachine, iPreviousState ); |
|
183 iOutstandingNotifications.InsertL(aNotification); |
|
184 ActivateCurrentStateL(aStateMachine); |
|
185 } |
|
186 break; |
|
187 |
|
188 case ECalenNotifyEntryDeleted: |
|
189 { |
|
190 SetCurrentState( aStateMachine, iPreviousState ); |
|
191 iOutstandingNotifications.InsertL(aNotification); |
|
192 ActivateCurrentStateL(aStateMachine); |
|
193 } |
|
194 break; |
|
195 default: |
|
196 CCalenState::HandleNotificationL( aNotification, aStateMachine ); |
|
197 break; |
|
198 } |
|
199 |
|
200 TRACE_EXIT_POINT; |
|
201 } |
|
202 |
|
203 // ---------------------------------------------------------------------------- |
|
204 // CCalenViewingState::HandleStateActivationL |
|
205 // Behavior when state is activated. |
|
206 // ---------------------------------------------------------------------------- |
|
207 void CCalenViewingState::HandleStateActivationL(CCalenStateMachine& aStateMachine) |
|
208 { |
|
209 TRACE_ENTRY_POINT; |
|
210 |
|
211 if( iOutstandingNotifications.Find(ECalenNotifyEntryDeleted) ) |
|
212 { |
|
213 SetCurrentState( aStateMachine, iPreviousState ); |
|
214 ActivateCurrentStateL(aStateMachine); |
|
215 } |
|
216 else |
|
217 { |
|
218 CCalenState::HandleStateActivationL(aStateMachine); |
|
219 } |
|
220 TRACE_EXIT_POINT; |
|
221 } |
|
222 |
|
223 // end of file |