|
1 /* |
|
2 * Copyright (c) 2006-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <centralrepository.h> |
|
21 #include <vcommanddomaincrkeys.h> |
|
22 #include <voiceuidomainpskeys.h> |
|
23 |
|
24 #include <vascvpbkhandler.h> |
|
25 |
|
26 #include "vuicdatastorage.h" |
|
27 |
|
28 #include "vuicvoicerecogdialogimpl.h" |
|
29 #include "vuictoneplayer.h" |
|
30 #include "vuicpropertyhandler.h" |
|
31 #include "vuictutorial.h" |
|
32 #include "vuicttsplayer.h" |
|
33 |
|
34 #include "rubydebug.h" |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CDataStorage::NewL |
|
38 // Two-phased constructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CDataStorage* CDataStorage::NewL( CVoiceRecognitionDialogImpl* aVoiceRecognitionImpl ) |
|
42 { |
|
43 RUBY_DEBUG_BLOCK( "CDataStorage::NewL" ); |
|
44 |
|
45 CDataStorage* self = new (ELeave) CDataStorage( aVoiceRecognitionImpl ); |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(); |
|
48 CleanupStack::Pop( self ); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // Destructor |
|
53 CDataStorage::~CDataStorage() |
|
54 { |
|
55 RUBY_DEBUG0( "CDataStorage::~CDataStorage START" ); |
|
56 |
|
57 if ( iTonePlayer ) |
|
58 { |
|
59 iTonePlayer->RegisterObserver( NULL ); |
|
60 } |
|
61 delete iTonePlayer; |
|
62 |
|
63 delete iPbkHandler; |
|
64 |
|
65 delete iTtsPlayer; |
|
66 |
|
67 delete iRecognitionHandlerBuilder; // Deletes also iRecognitionHandler |
|
68 delete iVerificationRecognitionHandlerBuilder; // Deletes also iVerificationRecognitionHandler |
|
69 delete iAccessoryButtonMonitor; |
|
70 delete iTutorial; |
|
71 |
|
72 // Contains original tags |
|
73 if ( iAdditionalTagList ) |
|
74 { |
|
75 iAdditionalTagList->ResetAndDestroy(); |
|
76 } |
|
77 delete iAdditionalTagList; |
|
78 |
|
79 // Contains original tags |
|
80 if ( iCompleteTagList ) |
|
81 { |
|
82 iCompleteTagList->ResetAndDestroy(); |
|
83 } |
|
84 delete iCompleteTagList; |
|
85 |
|
86 delete iTag; |
|
87 delete iContext; |
|
88 |
|
89 RUBY_DEBUG0( "CDataStorage::~CDataStorage EXIT" ); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CDataStorage::SetRecognitionHandlerBuilder |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CDataStorage::SetRecognitionHandlerBuilder( CNssRecognitionHandlerBuilder* aRecognitionHandlerBuilder ) |
|
97 { |
|
98 RUBY_DEBUG0( "CDataStorage::SetRecognitionHandlerBuilder START" ); |
|
99 |
|
100 if ( iRecognitionHandlerBuilder && iRecognitionHandlerBuilder != aRecognitionHandlerBuilder ) |
|
101 { |
|
102 delete iRecognitionHandlerBuilder; // Deletes also iRecognitionHandler |
|
103 iRecognitionHandler = NULL; |
|
104 } |
|
105 |
|
106 iRecognitionHandlerBuilder = aRecognitionHandlerBuilder; |
|
107 |
|
108 RUBY_DEBUG0( "CDataStorage::SetRecognitionHandlerBuilder EXIT" ); |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CDataStorage::SetRecognitionHandler |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CDataStorage::SetRecognitionHandler( MNssRecognitionHandler* aRecognitionHandler ) |
|
116 { |
|
117 RUBY_DEBUG0( "CDataStorage::SetRecognitionHandler START" ); |
|
118 |
|
119 iRecognitionHandler = aRecognitionHandler; |
|
120 |
|
121 RUBY_DEBUG0( "CDataStorage::SetRecognitionHandler EXIT" ); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CDataStorage::SetVerificationRecognitionHandlerBuilder |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CDataStorage::SetVerificationRecognitionHandlerBuilder( CNssRecognitionHandlerBuilder* aRecognitionHandlerBuilder ) |
|
129 { |
|
130 RUBY_DEBUG0( "CDataStorage::SetVerificationRecognitionHandlerBuilder START" ); |
|
131 |
|
132 if ( iVerificationRecognitionHandlerBuilder && iVerificationRecognitionHandlerBuilder != aRecognitionHandlerBuilder ) |
|
133 { |
|
134 delete iVerificationRecognitionHandlerBuilder; // Deletes also iRecognitionHandler |
|
135 iVerificationRecognitionHandler = NULL; |
|
136 } |
|
137 |
|
138 iVerificationRecognitionHandlerBuilder = aRecognitionHandlerBuilder; |
|
139 |
|
140 RUBY_DEBUG0( "CDataStorage::SetVerificationRecognitionHandlerBuilder EXIT" ); |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CDataStorage::SetVerificationRecognitionHandler |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CDataStorage::SetVerificationRecognitionHandler( MNssRecognitionHandler* aRecognitionHandler ) |
|
148 { |
|
149 RUBY_DEBUG0( "CDataStorage::SetVerificationRecognitionHandler START" ); |
|
150 |
|
151 iVerificationRecognitionHandler = aRecognitionHandler; |
|
152 |
|
153 RUBY_DEBUG0( "CDataStorage::SetVerificationRecognitionHandler EXIT" ); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CDataStorage::SetAdditionalTagList |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CDataStorage::SetAdditionalTagList( CArrayPtrFlat<MNssTag>* aAdditionalTagList ) |
|
161 { |
|
162 RUBY_DEBUG0( "CDataStorage::SetAdditionalTagList START" ); |
|
163 |
|
164 if ( iAdditionalTagList && iAdditionalTagList != aAdditionalTagList ) |
|
165 { |
|
166 iAdditionalTagList->ResetAndDestroy(); |
|
167 delete iAdditionalTagList; |
|
168 } |
|
169 |
|
170 iAdditionalTagList = aAdditionalTagList; |
|
171 |
|
172 RUBY_DEBUG0( "CDataStorage::SetAdditionalTagList EXIT" ); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CDataStorage::SetCompleteTagList |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CDataStorage::SetCompleteTagList( CArrayPtrFlat<MNssTag>* aCompleteTagList ) |
|
180 { |
|
181 RUBY_DEBUG0( "CDataStorage::SetCompleteTagList START" ); |
|
182 |
|
183 if ( iCompleteTagList && iCompleteTagList != aCompleteTagList ) |
|
184 { |
|
185 iCompleteTagList->ResetAndDestroy(); |
|
186 delete iCompleteTagList; |
|
187 } |
|
188 |
|
189 iCompleteTagList = aCompleteTagList; |
|
190 |
|
191 RUBY_DEBUG0( "CDataStorage::SetCompleteTagList EXIT" ); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CDataStorage::SetTag |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CDataStorage::SetTag( MNssTag* aTag, TBool aDestroyIfExists ) |
|
199 { |
|
200 RUBY_DEBUG0( "CDataStorage::SetTag START" ); |
|
201 |
|
202 if ( iTag && aDestroyIfExists && iTag != aTag ) |
|
203 { |
|
204 delete iTag; |
|
205 } |
|
206 |
|
207 iTag = aTag; |
|
208 |
|
209 RUBY_DEBUG0( "CDataStorage::SetTag EXIT" ); |
|
210 } |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CDataStorage::SetContext |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 void CDataStorage::SetContext( MNssContext* aContext ) |
|
217 { |
|
218 RUBY_DEBUG0( "CDataStorage::SetContext START" ); |
|
219 |
|
220 if ( iContext && iContext != aContext ) |
|
221 { |
|
222 delete iContext; |
|
223 } |
|
224 |
|
225 iContext = aContext; |
|
226 |
|
227 RUBY_DEBUG0( "CDataStorage::SetContext EXIT" ); |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CDataStorage::SetAdaptationEnabled |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 void CDataStorage::SetAdaptationEnabled( const TBool aAdaptationEnabled ) |
|
235 { |
|
236 RUBY_DEBUG0( "CDataStorage::SetAdaptationEnabled START" ); |
|
237 |
|
238 iAdaptationEnabled = aAdaptationEnabled; |
|
239 |
|
240 RUBY_DEBUG0( "CDataStorage::SetAdaptationEnabled EXIT" ); |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CDataStorage::SetPlayDuration |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 void CDataStorage::SetPlayDuration( const TTimeIntervalMicroSeconds& aPlayDuration ) |
|
248 { |
|
249 RUBY_DEBUG0( "CDataStorage::SetPlayDuration START" ); |
|
250 |
|
251 iPlayDuration = aPlayDuration; |
|
252 |
|
253 RUBY_DEBUG0( "CDataStorage::SetPlayDuration EXIT" ); |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CDataStorage::SetVerificationMode |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 void CDataStorage::SetVerificationMode( const TInt aMode ) |
|
261 { |
|
262 RUBY_DEBUG0( "CDataStorage::SetVerificationMode START" ); |
|
263 |
|
264 if ( aMode == KResetMode ) |
|
265 { |
|
266 TRAP_IGNORE( |
|
267 CRepository* client = CRepository::NewLC( KCRUidVCommandSettings ); |
|
268 client->Get( KVCVerification, iVerificationMode ); |
|
269 CleanupStack::PopAndDestroy( client ) ); |
|
270 } |
|
271 else |
|
272 { |
|
273 iVerificationMode = aMode; |
|
274 } |
|
275 |
|
276 RUBY_DEBUG0( "CDataStorage::SetVerificationMode EXIT" ); |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CDataStorage::SetVerificationTryCount |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CDataStorage::SetVerificationTryCount( const TInt aCount ) |
|
284 { |
|
285 RUBY_DEBUG0( "CDataStorage::SetVerificationTryCount START" ); |
|
286 |
|
287 iVerificationTryCount = aCount; |
|
288 |
|
289 RUBY_DEBUG0( "CDataStorage::SetVerificationTryCount EXIT" ); |
|
290 } |
|
291 |
|
292 // ----------------------------------------------------------------------------- |
|
293 // CDataStorage::SetDeviceLockMode |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 void CDataStorage::SetDeviceLockMode( const TBool aDeviceLockMode ) |
|
297 { |
|
298 RUBY_DEBUG0( "CDataStorage::SetDeviceLockMode START" ); |
|
299 |
|
300 iDeviceLockMode = aDeviceLockMode; |
|
301 |
|
302 RUBY_DEBUG0( "CDataStorage::SetDeviceLockMode EXIT" ); |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CDataStorage::VoiceRecognitionImpl |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 CVoiceRecognitionDialogImpl* CDataStorage::VoiceRecognitionImpl() const |
|
310 { |
|
311 RUBY_DEBUG0( "CDataStorage::VoiceRecognitionImpl" ); |
|
312 |
|
313 return iVoiceRecognitionImpl; |
|
314 } |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // CDataStorage::RecognitionHandlerBuilder |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 CNssRecognitionHandlerBuilder* CDataStorage::RecognitionHandlerBuilder() const |
|
321 { |
|
322 RUBY_DEBUG0( "CDataStorage::RecognitionHandlerBuilder" ); |
|
323 |
|
324 return iRecognitionHandlerBuilder; |
|
325 } |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // CDataStorage::RecognitionHandler |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 MNssRecognitionHandler* CDataStorage::RecognitionHandler() const |
|
332 { |
|
333 RUBY_DEBUG0( "CDataStorage::RecognitionHandler" ); |
|
334 |
|
335 return iRecognitionHandler; |
|
336 } |
|
337 |
|
338 // ----------------------------------------------------------------------------- |
|
339 // CDataStorage::VerificationRecognitionHandlerBuilder |
|
340 // ----------------------------------------------------------------------------- |
|
341 // |
|
342 CNssRecognitionHandlerBuilder* CDataStorage::VerificationRecognitionHandlerBuilder() const |
|
343 { |
|
344 RUBY_DEBUG0( "CDataStorage::VerificationRecognitionHandlerBuilder" ); |
|
345 |
|
346 return iVerificationRecognitionHandlerBuilder; |
|
347 } |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CDataStorage::VerificationRecognitionHandler |
|
351 // ----------------------------------------------------------------------------- |
|
352 // |
|
353 MNssRecognitionHandler* CDataStorage::VerificationRecognitionHandler() const |
|
354 { |
|
355 RUBY_DEBUG0( "CDataStorage::VerificationRecognitionHandler" ); |
|
356 |
|
357 return iVerificationRecognitionHandler; |
|
358 } |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // CDataStorage::TonePlayer |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 CTonePlayer* CDataStorage::TonePlayer() const |
|
365 { |
|
366 RUBY_DEBUG0( "CDataStorage::TonePlayer" ); |
|
367 |
|
368 return iTonePlayer; |
|
369 } |
|
370 |
|
371 // ----------------------------------------------------------------------------- |
|
372 // CDataStorage::TtsPlayer |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 CTTSPlayer* CDataStorage::TtsPlayer() const |
|
376 { |
|
377 RUBY_DEBUG0( "CDataStorage::TtsPlayer" ); |
|
378 |
|
379 return iTtsPlayer; |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CDataStorage::PbkHandler |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 MVasBasePbkHandler* CDataStorage::PbkHandler() const |
|
387 { |
|
388 RUBY_DEBUG0( "CDataStorage::PbkHandler" ); |
|
389 |
|
390 return iPbkHandler; |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CDataStorage::AccessoryButtonMonitor |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 CPropertyHandler* CDataStorage::AccessoryButtonMonitor() const |
|
398 { |
|
399 RUBY_DEBUG0( "CDataStorage::AccessoryButtonMonitor" ); |
|
400 |
|
401 return iAccessoryButtonMonitor; |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // CDataStorage::Tutorial |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 CTutorial* CDataStorage::Tutorial() const |
|
409 { |
|
410 RUBY_DEBUG0( "CDataStorage::Tutorial" ); |
|
411 |
|
412 return iTutorial; |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // CDataStorage::AdditionalTagList |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 CArrayPtrFlat<MNssTag>* CDataStorage::AdditionalTagList() const |
|
420 { |
|
421 RUBY_DEBUG0( "CDataStorage::AdditionalTagList" ); |
|
422 |
|
423 return iAdditionalTagList; |
|
424 } |
|
425 |
|
426 // ----------------------------------------------------------------------------- |
|
427 // CDataStorage::CompleteTagList |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 CArrayPtrFlat<MNssTag>* CDataStorage::CompleteTagList() const |
|
431 { |
|
432 RUBY_DEBUG0( "CDataStorage::CompleteTagList" ); |
|
433 |
|
434 return iCompleteTagList; |
|
435 } |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // CDataStorage::Tag |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 MNssTag* CDataStorage::Tag() const |
|
442 { |
|
443 RUBY_DEBUG0( "CDataStorage::Tag" ); |
|
444 |
|
445 return iTag; |
|
446 } |
|
447 |
|
448 // ----------------------------------------------------------------------------- |
|
449 // CDataStorage::Context |
|
450 // ----------------------------------------------------------------------------- |
|
451 // |
|
452 MNssContext* CDataStorage::Context() const |
|
453 { |
|
454 RUBY_DEBUG0( "CDataStorage::Context" ); |
|
455 |
|
456 return iContext; |
|
457 } |
|
458 |
|
459 // ----------------------------------------------------------------------------- |
|
460 // CDataStorage::SynthesizerMode |
|
461 // ----------------------------------------------------------------------------- |
|
462 // |
|
463 TInt CDataStorage::SynthesizerMode() const |
|
464 { |
|
465 RUBY_DEBUG0( "CDataStorage::SynthesizerMode" ); |
|
466 |
|
467 return iSynthesizerMode; |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // CDataStorage::AdaptationEnabled |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 TBool CDataStorage::AdaptationEnabled() const |
|
475 { |
|
476 RUBY_DEBUG0( "CDataStorage::AdaptationEnabled" ); |
|
477 |
|
478 return iAdaptationEnabled; |
|
479 } |
|
480 |
|
481 // ----------------------------------------------------------------------------- |
|
482 // CDataStorage::PlayDuration |
|
483 // ----------------------------------------------------------------------------- |
|
484 // |
|
485 TTimeIntervalMicroSeconds CDataStorage::PlayDuration() const |
|
486 { |
|
487 RUBY_DEBUG0( "CDataStorage::PlayDuration" ); |
|
488 |
|
489 return iPlayDuration; |
|
490 } |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // CDataStorage::VerificationMode |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 TInt CDataStorage::VerificationMode() const |
|
497 { |
|
498 RUBY_DEBUG0( "CDataStorage::VerificationMode" ); |
|
499 |
|
500 return iVerificationMode; |
|
501 } |
|
502 |
|
503 // ----------------------------------------------------------------------------- |
|
504 // CDataStorage::VerificationTryCount |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 TInt CDataStorage::VerificationTryCount() const |
|
508 { |
|
509 RUBY_DEBUG0( "CDataStorage::VerificationTryCount" ); |
|
510 |
|
511 return iVerificationTryCount; |
|
512 } |
|
513 |
|
514 // ----------------------------------------------------------------------------- |
|
515 // CDataStorage::DeviceLockMode |
|
516 // ----------------------------------------------------------------------------- |
|
517 // |
|
518 TBool CDataStorage::DeviceLockMode() const |
|
519 { |
|
520 RUBY_DEBUG0( "CDataStorage::DeviceLockMode" ); |
|
521 |
|
522 return iDeviceLockMode; |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------- |
|
526 // CDataStorage::CDataStorage |
|
527 // --------------------------------------------------------- |
|
528 // |
|
529 CDataStorage::CDataStorage( CVoiceRecognitionDialogImpl* aVoiceRecognitionImpl ) |
|
530 : iVoiceRecognitionImpl( aVoiceRecognitionImpl ), iDeviceLockMode( EFalse ) |
|
531 { |
|
532 } |
|
533 |
|
534 // --------------------------------------------------------- |
|
535 // CDataStorage::ConstructL |
|
536 // --------------------------------------------------------- |
|
537 // |
|
538 void CDataStorage::ConstructL() |
|
539 { |
|
540 RUBY_DEBUG_BLOCK( "CDataStorage::ConstructL" ); |
|
541 |
|
542 iTonePlayer = CTonePlayer::NewL(); |
|
543 iTonePlayer->RegisterObserver( iVoiceRecognitionImpl ); |
|
544 |
|
545 iPbkHandler = CVasVPbkHandler::NewL(); |
|
546 |
|
547 iTtsPlayer = CTTSPlayer::NewL( iVoiceRecognitionImpl ); |
|
548 |
|
549 iAccessoryButtonMonitor = CPropertyHandler::NewL( KPSUidVoiceUiAccMonitor, |
|
550 KVoiceUiOpenKey, |
|
551 KPSUidVoiceUiAccMonitor, |
|
552 KVoiceUiAccessoryEvent ); |
|
553 |
|
554 iTutorial = CTutorial::NewL(); |
|
555 |
|
556 TRAP_IGNORE( |
|
557 CRepository* client = CRepository::NewLC( KCRUidVCommandSettings ); |
|
558 client->Get( KVCSynthesizer, iSynthesizerMode ); |
|
559 client->Get( KVCVerification, iVerificationMode ); |
|
560 CleanupStack::PopAndDestroy( client ) ); |
|
561 |
|
562 iVerificationTryCount = KVerificationTries; |
|
563 } |
|
564 |
|
565 // End of File |
|
566 |