|
1 /* |
|
2 * Copyright (c) 2006-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 <ccafactory.h> |
|
21 #include <mccaparameter.h> |
|
22 #include <mccaconnection.h> |
|
23 |
|
24 #include <vasmbasepbkhandler.h> |
|
25 |
|
26 #include <vuivoicerecognition.rsg> |
|
27 |
|
28 #include "vuivoicerecognition.hrh" |
|
29 |
|
30 #include "vuicstate.h" |
|
31 #include "vuicresultsstate.h" |
|
32 #include "vuicplaystate.h" |
|
33 #include "vuiccontactresultsstate.h" |
|
34 #include "vuicabortstate.h" |
|
35 #include "vuicerrorstate.h" |
|
36 #include "vuicexitstate.h" |
|
37 |
|
38 #include "vuicdatastorage.h" |
|
39 |
|
40 #include "vuicvoicerecogdialogimpl.h" |
|
41 #include "vuicnbestlistdialog.h" |
|
42 #include "vuicttsplayer.h" |
|
43 #include "vuivoiceicondefs.h" |
|
44 |
|
45 #include <CVPbkContactStoreUriArray.h> |
|
46 #include <CVPbkContactManager.h> |
|
47 #include <VPbkContactStoreUris.h> |
|
48 #include <TVPbkContactStoreUriPtr.h> |
|
49 #include <CVPbkContactIdConverter.h> |
|
50 #include <MVPbkContactStore.h> |
|
51 #include <MVPbkContactStoreList.h> |
|
52 |
|
53 #include "rubydebug.h" |
|
54 |
|
55 _LIT( KTab, "\t" ); |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CResultsState::NewL |
|
59 // Two-phased constructor. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CResultsState* CResultsState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel ) |
|
63 { |
|
64 CResultsState* self = new (ELeave) CResultsState( aDataStorage, aUiModel ); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // Destructor |
|
72 CResultsState::~CResultsState() |
|
73 { |
|
74 RUBY_DEBUG0( "CResultsState::~CResultsState START" ); |
|
75 |
|
76 DataStorage().TtsPlayer()->Stop(); |
|
77 |
|
78 delete iNBestListDialog; |
|
79 |
|
80 delete iTagList; // Only copies of pointers, do not reset and destroy |
|
81 |
|
82 if ( iConnection ) |
|
83 { |
|
84 iConnection->Close(); |
|
85 } |
|
86 |
|
87 RUBY_DEBUG0( "CResultsState::~CResultsState EXIT" ); |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------- |
|
91 // CResultsState::HandleEventL |
|
92 // --------------------------------------------------------- |
|
93 // |
|
94 void CResultsState::HandleEventL( TInt aEvent ) |
|
95 { |
|
96 RUBY_DEBUG_BLOCK( "CResultsState::HandleEventL" ); |
|
97 |
|
98 CState* nextState = NULL; |
|
99 |
|
100 switch( aEvent ) |
|
101 { |
|
102 case KErrNone: |
|
103 |
|
104 if ( iInternalState == EStarted ) |
|
105 { |
|
106 iInternalState = EInitialized; |
|
107 } |
|
108 else if ( iInternalState == EInitialized ) |
|
109 { |
|
110 iInternalState = ECompleted; |
|
111 nextState = this; |
|
112 } |
|
113 break; |
|
114 |
|
115 case EVoiceTagSoftKeySelect: |
|
116 |
|
117 if ( DataStorage().Tag()->Context()->ContextName() == KVoiceDialContext ) |
|
118 { |
|
119 nextState = CContactResultsState::NewL( DataStorage(), UiModel() ); |
|
120 } |
|
121 else |
|
122 { |
|
123 nextState = CPlayState::NewL( DataStorage(), UiModel() ); |
|
124 } |
|
125 break; |
|
126 |
|
127 case EVoiceTagSoftKeyDirectSelect: |
|
128 |
|
129 nextState = CPlayState::NewL( DataStorage(), UiModel() ); |
|
130 break; |
|
131 |
|
132 case EAknSoftkeyQuit: |
|
133 case EAknSoftkeyNo: |
|
134 case EVoiceTagSoftKeyQuit: |
|
135 case EEndCallKeypress: |
|
136 case ELongKeypress: |
|
137 |
|
138 nextState = CAbortState::NewL( DataStorage(), UiModel() ); |
|
139 break; |
|
140 |
|
141 case EShortKeypress: |
|
142 case EUpKeypress: |
|
143 case EDownKeypress: |
|
144 case ESelectKeypress: |
|
145 case EDirectSelectKeypress: |
|
146 case EOptionsKeypress: |
|
147 case EOpenKeypress: |
|
148 case EDragKeypress: |
|
149 case EScrollKeypress: |
|
150 |
|
151 iKeypress = aEvent; |
|
152 nextState = this; |
|
153 break; |
|
154 |
|
155 case EAknSoftkeyOpen: |
|
156 |
|
157 nextState = CExitState::NewL( DataStorage(), UiModel() ); |
|
158 break; |
|
159 |
|
160 default: |
|
161 |
|
162 nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent ); |
|
163 break; |
|
164 } |
|
165 |
|
166 DataStorage().VoiceRecognitionImpl()->ChangeState( nextState ); |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------- |
|
170 // CResultsState::ExecuteL |
|
171 // --------------------------------------------------------- |
|
172 // |
|
173 void CResultsState::ExecuteL() |
|
174 { |
|
175 RUBY_DEBUG_BLOCK( "CResultsState::ExecuteL" ); |
|
176 |
|
177 if ( HandleKeypressL() ) |
|
178 { |
|
179 iKeypress = ENoKeypress; |
|
180 } |
|
181 else if ( iInternalState == ECompleted ) |
|
182 { |
|
183 DataStorage().TtsPlayer()->Stop(); |
|
184 } |
|
185 else |
|
186 { |
|
187 TInt returnValue = KErrNoResults; |
|
188 |
|
189 if ( DataStorage().CompleteTagList()->Count() != KErrNone ) |
|
190 { |
|
191 iInternalState = EStarted; |
|
192 |
|
193 CreateContactArrayL(); |
|
194 |
|
195 if ( iTagList->Count() != KErrNone ) |
|
196 { |
|
197 iNBestListDialog = CNBestListDialog::NewL(); |
|
198 |
|
199 CDesC16ArrayFlat* items = NULL; |
|
200 TRAPD( error, items = CreateItemsArrayL() ); |
|
201 |
|
202 if ( !error ) |
|
203 { |
|
204 iNBestListDialog->CreateNBestListPopupLC( items ); |
|
205 iNBestListDialog->SetSoftkeysL( R_SOFTKEYS_OPTIONS_QUIT__SELECT ); |
|
206 |
|
207 CheckOptionsCommands(); |
|
208 PlaySelectedNameL(); |
|
209 BringToForeground(); |
|
210 |
|
211 // If automatic confirmation or device lock is on then start the timer |
|
212 if ( DataStorage().VerificationMode() == EAutomatic || |
|
213 DataStorage().DeviceLockMode() ) |
|
214 { |
|
215 StartTimerL( *this, KTimeoutMicroseconds, KTimeoutMicroseconds ); |
|
216 } |
|
217 |
|
218 iNBestListDialog->RegisterForKeyCallback( DataStorage().VoiceRecognitionImpl() ); |
|
219 returnValue = iNBestListDialog->ShowNBestListPopupL(); // Pops things pushed in CreateNBestListPopupLC |
|
220 RUBY_DEBUG1( "CResultsState::ExecuteL - N-Best list returns [%d]", returnValue ); |
|
221 } |
|
222 else if ( error != KErrNotFound ) |
|
223 { |
|
224 User::Leave( error ); |
|
225 } |
|
226 } |
|
227 } |
|
228 |
|
229 if ( returnValue != KErrNone ) |
|
230 { |
|
231 iInternalState = ECompleted; |
|
232 |
|
233 SelectTag(); |
|
234 |
|
235 HandleEventL( returnValue ); |
|
236 } |
|
237 } |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------- |
|
241 // CResultsState::CResultsState |
|
242 // --------------------------------------------------------- |
|
243 // |
|
244 void CResultsState::CCASimpleNotifyL( TNotifyType /*aType*/, TInt /*aReason*/ ) |
|
245 { |
|
246 RUBY_DEBUG_BLOCK( "CResultsState::CCASimpleNotifyL" ); |
|
247 |
|
248 HandleEventL( EAknSoftkeyOpen ); |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------- |
|
252 // CResultsState::CResultsState |
|
253 // --------------------------------------------------------- |
|
254 // |
|
255 CResultsState::CResultsState( CDataStorage& aDataStorage, CUiModel& aUiModel ) |
|
256 : CState( aDataStorage, aUiModel ), iKeypress( ENoKeypress ), |
|
257 iInternalState( ENotStarted ) |
|
258 { |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------- |
|
262 // CResultsState::ConstructL |
|
263 // --------------------------------------------------------- |
|
264 // |
|
265 void CResultsState::ConstructL() |
|
266 { |
|
267 RUBY_DEBUG_BLOCK( "CResultsState::ConstructL" ); |
|
268 |
|
269 CState::ConstructL(); |
|
270 |
|
271 DataStorage().SetAdaptationEnabled( ETrue ); |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------- |
|
275 // CResultsState::DoTimedEventL |
|
276 // --------------------------------------------------------- |
|
277 // |
|
278 void CResultsState::DoTimedEventL() |
|
279 { |
|
280 RUBY_DEBUG_BLOCK( "CResultsState::DoTimedEventL" ); |
|
281 |
|
282 SelectTag(); |
|
283 |
|
284 HandleEventL( EVoiceTagSoftKeySelect ); |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------- |
|
288 // CResultsState::HandleKeypressL |
|
289 // --------------------------------------------------------- |
|
290 // |
|
291 TBool CResultsState::HandleKeypressL() |
|
292 { |
|
293 RUBY_DEBUG_BLOCK( "CResultsState::HandleKeypressL" ); |
|
294 |
|
295 TBool handled = ETrue; |
|
296 |
|
297 if ( iKeypress == EShortKeypress ) |
|
298 { |
|
299 CDesC16ArrayFlat* items = NULL; |
|
300 |
|
301 if ( UpdateContactArray() ) |
|
302 { |
|
303 items = CreateItemsArrayL(); |
|
304 } |
|
305 |
|
306 if ( iNBestListDialog->HandleShortKeypressL( items ) ) |
|
307 { |
|
308 iInternalState = EStarted; |
|
309 |
|
310 CheckOptionsCommands(); |
|
311 PlaySelectedNameL(); |
|
312 |
|
313 // If automatic confirmation or device lock is on then start the timer |
|
314 if ( DataStorage().VerificationMode() == EAutomatic || |
|
315 DataStorage().DeviceLockMode() ) |
|
316 { |
|
317 StartTimerL( *this, KTimeoutMicroseconds, KTimeoutMicroseconds ); |
|
318 } |
|
319 } |
|
320 else |
|
321 { |
|
322 HandleEventL( KErrNoResults ); |
|
323 } |
|
324 } |
|
325 else if ( iKeypress == EUpKeypress || iKeypress == EDownKeypress || |
|
326 iKeypress == EDragKeypress ) |
|
327 { |
|
328 iInternalState = EStarted; |
|
329 |
|
330 CheckOptionsCommands(); |
|
331 PlaySelectedNameL(); |
|
332 |
|
333 // If automatic confirmation or device lock is on then start the timer |
|
334 if ( DataStorage().VerificationMode() == EAutomatic || |
|
335 DataStorage().DeviceLockMode() ) |
|
336 { |
|
337 StartTimerL( *this, KTimeoutMicroseconds, KTimeoutMicroseconds ); |
|
338 } |
|
339 } |
|
340 else if ( iKeypress == EScrollKeypress ) |
|
341 { |
|
342 StopTimer(); |
|
343 } |
|
344 else if ( iKeypress == ESelectKeypress ) |
|
345 { |
|
346 if ( !DataStorage().Tag() ) |
|
347 { |
|
348 SelectTag(); |
|
349 |
|
350 HandleEventL( EVoiceTagSoftKeySelect ); |
|
351 } |
|
352 } |
|
353 else if ( iKeypress == EDirectSelectKeypress ) |
|
354 { |
|
355 if ( !DataStorage().Tag() ) |
|
356 { |
|
357 SelectTag(); |
|
358 |
|
359 HandleEventL( EVoiceTagSoftKeyDirectSelect ); |
|
360 } |
|
361 } |
|
362 else if ( iKeypress == EOptionsKeypress ) |
|
363 { |
|
364 StopTimer(); |
|
365 DataStorage().SetVerificationMode( EManual ); |
|
366 } |
|
367 else if ( iKeypress == EOpenKeypress ) |
|
368 { |
|
369 OpenPhonebookContactL(); |
|
370 } |
|
371 else |
|
372 { |
|
373 handled = EFalse; |
|
374 } |
|
375 |
|
376 return handled; |
|
377 } |
|
378 |
|
379 // --------------------------------------------------------------------------- |
|
380 // CResultsState::PlaySelectedNameL |
|
381 // --------------------------------------------------------------------------- |
|
382 // |
|
383 void CResultsState::PlaySelectedNameL() |
|
384 { |
|
385 RUBY_DEBUG_BLOCK( "CResultsState::PlaySelectedNameL" ); |
|
386 |
|
387 // if TTS is used |
|
388 if ( ( DataStorage().SynthesizerMode() != KErrNone || |
|
389 DataStorage().DeviceLockMode() ) && |
|
390 iTagList->Count() > 0 ) |
|
391 { |
|
392 TInt index = iNBestListDialog->SelectedIndex(); |
|
393 HBufC* text = NULL; |
|
394 |
|
395 if ( iTagList->At( index )->Context()->ContextName() == KVoiceDialContext ) |
|
396 { |
|
397 text = iTagList->At( index )->SpeechItem()->PartialTextL( KNameTrainingIndex ); |
|
398 } |
|
399 else |
|
400 { |
|
401 text = HBufC::NewL( 0 ); |
|
402 } |
|
403 |
|
404 CleanupStack::PushL( text ); |
|
405 |
|
406 DataStorage().TtsPlayer()->PlayL( iTagList->At( index )->SpeechItem()->Text(), 0, |
|
407 iTagList->At( index )->SpeechItem()->Text().Length(), |
|
408 *text ); |
|
409 |
|
410 CleanupStack::PopAndDestroy( text ); |
|
411 } |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------------------------- |
|
415 // CResultsState::CheckOptionsCommands |
|
416 // --------------------------------------------------------------------------- |
|
417 // |
|
418 void CResultsState::CheckOptionsCommands() |
|
419 { |
|
420 RUBY_DEBUG0( "CResultsState::CheckOptionsCommands START" ); |
|
421 |
|
422 if ( iTagList->Count() > 0 ) |
|
423 { |
|
424 TBool hidden = ETrue; |
|
425 |
|
426 TInt index = iNBestListDialog->SelectedIndex(); |
|
427 if ( iTagList->At( index )->Context()->ContextName() == KVoiceDialContext ) |
|
428 { |
|
429 hidden = EFalse; |
|
430 } |
|
431 iNBestListDialog->SetCommandsHidden( hidden ); |
|
432 } |
|
433 RUBY_DEBUG0( "CResultsState::CheckOptionsCommands EXIT" ); |
|
434 } |
|
435 |
|
436 // --------------------------------------------------------------------------- |
|
437 // CResultsState::CreateContactArrayL |
|
438 // --------------------------------------------------------------------------- |
|
439 // |
|
440 void CResultsState::CreateContactArrayL() |
|
441 { |
|
442 RUBY_DEBUG_BLOCK( "CResultsState::CreateContactArrayL" ); |
|
443 |
|
444 CArrayPtrFlat<MNssTag>* completeTagList = DataStorage().CompleteTagList(); |
|
445 |
|
446 iTagList = new ( ELeave ) CArrayPtrFlat<MNssTag>( KSindMaxResults ); |
|
447 |
|
448 // Add commands to taglist |
|
449 for ( TInt i = 0; i < completeTagList->Count() && iTagList->Count() < KSindMaxResults; ++i ) |
|
450 { |
|
451 MNssTag* tag = completeTagList->At( i ); |
|
452 |
|
453 if ( tag->Context()->ContextName() == KVoiceDialContext && |
|
454 ( !DataStorage().DeviceLockMode() || tag->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial ) ) |
|
455 { |
|
456 if ( !CheckIfAlreadyAdded( tag ) ) |
|
457 { |
|
458 iTagList->AppendL( tag ); |
|
459 } |
|
460 } |
|
461 else if ( !DataStorage().DeviceLockMode() ) |
|
462 { |
|
463 iTagList->AppendL( tag ); |
|
464 } |
|
465 } |
|
466 } |
|
467 |
|
468 // --------------------------------------------------------------------------- |
|
469 // CResultsState::UpdateContactArray |
|
470 // --------------------------------------------------------------------------- |
|
471 // |
|
472 TBool CResultsState::UpdateContactArray() |
|
473 { |
|
474 RUBY_DEBUG0( "CResultsState::UpdateContactArray START" ); |
|
475 |
|
476 MNssTag* tag = iTagList->At( iNBestListDialog->SelectedIndex() ); |
|
477 |
|
478 TBool currentTagFound = EFalse; |
|
479 TBool updated = EFalse; |
|
480 |
|
481 if ( tag->Context()->ContextName() == KVoiceDialContext ) |
|
482 { |
|
483 for ( TInt i = 0; i < DataStorage().CompleteTagList()->Count(); ++i ) |
|
484 { |
|
485 MNssTag* newTag = DataStorage().CompleteTagList()->At( i ); |
|
486 |
|
487 if ( newTag->Context()->ContextName() == KVoiceDialContext && |
|
488 ( !DataStorage().DeviceLockMode() || newTag->RRD()->IntArray()->At( KVasExtensionRrdLocation ) == EDial ) && |
|
489 tag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) == |
|
490 newTag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) ) |
|
491 { |
|
492 if ( currentTagFound ) |
|
493 { |
|
494 iTagList->At( iNBestListDialog->SelectedIndex() ) = newTag; |
|
495 updated = ETrue; |
|
496 break; |
|
497 } |
|
498 else if ( tag->SpeechItem()->RawText() == newTag->SpeechItem()->RawText() ) |
|
499 { |
|
500 currentTagFound = ETrue; |
|
501 } |
|
502 } |
|
503 } |
|
504 } |
|
505 |
|
506 RUBY_DEBUG0( "CResultsState::UpdateContactArray EXIT" ); |
|
507 |
|
508 return updated; |
|
509 } |
|
510 |
|
511 // --------------------------------------------------------- |
|
512 // CResultsState::CheckIfAlreadyAdded |
|
513 // --------------------------------------------------------- |
|
514 // |
|
515 TBool CResultsState::CheckIfAlreadyAdded( MNssTag* aTag ) |
|
516 { |
|
517 RUBY_DEBUG0( "CResultsState::CheckIfAlreadyAdded START" ); |
|
518 |
|
519 TBool returnValue = EFalse; |
|
520 |
|
521 for ( TInt i = 0; i < iTagList->Count(); ++i ) |
|
522 { |
|
523 if ( aTag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) == |
|
524 iTagList->At( i )->RRD()->IntArray()->At( KVasContactIdRrdLocation ) ) |
|
525 { |
|
526 returnValue = ETrue; |
|
527 |
|
528 break; |
|
529 } |
|
530 } |
|
531 |
|
532 RUBY_DEBUG0( "CResultsState::CheckIfAlreadyAdded EXIT" ); |
|
533 |
|
534 return returnValue; |
|
535 } |
|
536 |
|
537 // --------------------------------------------------------------------------- |
|
538 // CResultsState::CreateItemsArrayLC |
|
539 // --------------------------------------------------------------------------- |
|
540 // |
|
541 CDesC16ArrayFlat* CResultsState::CreateItemsArrayL() |
|
542 { |
|
543 RUBY_DEBUG_BLOCK( "CResultsState::CreateItemsArrayL" ); |
|
544 |
|
545 TInt count = iTagList->Count(); |
|
546 |
|
547 CDesC16ArrayFlat* items = new ( ELeave ) CDesC16ArrayFlat( KSindMaxResults ); |
|
548 CleanupStack::PushL( items ); |
|
549 |
|
550 TName buffer; |
|
551 |
|
552 for ( TInt i = 0; i < count; ++i ) |
|
553 { |
|
554 MNssTag* tag = iTagList->At( i ); |
|
555 |
|
556 if ( tag->Context()->ContextName() == KVoiceDialContext ) |
|
557 { |
|
558 FillDialContextBufferL( tag, buffer ); |
|
559 |
|
560 items->AppendL( buffer ); |
|
561 } |
|
562 else |
|
563 { |
|
564 FillCommandContextBuffer( tag, buffer ); |
|
565 |
|
566 items->AppendL( buffer ); |
|
567 } |
|
568 } |
|
569 |
|
570 CleanupStack::Pop( items ); |
|
571 |
|
572 return items; |
|
573 } |
|
574 |
|
575 // --------------------------------------------------------- |
|
576 // CResultsState::FillDialContextBufferL |
|
577 // --------------------------------------------------------- |
|
578 // |
|
579 void CResultsState::FillDialContextBufferL( MNssTag* aTag, TDes& aBuffer ) |
|
580 { |
|
581 RUBY_DEBUG_BLOCK( "CResultsState::FillDialContextBufferL" ); |
|
582 |
|
583 TPtrC type = KNullDesC(); |
|
584 |
|
585 DataStorage().PbkHandler()->FindContactFieldL( aTag ); |
|
586 |
|
587 type.Set( GetContactIconType( DataStorage().PbkHandler()->FieldTypeL() ) ); |
|
588 |
|
589 // Get the actual name only |
|
590 HBufC* name = aTag->SpeechItem()->PartialTextL( KNameTrainingIndex ); |
|
591 CleanupStack::PushL( name ); |
|
592 |
|
593 aBuffer.Zero(); |
|
594 aBuffer.Append( type ); |
|
595 aBuffer.Append( KTab ); |
|
596 aBuffer.Append( *name ); |
|
597 aBuffer.Append( KTab ); |
|
598 |
|
599 HBufC* label = NULL; |
|
600 |
|
601 TRAPD( error, label = aTag->SpeechItem()->PartialTextL( KExtensionTrainingIndex ) ); |
|
602 if ( error == KErrNone || error == KErrNotFound ) |
|
603 { |
|
604 // If there is no extension then the phonebook label is shown |
|
605 if ( label ) |
|
606 { |
|
607 CleanupStack::PushL( label ); |
|
608 |
|
609 aBuffer.Append( *label ); |
|
610 |
|
611 CleanupStack::PopAndDestroy( label ); |
|
612 } |
|
613 else |
|
614 { |
|
615 aBuffer.Append( DataStorage().PbkHandler()->LabelL() ); |
|
616 } |
|
617 } |
|
618 else |
|
619 { |
|
620 User::Leave( error ); |
|
621 } |
|
622 |
|
623 CleanupStack::PopAndDestroy( name ); |
|
624 } |
|
625 |
|
626 // --------------------------------------------------------- |
|
627 // CResultsState::FillCommandContextBuffer |
|
628 // --------------------------------------------------------- |
|
629 // |
|
630 void CResultsState::FillCommandContextBuffer( MNssTag* aTag, TDes& aBuffer ) |
|
631 { |
|
632 RUBY_DEBUG0( "CResultsState::FillCommandContextBuffer START" ); |
|
633 |
|
634 aBuffer.Zero(); |
|
635 |
|
636 if ( aTag->RRD()->IntArray()->At( KVasContactIdRrdLocation ) >= KProfileValue ) |
|
637 { |
|
638 aBuffer.Append( KIconProfile ); |
|
639 } |
|
640 else |
|
641 { |
|
642 aBuffer.Append( KIconApplication ); |
|
643 } |
|
644 |
|
645 aBuffer.Append( KTab ); |
|
646 aBuffer.Append( aTag->SpeechItem()->Text() ); |
|
647 |
|
648 RUBY_DEBUG0( "CResultsState::FillCommandContextBuffer EXIT" ); |
|
649 } |
|
650 |
|
651 // --------------------------------------------------------- |
|
652 // CResultsState::GetContactIconType |
|
653 // --------------------------------------------------------- |
|
654 // |
|
655 TPtrC CResultsState::GetContactIconType( TFieldType aFieldType ) |
|
656 { |
|
657 RUBY_DEBUG0( "CResultsState::GetContactIconType START" ); |
|
658 |
|
659 TPtrC type; |
|
660 // select a phone type |
|
661 if ( aFieldType == KUidContactFieldVCardMapVOICE ) |
|
662 { |
|
663 type.Set( KIconPhone ); |
|
664 } |
|
665 else if ( aFieldType == KUidContactFieldVCardMapCELL ) |
|
666 { |
|
667 type.Set( KIconMobile ); |
|
668 } |
|
669 else if ( aFieldType == KUidContactFieldVCardMapFAX ) |
|
670 { |
|
671 type.Set( KIconFax ); |
|
672 } |
|
673 else if ( aFieldType == KUidContactFieldVCardMapEMAILINTERNET ) |
|
674 { |
|
675 type.Set( KIconEmail ); |
|
676 } |
|
677 else if ( aFieldType == KUidContactFieldVCardMapVIDEO ) |
|
678 { |
|
679 type.Set( KIconVideo ); |
|
680 } |
|
681 else if ( aFieldType == KUidContactFieldVCardMapVOIP ) |
|
682 { |
|
683 type.Set( KIconVoip ); |
|
684 } |
|
685 else |
|
686 { |
|
687 type.Set( KIconBlank ); |
|
688 } |
|
689 |
|
690 RUBY_DEBUG0( "CResultsState::GetContactIconType EXIT" ); |
|
691 |
|
692 return type; |
|
693 } |
|
694 |
|
695 // --------------------------------------------------------- |
|
696 // CResultsState::SelectTag |
|
697 // --------------------------------------------------------- |
|
698 // |
|
699 void CResultsState::SelectTag() |
|
700 { |
|
701 RUBY_DEBUG0( "CResultsState::SelectTag START" ); |
|
702 |
|
703 if ( iTagList && iTagList->Count() > 0 ) |
|
704 { |
|
705 DataStorage().SetTag( iTagList->At( iNBestListDialog->SelectedIndex() ), ETrue ); |
|
706 |
|
707 // Remove selected item from the complete taglist |
|
708 for ( TInt i = 0; i < DataStorage().CompleteTagList()->Count(); ++i ) |
|
709 { |
|
710 if ( DataStorage().CompleteTagList()->At( i ) == |
|
711 DataStorage().Tag() ) |
|
712 { |
|
713 DataStorage().CompleteTagList()->Delete( i ); |
|
714 break; |
|
715 } |
|
716 } |
|
717 } |
|
718 |
|
719 RUBY_DEBUG0( "CResultsState::SelectTag EXIT" ); |
|
720 } |
|
721 |
|
722 // --------------------------------------------------------- |
|
723 // CResultsState::OpenPhonebookContactL |
|
724 // --------------------------------------------------------- |
|
725 // |
|
726 void CResultsState::OpenPhonebookContactL() |
|
727 { |
|
728 RUBY_DEBUG_BLOCK( "CResultsState::OpenPhonebookContactL" ); |
|
729 |
|
730 SelectTag(); |
|
731 |
|
732 if ( iConnection ) |
|
733 { |
|
734 iConnection->Close(); |
|
735 } |
|
736 iConnection = TCCAFactory::NewConnectionL(); |
|
737 |
|
738 MCCAParameter* parameter = TCCAFactory::NewParameterL(); |
|
739 CleanupClosePushL( *parameter ); |
|
740 |
|
741 parameter->SetConnectionFlag( MCCAParameter::ENormal ); |
|
742 parameter->SetContactDataFlag( MCCAParameter::EContactLink ); |
|
743 |
|
744 // Create a Contact Manager and bind it with the default contact database |
|
745 CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewL(); |
|
746 CleanupStack::PushL( uriArray ); |
|
747 |
|
748 TVPbkContactStoreUriPtr uri( VPbkContactStoreUris::DefaultCntDbUri() ); |
|
749 uriArray->AppendL( uri ); |
|
750 |
|
751 CVPbkContactManager* contactManager = CVPbkContactManager::NewL(*uriArray); |
|
752 CleanupStack::PushL( contactManager ); |
|
753 |
|
754 // Find Contacts Model store URI from the contact manager (copied from Phonebook app) |
|
755 MVPbkContactStore* defaultStore = contactManager->ContactStoresL().Find( uri ); |
|
756 User::LeaveIfNull( defaultStore ); |
|
757 |
|
758 // Create a ContactIdConverter object for the ContactId-to-ContactLink conversion |
|
759 CVPbkContactIdConverter* idConverter = CVPbkContactIdConverter::NewL( *defaultStore ); |
|
760 CleanupStack::PushL( idConverter ); |
|
761 |
|
762 MVPbkContactLink* link = idConverter->IdentifierToLinkLC( |
|
763 DataStorage().Tag()->RRD()->IntArray()->At( KVasContactIdRrdLocation )); |
|
764 |
|
765 HBufC8* link8 = link->PackLC(); |
|
766 HBufC16* link16 = HBufC16::NewLC( link8->Length() ); |
|
767 link16->Des().Copy( *link8 ); |
|
768 |
|
769 parameter->SetContactDataL( link16->Des() ); |
|
770 |
|
771 iConnection->LaunchAppL( *parameter, this ); |
|
772 |
|
773 CleanupStack::PopAndDestroy(6,uriArray); |
|
774 CleanupStack::Pop();//parameter |
|
775 } |
|
776 |
|
777 // End of File |
|
778 |