35
|
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: running (normal operation) application state
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "tvtuistates.h"
|
|
20 |
#include "tvtuiappstates.h"
|
|
21 |
#include "mvtuistatecontext.h"
|
|
22 |
#include "cvtuiappshutter.h"
|
|
23 |
#include "videotelui.hrh"
|
|
24 |
#include <cvtlogger.h>
|
|
25 |
#include <vtengevents.h>
|
|
26 |
#include <StringLoader.h>
|
|
27 |
#include <AknQueryDialog.h>
|
|
28 |
#include <videotelui.rsg>
|
|
29 |
|
|
30 |
TVtUiStateRunning* TVtUiStateRunning::iInstance = NULL;
|
|
31 |
|
|
32 |
// c++ constructor
|
|
33 |
TVtUiStateRunning::TVtUiStateRunning(
|
|
34 |
MVtUiStateContext& aCtx, TVtUiStates& aUiStates )
|
|
35 |
: TVtUiAppStateBase( aCtx, aUiStates ), iCreateVoiceCallDlg( NULL )
|
|
36 |
{
|
|
37 |
}
|
|
38 |
|
|
39 |
// Destructor
|
|
40 |
TVtUiStateRunning::~TVtUiStateRunning()
|
|
41 |
{
|
|
42 |
}
|
|
43 |
|
|
44 |
// -----------------------------------------------------------------------------
|
|
45 |
// TVtUiStateRunning::InstanceL
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
TVtUiStateRunning * TVtUiStateRunning::InstanceL(
|
|
49 |
MVtUiStateContext& aCtx,
|
|
50 |
TVtUiStates& aUiStates )
|
|
51 |
{
|
|
52 |
__VTPRINTENTER( "UiStateRunning.InstanceL" )
|
|
53 |
if ( iInstance == NULL )
|
|
54 |
iInstance = new ( ELeave ) TVtUiStateRunning( aCtx, aUiStates );
|
|
55 |
__VTPRINTEXIT( "UiStateRunning.InstanceL" )
|
|
56 |
return iInstance;
|
|
57 |
}
|
|
58 |
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
// TVtUiStateRunning::HandleVtEventL
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
TVtUiAppStateBase::TEventResponse TVtUiStateRunning::HandleVtEventL(
|
|
64 |
const TInt aEvent )
|
|
65 |
{
|
|
66 |
__VTPRINTENTER( "UiStateRunning.HandleVtEventL" )
|
|
67 |
// let TVtUiAppStateBase base class do common tasks
|
|
68 |
TEventResponse handled = TVtUiAppStateBase::HandleVtEventL( aEvent );
|
|
69 |
switch ( aEvent )
|
|
70 |
{
|
|
71 |
case KVtEngDeviceLockOn:
|
|
72 |
case KVtEngDeviceLockOff:
|
|
73 |
TVtUiAppStateBase::HandleVtEventL( aEvent );
|
|
74 |
if ( aEvent == KVtEngDeviceLockOff )
|
|
75 |
{
|
|
76 |
iCtx.ChangeApplicationFocus( ETrue );
|
|
77 |
}
|
|
78 |
break;
|
|
79 |
case KVtEngSessionStateChanged:
|
|
80 |
if ( CheckEndActiveCallL() )
|
|
81 |
{
|
|
82 |
// At this point shutdown is in progress. Don't allow
|
|
83 |
// appUi to do actions due to this event.
|
|
84 |
handled = EEventHandled;
|
|
85 |
}
|
|
86 |
break;
|
|
87 |
default:
|
|
88 |
break;
|
|
89 |
}
|
|
90 |
__VTPRINTEXIT( "UiStateRunning.HandleVtEventL" )
|
|
91 |
return handled;
|
|
92 |
}
|
|
93 |
|
|
94 |
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
// TVtUiStateRunning::HandleCommandL
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
TVtUiAppStateBase::TEventResponse TVtUiStateRunning::HandleCommandL(
|
|
100 |
const TInt aCommand )
|
|
101 |
{
|
|
102 |
__VTPRINTENTER( "UiStateRunning.HandleCommandL" )
|
|
103 |
/** By default all commands are enabled by running state.
|
|
104 |
* Other details command validations are done elsewhere
|
|
105 |
*/
|
|
106 |
TEventResponse handled = EEventHandled;
|
|
107 |
switch ( aCommand )
|
|
108 |
{
|
|
109 |
case EVtUiCmdEndActiveCall:
|
|
110 |
{
|
|
111 |
const MVtEngSessionInfo::TSessionState state = SessionState( EFalse );
|
|
112 |
if ( state == MVtEngSessionInfo::EOpen )
|
|
113 |
{
|
|
114 |
ShutdownWithEngineCommandL( KVtEngTerminateSession );
|
|
115 |
}
|
|
116 |
}
|
|
117 |
break;
|
|
118 |
case EVtUiCmdCreateVoice:
|
|
119 |
CreateVoiceCallL();
|
|
120 |
break;
|
|
121 |
case EVtUiCmdDialEmergency:
|
|
122 |
// Attempt emergency call. Note that emergency number check is done
|
|
123 |
// after calling DialEmergencyCallL and if supplied number is not
|
|
124 |
// emergency leave occurs.
|
|
125 |
TRAP_IGNORE( DialEmergencyCallL() );
|
|
126 |
break;
|
|
127 |
default:
|
|
128 |
handled = TVtUiAppStateBase::HandleCommandL( aCommand );
|
|
129 |
break;
|
|
130 |
}
|
|
131 |
__VTPRINTEXITR( "UiStateRunning.HandleCommandL %d", handled )
|
|
132 |
return handled;
|
|
133 |
}
|
|
134 |
|
|
135 |
|
|
136 |
// -----------------------------------------------------------------------------
|
|
137 |
// TVtUiStateRunning::HandleForegroundChangedL
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
TBool TVtUiStateRunning::HandleForegroundChangedL( const TBool aIsForeground )
|
|
141 |
{
|
|
142 |
__VTPRINTENTER( "UiStateRunning.HandleForegroundChangedL" )
|
|
143 |
|
|
144 |
// Closes create voice call dialog if it is open
|
|
145 |
delete iCreateVoiceCallDlg; iCreateVoiceCallDlg = NULL;
|
|
146 |
|
|
147 |
SetLightsState( aIsForeground );
|
|
148 |
|
|
149 |
iCtx.RefreshL( MVtUiStateContext::ENaviPane );
|
|
150 |
|
|
151 |
TBool handleAsForeground( aIsForeground );
|
|
152 |
TPtrC8 params( reinterpret_cast< TUint8* >( &handleAsForeground ),
|
|
153 |
sizeof( TBool ) );
|
|
154 |
iCtx.DoExecuteCmdL( KVtEngSetUIForeground, ¶ms );
|
|
155 |
__VTPRINTEXIT( "UiStateRunning.HandleForegroundChangedL" )
|
|
156 |
return handleAsForeground;
|
|
157 |
}
|
|
158 |
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
// TVtUiStateRunning::PreHandleForegroundChangedL
|
|
161 |
// -----------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
TBool TVtUiStateRunning::PreHandleForegroundChangedL( const TBool aIsForeground )
|
|
164 |
{
|
|
165 |
__VTPRINTENTER( "UiStateRunning.PreHandleForegroundChangedL" )
|
|
166 |
TBool handleAsForeground( aIsForeground );
|
|
167 |
TPtrC8 params( reinterpret_cast< TUint8* >( &handleAsForeground ), sizeof( TBool ) );
|
|
168 |
iCtx.DoExecuteCmdL( KVtEngSetUIForeground, ¶ms );
|
|
169 |
__VTPRINTEXIT( "UiStateRunning.PreHandleForegroundChangedL" )
|
|
170 |
return handleAsForeground;
|
|
171 |
}
|
|
172 |
|
|
173 |
// -----------------------------------------------------------------------------
|
|
174 |
// TVtUiStateRunning::HandleLayoutChangedL
|
|
175 |
// -----------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
void TVtUiStateRunning::HandleLayoutChangedL( )
|
|
178 |
{
|
|
179 |
__VTPRINTENTER( "UiStateRunning.HandleLayoutChangedL" )
|
|
180 |
iUiStates.SetLayoutChangeNeeded( EFalse );
|
|
181 |
iCtx.DoHandleLayoutChangedL();
|
|
182 |
__VTPRINTEXIT( "UiStateRunning.HandleLayoutChangedL" )
|
|
183 |
}
|
|
184 |
|
|
185 |
// -----------------------------------------------------------------------------
|
|
186 |
// TVtUiStateRunning::StartDtmfTone
|
|
187 |
// -----------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
void TVtUiStateRunning::StartDtmfTone( const TChar& aTone )
|
|
190 |
{
|
|
191 |
iCtx.StartDtmfTone( aTone );
|
|
192 |
}
|
|
193 |
|
|
194 |
// -----------------------------------------------------------------------------
|
|
195 |
// TVtUiStateRunning::StopDtmfTone
|
|
196 |
// -----------------------------------------------------------------------------
|
|
197 |
//
|
|
198 |
void TVtUiStateRunning::StopDtmfTone()
|
|
199 |
{
|
|
200 |
iCtx.StopDtmfTone();
|
|
201 |
}
|
|
202 |
|
|
203 |
// -----------------------------------------------------------------------------
|
|
204 |
// TVtUiStateRunning::CreateVoiceCallL
|
|
205 |
// -----------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
void TVtUiStateRunning::CreateVoiceCallL()
|
|
208 |
{
|
|
209 |
__VTPRINTENTER( "TVtUiStateRunning.CreateVoiceCallL" )
|
|
210 |
HBufC* prompt =
|
|
211 |
StringLoader::LoadLC( R_VIDEOTELUI_QTN_QUERY_CREATE_VOICE_CALL );
|
|
212 |
|
|
213 |
// Create and initialize query dialog
|
|
214 |
CAknQueryDialog* createVoiceCallDlg = CAknQueryDialog::NewL();
|
|
215 |
CleanupStack::PushL( createVoiceCallDlg );
|
|
216 |
createVoiceCallDlg->SetPromptL( *prompt );
|
|
217 |
CleanupStack::Pop(); // createVoiceCallDlg
|
|
218 |
|
|
219 |
iCreateVoiceCallDlg = createVoiceCallDlg;
|
|
220 |
TInt result( KErrNone );
|
|
221 |
TRAPD( error, result = iCreateVoiceCallDlg->ExecuteLD(
|
|
222 |
R_VIDEOTELUI_CREATE_VOICE_QUERY ) );
|
|
223 |
// Just set to NULL because ExecuteLD() deletes instance
|
|
224 |
iCreateVoiceCallDlg = NULL;
|
|
225 |
// Leave if ExecuteLD() left
|
|
226 |
User::LeaveIfError( error );
|
|
227 |
CleanupStack::PopAndDestroy( ); // prompt
|
|
228 |
if ( result )
|
|
229 |
{
|
|
230 |
//user answered yes
|
|
231 |
iCtx.DoExecuteCmdL( KVtEngSwitchToVoice, NULL );
|
|
232 |
}
|
|
233 |
__VTPRINTEXITR( "TVtUiAppStateBase.CreateVoiceCallL %d", result )
|
|
234 |
}
|
|
235 |
|
|
236 |
// -----------------------------------------------------------------------------
|
|
237 |
// TVtUiStateRunning::ShutdownWithEngineCommandL
|
|
238 |
// Starts shutdown with command to engine.
|
|
239 |
// -----------------------------------------------------------------------------
|
|
240 |
//
|
|
241 |
void TVtUiStateRunning::ShutdownWithEngineCommandL( const TInt aCommand )
|
|
242 |
{
|
|
243 |
__VTPRINTENTER(
|
|
244 |
"TVtUiStateRunning.ShutdownWithEngineCommandL" )
|
|
245 |
TVtUiAppStateBase* resetState =
|
|
246 |
TVtUiStateResetting::InstanceL( iCtx, iUiStates, aCommand );
|
|
247 |
CVtUiAppShutter* shutter = CVtUiAppShutter::InstanceL( *resetState );
|
|
248 |
if ( shutter )
|
|
249 |
{
|
|
250 |
// open resetting state, handles engine command request/reply
|
|
251 |
ChangeStateL( *resetState );
|
|
252 |
#ifdef _DEBUG
|
|
253 |
__VTPRINTEXIT(
|
|
254 |
"TVtUiStateRunning.ShutdownWithEngineCommandL 1" )
|
|
255 |
return;
|
|
256 |
#endif
|
|
257 |
}
|
|
258 |
|
|
259 |
__VTPRINTEXIT(
|
|
260 |
"TVtUiStateRunning.ShutdownWithEngineCommandL 0" )
|
|
261 |
}
|
|
262 |
|
|
263 |
// -----------------------------------------------------------------------------
|
|
264 |
// TVtUiStateRunning::DialEmergencyCallL
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
//
|
|
267 |
void TVtUiStateRunning::DialEmergencyCallL()
|
|
268 |
{
|
|
269 |
__VTPRINTENTER(
|
|
270 |
"TVtUiStateRunning.DialEmergencyCallL" )
|
|
271 |
TVtUiAppStateBase* resetState =
|
|
272 |
TVtUiStateResetting::InstanceL( iCtx, iUiStates );
|
|
273 |
CVtUiAppShutter* shutter = CVtUiAppShutter::InstanceL( *resetState );
|
|
274 |
if ( shutter )
|
|
275 |
{
|
|
276 |
// Make emergency call and proceed when 1) state has given permission
|
|
277 |
// and 2) callback from emergency call api is received
|
|
278 |
shutter->ShutdownWithEmergencyCallL( iCtx );
|
|
279 |
ChangeStateL( *resetState );
|
|
280 |
}
|
|
281 |
__VTPRINTEXIT( "TVtUiStateRunning.DialEmergencyCallL" )
|
|
282 |
}
|
|
283 |
|
|
284 |
// -----------------------------------------------------------------------------
|
|
285 |
// TVtUiStateRunning::OpenL
|
|
286 |
// -----------------------------------------------------------------------------
|
|
287 |
//
|
|
288 |
void TVtUiStateRunning::OpenL()
|
|
289 |
{
|
|
290 |
__VTPRINTENTER( "TVtUiStateRunning.OpenL" )
|
|
291 |
SetExecState( TVtUiStates::EExecStateRunning );
|
|
292 |
iCtx.RefreshStatesL();
|
|
293 |
__VTPRINTEXIT( "TVtUiStateRunning.OpenL" )
|
|
294 |
}
|
|
295 |
|
|
296 |
// -----------------------------------------------------------------------------
|
|
297 |
// TVtUiStateRunning::Close
|
|
298 |
// -----------------------------------------------------------------------------
|
|
299 |
//
|
|
300 |
void TVtUiStateRunning::Close()
|
|
301 |
{
|
|
302 |
__VTPRINTENTER( "TVtUiStateRunning.Close" )
|
|
303 |
if ( TVtUiStateRunning::iInstance )
|
|
304 |
{
|
|
305 |
delete TVtUiStateRunning::iInstance;
|
|
306 |
TVtUiStateRunning::iInstance = NULL;
|
|
307 |
}
|
|
308 |
__VTPRINTEXIT( "TVtUiStateRunning.Close" )
|
|
309 |
}
|