uiservicetab/vimpstui/src/cvimpstuisearchviewcontrol.cpp
changeset 15 81eeb8c83ce5
parent 0 5e5d6b214f4f
equal deleted inserted replaced
0:5e5d6b214f4f 15:81eeb8c83ce5
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation for CVIMPSTUiSearchViewControl.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cvimpstuisearchviewcontrol.h"
       
    22 
       
    23 #include "mvimpstcmdhandler.h"
       
    24 #include "vimpstutils.h"
       
    25 #include "tvimpstconsts.h"
       
    26 #include "mvimpstengine.h"
       
    27 #include "cvimpstuisearchview.h"
       
    28 #include "vimpstui.hrh"
       
    29 #include "vimpstutilsdialog.h"
       
    30 #include    "vimpstdebugprint.h" 
       
    31 // imlauncher
       
    32 #include <imcvlauncher.h>
       
    33 
       
    34 
       
    35 // system include
       
    36 #include 	<aknenv.h>
       
    37 #include	<aknlists.h>
       
    38 #include    <AknIconArray.h>
       
    39 #include 	<AknUtils.h> 
       
    40 #include 	<StringLoader.h>
       
    41 
       
    42 // Pbk2
       
    43 #include <MPbk2KeyEventHandler.h>
       
    44 #include <vimpstuires.rsg>
       
    45 
       
    46 
       
    47 
       
    48 // ================= MEMBER FUNCTIONS =======================
       
    49 
       
    50 
       
    51 // --------------------------------------------------------------------------
       
    52 // CVIMPSTUiSearchViewControl::CVIMPSTUiSearchViewControl
       
    53 // --------------------------------------------------------------------------
       
    54 //
       
    55 CVIMPSTUiSearchViewControl::CVIMPSTUiSearchViewControl( MPbk2KeyEventHandler* aKeyEventHandler,
       
    56 														TUint32 aServiceId,
       
    57 													   	MVIMPSTEngine& aEngine,
       
    58 													   	MVIMPSTCmdHandler& aCommandHandler,
       
    59 													   	CVIMPSTUiSearchView& aSearchView )
       
    60 	:iKeyEventHandler(aKeyEventHandler),
       
    61 	 iServiceId(aServiceId),
       
    62 	 iEngine( aEngine ),
       
    63 	 iCommandHandler( aCommandHandler ),
       
    64 	 iSearchView( aSearchView )
       
    65     {
       
    66     
       
    67     }
       
    68 
       
    69 
       
    70 // --------------------------------------------------------------------------
       
    71 // CVIMPSTUiSearchViewControl::ConstructL
       
    72 // --------------------------------------------------------------------------
       
    73 //
       
    74 void CVIMPSTUiSearchViewControl::ConstructL()
       
    75     {
       
    76     CreateWindowL();
       
    77     iItemArray = new ( ELeave ) CDesCArrayFlat( KArrayGranularity );   
       
    78     // Create listbox
       
    79     iListBox = new ( ELeave ) CAknDoubleStyleListBox;
       
    80     iListBox->ConstructL( this, EAknListBoxSelectionList );
       
    81     
       
    82     //iListBox->SetListBoxObserver( this );
       
    83     
       
    84     iListBox->SetContainerWindowL(*this);
       
    85     iListBox->CreateScrollBarFrameL(ETrue);
       
    86     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL
       
    87         (CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
    88         
       
    89     // set marquee on
       
    90     iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
       
    91    	iListBox->Model()->SetItemTextArray( iItemArray );
       
    92 	iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
    93 	
       
    94 	iListBox->SetListBoxObserver( this );
       
    95 			
       
    96 	ActivateL();
       
    97 
       
    98     }
       
    99 
       
   100 
       
   101 // --------------------------------------------------------------------------
       
   102 // CVIMPSTUiSearchViewControl::NewL
       
   103 // --------------------------------------------------------------------------
       
   104 //
       
   105 CVIMPSTUiSearchViewControl* CVIMPSTUiSearchViewControl::NewL
       
   106         								  ( MPbk2KeyEventHandler* aKeyEventHandler, 
       
   107         									TUint32 aServiceId,
       
   108         									MVIMPSTEngine& aEngine,
       
   109         									MVIMPSTCmdHandler& aCommandHandler,
       
   110         									CVIMPSTUiSearchView& aSearchView )
       
   111     {
       
   112     CVIMPSTUiSearchViewControl* self = NewLC(aKeyEventHandler,
       
   113     										 aServiceId, aEngine, 
       
   114     										 aCommandHandler, aSearchView );
       
   115     CleanupStack::Pop(self);
       
   116     return self;
       
   117     }
       
   118 
       
   119 
       
   120 // --------------------------------------------------------------------------
       
   121 // CVIMPSTUiSearchViewControl::NewLC
       
   122 // --------------------------------------------------------------------------
       
   123 //
       
   124 CVIMPSTUiSearchViewControl* CVIMPSTUiSearchViewControl::NewLC
       
   125 									        ( MPbk2KeyEventHandler* aKeyEventHandler,
       
   126 									          TUint32 aServiceId,
       
   127 									          MVIMPSTEngine& aEngine,
       
   128 									          MVIMPSTCmdHandler& aCommandHandler,
       
   129 									          CVIMPSTUiSearchView& aSearchView )
       
   130     {
       
   131     CVIMPSTUiSearchViewControl* self =
       
   132         new (ELeave) CVIMPSTUiSearchViewControl(aKeyEventHandler,
       
   133         									 aServiceId, aEngine,
       
   134         									 aCommandHandler, aSearchView);
       
   135     CleanupStack::PushL(self);
       
   136     self->ConstructL();
       
   137     return self;
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CVIMPSTUiSearchViewControl::Destructor
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 CVIMPSTUiSearchViewControl::~CVIMPSTUiSearchViewControl()
       
   145     {
       
   146    
       
   147 	delete iItemArray;
       
   148     delete iListBox;
       
   149 	}
       
   150 
       
   151 // ---------------------------------------------------------
       
   152 // CVIMPSTUiSearchViewControl::SearchResultL()
       
   153 // ---------------------------------------------------------
       
   154 //
       
   155 void CVIMPSTUiSearchViewControl::SearchResultL(RArray<TVIMPSTSearchData> aSearchData )
       
   156     {
       
   157    	UpdateListBoxL(aSearchData);
       
   158     }
       
   159 
       
   160 
       
   161 // ---------------------------------------------------------
       
   162 // CVIMPSTUiSearchViewControl::SearchFinishedL()
       
   163 // ---------------------------------------------------------
       
   164 //
       
   165 void CVIMPSTUiSearchViewControl::SearchFinishedL(TInt /*aError*/)
       
   166     {
       
   167     // if any error show error note
       
   168     if( ! iItemArray->Count() )
       
   169 	    {
       
   170 	    SetEmptyTextsToListboxL();	
       
   171 	    iListBox->DrawNow();
       
   172 	    }
       
   173 	UpdateCbaL();
       
   174 	}
       
   175 
       
   176 // ---------------------------------------------------------
       
   177 // CVIMPSTUiSearchViewControl::HandleControlEventL
       
   178 // ---------------------------------------------------------
       
   179 //
       
   180 void CVIMPSTUiSearchViewControl::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent aEventType)
       
   181     {
       
   182     // We only observe iFindbox
       
   183     if( EEventStateChanged == aEventType )
       
   184         {
       
   185 
       
   186       	((CAknFilteredTextListBoxModel*) iListBox->Model() )
       
   187             ->Filter()->HandleOfferkeyEventL();        
       
   188         
       
   189         }
       
   190     }
       
   191 
       
   192 // ---------------------------------------------------------------------------
       
   193 // CVIMPSTUiSearchViewControl::SetEmptyTextsToListboxL()
       
   194 // See header for details. 
       
   195 // ---------------------------------------------------------------------------
       
   196 //
       
   197 void CVIMPSTUiSearchViewControl::SetEmptyTextsToListboxL()
       
   198     {    
       
   199     HBufC* emptyFinal = VIMPSTUtils::CombineStringFromResourceLC
       
   200     									( R_QTN_CHAT_EMPTY_SEARCH_PRIMARY, 
       
   201     									  R_QTN_CHAT_EMPTY_SEARCH);
       
   202     				
       
   203     iListBox->View()->SetListEmptyTextL( *emptyFinal );
       
   204     CleanupStack::PopAndDestroy(); // emptyFinal    
       
   205     }
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // CVIMPSTUiSearchViewControl::SetSearchingTextToListboxL()
       
   209 // See header for details. 
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 void CVIMPSTUiSearchViewControl::SetSearchingTextToListboxL()
       
   213     {    
       
   214     iListBox->View()->SetListEmptyTextL( KSpace );
       
   215     iListBox->DrawNow();
       
   216     }
       
   217 
       
   218 
       
   219 // ---------------------------------------------------------
       
   220 // CVIMPSTUiSearchViewControl::HandleListBoxEventL
       
   221 // Handles list box events
       
   222 // (other items were commented in a header).
       
   223 // ---------------------------------------------------------
       
   224 //
       
   225 void CVIMPSTUiSearchViewControl::HandleListBoxEventL( CEikListBox* /*aListBox*/,
       
   226 												 TListBoxEvent aEventType )
       
   227     {
       
   228     switch(aEventType)
       
   229         {
       
   230 
       
   231         case EEventItemSingleClicked:
       
   232 
       
   233             {
       
   234             TInt curIndex = iListBox->CurrentItemIndex();
       
   235             if( curIndex >=0)
       
   236                 {
       
   237             HBufC* contactId = GetFocusedContactLC() ;
       
   238 
       
   239             if ( contactId->Length() )
       
   240                 {
       
   241             if( iCommandHandler.GetProcessInterface().FindAnyContact( *contactId ) )
       
   242                 {
       
   243             //contact is already there in contact list
       
   244             TInt index = iCommandHandler.GetProcessInterface().FindContactIndexL(*contactId);
       
   245             TVIMPSTEnums::TOnlineStatus onlinestatus = iCommandHandler.GetProcessInterface().GetOnlineStatusL(index);
       
   246             if(TVIMPSTEnums::EPending != onlinestatus) //if contact is not remote pending
       
   247                 {
       
   248             //open conversation view
       
   249             OpenConversationL( *contactId );   
       
   250                 }
       
   251 
       
   252                 }
       
   253             else 
       
   254                 {	
       
   255             //ask the query for adding contact
       
   256             HBufC* queryTxt = StringLoader::LoadLC( R_QTN_CHAT_REACTIVE_ADD_LIST, *contactId );
       
   257             TInt response = VIMPSTUtilsDialog::DisplayQueryDialogL(
       
   258                     R_GENERIC_YES_NO_CONFIRMATION_QUERY,
       
   259                     *queryTxt );
       
   260 
       
   261             if ( ( response == EAknSoftkeyOk ) || ( response == EAknSoftkeyYes ) )
       
   262                 {
       
   263             iSearchView.HandleCommandL( ESearchAddFriends );
       
   264                 }
       
   265             CleanupStack::PopAndDestroy( queryTxt );	 
       
   266                 }
       
   267                 }
       
   268             CleanupStack::PopAndDestroy( contactId );	 
       
   269                 }
       
   270             break;
       
   271             }
       
   272             // Add enter key handling
       
   273         case EEventEnterKeyPressed:
       
   274             {
       
   275             CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   276             TInt commandId( iCba->ButtonGroup()->CommandId( CEikButtonGroupContainer::EMiddleSoftkeyPosition));
       
   277 
       
   278             iSearchView.HandleCommandL(commandId);
       
   279             break;
       
   280             }
       
   281         }
       
   282     UpdateCbaL();	  
       
   283 	}
       
   284 
       
   285 // ---------------------------------------------------------
       
   286 // CVIMPSTUiSearchViewControl::OpenConversationL(
       
   287 // (other items were commented in a header).
       
   288 // ---------------------------------------------------------
       
   289 void CVIMPSTUiSearchViewControl::OpenConversationL(const TDesC& aContactId )
       
   290 	{
       
   291 	MVIMPSTProcessArray& arrayProcess = iCommandHandler.GetProcessInterface();
       
   292 	TInt indexInTabbedView = arrayProcess.FindContactIndexL( aContactId );
       
   293 	TInt result = EAknSoftkeyOk;
       
   294 
       
   295 	//get the status from engine.
       
   296 	TVIMPSTEnums::TOnlineStatus status = arrayProcess.GetOnlineStatusL(indexInTabbedView);
       
   297 
       
   298 	if( status == TVIMPSTEnums::EOffline )
       
   299 	    {
       
   300 	    TBool isConvExist = arrayProcess.IsConversationExistL( aContactId );
       
   301 	    
       
   302 	    if( !isConvExist)
       
   303 		    {
       
   304 		
       
   305 			HBufC* msg = StringLoader::LoadLC( R_QTN_CHAT_CONTACT_MAY_NOT_RECEIVE_MESSAGE,
       
   306 										        aContactId );                    
       
   307 
       
   308 			 result = VIMPSTUtilsDialog::DisplayQueryDialogL(
       
   309 			        R_CHAT_CONTACT_MAY_NOT_RECEIVE_MESSAGE_DIALOG,
       
   310 			        msg->Des() );
       
   311 			CleanupStack::PopAndDestroy( msg );
       
   312 		    }
       
   313 	    }
       
   314 
       
   315 	if( ( result == EAknSoftkeyOk ) || ( result == EAknSoftkeyYes ) )
       
   316 		{
       
   317 		TVwsViewId activeViewId;
       
   318 	    CCoeEnv::Static()->AppUi()->GetActiveViewId( activeViewId );
       
   319 	    TPtrC itemName = arrayProcess.GetItemNameText(indexInTabbedView) ;
       
   320 	    // not own this p
       
   321 	    MVPbkContactLink* contactLink = arrayProcess.ContactLink( indexInTabbedView );
       
   322 		arrayProcess.ResetPendingMsg( indexInTabbedView );
       
   323 		// imlauncher call for luanching the conversationview with seletced contact
       
   324 		//IMCVLauncher::LaunchImConversationViewL(activeViewId, iServiceId, aContactId );	
       
   325 		// imlauncher call for luanching the conversationview with seletced user id
       
   326 		IMCVLauncher::LaunchImConversationViewL(activeViewId, iServiceId, aContactId, itemName, contactLink);
       
   327 		}
       
   328 	}
       
   329 
       
   330 
       
   331 // ---------------------------------------------------------
       
   332 // CVIMPSTUiSearchViewControl::SizeChanged()
       
   333 // Called by framework
       
   334 // (other items were commented in a header).
       
   335 // ---------------------------------------------------------
       
   336 //
       
   337 void CVIMPSTUiSearchViewControl::SizeChanged()
       
   338 	{
       
   339 	if ( iListBox )
       
   340         {
       
   341         iListBox->SetRect(Rect());
       
   342         }  
       
   343     }
       
   344 
       
   345 // ---------------------------------------------------------
       
   346 // CVIMPSTUiSearchViewControl::CountComponentControls()
       
   347 // Returns number of controls
       
   348 // (other items were commented in a header).
       
   349 // ---------------------------------------------------------
       
   350 //
       
   351 TInt CVIMPSTUiSearchViewControl::CountComponentControls() const
       
   352 	{
       
   353 	//Only one compound control so returning 1
       
   354 	return 1;
       
   355 	}
       
   356 
       
   357 // ---------------------------------------------------------
       
   358 // CVIMPSTUiSearchViewControl::ComponentControl( TInt aIndex )
       
   359 // Returns control for given index
       
   360 // (other items were commented in a header).
       
   361 // ---------------------------------------------------------
       
   362 //
       
   363 CCoeControl* CVIMPSTUiSearchViewControl::ComponentControl( TInt aIndex ) const
       
   364 	{
       
   365 	if( aIndex == 0 )
       
   366 		{
       
   367         return iListBox;
       
   368         }
       
   369     else
       
   370         {
       
   371         return NULL;
       
   372     	}
       
   373 	}
       
   374 
       
   375 // ---------------------------------------------------------
       
   376 // CVIMPSTUiSearchViewControl::OfferKeyEventL()
       
   377 // Handles user key inputs
       
   378 // (other items were commented in a header).
       
   379 // ---------------------------------------------------------
       
   380 //
       
   381 TKeyResponse CVIMPSTUiSearchViewControl::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   382 													TEventCode aType )
       
   383 	{
       
   384 	TKeyResponse result = EKeyWasNotConsumed;
       
   385 
       
   386     // Offer key event first to the key event handler
       
   387     if ( iKeyEventHandler && iKeyEventHandler->Pbk2ProcessKeyEventL
       
   388             ( aKeyEvent, aType ) )
       
   389         {
       
   390         result = EKeyWasConsumed;
       
   391         }
       
   392         
       
   393     switch ( aKeyEvent.iCode )
       
   394            {
       
   395          /*  case EKeyEnter:
       
   396 				{
       
   397 				iSearchView.HandleCommandL(iCurrentCmdToExe);
       
   398 				result = EKeyWasConsumed;
       
   399 				break;
       
   400 				}*/
       
   401 			default:
       
   402 				break;
       
   403            }
       
   404         
       
   405     // Not consumed by the key handler, offer to the control next
       
   406     if ( result == EKeyWasNotConsumed )
       
   407         {
       
   408         if ( iListBox )
       
   409             {
       
   410             result = iListBox->OfferKeyEventL(aKeyEvent, aType);
       
   411             }
       
   412         }
       
   413     UpdateCbaL();
       
   414     return result;
       
   415     
       
   416 	}
       
   417 
       
   418 
       
   419 // ---------------------------------------------------------
       
   420 // CVIMPSTUiSearchViewControl::UpdateListBoxL()
       
   421 // ---------------------------------------------------------
       
   422 //
       
   423 void CVIMPSTUiSearchViewControl::UpdateListBoxL(RArray<TVIMPSTSearchData> aSerachData)
       
   424     {
       
   425 	
       
   426 	TInt granularity( iItemArray->Count() );
       
   427 	++granularity;
       
   428 	
       
   429    	CDesCArray* tempArray = new ( ELeave ) CDesCArrayFlat( granularity );
       
   430 	CleanupStack::PushL( tempArray );
       
   431     
       
   432     iListBox->Model()->SetItemTextArray( tempArray );
       
   433 	iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   434 	iListBox->HandleItemAdditionL();
       
   435 	for ( TInt i =0; i < aSerachData.Count() ; ++ i)
       
   436 	    {
       
   437 	    TVIMPSTSearchData data = aSerachData [i];
       
   438 	    HBufC* itemText = HBufC::NewLC( 100 );
       
   439 	    TPtr itemTextPtr( itemText->Des() );
       
   440 
       
   441 	    itemTextPtr.Append( KTab );
       
   442 
       
   443 	    itemTextPtr.Append( VIMPSTUtils::DisplayId( data.iEmailId ));
       
   444 	    itemTextPtr.Append( KTab );
       
   445 
       
   446 	    itemTextPtr.Append(data.iEmailId);
       
   447 	    itemTextPtr.Append( KTab );
       
   448 
       
   449 	    iItemArray->AppendL( itemTextPtr );
       
   450 	    CleanupStack::PopAndDestroy( itemText );
       
   451 	    }
       
   452     
       
   453 	CleanupStack::PopAndDestroy(tempArray );  // tempArray
       
   454 	
       
   455 	
       
   456 	iListBox->Model()->SetItemTextArray( iItemArray );
       
   457 	iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   458 
       
   459     iListBox->HandleItemAdditionL();
       
   460     
       
   461 	if ( iItemArray->MdcaCount() > 0 )
       
   462 		{
       
   463 		iListBox->SetCurrentItemIndexAndDraw( 0 );
       
   464 		}
       
   465 		
       
   466     iListBox->UpdateScrollBarsL();
       
   467     
       
   468     UpdateCbaL();
       
   469        
       
   470     }
       
   471     
       
   472     
       
   473 // ---------------------------------------------------------
       
   474 // CVIMPSTUiSearchViewControl::ListBox()
       
   475 // (other items were commented in a header).
       
   476 // ---------------------------------------------------------
       
   477 //
       
   478 CEikListBox* CVIMPSTUiSearchViewControl::ListBox() const
       
   479 	{
       
   480 	return iListBox;
       
   481 	}
       
   482 
       
   483 // ---------------------------------------------------------
       
   484 // CVIMPSTUiSearchViewControl::GetFocusedItemText
       
   485 // (other items were commented in a header).
       
   486 // ---------------------------------------------------------
       
   487 //
       
   488 HBufC* CVIMPSTUiSearchViewControl::GetFocusedContactLC() const
       
   489 	{
       
   490 	HBufC* retText=NULL;
       
   491 	TInt curIndex = iListBox->CurrentItemIndex();
       
   492     TPtrC ptr= iItemArray->MdcaPoint(curIndex);
       
   493     ptr.Set(ptr.Mid(1));  // set pointer from next char :since first char is KTab
       
   494     
       
   495     TInt pos=ptr.FindC(KTab);
       
   496    
       
   497     if( pos !=KErrNotFound &&  (pos != ptr.Length()-1))
       
   498       {
       
   499       ptr.Set(ptr.Mid( pos+1, ( ptr.Length()-2-pos )));
       
   500       retText = ptr.AllocLC();
       
   501       }
       
   502     return retText;
       
   503 	}
       
   504 
       
   505 // ---------------------------------------------------------
       
   506 // CVIMPSTUiSearchViewControl::ClearListBoxContents()
       
   507 // ---------------------------------------------------------
       
   508 //
       
   509 void CVIMPSTUiSearchViewControl::ClearListBoxContents()
       
   510     {
       
   511 	iItemArray->Reset();
       
   512     TRAPD( err, iListBox->HandleItemRemovalL() );
       
   513     if( err != KErrNone )
       
   514         {
       
   515         CActiveScheduler::Current()->Error( err );
       
   516         }
       
   517     iListBox->DrawNow();
       
   518     }
       
   519 // ---------------------------------------------------------
       
   520 // CVIMPSTUiSearchViewControl::UpdateCbaL()
       
   521 // Updates Softkeys according to current focus.
       
   522 // ---------------------------------------------------------
       
   523 //
       
   524 void CVIMPSTUiSearchViewControl::UpdateCbaL( TBool  aUseDefaultCba /*= EFalse*/ )
       
   525     {
       
   526     TInt cbaRes = R_SERVTAB_SOFTKEYS_OPTIONS_BACK__EMPTY;
       
   527     iCurrentCmdToExe = -1;
       
   528     TInt index = KErrNotFound;
       
   529     if ( !iCba ) 
       
   530         {
       
   531         iCba = CEikButtonGroupContainer::Current();
       
   532         }
       
   533     if( iListBox )
       
   534 	    {
       
   535 	    index = iListBox->CurrentItemIndex();	
       
   536 	    }
       
   537     if( aUseDefaultCba )  
       
   538 	    {
       
   539 	    cbaRes = R_SERVTAB_SOFTKEYS_OPTIONS_BACK__EMPTY;
       
   540 	    }
       
   541     else if( KErrNotFound == index )
       
   542 		{
       
   543 		cbaRes = R_SERVTAB_SOFTKEYS_OPTION_NEW_SEARCH__BACK;
       
   544 		iCurrentCmdToExe = ESearchNew;
       
   545 		}
       
   546 	else //some results are there, hence update it to add to contacts.
       
   547 		{
       
   548 		if(iSearchView.HideAddToContactsL())
       
   549 		    {			
       
   550 		    CHAT_DP( D_CHAT_LIT("CVIMPSTUiDoubleListboxArray::HideAddToContactsL after" ) );		
       
   551 		    HBufC* contactId = GetFocusedContactLC();
       
   552 		    TInt curIndex = iCommandHandler.GetProcessInterface().FindContactIndexL(*contactId); 
       
   553 		    TVIMPSTEnums::TOnlineStatus onlinestatus = iCommandHandler.GetProcessInterface().GetOnlineStatusL(curIndex);   
       
   554 		    CleanupStack::PopAndDestroy(contactId);
       
   555 		    if( TVIMPSTEnums::EPending == onlinestatus )
       
   556 		        {
       
   557 		        CHAT_DP( D_CHAT_LIT("CVIMPSTUiDoubleListboxArray::EPending in" ) );		
       
   558 		        cbaRes = R_SERVTAB_SOFTKEYS_OPTIONS_BACK__EMPTY;
       
   559 		        iCurrentCmdToExe = -1;    
       
   560 		        }
       
   561 		    else
       
   562 		        {
       
   563 		        CHAT_DP( D_CHAT_LIT("CVIMPSTUiDoubleListboxArray::ESearchOpenConversation" ) );		
       
   564 		        cbaRes = R_SERVTAB_SOFTKEYS_OPTION_SEARCH_OPENCONV__BACK;
       
   565 		        iCurrentCmdToExe = ESearchOpenConversation;    
       
   566 		        }
       
   567 
       
   568 		    }
       
   569 		else
       
   570 			{
       
   571 			cbaRes = R_SERVTAB_SOFTKEYS_OPTION_ADD_TO_CONTACTS__BACK;	
       
   572 			iCurrentCmdToExe = ESearchAddFriends;
       
   573 			}   
       
   574         }
       
   575   	if( iCba )
       
   576         {
       
   577         iCba->SetCommandSetL( cbaRes );
       
   578      	iCba->DrawNow();
       
   579         }
       
   580     }
       
   581 
       
   582 //  End of File