|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Observer voice headset key presses |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "vcmanagervoiceheadsetlauncher.h" |
|
20 #include "rubydebug.h" |
|
21 #include <apgcli.h> |
|
22 #include <apgtask.h> |
|
23 #include <apacmdln.h> |
|
24 #include <remconinterfaceselector.h> |
|
25 #include <RemConCallHandlingTarget.h> |
|
26 #include <voiceuidomainpskeys.h> |
|
27 #include <vuivoicerecogdefs.h> |
|
28 #include <ctsydomainpskeys.h> |
|
29 #include <coreapplicationuisdomainpskeys.h> |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CVCommandManagerVoiceHeadSetLauncher::CVCommandManagerVoiceHeadSetLauncher |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CVCommandManagerVoiceHeadSetLauncher::CVCommandManagerVoiceHeadSetLauncher() |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CVCommandManagerVoiceHeadSetLauncher::ConstructL |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CVCommandManagerVoiceHeadSetLauncher::ConstructL() |
|
51 { |
|
52 RUBY_DEBUG_BLOCK( "CVCommandManagerVoiceHeadSetLauncher::ConstructL" ); |
|
53 iSelector = CRemConInterfaceSelector::NewL(); |
|
54 iCallHandlingTarget = CRemConCallHandlingTarget::NewL( *iSelector, *this ); |
|
55 // Connect to Remote Control server as target. After succesfull call |
|
56 // client is ready to receive commands. Call this method only once in a |
|
57 // process. |
|
58 iSelector->OpenTargetL(); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CVCommandManagerVoiceHeadSetLauncher::NewL |
|
63 // Two-phased constructor. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CVCommandManagerVoiceHeadSetLauncher* CVCommandManagerVoiceHeadSetLauncher::NewL() |
|
67 { |
|
68 CVCommandManagerVoiceHeadSetLauncher* self = new( ELeave ) CVCommandManagerVoiceHeadSetLauncher; |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop( self ); |
|
72 return self; |
|
73 } |
|
74 |
|
75 |
|
76 // Destructor |
|
77 CVCommandManagerVoiceHeadSetLauncher::~CVCommandManagerVoiceHeadSetLauncher() |
|
78 { |
|
79 RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::~CVCommandManagerVoiceHeadSetLauncher - START" ); |
|
80 |
|
81 // iCallHandlingTarget will be destroyed when iSelector is destroyed. |
|
82 delete iSelector; |
|
83 |
|
84 RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::~CVCommandManagerVoiceHeadSetLauncher - EXIT" ); |
|
85 } |
|
86 |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CVCommandManagerVoiceHeadSetLauncher::AnswerCall |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CVCommandManagerVoiceHeadSetLauncher::AnswerCall() |
|
93 { |
|
94 RUBY_DEBUG0( "" ); |
|
95 TRequestStatus response( KErrNone ); |
|
96 iCallHandlingTarget->SendResponse( response, ERemConExtAnswerCall, KErrNone ); |
|
97 User::WaitForRequest( response ); |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CVCommandManagerVoiceHeadSetLauncher::AnswerCall |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 void CVCommandManagerVoiceHeadSetLauncher::AnswerEndCall() |
|
105 { |
|
106 RUBY_DEBUG0( "" ); |
|
107 iProperty.Set( KPSUidVoiceUiAccMonitor, KVoiceUiAccessoryEvent, KVoiceUiShortPressEvent ); |
|
108 TRequestStatus response( KErrNone ); |
|
109 iCallHandlingTarget->SendResponse( response, ERemConExtAnswerEnd, KErrNone ); |
|
110 User::WaitForRequest( response ); |
|
111 } |
|
112 |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CVCommandManagerVoiceHeadSetLauncher::EndCall |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CVCommandManagerVoiceHeadSetLauncher::EndCall() |
|
119 { |
|
120 RUBY_DEBUG0( "" ); |
|
121 TRequestStatus response( KErrNone ); |
|
122 iCallHandlingTarget->SendResponse( response, ERemConExtEndCall, KErrNone ); |
|
123 User::WaitForRequest( response ); |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CVCommandManagerVoiceHeadSetLauncher::LastNumberRedial |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CVCommandManagerVoiceHeadSetLauncher::LastNumberRedial() |
|
131 { |
|
132 RUBY_DEBUG0( "" ); |
|
133 TRequestStatus response( KErrNone ); |
|
134 iCallHandlingTarget->SendResponse( response, ERemConExtLastNumberRedial, KErrNone ); |
|
135 User::WaitForRequest( response ); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CVCommandManagerVoiceHeadSetLauncher::VoiceDial |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CVCommandManagerVoiceHeadSetLauncher::VoiceDial( const TBool /*aActivate*/ ) |
|
143 { |
|
144 RUBY_DEBUG0( "" ); |
|
145 if ( GetAutoLockValue() > EAutolockOff ) |
|
146 { |
|
147 TRemConExtCmdSource source; |
|
148 iCallHandlingTarget->GetCommandSourceInfo( source ); |
|
149 |
|
150 if ( source == ERemConExtCmdSourceBluetooth ) |
|
151 { |
|
152 TRAP_IGNORE( LaunchVoiceUiL( ETrue ) ); |
|
153 } |
|
154 } |
|
155 else |
|
156 { |
|
157 TRAP_IGNORE( LaunchVoiceUiL( EFalse ) ); |
|
158 } |
|
159 TRequestStatus response( KErrNone ); |
|
160 iCallHandlingTarget->SendResponse( response, ERemConExtVoiceDial, KErrNone ); |
|
161 User::WaitForRequest( response ); |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // CVCommandManagerVoiceHeadSetLauncher::DialCall |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 void CVCommandManagerVoiceHeadSetLauncher::DialCall( const TDesC8& /*aTelNumber*/ ) |
|
169 { |
|
170 RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::DialCall" ); |
|
171 TRequestStatus response( KErrNone ); |
|
172 iCallHandlingTarget->SendResponse( response, ERemConExtDialCall, KErrNone ); |
|
173 User::WaitForRequest( response ); |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // CVCommandManagerVoiceHeadSetLauncher::MultipartyCalling |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 void CVCommandManagerVoiceHeadSetLauncher::MultipartyCalling( const TDesC8& /*aData*/ ) |
|
181 { |
|
182 RUBY_DEBUG0( "" ); |
|
183 TRequestStatus response( KErrNone ); |
|
184 iCallHandlingTarget->SendResponse( response, ERemConExt3WaysCalling, KErrNone ); |
|
185 User::WaitForRequest( response ); |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // CVCommandManagerVoiceHeadSetLauncher::GenerateDTMF |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 void CVCommandManagerVoiceHeadSetLauncher::GenerateDTMF( const TChar /*aChar*/ ) |
|
193 { |
|
194 RUBY_DEBUG0( "" ); |
|
195 TRequestStatus response( KErrNone ); |
|
196 iCallHandlingTarget->SendResponse( response, ERemConExtGenerateDTMF, KErrNone ); |
|
197 User::WaitForRequest( response ); |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CVCommandManagerVoiceHeadSetLauncher::SpeedDial |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 void CVCommandManagerVoiceHeadSetLauncher::SpeedDial( const TInt /*aIndex*/ ) |
|
205 { |
|
206 RUBY_DEBUG0( "" ); |
|
207 TRequestStatus response( KErrNone ); |
|
208 iCallHandlingTarget->SendResponse( response, ERemConExtSpeedDial, KErrNone ); |
|
209 User::WaitForRequest( response ); |
|
210 } |
|
211 |
|
212 |
|
213 // --------------------------------------------------------- |
|
214 // CVCommandManagerVoiceHeadSetLauncher::LaunchVoiceUiL |
|
215 // --------------------------------------------------------- |
|
216 // |
|
217 void CVCommandManagerVoiceHeadSetLauncher::LaunchVoiceUiL( TBool aDeviceLockMode ) |
|
218 { |
|
219 RUBY_DEBUG_BLOCK( "" ); |
|
220 |
|
221 // Check that phone or video call is not currently active |
|
222 TInt state = CheckCallState(); |
|
223 if ( ( state == EPSCTsyCallStateNone || |
|
224 state == EPSCTsyCallStateUninitialized || |
|
225 state == KErrUnknown ) && !IsVideoCall() ) |
|
226 { |
|
227 TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() ); |
|
228 TApaTask apaTask = apaTaskList.FindApp( KVoiceUiUID ); |
|
229 |
|
230 if ( apaTask.Exists() ) |
|
231 { |
|
232 apaTask.BringToForeground(); |
|
233 |
|
234 iProperty.Set( KPSUidVoiceUiAccMonitor, KVoiceUiAccessoryEvent, KVoiceUiLongPressEvent ); |
|
235 } |
|
236 else |
|
237 { |
|
238 RApaLsSession apaLsSession; |
|
239 User::LeaveIfError( apaLsSession.Connect() ); |
|
240 |
|
241 TApaAppInfo appInfo; |
|
242 User::LeaveIfError( apaLsSession.GetAppInfo( appInfo, KVoiceUiUID ) ); |
|
243 |
|
244 TFileName appName = appInfo.iFullName; |
|
245 CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC(); |
|
246 |
|
247 apaCommandLine->SetExecutableNameL( appName ); |
|
248 apaCommandLine->SetCommandL( EApaCommandRunWithoutViews ); |
|
249 |
|
250 if ( aDeviceLockMode ) |
|
251 { |
|
252 // Command line parameters |
|
253 apaCommandLine->SetTailEndL( KVoiceUiMode ); |
|
254 } |
|
255 |
|
256 User::LeaveIfError ( apaLsSession.StartApp( *apaCommandLine ) ); |
|
257 CleanupStack::PopAndDestroy( apaCommandLine ); |
|
258 |
|
259 apaLsSession.Close(); |
|
260 } |
|
261 } |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------- |
|
265 // CVCommandManagerVoiceHeadSetLauncher::CheckCallState |
|
266 // --------------------------------------------------------- |
|
267 // |
|
268 TInt CVCommandManagerVoiceHeadSetLauncher::CheckCallState() |
|
269 { |
|
270 RUBY_DEBUG0( "START" ); |
|
271 |
|
272 TInt callState; |
|
273 TInt err = RProperty::Get( KPSUidCtsyCallInformation, |
|
274 KCTsyCallState, |
|
275 callState ); |
|
276 if ( err == KErrNotFound ) |
|
277 { |
|
278 callState = KErrNotFound; |
|
279 } |
|
280 |
|
281 RUBY_DEBUG0( "EXIT" ); |
|
282 |
|
283 return callState; |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CVCommandManagerVoiceHeadSetLauncher::IsVideoCall |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 TBool CVCommandManagerVoiceHeadSetLauncher::IsVideoCall() |
|
291 { |
|
292 RUBY_DEBUG0( "START" ); |
|
293 |
|
294 TInt callType; |
|
295 RProperty::Get( KPSUidCtsyCallInformation, |
|
296 KCTsyCallType, |
|
297 callType );// Ignore errors |
|
298 |
|
299 RUBY_DEBUG0( "EXIT" ); |
|
300 |
|
301 return callType == EPSCTsyCallTypeH324Multimedia; |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 TInt CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue() |
|
309 { |
|
310 RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue START" ); |
|
311 |
|
312 TInt autoLockValue; |
|
313 TInt err = RProperty::Get( KPSUidCoreApplicationUIs, |
|
314 KCoreAppUIsAutolockStatus, |
|
315 autoLockValue ); |
|
316 if ( err == KErrNotFound ) |
|
317 { |
|
318 autoLockValue = KErrNotFound; |
|
319 } |
|
320 |
|
321 RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue EXIT" ); |
|
322 |
|
323 return autoLockValue; |
|
324 } |
|
325 |
|
326 // End of File |