1 /* |
|
2 * Copyright (c) 2004-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <featmgr.h> |
|
21 |
|
22 #include <AknMediatorFacade.h> |
|
23 |
|
24 #include <SecondaryDisplay/AknSecondaryDisplayDefs.h> |
|
25 |
|
26 #include <vuivoicerecognition.rsg> |
|
27 #include <vuivoicerecogdefs.h> |
|
28 |
|
29 #include "vuivoicerecognition.hrh" |
|
30 |
|
31 #include "vuiclistquerydialog.h" |
|
32 #include "vuicverificationdialog.h" |
|
33 |
|
34 #include "vuimkeycallback.h" |
|
35 |
|
36 #include "rubydebug.h" |
|
37 |
|
38 // CONSTANTS |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CVerificationDialog::CVerificationDialog |
|
44 // C++ default constructor can NOT contain any code, that |
|
45 // might leave. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CVerificationDialog::CVerificationDialog() |
|
49 : iCurrentIndex( 0 ) |
|
50 { |
|
51 } |
|
52 |
|
53 |
|
54 // Destructor |
|
55 CVerificationDialog::~CVerificationDialog() |
|
56 { |
|
57 RUBY_DEBUG0( "CVerificationDialog::~CVerificationDialog START" ); |
|
58 |
|
59 RegisterForKeyCallback( NULL ); |
|
60 |
|
61 delete iDialog; |
|
62 iDialog = NULL; |
|
63 |
|
64 iEikonEnv->EikAppUi()->RemoveFromStack( this ); |
|
65 |
|
66 RUBY_DEBUG0( "CVerificationDialog::~CVerificationDialog EXIT" ); |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CVerificationDialog::ConstructL |
|
72 // Symbian 2nd phase constructor can leave. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CVerificationDialog::ConstructL() |
|
76 { |
|
77 RUBY_DEBUG_BLOCK( "CVerificationDialog::ConstructL" ); |
|
78 |
|
79 iEikonEnv->EikAppUi()->AddToStackL( this, ECoeStackPriorityAlert ); |
|
80 } |
|
81 |
|
82 |
|
83 // --------------------------------------------------------- |
|
84 // CVerificationDialog::NewL |
|
85 // Two-phased constructor. |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 CVerificationDialog* CVerificationDialog::NewL() |
|
89 { |
|
90 CVerificationDialog* self = new (ELeave) CVerificationDialog(); |
|
91 CleanupStack::PushL(self); |
|
92 self->ConstructL(); |
|
93 CleanupStack::Pop( self ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CVerificationDialog::RegisterForKeyCallback |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CVerificationDialog::RegisterForKeyCallback( MKeyCallback* aKeyCallback ) |
|
102 { |
|
103 iKeyCallback = aKeyCallback; |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------- |
|
107 // TKeyResponse CVerificationDialog::OfferKeyEventL |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 TKeyResponse CVerificationDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode /*aType*/ ) |
|
111 { |
|
112 RUBY_DEBUG_BLOCK( "CVerificationDialog::OfferKeyEventL" ); |
|
113 |
|
114 TKeyResponse keyStatus = EKeyWasNotConsumed; |
|
115 |
|
116 TInt event = ConvertKeyEventL( aKeyEvent ); |
|
117 |
|
118 if ( event != ENoKeypress ) |
|
119 { |
|
120 switch( event ) |
|
121 { |
|
122 case ESelectKeypress: |
|
123 { |
|
124 keyStatus = EKeyWasConsumed; |
|
125 break; |
|
126 } |
|
127 |
|
128 case EUpKeypress: |
|
129 { |
|
130 --iCurrentIndex; |
|
131 if ( iCurrentIndex <= -1 ) |
|
132 { |
|
133 iCurrentIndex = KVerificationCommands - 1; |
|
134 } |
|
135 break; |
|
136 } |
|
137 |
|
138 case EDownKeypress: |
|
139 { |
|
140 ++iCurrentIndex; |
|
141 if ( iCurrentIndex >= KVerificationCommands ) |
|
142 { |
|
143 iCurrentIndex = 0; |
|
144 } |
|
145 break; |
|
146 } |
|
147 |
|
148 case EVoiceTagSoftKeyCancel: |
|
149 { |
|
150 iEikonEnv->EikAppUi()->RemoveFromStack( this ); |
|
151 break; |
|
152 } |
|
153 |
|
154 default: |
|
155 break; |
|
156 } |
|
157 |
|
158 if ( iKeyCallback ) |
|
159 { |
|
160 iKeyCallback->HandleKeypressL( event ); |
|
161 } |
|
162 } |
|
163 |
|
164 return keyStatus; |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CVerificationDialog::MediatorCommandL |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 TAknDialogMediatorObserverCommand CVerificationDialog::MediatorCommandL( TUid /*aDomain*/, |
|
172 TUid aCategory, |
|
173 TInt aCommandId, |
|
174 const TDesC8& aData ) |
|
175 { |
|
176 RUBY_DEBUG_BLOCK( "CVerificationDialog::MediatorCommandL" ); |
|
177 |
|
178 TAknDialogMediatorObserverCommand retValue = EHandleAsNormal; |
|
179 |
|
180 if ( aCategory == SecondaryDisplay::KCatVoiceUi && |
|
181 aCommandId == SecondaryDisplay::ECmdShowVoiceVerificationQuery ) |
|
182 { |
|
183 if ( aData.Length() == sizeof( SAknDialogFeedback ) ) |
|
184 { |
|
185 const SAknDialogFeedback& params = |
|
186 reinterpret_cast<const SAknDialogFeedback&>( *( aData.Ptr() ) ); |
|
187 |
|
188 if ( params.iKey.iCode == EKeyCBA1 ) |
|
189 { |
|
190 // LSK should select current selection |
|
191 iKeyCallback->HandleKeypressL( ESelectKeypress ); |
|
192 |
|
193 retValue = EDoNothingWithThisCommand; |
|
194 } |
|
195 } |
|
196 else |
|
197 { |
|
198 SAknIntegerUpdate* params = (SAknIntegerUpdate*) &aData; |
|
199 |
|
200 if ( params->iCmd == EAknListQueryUpdateSelection ) |
|
201 { |
|
202 iCurrentIndex = params->iId; |
|
203 iDialog->ListControl()->Listbox()->SetCurrentItemIndexAndDraw( iCurrentIndex ); |
|
204 |
|
205 // Just send EUpKeypress or EDownKeypress event to notify that selection |
|
206 // has changed |
|
207 iKeyCallback->HandleKeypressL( EDownKeypress ); |
|
208 } |
|
209 } |
|
210 } |
|
211 return retValue; |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // CVerificationDialog::NotifyMediatorExit |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 void CVerificationDialog::NotifyMediatorExit() |
|
219 { |
|
220 RUBY_DEBUG0( "CVerificationDialog::NotifyMediatorExit" ); |
|
221 // Do nothing |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CVerificationDialog::CreateVerificationPopupLC |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 void CVerificationDialog::CreateVerificationPopupLC( const TDesC& aHeader ) |
|
229 { |
|
230 RUBY_DEBUG0( "CVerificationDialog::CreateVerificationPopupLC START" ); |
|
231 |
|
232 iDialog = CListQueryDialog::NewL( &iCurrentIndex, &iDialog ); |
|
233 iDialog->PrepareLC( R_VERIFICATION_QUERY ); |
|
234 |
|
235 iDialog->QueryHeading()->SetTextL( aHeader ); |
|
236 |
|
237 SecondaryDisplay::TVerificationData data; |
|
238 data.iName.Append( aHeader ); |
|
239 |
|
240 SetSecondaryDisplayDataL( data ); |
|
241 |
|
242 RUBY_DEBUG0( "CVerificationDialog::CreateVerificationPopupLC EXIT" ); |
|
243 } |
|
244 |
|
245 // ----------------------------------------------------------------------------- |
|
246 // CVerificationDialog::ShowVerificationPopupL |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 TInt CVerificationDialog::ShowVerificationPopupL() |
|
250 { |
|
251 RUBY_DEBUG0( "CVerificationDialog::ShowVerificationPopupL START" ); |
|
252 |
|
253 // Show verification dialog |
|
254 TInt returnValue = iDialog->RunLD(); |
|
255 |
|
256 // Touch selection returns EAknSoftkeyOk |
|
257 if ( returnValue == EAknSoftkeyOk ) |
|
258 { |
|
259 returnValue = EVoiceTagSoftKeySelect; |
|
260 } |
|
261 |
|
262 RUBY_DEBUG0( "CVerificationDialog::ShowVerificationPopupL EXIT" ); |
|
263 |
|
264 return returnValue; |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CVerificationDialog::ConvertKeyEventL |
|
269 // ----------------------------------------------------------------------------- |
|
270 // |
|
271 TInt CVerificationDialog::ConvertKeyEventL( const TKeyEvent& aKeyEvent ) |
|
272 { |
|
273 TInt event = ENoKeypress; |
|
274 |
|
275 switch( aKeyEvent.iCode ) |
|
276 { |
|
277 case EKeyNo: |
|
278 case EKeyEscape: |
|
279 { |
|
280 event = EVoiceTagSoftKeyCancel; |
|
281 break; |
|
282 } |
|
283 |
|
284 case EKeyDevice3: |
|
285 case EKeyYes: |
|
286 { |
|
287 event = ESelectKeypress; |
|
288 break; |
|
289 } |
|
290 |
|
291 case EKeyUpArrow: |
|
292 { |
|
293 event = EUpKeypress; |
|
294 break; |
|
295 } |
|
296 |
|
297 case EKeyDownArrow: |
|
298 { |
|
299 event = EDownKeypress; |
|
300 break; |
|
301 } |
|
302 |
|
303 default: |
|
304 { |
|
305 event = ENoKeypress; |
|
306 break; |
|
307 } |
|
308 } |
|
309 return event; |
|
310 } |
|
311 |
|
312 // --------------------------------------------------------------------------- |
|
313 // CVerificationDialog::SelectedCommand |
|
314 // --------------------------------------------------------------------------- |
|
315 // |
|
316 TInt CVerificationDialog::SelectedCommand( TInt aId ) |
|
317 { |
|
318 RUBY_DEBUG0( "CVerificationDialog::SelectedCommand START" ); |
|
319 |
|
320 TInt command; |
|
321 TInt index = iCurrentIndex; |
|
322 |
|
323 if ( aId != KErrGeneral ) |
|
324 { |
|
325 index = aId; |
|
326 } |
|
327 |
|
328 switch( index ) |
|
329 { |
|
330 case 0: |
|
331 command = EVoiceTagSoftKeySelect; |
|
332 break; |
|
333 |
|
334 case 1: |
|
335 command = EVoiceTagSoftKeyOther; |
|
336 break; |
|
337 |
|
338 case 2: |
|
339 command = EVoiceTagSoftKeyCancel; |
|
340 break; |
|
341 |
|
342 default: |
|
343 command = KErrGeneral; |
|
344 break; |
|
345 } |
|
346 |
|
347 RUBY_DEBUG0( "CVerificationDialog::SelectedCommand EXIT" ); |
|
348 |
|
349 return command; |
|
350 } |
|
351 |
|
352 // --------------------------------------------------------- |
|
353 // CVerificationDialog::SetSecondaryDisplayDataL |
|
354 // Sets additional information to be sent to secondary display |
|
355 // --------------------------------------------------------- |
|
356 // |
|
357 void CVerificationDialog::SetSecondaryDisplayDataL( SecondaryDisplay::TVerificationData& aData ) |
|
358 { |
|
359 RUBY_DEBUG_BLOCK( "CVerificationDialog::SetSecondaryDisplayDataL" ); |
|
360 |
|
361 if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) |
|
362 { |
|
363 // Create dummy id list (needed for list query automation) |
|
364 CArrayFixFlat<TInt>* array = new ( ELeave ) CArrayFixFlat<TInt>( 1 ); |
|
365 CleanupStack::PushL( array ); |
|
366 for( TInt i = 0; i < 3; ++i ) |
|
367 { |
|
368 array->AppendL( i ); |
|
369 } |
|
370 |
|
371 iDialog->PublishDialogL( SecondaryDisplay::ECmdShowVoiceVerificationQuery, |
|
372 SecondaryDisplay::KCatVoiceUi, |
|
373 array ); |
|
374 |
|
375 iDialog->SetMediatorObserver( this ); |
|
376 |
|
377 CleanupStack::Pop( array ); // Dialog takes ownership of array |
|
378 |
|
379 // fetch akn utility for mediator support, \oem\aknmediatorfacade.h |
|
380 CAknMediatorFacade* covercl = AknMediatorFacade( iDialog ); |
|
381 |
|
382 if ( covercl ) |
|
383 { |
|
384 covercl->BufStream() << aData.iName; |
|
385 covercl->BufStream().CommitL(); // no more data to send so commit buf |
|
386 } |
|
387 } |
|
388 } |
|
389 |
|
390 // End of File |
|