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