|
1 /* |
|
2 * Copyright (c) 2007-2009 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 <calentoolbar.h> |
|
21 |
|
22 #include "calensettingsstate.h" |
|
23 #include "calendarui_debug.h" // Debug macros |
|
24 #include "calencontroller.h" |
|
25 #include "calenstatemachine.h" |
|
26 #include "calennotifier.h" |
|
27 #include "calenviewmanager.h" |
|
28 |
|
29 // ---------------------------------------------------------------------------- |
|
30 // CCalenSettingsState::NewLC |
|
31 // First stage construction |
|
32 // ---------------------------------------------------------------------------- |
|
33 CCalenSettingsState* CCalenSettingsState::NewLC( CCalenController& aController, |
|
34 RHashSet<TCalenNotification>& aOutstandingNotifications ) |
|
35 { |
|
36 TRACE_ENTRY_POINT; |
|
37 |
|
38 CCalenSettingsState* self = new ( ELeave ) CCalenSettingsState( aController, |
|
39 aOutstandingNotifications ); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 |
|
43 TRACE_EXIT_POINT; |
|
44 return self; |
|
45 } |
|
46 |
|
47 // ---------------------------------------------------------------------------- |
|
48 // CCalenSettingsState::ConstructL |
|
49 // Second stage construction |
|
50 // ---------------------------------------------------------------------------- |
|
51 void CCalenSettingsState::ConstructL() |
|
52 { |
|
53 TRACE_ENTRY_POINT; |
|
54 BaseConstructL(); |
|
55 |
|
56 TRACE_EXIT_POINT; |
|
57 } |
|
58 |
|
59 // ---------------------------------------------------------------------------- |
|
60 // CCalenSettingsState::CCalenSettingsState |
|
61 // C++ Constructor |
|
62 // ---------------------------------------------------------------------------- |
|
63 CCalenSettingsState::CCalenSettingsState( CCalenController& aController, |
|
64 RHashSet<TCalenNotification>& aOutstandingNotifications ) |
|
65 : CCalenState( aController, aOutstandingNotifications ) |
|
66 { |
|
67 TRACE_ENTRY_POINT; |
|
68 |
|
69 TRACE_EXIT_POINT; |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // CCalenSettingsState::CCalenSettingsState |
|
74 // Destructor |
|
75 // ---------------------------------------------------------------------------- |
|
76 CCalenSettingsState::~CCalenSettingsState() |
|
77 { |
|
78 TRACE_ENTRY_POINT; |
|
79 |
|
80 TRACE_EXIT_POINT; |
|
81 } |
|
82 |
|
83 // ---------------------------------------------------------------------------- |
|
84 // CCalenSettingsState::HandleCommandL |
|
85 // From CCalenState |
|
86 // ---------------------------------------------------------------------------- |
|
87 TBool CCalenSettingsState::HandleCommandL( const TCalenCommand& aCommand, |
|
88 CCalenStateMachine& aStateMachine ) |
|
89 { |
|
90 TRACE_ENTRY_POINT; |
|
91 |
|
92 TInt cmd = aCommand.Command(); |
|
93 MCalenCommandHandler* handler = iController.GetCommandHandlerL( cmd ); |
|
94 |
|
95 ASSERT( handler ); |
|
96 TBool cmdUsed = EFalse; |
|
97 |
|
98 switch( cmd ) |
|
99 { |
|
100 case ECalenFasterAppExit: |
|
101 { |
|
102 SetCurrentState( aStateMachine, CCalenStateMachine::ECalenIdleState ); |
|
103 ActivateCurrentStateL(aStateMachine); |
|
104 cmdUsed = ETrue; |
|
105 } |
|
106 break; |
|
107 case ECalenMissedEventViewFromIdle: |
|
108 { |
|
109 cmdUsed = ETrue; |
|
110 break; |
|
111 } |
|
112 case ECalenEventViewFromAlarm: |
|
113 case ECalenEventViewFromAlarmStopOnly: |
|
114 case ECalenDayView: |
|
115 { |
|
116 cmdUsed = ETrue; |
|
117 } |
|
118 break; |
|
119 default: |
|
120 break; |
|
121 } |
|
122 if(cmdUsed) |
|
123 { |
|
124 RequestCallbackL( handler, aCommand ); |
|
125 } |
|
126 |
|
127 TRACE_EXIT_POINT; |
|
128 return cmdUsed; |
|
129 } |
|
130 |
|
131 // ---------------------------------------------------------------------------- |
|
132 // CCalenSettingsState::HandleNotificationL |
|
133 // From CCalenState |
|
134 // ---------------------------------------------------------------------------- |
|
135 void CCalenSettingsState::HandleNotificationL(const TCalenNotification& aNotification, |
|
136 CCalenStateMachine& aStateMachine ) |
|
137 { |
|
138 TRACE_ENTRY_POINT; |
|
139 |
|
140 switch( aNotification ) |
|
141 { |
|
142 case ECalenNotifyPluginEnabledDisabled: |
|
143 case ECalenNotifyEComRegistryChanged: |
|
144 { |
|
145 CCalenState::HandleNotificationL( aNotification, aStateMachine ); |
|
146 } |
|
147 break; |
|
148 case ECalenNotifySettingsClosed: |
|
149 { |
|
150 // Settings closed, go back to previous state. |
|
151 SetCurrentState( aStateMachine, iPreviousState ); |
|
152 iOutstandingNotifications.InsertL(aNotification); |
|
153 ActivateCurrentStateL(aStateMachine); |
|
154 } |
|
155 break; |
|
156 default: |
|
157 // default is defer all other notifications when we are in setting state |
|
158 iOutstandingNotifications.InsertL(aNotification); |
|
159 break; |
|
160 } |
|
161 |
|
162 TRACE_EXIT_POINT; |
|
163 } |
|
164 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // CCalenSettingsState::HandleStateActivationL |
|
167 // Behavior when state is activated. |
|
168 // ---------------------------------------------------------------------------- |
|
169 void CCalenSettingsState::HandleStateActivationL() |
|
170 { |
|
171 TRACE_ENTRY_POINT; |
|
172 |
|
173 if( iOutstandingNotifications.FindL(ECalenNotifySettingsCRepKeyChanged) ) |
|
174 { |
|
175 iController.Notifier().BroadcastApprovedNotification( ECalenNotifySettingsCRepKeyChanged ); |
|
176 } |
|
177 |
|
178 TRACE_EXIT_POINT; |
|
179 } |
|
180 |
|
181 // end of file |