|
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 #include "tvtuiappstates.h" |
|
20 #include "videotelui.hrh" |
|
21 #include "tvtuistates.h" |
|
22 #include "cvtuiappshutter.h" |
|
23 #include "mvtuistatecontext.h" |
|
24 #include <videotelui.rsg> |
|
25 #include <aknquerydialog.h> |
|
26 #include <stringloader.h> |
|
27 #include <cvtlogger.h> |
|
28 #include <cvtengmodel.h> |
|
29 #include <vtengevents.h> |
|
30 #include <mvtengcommandhandler.h> |
|
31 #include <coreapplicationuisdomainpskeys.h> |
|
32 |
|
33 // By default call ending command is allowed to send to call handling. |
|
34 |
|
35 // Initially no shutdown request |
|
36 TBool TVtUiAppStateBase::iShutdownRequested = EFalse; |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // c++ constructor |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 TVtUiAppStateBase::TVtUiAppStateBase( |
|
43 MVtUiStateContext& aCtx, |
|
44 TVtUiStates& aUiStates ) : iCtx(aCtx), iUiStates( aUiStates ) |
|
45 { |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // Destructor |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 TVtUiAppStateBase::~TVtUiAppStateBase() |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // TVtUiAppStateBase::AppUiStartupPhase1DoneL |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void TVtUiAppStateBase::AppUiStartupPhase1DoneL() |
|
61 { |
|
62 // no default behavior |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // TVtUiAppStateBase::AppUiStartupPhase2DoneL |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void TVtUiAppStateBase::AppUiStartupPhase2DoneL() |
|
70 { |
|
71 // no default behavior |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // TVtUiAppStateBase::ShutdownDoneL |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void TVtUiAppStateBase::ShutdownDoneL() |
|
79 { |
|
80 // no default behavior |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // TVtUiAppStateBase::HandleForegroundChangedL |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 TBool TVtUiAppStateBase::HandleForegroundChangedL( |
|
88 const TBool /*aIsForegroung*/ ) |
|
89 { |
|
90 // no default behavior |
|
91 return EFalse; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // TVtUiAppStateBase::PreHandleForegroundChangedL |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 TBool TVtUiAppStateBase::PreHandleForegroundChangedL( |
|
99 const TBool /*aIsForegroung*/ ) |
|
100 { |
|
101 // no default behavior |
|
102 return EFalse; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // TVtUiAppStateBase::StartDtmfTone |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void TVtUiAppStateBase::StartDtmfTone( const TChar& /*aTone*/ ) |
|
110 { |
|
111 // no default behavior |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // TVtUiAppStateBase::StopDtmfTone |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void TVtUiAppStateBase::StopDtmfTone() |
|
119 { |
|
120 // no default behavior |
|
121 } |
|
122 |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // TVtUiAppStateBase::SetInitialStateL |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void TVtUiAppStateBase::SetInitialStateL( |
|
129 MVtUiStateContext& aCtx, |
|
130 TVtUiStates& aUiStates ) |
|
131 { |
|
132 __VTPRINTENTER( "TVtUiAppStateBase.SetInitialState" ) |
|
133 TVtUiAppStateBase* initialState = |
|
134 TVtUiStateStarting::InstanceL( aCtx, aUiStates ); |
|
135 aCtx.ChangeState( initialState ); |
|
136 initialState->OpenL(); |
|
137 __VTPRINTEXIT( "TVtUiAppStateBase.SetInitialState" ) |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // TVtUiAppStateBase::AppUiStartupFailedL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void TVtUiAppStateBase::AppUiStartupFailedL() |
|
145 { |
|
146 __VTPRINTENTER( "TVtUiAppStateBase.AppUiStartupFailedL" ) |
|
147 // Shutdown |
|
148 ChangeStateL( *TVtUiStateResetting::InstanceL( iCtx, iUiStates ) ); |
|
149 __VTPRINTEXIT( "TVtUiAppStateBase.AppUiStartupFailedL" ) |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // TVtUiAppStateBase::OpenL |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void TVtUiAppStateBase::OpenL() |
|
157 { |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // TVtUiAppStateBase::Close |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 void TVtUiAppStateBase::Close() |
|
165 { |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // TVtUiAppStateBase::ChangeStateL |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 void TVtUiAppStateBase::ChangeStateL( TVtUiAppStateBase& aNewState ) |
|
173 { |
|
174 __VTPRINTENTER( "TVtUiAppStateBase.ChangeStateL" ) |
|
175 |
|
176 // Check for transition to already active state. |
|
177 TVtUiAppStateBase* state = &aNewState; |
|
178 if ( state == this ) |
|
179 { |
|
180 __VTPRINTEXITR( "TVtUiAppStateBase.ChangeStateL %d", 0 ) |
|
181 return; |
|
182 } |
|
183 const TVtEngCommandId pending = |
|
184 iCtx.Model().CommandHandler().PendingCommand(); |
|
185 if ( pending != KVtEngCommandNone && |
|
186 state == TVtUiStateResetting::InstanceL( iCtx, iUiStates ) ) |
|
187 { |
|
188 // delay shutdown until engine command completes |
|
189 __VTPRINT2( DEBUG_GEN, "TVtUiAppStateBase.ChangeStateL, pengind command is: %d", pending ); |
|
190 TVtUiAppStateBase::iShutdownRequested = ETrue; |
|
191 |
|
192 if ( pending == KVtEngInitializeShareImage ) |
|
193 { |
|
194 iCtx.Model().CommandHandler().CancelCommand( pending ); |
|
195 } |
|
196 |
|
197 __VTPRINTEXITR( "TVtUiAppStateBase.ChangeStateL %d", KErrNotReady ) |
|
198 return; |
|
199 } |
|
200 __VTPRINT( DEBUG_GEN, |
|
201 " TVtUiAppStateBase.ChangeStateL !! STATE TRANSITION !!" ) |
|
202 iCtx.ChangeState( &aNewState ); |
|
203 Close(); |
|
204 // perform entry action for new state |
|
205 aNewState.OpenL(); |
|
206 __VTPRINTEXITR( "TVtUiAppStateBase.ChangeStateL %d", 1 ) |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // TVtUiAppStateBase::CleanupResetPushL |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void TVtUiAppStateBase::CleanupResetPushL() |
|
214 { |
|
215 // Shutdown if leave occurs in critical ops. |
|
216 CleanupStack::PushL( |
|
217 TCleanupItem( TransitionToReset, this ) ); |
|
218 } |
|
219 |
|
220 // ----------------------------------------------------------------------------- |
|
221 // TVtUiAppStateBase::TransitionToReset |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 void TVtUiAppStateBase::TransitionToReset( TAny* aAny ) |
|
225 { |
|
226 TVtUiAppStateBase* state = reinterpret_cast< TVtUiAppStateBase* >( aAny ); |
|
227 TRAP_IGNORE( state->ChangeStateL( *TVtUiStateResetting::InstanceL( |
|
228 state->iCtx, state->iUiStates ) ) ); |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // TVtUiAppStateBase::HandleVTCommandPerformedL |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 TVtUiAppStateBase::TEventResponse TVtUiAppStateBase::HandleVTCommandPerformedL( |
|
236 TVtEngCommandId /*aCommand*/, |
|
237 const TInt /*aError*/ ) |
|
238 { |
|
239 __VTPRINTENTER( "TVtUiAppStateBase.HandleVTCommandPerformedL" ) |
|
240 // By default all UI is allowed to handle all command completions. |
|
241 TEventResponse handled = EEventNotHandled; |
|
242 |
|
243 // check if shutdown requested while command was pending |
|
244 const TVtEngCommandId pending = iCtx.Model().CommandHandler().PendingCommand(); |
|
245 if ( pending == KVtEngCommandNone && |
|
246 TVtUiAppStateBase::iShutdownRequested ) |
|
247 { |
|
248 __VTPRINT( DEBUG_GEN, "Handling delayed shutdown" ); |
|
249 ChangeStateL( *TVtUiStateResetting::InstanceL( |
|
250 iCtx, iUiStates ) ); |
|
251 } |
|
252 __VTPRINTEXIT( "TVtUiAppStateBase.HandleVTCommandPerformedL" ) |
|
253 return handled; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // TVtUiAppStateBase::HandleVtEventL |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 TVtUiAppStateBase::TEventResponse TVtUiAppStateBase::HandleVtEventL( |
|
261 const TInt aEvent ) |
|
262 { |
|
263 __VTPRINTENTER( "TVtUiAppStateBase.HandleVtEventL" ) |
|
264 TEventResponse handled = EEventHandled; |
|
265 switch ( aEvent ) |
|
266 { |
|
267 case KVtEngDeviceLockOn: |
|
268 case KVtEngDeviceLockOff: |
|
269 HandleDeviceLockEventL( aEvent == KVtEngDeviceLockOn ); |
|
270 break; |
|
271 case KVtEngRemoteDisconnect: |
|
272 /** Don't allow sending of end active call command to call handling |
|
273 * because requesting disconnect from the network after NW originated |
|
274 * termination violates standards. |
|
275 */ |
|
276 break; |
|
277 default: |
|
278 handled = EEventNotHandled; |
|
279 break; |
|
280 } |
|
281 __VTPRINTEXIT( "TVtUiAppStateBase.HandleVtEventL" ) |
|
282 return handled; |
|
283 } |
|
284 |
|
285 // ----------------------------------------------------------------------------- |
|
286 // TVtUiAppStateBase::HandleCommandL |
|
287 // ----------------------------------------------------------------------------- |
|
288 // |
|
289 TVtUiAppStateBase::TEventResponse TVtUiAppStateBase::HandleCommandL( |
|
290 const TInt /*aCommand*/ ) |
|
291 { |
|
292 __VTPRINTENTER( "TVtUiAppStateBase.HandleCommandL" ) |
|
293 TEventResponse handled = EEventNotHandled; |
|
294 __VTPRINTEXITR( "TVtUiAppStateBase.HandleCommandL %d", handled ) |
|
295 return handled; |
|
296 } |
|
297 |
|
298 // ----------------------------------------------------------------------------- |
|
299 // TVtUiAppStateBase::HandleLayoutChangedL |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 void TVtUiAppStateBase::HandleLayoutChangedL( ) |
|
303 { |
|
304 __VTPRINTENTER( "TVtUiAppStateBase.HandleLayoutChangedL" ) |
|
305 // By default only indicate that layout change needs to be handled. |
|
306 iUiStates.SetLayoutChangeNeeded( ETrue ); |
|
307 __VTPRINTEXIT( "TVtUiAppStateBase.HandleLayoutChangedL" ) |
|
308 } |
|
309 |
|
310 // ----------------------------------------------------------------------------- |
|
311 // TVtUiAppStateBase::HandleShutdownReady |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void TVtUiAppStateBase::HandleShutdownReady() |
|
315 { |
|
316 __VTPRINTENTER( "TVtUiAppStateBase.HandleShutdownReady" ) |
|
317 // forwarded to AppUi which handles UI framework exit |
|
318 iCtx.HandleShutdownReady(); |
|
319 iCtx.ChangeState( NULL ); |
|
320 // deletes current state |
|
321 Close(); |
|
322 __VTPRINTEXIT( "TVtUiAppStateBase.HandleShutdownReady" ) |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // TVtUiAppStateBase::HandleDeviceLockEventL |
|
327 // |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void TVtUiAppStateBase::HandleDeviceLockEventL( const TBool aDeviceIsLocked ) |
|
331 { |
|
332 __VTPRINTENTER( "TVtUiAppStateBase.HandleDeviceLockEventL" ) |
|
333 iUiStates.SetDeviceLockOn( aDeviceIsLocked ); |
|
334 if ( aDeviceIsLocked ) |
|
335 { |
|
336 iCtx.ChangeApplicationFocus( EFalse ); |
|
337 } |
|
338 __VTPRINTEXITR( "TVtUiAppStateBase.HandleDeviceLockEventL lock state=%d", |
|
339 aDeviceIsLocked ) |
|
340 } |
|
341 |
|
342 // ----------------------------------------------------------------------------- |
|
343 // TVtUiAppStateBase::CheckEndActiveCallL |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 TBool TVtUiAppStateBase::CheckEndActiveCallL() |
|
347 { |
|
348 __VTPRINTENTER( "TVtUiAppStateBase.CheckEndActiveCallL" ) |
|
349 const MVtEngSessionInfo::TSessionState state = SessionState( EFalse ); |
|
350 TBool shutdownStarted( EFalse ); |
|
351 if ( state == MVtEngSessionInfo::EIdle ) |
|
352 { |
|
353 __VTPRINT( DEBUG_GEN, "VtUi.Release bearer" ) |
|
354 // h.245 session is ended |
|
355 ChangeStateL( *TVtUiStateResetting::InstanceL( iCtx, iUiStates ) ); |
|
356 shutdownStarted = ETrue; |
|
357 } |
|
358 __VTPRINTEXITR( "TVtUiAppStateBase.CheckEndActiveCallL %d", |
|
359 shutdownStarted ) |
|
360 return shutdownStarted; |
|
361 } |
|
362 |
|
363 // ----------------------------------------------------------------------------- |
|
364 // TVtUiAppStateBase::SessionState |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 MVtEngSessionInfo::TSessionState TVtUiAppStateBase::SessionState( |
|
368 const TBool aUpdate ) const |
|
369 { |
|
370 const CVtEngModel& model = iCtx.Model(); |
|
371 const MVtEngSessionInfo& session = model.Session(); |
|
372 return session.State( aUpdate ); |
|
373 } |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // TVtUiAppStateBase::SetLightsState |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 void TVtUiAppStateBase::SetLightsState( const TBool aOn ) |
|
380 { |
|
381 __VTPRINTENTER( "TVtUiAppStateBase.SetLightsState" ) |
|
382 const TInt value = aOn ? EForcedLightsOn : EForcedLightsOff; |
|
383 RProperty::Set( |
|
384 KPSUidCoreApplicationUIs, |
|
385 KLightsVTForcedLightsOn, |
|
386 value ); |
|
387 __VTPRINTEXIT( "TVtUiAppStateBase.SetLightsState" ) |
|
388 } |
|
389 |
|
390 // ----------------------------------------------------------------------------- |
|
391 // TVtUiAppStateBase::SetExecState |
|
392 // ----------------------------------------------------------------------------- |
|
393 // |
|
394 void TVtUiAppStateBase::SetExecState( const TVtUiStates::TVtUiExecState aState ) |
|
395 { |
|
396 __VTPRINTENTER( "TVtUiAppStateBase.SetExecState" ) |
|
397 iUiStates.SetExecState( aState ); |
|
398 __VTPRINTEXITR( "TVtUiAppStateBase.SetExecState %d", aState ) |
|
399 } |