19
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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: Implementation for CPbkInfoViewSindHandler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "pbkinfoviewsindhandler.h"
|
|
21 |
#include "pbkinfoviewreshandler.h"
|
|
22 |
#include "pbkinfoviewdefines.h"
|
|
23 |
#include <pbkinfoview.rsg>
|
|
24 |
|
|
25 |
#include <vuivoicerecogdefs.h> // KVoiceDialContext
|
|
26 |
#include <nssvascoreconstant.h>
|
|
27 |
#include <vascvpbkhandler.h>
|
|
28 |
#include <CPbkContactEngine.h>
|
|
29 |
#include <CPbkContactItem.h>
|
|
30 |
#include <CPbkFieldInfo.h>
|
|
31 |
#include <StringLoader.h>
|
|
32 |
#include <nssvascoreconstant.h>
|
|
33 |
|
|
34 |
#include "rubydebug.h"
|
|
35 |
|
|
36 |
// ----------------------------------------------------------------------------
|
|
37 |
// RemapCommand
|
|
38 |
// Remap command to the correct order.
|
|
39 |
// @param aCommandId
|
|
40 |
// ----------------------------------------------------------------------------
|
|
41 |
static TInt RemapCommand( TInt aCommandId )
|
|
42 |
{
|
|
43 |
switch (aCommandId)
|
|
44 |
{
|
|
45 |
case EEmailCommand:
|
|
46 |
return EMessageCommand;
|
|
47 |
case EVoipCommand:
|
|
48 |
return EEmailCommand;
|
|
49 |
case EMessageCommand:
|
|
50 |
return EVoipCommand;
|
|
51 |
default:
|
|
52 |
return aCommandId;
|
|
53 |
}
|
|
54 |
}
|
|
55 |
// ================= MEMBER FUNCTIONS =======================
|
|
56 |
|
|
57 |
inline CPbkInfoViewSindHandler::CPbkInfoViewSindHandler()
|
|
58 |
{
|
|
59 |
}
|
|
60 |
|
|
61 |
// ----------------------------------------------------------------------------
|
|
62 |
// CPbkInfoViewSindHandler::ConstructL
|
|
63 |
// Creates a new instance of CPbkSindHandler.
|
|
64 |
// @param aContactId Contact id for the contact whose voice tags are to
|
|
65 |
// be fetched from vas db.
|
|
66 |
// ----------------------------------------------------------------------------
|
|
67 |
inline void CPbkInfoViewSindHandler::ConstructL( TInt aContactId )
|
|
68 |
{
|
|
69 |
InitializeL( aContactId );
|
|
70 |
|
|
71 |
CreateVoiceTagListL( aContactId );
|
|
72 |
|
|
73 |
CreatePopupArrayL();
|
|
74 |
}
|
|
75 |
|
|
76 |
// ----------------------------------------------------------------------------
|
|
77 |
// CPbkInfoViewSindHandler::TestConstructL
|
|
78 |
// Creates an instance that doesn't require CCoeEnv for STIF testing purposes.
|
|
79 |
// @param aContactId Contact id for the contact whose voice tags are to
|
|
80 |
// be fetched from vas db.
|
|
81 |
// ----------------------------------------------------------------------------
|
|
82 |
inline void CPbkInfoViewSindHandler::TestConstructL( TInt aContactId )
|
|
83 |
{
|
|
84 |
InitializeL( aContactId );
|
|
85 |
|
|
86 |
CreateVoiceTagListL( aContactId );
|
|
87 |
}
|
|
88 |
|
|
89 |
// ----------------------------------------------------------------------------
|
|
90 |
// CPbkInfoViewSindHandler::InitializeL
|
|
91 |
// Initialization.
|
|
92 |
// @param aContactId Contact id for the contact whose voice tags are
|
|
93 |
// fetched from vas db.
|
|
94 |
// @return TInt KErrNone on success
|
|
95 |
// ----------------------------------------------------------------------------
|
|
96 |
void CPbkInfoViewSindHandler::InitializeL( TInt aContactId )
|
|
97 |
{
|
|
98 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::InitializeL" );
|
|
99 |
|
|
100 |
// create Vas db manager
|
|
101 |
iVasDbManager = CNssVASDBMgr::NewL();
|
|
102 |
|
|
103 |
iVasDbManager->InitializeL();
|
|
104 |
|
|
105 |
// Ownership not transferred
|
|
106 |
iContextManager = iVasDbManager->GetContextMgr();
|
|
107 |
// Ownership not transferred
|
|
108 |
iTagManager = iVasDbManager->GetTagMgr();
|
|
109 |
|
|
110 |
iWait = new (ELeave) CActiveSchedulerWait();
|
|
111 |
|
|
112 |
// Create and initialize phonebook handler that is used to get the
|
|
113 |
// phone numbers etc used in voice tags.
|
|
114 |
iPbkHandler = CVasVPbkHandler::NewL();
|
|
115 |
iPbkHandler->InitializeL();
|
|
116 |
|
|
117 |
iPbkEngine = CPbkContactEngine::NewL();
|
|
118 |
|
|
119 |
if( aContactId == KVoiceTaglessContactId )
|
|
120 |
{
|
|
121 |
iPbkContactItem = iPbkEngine->CreateEmptyContactL();
|
|
122 |
}
|
|
123 |
else
|
|
124 |
{
|
|
125 |
iPbkHandler->FindContactL( aContactId, ETrue );
|
|
126 |
iPbkContactItem = iPbkEngine->ReadContactL( aContactId );
|
|
127 |
}
|
|
128 |
|
|
129 |
iTts = CTtsUtility::NewL( *this );
|
|
130 |
|
|
131 |
// Put to thread local storage so that CompareL can use this pointer
|
|
132 |
Dll::SetTls( iPbkContactItem );
|
|
133 |
|
|
134 |
iPlaybackIndex = -1;
|
|
135 |
}
|
|
136 |
|
|
137 |
// ----------------------------------------------------------------------------
|
|
138 |
// CPbkInfoViewSindHandler::NewL
|
|
139 |
//
|
|
140 |
// ----------------------------------------------------------------------------
|
|
141 |
CPbkInfoViewSindHandler* CPbkInfoViewSindHandler::NewL( TInt aContactId )
|
|
142 |
{
|
|
143 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::NewL" );
|
|
144 |
|
|
145 |
CPbkInfoViewSindHandler* self = new (ELeave) CPbkInfoViewSindHandler;
|
|
146 |
CleanupStack::PushL( self );
|
|
147 |
self->ConstructL( aContactId );
|
|
148 |
CleanupStack::Pop(self);
|
|
149 |
return self;
|
|
150 |
}
|
|
151 |
|
|
152 |
// ----------------------------------------------------------------------------
|
|
153 |
// CPbkInfoViewSindHandler::TestNewL
|
|
154 |
//
|
|
155 |
// ----------------------------------------------------------------------------
|
|
156 |
CPbkInfoViewSindHandler* CPbkInfoViewSindHandler::TestNewL( TInt aContactId )
|
|
157 |
{
|
|
158 |
CPbkInfoViewSindHandler* self = new (ELeave) CPbkInfoViewSindHandler;
|
|
159 |
CleanupStack::PushL( self );
|
|
160 |
self->TestConstructL( aContactId );
|
|
161 |
CleanupStack::Pop(self);
|
|
162 |
return self;
|
|
163 |
}
|
|
164 |
|
|
165 |
// ----------------------------------------------------------------------------
|
|
166 |
// CPbkInfoViewSindHandler::~CPbkInfoViewSindHandler
|
|
167 |
//
|
|
168 |
// ----------------------------------------------------------------------------
|
|
169 |
CPbkInfoViewSindHandler::~CPbkInfoViewSindHandler()
|
|
170 |
{
|
|
171 |
delete iVasDbManager;
|
|
172 |
iVasDbManager = NULL;
|
|
173 |
|
|
174 |
delete iContext;
|
|
175 |
iContext = NULL;
|
|
176 |
|
|
177 |
delete iWait;
|
|
178 |
iWait = NULL;
|
|
179 |
|
|
180 |
iTagArray.ResetAndDestroy();
|
|
181 |
|
|
182 |
// Free iPbkContactItem from thread local storage
|
|
183 |
Dll::FreeTls();
|
|
184 |
|
|
185 |
delete iPbkContactItem;
|
|
186 |
iPbkContactItem = NULL;
|
|
187 |
|
|
188 |
delete iPbkEngine;
|
|
189 |
iPbkEngine = NULL;
|
|
190 |
|
|
191 |
iPopupArray.ResetAndDestroy();
|
|
192 |
|
|
193 |
delete iPbkHandler;
|
|
194 |
|
|
195 |
delete iTts;
|
|
196 |
}
|
|
197 |
|
|
198 |
// ----------------------------------------------------------------------------
|
|
199 |
// CPbkInfoViewSindHandler::VoiceTagCount
|
|
200 |
// Returns the number of voice tags for the contact.
|
|
201 |
// @return TInt voice tag count.
|
|
202 |
// ----------------------------------------------------------------------------
|
|
203 |
TInt CPbkInfoViewSindHandler::VoiceTagCount()
|
|
204 |
{
|
|
205 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::VoiceTagCount" );
|
|
206 |
|
|
207 |
return iTagArray.Count();
|
|
208 |
}
|
|
209 |
|
|
210 |
// ----------------------------------------------------------------------------
|
|
211 |
// CPbkInfoViewSindHandler::VoiceTagL
|
|
212 |
// Returns a voice tag.
|
|
213 |
// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
|
|
214 |
// @return TDesC& the voice tag
|
|
215 |
// ----------------------------------------------------------------------------
|
|
216 |
const TDesC& CPbkInfoViewSindHandler::VoiceTagL( TInt aIndex )
|
|
217 |
{
|
|
218 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::VoiceTagL" );
|
|
219 |
|
|
220 |
__ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
|
|
221 |
User::Leave( KErrArgument ) );
|
|
222 |
|
|
223 |
return iTagArray[aIndex]->SpeechItem()->Text();
|
|
224 |
}
|
|
225 |
|
|
226 |
// ----------------------------------------------------------------------------
|
|
227 |
// CPbkInfoViewSindHandler::VoiceTagLabelLC
|
|
228 |
// Returns the label associated with a voice tag (mobile, home, etc).
|
|
229 |
// @param aIndex index for the voice tag label.
|
|
230 |
// 0 <= aIndex <= VoiceTagCount() - 1
|
|
231 |
// @return TPtrC the value
|
|
232 |
// ----------------------------------------------------------------------------
|
|
233 |
HBufC* CPbkInfoViewSindHandler::VoiceTagLabelLC( TInt aIndex )
|
|
234 |
{
|
|
235 |
RUBY_DEBUG0( "CPbkInfoViewSindHandler::VoiceTagLabelLC START" );
|
|
236 |
|
|
237 |
__ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
|
|
238 |
User::Leave( KErrArgument ) );
|
|
239 |
|
|
240 |
TInt contactId = iTagArray[aIndex]->RRD()
|
|
241 |
->IntArray()->At( KVasContactIdRrdLocation );
|
|
242 |
TInt fieldId = iTagArray[aIndex]->RRD()
|
|
243 |
->IntArray()->At( KVasFieldIdRrdLocation );
|
|
244 |
|
|
245 |
// RawText is in the format of _1firstName_1lastName_2extension
|
|
246 |
// or _2extension _1firstName_1lastName
|
|
247 |
HBufC* tagLabel = iTagArray[aIndex]->SpeechItem()->RawText().AllocLC();
|
|
248 |
tagLabel->Des().TrimAll();
|
|
249 |
|
|
250 |
TInt separatorIndex = tagLabel->Des().Find( KTagExtensionSeparator );
|
|
251 |
// Checks whether this a voice tag for nick name (with or without
|
|
252 |
// extensions) or for first-last name combination without extension.
|
|
253 |
// In this case show the whole tag, just remove separators.
|
|
254 |
if( iTagArray[aIndex]->RRD()->IntArray()->At( KVasTagTypeRrdLocation )
|
|
255 |
== ETagTypeNickName || separatorIndex == KErrNotFound )
|
|
256 |
{
|
|
257 |
// Remove name separators
|
|
258 |
while( (separatorIndex = tagLabel->Des().Find( KTagNameSeparator ) )
|
|
259 |
!= KErrNotFound )
|
|
260 |
{
|
|
261 |
tagLabel->Des().Replace( separatorIndex, KTagSeparatorLength,
|
|
262 |
KSpace );
|
|
263 |
}
|
|
264 |
// Remove extension separator
|
|
265 |
separatorIndex = tagLabel->Des().Find( KTagExtensionSeparator );
|
|
266 |
if( separatorIndex != KErrNotFound )
|
|
267 |
{
|
|
268 |
tagLabel->Des().Replace( separatorIndex, KTagSeparatorLength,
|
|
269 |
KSpace );
|
|
270 |
}
|
|
271 |
|
|
272 |
RUBY_DEBUG0( "CPbkInfoViewSindHandler::VoiceTagLabelLC EXIT" );
|
|
273 |
return tagLabel;
|
|
274 |
}
|
|
275 |
|
|
276 |
TInt nameSeparatorIndex = tagLabel->Des().Find( KTagNameSeparator );
|
|
277 |
CleanupStack::PopAndDestroy( tagLabel );
|
|
278 |
|
|
279 |
// Show the extension only
|
|
280 |
|
|
281 |
// RawText is in format _2extension _1firstName_1lastName
|
|
282 |
if( nameSeparatorIndex > separatorIndex )
|
|
283 |
{
|
|
284 |
TInt length( nameSeparatorIndex - separatorIndex - KTagSeparatorLength );
|
|
285 |
tagLabel = iTagArray[aIndex]->SpeechItem()->RawText()
|
|
286 |
.Mid( separatorIndex + KTagSeparatorLength, length )
|
|
287 |
.AllocLC();
|
|
288 |
}
|
|
289 |
// _1firstName_1lastName_2extension
|
|
290 |
else
|
|
291 |
{
|
|
292 |
tagLabel = iTagArray[aIndex]->SpeechItem()->RawText()
|
|
293 |
.Mid( separatorIndex + KTagSeparatorLength ).AllocLC();
|
|
294 |
}
|
|
295 |
|
|
296 |
RUBY_DEBUG0( "CPbkInfoViewSindHandler::VoiceTagLabelLC EXIT" );
|
|
297 |
|
|
298 |
return tagLabel;
|
|
299 |
}
|
|
300 |
|
|
301 |
// ----------------------------------------------------------------------------
|
|
302 |
// CPbkInfoViewSindHandler::VoiceTagValueL
|
|
303 |
// Returns the phone number, e-mail address, etc. associated with a voice tag.
|
|
304 |
// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
|
|
305 |
// @return TPtrC the value
|
|
306 |
// ----------------------------------------------------------------------------
|
|
307 |
TPtrC CPbkInfoViewSindHandler::VoiceTagValueL( TInt aIndex )
|
|
308 |
{
|
|
309 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::VoiceTagValueL" );
|
|
310 |
|
|
311 |
__ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
|
|
312 |
User::Leave( KErrArgument ) );
|
|
313 |
|
|
314 |
// By using CVasVPbkHandler, info view will show consistent information with
|
|
315 |
// Recognition UI.
|
|
316 |
iPbkHandler->FindContactFieldL( iTagArray[aIndex] );
|
|
317 |
return iPbkHandler->TextL();
|
|
318 |
}
|
|
319 |
|
|
320 |
// ----------------------------------------------------------------------------
|
|
321 |
// CPbkInfoViewSindHandler::PopupTextL
|
|
322 |
// Returns the popup text associated with a voice tag.
|
|
323 |
// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
|
|
324 |
// @return TDesC& popup text
|
|
325 |
// ----------------------------------------------------------------------------
|
|
326 |
TDesC& CPbkInfoViewSindHandler::PopupTextL( TInt aIndex )
|
|
327 |
{
|
|
328 |
__ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
|
|
329 |
User::Leave( KErrArgument ) );
|
|
330 |
__ASSERT_ALWAYS( aIndex >= 0 && aIndex < iPopupArray.Count(),
|
|
331 |
User::Leave( KErrArgument ) );
|
|
332 |
|
|
333 |
return *iPopupArray[aIndex];
|
|
334 |
}
|
|
335 |
|
|
336 |
// ----------------------------------------------------------------------------
|
|
337 |
// CPbkInfoViewSindHandler::PlayVoiceCommandL
|
|
338 |
// Plays a voice tag.
|
|
339 |
// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
|
|
340 |
// ----------------------------------------------------------------------------
|
|
341 |
void CPbkInfoViewSindHandler::PlayVoiceCommandL( TInt aIndex )
|
|
342 |
{
|
|
343 |
__ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
|
|
344 |
User::Leave( KErrArgument ) );
|
|
345 |
|
|
346 |
if( IsPlaying() )
|
|
347 |
{
|
|
348 |
CancelPlaybackL();
|
|
349 |
}
|
|
350 |
iTts->Stop();
|
|
351 |
|
|
352 |
iPlaybackIndex = aIndex;
|
|
353 |
|
|
354 |
// fetch contact name and contact type (mobile, e-mail etc.)
|
|
355 |
// ignore KErrNotFound leave
|
|
356 |
HBufC* contact = NULL;
|
|
357 |
HBufC* type = NULL;
|
|
358 |
TRAPD( err, contact = iTagArray[aIndex]->SpeechItem()->PartialTextL( KNameTrainingIndex ) );
|
|
359 |
if ( err != KErrNone && err != KErrNotFound) User::Leave( err );
|
|
360 |
TRAPD( err2, iTagArray[aIndex]->SpeechItem()->PartialTextL( KExtensionTrainingIndex ) );
|
|
361 |
if ( err2 != KErrNone && err2 != KErrNotFound) User::Leave( err2 );
|
|
362 |
|
|
363 |
// fetch whole tts string
|
|
364 |
const TDesC& text = iTagArray[aIndex]->SpeechItem()->Text();
|
|
365 |
TInt contactIndex;
|
|
366 |
TInt typeIndex;
|
|
367 |
if ( contact && type )
|
|
368 |
{
|
|
369 |
// get contact and type indexes
|
|
370 |
// assume contactIndex is before typeIndex
|
|
371 |
contactIndex = text.Find( *contact );
|
|
372 |
typeIndex = text.Right( text.Length()-contactIndex-contact->Length() ).Find( *type );
|
|
373 |
if ( typeIndex==KErrNotFound )
|
|
374 |
{
|
|
375 |
// if not, change the order
|
|
376 |
typeIndex = text.Find( *type );
|
|
377 |
contactIndex = text.Right( text.Length()-typeIndex-type->Length() ).Find( *contact );
|
|
378 |
contactIndex = type->Length();
|
|
379 |
}
|
|
380 |
else
|
|
381 |
{
|
|
382 |
typeIndex = contact->Length();
|
|
383 |
}
|
|
384 |
// create segments
|
|
385 |
CTtsParsedText* parsedText = CTtsParsedText::NewL();
|
|
386 |
CleanupStack::PushL( parsedText );
|
|
387 |
|
|
388 |
TTtsStyle* contactStyle = new (ELeave) TTtsStyle();
|
|
389 |
CleanupStack::PushL( contactStyle );
|
|
390 |
|
|
391 |
TTtsStyleID* contactStyleId = new (ELeave) TTtsStyleID( 0 );
|
|
392 |
CleanupStack::PushL( contactStyleId );
|
|
393 |
|
|
394 |
TTtsSegment* contactSegment = new (ELeave) TTtsSegment( 0 );
|
|
395 |
CleanupStack::PushL( contactSegment );
|
|
396 |
|
|
397 |
contactStyle->iLanguage = User::Language();
|
|
398 |
*contactStyleId = iTts->AddStyleL( *contactStyle );
|
|
399 |
contactSegment->SetStyleID( *contactStyleId );
|
|
400 |
|
|
401 |
TTtsStyle* typeStyle = new (ELeave) TTtsStyle();
|
|
402 |
CleanupStack::PushL( typeStyle );
|
|
403 |
|
|
404 |
TTtsStyleID* typeStyleId = new (ELeave) TTtsStyleID( 0 );
|
|
405 |
CleanupStack::PushL( typeStyleId );
|
|
406 |
|
|
407 |
TTtsSegment* typeSegment = new (ELeave) TTtsSegment( 0 );
|
|
408 |
CleanupStack::PushL( typeSegment );
|
|
409 |
|
|
410 |
typeStyle->iLanguage = User::Language();
|
|
411 |
*typeStyleId = iTts->AddStyleL( *typeStyle );
|
|
412 |
typeSegment->SetStyleID( *typeStyleId );
|
|
413 |
|
|
414 |
if (contactIndex < typeIndex)
|
|
415 |
{
|
|
416 |
contactSegment->SetTextPtr( text.Mid( contactIndex, contact->Length() ) );
|
|
417 |
typeSegment->SetTextPtr( text.Right( text.Length()-typeIndex ) );
|
|
418 |
parsedText->AddSegmentL( *contactSegment );
|
|
419 |
parsedText->AddSegmentL( *typeSegment );
|
|
420 |
}
|
|
421 |
else
|
|
422 |
{
|
|
423 |
typeSegment->SetTextPtr( text.Mid( typeIndex, type->Length() ) );
|
|
424 |
contactSegment->SetTextPtr( text.Right( text.Length()-contactIndex ) );
|
|
425 |
parsedText->AddSegmentL( *typeSegment );
|
|
426 |
parsedText->AddSegmentL( *contactSegment );
|
|
427 |
}
|
|
428 |
parsedText->SetTextL( text );
|
|
429 |
iTts->OpenAndPlayParsedTextL( *parsedText );
|
|
430 |
|
|
431 |
CleanupStack::PopAndDestroy( typeSegment );
|
|
432 |
CleanupStack::PopAndDestroy( typeStyleId );
|
|
433 |
CleanupStack::PopAndDestroy( typeStyle );
|
|
434 |
CleanupStack::PopAndDestroy( contactSegment );
|
|
435 |
CleanupStack::PopAndDestroy( contactStyleId );
|
|
436 |
CleanupStack::PopAndDestroy( contactStyle );
|
|
437 |
CleanupStack::PopAndDestroy( parsedText );
|
|
438 |
}
|
|
439 |
else
|
|
440 |
{
|
|
441 |
// if there is only one part (contact), play normally
|
|
442 |
iTagArray[aIndex]->SpeechItem()->PlayL( this );
|
|
443 |
}
|
|
444 |
}
|
|
445 |
|
|
446 |
// ----------------------------------------------------------------------------
|
|
447 |
// CPbkInfoViewSindHandler::CancelPlaybackL
|
|
448 |
// Cancels voice tag playback.
|
|
449 |
// ----------------------------------------------------------------------------
|
|
450 |
void CPbkInfoViewSindHandler::CancelPlaybackL()
|
|
451 |
{
|
|
452 |
if( !( iPlaybackIndex > -1 &&
|
|
453 |
iPlaybackIndex < iTagArray.Count() ) )
|
|
454 |
{
|
|
455 |
return;
|
|
456 |
}
|
|
457 |
|
|
458 |
iTagArray[iPlaybackIndex]->SpeechItem()->CancelL();
|
|
459 |
|
|
460 |
iPlaybackIndex = -1;
|
|
461 |
}
|
|
462 |
|
|
463 |
// ----------------------------------------------------------------------------
|
|
464 |
// CPbkInfoViewSindHandler::IsPlaying
|
|
465 |
// Is voice tag playing ongoing.
|
|
466 |
// @return TBool boolean value
|
|
467 |
// ----------------------------------------------------------------------------
|
|
468 |
TBool CPbkInfoViewSindHandler::IsPlaying()
|
|
469 |
{
|
|
470 |
return iPlaybackIndex > -1;
|
|
471 |
}
|
|
472 |
|
|
473 |
// ----------------------------------------------------------------------------
|
|
474 |
// CPbkInfoViewSindHandler::IconIdL
|
|
475 |
// Returns an icon id for the contact field the voice tag is associated with.
|
|
476 |
// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
|
|
477 |
// @return TInt the icon id
|
|
478 |
// ----------------------------------------------------------------------------
|
|
479 |
TInt CPbkInfoViewSindHandler::IconIdL( TInt aIndex )
|
|
480 |
{
|
|
481 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::IconIdL" );
|
|
482 |
|
|
483 |
__ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
|
|
484 |
User::Leave( KErrArgument ) );
|
|
485 |
|
|
486 |
TInt contactId = iTagArray[aIndex]->RRD()
|
|
487 |
->IntArray()->At( KVasContactIdRrdLocation );
|
|
488 |
TInt fieldId = iTagArray[aIndex]->RRD()
|
|
489 |
->IntArray()->At( KVasFieldIdRrdLocation );
|
|
490 |
|
|
491 |
iPbkContactItemField = iPbkContactItem->FindField( fieldId );
|
|
492 |
if ( !iPbkContactItemField )
|
|
493 |
{
|
|
494 |
iPbkContactItemField = FindDefaultField( iPbkContactItem, fieldId );
|
|
495 |
}
|
|
496 |
|
|
497 |
if ( !iPbkContactItemField )
|
|
498 |
{
|
|
499 |
User::Leave( KErrNotFound );
|
|
500 |
}
|
|
501 |
|
|
502 |
return iPbkContactItemField->IconId();
|
|
503 |
}
|
|
504 |
|
|
505 |
// ----------------------------------------------------------------------------
|
|
506 |
// CPbkInfoViewSindHandler::FieldIdL
|
|
507 |
// Returns an field id for the contact field.
|
|
508 |
// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
|
|
509 |
// @return TInt the field id
|
|
510 |
// ----------------------------------------------------------------------------
|
|
511 |
TInt CPbkInfoViewSindHandler::FieldIdL( TInt aIndex )
|
|
512 |
{
|
|
513 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::FieldIdL" );
|
|
514 |
|
|
515 |
__ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
|
|
516 |
User::Leave( KErrArgument ) );
|
|
517 |
|
|
518 |
iPbkHandler->FindContactFieldL( iTagArray[aIndex] );
|
|
519 |
|
|
520 |
return iPbkHandler->FieldIdL();
|
|
521 |
}
|
|
522 |
|
|
523 |
// ----------------------------------------------------------------------------
|
|
524 |
// CPbkInfoViewSindHandler::LabelL
|
|
525 |
// Returns label for the contact field.
|
|
526 |
// @param aIndex index for the voice tag. 0 <= aIndex <= VoiceTagCount() - 1
|
|
527 |
// @return TPtrC the tag label
|
|
528 |
// ----------------------------------------------------------------------------
|
|
529 |
TPtrC CPbkInfoViewSindHandler::LabelL( TInt aIndex )
|
|
530 |
{
|
|
531 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::LabelL" );
|
|
532 |
|
|
533 |
__ASSERT_ALWAYS( aIndex >= 0 && aIndex < VoiceTagCount(),
|
|
534 |
User::Leave( KErrArgument ) );
|
|
535 |
|
|
536 |
iPbkHandler->FindContactFieldL( iTagArray[aIndex] );
|
|
537 |
|
|
538 |
return iPbkHandler->LabelL();
|
|
539 |
}
|
|
540 |
|
|
541 |
// ----------------------------------------------------------------------------
|
|
542 |
// CPbkInfoViewSindHandler::CreateVoiceTagListL
|
|
543 |
// Fetches voice tag list from vas db.
|
|
544 |
// @param aContactId Contact id for the contact whose voice tags are
|
|
545 |
// fetched from vas db.
|
|
546 |
// ----------------------------------------------------------------------------
|
|
547 |
void CPbkInfoViewSindHandler::CreateVoiceTagListL( TInt aContactId )
|
|
548 |
{
|
|
549 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::CreateVoiceTagListL" );
|
|
550 |
|
|
551 |
// Get context
|
|
552 |
TInt err = iContextManager->GetContext( this, KVoiceDialContext );
|
|
553 |
if ( err == KErrNone )
|
|
554 |
{
|
|
555 |
if ( iWait && !iWait->IsStarted() )
|
|
556 |
{
|
|
557 |
// Let's synchronize GetContext-method.
|
|
558 |
iWait->Start();
|
|
559 |
if ( !iContext )
|
|
560 |
{
|
|
561 |
// the context getting has failed.
|
|
562 |
// cannot continue
|
|
563 |
User::Leave( KErrGeneral );
|
|
564 |
}
|
|
565 |
|
|
566 |
}
|
|
567 |
else
|
|
568 |
{
|
|
569 |
User::Leave( KErrGeneral );
|
|
570 |
}
|
|
571 |
}
|
|
572 |
else
|
|
573 |
{
|
|
574 |
User::Leave( KErrGeneral );
|
|
575 |
}
|
|
576 |
|
|
577 |
iErr = iTagManager->GetTagList( this, iContext,
|
|
578 |
aContactId, KVasContactIdRrdLocation );
|
|
579 |
|
|
580 |
if( !iErr )
|
|
581 |
{
|
|
582 |
// Let's synchronize the GetTagList call
|
|
583 |
if ( iWait && !iWait->IsStarted() )
|
|
584 |
{
|
|
585 |
iWait->Start();
|
|
586 |
RUBY_DEBUG1( "CPbkInfoViewSindHandler::CreateVoiceTagListL - iErr=[%d]", iErr );
|
|
587 |
}
|
|
588 |
else
|
|
589 |
{
|
|
590 |
User::Leave( KErrGeneral );
|
|
591 |
}
|
|
592 |
}
|
|
593 |
}
|
|
594 |
|
|
595 |
// ----------------------------------------------------------------------------
|
|
596 |
// CPbkInfoViewSindHandler::CreatePopupArrayL
|
|
597 |
// Creates an array for popups in info view list.
|
|
598 |
// @param aContactId Contact id for the contact whose voice tags are
|
|
599 |
// fetched from vas db.
|
|
600 |
// @return TInt KErrNone on success
|
|
601 |
// ----------------------------------------------------------------------------
|
|
602 |
void CPbkInfoViewSindHandler::CreatePopupArrayL()
|
|
603 |
{
|
|
604 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::CreatePopupArrayL" );
|
|
605 |
|
|
606 |
// Create popup text for each voice tag
|
|
607 |
for( TInt i( 0 ); i < iTagArray.Count(); i++ )
|
|
608 |
{
|
|
609 |
HBufC* voiceTag( iTagArray[i]->SpeechItem()->RawText().AllocLC() );
|
|
610 |
|
|
611 |
HBufC* resourceText;
|
|
612 |
TInt index = voiceTag->Des().Find( KTagExtensionSeparator );
|
|
613 |
// Checks whether this a voice tag without an extension
|
|
614 |
if( index == KErrNotFound )
|
|
615 |
{
|
|
616 |
resourceText = StringLoader::LoadLC( R_INFOVIEW_POPUP_CONTACT );
|
|
617 |
}
|
|
618 |
else
|
|
619 |
{
|
|
620 |
resourceText = StringLoader::LoadLC( R_INFOVIEW_POPUP_GENERAL );
|
|
621 |
}
|
|
622 |
|
|
623 |
// Remove name separators
|
|
624 |
while( (index = voiceTag->Des().Find( KTagNameSeparator ) )
|
|
625 |
!= KErrNotFound )
|
|
626 |
{
|
|
627 |
voiceTag->Des().Replace( index, KTagSeparatorLength,
|
|
628 |
KSpace );
|
|
629 |
}
|
|
630 |
// Remove extension separator
|
|
631 |
index = voiceTag->Des().Find( KTagExtensionSeparator );
|
|
632 |
if( index != KErrNotFound )
|
|
633 |
{
|
|
634 |
voiceTag->Des().Replace( index, KTagSeparatorLength,
|
|
635 |
KSpace );
|
|
636 |
}
|
|
637 |
voiceTag->Des().TrimAll();
|
|
638 |
|
|
639 |
TName popupText;
|
|
640 |
// Insert voiceTag to resourceText to create popupText
|
|
641 |
StringLoader::Format( popupText, *resourceText, -1, *voiceTag );
|
|
642 |
|
|
643 |
iPopupArray.AppendL( popupText.AllocL() );
|
|
644 |
|
|
645 |
//CleanupStack::Pop( popupText );
|
|
646 |
CleanupStack::PopAndDestroy( resourceText );
|
|
647 |
CleanupStack::PopAndDestroy( voiceTag );
|
|
648 |
}
|
|
649 |
}
|
|
650 |
|
|
651 |
// ----------------------------------------------------------------------------
|
|
652 |
// CPbkInfoViewSindHandler::GetContextCompleted
|
|
653 |
//
|
|
654 |
// ----------------------------------------------------------------------------
|
|
655 |
void CPbkInfoViewSindHandler::GetContextCompleted( MNssContext* aContext,
|
|
656 |
TInt aErrorCode )
|
|
657 |
{
|
|
658 |
if( aErrorCode == KErrNone )
|
|
659 |
{
|
|
660 |
// ownership is transferred
|
|
661 |
iContext = aContext;
|
|
662 |
|
|
663 |
// if the iWait has been started, the completion of GetContext method
|
|
664 |
// has been synchronized in VoiceTagField - method. Otherwise
|
|
665 |
// the completion has happened in background.
|
|
666 |
if ( iWait && iWait->IsStarted() )
|
|
667 |
{
|
|
668 |
iWait->AsyncStop();
|
|
669 |
}
|
|
670 |
}
|
|
671 |
else
|
|
672 |
{
|
|
673 |
iErr = aErrorCode;
|
|
674 |
// if the get context has been synchronized:
|
|
675 |
if ( iWait && iWait->IsStarted() )
|
|
676 |
{
|
|
677 |
iWait->AsyncStop();
|
|
678 |
}
|
|
679 |
}
|
|
680 |
}
|
|
681 |
|
|
682 |
// ----------------------------------------------------------------------------
|
|
683 |
// CPbkInfoViewSindHandler::GetContextListCompleted
|
|
684 |
// Callback, getting of contexts has completed successfully.
|
|
685 |
// ----------------------------------------------------------------------------
|
|
686 |
void CPbkInfoViewSindHandler::GetContextListCompleted(
|
|
687 |
MNssContextListArray* /*aContextList*/, TInt /*aErrorCode*/ )
|
|
688 |
{
|
|
689 |
// never comes here, defined as pure virtual in MNssGetContextClient.
|
|
690 |
}
|
|
691 |
|
|
692 |
// ----------------------------------------------------------------------------
|
|
693 |
// CPbkInfoViewSindHandler::GetTagListCompleted
|
|
694 |
// Callback, getting of tags has completed successfully.
|
|
695 |
// ----------------------------------------------------------------------------
|
|
696 |
void CPbkInfoViewSindHandler::GetTagListCompleted( MNssTagListArray* aTagList,
|
|
697 |
TInt aErrorCode )
|
|
698 |
{
|
|
699 |
RUBY_DEBUG0( "CPbkInfoViewSindHandler::GetTagListCompleted" );
|
|
700 |
|
|
701 |
if( aErrorCode == KErrNone )
|
|
702 |
{
|
|
703 |
// Fill the tag array
|
|
704 |
for( TInt i( 0 ); i < aTagList->Count(); i++ )
|
|
705 |
{
|
|
706 |
MNssTag* tag = aTagList->At( i );
|
|
707 |
|
|
708 |
TInt fieldId = tag->RRD()->IntArray()->At( KVasFieldIdRrdLocation );
|
|
709 |
|
|
710 |
// Get pointer to CPbkContactItem-object from thread local storage
|
|
711 |
CPbkContactItem* pbkContactItem =
|
|
712 |
static_cast<CPbkContactItem*>( Dll::Tls() );
|
|
713 |
|
|
714 |
TPbkContactItemField* field = pbkContactItem->FindField( fieldId );
|
|
715 |
if ( !field )
|
|
716 |
{
|
|
717 |
field = FindDefaultField( pbkContactItem, fieldId );
|
|
718 |
}
|
|
719 |
|
|
720 |
// Add only tags that have field in phonebook
|
|
721 |
if ( field )
|
|
722 |
{
|
|
723 |
iTagArray.Append( tag );
|
|
724 |
}
|
|
725 |
else
|
|
726 |
{
|
|
727 |
// If some tag is missing then we don't want to show anything
|
|
728 |
iTagArray.ResetAndDestroy();
|
|
729 |
break;
|
|
730 |
}
|
|
731 |
}
|
|
732 |
|
|
733 |
aTagList->Reset();
|
|
734 |
delete aTagList;
|
|
735 |
|
|
736 |
iTagArray.Sort( TLinearOrder<MNssTag>( CPbkInfoViewSindHandler::Compare ) );
|
|
737 |
|
|
738 |
// Continue with CreateVoiceTagListL-method.
|
|
739 |
if ( iWait && iWait->IsStarted() )
|
|
740 |
{
|
|
741 |
iWait->AsyncStop();
|
|
742 |
}
|
|
743 |
}
|
|
744 |
|
|
745 |
else // aErrorCode != KErrNone
|
|
746 |
{
|
|
747 |
iErr = aErrorCode;
|
|
748 |
if ( iWait && iWait->IsStarted() )
|
|
749 |
{
|
|
750 |
iWait->AsyncStop();
|
|
751 |
}
|
|
752 |
}
|
|
753 |
}
|
|
754 |
|
|
755 |
// -----------------------------------------------------------------------------
|
|
756 |
// CPbkInfoViewSindHandler::HandlePlayComplete
|
|
757 |
// Callback, playback has been completed.
|
|
758 |
// -----------------------------------------------------------------------------
|
|
759 |
//
|
|
760 |
void CPbkInfoViewSindHandler::HandlePlayComplete( TNssPlayResult /*aResult*/ )
|
|
761 |
{
|
|
762 |
iPlaybackIndex = -1;
|
|
763 |
}
|
|
764 |
|
|
765 |
|
|
766 |
// -----------------------------------------------------------------------------
|
|
767 |
// Calls CompareL and catches possible leaves
|
|
768 |
// -----------------------------------------------------------------------------
|
|
769 |
//
|
|
770 |
TInt CPbkInfoViewSindHandler::Compare( const MNssTag& aTag1, const MNssTag& aTag2 )
|
|
771 |
{
|
|
772 |
TInt result = 0;
|
|
773 |
|
|
774 |
TRAP_IGNORE( result = CompareL( aTag1, aTag2 ) );
|
|
775 |
|
|
776 |
return result;
|
|
777 |
}
|
|
778 |
|
|
779 |
// -----------------------------------------------------------------------------
|
|
780 |
// Compares two voice tags and decides which one should be displayed first in
|
|
781 |
// info view list. Used in the sorting of voice tags.
|
|
782 |
// @param aTag1 A voice tag
|
|
783 |
// @param aTag2 A voice tag
|
|
784 |
// @return TInt -1 if aTag1 should be displayed first, 1 if aTag2 should be
|
|
785 |
// displayed first, 0 otherwise.
|
|
786 |
// -----------------------------------------------------------------------------
|
|
787 |
//
|
|
788 |
TInt CPbkInfoViewSindHandler::CompareL( const MNssTag& aTag1, const MNssTag& aTag2 )
|
|
789 |
{
|
|
790 |
RUBY_DEBUG_BLOCK( "CPbkInfoViewSindHandler::GetTagListCompleted" );
|
|
791 |
|
|
792 |
MNssTag& tag1 = const_cast<MNssTag&>( aTag1 );
|
|
793 |
MNssTag& tag2 = const_cast<MNssTag&>( aTag2 );
|
|
794 |
|
|
795 |
TInt tagType1 = tag1.RRD()->IntArray()->At( KVasTagTypeRrdLocation );
|
|
796 |
TInt tagType2 = tag2.RRD()->IntArray()->At( KVasTagTypeRrdLocation );
|
|
797 |
|
|
798 |
// Check if one of the tags is for nickname
|
|
799 |
if( ( tagType1 == ETagTypeName || tagType1 == ETagTypeCompanyName ) &&
|
|
800 |
tagType2 == ETagTypeNickName )
|
|
801 |
{
|
|
802 |
return -1;
|
|
803 |
}
|
|
804 |
if( ( tagType2 == ETagTypeName || tagType2 == ETagTypeCompanyName ) &&
|
|
805 |
tagType1 == ETagTypeNickName )
|
|
806 |
{
|
|
807 |
return 1;
|
|
808 |
}
|
|
809 |
|
|
810 |
TInt fieldId1 = tag1.RRD()->IntArray()->At( KVasFieldIdRrdLocation );
|
|
811 |
TInt fieldId2 = tag2.RRD()->IntArray()->At( KVasFieldIdRrdLocation );
|
|
812 |
|
|
813 |
// Get pointer to CPbkContactItem-object from thread local storage
|
|
814 |
CPbkContactItem* pbkContactItem =
|
|
815 |
static_cast<CPbkContactItem*>( Dll::Tls() );
|
|
816 |
|
|
817 |
TPbkContactItemField* field1 = pbkContactItem->FindField( fieldId1 );
|
|
818 |
if ( !field1 )
|
|
819 |
{
|
|
820 |
field1 = FindDefaultField( pbkContactItem, fieldId1 );
|
|
821 |
}
|
|
822 |
TPbkContactItemField* field2 = pbkContactItem->FindField( fieldId2 );
|
|
823 |
if ( !field2 )
|
|
824 |
{
|
|
825 |
field2 = FindDefaultField( pbkContactItem, fieldId2 );
|
|
826 |
}
|
|
827 |
|
|
828 |
if ( !field1 || !field2 )
|
|
829 |
{
|
|
830 |
User::Leave( KErrNotFound );
|
|
831 |
}
|
|
832 |
|
|
833 |
TBool noExtension1 = EFalse;
|
|
834 |
TBool noExtension2 = EFalse;
|
|
835 |
|
|
836 |
HBufC* label = tag1.SpeechItem()->RawText().AllocLC();
|
|
837 |
label->Des().TrimAll();
|
|
838 |
|
|
839 |
TInt index = label->Des().Find( KTagExtensionSeparator );
|
|
840 |
// Checks whether this a voice tag without extension
|
|
841 |
if( index == KErrNotFound )
|
|
842 |
{
|
|
843 |
noExtension1 = ETrue;
|
|
844 |
}
|
|
845 |
|
|
846 |
CleanupStack::PopAndDestroy( label );
|
|
847 |
|
|
848 |
label = tag2.SpeechItem()->RawText().AllocLC();
|
|
849 |
label->Des().TrimAll();
|
|
850 |
|
|
851 |
index = label->Des().Find( KTagExtensionSeparator );
|
|
852 |
// Checks whether this a voice tag without extension
|
|
853 |
if( index == KErrNotFound )
|
|
854 |
{
|
|
855 |
noExtension2 = ETrue;
|
|
856 |
}
|
|
857 |
|
|
858 |
CleanupStack::PopAndDestroy( label );
|
|
859 |
|
|
860 |
if( noExtension1 && !noExtension2 )
|
|
861 |
{
|
|
862 |
return -1;
|
|
863 |
}
|
|
864 |
else if ( !noExtension1 && noExtension2 )
|
|
865 |
{
|
|
866 |
return 1;
|
|
867 |
}
|
|
868 |
|
|
869 |
// // compare the two neighbors
|
|
870 |
// TInt ret = field1->Compare( *field2 );
|
|
871 |
//
|
|
872 |
// // Sorting for normal call, sms, and multimedia msg fields
|
|
873 |
// if ( ret == 0)
|
|
874 |
// {
|
|
875 |
// TInt actionId1 = tag1.RRD()->IntArray()->At( KVasExtensionRrdLocation );
|
|
876 |
// TInt actionId2 = tag2.RRD()->IntArray()->At( KVasExtensionRrdLocation );
|
|
877 |
//
|
|
878 |
// if ( actionId1 != actionId2 )
|
|
879 |
// {
|
|
880 |
// if ( actionId1 < actionId2 )
|
|
881 |
// {
|
|
882 |
// return -1;
|
|
883 |
// }
|
|
884 |
// return 1;
|
|
885 |
// }
|
|
886 |
// }
|
|
887 |
//
|
|
888 |
// return ret;
|
|
889 |
TInt cmdId1 = tag1.RRD()->IntArray()->At( KVasExtensionCommandRrdLocation );
|
|
890 |
TInt cmdId2 = tag2.RRD()->IntArray()->At( KVasExtensionCommandRrdLocation );
|
|
891 |
return ( RemapCommand( cmdId1 ) - RemapCommand( cmdId2 ));
|
|
892 |
}
|
|
893 |
|
|
894 |
// -----------------------------------------------------------------------------
|
|
895 |
// Tries to find a default contact item field
|
|
896 |
// @param aContactItem A contact item
|
|
897 |
// @param aFieldId A field to search
|
|
898 |
// @return TPbkContactItemField* Default field if found, otherwise NULL
|
|
899 |
// -----------------------------------------------------------------------------
|
|
900 |
//
|
|
901 |
TPbkContactItemField* CPbkInfoViewSindHandler::FindDefaultField
|
|
902 |
( CPbkContactItem* aContactItem, TInt aFieldId )
|
|
903 |
{
|
|
904 |
TPbkContactItemField* field = NULL;
|
|
905 |
|
|
906 |
if ( aFieldId == EPbkFieldIdPhoneNumberVideo )
|
|
907 |
{
|
|
908 |
field = aContactItem->DefaultVideoNumberField();
|
|
909 |
}
|
|
910 |
else if ( aFieldId == EPbkFieldIdEmailAddress )
|
|
911 |
{
|
|
912 |
field = aContactItem->DefaultEmailField();
|
|
913 |
}
|
|
914 |
else if ( aFieldId == EPbkFieldIdVOIP )
|
|
915 |
{
|
|
916 |
field = aContactItem->DefaultVoipField();
|
|
917 |
}
|
|
918 |
|
|
919 |
return field;
|
|
920 |
}
|
|
921 |
|
|
922 |
// End of file
|