1 /* |
|
2 * Copyright (c) 2004-2007 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: The Voice Recognition dialog implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32base.h> |
|
21 |
|
22 #include <voiceuidomainpskeys.h> |
|
23 |
|
24 #include "vuivoicerecognition.hrh" |
|
25 |
|
26 #include "vuicvoicerecogdialogimpl.h" |
|
27 |
|
28 #include "vuicpropertyhandler.h" |
|
29 |
|
30 #include "vuicdatastorage.h" |
|
31 #include "vuicuimodel.h" |
|
32 |
|
33 #include "vuicprecheckstate.h" |
|
34 |
|
35 #include "vuimvoicerecogdialogcallback.h" |
|
36 |
|
37 #include "rubydebug.h" |
|
38 |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CVoiceRecognitionDialogImpl::NewL |
|
45 // Two-phased constructor. |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CVoiceRecognitionDialogImpl* CVoiceRecognitionDialogImpl::NewL( MVoiceRecognitionDialogCallback* aObserver ) |
|
49 { |
|
50 RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialogImpl::NewL" ); |
|
51 |
|
52 CVoiceRecognitionDialogImpl* self = new (ELeave) CVoiceRecognitionDialogImpl( aObserver ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // Destructor |
|
60 CVoiceRecognitionDialogImpl::~CVoiceRecognitionDialogImpl() |
|
61 { |
|
62 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::~CVoiceRecognitionDialogImpl START" ); |
|
63 |
|
64 iObserver = NULL; |
|
65 |
|
66 iMutex.Close(); |
|
67 |
|
68 Cancel(); |
|
69 |
|
70 // If states are equal only one can be deleted |
|
71 if ( iState != iNextState ) |
|
72 { |
|
73 delete iState; |
|
74 delete iNextState; |
|
75 } |
|
76 else |
|
77 { |
|
78 delete iState; |
|
79 } |
|
80 |
|
81 delete iDataStorage; |
|
82 delete iUiModel; |
|
83 |
|
84 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::~CVoiceRecognitionDialogImpl EXIT" ); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------- |
|
88 // CVoiceRecognitionDialogImpl::ExecuteL |
|
89 // --------------------------------------------------------- |
|
90 // |
|
91 void CVoiceRecognitionDialogImpl::ExecuteL() |
|
92 { |
|
93 RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialogImpl::ExecuteL" ); |
|
94 |
|
95 ChangeState( CPrecheckState::NewL( *iDataStorage, *iUiModel ) ); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CVoiceRecognitionDialogImpl::SetDeviceLockMode |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 void CVoiceRecognitionDialogImpl::SetOnlyCallsAllowed() |
|
103 { |
|
104 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SetOnlyCallsAllowed START" ); |
|
105 |
|
106 iDataStorage->SetDeviceLockMode( ETrue ); |
|
107 |
|
108 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SetOnlyCallsAllowed EXIT" ); |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CVoiceRecognitionDialogImpl::CVoiceRecognitionDialogImpl |
|
113 // C++ default constructor can NOT contain any code, that |
|
114 // might leave. |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 CVoiceRecognitionDialogImpl::CVoiceRecognitionDialogImpl( MVoiceRecognitionDialogCallback* aObserver ) |
|
118 : CActive( EPriorityStandard ), iObserver( aObserver ) |
|
119 { |
|
120 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::CVoiceRecognitionDialogImpl START" ); |
|
121 |
|
122 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::CVoiceRecognitionDialogImpl EXIT" ); |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CVoiceRecognitionDialogImpl::ConstructL |
|
127 // Symbian 2nd phase constructor can leave. |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CVoiceRecognitionDialogImpl::ConstructL() |
|
131 { |
|
132 RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialogImpl::ConstructL" ); |
|
133 |
|
134 CActiveScheduler::Add( this ); |
|
135 |
|
136 iDataStorage = CDataStorage::NewL( this ); |
|
137 |
|
138 iUiModel = CUiModel::NewL(); |
|
139 |
|
140 iMutex.CreateLocal(); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------- |
|
144 // CVoiceRecognitionDialogImpl::RunL |
|
145 // Handle a change event. |
|
146 // --------------------------------------------------------- |
|
147 // |
|
148 void CVoiceRecognitionDialogImpl::RunL() |
|
149 { |
|
150 RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialogImpl::RunL" ); |
|
151 |
|
152 if ( iState != iNextState ) |
|
153 { |
|
154 delete iState; |
|
155 iState = iNextState; |
|
156 } |
|
157 iNextState = NULL; |
|
158 |
|
159 if ( iMutex.IsHeld() ) |
|
160 { |
|
161 iMutex.Signal(); |
|
162 } |
|
163 |
|
164 TRAPD( error, iState->ExecuteL() ); |
|
165 |
|
166 if ( error != KErrNone ) |
|
167 { |
|
168 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::RunL - State execution failed with error [%d]", error ); |
|
169 Exit(); |
|
170 } |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------- |
|
174 // CVoiceRecognitionDialogImpl::DoCancel |
|
175 // Cancel the request to receive events. |
|
176 // --------------------------------------------------------- |
|
177 // |
|
178 void CVoiceRecognitionDialogImpl::DoCancel() |
|
179 { |
|
180 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::DoCancel START" ); |
|
181 |
|
182 |
|
183 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::DoCancel EXIT" ); |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------- |
|
187 // CVoiceRecognitionDialogImpl::HandleKeypressL |
|
188 // Called when a key is pressed |
|
189 // --------------------------------------------------------- |
|
190 // |
|
191 void CVoiceRecognitionDialogImpl::HandleKeypressL( TInt aSoftkey ) |
|
192 { |
|
193 RUBY_DEBUG_BLOCK( "CVoiceRecognitionDialogImpl::HandleKeypressL" ); |
|
194 |
|
195 CheckState(); |
|
196 |
|
197 TRAPD( error, iState->HandleEventL( aSoftkey ) ); |
|
198 |
|
199 if ( error != KErrNone ) |
|
200 { |
|
201 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleKeypressL - Event handling failed with error [%d]", error ); |
|
202 Exit(); |
|
203 } |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------- |
|
207 // CVoiceRecognitionDialogImpl::HandleRecognizeInitComplete |
|
208 // Called when HandleRecognizeInit() completes |
|
209 // --------------------------------------------------------- |
|
210 // |
|
211 void CVoiceRecognitionDialogImpl::HandleRecognizeInitComplete( TNssRecognizeInitError aErrorCode ) |
|
212 { |
|
213 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecognizeInitComplete START" ); |
|
214 |
|
215 CheckState(); |
|
216 |
|
217 TInt errorCode = KErrNone; |
|
218 |
|
219 if ( aErrorCode == MNssRecognizeInitCompleteHandler::EVasRecognizeInitFailed ) |
|
220 { |
|
221 errorCode = KErrInit; |
|
222 } |
|
223 else if ( aErrorCode == MNssRecognizeInitCompleteHandler::EVasNoTagInContexts ) |
|
224 { |
|
225 errorCode = KErrNoContacts; |
|
226 } |
|
227 else if ( aErrorCode != MNssRecognizeInitCompleteHandler::EVasErrorNone ) |
|
228 { |
|
229 errorCode = KErrGeneral; |
|
230 } |
|
231 |
|
232 TRAPD( error, iState->HandleEventL( errorCode ) ); |
|
233 |
|
234 if ( error != KErrNone ) |
|
235 { |
|
236 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleRecognizeInitComplete - Event handling failed with error [%d]", error ); |
|
237 Exit(); |
|
238 } |
|
239 |
|
240 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecognizeInitComplete EXIT" ); |
|
241 } |
|
242 |
|
243 #ifndef __WINS__ |
|
244 #ifdef __FULLDUPLEX_CHANGE |
|
245 // --------------------------------------------------------- |
|
246 // CVoiceRecognitionDialogImpl::HandlePreSamplingStarted |
|
247 // Called when HandlePreSamplingStarted() completes |
|
248 // --------------------------------------------------------- |
|
249 // |
|
250 void CVoiceRecognitionDialogImpl::HandlePreSamplingStarted( TInt aErrorCode ) |
|
251 { |
|
252 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandlePreSamplingStarted START" ); |
|
253 |
|
254 CheckState(); |
|
255 |
|
256 TRAPD( error, iState->HandleEventL( aErrorCode ) ); |
|
257 |
|
258 if ( error != KErrNone ) |
|
259 { |
|
260 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandlePreSamplingStarted - Event handling failed with error [%d]", error ); |
|
261 Exit(); |
|
262 } |
|
263 |
|
264 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandlePreSamplingStarted EXIT" ); |
|
265 } |
|
266 #endif // __FULLDUPLEX_CHANGE |
|
267 #endif // __WINS__ |
|
268 |
|
269 // --------------------------------------------------------- |
|
270 // CVoiceRecognitionDialogImpl::HandleRecordStarted |
|
271 // Called when recording has started |
|
272 // --------------------------------------------------------- |
|
273 // |
|
274 void CVoiceRecognitionDialogImpl::HandleRecordStarted() |
|
275 { |
|
276 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecordStarted START" ); |
|
277 |
|
278 CheckState(); |
|
279 |
|
280 TRAPD( error, iState->HandleEventL( KErrNone ) ); |
|
281 |
|
282 if ( error != KErrNone ) |
|
283 { |
|
284 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleRecordStarted - Event handling failed with error [%d]", error ); |
|
285 Exit(); |
|
286 } |
|
287 |
|
288 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecordStarted EXIT" ); |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------- |
|
292 // CVoiceRecognitionDialogImpl::HandleEouDetected |
|
293 // Called when end-of-utterance is detected |
|
294 // --------------------------------------------------------- |
|
295 // |
|
296 void CVoiceRecognitionDialogImpl::HandleEouDetected() |
|
297 { |
|
298 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleEouDetected START" ); |
|
299 |
|
300 CheckState(); |
|
301 |
|
302 TRAPD( error, iState->HandleEventL( KErrNone ) ); |
|
303 |
|
304 if ( error != KErrNone ) |
|
305 { |
|
306 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleEouDetected - Event handling failed with error [%d]", error ); |
|
307 Exit(); |
|
308 } |
|
309 |
|
310 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleEouDetected EXIT" ); |
|
311 } |
|
312 |
|
313 // --------------------------------------------------------- |
|
314 // CVoiceRecognitionDialogImpl::HandleRecognizeComplete |
|
315 // Called when recognition ends |
|
316 // --------------------------------------------------------- |
|
317 // |
|
318 void CVoiceRecognitionDialogImpl::HandleRecognizeComplete( CArrayPtrFlat<MNssTag>* aTagList, |
|
319 TNssRecognizeError aErrorCode ) |
|
320 { |
|
321 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecognizeComplete START" ); |
|
322 |
|
323 CheckState(); |
|
324 |
|
325 TInt errorCode = KErrNone; |
|
326 |
|
327 if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognitionFailedNoMatch ) |
|
328 { |
|
329 errorCode = KErrNoMatch; |
|
330 } |
|
331 else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognizeAccessDeny ) |
|
332 { |
|
333 errorCode = KErrAbort; |
|
334 } |
|
335 else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognizeFailed ) |
|
336 { |
|
337 errorCode = KErrRecogFailed; |
|
338 } |
|
339 else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognitionFailedNoSpeech ) |
|
340 { |
|
341 errorCode = KErrNoSpeech; |
|
342 } |
|
343 else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognitionFailedTooEarly ) |
|
344 { |
|
345 errorCode = KErrTooEarly; |
|
346 } |
|
347 else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognitionFailedTooLong ) |
|
348 { |
|
349 errorCode = KErrTooLong; |
|
350 } |
|
351 else if ( aErrorCode == MNssRecognizeEventHandler::EVasRecognitionFailedTooShort ) |
|
352 { |
|
353 errorCode = KErrTooShort; |
|
354 } |
|
355 else if ( aErrorCode != MNssRecognizeEventHandler::EVasErrorNone ) |
|
356 { |
|
357 errorCode = KErrGeneral; |
|
358 } |
|
359 |
|
360 // If complete tag list has been set then results are voice verification results |
|
361 // and should be put to additional tag list |
|
362 if ( !iDataStorage->CompleteTagList() ) |
|
363 { |
|
364 iDataStorage->SetCompleteTagList( aTagList ); |
|
365 } |
|
366 else |
|
367 { |
|
368 iDataStorage->SetAdditionalTagList( aTagList ); |
|
369 } |
|
370 |
|
371 TRAPD( error, iState->HandleEventL( errorCode ) ); |
|
372 |
|
373 if ( error != KErrNone ) |
|
374 { |
|
375 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleRecognizeComplete - Event handling failed with error [%d]", error ); |
|
376 Exit(); |
|
377 } |
|
378 |
|
379 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleRecognizeComplete EXIT" ); |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------- |
|
383 // CVoiceRecognitionDialogImpl::HandleAdaptComplete |
|
384 // Called when the adaptation is complete |
|
385 // --------------------------------------------------------- |
|
386 // |
|
387 void CVoiceRecognitionDialogImpl::HandleAdaptComplete( TInt aErrorCode ) |
|
388 { |
|
389 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleAdaptComplete START" ); |
|
390 |
|
391 CheckState(); |
|
392 |
|
393 TRAPD( error, iState->HandleEventL( aErrorCode ) ); |
|
394 |
|
395 if ( error != KErrNone ) |
|
396 { |
|
397 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleAdaptComplete - Event handling failed with error [%d]", error ); |
|
398 Exit(); |
|
399 } |
|
400 |
|
401 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleAdaptComplete EXIT" ); |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // CVoiceRecognitionDialogImpl::MapcInitComplete |
|
406 // CMdaAudioPlayerUtility initialization complete |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 void CVoiceRecognitionDialogImpl::MapcInitComplete( TInt aError, |
|
410 const TTimeIntervalMicroSeconds& aDuration ) |
|
411 { |
|
412 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcInitComplete START" ); |
|
413 |
|
414 CheckState(); |
|
415 |
|
416 iDataStorage->SetPlayDuration( aDuration ); |
|
417 |
|
418 TRAPD( error, iState->HandleEventL( aError ) ); |
|
419 |
|
420 if ( error != KErrNone ) |
|
421 { |
|
422 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::MapcInitComplete - Event handling failed with error [%d]", error ); |
|
423 Exit(); |
|
424 } |
|
425 |
|
426 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcInitComplete EXIT" ); |
|
427 } |
|
428 |
|
429 // --------------------------------------------------------------------------- |
|
430 // CVoiceRecogPlaybackDialog::MapcPlayComplete |
|
431 // Playback complete, notify observer |
|
432 // --------------------------------------------------------------------------- |
|
433 // |
|
434 void CVoiceRecognitionDialogImpl::MapcPlayComplete( TInt aError ) |
|
435 { |
|
436 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcPlayComplete START" ); |
|
437 |
|
438 CheckState(); |
|
439 |
|
440 TRAPD( error, iState->HandleEventL( aError ) ); |
|
441 |
|
442 if ( error != KErrNone ) |
|
443 { |
|
444 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::MapcPlayComplete - Event handling failed with error [%d]", error ); |
|
445 Exit(); |
|
446 } |
|
447 |
|
448 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcPlayComplete EXIT" ); |
|
449 } |
|
450 |
|
451 // --------------------------------------------------------------------------- |
|
452 // CVoiceRecognitionDialogImpl::MapcCustomCommandEvent |
|
453 // Called when asynchronous custom command finishes. |
|
454 // --------------------------------------------------------------------------- |
|
455 // |
|
456 void CVoiceRecognitionDialogImpl::MapcCustomCommandEvent( TInt /*aEvent*/, TInt aError ) |
|
457 { |
|
458 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcCustomCommandEvent START" ); |
|
459 |
|
460 CheckState(); |
|
461 |
|
462 TRAPD( error, iState->HandleEventL( aError ) ); |
|
463 |
|
464 if ( error != KErrNone ) |
|
465 { |
|
466 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::MapcCustomCommandEvent - Event handling failed with error [%d]", error ); |
|
467 Exit(); |
|
468 } |
|
469 |
|
470 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::MapcCustomCommandEvent EXIT" ); |
|
471 } |
|
472 |
|
473 // ----------------------------------------------------------------------------- |
|
474 // CVoiceRecognitionDialogImpl::GetContextCompleted |
|
475 // ----------------------------------------------------------------------------- |
|
476 // |
|
477 void CVoiceRecognitionDialogImpl::GetContextCompleted( MNssContext* aContext, TInt aErrorCode ) |
|
478 { |
|
479 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetContextCompleted START" ); |
|
480 |
|
481 CheckState(); |
|
482 |
|
483 iDataStorage->SetContext( aContext ); |
|
484 |
|
485 TRAPD( error, iState->HandleEventL( aErrorCode ) ); |
|
486 |
|
487 if ( error != KErrNone ) |
|
488 { |
|
489 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::GetContextCompleted - Event handling failed with error [%d]", error ); |
|
490 Exit(); |
|
491 } |
|
492 |
|
493 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetContextCompleted EXIT" ); |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // CVoiceRecognitionDialogImpl::GetContextListCompleted |
|
498 // ----------------------------------------------------------------------------- |
|
499 // |
|
500 void CVoiceRecognitionDialogImpl::GetContextListCompleted( MNssContextListArray* /*aContextList*/, |
|
501 TInt aErrorCode ) |
|
502 { |
|
503 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetContextListCompleted START" ); |
|
504 |
|
505 CheckState(); |
|
506 |
|
507 TRAPD( error, iState->HandleEventL( aErrorCode ) ); |
|
508 |
|
509 if ( error != KErrNone ) |
|
510 { |
|
511 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::GetContextListCompleted - Event handling failed with error [%d]", error ); |
|
512 Exit(); |
|
513 } |
|
514 |
|
515 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetContextListCompleted EXIT" ); |
|
516 } |
|
517 |
|
518 // ----------------------------------------------------------------------------- |
|
519 // CVoiceRecognitionDialogImpl::GetTagListCompleted |
|
520 // ----------------------------------------------------------------------------- |
|
521 // |
|
522 void CVoiceRecognitionDialogImpl::GetTagListCompleted( MNssTagListArray* aTagList, TInt aErrorCode ) |
|
523 { |
|
524 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetTagListCompleted START" ); |
|
525 |
|
526 CheckState(); |
|
527 |
|
528 iDataStorage->SetAdditionalTagList( aTagList ); |
|
529 |
|
530 TRAPD( error, iState->HandleEventL( aErrorCode ) ); |
|
531 |
|
532 if ( error != KErrNone ) |
|
533 { |
|
534 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::GetTagListCompleted - Event handling failed with error [%d]", error ); |
|
535 Exit(); |
|
536 } |
|
537 |
|
538 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::GetTagListCompleted EXIT" ); |
|
539 } |
|
540 |
|
541 // ----------------------------------------------------------------------------- |
|
542 // CVoiceRecognitionDialogImpl::SaveContextCompleted |
|
543 // ----------------------------------------------------------------------------- |
|
544 // |
|
545 void CVoiceRecognitionDialogImpl::SaveContextCompleted( TInt aErrorCode ) |
|
546 { |
|
547 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SaveContextCompleted START" ); |
|
548 |
|
549 CheckState(); |
|
550 |
|
551 TRAPD( error, iState->HandleEventL( aErrorCode ) ); |
|
552 |
|
553 if ( error != KErrNone ) |
|
554 { |
|
555 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::SaveContextCompleted - Event handling failed with error [%d]", error ); |
|
556 Exit(); |
|
557 } |
|
558 |
|
559 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SaveContextCompleted EXIT" ); |
|
560 } |
|
561 |
|
562 // ----------------------------------------------------------------------------- |
|
563 // CVoiceRecognitionDialogImpl::HandleTrainComplete |
|
564 // ----------------------------------------------------------------------------- |
|
565 // |
|
566 void CVoiceRecognitionDialogImpl::HandleTrainComplete( TInt aErrorCode ) |
|
567 { |
|
568 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleTrainComplete START" ); |
|
569 |
|
570 CheckState(); |
|
571 |
|
572 TRAPD( error, iState->HandleEventL( aErrorCode ) ); |
|
573 |
|
574 if ( error != KErrNone ) |
|
575 { |
|
576 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::HandleTrainComplete - Event handling failed with error [%d]", error ); |
|
577 Exit(); |
|
578 } |
|
579 |
|
580 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandleTrainComplete EXIT" ); |
|
581 } |
|
582 |
|
583 // ----------------------------------------------------------------------------- |
|
584 // CVoiceRecognitionDialogImpl::SaveTagCompleted |
|
585 // ----------------------------------------------------------------------------- |
|
586 // |
|
587 void CVoiceRecognitionDialogImpl::SaveTagCompleted( TInt aErrorCode ) |
|
588 { |
|
589 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SaveTagCompleted START" ); |
|
590 |
|
591 CheckState(); |
|
592 |
|
593 TRAPD( error, iState->HandleEventL( aErrorCode ) ); |
|
594 |
|
595 if ( error != KErrNone ) |
|
596 { |
|
597 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::SaveTagCompleted - Event handling failed with error [%d]", error ); |
|
598 Exit(); |
|
599 } |
|
600 |
|
601 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::SaveTagCompleted EXIT" ); |
|
602 } |
|
603 |
|
604 // ----------------------------------------------------------------------------- |
|
605 // CVoiceRecognitionDialogImpl::DeleteContextCompleted |
|
606 // ----------------------------------------------------------------------------- |
|
607 // |
|
608 void CVoiceRecognitionDialogImpl::DeleteContextCompleted( TInt aErrorCode ) |
|
609 { |
|
610 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::DeleteContextCompleted START" ); |
|
611 |
|
612 CheckState(); |
|
613 |
|
614 TRAPD( error, iState->HandleEventL( aErrorCode ) ); |
|
615 |
|
616 if ( error != KErrNone ) |
|
617 { |
|
618 RUBY_DEBUG1( "CVoiceRecognitionDialogImpl::DeleteContextCompleted - Event handling failed with error [%d]", error ); |
|
619 Exit(); |
|
620 } |
|
621 |
|
622 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::DeleteContextCompleted EXIT" ); |
|
623 } |
|
624 |
|
625 // ---------------------------------------------------- |
|
626 // CVoiceRecognitionDialog::HandlePropertyValueChange |
|
627 // Handle property value change event. |
|
628 // ---------------------------------------------------- |
|
629 // |
|
630 void CVoiceRecognitionDialogImpl::HandlePropertyValueChange( TInt aValue ) |
|
631 { |
|
632 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandlePropertyValueChange START" ); |
|
633 |
|
634 CheckState(); |
|
635 |
|
636 switch( aValue ) |
|
637 { |
|
638 // Short press of a headset key |
|
639 case KVoiceUiShortPressEvent: |
|
640 { |
|
641 TRAP_IGNORE( iState->HandleEventL( EShortKeypress ) ); |
|
642 break; |
|
643 } |
|
644 |
|
645 // Long press of a headset key |
|
646 case KVoiceUiLongPressEvent: |
|
647 { |
|
648 TRAP_IGNORE( iState->HandleEventL( ELongKeypress ) ); |
|
649 break; |
|
650 } |
|
651 |
|
652 default: |
|
653 { |
|
654 // pass |
|
655 break; |
|
656 } |
|
657 } |
|
658 |
|
659 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::HandlePropertyValueChange EXIT" ); |
|
660 } |
|
661 |
|
662 // --------------------------------------------------------- |
|
663 // CVoiceRecognitionDialogImpl::ChangeState |
|
664 // Change current state and set object active |
|
665 // --------------------------------------------------------- |
|
666 // |
|
667 void CVoiceRecognitionDialogImpl::ChangeState( CState* aNextState ) |
|
668 { |
|
669 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::ChangeState START" ); |
|
670 |
|
671 if ( aNextState ) |
|
672 { |
|
673 CheckState(); |
|
674 |
|
675 iNextState = aNextState; |
|
676 |
|
677 if ( !IsActive() ) |
|
678 { |
|
679 TRequestStatus* pRS = &iStatus; |
|
680 User::RequestComplete( pRS, KErrNone ); |
|
681 SetActive(); |
|
682 } |
|
683 } |
|
684 |
|
685 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::ChangeState EXIT" ); |
|
686 } |
|
687 |
|
688 // --------------------------------------------------------- |
|
689 // CVoiceRecognitionDialogImpl::CheckState |
|
690 // Check if state can be changed and if it can't starts waiting |
|
691 // --------------------------------------------------------- |
|
692 // |
|
693 void CVoiceRecognitionDialogImpl::CheckState() |
|
694 { |
|
695 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::CheckState START" ); |
|
696 |
|
697 if ( iNextState ) |
|
698 { |
|
699 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::CheckState - Start waiting" ); |
|
700 iMutex.Wait(); |
|
701 } |
|
702 |
|
703 RUBY_DEBUG0( "CVoiceRecognitionDialogImpl::CheckState EXIT" ); |
|
704 } |
|
705 |
|
706 // --------------------------------------------------------- |
|
707 // CVoiceRecognitionDialogImpl::Exit |
|
708 // |
|
709 // --------------------------------------------------------- |
|
710 // |
|
711 void CVoiceRecognitionDialogImpl::Exit() |
|
712 { |
|
713 if ( iObserver ) |
|
714 { |
|
715 iObserver->DialogDismissed(); |
|
716 |
|
717 iObserver = NULL; |
|
718 } |
|
719 } |
|
720 |
|
721 // End of File |
|