|
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 |
|
20 // includes |
|
21 #include "calendeletingstate.h" |
|
22 #include "calendarui_debug.h" // Debug macros |
|
23 #include "calencontroller.h" |
|
24 #include "calenstatemachine.h" |
|
25 #include "calennotifier.h" |
|
26 |
|
27 // ---------------------------------------------------------------------------- |
|
28 // CCalenDeletingState::NewLC |
|
29 // First stage construction |
|
30 // ---------------------------------------------------------------------------- |
|
31 CCalenDeletingState* CCalenDeletingState::NewLC( CCalenController& aController, |
|
32 RHashSet<TCalenNotification>& aOutstandingNotifications ) |
|
33 { |
|
34 TRACE_ENTRY_POINT; |
|
35 |
|
36 CCalenDeletingState* self = new( ELeave ) CCalenDeletingState( aController,aOutstandingNotifications ); |
|
37 |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 |
|
41 TRACE_EXIT_POINT; |
|
42 return self; |
|
43 } |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // CCalenDeletingState::ConstructL |
|
47 // Second stage construction |
|
48 // ---------------------------------------------------------------------------- |
|
49 void CCalenDeletingState::ConstructL() |
|
50 { |
|
51 TRACE_ENTRY_POINT; |
|
52 BaseConstructL(); |
|
53 |
|
54 TRACE_EXIT_POINT; |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // CCalenDeletingState::CCalenDeletingState |
|
59 // C++ Constructor |
|
60 // ---------------------------------------------------------------------------- |
|
61 CCalenDeletingState::CCalenDeletingState( CCalenController& aController, |
|
62 RHashSet<TCalenNotification>& aOutstandingNotifications ) |
|
63 : CCalenState( aController, aOutstandingNotifications ) |
|
64 { |
|
65 TRACE_ENTRY_POINT; |
|
66 |
|
67 TRACE_EXIT_POINT; |
|
68 } |
|
69 |
|
70 // ---------------------------------------------------------------------------- |
|
71 // CCalenDeletingState::CCalenDeletingState |
|
72 // Destructor |
|
73 // ---------------------------------------------------------------------------- |
|
74 CCalenDeletingState::~CCalenDeletingState() |
|
75 { |
|
76 TRACE_ENTRY_POINT; |
|
77 |
|
78 TRACE_EXIT_POINT; |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // CCalenDeletingState::HandleCommandL |
|
83 // From CCalenState |
|
84 // ---------------------------------------------------------------------------- |
|
85 TBool CCalenDeletingState::HandleCommandL( const TCalenCommand& aCommand, |
|
86 CCalenStateMachine& aStateMachine ) |
|
87 { |
|
88 TRACE_ENTRY_POINT; |
|
89 |
|
90 TInt cmd = aCommand.Command(); |
|
91 MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd ); |
|
92 |
|
93 ASSERT( handler ); // FIXME: error ui |
|
94 |
|
95 TBool cmdUsed = EFalse; |
|
96 |
|
97 if(ECalenDeleteEntryWithoutQuery == cmd) |
|
98 { |
|
99 RequestCallbackL( handler, aCommand ); |
|
100 cmdUsed = ETrue; |
|
101 } |
|
102 else if(ECalenFasterAppExit == cmd) |
|
103 { |
|
104 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState ); |
|
105 ActivateCurrentStateL(aStateMachine); |
|
106 RequestCallbackL( handler, aCommand ); |
|
107 cmdUsed = ETrue; |
|
108 } |
|
109 else if(ECalenStartActiveStep == cmd) |
|
110 { |
|
111 RequestCallbackL( handler, aCommand ); |
|
112 cmdUsed = ETrue; |
|
113 } |
|
114 |
|
115 else if(ECalenMissedEventViewFromIdle == cmd) |
|
116 { |
|
117 RequestCallbackL( handler, aCommand ); |
|
118 cmdUsed = ETrue; |
|
119 } |
|
120 else if(ECalenMissedAlarmsViewFromIdle == cmd) |
|
121 { |
|
122 RequestCallbackL( handler, aCommand ); |
|
123 cmdUsed = ETrue; |
|
124 } |
|
125 |
|
126 TRACE_EXIT_POINT; |
|
127 return cmdUsed; |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // CCalenDeletingState::HandleNotificationL |
|
132 // From CCalenState |
|
133 // ---------------------------------------------------------------------------- |
|
134 void CCalenDeletingState::HandleNotificationL(const TCalenNotification& aNotification, |
|
135 CCalenStateMachine& aStateMachine ) |
|
136 { |
|
137 TRACE_ENTRY_POINT; |
|
138 |
|
139 switch( aNotification ) |
|
140 { |
|
141 case ECalenNotifyEntryDeleted: // issued when new entry dialog is cancelled |
|
142 case ECalenNotifyInstanceDeleted: |
|
143 case ECalenNotifyMultipleEntriesDeleted: |
|
144 case ECalenNotifyDeleteFailed: // delete failed or cancelled |
|
145 case ECalenNotifyMarkedEntryDeleted: |
|
146 { |
|
147 SetCurrentState( aStateMachine, iPreviousState ); |
|
148 // DONT broadcast these notifications until the previous state( idle or viewer ) is activated |
|
149 // which would broadcast in HandleStateActivationL() |
|
150 iOutstandingNotifications.InsertL(aNotification); |
|
151 ActivateCurrentStateL(aStateMachine); |
|
152 } |
|
153 break; |
|
154 case ECalenNotifyCancelDelete: |
|
155 { |
|
156 SetCurrentState( aStateMachine, iPreviousState); |
|
157 SetCurrentPreviousState( aStateMachine, GetCurrentState(aStateMachine) ); |
|
158 |
|
159 iOutstandingNotifications.InsertL(aNotification); |
|
160 ActivateCurrentStateL(aStateMachine); |
|
161 |
|
162 CancelPreviousCmd(aStateMachine); |
|
163 } |
|
164 break; |
|
165 default: |
|
166 CCalenState::HandleNotificationL( aNotification, aStateMachine ); |
|
167 break; |
|
168 } |
|
169 |
|
170 TRACE_EXIT_POINT; |
|
171 } |
|
172 |
|
173 // end of file |