uiservicetab/vimpstui/src/cvimpstuisearchviewcontrol.cpp
branchRCL_3
changeset 22 3104fc151679
parent 21 2b7283837edb
child 23 9a48e301e94b
equal deleted inserted replaced
21:2b7283837edb 22:3104fc151679
     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 "uiservicetabtracer.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 	TRACER_AUTO;
       
   229     switch(aEventType)
       
   230         {
       
   231 
       
   232         case EEventItemSingleClicked:
       
   233 
       
   234             {
       
   235             TInt curIndex = iListBox->CurrentItemIndex();
       
   236             if( curIndex >=0)
       
   237                 {
       
   238             HBufC* contactId = GetFocusedContactLC() ;
       
   239 
       
   240             if ( contactId->Length() )
       
   241                 {
       
   242             if( iCommandHandler.GetProcessInterface().FindAnyContact( *contactId ) )
       
   243                 {
       
   244             //contact is already there in contact list
       
   245             TInt index = iCommandHandler.GetProcessInterface().FindContactIndexL(*contactId);
       
   246             TVIMPSTEnums::TOnlineStatus onlinestatus = iCommandHandler.GetProcessInterface().GetOnlineStatusL(index);
       
   247             if(TVIMPSTEnums::EPending != onlinestatus) //if contact is not remote pending
       
   248                 {
       
   249             //open conversation view
       
   250             OpenConversationL( *contactId );   
       
   251                 }
       
   252 
       
   253                 }
       
   254             else 
       
   255                 {	
       
   256             //ask the query for adding contact
       
   257             HBufC* queryTxt = StringLoader::LoadLC( R_QTN_CHAT_REACTIVE_ADD_LIST, *contactId );
       
   258             TInt response = VIMPSTUtilsDialog::DisplayQueryDialogL(
       
   259                     R_GENERIC_YES_NO_CONFIRMATION_QUERY,
       
   260                     *queryTxt );
       
   261 
       
   262             if ( ( response == EAknSoftkeyOk ) || ( response == EAknSoftkeyYes ) )
       
   263                 {
       
   264             iSearchView.HandleCommandL( ESearchAddFriends );
       
   265                 }
       
   266             CleanupStack::PopAndDestroy( queryTxt );	 
       
   267                 }
       
   268                 }
       
   269             CleanupStack::PopAndDestroy( contactId );	 
       
   270                 }
       
   271             break;
       
   272             }
       
   273             // Add enter key handling
       
   274         case EEventEnterKeyPressed:
       
   275             {
       
   276             CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   277             TInt commandId( iCba->ButtonGroup()->CommandId( CEikButtonGroupContainer::EMiddleSoftkeyPosition));
       
   278 
       
   279             iSearchView.HandleCommandL(commandId);
       
   280             break;
       
   281             }
       
   282         }
       
   283     UpdateCbaL();	  
       
   284 	}
       
   285 
       
   286 // ---------------------------------------------------------
       
   287 // CVIMPSTUiSearchViewControl::OpenConversationL(
       
   288 // (other items were commented in a header).
       
   289 // ---------------------------------------------------------
       
   290 void CVIMPSTUiSearchViewControl::OpenConversationL(const TDesC& aContactId )
       
   291 	{
       
   292 	TRACER_AUTO;
       
   293 	MVIMPSTProcessArray& arrayProcess = iCommandHandler.GetProcessInterface();
       
   294 	TInt indexInTabbedView = arrayProcess.FindContactIndexL( aContactId );
       
   295 	TInt result = EAknSoftkeyOk;
       
   296 
       
   297 	//get the status from engine.
       
   298 	TVIMPSTEnums::TOnlineStatus status = arrayProcess.GetOnlineStatusL(indexInTabbedView);
       
   299 
       
   300 	if( status == TVIMPSTEnums::EOffline )
       
   301 	    {
       
   302 	    TBool isConvExist = arrayProcess.IsConversationExistL( aContactId );
       
   303 	    
       
   304 	    if( !isConvExist)
       
   305 		    {
       
   306 		
       
   307 			HBufC* msg = StringLoader::LoadLC( R_QTN_CHAT_CONTACT_MAY_NOT_RECEIVE_MESSAGE,
       
   308 										        aContactId );                    
       
   309 
       
   310 			 result = VIMPSTUtilsDialog::DisplayQueryDialogL(
       
   311 			        R_CHAT_CONTACT_MAY_NOT_RECEIVE_MESSAGE_DIALOG,
       
   312 			        msg->Des() );
       
   313 			CleanupStack::PopAndDestroy( msg );
       
   314 		    }
       
   315 	    }
       
   316 
       
   317 	if( ( result == EAknSoftkeyOk ) || ( result == EAknSoftkeyYes ) )
       
   318 		{
       
   319 		TVwsViewId activeViewId;
       
   320 	    CCoeEnv::Static()->AppUi()->GetActiveViewId( activeViewId );
       
   321 	    TPtrC itemName = arrayProcess.GetItemNameText(indexInTabbedView) ;
       
   322 	    // not own this p
       
   323 	    MVPbkContactLink* contactLink = arrayProcess.ContactLink( indexInTabbedView );
       
   324 		arrayProcess.ResetPendingMsg( indexInTabbedView );
       
   325 		// imlauncher call for luanching the conversationview with seletced contact
       
   326 		//IMCVLauncher::LaunchImConversationViewL(activeViewId, iServiceId, aContactId );	
       
   327 		// imlauncher call for luanching the conversationview with seletced user id
       
   328 		IMCVLauncher::LaunchImConversationViewL(activeViewId, iServiceId, aContactId, itemName, contactLink);
       
   329 		}
       
   330 	}
       
   331 
       
   332 
       
   333 // ---------------------------------------------------------
       
   334 // CVIMPSTUiSearchViewControl::SizeChanged()
       
   335 // Called by framework
       
   336 // (other items were commented in a header).
       
   337 // ---------------------------------------------------------
       
   338 //
       
   339 void CVIMPSTUiSearchViewControl::SizeChanged()
       
   340 	{
       
   341 	TRACER_AUTO;
       
   342 	if ( iListBox )
       
   343         {
       
   344         iListBox->SetRect(Rect());
       
   345         }  
       
   346     }
       
   347 
       
   348 // ---------------------------------------------------------
       
   349 // CVIMPSTUiSearchViewControl::CountComponentControls()
       
   350 // Returns number of controls
       
   351 // (other items were commented in a header).
       
   352 // ---------------------------------------------------------
       
   353 //
       
   354 TInt CVIMPSTUiSearchViewControl::CountComponentControls() const
       
   355 	{
       
   356 	//Only one compound control so returning 1
       
   357 	return 1;
       
   358 	}
       
   359 
       
   360 // ---------------------------------------------------------
       
   361 // CVIMPSTUiSearchViewControl::ComponentControl( TInt aIndex )
       
   362 // Returns control for given index
       
   363 // (other items were commented in a header).
       
   364 // ---------------------------------------------------------
       
   365 //
       
   366 CCoeControl* CVIMPSTUiSearchViewControl::ComponentControl( TInt aIndex ) const
       
   367 	{
       
   368 	if( aIndex == 0 )
       
   369 		{
       
   370         return iListBox;
       
   371         }
       
   372     else
       
   373         {
       
   374         return NULL;
       
   375     	}
       
   376 	}
       
   377 
       
   378 // ---------------------------------------------------------
       
   379 // CVIMPSTUiSearchViewControl::OfferKeyEventL()
       
   380 // Handles user key inputs
       
   381 // (other items were commented in a header).
       
   382 // ---------------------------------------------------------
       
   383 //
       
   384 TKeyResponse CVIMPSTUiSearchViewControl::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   385 													TEventCode aType )
       
   386 	{
       
   387 	TRACER_AUTO;
       
   388 	TKeyResponse result = EKeyWasNotConsumed;
       
   389 
       
   390     // Offer key event first to the key event handler
       
   391     if ( iKeyEventHandler && iKeyEventHandler->Pbk2ProcessKeyEventL
       
   392             ( aKeyEvent, aType ) )
       
   393         {
       
   394         result = EKeyWasConsumed;
       
   395         }
       
   396         
       
   397     switch ( aKeyEvent.iCode )
       
   398            {
       
   399          /*  case EKeyEnter:
       
   400 				{
       
   401 				iSearchView.HandleCommandL(iCurrentCmdToExe);
       
   402 				result = EKeyWasConsumed;
       
   403 				break;
       
   404 				}*/
       
   405 			default:
       
   406 				break;
       
   407            }
       
   408         
       
   409     // Not consumed by the key handler, offer to the control next
       
   410     if ( result == EKeyWasNotConsumed )
       
   411         {
       
   412         if ( iListBox )
       
   413             {
       
   414             result = iListBox->OfferKeyEventL(aKeyEvent, aType);
       
   415             }
       
   416         }
       
   417     UpdateCbaL();
       
   418     return result;
       
   419     
       
   420 	}
       
   421 
       
   422 
       
   423 // ---------------------------------------------------------
       
   424 // CVIMPSTUiSearchViewControl::UpdateListBoxL()
       
   425 // ---------------------------------------------------------
       
   426 //
       
   427 void CVIMPSTUiSearchViewControl::UpdateListBoxL(RArray<TVIMPSTSearchData> aSerachData)
       
   428     {
       
   429 	TRACER_AUTO;
       
   430 	TInt granularity( iItemArray->Count() );
       
   431 	++granularity;
       
   432 	
       
   433    	CDesCArray* tempArray = new ( ELeave ) CDesCArrayFlat( granularity );
       
   434 	CleanupStack::PushL( tempArray );
       
   435     
       
   436     iListBox->Model()->SetItemTextArray( tempArray );
       
   437 	iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   438 	iListBox->HandleItemAdditionL();
       
   439 	for ( TInt i =0; i < aSerachData.Count() ; ++ i)
       
   440 	    {
       
   441 	    TVIMPSTSearchData data = aSerachData [i];
       
   442 	    HBufC* itemText = HBufC::NewLC( 100 );
       
   443 	    TPtr itemTextPtr( itemText->Des() );
       
   444 
       
   445 	    itemTextPtr.Append( KTab );
       
   446 
       
   447 	    itemTextPtr.Append( VIMPSTUtils::DisplayId( data.iEmailId ));
       
   448 	    itemTextPtr.Append( KTab );
       
   449 
       
   450 	    itemTextPtr.Append(data.iEmailId);
       
   451 	    itemTextPtr.Append( KTab );
       
   452 
       
   453 	    iItemArray->AppendL( itemTextPtr );
       
   454 	    CleanupStack::PopAndDestroy( itemText );
       
   455 	    }
       
   456     
       
   457 	CleanupStack::PopAndDestroy(tempArray );  // tempArray
       
   458 	
       
   459 	
       
   460 	iListBox->Model()->SetItemTextArray( iItemArray );
       
   461 	iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   462 
       
   463     iListBox->HandleItemAdditionL();
       
   464     
       
   465 	if ( iItemArray->MdcaCount() > 0 )
       
   466 		{
       
   467 		iListBox->SetCurrentItemIndexAndDraw( 0 );
       
   468 		}
       
   469 		
       
   470     iListBox->UpdateScrollBarsL();
       
   471     
       
   472     UpdateCbaL();
       
   473        
       
   474     }
       
   475     
       
   476     
       
   477 // ---------------------------------------------------------
       
   478 // CVIMPSTUiSearchViewControl::ListBox()
       
   479 // (other items were commented in a header).
       
   480 // ---------------------------------------------------------
       
   481 //
       
   482 CEikListBox* CVIMPSTUiSearchViewControl::ListBox() const
       
   483 	{
       
   484 	return iListBox;
       
   485 	}
       
   486 
       
   487 // ---------------------------------------------------------
       
   488 // CVIMPSTUiSearchViewControl::GetFocusedItemText
       
   489 // (other items were commented in a header).
       
   490 // ---------------------------------------------------------
       
   491 //
       
   492 HBufC* CVIMPSTUiSearchViewControl::GetFocusedContactLC() const
       
   493 	{
       
   494 	TRACER_AUTO;
       
   495 	HBufC* retText=NULL;
       
   496 	TInt curIndex = iListBox->CurrentItemIndex();
       
   497     TPtrC ptr= iItemArray->MdcaPoint(curIndex);
       
   498     ptr.Set(ptr.Mid(1));  // set pointer from next char :since first char is KTab
       
   499     
       
   500     TInt pos=ptr.FindC(KTab);
       
   501    
       
   502     if( pos !=KErrNotFound &&  (pos != ptr.Length()-1))
       
   503       {
       
   504       ptr.Set(ptr.Mid( pos+1, ( ptr.Length()-2-pos )));
       
   505       retText = ptr.AllocLC();
       
   506       }
       
   507     return retText;
       
   508 	}
       
   509 
       
   510 // ---------------------------------------------------------
       
   511 // CVIMPSTUiSearchViewControl::ClearListBoxContents()
       
   512 // ---------------------------------------------------------
       
   513 //
       
   514 void CVIMPSTUiSearchViewControl::ClearListBoxContents()
       
   515     {
       
   516 	TRACER_AUTO;
       
   517 	iItemArray->Reset();
       
   518     TRAPD( err, iListBox->HandleItemRemovalL() );
       
   519     if( err != KErrNone )
       
   520         {
       
   521         CActiveScheduler::Current()->Error( err );
       
   522         }
       
   523     iListBox->DrawNow();
       
   524     }
       
   525 // ---------------------------------------------------------
       
   526 // CVIMPSTUiSearchViewControl::UpdateCbaL()
       
   527 // Updates Softkeys according to current focus.
       
   528 // ---------------------------------------------------------
       
   529 //
       
   530 void CVIMPSTUiSearchViewControl::UpdateCbaL( TBool  aUseDefaultCba /*= EFalse*/ )
       
   531     {
       
   532 	TRACER_AUTO;
       
   533     TInt cbaRes = R_SERVTAB_SOFTKEYS_OPTIONS_BACK__EMPTY;
       
   534     iCurrentCmdToExe = -1;
       
   535     TInt index = KErrNotFound;
       
   536     if ( !iCba ) 
       
   537         {
       
   538         iCba = CEikButtonGroupContainer::Current();
       
   539         }
       
   540     if( iListBox )
       
   541 	    {
       
   542 	    index = iListBox->CurrentItemIndex();	
       
   543 	    }
       
   544     if( aUseDefaultCba )  
       
   545 	    {
       
   546 	    cbaRes = R_SERVTAB_SOFTKEYS_OPTIONS_BACK__EMPTY;
       
   547 	    }
       
   548     else if( KErrNotFound == index )
       
   549 		{
       
   550 		cbaRes = R_SERVTAB_SOFTKEYS_OPTION_NEW_SEARCH__BACK;
       
   551 		iCurrentCmdToExe = ESearchNew;
       
   552 		}
       
   553 	else //some results are there, hence update it to add to contacts.
       
   554 		{
       
   555 		if(iSearchView.HideAddToContactsL())
       
   556 		    {			
       
   557 		   TRACE(" after"  );		
       
   558 		    HBufC* contactId = GetFocusedContactLC();
       
   559 		    TInt curIndex = iCommandHandler.GetProcessInterface().FindContactIndexL(*contactId); 
       
   560 		    TVIMPSTEnums::TOnlineStatus onlinestatus = iCommandHandler.GetProcessInterface().GetOnlineStatusL(curIndex);   
       
   561 		    CleanupStack::PopAndDestroy(contactId);
       
   562 		    if( TVIMPSTEnums::EPending == onlinestatus )
       
   563 		        {
       
   564 		        TRACE(" EPending in"  );		
       
   565 		        cbaRes = R_SERVTAB_SOFTKEYS_OPTIONS_BACK__EMPTY;
       
   566 		        iCurrentCmdToExe = -1;    
       
   567 		        }
       
   568 		    else
       
   569 		        {
       
   570 		        TRACE("ESearchOpenConversation"  );		
       
   571 		        cbaRes = R_SERVTAB_SOFTKEYS_OPTION_SEARCH_OPENCONV__BACK;
       
   572 		        iCurrentCmdToExe = ESearchOpenConversation;    
       
   573 		        }
       
   574 
       
   575 		    }
       
   576 		else
       
   577 			{
       
   578 			cbaRes = R_SERVTAB_SOFTKEYS_OPTION_ADD_TO_CONTACTS__BACK;	
       
   579 			iCurrentCmdToExe = ESearchAddFriends;
       
   580 			}   
       
   581         }
       
   582   	if( iCba )
       
   583         {
       
   584         iCba->SetCommandSetL( cbaRes );
       
   585      	iCba->DrawNow();
       
   586         }
       
   587     }
       
   588 
       
   589 //  End of File