|
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: Pbk info view dialog. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <AknIconArray.h> // for GulArray |
|
22 #include <bldvariant.hrh> |
|
23 #include "pbkinfoviewdialog.h" |
|
24 #include "pbkinfoviewutil.h" |
|
25 #include "pbkinfoviewsindhandler.h" |
|
26 #include "pbkinfoviewdefines.h" |
|
27 #include <pbkinfoview.rsg> |
|
28 #include "pbkinfoview.rh" |
|
29 #include <e32property.h> // RProperty |
|
30 #include <PSVariables.h> // Property values |
|
31 #include <ctsydomainpskeys.h> |
|
32 |
|
33 #include "rubydebug.h" |
|
34 |
|
35 #include <csxhelp/vc.hlp.hrh> // for help text id |
|
36 #include <eikmenub.h> // CEikMenuBar |
|
37 #include <PbkIconId.hrh> // Phonebook icon ids |
|
38 #include <aknnotewrappers.h> // For information note |
|
39 #include <StringLoader.h> |
|
40 |
|
41 #include <MPbk2FieldPropertyArray.h> |
|
42 #include <VPbkEng.rsg> |
|
43 #include <CPbk2StoreConfiguration.h> |
|
44 #include <CVPbkContactStoreUriArray.h> |
|
45 #include <CVPbkContactManager.h> |
|
46 #include <VPbkContactStoreUris.h> |
|
47 #include <CVPbkFieldTypeRefsList.h> |
|
48 #include <CPbk2IconFactory.h> |
|
49 #include <Pbk2FieldPropertiesFactory.h> |
|
50 #include <MPbk2FieldProperty.h> |
|
51 #include <TVPbkContactStoreUriPtr.h> |
|
52 #include <PbkFields.hrh> |
|
53 |
|
54 #include <MPbk2FieldPropertyArray2.h> |
|
55 #include <MPbk2FieldProperty2.h> |
|
56 #include <MPbk2FieldProperty.h> |
|
57 |
|
58 const TUint KFieldIds[] = |
|
59 { |
|
60 R_VPBK_FIELD_TYPE_LANDPHONEGEN, |
|
61 R_VPBK_FIELD_TYPE_MOBILEPHONEGEN, |
|
62 R_VPBK_FIELD_TYPE_VIDEONUMBERGEN, |
|
63 R_VPBK_FIELD_TYPE_VOIPGEN, |
|
64 R_VPBK_FIELD_TYPE_EMAILGEN, |
|
65 R_VPBK_FIELD_TYPE_IMPP |
|
66 }; |
|
67 |
|
68 NONSHARABLE_CLASS( TXspIconHelper ) |
|
69 { |
|
70 public: |
|
71 TXspIconHelper( TInt aIndex, const TDesC& aLable ); |
|
72 TDesC& LableText(); |
|
73 TInt Index(); |
|
74 private: |
|
75 TBuf<KPbkSIPMaxLength> iLable; |
|
76 TInt iIndex; |
|
77 }; |
|
78 |
|
79 TXspIconHelper::TXspIconHelper( TInt aIndex, const TDesC& aLable ): |
|
80 iLable(aLable),iIndex(aIndex) |
|
81 { |
|
82 } |
|
83 |
|
84 inline TInt TXspIconHelper::Index() |
|
85 { |
|
86 return iIndex; |
|
87 } |
|
88 inline TDesC& TXspIconHelper::LableText() |
|
89 { |
|
90 return iLable; |
|
91 } |
|
92 |
|
93 // ============================ MEMBER FUNCTIONS =============================== |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CPbkInfoViewDialog::NewL |
|
97 // |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 CPbkInfoViewDialog* CPbkInfoViewDialog::NewL( TInt aContactId ) |
|
101 { |
|
102 RUBY_DEBUG_BLOCK( "CPbkInfoViewDialog::NewL" ); |
|
103 |
|
104 CPbkInfoViewDialog* self = new ( ELeave ) CPbkInfoViewDialog( aContactId ); |
|
105 CleanupStack::PushL(self); |
|
106 self->ConstructL(); |
|
107 CleanupStack::Pop(self); |
|
108 |
|
109 return self; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CPbkInfoViewDialog::CPbkInfoViewDialog |
|
114 // |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 CPbkInfoViewDialog::CPbkInfoViewDialog( TInt aContactId ) |
|
118 { |
|
119 iContactId = aContactId; |
|
120 |
|
121 if( aContactId == KVoiceTaglessContactId ) |
|
122 { |
|
123 iVoiceTaglessContact = ETrue; |
|
124 } |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CPbkInfoViewDialog::ConstructL |
|
129 // |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CPbkInfoViewDialog::ConstructL() |
|
133 { |
|
134 CAknDialog::ConstructL( R_INFOVIEW_DIALOG_MENU ); |
|
135 |
|
136 // Hide tabs |
|
137 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
138 if ( statusPane && statusPane->PaneCapabilities |
|
139 ( TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() ) |
|
140 { |
|
141 iNaviPane = (CAknNavigationControlContainer*) statusPane->ControlL |
|
142 ( TUid::Uid(EEikStatusPaneUidNavi ) ); |
|
143 iNaviPane->PushDefaultL(); |
|
144 } |
|
145 |
|
146 iAvkonAppUi->SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyLong ); |
|
147 |
|
148 // Get the previous title so it can be restored |
|
149 iStatusPaneHandler = CStatusPaneHandler::NewL( iAvkonAppUi ); |
|
150 iStatusPaneHandler->StoreOriginalTitleL(); |
|
151 |
|
152 iPopupController = CAknInfoPopupNoteController::NewL(); |
|
153 |
|
154 iResHandler = CPbkInfoViewResHandler::NewL(); |
|
155 |
|
156 iSindHandler = CPbkInfoViewSindHandler::NewL( iContactId ); |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CPbkInfoViewDialog::~CPbkInfoViewDialog() |
|
161 // Destructor. |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 CPbkInfoViewDialog::~CPbkInfoViewDialog() |
|
165 { |
|
166 delete iStatusPaneHandler; |
|
167 iStatusPaneHandler = NULL; |
|
168 delete iPopupController; |
|
169 iPopupController = NULL; |
|
170 delete iResHandler; |
|
171 iResHandler = NULL; |
|
172 delete iSindHandler; |
|
173 iSindHandler = NULL; |
|
174 |
|
175 if ( iAvkonAppUi ) |
|
176 { |
|
177 iAvkonAppUi->RemoveFromStack( this ); |
|
178 } |
|
179 |
|
180 // Restore tabs |
|
181 if ( iNaviPane ) |
|
182 { |
|
183 iNaviPane->Pop(); |
|
184 } |
|
185 |
|
186 iXspIconHelper.Close(); |
|
187 } |
|
188 |
|
189 //------------------------------------------------------------------------------ |
|
190 // CPbkInfoViewDialog::ExecuteLD |
|
191 // Overrides CAknDialog::ExecuteLD. Checks whether the contact has any voice |
|
192 // tags. If not an info note is displayed. Otherwise calls CAknDialog::ExecuteLD |
|
193 // @param aResourceId The resource ID of the dialog to be loaded |
|
194 // @return see CAknDialog::ExecuteLD |
|
195 //------------------------------------------------------------------------------ |
|
196 // |
|
197 TInt CPbkInfoViewDialog::ExecuteLD( TInt aResourceId ) |
|
198 { |
|
199 // Check whether info view should be shown at all |
|
200 if( iContactId == KVoiceTaglessContactId ) |
|
201 { |
|
202 ShowInformationNoteL( R_INFOVIEW_EMPTY_VIEW_SIM_CONTACT ); |
|
203 delete this; |
|
204 return 0; |
|
205 } |
|
206 else if( iSindHandler->VoiceTagCount() == 0 ) |
|
207 { |
|
208 ShowInformationNoteL( R_INFOVIEW_EMPTY_VIEW ); |
|
209 delete this; |
|
210 return 0; |
|
211 } |
|
212 // Show info view |
|
213 else |
|
214 { |
|
215 return CAknDialog::ExecuteLD( aResourceId ); |
|
216 } |
|
217 } |
|
218 |
|
219 //------------------------------------------------------------------------------ |
|
220 // CPbkInfoViewDialog::FocusChanged (from CCoeControl) |
|
221 //------------------------------------------------------------------------------ |
|
222 // |
|
223 void CPbkInfoViewDialog::FocusChanged( TDrawNow aDrawNow ) |
|
224 { |
|
225 CAknDialog::FocusChanged(aDrawNow); |
|
226 TRAP_IGNORE( iStatusPaneHandler->SetTitleL(R_INFOVIEW_DIALOG_TITLE) ); |
|
227 } |
|
228 //------------------------------------------------------------------------------ |
|
229 // CPbkInfoViewDialog::ActivateL (from CCoeControl) |
|
230 // Called by system when dialog is activated. |
|
231 //------------------------------------------------------------------------------ |
|
232 // |
|
233 void CPbkInfoViewDialog::ActivateL() |
|
234 { |
|
235 CAknDialog::ActivateL(); |
|
236 |
|
237 // This cannot be in ConstructL which is executed before dialog is launched |
|
238 iAvkonAppUi->AddToStackL( this ); |
|
239 } |
|
240 |
|
241 //------------------------------------------------------------------------------ |
|
242 // CPbkInfoViewDialog::GetHelpContext |
|
243 // Method to get context sensitive help topic. |
|
244 // @param aContext Help topic to open. |
|
245 //------------------------------------------------------------------------------ |
|
246 // |
|
247 void CPbkInfoViewDialog::GetHelpContext( TCoeHelpContext& aContext ) const |
|
248 { |
|
249 aContext.iMajor = TUid::Uid( PBKINFOVIEW_HELP_UID ); |
|
250 aContext.iContext = KVCINFO_HLP_MAINVIEW; |
|
251 } |
|
252 |
|
253 //------------------------------------------------------------------------------ |
|
254 // CPbkInfoViewDialog::ProcessCommandL |
|
255 // Handles menu events. |
|
256 // @param aCommandId Command id. |
|
257 //------------------------------------------------------------------------------ |
|
258 // |
|
259 void CPbkInfoViewDialog::ProcessCommandL( TInt aCommandId ) |
|
260 { |
|
261 HideMenu(); |
|
262 |
|
263 switch ( aCommandId ) |
|
264 { |
|
265 case EInfoViewMenuCmdPlay: |
|
266 { |
|
267 if ( IsCallActive() ) |
|
268 { |
|
269 CallInProgressNoteL(); |
|
270 } |
|
271 else |
|
272 { |
|
273 iSindHandler->PlayVoiceCommandL( CurrentItemIndex() ); |
|
274 } |
|
275 |
|
276 break; |
|
277 } |
|
278 case EInfoViewMenuCmdHelp: |
|
279 { |
|
280 iAvkonAppUi->ProcessCommandL( EAknCmdHelp ); |
|
281 break; |
|
282 } |
|
283 case EInfoViewMenuCmdExit: |
|
284 { |
|
285 iAvkonAppUi->ProcessCommandL( EAknCmdExit ); |
|
286 break; |
|
287 } |
|
288 case EAknCmdExit: |
|
289 case EEikCmdExit: |
|
290 { |
|
291 // |
|
292 // Exit dialog |
|
293 // |
|
294 // CEikAppUi::ProcessCommandL starts CAknAppShutter that |
|
295 // closes all dialogs and finally calling application. Before |
|
296 // dialog is closed (deleted) it's OkToExitL(EEikBidCancel) |
|
297 // is called. EEikBidCancel means OkToExitL must silently |
|
298 // save and return ETrue. |
|
299 // |
|
300 iAvkonAppUi->ProcessCommandL( EAknCmdExit ); |
|
301 |
|
302 break; |
|
303 } |
|
304 |
|
305 default: |
|
306 { |
|
307 break; |
|
308 } |
|
309 } |
|
310 } |
|
311 |
|
312 |
|
313 // ---------------------------------------------------------------------------- |
|
314 // CPbkInfoViewDialog::IsCallActive |
|
315 // ---------------------------------------------------------------------------- |
|
316 // |
|
317 TBool CPbkInfoViewDialog::IsCallActive() |
|
318 { |
|
319 TBool callActive( EFalse ); |
|
320 TInt state( 0 ); |
|
321 TInt err = RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, |
|
322 state ); |
|
323 |
|
324 // note! errors are handled as a call is active |
|
325 if( err || state == EPSCTsyCallStateConnected |
|
326 || state == EPSCTsyCallStateAlerting |
|
327 || state == EPSCTsyCallStateRinging |
|
328 || state == EPSCTsyCallStateDialling |
|
329 || state == EPSCTsyCallStateAnswering ) |
|
330 { |
|
331 callActive = ETrue; |
|
332 } |
|
333 else |
|
334 { |
|
335 TInt callType( 0 ); |
|
336 TInt err = RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallType, |
|
337 callType ); |
|
338 if ( err || callType == EPSCTsyCallTypeH324Multimedia ) |
|
339 { |
|
340 callActive = ETrue; |
|
341 } |
|
342 } |
|
343 |
|
344 return callActive; |
|
345 } |
|
346 |
|
347 // ---------------------------------------------------------------------------- |
|
348 // CPbkInfoViewDialog::CallInProgressNoteL |
|
349 // ---------------------------------------------------------------------------- |
|
350 // |
|
351 void CPbkInfoViewDialog::CallInProgressNoteL() |
|
352 { |
|
353 HBufC* text = StringLoader::LoadLC( R_TEXT_CALL_IN_PROGRESS ); |
|
354 CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue ); |
|
355 note->ExecuteLD( *text ); |
|
356 CleanupStack::PopAndDestroy( text ); |
|
357 } |
|
358 |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // CPbkInfoViewDialog::OkToExitL |
|
362 // Called by framework before exiting the dialog. |
|
363 // @param aButtonId Button id. |
|
364 // @return ETrue to exit\ EFalse to not to exit. |
|
365 // ----------------------------------------------------------------------------- |
|
366 // |
|
367 TBool CPbkInfoViewDialog::OkToExitL( TInt aButtonId ) |
|
368 { |
|
369 if( iSindHandler->IsPlaying() ) |
|
370 { |
|
371 iSindHandler->CancelPlaybackL(); |
|
372 } |
|
373 |
|
374 switch ( aButtonId ) |
|
375 { |
|
376 case EAknSoftkeyBack: |
|
377 { |
|
378 return ETrue; |
|
379 } |
|
380 |
|
381 case EAknSoftkeyClose: |
|
382 case EAknSoftkeyExit: |
|
383 { |
|
384 iAvkonAppUi->ProcessCommandL( EAknCmdExit ); |
|
385 return ETrue; |
|
386 } |
|
387 |
|
388 case EAknSoftkeySelect: // Middle soft key, no exit |
|
389 { |
|
390 if ( IsCallActive() ) |
|
391 { |
|
392 CallInProgressNoteL(); |
|
393 } |
|
394 else |
|
395 { |
|
396 iSindHandler->PlayVoiceCommandL( CurrentItemIndex() ); |
|
397 } |
|
398 |
|
399 return EFalse; |
|
400 } |
|
401 |
|
402 default: |
|
403 { |
|
404 return CAknDialog::OkToExitL( aButtonId ); |
|
405 } |
|
406 } |
|
407 } |
|
408 |
|
409 // ---------------------------------------------------------------------------- |
|
410 // CPbkInfoViewDialog::OfferKeyEventL |
|
411 // Called by framework for key event handling. |
|
412 // ---------------------------------------------------------------------------- |
|
413 // |
|
414 TKeyResponse CPbkInfoViewDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
415 TEventCode aType ) |
|
416 { |
|
417 if ( aType == EEventKey ) |
|
418 { |
|
419 switch ( aKeyEvent.iCode ) |
|
420 { |
|
421 case EKeyEscape: // Framework calls this when dialog must shut |
|
422 { |
|
423 return CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
424 } |
|
425 |
|
426 case EKeyUpArrow: |
|
427 case EKeyDownArrow: |
|
428 { |
|
429 CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
430 if( iSindHandler->VoiceTagCount() > 0 ) |
|
431 { |
|
432 ShowPopupL(); |
|
433 } |
|
434 return EKeyWasConsumed; |
|
435 } |
|
436 |
|
437 default: |
|
438 break; |
|
439 } |
|
440 } |
|
441 |
|
442 return CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
443 } |
|
444 |
|
445 // ---------------------------------------------------------------------------- |
|
446 // CPbkInfoViewDialog::HandleResourceChange |
|
447 // Called when display resolution changes. |
|
448 // ---------------------------------------------------------------------------- |
|
449 // |
|
450 void CPbkInfoViewDialog::HandleResourceChange( TInt aType ) |
|
451 { |
|
452 // Handle change in layout orientation |
|
453 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
454 { |
|
455 TRect mainPaneRect; |
|
456 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
457 mainPaneRect ); |
|
458 SetRect( mainPaneRect ); |
|
459 //iListBox->SetSize( mainPaneRect.Size() ); |
|
460 iListBox->SetSize( mainPaneRect.Size() ); |
|
461 CCoeControl::HandleResourceChange( aType ); |
|
462 DrawDeferred(); |
|
463 } |
|
464 else |
|
465 { |
|
466 CCoeControl::HandleResourceChange( aType ); |
|
467 } |
|
468 } |
|
469 |
|
470 // ---------------------------------------------------------------------------- |
|
471 // CPbkInfoViewDialog::PostLayoutDynInitL |
|
472 // Called by framework after dialog is shown. |
|
473 // ---------------------------------------------------------------------------- |
|
474 // |
|
475 void CPbkInfoViewDialog::PostLayoutDynInitL() |
|
476 { |
|
477 } |
|
478 |
|
479 // ---------------------------------------------------------------------------- |
|
480 // CPbkInfoViewDialog::PreLayoutDynInitL |
|
481 // Called by framework before dialog is shown. |
|
482 // ---------------------------------------------------------------------------- |
|
483 // |
|
484 void CPbkInfoViewDialog::PreLayoutDynInitL() |
|
485 { |
|
486 RUBY_DEBUG_BLOCK( "CPbkInfoViewDialog::PreLayoutDynInitL" ); |
|
487 |
|
488 iListBox = ( CAknDoubleGraphicStyleListBox* ) ControlOrNull ( EInfoViewDialogList ); |
|
489 |
|
490 __ASSERT_ALWAYS( iListBox, TPbkInfoViewUtil::Panic( KErrGeneral ) ); |
|
491 |
|
492 iListBox->SetListBoxObserver( this ); |
|
493 iListBox->CreateScrollBarFrameL( ETrue ); |
|
494 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
495 CEikScrollBarFrame::EAuto ); |
|
496 iListBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue ); |
|
497 |
|
498 TDesC* des; |
|
499 // Set empty list text |
|
500 if( iVoiceTaglessContact ) |
|
501 { |
|
502 des = StringLoader::LoadLC( R_INFOVIEW_EMPTY_VIEW_SIM_CONTACT ); |
|
503 iListBox->View()->SetListEmptyTextL( *des ); |
|
504 } |
|
505 else |
|
506 { |
|
507 des = StringLoader::LoadLC( R_INFOVIEW_EMPTY_VIEW ); |
|
508 iListBox->View()->SetListEmptyTextL( *des ); |
|
509 } |
|
510 CleanupStack::PopAndDestroy( des ); |
|
511 |
|
512 // Set icons |
|
513 |
|
514 CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray( KDefaultArraySize ); |
|
515 CleanupStack::PushL( icons ); |
|
516 |
|
517 CreateFieldIconsL( icons ); |
|
518 |
|
519 CleanupStack::Pop( icons ); |
|
520 |
|
521 CreateListBoxItemsL(); |
|
522 |
|
523 iListBox->UpdateScrollBarsL(); |
|
524 iListBox->ScrollBarFrame()->MoveVertThumbTo( 0 ); |
|
525 |
|
526 iStatusPaneHandler->SetTitleL( R_INFOVIEW_DIALOG_TITLE ); |
|
527 |
|
528 UpdateCbaL( R_SOFTKEYS_OPTIONS_BACK__PLAY ); |
|
529 } |
|
530 |
|
531 // ----------------------------------------------------------------------------- |
|
532 // CPbkInfoViewDialog::DynInitMenuPaneL |
|
533 // Called by framework before menu is shown. |
|
534 // @param aResourceId Menu resource id. |
|
535 // @param aMenuPane Pointer to the menu. |
|
536 // ----------------------------------------------------------------------------- |
|
537 // |
|
538 void CPbkInfoViewDialog::DynInitMenuPaneL( TInt aResourceID, |
|
539 CEikMenuPane* aMenuPane ) |
|
540 { |
|
541 if ( aResourceID == R_INFOVIEW_DIALOG_MENU_PANE ) |
|
542 { |
|
543 // No play function in menu if there are no voice tags |
|
544 if( iSindHandler->VoiceTagCount() == 0 ) |
|
545 { |
|
546 aMenuPane->SetItemDimmed( EInfoViewMenuCmdPlay, ETrue ); |
|
547 } |
|
548 } |
|
549 } |
|
550 |
|
551 // ----------------------------------------------------------------------------- |
|
552 // CPbkInfoViewDialog::IconIndex |
|
553 // Returns TInfoViewDialogIconIndex enumeration icon index. |
|
554 // @param aIconId enumeration TPbkIconId from PbkIconId.hrh. |
|
555 // @return TInt Icon index. |
|
556 // ----------------------------------------------------------------------------- |
|
557 // |
|
558 TInt CPbkInfoViewDialog::IconIndex( TInt aIconId, TInt aTagIndex ) |
|
559 { |
|
560 TInt iconIndex; |
|
561 |
|
562 switch ( aIconId ) |
|
563 { |
|
564 case EPbkqgn_prop_nrtyp_mobile: |
|
565 iconIndex = EIconIndexMobile; |
|
566 break; |
|
567 case EPbkqgn_prop_nrtyp_phone: |
|
568 iconIndex = EIconIndexPhone; |
|
569 break; |
|
570 case EPbkqgn_prop_nrtyp_video: |
|
571 iconIndex = EIconIndexVideo; |
|
572 break; |
|
573 case EPbkqgn_prop_nrtyp_email: |
|
574 iconIndex = EIconIndexEmail; |
|
575 break; |
|
576 case EPbkqgn_prop_nrtyp_voip: |
|
577 iconIndex = EIconIndexVoip; |
|
578 if ( iSindHandler->FieldIdL( aTagIndex ) == EPbkFieldIdXsp ) |
|
579 { |
|
580 for ( TInt i=0; i<iXspIconHelper.Count();i++) |
|
581 { |
|
582 if ( !iXspIconHelper[i].LableText().Compare(iSindHandler->LabelL(aTagIndex)) ) |
|
583 { |
|
584 iconIndex = iXspIconHelper[i].Index(); |
|
585 } |
|
586 } |
|
587 } |
|
588 break; |
|
589 default: |
|
590 iconIndex = EIconIndexPhone; |
|
591 break; |
|
592 } |
|
593 |
|
594 return iconIndex; |
|
595 } |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CPbkInfoViewDialog::CreateListBoxItemsL |
|
599 // Creates listbox items. |
|
600 // ----------------------------------------------------------------------------- |
|
601 // |
|
602 void CPbkInfoViewDialog::CreateListBoxItemsL() |
|
603 { |
|
604 RUBY_DEBUG_BLOCK( "CPbkInfoViewDialog::CreateListBoxItemsL" ); |
|
605 |
|
606 CAknDoubleGraphicStyleListBox* listBox = iListBox; |
|
607 CDesCArray* items = (CDesCArray*) listBox->Model()->ItemTextArray(); |
|
608 items->Reset(); |
|
609 listBox->ItemDrawer()->ClearAllPropertiesL(); |
|
610 |
|
611 TInt count = iSindHandler->VoiceTagCount(); |
|
612 |
|
613 // Create dialog entries |
|
614 for ( TInt i = 0; i < count; i++ ) |
|
615 { |
|
616 // Line header |
|
617 HBufC* firstLine = iSindHandler->VoiceTagLabelLC( i ); |
|
618 // Phone number, email address, etc... |
|
619 HBufC* secondLine = iSindHandler->VoiceTagValueL( i ).AllocLC(); |
|
620 |
|
621 TInt iconIndex = IconIndex( iSindHandler->IconIdL( i ), i ); |
|
622 |
|
623 TPtr ptr1 = firstLine->Des(); |
|
624 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr1 ); |
|
625 TPtr ptr2 = secondLine->Des(); |
|
626 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr2 ); |
|
627 |
|
628 HBufC* listBoxItem = NULL; |
|
629 listBoxItem = TDialogUtil::ConstructListBoxItemLC( firstLine->Des(), |
|
630 secondLine->Des(), |
|
631 iconIndex ); |
|
632 |
|
633 items->AppendL( listBoxItem->Des() ); |
|
634 |
|
635 CleanupStack::PopAndDestroy( listBoxItem ); |
|
636 CleanupStack::PopAndDestroy( secondLine ); |
|
637 CleanupStack::PopAndDestroy( firstLine ); |
|
638 } |
|
639 |
|
640 listBox->HandleItemAdditionL(); |
|
641 |
|
642 TInt current = CurrentItemIndex(); |
|
643 if (current == KErrNotFound) |
|
644 { |
|
645 current = 0; |
|
646 } |
|
647 |
|
648 iListBox->SetCurrentItemIndexAndDraw( current ); |
|
649 } |
|
650 |
|
651 // ----------------------------------------------------------------------------- |
|
652 // CPbkInfoViewDialog::HandleListBoxEventL (from MEikListBoxObserver) |
|
653 // From MEikListBoxObserver, called by framework. |
|
654 // ----------------------------------------------------------------------------- |
|
655 // |
|
656 void CPbkInfoViewDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
657 TListBoxEvent aEventType ) |
|
658 { |
|
659 switch ( aEventType ) |
|
660 { |
|
661 case EEventEnterKeyPressed: |
|
662 case EEventItemSingleClicked: |
|
663 { |
|
664 if ( iSindHandler->VoiceTagCount() > 0 ) |
|
665 { |
|
666 ShowPopupL(); |
|
667 |
|
668 if ( IsCallActive() ) |
|
669 { |
|
670 CallInProgressNoteL(); |
|
671 } |
|
672 else |
|
673 { |
|
674 iSindHandler->PlayVoiceCommandL( CurrentItemIndex() ); |
|
675 } |
|
676 |
|
677 } |
|
678 break; |
|
679 } |
|
680 |
|
681 default: |
|
682 break; |
|
683 } |
|
684 } |
|
685 |
|
686 // ----------------------------------------------------------------------------- |
|
687 // CPbkInfoViewDialog::CurrentItemIndex |
|
688 // Gets current listbox item. |
|
689 // ----------------------------------------------------------------------------- |
|
690 // |
|
691 TInt CPbkInfoViewDialog::CurrentItemIndex() |
|
692 { |
|
693 TInt ret; |
|
694 |
|
695 if ( iListBox->Model()->NumberOfItems() == 0 ) |
|
696 { |
|
697 ret = KErrNotFound; |
|
698 } |
|
699 else |
|
700 { |
|
701 ret = iListBox->CurrentItemIndex(); |
|
702 } |
|
703 |
|
704 return ret; |
|
705 } |
|
706 |
|
707 // ----------------------------------------------------------------------------- |
|
708 // CPbkInfoViewDialog::UpdateCbaL |
|
709 // Updates dialog cba. |
|
710 // @param aResourceId Resource id. |
|
711 // ----------------------------------------------------------------------------- |
|
712 // |
|
713 void CPbkInfoViewDialog::UpdateCbaL( TInt aResourceId ) |
|
714 { |
|
715 CEikButtonGroupContainer& cba = ButtonGroupContainer(); |
|
716 cba.SetCommandSetL( aResourceId ); |
|
717 cba.DrawDeferred(); |
|
718 } |
|
719 |
|
720 // ----------------------------------------------------------------------------- |
|
721 // CPbkInfoViewDialog::ShowPopupL |
|
722 // Shows popup for a voice command in the list. |
|
723 // ----------------------------------------------------------------------------- |
|
724 // |
|
725 void CPbkInfoViewDialog::ShowPopupL() |
|
726 { |
|
727 iPopupController->SetTextL( iSindHandler->PopupTextL( CurrentItemIndex() ) ); |
|
728 iPopupController->ShowInfoPopupNote(); |
|
729 } |
|
730 |
|
731 // ----------------------------------------------------------------------------- |
|
732 // CPbkInfoViewDialog::ShowInformationNoteL |
|
733 // |
|
734 // ----------------------------------------------------------------------------- |
|
735 // |
|
736 void CPbkInfoViewDialog::ShowInformationNoteL( TInt aResourceId ) |
|
737 { |
|
738 TDesC* noteText = StringLoader::LoadLC( aResourceId ); |
|
739 |
|
740 CAknInformationNote* dialog = |
|
741 new(ELeave)CAknInformationNote( R_AKN_INFORMATION_NOTE ); |
|
742 dialog->ExecuteLD( *noteText ); |
|
743 |
|
744 CleanupStack::PopAndDestroy( noteText ); |
|
745 } |
|
746 |
|
747 void CPbkInfoViewDialog::CreateFieldIconsL(CArrayPtr<CGulIcon>* aIconArray) |
|
748 { |
|
749 CPbk2StoreConfiguration* configuration = CPbk2StoreConfiguration::NewL(); |
|
750 CleanupStack::PushL(configuration); |
|
751 |
|
752 CVPbkContactStoreUriArray* uriArray = configuration->CurrentConfigurationL(); |
|
753 CleanupStack::PushL( uriArray ); |
|
754 if ( uriArray->IsIncluded(VPbkContactStoreUris::DefaultCntDbUri()) == EFalse ) |
|
755 { |
|
756 uriArray->AppendL( VPbkContactStoreUris::DefaultCntDbUri() ); |
|
757 } |
|
758 |
|
759 CVPbkContactManager* contactManager = CVPbkContactManager::NewL(*uriArray); |
|
760 CleanupStack::PushL( contactManager ); |
|
761 |
|
762 TInt arraySize = sizeof KFieldIds / sizeof KFieldIds[0]; |
|
763 TInt count =0; |
|
764 const MVPbkFieldType* fieldType = NULL; |
|
765 CGulIcon* icon = NULL; |
|
766 |
|
767 CVPbkFieldTypeRefsList* fieldTypeList = CVPbkFieldTypeRefsList::NewL(); |
|
768 CleanupStack::PushL( fieldTypeList ); |
|
769 |
|
770 for( count = 0; count < arraySize; ++count ) |
|
771 { |
|
772 fieldType = contactManager->FieldTypes().Find( KFieldIds[count] ); |
|
773 fieldTypeList->AppendL(*fieldType); |
|
774 } |
|
775 |
|
776 MPbk2FieldPropertyArray* propertyArray = Pbk2FieldPropertiesFactory::CreateLC(*fieldTypeList, |
|
777 &contactManager->FsSession() ); |
|
778 |
|
779 CPbk2IconFactory* pbk2IconFactory = CPbk2IconFactory::NewL(); |
|
780 CleanupStack::PushL( pbk2IconFactory ); |
|
781 |
|
782 for( count = 0; count < propertyArray->Count(); ++ count) |
|
783 { |
|
784 icon = pbk2IconFactory->CreateIconL( propertyArray->At(count).IconId()); |
|
785 // Append xSP icon info to helper array |
|
786 if ( propertyArray->At(count).FieldType().FieldTypeResId() == R_VPBK_FIELD_TYPE_IMPP |
|
787 && icon && icon->Bitmap()->Handle() ) |
|
788 { |
|
789 const MPbk2FieldProperty& property = propertyArray->At(count); |
|
790 MPbk2FieldProperty2* property2 = reinterpret_cast<MPbk2FieldProperty2*> |
|
791 ( const_cast<MPbk2FieldProperty&> (property).FieldPropertyExtension( |
|
792 KMPbk2FieldPropertyExtension2Uid ) ); |
|
793 TXspIconHelper xsp( count, property2->XSpName() ); |
|
794 iXspIconHelper.Append( xsp ); |
|
795 } |
|
796 aIconArray->AppendL(icon); |
|
797 } |
|
798 |
|
799 iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( aIconArray ); |
|
800 |
|
801 //Destroy: configuration,uriArray,contactManager |
|
802 //fieldTypeList,propertyArray,pbk2IconFactory |
|
803 CleanupStack::PopAndDestroy( 6,configuration ); |
|
804 } |
|
805 // End of File |