|
1 /* |
|
2 * Copyright (c) 2005-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: Observer voice key presses |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "vcmanagervoicekeylauncher.h" |
|
20 #include "rubydebug.h" |
|
21 #include <featmgr.h> |
|
22 #include <eikappui.h> |
|
23 #include <apgcli.h> |
|
24 #include <apgtask.h> |
|
25 #include <apacmdln.h> |
|
26 #include <apgwgnam.h> |
|
27 |
|
28 |
|
29 // CONSTANTS |
|
30 const TInt KCapturePriority( 255 ); |
|
31 const TUint KLongVoiceKey( 0x102818E7 ); // unique (UID of this exe) |
|
32 const TUid KVoiceUiUID = { 0x101F8543 }; |
|
33 |
|
34 // --------------------------------------------------------- |
|
35 // CVCommandManagerVoiceKeyLauncher::NewL |
|
36 // --------------------------------------------------------- |
|
37 // |
|
38 CVCommandManagerVoiceKeyLauncher* CVCommandManagerVoiceKeyLauncher::NewL() |
|
39 { |
|
40 CVCommandManagerVoiceKeyLauncher* self = new (ELeave) CVCommandManagerVoiceKeyLauncher(); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------- |
|
48 // CVCommandManagerVoiceKeyLauncher::CVCommandManagerVoiceKeyLauncher |
|
49 // C++ constructor can NOT contain any code, that might leave. |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 CVCommandManagerVoiceKeyLauncher::CVCommandManagerVoiceKeyLauncher() |
|
53 : CActive( EPriorityStandard ) |
|
54 { |
|
55 // nothing |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // CVCommandManagerVoiceKeyLauncher::ConstructL |
|
60 // C++ constructor can NOT contain any code, that might leave. |
|
61 // --------------------------------------------------------- |
|
62 // |
|
63 void CVCommandManagerVoiceKeyLauncher::ConstructL() |
|
64 { |
|
65 RUBY_DEBUG_BLOCK( "" ); |
|
66 |
|
67 // Check if the voice key exist |
|
68 iKeyEnabled = FeatureManager::FeatureSupported( KFeatureIdKeypadNoVoiceKey ); |
|
69 if ( iKeyEnabled ) |
|
70 { |
|
71 User::LeaveIfError( iWsSession.Connect() ); |
|
72 |
|
73 iWindowGroup = RWindowGroup ( iWsSession ); |
|
74 iWindowGroup.Construct( (TUint32) &iWindowGroup, EFalse ); |
|
75 |
|
76 iWindowGroup.SetOrdinalPosition( -1 ); |
|
77 iWindowGroup.EnableReceiptOfFocus( EFalse ); |
|
78 |
|
79 iKeyCaptureHandle = iWindowGroup.CaptureKey( EKeyDevice6, 0, 0 ); |
|
80 iLongKeyCaptureHandle = iWindowGroup.CaptureLongKey( (TUint)EKeyDevice6, |
|
81 KLongVoiceKey, 0, 0, KCapturePriority, ELongCaptureNormal ); |
|
82 |
|
83 CApaWindowGroupName* name = CApaWindowGroupName::NewLC( iWsSession ); |
|
84 name->SetHidden( ETrue ); |
|
85 name->SetWindowGroupName( iWindowGroup ); |
|
86 CleanupStack::PopAndDestroy( name ); |
|
87 |
|
88 iWsSession.EventReady( &iStatus ); |
|
89 |
|
90 CActiveScheduler::Add( this ); |
|
91 SetActive(); |
|
92 |
|
93 } |
|
94 |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // CVCommandManagerVoiceKeyLauncher::~CVCommandManagerVoiceKeyLauncher |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 CVCommandManagerVoiceKeyLauncher::~CVCommandManagerVoiceKeyLauncher() |
|
102 { |
|
103 RUBY_DEBUG0( "START" ); |
|
104 if ( iKeyEnabled ) |
|
105 { |
|
106 Cancel(); |
|
107 iWindowGroup.Close(); |
|
108 iWsSession.Close(); |
|
109 } |
|
110 |
|
111 RUBY_DEBUG0( "EXIT" ); |
|
112 } |
|
113 |
|
114 |
|
115 // --------------------------------------------------------- |
|
116 // CVCommandManagerVoiceKeyLauncher::DoCancel |
|
117 // --------------------------------------------------------- |
|
118 // |
|
119 void CVCommandManagerVoiceKeyLauncher::DoCancel() |
|
120 { |
|
121 RUBY_DEBUG0( "START" ); |
|
122 |
|
123 |
|
124 if ( iKeyEnabled ) |
|
125 { |
|
126 iWsSession.EventReadyCancel(); |
|
127 iWindowGroup.CancelCaptureKey( iKeyCaptureHandle ); |
|
128 iWindowGroup.CancelCaptureKey( iLongKeyCaptureHandle ); |
|
129 } |
|
130 |
|
131 RUBY_DEBUG0( "EXIT" ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------- |
|
135 // CVCommandManagerVoiceKeyLauncher::RunL |
|
136 // --------------------------------------------------------- |
|
137 // |
|
138 void CVCommandManagerVoiceKeyLauncher::RunL() |
|
139 { |
|
140 RUBY_DEBUG_BLOCK( "" ); |
|
141 |
|
142 if ( iStatus.Int() == KErrNone ) |
|
143 { |
|
144 TWsEvent event; |
|
145 iWsSession.GetEvent( event ); |
|
146 |
|
147 iWsSession.EventReady( &iStatus ); |
|
148 SetActive(); |
|
149 |
|
150 if ( event.Key()->iCode == KLongVoiceKey ) |
|
151 { |
|
152 //iWsSession.SendEventToOneWindowGroupsPerClient( event ); |
|
153 |
|
154 LaunchVoiceUiL(); |
|
155 } |
|
156 } |
|
157 } |
|
158 |
|
159 |
|
160 // --------------------------------------------------------- |
|
161 // CVCommandManagerVoiceKeyLauncher::LaunchVoiceUiL |
|
162 // --------------------------------------------------------- |
|
163 // |
|
164 void CVCommandManagerVoiceKeyLauncher::LaunchVoiceUiL() |
|
165 { |
|
166 RUBY_DEBUG_BLOCK( "" ); |
|
167 |
|
168 TApaTaskList apaTaskList( CCoeEnv::Static()->WsSession() ); |
|
169 TApaTask apaTask = apaTaskList.FindApp( KVoiceUiUID ); |
|
170 |
|
171 if ( apaTask.Exists() ) |
|
172 { |
|
173 apaTask.BringToForeground(); |
|
174 } |
|
175 else |
|
176 { |
|
177 RApaLsSession apaLsSession; |
|
178 User::LeaveIfError( apaLsSession.Connect() ); |
|
179 CleanupClosePushL(apaLsSession); |
|
180 |
|
181 TApaAppInfo appInfo; |
|
182 User::LeaveIfError( apaLsSession.GetAppInfo( appInfo, KVoiceUiUID ) ); |
|
183 |
|
184 TFileName appName = appInfo.iFullName; |
|
185 CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC(); |
|
186 |
|
187 apaCommandLine->SetExecutableNameL( appName ); |
|
188 apaCommandLine->SetCommandL( EApaCommandRunWithoutViews ); |
|
189 User::LeaveIfError ( apaLsSession.StartApp( *apaCommandLine ) ); |
|
190 CleanupStack::PopAndDestroy( apaCommandLine ); |
|
191 |
|
192 CleanupStack::PopAndDestroy(&apaLsSession); |
|
193 } |
|
194 } |
|
195 |
|
196 // End of File |