35
|
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: Base class for application states.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef T_VTUIAPPSTATEBASE_H
|
|
20 |
#define T_VTUIAPPSTATEBASE_H
|
|
21 |
|
|
22 |
#include <e32base.h>
|
|
23 |
#include <mvtengsessioninfo.h>
|
|
24 |
#include "mvtuistatecontext.h"
|
|
25 |
#include "mvtuishutterobserver.h"
|
|
26 |
#include "tvtuistates.h"
|
|
27 |
|
|
28 |
/**
|
|
29 |
* Base class for application states related to application startup, normal
|
|
30 |
* operation and shutdown. AppUi delegates decision making by forwarding
|
|
31 |
* events/commands it receives to current state.
|
|
32 |
* Not all event handlers declared by the base class are applicable in
|
|
33 |
* all concrete states. All methods returning TEventResponse imply that it may
|
|
34 |
* consume the event completely and caller should not process it further.
|
|
35 |
*
|
|
36 |
* It should be kept in mind that as new functionality is added to application,
|
|
37 |
* state classes may need changes if e.g. handling of specific event should be
|
|
38 |
* allowed in appUi. By default event handler in specific state may consume all
|
|
39 |
* events. Note that in this context e.g. HandleCommandL is considered as an
|
|
40 |
* event handler.
|
|
41 |
*
|
|
42 |
* @since S60 v3.2
|
|
43 |
*/
|
|
44 |
class TVtUiAppStateBase : public MVtUiShutterObserver
|
|
45 |
{
|
|
46 |
public: // new functions
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Return value from state's event handlers.
|
|
50 |
*/
|
|
51 |
enum TEventResponse
|
|
52 |
{
|
|
53 |
/** Event was handled by a state and should
|
|
54 |
* not be further processed by caller.
|
|
55 |
*/
|
|
56 |
EEventHandled,
|
|
57 |
/** Event can be handled by caller. */
|
|
58 |
EEventNotHandled
|
|
59 |
};
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Performs state dependent actions when phase 1 of
|
|
63 |
* startup is completed.
|
|
64 |
*/
|
|
65 |
virtual void AppUiStartupPhase1DoneL();
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Performs state dependent actions when startup fails.
|
|
69 |
*/
|
|
70 |
virtual void AppUiStartupFailedL();
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Performs state dependent actions when phase 2 of
|
|
74 |
* startup is completed.
|
|
75 |
*/
|
|
76 |
virtual void AppUiStartupPhase2DoneL();
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Handles completion of shutdown.
|
|
80 |
*/
|
|
81 |
virtual void ShutdownDoneL();
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Handles completion of an VT engine command.
|
|
85 |
* @param aCommand completed command
|
|
86 |
* @param aError error
|
|
87 |
* @return event response, is caller allowed to handle event
|
|
88 |
*/
|
|
89 |
virtual TEventResponse HandleVTCommandPerformedL(
|
|
90 |
const TVtEngCommandId aCommand,
|
|
91 |
const TInt aError );
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Handles event from the engine.
|
|
95 |
* @param aEvent
|
|
96 |
* @return event response, is caller allowed to handle event
|
|
97 |
*/
|
|
98 |
virtual TEventResponse HandleVtEventL( const TInt aEvent );
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Handles command from the user (or application framework).
|
|
102 |
* @param aCommand
|
|
103 |
* @return event response, is caller allowed to handle event
|
|
104 |
*/
|
|
105 |
virtual TEventResponse HandleCommandL( const TInt aCommand );
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Performs state dependent actions for foreground change event.
|
|
109 |
* @param aIsForeground foreground status passed from UI framework
|
|
110 |
* @return ETrue if application should behave as in foreground
|
|
111 |
*/
|
|
112 |
virtual TBool HandleForegroundChangedL( const TBool aIsForeground );
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Performs state dependent previous actions for foreground change event.
|
|
116 |
* @param aIsForeground foreground status passed from UI framework
|
|
117 |
* @return ETrue if application should behave as in foreground
|
|
118 |
*/
|
|
119 |
virtual TBool PreHandleForegroundChangedL( const TBool aIsForeground );
|
|
120 |
/**
|
|
121 |
* Performs state dependent actions for layout change.
|
|
122 |
*/
|
|
123 |
virtual void HandleLayoutChangedL();
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Sends DTMF tone if allowed by current state.
|
|
127 |
* @param aTone DTMF tone to send
|
|
128 |
*/
|
|
129 |
virtual void StartDtmfTone( const TChar& aTone );
|
|
130 |
|
|
131 |
/**
|
|
132 |
* Stops DTMF tone if allowed by current state.
|
|
133 |
*/
|
|
134 |
virtual void StopDtmfTone();
|
|
135 |
|
|
136 |
/**
|
|
137 |
* Sets initial application state.
|
|
138 |
* @param aCtx state context providing services to states
|
|
139 |
* @param aUiStates ui states
|
|
140 |
*/
|
|
141 |
static void SetInitialStateL(
|
|
142 |
MVtUiStateContext& aCtx,
|
|
143 |
TVtUiStates& aUiStates);
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Get whether the shutdown requested
|
|
147 |
* @return ETrue if shutdown requested
|
|
148 |
*/
|
|
149 |
static TBool ShutdownRequested();
|
|
150 |
|
|
151 |
protected: // for concrete state classes
|
|
152 |
|
|
153 |
/**
|
|
154 |
* Destructor, for cleanup.
|
|
155 |
*/
|
|
156 |
virtual ~TVtUiAppStateBase();
|
|
157 |
|
|
158 |
/**
|
|
159 |
* Performs entry action for a state.
|
|
160 |
*/
|
|
161 |
virtual void OpenL();
|
|
162 |
|
|
163 |
/**
|
|
164 |
* Performs exit action for a state and deletes that state.
|
|
165 |
*/
|
|
166 |
virtual void Close();
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Sets current state.
|
|
170 |
*/
|
|
171 |
void ChangeStateL( TVtUiAppStateBase& aNewState );
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Sets transition to resetting state as cleanup item.
|
|
175 |
*/
|
|
176 |
void CleanupResetPushL();
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Starts shutdown when leave occurred.
|
|
180 |
*/
|
|
181 |
static void TransitionToReset( TAny* aAny );
|
|
182 |
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Ends the call if necessary and starts shutdown.
|
|
186 |
* @return ETrue if shutdown started.
|
|
187 |
*/
|
|
188 |
TBool CheckEndActiveCallL();
|
|
189 |
|
|
190 |
/**
|
|
191 |
* Returns engine session state.
|
|
192 |
* @param aUpdate is state forced to update
|
|
193 |
* @return session state
|
|
194 |
*/
|
|
195 |
MVtEngSessionInfo::TSessionState SessionState(
|
|
196 |
const TBool aUpdate ) const;
|
|
197 |
|
|
198 |
/**
|
|
199 |
* Sets forced lights state in the system.
|
|
200 |
*/
|
|
201 |
void SetLightsState( const TBool aOn );
|
|
202 |
|
|
203 |
/**
|
|
204 |
* Delegates engine command execution to the state context.
|
|
205 |
*/
|
|
206 |
template < typename T >
|
|
207 |
inline void ExecuteEngineCommand(
|
|
208 |
TInt aCommand, T& aParam );
|
|
209 |
|
|
210 |
/**
|
|
211 |
* Sets execution state.
|
|
212 |
*/
|
|
213 |
void SetExecState( const TVtUiStates::TVtUiExecState aState );
|
|
214 |
|
|
215 |
protected: // constructor
|
|
216 |
|
|
217 |
// c++ constructor
|
|
218 |
TVtUiAppStateBase( MVtUiStateContext& aCtx, TVtUiStates& aUiStates );
|
|
219 |
|
|
220 |
private: // from MVtUiShutterObserver
|
|
221 |
|
|
222 |
/**
|
|
223 |
* Handles 'shutdown ready' event.
|
|
224 |
*/
|
|
225 |
virtual void HandleShutdownReady();
|
|
226 |
|
|
227 |
private: // new functions
|
|
228 |
|
|
229 |
/**
|
|
230 |
* Updates applications lock state and sends to background if
|
|
231 |
* the device is locked.
|
|
232 |
*/
|
|
233 |
void HandleDeviceLockEventL( const TBool aDeviceIsLocked );
|
|
234 |
|
|
235 |
protected: // data members
|
|
236 |
|
|
237 |
// Context providing services to states
|
|
238 |
MVtUiStateContext& iCtx;
|
|
239 |
|
|
240 |
// Various application specific state information
|
|
241 |
TVtUiStates& iUiStates;
|
|
242 |
|
|
243 |
/** Prevents sending end call command to call handling if ETrue.
|
|
244 |
* It is not allowed when call clearing is network originated.
|
|
245 |
*/
|
|
246 |
|
|
247 |
/**
|
|
248 |
* shutdown request received
|
|
249 |
*/
|
|
250 |
static TBool iShutdownRequested;
|
|
251 |
|
|
252 |
};
|
|
253 |
|
|
254 |
#include "tvtuiappstatebase.inl"
|
|
255 |
|
|
256 |
#endif // T_VTUIAPPSTATEBASE_H
|