voiceui/pbkinfoviewimpl/src/pbkinfoviewdialog.cpp
changeset 0 bf1d17376201
child 12 fc313e1df071
equal deleted inserted replaced
-1:000000000000 0:bf1d17376201
       
     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 // ============================ MEMBER FUNCTIONS ===============================
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CPbkInfoViewDialog::NewL
       
    45 //
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CPbkInfoViewDialog* CPbkInfoViewDialog::NewL( TInt aContactId )
       
    49     {
       
    50     RUBY_DEBUG_BLOCK( "CPbkInfoViewDialog::NewL" );
       
    51 
       
    52     CPbkInfoViewDialog* self = new ( ELeave ) CPbkInfoViewDialog( aContactId );
       
    53     CleanupStack::PushL(self);
       
    54     self->ConstructL();
       
    55     CleanupStack::Pop(self);
       
    56     
       
    57     return self;
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CPbkInfoViewDialog::CPbkInfoViewDialog
       
    62 // 
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CPbkInfoViewDialog::CPbkInfoViewDialog( TInt aContactId )
       
    66     {
       
    67 	iContactId = aContactId;
       
    68 	
       
    69 	if( aContactId == KVoiceTaglessContactId )
       
    70 	    {
       
    71 	    iVoiceTaglessContact = ETrue;
       
    72 	    }
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CPbkInfoViewDialog::ConstructL
       
    77 //
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CPbkInfoViewDialog::ConstructL()
       
    81     {
       
    82     CAknDialog::ConstructL( R_INFOVIEW_DIALOG_MENU );
       
    83 	
       
    84     // Hide tabs
       
    85     CEikStatusPane* statusPane = iAvkonAppUi->StatusPane();
       
    86     if ( statusPane && statusPane->PaneCapabilities
       
    87              ( TUid::Uid( EEikStatusPaneUidTitle ) ).IsPresent() )
       
    88         {
       
    89         iNaviPane = (CAknNavigationControlContainer*) statusPane->ControlL
       
    90                     ( TUid::Uid(EEikStatusPaneUidNavi ) );
       
    91         iNaviPane->PushDefaultL();
       
    92         }
       
    93         
       
    94     iAvkonAppUi->SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyLong );
       
    95 	
       
    96 	// Get the previous title so it can be restored
       
    97 	iStatusPaneHandler = CStatusPaneHandler::NewL( iAvkonAppUi );
       
    98 	iStatusPaneHandler->StoreOriginalTitleL();
       
    99 	
       
   100 	iPopupController = CAknInfoPopupNoteController::NewL();
       
   101 	
       
   102 	iResHandler = CPbkInfoViewResHandler::NewL();
       
   103 	
       
   104 	iSindHandler = CPbkInfoViewSindHandler::NewL( iContactId );
       
   105     } 
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CPbkInfoViewDialog::~CPbkInfoViewDialog()
       
   109 // Destructor.
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 CPbkInfoViewDialog::~CPbkInfoViewDialog()
       
   113     {
       
   114 	delete iStatusPaneHandler;
       
   115 	iStatusPaneHandler = NULL;
       
   116 	delete iPopupController;
       
   117 	iPopupController = NULL;
       
   118     delete iResHandler;
       
   119 	iResHandler = NULL;
       
   120 	delete iSindHandler;
       
   121 	iSindHandler = NULL;
       
   122 	
       
   123 	if ( iAvkonAppUi )
       
   124 		{
       
   125 		iAvkonAppUi->RemoveFromStack( this  );
       
   126 		}
       
   127 		
       
   128     // Restore tabs
       
   129     if ( iNaviPane )
       
   130         {
       
   131         iNaviPane->Pop();
       
   132         }
       
   133     }
       
   134 
       
   135 //------------------------------------------------------------------------------
       
   136 // CPbkInfoViewDialog::ExecuteLD
       
   137 // Overrides CAknDialog::ExecuteLD. Checks whether the contact has any voice
       
   138 // tags. If not an info note is displayed. Otherwise calls CAknDialog::ExecuteLD
       
   139 // @param aResourceId The resource ID of the dialog to be loaded
       
   140 // @return see CAknDialog::ExecuteLD
       
   141 //------------------------------------------------------------------------------
       
   142 //
       
   143 TInt CPbkInfoViewDialog::ExecuteLD( TInt aResourceId )
       
   144     {
       
   145     // Check whether info view should be shown at all
       
   146     if( iContactId == KVoiceTaglessContactId )
       
   147         {
       
   148         ShowInformationNoteL( R_INFOVIEW_EMPTY_VIEW_SIM_CONTACT );
       
   149         delete this;
       
   150         return 0;
       
   151         }
       
   152     else if( iSindHandler->VoiceTagCount() == 0 )
       
   153         {
       
   154         ShowInformationNoteL( R_INFOVIEW_EMPTY_VIEW );
       
   155         delete this;
       
   156         return 0;
       
   157         }
       
   158     // Show info view
       
   159     else
       
   160         {
       
   161         return CAknDialog::ExecuteLD( aResourceId );
       
   162         }    
       
   163     }
       
   164 
       
   165 //------------------------------------------------------------------------------
       
   166 // CPbkInfoViewDialog::ActivateL (from CCoeControl)
       
   167 // Called by system when dialog is activated.
       
   168 //------------------------------------------------------------------------------
       
   169 //
       
   170 void CPbkInfoViewDialog::ActivateL()
       
   171 	{
       
   172     CAknDialog::ActivateL();
       
   173 
       
   174     // This cannot be in ConstructL which is executed before dialog is launched
       
   175     iAvkonAppUi->AddToStackL( this );
       
   176     }
       
   177 
       
   178 //------------------------------------------------------------------------------
       
   179 // CPbkInfoViewDialog::GetHelpContext
       
   180 // Method to get context sensitive help topic.
       
   181 // @param aContext Help topic to open.
       
   182 //------------------------------------------------------------------------------
       
   183 //
       
   184 void CPbkInfoViewDialog::GetHelpContext( TCoeHelpContext& aContext ) const
       
   185 	{
       
   186 	aContext.iMajor = TUid::Uid( PBKINFOVIEW_HELP_UID );
       
   187 	aContext.iContext = KVCINFO_HLP_MAINVIEW;    
       
   188 	}
       
   189 
       
   190 //------------------------------------------------------------------------------
       
   191 // CPbkInfoViewDialog::ProcessCommandL
       
   192 // Handles menu events.
       
   193 // @param  aCommandId Command id.
       
   194 //------------------------------------------------------------------------------
       
   195 //
       
   196 void CPbkInfoViewDialog::ProcessCommandL( TInt aCommandId ) 
       
   197 	{
       
   198 	HideMenu();
       
   199 
       
   200 	switch ( aCommandId )
       
   201 		{
       
   202         case EInfoViewMenuCmdPlay:
       
   203 			{
       
   204 			if ( IsCallActive() )
       
   205 			    {
       
   206 			    CallInProgressNoteL();
       
   207 			    }
       
   208 			else 
       
   209 			    {
       
   210 			    iSindHandler->PlayVoiceCommandL( CurrentItemIndex() );
       
   211 			    }
       
   212 			
       
   213 			break;
       
   214 			}
       
   215 		case EInfoViewMenuCmdHelp:
       
   216 			{
       
   217 			iAvkonAppUi->ProcessCommandL( EAknCmdHelp );
       
   218 			break;
       
   219 			}
       
   220         case EInfoViewMenuCmdExit:
       
   221 			{
       
   222 			iAvkonAppUi->ProcessCommandL( EAknCmdExit );
       
   223 			break;
       
   224 			}
       
   225         case EAknCmdExit:
       
   226         case EEikCmdExit:
       
   227 			{
       
   228             //
       
   229 			// Exit dialog
       
   230 			//
       
   231 			// CEikAppUi::ProcessCommandL starts CAknAppShutter that 
       
   232 			// closes all dialogs and finally calling application. Before 
       
   233 			// dialog is closed (deleted) it's OkToExitL(EEikBidCancel)
       
   234 			// is called. EEikBidCancel means OkToExitL must silently
       
   235 			// save and return ETrue.
       
   236 			//
       
   237 			iAvkonAppUi->ProcessCommandL( EAknCmdExit );
       
   238 
       
   239 			break;
       
   240 			}
       
   241 
       
   242 		default:
       
   243 			{
       
   244 			break;
       
   245 			}
       
   246 		}
       
   247 	}
       
   248 
       
   249 
       
   250 // ----------------------------------------------------------------------------
       
   251 // CPbkInfoViewDialog::IsCallActive
       
   252 // ----------------------------------------------------------------------------
       
   253 //
       
   254 TBool CPbkInfoViewDialog::IsCallActive()
       
   255     {
       
   256     TBool callActive( EFalse );
       
   257     TInt state( 0 );
       
   258     TInt err = RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState,
       
   259                                state );
       
   260                                
       
   261     // note! errors are handled as a call is active    
       
   262     if( err || state == EPSCTsyCallStateConnected 
       
   263             || state == EPSCTsyCallStateAlerting
       
   264             || state == EPSCTsyCallStateRinging
       
   265             || state == EPSCTsyCallStateDialling
       
   266             || state == EPSCTsyCallStateAnswering ) 
       
   267         {
       
   268         callActive = ETrue;
       
   269         }
       
   270     else
       
   271         {
       
   272         TInt callType( 0 );
       
   273         TInt err =  RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallType,
       
   274                                 callType );
       
   275         if ( err || callType == EPSCTsyCallTypeH324Multimedia ) 
       
   276             {
       
   277             callActive = ETrue;
       
   278             }
       
   279         }    
       
   280     
       
   281     return callActive;
       
   282     }
       
   283 
       
   284 // ----------------------------------------------------------------------------
       
   285 // CPbkInfoViewDialog::CallInProgressNoteL
       
   286 // ----------------------------------------------------------------------------
       
   287 //
       
   288 void CPbkInfoViewDialog::CallInProgressNoteL()
       
   289     {
       
   290     HBufC* text = StringLoader::LoadLC( R_TEXT_CALL_IN_PROGRESS );
       
   291     CAknInformationNote* note = new( ELeave ) CAknInformationNote( ETrue );
       
   292     note->ExecuteLD( *text );
       
   293     CleanupStack::PopAndDestroy( text );
       
   294     }
       
   295 
       
   296     
       
   297 // -----------------------------------------------------------------------------
       
   298 // CPbkInfoViewDialog::OkToExitL
       
   299 // Called by framework before exiting the dialog.
       
   300 // @param aButtonId Button id.
       
   301 // @return ETrue to exit\ EFalse to not to exit.
       
   302 // -----------------------------------------------------------------------------
       
   303 //
       
   304 TBool CPbkInfoViewDialog::OkToExitL( TInt aButtonId )
       
   305     {
       
   306     if( iSindHandler->IsPlaying() )
       
   307 	    {
       
   308 		iSindHandler->CancelPlaybackL();
       
   309 		}
       
   310     
       
   311     switch ( aButtonId )
       
   312         {
       
   313         case EAknSoftkeyBack:
       
   314             {
       
   315             return ETrue;
       
   316             }
       
   317             
       
   318         case EAknSoftkeyClose:
       
   319         case EAknSoftkeyExit:
       
   320             {
       
   321             iAvkonAppUi->ProcessCommandL( EAknCmdExit );
       
   322             return ETrue;
       
   323             }
       
   324             
       
   325         case EAknSoftkeySelect: // Middle soft key, no exit
       
   326             {
       
   327             if ( IsCallActive() )
       
   328 			    {
       
   329 			    CallInProgressNoteL();
       
   330 			    }
       
   331 			else 
       
   332 			    {
       
   333 			    iSindHandler->PlayVoiceCommandL( CurrentItemIndex() );
       
   334 			    }
       
   335             
       
   336             return EFalse;
       
   337             }
       
   338             
       
   339          default:
       
   340             {
       
   341             return CAknDialog::OkToExitL( aButtonId );
       
   342             }   
       
   343         }
       
   344     }
       
   345 
       
   346 // ----------------------------------------------------------------------------
       
   347 // CPbkInfoViewDialog::OfferKeyEventL
       
   348 // Called by framework for key event handling.
       
   349 // ----------------------------------------------------------------------------
       
   350 //
       
   351 TKeyResponse CPbkInfoViewDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   352                                                  TEventCode aType )
       
   353 	{
       
   354 	if ( aType == EEventKey )
       
   355 		{
       
   356 		switch ( aKeyEvent.iCode )
       
   357 			{
       
   358 			case EKeyEscape:  // Framework calls this when dialog must shut
       
   359 				{
       
   360 				return CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   361         		}
       
   362         		
       
   363             case EKeyUpArrow:
       
   364             case EKeyDownArrow:
       
   365                 {
       
   366                 CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   367                 if( iSindHandler->VoiceTagCount() > 0 )
       
   368                     {
       
   369                     ShowPopupL();
       
   370                     }
       
   371                 return EKeyWasConsumed;
       
   372                 }
       
   373 			
       
   374             default:
       
   375 			    break;
       
   376 			}
       
   377 		}
       
   378 		
       
   379 	return CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   380 	}
       
   381 
       
   382 // ----------------------------------------------------------------------------
       
   383 // CPbkInfoViewDialog::HandleResourceChange
       
   384 // Called when display resolution changes.
       
   385 // ----------------------------------------------------------------------------
       
   386 //
       
   387 void CPbkInfoViewDialog::HandleResourceChange( TInt aType )
       
   388     {
       
   389     // Handle change in layout orientation
       
   390     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   391         {
       
   392         TRect mainPaneRect;
       
   393         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   394                                            mainPaneRect );
       
   395         SetRect( mainPaneRect );
       
   396         //iListBox->SetSize( mainPaneRect.Size() );
       
   397         iListBox->SetSize( mainPaneRect.Size() );
       
   398         CCoeControl::HandleResourceChange( aType );
       
   399 		DrawDeferred();
       
   400 		}
       
   401 	else
       
   402 	    {
       
   403 	    CCoeControl::HandleResourceChange( aType );
       
   404 	    }
       
   405     }
       
   406 
       
   407 // ----------------------------------------------------------------------------
       
   408 // CPbkInfoViewDialog::PostLayoutDynInitL
       
   409 // Called by framework after dialog is shown.
       
   410 // ----------------------------------------------------------------------------
       
   411 //
       
   412 void CPbkInfoViewDialog::PostLayoutDynInitL()
       
   413 	{
       
   414 	}
       
   415 
       
   416 // ----------------------------------------------------------------------------
       
   417 // CPbkInfoViewDialog::PreLayoutDynInitL
       
   418 // Called by framework before dialog is shown.
       
   419 // ----------------------------------------------------------------------------
       
   420 //
       
   421 void CPbkInfoViewDialog::PreLayoutDynInitL()
       
   422     {
       
   423     RUBY_DEBUG_BLOCK( "CPbkInfoViewDialog::PreLayoutDynInitL" );
       
   424     
       
   425     iListBox = ( CAknDoubleGraphicStyleListBox* ) ControlOrNull ( EInfoViewDialogList );
       
   426     
       
   427    	__ASSERT_ALWAYS( iListBox, TPbkInfoViewUtil::Panic( KErrGeneral ) );
       
   428 	
       
   429 	iListBox->SetListBoxObserver( this );
       
   430 	iListBox->CreateScrollBarFrameL( ETrue );
       
   431 	iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
       
   432 	                                                      CEikScrollBarFrame::EAuto );                                 
       
   433     iListBox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue );
       
   434 	
       
   435 	TDesC* des;
       
   436 	// Set empty list text
       
   437 	if( iVoiceTaglessContact )
       
   438 	    {
       
   439     	des = StringLoader::LoadLC( R_INFOVIEW_EMPTY_VIEW_SIM_CONTACT );
       
   440     	iListBox->View()->SetListEmptyTextL( *des );
       
   441 	    }
       
   442 	else
       
   443 	    {
       
   444     	des = StringLoader::LoadLC( R_INFOVIEW_EMPTY_VIEW );
       
   445     	iListBox->View()->SetListEmptyTextL( *des );
       
   446 	    }
       
   447 	CleanupStack::PopAndDestroy( des );
       
   448     
       
   449     // Set icons
       
   450 	TFileName bitmapName;
       
   451 	CPbkInfoViewResHandler::GetBitmapFileName( bitmapName );
       
   452 	CArrayPtr<CGulIcon>* icons = new (ELeave) CAknIconArray( KDefaultArraySize );
       
   453 	CleanupStack::PushL( icons );
       
   454 	
       
   455 	// NOTE: icons must be appended in the order of enumeration 
       
   456 	// TInfoViewDialogIconIndex
       
   457 	icons->AppendL( TDialogUtil::CreateIconL(
       
   458 	                KAknsIIDQgnPropNrtypMobile, bitmapName,
       
   459 	                EMbmAvkonQgn_prop_nrtyp_mobile, 
       
   460 	                EMbmAvkonQgn_prop_nrtyp_mobile_mask ) );
       
   461 	
       
   462 	icons->AppendL( TDialogUtil::CreateIconL( 
       
   463 	                KAknsIIDQgnPropNrtypPhone, bitmapName,
       
   464 	                EMbmAvkonQgn_prop_nrtyp_phone,
       
   465 	                EMbmAvkonQgn_prop_nrtyp_phone_mask ) );
       
   466 	                
       
   467 	icons->AppendL( TDialogUtil::CreateIconL( 
       
   468 	                KAknsIIDQgnPropFolderVideo, bitmapName,
       
   469 	                EMbmAvkonQgn_prop_nrtyp_video,
       
   470 	                EMbmAvkonQgn_prop_nrtyp_video_mask ) );
       
   471 	                
       
   472 	icons->AppendL( TDialogUtil::CreateIconL(
       
   473 	                KAknsIIDQgnPropMceEmailTitle, bitmapName,
       
   474 	                EMbmAvkonQgn_prop_nrtyp_email,
       
   475 	                EMbmAvkonQgn_prop_nrtyp_email_mask ) );
       
   476 	                
       
   477 	icons->AppendL( TDialogUtil::CreateIconL(
       
   478 	                KAknsIIDQgnIndiVoipCallActive, bitmapName,
       
   479 	                EMbmAvkonQgn_prop_nrtyp_voip,
       
   480 	                EMbmAvkonQgn_prop_nrtyp_voip_mask ) );
       
   481 	
       
   482 	icons->AppendL( TDialogUtil::CreateIconL(
       
   483 	                KAknsIIDQgnLogoEmpty, bitmapName,
       
   484 	                EMbmAvkonQgn_prop_empty,
       
   485 	                EMbmAvkonQgn_prop_empty_mask ) );
       
   486 	
       
   487 	iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons );
       
   488 	CleanupStack::Pop( icons );
       
   489 
       
   490 	CreateListBoxItemsL();
       
   491 	
       
   492 	iListBox->UpdateScrollBarsL();
       
   493 	iListBox->ScrollBarFrame()->MoveVertThumbTo( 0 );
       
   494 
       
   495 	iStatusPaneHandler->SetTitleL( R_INFOVIEW_DIALOG_TITLE );
       
   496 	
       
   497 	UpdateCbaL( R_SOFTKEYS_OPTIONS_BACK__PLAY );
       
   498 	}
       
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 // CPbkInfoViewDialog::DynInitMenuPaneL
       
   502 // Called by framework before menu is shown.
       
   503 // @param aResourceId Menu resource id.
       
   504 // @param aMenuPane Pointer to the menu.
       
   505 // -----------------------------------------------------------------------------
       
   506 //
       
   507 void CPbkInfoViewDialog::DynInitMenuPaneL( TInt aResourceID,
       
   508                                            CEikMenuPane* aMenuPane )
       
   509 	{
       
   510 	if ( aResourceID == R_INFOVIEW_DIALOG_MENU_PANE )
       
   511 	    {
       
   512 	    // No play function in menu if there are no voice tags
       
   513 	    if( iSindHandler->VoiceTagCount() == 0 )
       
   514             {
       
   515     	    aMenuPane->SetItemDimmed( EInfoViewMenuCmdPlay, ETrue );
       
   516             }
       
   517 	    }
       
   518 	}
       
   519 	
       
   520 // -----------------------------------------------------------------------------
       
   521 // CPbkInfoViewDialog::IconIndex
       
   522 // Returns TInfoViewDialogIconIndex enumeration icon index.
       
   523 // @param aIconId enumeration TPbkIconId from PbkIconId.hrh.
       
   524 // @return TInt Icon index.
       
   525 // -----------------------------------------------------------------------------
       
   526 //
       
   527 TInt CPbkInfoViewDialog::IconIndex( TInt aIconId )
       
   528 	{
       
   529 	TInt iconIndex;
       
   530 	
       
   531 	switch ( aIconId )
       
   532 		{
       
   533 		case EPbkqgn_prop_nrtyp_mobile:
       
   534 		    iconIndex = EIconIndexMobile;
       
   535 		    break;
       
   536 		case EPbkqgn_prop_nrtyp_phone:
       
   537 		    iconIndex = EIconIndexPhone;
       
   538 		    break;
       
   539 		case EPbkqgn_prop_nrtyp_video:
       
   540 		    iconIndex = EIconIndexVideo;
       
   541 		    break;
       
   542 		case EPbkqgn_prop_nrtyp_email:
       
   543 		    iconIndex = EIconIndexEmail;
       
   544 		    break;
       
   545 		case EPbkqgn_prop_nrtyp_voip:
       
   546 		    iconIndex = EIconIndexVoip;
       
   547 		    break;
       
   548 		default:
       
   549 		    iconIndex = EIconIndexEmpty;    
       
   550 		    break;
       
   551 		}
       
   552 		
       
   553     return iconIndex; 
       
   554 	}
       
   555 		
       
   556 // -----------------------------------------------------------------------------
       
   557 // CPbkInfoViewDialog::CreateListBoxItemsL
       
   558 // Creates listbox items.
       
   559 // -----------------------------------------------------------------------------
       
   560 //
       
   561 void CPbkInfoViewDialog::CreateListBoxItemsL()
       
   562 	{
       
   563 	RUBY_DEBUG_BLOCK( "CPbkInfoViewDialog::CreateListBoxItemsL" );
       
   564 	
       
   565 	CAknDoubleGraphicStyleListBox* listBox = iListBox;
       
   566 	CDesCArray* items = (CDesCArray*) listBox->Model()->ItemTextArray();
       
   567 	items->Reset();
       
   568     listBox->ItemDrawer()->ClearAllPropertiesL();
       
   569 	
       
   570 	TInt count = iSindHandler->VoiceTagCount();
       
   571 	
       
   572 	// Create dialog entries
       
   573 	for ( TInt i = 0; i < count; i++ )
       
   574 		{
       
   575 		// Line header
       
   576 		HBufC* firstLine = iSindHandler->VoiceTagLabelLC( i );
       
   577 		// Phone number, email address, etc...
       
   578 		HBufC* secondLine = iSindHandler->VoiceTagValueL( i ).AllocLC();
       
   579 		TInt iconIndex = IconIndex( iSindHandler->IconIdL( i ) );
       
   580 
       
   581 		TPtr ptr1 = firstLine->Des();
       
   582 		AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr1 );
       
   583 		TPtr ptr2 = secondLine->Des();
       
   584 		AknTextUtils::DisplayTextLanguageSpecificNumberConversion( ptr2 );
       
   585 
       
   586 		HBufC* listBoxItem = NULL;
       
   587 		listBoxItem = TDialogUtil::ConstructListBoxItemLC( firstLine->Des(), 
       
   588 		                                                   secondLine->Des(),
       
   589                                                            iconIndex );         
       
   590 
       
   591 		items->AppendL( listBoxItem->Des() );
       
   592 		
       
   593 		CleanupStack::PopAndDestroy( listBoxItem );
       
   594 		CleanupStack::PopAndDestroy( secondLine );
       
   595 		CleanupStack::PopAndDestroy( firstLine );
       
   596 		}
       
   597 
       
   598 	listBox->HandleItemAdditionL();
       
   599 
       
   600     TInt current = CurrentItemIndex();
       
   601     if (current == KErrNotFound)
       
   602         {
       
   603 		current = 0;
       
   604         }
       
   605 		
       
   606 	iListBox->SetCurrentItemIndexAndDraw( current );
       
   607 	}
       
   608 	
       
   609 // -----------------------------------------------------------------------------
       
   610 // CPbkInfoViewDialog::HandleListBoxEventL (from MEikListBoxObserver)
       
   611 // From MEikListBoxObserver, called by framework.
       
   612 // -----------------------------------------------------------------------------
       
   613 //
       
   614 void CPbkInfoViewDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/,
       
   615                                               TListBoxEvent aEventType )
       
   616     {
       
   617     switch ( aEventType )
       
   618         {
       
   619         case EEventEnterKeyPressed:
       
   620         case EEventItemSingleClicked:
       
   621             {            
       
   622             if ( iSindHandler->VoiceTagCount() > 0 )
       
   623                 {
       
   624                 ShowPopupL();
       
   625                 
       
   626                 if ( IsCallActive() )
       
   627                     {
       
   628                     CallInProgressNoteL();
       
   629                     }
       
   630                 else 
       
   631                     {
       
   632                     iSindHandler->PlayVoiceCommandL( CurrentItemIndex() );
       
   633                     }
       
   634               
       
   635                 }
       
   636             break;
       
   637             }
       
   638           
       
   639         default:
       
   640             break;
       
   641         }
       
   642     }
       
   643 
       
   644 // -----------------------------------------------------------------------------
       
   645 // CPbkInfoViewDialog::CurrentItemIndex
       
   646 // Gets current listbox item.
       
   647 // -----------------------------------------------------------------------------
       
   648 //
       
   649 TInt CPbkInfoViewDialog::CurrentItemIndex()
       
   650 	{
       
   651 	TInt ret;
       
   652 	
       
   653 	if ( iListBox->Model()->NumberOfItems() == 0 )
       
   654 		{
       
   655 		ret = KErrNotFound;
       
   656 		}
       
   657     else
       
   658         {
       
   659         ret = iListBox->CurrentItemIndex();
       
   660         }
       
   661 	
       
   662 	return ret;
       
   663 	}
       
   664 	
       
   665 // -----------------------------------------------------------------------------
       
   666 // CPbkInfoViewDialog::UpdateCbaL
       
   667 // Updates dialog cba.
       
   668 // @param aResourceId Resource id.
       
   669 // -----------------------------------------------------------------------------
       
   670 //
       
   671 void CPbkInfoViewDialog::UpdateCbaL( TInt aResourceId )
       
   672     {
       
   673     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
   674     cba.SetCommandSetL( aResourceId );
       
   675     cba.DrawDeferred();
       
   676     }
       
   677 
       
   678 // -----------------------------------------------------------------------------
       
   679 // CPbkInfoViewDialog::ShowPopupL
       
   680 // Shows popup for a voice command in the list.
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 void CPbkInfoViewDialog::ShowPopupL()
       
   684     {
       
   685     iPopupController->SetTextL( iSindHandler->PopupTextL( CurrentItemIndex() ) );
       
   686     iPopupController->ShowInfoPopupNote();
       
   687     }
       
   688     
       
   689 // -----------------------------------------------------------------------------
       
   690 // CPbkInfoViewDialog::ShowInformationNoteL
       
   691 //
       
   692 // -----------------------------------------------------------------------------
       
   693 //
       
   694 void CPbkInfoViewDialog::ShowInformationNoteL( TInt aResourceId )
       
   695 	{
       
   696 	TDesC* noteText = StringLoader::LoadLC( aResourceId );
       
   697     	
       
   698     CAknInformationNote* dialog = 
       
   699         new(ELeave)CAknInformationNote( R_AKN_INFORMATION_NOTE );
       
   700     dialog->ExecuteLD( *noteText );
       
   701     
       
   702     CleanupStack::PopAndDestroy( noteText );
       
   703 	}
       
   704 
       
   705 //  End of File