19
|
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 |
iProperty.Close();
|
|
84 |
|
|
85 |
RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::~CVCommandManagerVoiceHeadSetLauncher - EXIT" );
|
|
86 |
}
|
|
87 |
|
|
88 |
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
// CVCommandManagerVoiceHeadSetLauncher::AnswerCall
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
void CVCommandManagerVoiceHeadSetLauncher::AnswerCall()
|
|
94 |
{
|
|
95 |
RUBY_DEBUG0( "" );
|
|
96 |
TRequestStatus response( KErrNone );
|
|
97 |
iCallHandlingTarget->SendResponse( response, ERemConExtAnswerCall, KErrNone );
|
|
98 |
User::WaitForRequest( response );
|
|
99 |
}
|
|
100 |
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
// CVCommandManagerVoiceHeadSetLauncher::AnswerCall
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
void CVCommandManagerVoiceHeadSetLauncher::AnswerEndCall()
|
|
106 |
{
|
|
107 |
RUBY_DEBUG0( "" );
|
|
108 |
iProperty.Set( KPSUidVoiceUiAccMonitor, KVoiceUiAccessoryEvent, KVoiceUiShortPressEvent );
|
|
109 |
TRequestStatus response( KErrNone );
|
|
110 |
iCallHandlingTarget->SendResponse( response, ERemConExtAnswerEnd, KErrNone );
|
|
111 |
User::WaitForRequest( response );
|
|
112 |
}
|
|
113 |
|
|
114 |
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
// CVCommandManagerVoiceHeadSetLauncher::EndCall
|
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
void CVCommandManagerVoiceHeadSetLauncher::EndCall()
|
|
120 |
{
|
|
121 |
RUBY_DEBUG0( "" );
|
|
122 |
TRequestStatus response( KErrNone );
|
|
123 |
iCallHandlingTarget->SendResponse( response, ERemConExtEndCall, KErrNone );
|
|
124 |
User::WaitForRequest( response );
|
|
125 |
}
|
|
126 |
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
// CVCommandManagerVoiceHeadSetLauncher::LastNumberRedial
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
void CVCommandManagerVoiceHeadSetLauncher::LastNumberRedial()
|
|
132 |
{
|
|
133 |
RUBY_DEBUG0( "" );
|
|
134 |
TRequestStatus response( KErrNone );
|
|
135 |
iCallHandlingTarget->SendResponse( response, ERemConExtLastNumberRedial, KErrNone );
|
|
136 |
User::WaitForRequest( response );
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// CVCommandManagerVoiceHeadSetLauncher::VoiceDial
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
void CVCommandManagerVoiceHeadSetLauncher::VoiceDial( const TBool /*aActivate*/ )
|
|
144 |
{
|
|
145 |
RUBY_DEBUG0( "" );
|
|
146 |
if ( GetAutoLockValue() > EAutolockOff )
|
|
147 |
{
|
|
148 |
TRemConExtCmdSource source;
|
|
149 |
iCallHandlingTarget->GetCommandSourceInfo( source );
|
|
150 |
|
|
151 |
if ( source == ERemConExtCmdSourceBluetooth )
|
|
152 |
{
|
|
153 |
TRAP_IGNORE( LaunchVoiceUiL( ETrue ) );
|
|
154 |
}
|
|
155 |
}
|
|
156 |
else
|
|
157 |
{
|
|
158 |
TRAP_IGNORE( LaunchVoiceUiL( EFalse ) );
|
|
159 |
}
|
|
160 |
TRequestStatus response( KErrNone );
|
|
161 |
iCallHandlingTarget->SendResponse( response, ERemConExtVoiceDial, KErrNone );
|
|
162 |
User::WaitForRequest( response );
|
|
163 |
}
|
|
164 |
|
|
165 |
// ---------------------------------------------------------------------------
|
|
166 |
// CVCommandManagerVoiceHeadSetLauncher::DialCall
|
|
167 |
// ---------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
void CVCommandManagerVoiceHeadSetLauncher::DialCall( const TDesC8& /*aTelNumber*/ )
|
|
170 |
{
|
|
171 |
RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::DialCall" );
|
|
172 |
TRequestStatus response( KErrNone );
|
|
173 |
iCallHandlingTarget->SendResponse( response, ERemConExtDialCall, KErrNone );
|
|
174 |
User::WaitForRequest( response );
|
|
175 |
}
|
|
176 |
|
|
177 |
// ---------------------------------------------------------------------------
|
|
178 |
// CVCommandManagerVoiceHeadSetLauncher::MultipartyCalling
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
void CVCommandManagerVoiceHeadSetLauncher::MultipartyCalling( const TDesC8& /*aData*/ )
|
|
182 |
{
|
|
183 |
RUBY_DEBUG0( "" );
|
|
184 |
TRequestStatus response( KErrNone );
|
|
185 |
iCallHandlingTarget->SendResponse( response, ERemConExt3WaysCalling, KErrNone );
|
|
186 |
User::WaitForRequest( response );
|
|
187 |
}
|
|
188 |
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
// CVCommandManagerVoiceHeadSetLauncher::GenerateDTMF
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
void CVCommandManagerVoiceHeadSetLauncher::GenerateDTMF( const TChar /*aChar*/ )
|
|
194 |
{
|
|
195 |
RUBY_DEBUG0( "" );
|
|
196 |
TRequestStatus response( KErrNone );
|
|
197 |
iCallHandlingTarget->SendResponse( response, ERemConExtGenerateDTMF, KErrNone );
|
|
198 |
User::WaitForRequest( response );
|
|
199 |
}
|
|
200 |
|
|
201 |
// ---------------------------------------------------------------------------
|
|
202 |
// CVCommandManagerVoiceHeadSetLauncher::SpeedDial
|
|
203 |
// ---------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
void CVCommandManagerVoiceHeadSetLauncher::SpeedDial( const TInt /*aIndex*/ )
|
|
206 |
{
|
|
207 |
RUBY_DEBUG0( "" );
|
|
208 |
TRequestStatus response( KErrNone );
|
|
209 |
iCallHandlingTarget->SendResponse( response, ERemConExtSpeedDial, KErrNone );
|
|
210 |
User::WaitForRequest( response );
|
|
211 |
}
|
|
212 |
|
|
213 |
|
|
214 |
// ---------------------------------------------------------
|
|
215 |
// CVCommandManagerVoiceHeadSetLauncher::LaunchVoiceUiL
|
|
216 |
// ---------------------------------------------------------
|
|
217 |
//
|
|
218 |
void CVCommandManagerVoiceHeadSetLauncher::LaunchVoiceUiL( TBool aDeviceLockMode )
|
|
219 |
{
|
|
220 |
RUBY_DEBUG_BLOCK( "" );
|
|
221 |
|
|
222 |
// Check that phone or video call is not currently active
|
|
223 |
TInt state = CheckCallState();
|
|
224 |
if ( ( state == EPSCTsyCallStateNone ||
|
|
225 |
state == EPSCTsyCallStateUninitialized ||
|
|
226 |
state == KErrUnknown ) && !IsVideoCall() )
|
|
227 |
{
|
|
228 |
TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() );
|
|
229 |
TApaTask apaTask = apaTaskList.FindApp( KVoiceUiUID );
|
|
230 |
|
|
231 |
if ( apaTask.Exists() )
|
|
232 |
{
|
|
233 |
apaTask.BringToForeground();
|
|
234 |
|
|
235 |
iProperty.Set( KPSUidVoiceUiAccMonitor, KVoiceUiAccessoryEvent, KVoiceUiLongPressEvent );
|
|
236 |
}
|
|
237 |
else
|
|
238 |
{
|
|
239 |
RApaLsSession apaLsSession;
|
|
240 |
User::LeaveIfError( apaLsSession.Connect() );
|
|
241 |
CleanupClosePushL(apaLsSession);
|
|
242 |
|
|
243 |
TApaAppInfo appInfo;
|
|
244 |
User::LeaveIfError( apaLsSession.GetAppInfo( appInfo, KVoiceUiUID ) );
|
|
245 |
|
|
246 |
TFileName appName = appInfo.iFullName;
|
|
247 |
CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC();
|
|
248 |
|
|
249 |
apaCommandLine->SetExecutableNameL( appName );
|
|
250 |
apaCommandLine->SetCommandL( EApaCommandRunWithoutViews );
|
|
251 |
|
|
252 |
if ( aDeviceLockMode )
|
|
253 |
{
|
|
254 |
// Command line parameters
|
|
255 |
apaCommandLine->SetTailEndL( KVoiceUiMode );
|
|
256 |
}
|
|
257 |
|
|
258 |
User::LeaveIfError ( apaLsSession.StartApp( *apaCommandLine ) );
|
|
259 |
CleanupStack::PopAndDestroy( apaCommandLine );
|
|
260 |
|
|
261 |
CleanupStack::PopAndDestroy(&apaLsSession);
|
|
262 |
}
|
|
263 |
}
|
|
264 |
}
|
|
265 |
|
|
266 |
// ---------------------------------------------------------
|
|
267 |
// CVCommandManagerVoiceHeadSetLauncher::CheckCallState
|
|
268 |
// ---------------------------------------------------------
|
|
269 |
//
|
|
270 |
TInt CVCommandManagerVoiceHeadSetLauncher::CheckCallState()
|
|
271 |
{
|
|
272 |
RUBY_DEBUG0( "START" );
|
|
273 |
|
|
274 |
TInt callState;
|
|
275 |
TInt err = RProperty::Get( KPSUidCtsyCallInformation,
|
|
276 |
KCTsyCallState,
|
|
277 |
callState );
|
|
278 |
if ( err == KErrNotFound )
|
|
279 |
{
|
|
280 |
callState = KErrNotFound;
|
|
281 |
}
|
|
282 |
|
|
283 |
RUBY_DEBUG0( "EXIT" );
|
|
284 |
|
|
285 |
return callState;
|
|
286 |
}
|
|
287 |
|
|
288 |
// -----------------------------------------------------------------------------
|
|
289 |
// CVCommandManagerVoiceHeadSetLauncher::IsVideoCall
|
|
290 |
// -----------------------------------------------------------------------------
|
|
291 |
//
|
|
292 |
TBool CVCommandManagerVoiceHeadSetLauncher::IsVideoCall()
|
|
293 |
{
|
|
294 |
RUBY_DEBUG0( "START" );
|
|
295 |
|
|
296 |
TInt callType;
|
|
297 |
RProperty::Get( KPSUidCtsyCallInformation,
|
|
298 |
KCTsyCallType,
|
|
299 |
callType );// Ignore errors
|
|
300 |
|
|
301 |
RUBY_DEBUG0( "EXIT" );
|
|
302 |
|
|
303 |
return callType == EPSCTsyCallTypeH324Multimedia;
|
|
304 |
}
|
|
305 |
|
|
306 |
// -----------------------------------------------------------------------------
|
|
307 |
// CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue
|
|
308 |
// -----------------------------------------------------------------------------
|
|
309 |
//
|
|
310 |
TInt CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue()
|
|
311 |
{
|
|
312 |
RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue START" );
|
|
313 |
|
|
314 |
TInt autoLockValue;
|
|
315 |
TInt err = RProperty::Get( KPSUidCoreApplicationUIs,
|
|
316 |
KCoreAppUIsAutolockStatus,
|
|
317 |
autoLockValue );
|
|
318 |
if ( err == KErrNotFound )
|
|
319 |
{
|
|
320 |
autoLockValue = KErrNotFound;
|
|
321 |
}
|
|
322 |
|
|
323 |
RUBY_DEBUG0( "CVCommandManagerVoiceHeadSetLauncher::GetAutoLockValue EXIT" );
|
|
324 |
|
|
325 |
return autoLockValue;
|
|
326 |
}
|
|
327 |
|
|
328 |
// End of File
|