uiservicetab/vimpstui/src/cvimpstuisinglelistboxtabviewcontrol.cpp
branchRCL_3
changeset 29 9a48e301e94b
child 34 e7f34e614544
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     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 CVIMPSTUiDoubleListBoxTabViewControl.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cvimpstuisinglelistboxtabviewcontrol.h"
       
    21 
       
    22 #include "cvimpstuisinglelistboxarray.h"
       
    23 #include "tvimpstenums.h"
       
    24 #include "mvimpstcmdhandler.h"
       
    25 #include "cvimpstuibranddata.h"
       
    26 #include "imcvuiliterals.h"
       
    27 #include "cvimpstuilistboxmodel.h"
       
    28 #include "vimpstutilsdialog.h"
       
    29 #include "vimpstui.hrh"
       
    30 #include "cvimpstuitabbedview.h"
       
    31 #include "mvimpstengine.h"
       
    32 #include "cvimpststoragemanagerfactory.h"
       
    33 #include "mvimpststorageserviceview.h"
       
    34 
       
    35 // system include
       
    36 #include 	<aknenv.h>
       
    37 #include	<aknlists.h>
       
    38 #include    <AknIconArray.h>
       
    39 #include	<eikclbd.h> 
       
    40 #include	<aknsfld.h> 
       
    41 #include 	<AknUtils.h> 
       
    42 #include	<AknLayout.lag>   
       
    43 #include 	<StringLoader.h>
       
    44 // Pbk2
       
    45 #include <MPbk2KeyEventHandler.h>
       
    46 #include <vimpstuires.rsg>
       
    47 
       
    48 
       
    49 #include    <MVPbkContactStoreListObserver.h>
       
    50 #include    "mvimpstenginepresencesubservice.h"
       
    51 #include "uiservicetabtracer.h"
       
    52 
       
    53 #include <aknlayoutscalable_avkon.cdl.h>
       
    54 // imlauncher
       
    55 #include <imcvlauncher.h>
       
    56 const TInt KTextLimit( 40 ); // Text-limit for find-field
       
    57 
       
    58 const TInt KMinContact(1);   // minmimum number of contacts to show findpane
       
    59 
       
    60 // ================= MEMBER FUNCTIONS =======================
       
    61 // --------------------------------------------------------------------------
       
    62 // CVIMPSTUiDoubleListBoxTabViewControl::HandleAvatarChangeL
       
    63 // --------------------------------------------------------------------------
       
    64 //
       
    65 void CVIMPSTUiSingleListBoxTabViewControl::HandleAvatarChangeL( const TDesC& /*aUserId*/ ) 
       
    66     {
       
    67   
       
    68     }   
       
    69 
       
    70 // --------------------------------------------------------------------------
       
    71 // CVIMPSTUiDoubleListBoxTabViewControl::CVIMPSTUiDoubleListBoxTabViewControl
       
    72 // --------------------------------------------------------------------------
       
    73 //
       
    74 CVIMPSTUiSingleListBoxTabViewControl::CVIMPSTUiSingleListBoxTabViewControl(CVIMPSTUiTabbedView& aTabbedView, MPbk2KeyEventHandler* aKeyEventHandler,
       
    75 														MVIMPSTCmdHandler& aCommandHandler,
       
    76 														TUint32 aServiceId,
       
    77 														CVIMPSTUiBrandData& aBrandHandler,
       
    78 														MVIMPSTEngine& aEngine,
       
    79 														CEikButtonGroupContainer* aCba)
       
    80 	:iTabbedView(aTabbedView),
       
    81 	 iKeyEventHandler(aKeyEventHandler),
       
    82 	 iCommandHandler(aCommandHandler),
       
    83 	 iArrayProcess(iCommandHandler.GetProcessInterface()),
       
    84 	 iServiceId(aServiceId),
       
    85 	 iBrandHandler(aBrandHandler),
       
    86 	 iEngine(aEngine),
       
    87 	 iCba(aCba)
       
    88     {
       
    89 
       
    90     }
       
    91 
       
    92 
       
    93 // --------------------------------------------------------------------------
       
    94 // CVIMPSTUiSingleListBoxTabViewControl::ConstructL
       
    95 // --------------------------------------------------------------------------
       
    96 //
       
    97 void CVIMPSTUiSingleListBoxTabViewControl::ConstructL()
       
    98     {
       
    99 	TRACER_AUTO;
       
   100     CreateWindowL();
       
   101    
       
   102     // register to get the call back for any array data change
       
   103      iArrayProcess.AddObserver(this); 
       
   104     
       
   105     // Create and construct listbox
       
   106     iListBox = new ( ELeave ) CVIMPSTUiSingleStyleListBox;
       
   107  
       
   108     iListBox->ConstructL(this);
       
   109     
       
   110     iListBox->SetContactListModelL(iArrayProcess);
       
   111     
       
   112     iListBox->SetListBoxObserver( this );
       
   113     
       
   114     iListBox->SetContainerWindowL(*this);
       
   115     iListBox->CreateScrollBarFrameL(ETrue);
       
   116     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL
       
   117         (CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
       
   118 	// set marquee on
       
   119     iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
       
   120     // If engine is uninstalled, do not construct the list view.
       
   121     // Display empty message
       
   122     if (iEngine.IsUnInstalled())
       
   123         {
       
   124         SetListEmptyTextL( R_QTN_SERVTAB_SWUPDATE_RESTART );
       
   125         return;
       
   126         }
       
   127     else
       
   128         {
       
   129     // Construction of the listbox view. Engine is not uninstalled.    
       
   130         CVIMPSTUiSingleListboxArray* friendsArray =
       
   131                 CVIMPSTUiSingleListboxArray::NewL(iArrayProcess,
       
   132                         iListBox->ItemDrawer()->ColumnData(), *iListBox);
       
   133         // now set the array
       
   134         iListBox->Model()->SetItemTextArray(friendsArray);
       
   135 
       
   136         iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
       
   137         // if there is any contact other than owndata , show findpane
       
   138         if (iListBox->Model()->NumberOfItems() > KMinContact)
       
   139             {
       
   140             // Create find-pane
       
   141             ActivateFindPaneL();
       
   142             }
       
   143         LoadBitmapsL();
       
   144         SetCbaLockL(EFalse);
       
   145         }
       
   146 
       
   147     
       
   148     }
       
   149 
       
   150 
       
   151 // --------------------------------------------------------------------------
       
   152 // CVIMPSTUiSingleListBoxTabViewControl::NewL
       
   153 // --------------------------------------------------------------------------
       
   154 //
       
   155 CVIMPSTUiSingleListBoxTabViewControl* CVIMPSTUiSingleListBoxTabViewControl::NewL
       
   156         (CVIMPSTUiTabbedView& aTabbedView,MPbk2KeyEventHandler* aKeyEventHandler, 
       
   157         MVIMPSTCmdHandler& aCommandHandler, TUint32 aServiceId,
       
   158         CVIMPSTUiBrandData& aBrandHandler,
       
   159         MVIMPSTEngine& aEngine,
       
   160         CEikButtonGroupContainer* aCba)
       
   161     {
       
   162 	TRACER_AUTO;
       
   163     CVIMPSTUiSingleListBoxTabViewControl* self = NewLC(aTabbedView,aKeyEventHandler,
       
   164     			aCommandHandler, aServiceId, aBrandHandler,aEngine,aCba);
       
   165     CleanupStack::Pop(self);
       
   166     return self;
       
   167     }
       
   168 
       
   169 
       
   170 // --------------------------------------------------------------------------
       
   171 // CVIMPSTUiSingleListBoxTabViewControl::NewLC
       
   172 // --------------------------------------------------------------------------
       
   173 //
       
   174 CVIMPSTUiSingleListBoxTabViewControl* CVIMPSTUiSingleListBoxTabViewControl::NewLC
       
   175         (CVIMPSTUiTabbedView& aTabbedView,MPbk2KeyEventHandler* aKeyEventHandler,
       
   176         MVIMPSTCmdHandler& aCommandHandler, TUint32 aServiceId,
       
   177         CVIMPSTUiBrandData& aBrandHandler,
       
   178         MVIMPSTEngine& aEngine,
       
   179         CEikButtonGroupContainer* aCba)
       
   180     {
       
   181 	TRACER_AUTO;
       
   182     CVIMPSTUiSingleListBoxTabViewControl* self =
       
   183         new (ELeave) CVIMPSTUiSingleListBoxTabViewControl(aTabbedView,aKeyEventHandler,
       
   184         aCommandHandler, aServiceId, aBrandHandler,aEngine,aCba);
       
   185     CleanupStack::PushL(self);
       
   186     self->ConstructL();
       
   187     return self;
       
   188     }
       
   189 
       
   190 
       
   191 // --------------------------------------------------------------------------
       
   192 // CVIMPSTUiSingleListBoxTabViewControl::~CVIMPSTUiSingleListBoxTabViewControl
       
   193 // --------------------------------------------------------------------------
       
   194 //
       
   195 CVIMPSTUiSingleListBoxTabViewControl::~CVIMPSTUiSingleListBoxTabViewControl()
       
   196     {
       
   197     
       
   198     delete iListBox;
       
   199     iArrayProcess.RemoveObserver();
       
   200     if( iFindbox )
       
   201     	{
       
   202     	delete iFindbox;
       
   203     	iFindbox = NULL;
       
   204     	}
       
   205       
       
   206     }
       
   207 	
       
   208 // ---------------------------------------------------------
       
   209 // CVIMPSTUiSingleListBoxTabViewControl::HandleAddition
       
   210 // ---------------------------------------------------------
       
   211 //
       
   212 void CVIMPSTUiSingleListBoxTabViewControl::HandleAdditionL(TVIMPSTEnums::TItem aType, TInt aIndex)
       
   213 	{
       
   214   	if(iListBox )
       
   215 		{
       
   216 		iListBox->HandleItemAdditionL();
       
   217 		UpdateViewL(aIndex,aType) ;
       
   218 		}
       
   219 	}
       
   220 
       
   221 // ---------------------------------------------------------
       
   222 // CVIMPSTUiSingleListBoxTabViewControl::HandleAddition
       
   223 // ---------------------------------------------------------
       
   224 //
       
   225 void CVIMPSTUiSingleListBoxTabViewControl::HandleDeletionL(TVIMPSTEnums::TItem aType, TInt aIndex )
       
   226 	{
       
   227     if(iListBox)
       
   228 		{
       
   229 		iListBox->HandleItemRemovalL();  
       
   230 		TInt count = iListBox->Model()->NumberOfItems();
       
   231 		if( count == aIndex )
       
   232 			{
       
   233 			aIndex = 0;	
       
   234 			}
       
   235 		UpdateViewL(aIndex,aType) ;
       
   236 		}
       
   237 	}
       
   238 
       
   239 // --------------------------------------------------------------------------
       
   240 // CVIMPSTUiSingleListBoxTabViewControl::HandleItemAdditionL
       
   241 // --------------------------------------------------------------------------
       
   242 //
       
   243 void CVIMPSTUiSingleListBoxTabViewControl::HandleItemAdditionL()
       
   244     {
       
   245    if(iListBox)
       
   246   	 	{
       
   247         iListBox->HandleItemAdditionL();  
       
   248         TInt index  = CurrentItemIndex();
       
   249     	TVIMPSTEnums::TItem type = iArrayProcess.GetType(index);
       
   250        	UpdateViewL(index,type) ;  
       
   251    		}
       
   252     }
       
   253 
       
   254 
       
   255 // --------------------------------------------------------------------------
       
   256 // CVIMPSTUiSingleListBoxTabViewControl::HandleItemRemovalL
       
   257 // --------------------------------------------------------------------------
       
   258 //
       
   259 void CVIMPSTUiSingleListBoxTabViewControl::HandleItemRemovalL()
       
   260     {
       
   261     if(iListBox)
       
   262   	 	{
       
   263         iListBox->HandleItemRemovalL();  
       
   264         TInt index  = CurrentItemIndex();
       
   265     	TVIMPSTEnums::TItem type = iArrayProcess.GetType(index);
       
   266        	UpdateViewL(index,type) ;  
       
   267     	}
       
   268     }
       
   269 
       
   270 
       
   271 
       
   272 // --------------------------------------------------------------------------
       
   273 // CVIMPSTUiSingleListBoxTabViewControl::SizeChanged
       
   274 // --------------------------------------------------------------------------
       
   275 //
       
   276 void CVIMPSTUiSingleListBoxTabViewControl::SizeChanged()
       
   277     {
       
   278     SetLayout(); //layouting controls
       
   279     if ( iFindbox && iFindPaneIsVisible  )
       
   280         {
       
   281         iFindbox->MakeVisible( ETrue );
       
   282         }
       
   283     }
       
   284 
       
   285 
       
   286 // --------------------------------------------------------------------------
       
   287 // CVIMPSTUiSingleListBoxTabViewControl::CountComponentControls
       
   288 // --------------------------------------------------------------------------
       
   289 //
       
   290 TInt CVIMPSTUiSingleListBoxTabViewControl::CountComponentControls() const
       
   291     { 
       
   292      // return number of controls inside this container
       
   293     if( !iFindbox )
       
   294         {
       
   295         // Find-pane does not exist when there is no data in listbox,
       
   296         // so only one control exists (listbox)
       
   297         return 1; //Ignore CodeScanner warning
       
   298         }
       
   299     else
       
   300         {
       
   301         // listbox and findbox exists. that makes it two
       
   302         return 2; //Ignore CodeScanner warning
       
   303         }
       
   304     }
       
   305 
       
   306 // --------------------------------------------------------------------------
       
   307 // CVIMPSTUiSingleListBoxTabViewControl::FocusChanged
       
   308 // --------------------------------------------------------------------------
       
   309 //
       
   310 void CVIMPSTUiSingleListBoxTabViewControl::FocusChanged( TDrawNow aDrawNow )
       
   311     {
       
   312     if ( iFindbox && iFindbox->IsVisible() )
       
   313             {
       
   314             iFindbox->SetFocus( IsFocused(), aDrawNow );
       
   315             if ( aDrawNow == EDrawNow && IsFocused() )
       
   316                 {
       
   317                 iFindbox->DrawDeferred();
       
   318                 }
       
   319             }
       
   320     }
       
   321 
       
   322 
       
   323 // --------------------------------------------------------------------------
       
   324 // CVIMPSTUiSingleListBoxTabViewControl::ComponentControl
       
   325 // --------------------------------------------------------------------------
       
   326 //
       
   327 CCoeControl* CVIMPSTUiSingleListBoxTabViewControl::ComponentControl(TInt aIndex) const
       
   328     {
       
   329    // return iListBox;
       
   330     switch ( aIndex )
       
   331         {
       
   332         // the caller wants to have the first control
       
   333         // so it's always listbox
       
   334         case 0:
       
   335             {
       
   336 			return iListBox;
       
   337             }
       
   338         // the caller wants to have the second control
       
   339         // so it's always the findbox if it exists
       
   340         case 1:
       
   341             {
       
   342             if( iFindbox )
       
   343                 {
       
   344                 return iFindbox;
       
   345                 }
       
   346             return NULL;
       
   347             }
       
   348         default:
       
   349             {
       
   350             return NULL;
       
   351             }
       
   352         }
       
   353     }
       
   354 
       
   355 
       
   356 // --------------------------------------------------------------------------
       
   357 // CVIMPSTUiSingleListBoxTabViewControl::OfferKeyEventL
       
   358 // --------------------------------------------------------------------------
       
   359 //
       
   360 TKeyResponse CVIMPSTUiSingleListBoxTabViewControl::OfferKeyEventL
       
   361         (const TKeyEvent& aKeyEvent,TEventCode aType)
       
   362     {
       
   363     if ( !aKeyEvent.iCode ) 
       
   364         {
       
   365         //The character code generated 
       
   366         //for an EEventKey, or 0 for a down or up event.
       
   367         //For down or up key return key consumed.. handle only the events
       
   368         
       
   369         if((EEventKeyDown == aType) && (EStdKeyDevice3 == aKeyEvent.iScanCode))
       
   370             {
       
   371             //for setting the command to be executed for the "Selection key"
       
   372             //in case of selection key, container's OfferKeyEventL() is called only for EEventKeyDown and EEventKeyUp
       
   373             //and not for EEventKey
       
   374             UpdateCbaL();
       
   375             }
       
   376         return EKeyWasConsumed;         
       
   377         }
       
   378     UpdateCbaL();
       
   379     TKeyResponse ret = EKeyWasNotConsumed;
       
   380     // Offer key event first to the key event handler
       
   381     if ( iKeyEventHandler && iKeyEventHandler->Pbk2ProcessKeyEventL
       
   382             ( aKeyEvent, aType ) )
       
   383         {
       
   384         ret = EKeyWasConsumed;
       
   385         }
       
   386     
       
   387     switch ( aKeyEvent.iCode )
       
   388        {
       
   389        case EKeyBackspace:
       
   390            {
       
   391            if ( iFindbox )  
       
   392                {
       
   393                if( iFindbox->TextLength() == 0 )
       
   394                    {
       
   395                    TVIMPSTEnums::TItem item = iArrayProcess.GetType( CurrentItemIndex() );
       
   396                    if(TVIMPSTEnums::EContactItem == item)
       
   397                        {
       
   398                        TInt index = CurrentItemIndex();
       
   399                        if( iArrayProcess.IsConversationExist(index) )
       
   400                            {
       
   401                            iTabbedView.CloseConversationL();
       
   402                            ret = EKeyWasConsumed;
       
   403                            }
       
   404                        else if(TVIMPSTEnums::EContactItem == iArrayProcess.GetType(  index ) )
       
   405                            {
       
   406                            if( TVIMPSTEnums::ESVCERegistered == iArrayProcess.GetLoginState()  )                          
       
   407                                {
       
   408                                iTabbedView.DeleteContactL();
       
   409                                }
       
   410                            ret = EKeyWasConsumed;
       
   411                            }
       
   412                        }
       
   413                    }
       
   414                }
       
   415            break;
       
   416            }
       
   417   
       
   418             // Case to handle send key press consumption.
       
   419         case EKeyYes:
       
   420             {
       
   421             TInt index = iListBox->CurrentItemIndex();
       
   422             if( TVIMPSTEnums::EOwnStatusItem == iArrayProcess.GetType( index ) )
       
   423                 {
       
   424                 ret = EKeyWasConsumed;
       
   425                 }
       
   426             break;
       
   427             }
       
   428        default:
       
   429            break;
       
   430        }
       
   431     
       
   432      if( EKeyPhoneSend == aKeyEvent.iCode  && ret != EKeyWasConsumed )
       
   433     	{
       
   434     	if( iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EVoip))
       
   435 		    {
       
   436 		    iTabbedView.MakeVoipCallL();
       
   437 		   	ret = EKeyWasConsumed;
       
   438 		    }
       
   439 	
       
   440     	}
       
   441     if( ret == EKeyWasConsumed )
       
   442 	    {
       
   443 	    // user might has choosen back/end key/application key etc
       
   444 	    // application might switch to background 
       
   445 	    // return from here
       
   446 	    return ret;	
       
   447 	    }
       
   448     if ( iFindPaneIsVisible && iFindbox ) 
       
   449 	    {
       
   450 	    ret = iFindbox->OfferKeyEventL( aKeyEvent, aType )	;
       
   451 	    }
       
   452     // Not consumed by the key handler and findpane , offer to the control next
       
   453     if ( ret == EKeyWasNotConsumed )
       
   454         {
       
   455         ret = iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   456         }
       
   457     iTabbedView.UpdateToolbarL();
       
   458     return ret;
       
   459     }
       
   460   
       
   461 // --------------------------------------------------------------------------
       
   462 // CVIMPSTUiSingleListBoxTabViewControl::CurrentItemIndex
       
   463 // --------------------------------------------------------------------------
       
   464 //
       
   465 TInt CVIMPSTUiSingleListBoxTabViewControl::CurrentItemIndex() const
       
   466     {
       
   467     if( !iListBox )
       
   468         {
       
   469         return KErrNotFound;
       
   470         }
       
   471     if( !iListBox->View() )
       
   472         {
       
   473         // CurrentItemIndex panics if the listbox has no view
       
   474         return KErrNotFound;
       
   475         }
       
   476 
       
   477     TInt curIndex( iListBox->CurrentItemIndex() );
       
   478     if ( curIndex < 0 )
       
   479         {
       
   480         return KErrNotFound;
       
   481         }
       
   482     CVIMPSTUiListBoxModel* model =
       
   483         static_cast<CVIMPSTUiListBoxModel*>( iListBox->Model() );
       
   484 
       
   485     if( model )
       
   486         {
       
   487         return model->FilteredItemIndex( curIndex );
       
   488         }
       
   489     return KErrNotFound;
       
   490     }
       
   491 
       
   492 
       
   493 
       
   494 // --------------------------------------------------------------------------
       
   495 // CVIMPSTUiSingleListBoxTabViewControl::SetCurrentItemIndex
       
   496 // --------------------------------------------------------------------------
       
   497 //
       
   498 void CVIMPSTUiSingleListBoxTabViewControl::SetCurrentItemIndex(TInt aIndex)
       
   499     {
       
   500     if (iListBox->CurrentItemIndex() != aIndex &&
       
   501         aIndex >= 0 &&
       
   502         aIndex < iListBox->Model()->NumberOfItems() )
       
   503         {
       
   504         iListBox->SetCurrentItemIndex(aIndex);
       
   505         TRAP_IGNORE(UpdateCbaL());
       
   506         }
       
   507     }
       
   508 
       
   509 
       
   510 // --------------------------------------------------------------------------
       
   511 // CVIMPSTUiSingleListBoxTabViewControl::SetCurrentItemIndexAndDraw
       
   512 // --------------------------------------------------------------------------
       
   513 //
       
   514 void CVIMPSTUiSingleListBoxTabViewControl::SetCurrentItemIndexAndDraw(TInt aIndex)
       
   515     {
       
   516     SetCurrentItemIndex(aIndex);
       
   517     this->DrawDeferred();
       
   518     }
       
   519 
       
   520 
       
   521 // --------------------------------------------------------------------------
       
   522 // CVIMPSTUiSingleListBoxTabViewControl::SetListEmptyTextL
       
   523 // --------------------------------------------------------------------------
       
   524 //
       
   525 void CVIMPSTUiSingleListBoxTabViewControl::SetListEmptyTextL(TInt aResourceId)
       
   526     {
       
   527     HBufC* msgText;
       
   528     TRACER_AUTO;    
       
   529     // Get Service Name from Engine , load string from resource and display.
       
   530     // This text is shown to tell the user to restart phone to get the service again.
       
   531     TPtrC serviceNamePtr(iEngine.ServiceName());
       
   532     msgText = StringLoader::LoadLC(aResourceId, serviceNamePtr, iCoeEnv);
       
   533     iListBox->View()->SetListEmptyTextL(*msgText);
       
   534     TRACE( "Display Text %S", msgText );
       
   535     
       
   536     CleanupStack::PopAndDestroy(msgText);
       
   537     }
       
   538 
       
   539 // ---------------------------------------------------------
       
   540 // CVIMPSTUiSingleListBoxTabViewControl::LoadBitmapsL
       
   541 // Called by framework when the view size is changed
       
   542 // ---------------------------------------------------------
       
   543 //
       
   544 void CVIMPSTUiSingleListBoxTabViewControl::LoadBitmapsL()
       
   545     {
       
   546   
       
   547     
       
   548 	CColumnListBoxData* listBoxData = iListBox->ItemDrawer()->ColumnData();
       
   549 	if ( !listBoxData )
       
   550 		{
       
   551 		//No listbox data
       
   552 		User::Leave( KErrNotFound );
       
   553 		}
       
   554 	
       
   555 	CAknIconArray* icons = iBrandHandler.LoadIconsLC( );
       
   556 	
       
   557     CArrayPtr<CGulIcon>* oldIconArray = listBoxData->IconArray();
       
   558     if( oldIconArray )
       
   559         {
       
   560         oldIconArray->ResetAndDestroy();
       
   561 		delete oldIconArray;
       
   562         listBoxData->SetIconArray( NULL );
       
   563         }
       
   564 
       
   565     // Set icon-array to listbox's drawer
       
   566     listBoxData->SetIconArray( icons );
       
   567     CleanupStack::Pop( icons );
       
   568     }
       
   569 
       
   570 // ---------------------------------------------------------
       
   571 // CVIMPSTUiSingleListBoxTabViewControl::HandleListBoxEventL(
       
   572 //			CEikListBox* /*aListBox*/, TListBoxEvent /*aEventType*/ )
       
   573 // From MEikListBoxObserver, Handles event's generated by listbox
       
   574 // (other items were commented in a header).
       
   575 // ---------------------------------------------------------
       
   576 //
       
   577 void CVIMPSTUiSingleListBoxTabViewControl::HandleListBoxEventL(
       
   578         CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
       
   579     {
       
   580     iTabbedView.UpdateToolbarL();
       
   581     UpdateCbaL();   
       
   582     switch(aEventType)
       
   583         {
       
   584         case EEventItemSingleClicked:
       
   585             {
       
   586     		TBool presenceEnabled = iEngine.IsSubServiceEnabled(TVIMPSTEnums::EPresence);
       
   587     		TBool imEnabled = iEngine.IsSubServiceEnabled(TVIMPSTEnums::EIM);
       
   588     		TBool voipEnabled = iEngine.IsSubServiceEnabled(TVIMPSTEnums::EVoip);
       
   589     		
       
   590     		TInt index = CurrentItemIndex();
       
   591     		TVIMPSTEnums::TItem itemType = iArrayProcess.GetType(index);    		
       
   592     		TVIMPSTEnums::TVIMPSTRegistrationState serviceState = iTabbedView.GetServiceState();
       
   593     		
       
   594     		if(TVIMPSTEnums::EOwnStatusItem == itemType && 
       
   595     		        TVIMPSTEnums::ESVCENotRegistered ==  serviceState)
       
   596     			{
       
   597     			iTabbedView.HandleCommandL( ECmdLogin );
       
   598     			}
       
   599     		else if(TVIMPSTEnums::EOwnStatusItem == itemType 
       
   600     				&& presenceEnabled &&
       
   601     				TVIMPSTEnums::ESVCERegistered ==  serviceState )
       
   602     			{
       
   603     			iTabbedView.HandleCommandL( ECmdChangeStatus );
       
   604     			}
       
   605     		else if( ( TVIMPSTEnums::EContactItem == itemType || 
       
   606     		           TVIMPSTEnums::EUnknonContactItem == itemType )&& imEnabled &&
       
   607     		           TVIMPSTEnums::ESVCERegistered == serviceState )
       
   608     		    {
       
   609     		    iTabbedView.HandleCommandL( ECmdOpenConversation );
       
   610     		    }
       
   611     		else if ( itemType == TVIMPSTEnums::EFriendRequestItem
       
   612     		        && TVIMPSTEnums::ESVCERegistered == serviceState)
       
   613     		    {
       
   614     		    iTabbedView.HandleCommandL( ECmdOpenFriendRequest );    		                    
       
   615     		    }
       
   616             else if( TVIMPSTEnums::EContactItem == itemType )
       
   617                   {
       
   618                   if( !(TVIMPSTEnums::ESVCEUpdatingContacts ==  serviceState ||
       
   619                           TVIMPSTEnums::ESVCENetworkConnecting ==  serviceState || 
       
   620                           TVIMPSTEnums::ESVCENetworkDisConnecting ==  serviceState))
       
   621                       {
       
   622                       iTabbedView.HandleCommandL( ECmdContactDetails );
       
   623                       }
       
   624                   }
       
   625     		break;
       
   626     		}
       
   627     	       // Add enter key handling
       
   628     	                        case EEventEnterKeyPressed:
       
   629     	                        {
       
   630     	                        CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
       
   631     	                        TInt commandId( iCba->ButtonGroup()->CommandId( CEikButtonGroupContainer::EMiddleSoftkeyPosition));
       
   632     	                       
       
   633     	                        iTabbedView.HandleCommandL(commandId);
       
   634     	                        break;
       
   635     	                        }
       
   636     	default:
       
   637     		{
       
   638     		break;
       
   639     		}
       
   640     	}
       
   641   
       
   642        }
       
   643 // ---------------------------------------------------------
       
   644 // CVIMPSTUiSingleListBoxTabViewControl::SendMessageL(
       
   645 //			CEikListBox* /*aListBox*/, TListBoxEvent /*aEventType*/ )
       
   646 // From MEikListBoxObserver, Handles event's generated by listbox
       
   647 // (other items were commented in a header).
       
   648 // ---------------------------------------------------------
       
   649 //
       
   650 void CVIMPSTUiSingleListBoxTabViewControl::SendMessageL()
       
   651 	{
       
   652 	TInt index = CurrentItemIndex();   
       
   653 	TPtrC seletctedItem = iArrayProcess.GetItemUserId(index) ;
       
   654 	if( index< 0 )
       
   655 		{
       
   656 		// return if item not found.
       
   657 		return;	
       
   658 		}
       
   659       if(seletctedItem.Length())
       
   660 		{
       
   661    // No need to check for the presence of the contact as in singleline 
       
   662    // list box there is no presence, hence directly open the ocnversation view.
       
   663     TVwsViewId activeViewId;
       
   664     CCoeEnv::Static()->AppUi()->GetActiveViewId( activeViewId );
       
   665     
       
   666     iArrayProcess.ResetPendingMsg( index );
       
   667     // imlauncher call for luanching the conversationview with seletced user id
       
   668     IMCVLauncher::LaunchImConversationViewL(activeViewId, iServiceId, seletctedItem );  
       
   669 		}
       
   670 	else
       
   671 		{
       
   672 	      //When there is no XSP Id present it comes to here
       
   673 		//Displaying a note that there is no XSP ID
       
   674 	      HBufC* note = NULL;
       
   675 	      note = StringLoader::LoadLC( R_QTN_SERVTAB_NOXSP_ERROR );
       
   676 	      VIMPSTUtilsDialog::DisplayNoteDialogL( *note );
       
   677 		CleanupStack::PopAndDestroy( note );
       
   678 		}
       
   679 	}
       
   680 // ---------------------------------------------------------
       
   681 // CVIMPSTUiSingleListBoxTabViewControl::UpdateViewL
       
   682 // (other items were commented in a header).
       
   683 // ---------------------------------------------------------
       
   684 //
       
   685 void CVIMPSTUiSingleListBoxTabViewControl::UpdateViewL( 
       
   686 				TInt aIndex, TVIMPSTEnums::TItem aType)
       
   687     {
       
   688 	TRACER_AUTO;
       
   689     TInt index = KErrNotFound;
       
   690     if( aIndex < 0 )
       
   691     	{
       
   692     	aIndex = CurrentItemIndex()<0?0:CurrentItemIndex();		
       
   693     	}
       
   694     switch(aType)
       
   695 	    {
       
   696 	    case TVIMPSTEnums::EContactItem:
       
   697 	    case TVIMPSTEnums::EOwnStatusItem:
       
   698 	    	{
       
   699 	    	/*Not attempting to get the index of contact because aIndex is the 
       
   700 	    	same as this index and we pass it on to the contactlistboxmodel's 
       
   701 	    	visibleitem method*/
       
   702 	    	CVIMPSTUiListBoxModel* list =
       
   703 	    	        static_cast<CVIMPSTUiListBoxModel*>( iListBox->Model() );
       
   704 	    	index = list->VisibleItemIndex(aIndex); 
       
   705 	    	if( index != KErrNotFound  && iFindbox )
       
   706 		        {
       
   707 		         if(iClrFindPaneFlag)
       
   708 	                {
       
   709 	                iFindbox->SetSearchTextL( KNullDesC );
       
   710 	                iFindbox->DrawNow();
       
   711 	                iClrFindPaneFlag = EFalse;
       
   712 	                }
       
   713 	            else
       
   714 	                {
       
   715 	                TBuf<KTextLimit> temp;
       
   716 	                iFindbox->GetSearchText(temp);
       
   717 	                if(0 != temp.Compare(KNullDesC))
       
   718 	                    {
       
   719 	                    ((CAknFilteredTextListBoxModel*) iListBox->Model() )
       
   720 	                            ->Filter()->HandleOfferkeyEventL();
       
   721 	                    }
       
   722 	                }		        
       
   723 		        }	
       
   724 		    break;     	
       
   725 	    	}	    	
       
   726 		default:
       
   727 			{
       
   728 			//nothing to do
       
   729 			break;
       
   730 			}    	
       
   731 	    }
       
   732 	iListBox->DrawNow();
       
   733 	SetCurrentItemIndex(aIndex);
       
   734 	SetFocusAndMakeItemVisible();
       
   735 	TInt count = iArrayProcess.Count();
       
   736     if(count > KMinContact && ! iFindPaneIsVisible)  
       
   737 		{
       
   738 		ActivateFindPaneL();		
       
   739 		}
       
   740     else if(count <= KMinContact && iFindPaneIsVisible) // extra check needed here to improve performance
       
   741 	    {
       
   742 	    DeactivateFindPaneL();	    
       
   743 	    }
       
   744     
       
   745 	//Update the Toolbar after moving the focus to the current item.
       
   746 	iTabbedView.UpdateToolbarL();   
       
   747 	UpdateCbaL();		
       
   748     }
       
   749 // ---------------------------------------------------------
       
   750 // CVIMPSTUiSingleListBoxTabViewControl::ActivateFindPaneL()
       
   751 // Activates find-pane
       
   752 // (other items were commented in a header).
       
   753 // ---------------------------------------------------------
       
   754 //
       
   755 void CVIMPSTUiSingleListBoxTabViewControl::ActivateFindPaneL()
       
   756     {
       
   757 	TRACER_AUTO;
       
   758     if( !iFindbox )
       
   759         {
       
   760         iFindbox = CAknSearchField::NewL( *this,
       
   761                 CAknSearchField::ESearch,
       
   762                 NULL, KTextLimit );
       
   763         static_cast<CAknFilteredTextListBoxModel*>( iListBox->Model() )
       
   764             ->CreateFilterL( iListBox, iFindbox );
       
   765 
       
   766         }
       
   767     iFindbox->SetObserver( this );
       
   768     iFindbox->ActivateL();
       
   769     iFindbox->ResetL();
       
   770     iFindbox->SetSearchTextL( KNullDesC );    
       
   771    
       
   772     iFindPaneIsVisible = ETrue;
       
   773     SetLayout();
       
   774 
       
   775     if( IsActivated() )
       
   776         {
       
   777         iFindbox->MakeVisible( ETrue );
       
   778         iFindbox->SetFocus( ETrue );
       
   779         iListBox->SizeChanged();
       
   780         DrawNow();
       
   781         }
       
   782     }
       
   783 
       
   784 // ---------------------------------------------------------
       
   785 // CVIMPSTUiSingleListBoxTabViewControl::DeactivateFindPaneL()
       
   786 // De-activates find-pane
       
   787 // (other items were commented in a header).
       
   788 // ---------------------------------------------------------
       
   789 //
       
   790 void CVIMPSTUiSingleListBoxTabViewControl::DeactivateFindPaneL()
       
   791     {
       
   792 	TRACER_AUTO;
       
   793     if( !iFindbox )
       
   794 	    {
       
   795 	    return;	
       
   796 	    }
       
   797     static_cast<CAknFilteredTextListBoxModel*>( iListBox->Model() )
       
   798         ->Filter()->ResetFilteringL();
       
   799 
       
   800 
       
   801     iFindbox->MakeVisible( EFalse );
       
   802     iFindbox->SetFocus( EFalse );
       
   803 
       
   804     iFindPaneIsVisible = EFalse;
       
   805     SetLayout();
       
   806 
       
   807     if( IsActivated() )
       
   808         {
       
   809         DrawNow();
       
   810         }
       
   811     }
       
   812     
       
   813     
       
   814   
       
   815 // ---------------------------------------------------------
       
   816 // CVIMPSTUiSingleListBoxTabViewControl::SetLayout()
       
   817 // Layouts current components according to AVKON LAF
       
   818 // (other items were commented in a header).
       
   819 // ---------------------------------------------------------
       
   820 //
       
   821 void CVIMPSTUiSingleListBoxTabViewControl::SetLayout()
       
   822     {
       
   823     const TRect rect( Rect() );
       
   824     if( iListBox && iFindPaneIsVisible )
       
   825         {
       
   826 
       
   827         TAknWindowLineLayout empty;
       
   828         empty.iC = 0;
       
   829         empty.il = 0;
       
   830         empty.it = 0;
       
   831         empty.ir = 0;
       
   832         empty.ib = 0;
       
   833         empty.iW = ELayoutEmpty;
       
   834         empty.iH = ELayoutEmpty;
       
   835 
       
   836         TAknWindowLineLayout findPane = AknLayoutScalable_Avkon::find_pane().LayoutLine();
       
   837         TAknWindowLineLayout listPane;
       
   838 
       
   839         // listPane should equal to parent's rect
       
   840         listPane.il = Rect().iTl.iX;
       
   841         listPane.ir = ELayoutEmpty;
       
   842         listPane.it = Rect().iTl.iY;
       
   843         listPane.ib = ELayoutEmpty;
       
   844         // this check is required since it's not guaranteed that listbox's SetRect
       
   845         // has been called when this code is executed
       
   846         if ( Size().iWidth > 0 )
       
   847             {
       
   848             listPane.iW = Size().iWidth;
       
   849             listPane.ir = ELayoutEmpty;
       
   850             }
       
   851         else
       
   852             {
       
   853             listPane.iW = ELayoutEmpty;
       
   854             listPane.ir = 0;
       
   855             }
       
   856         // but findpane's height should be subtracted
       
   857         listPane.iH = Size().iHeight - findPane.iH;
       
   858 
       
   859         // findPane's width should equal to listPane's width
       
   860         findPane.iW = listPane.iW;
       
   861         CAknFilteredTextListBoxModel* m = static_cast <CAknFilteredTextListBoxModel*> ( iListBox->Model() );
       
   862         if ( m->Filter() )
       
   863             {
       
   864             m->Filter()->SetParentControl( this );
       
   865             }
       
   866         TAknLayoutRect lrect;
       
   867         lrect.LayoutRect( Rect(), empty );
       
   868         AknLayoutUtils::LayoutControl( iFindbox, lrect.Rect(), findPane );
       
   869         AknLayoutUtils::LayoutControl( iListBox, Rect(), listPane );
       
   870                                       
       
   871         }
       
   872     else if( iListBox )
       
   873         {
       
   874         AknLayoutUtils::LayoutControl( iListBox,
       
   875                                        rect,
       
   876                                        AKN_LAYOUT_WINDOW_list_gen_pane( 0 ) );
       
   877         }
       
   878     }
       
   879     
       
   880 // ---------------------------------------------------------
       
   881 // CVIMPSTUiSingleListBoxTabViewControl::HandleControlEventL
       
   882 // ---------------------------------------------------------
       
   883 //
       
   884 void CVIMPSTUiSingleListBoxTabViewControl::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent aEventType)
       
   885     {
       
   886     // We only observe iFindbox
       
   887     if( EEventStateChanged == aEventType )
       
   888         {
       
   889 
       
   890       	((CAknFilteredTextListBoxModel*) iListBox->Model() )
       
   891             ->Filter()->HandleOfferkeyEventL();        
       
   892 
       
   893         }
       
   894     iListBox->DrawNow(); 
       
   895     iTabbedView.UpdateToolbarL();
       
   896     }
       
   897 
       
   898 // ---------------------------------------------------------
       
   899 // ---------------------------------------------------------
       
   900 // CVIMPSTUiSingleListBoxTabViewControl::CheckAndSetLastItemFlag()
       
   901 // Checks if the last contact is focused and Sets the iLastItemFlag
       
   902 // ---------------------------------------------------------
       
   903 void CVIMPSTUiSingleListBoxTabViewControl::CheckAndSetLastItemFlag()
       
   904     {
       
   905     if(iListBox->CurrentItemIndex() == (iArrayProcess.Count() - 1))
       
   906         {
       
   907         iLastItemFlag = ETrue;
       
   908         }
       
   909     else
       
   910         {
       
   911         iLastItemFlag = EFalse;
       
   912         }
       
   913     }
       
   914 // ---------------------------------------------------------
       
   915 // CVIMPSTUiSingleListBoxTabViewControl::SetFocusAndMakeItemVisible()
       
   916 // Compares the Saved Contact in iFocussedID with the contacts in the List and focuses if it is found 
       
   917 // ---------------------------------------------------------
       
   918 void CVIMPSTUiSingleListBoxTabViewControl::SetFocusAndMakeItemVisible()
       
   919     {  
       
   920     TInt count = iArrayProcess.Count();
       
   921     TInt index = CurrentItemIndex();
       
   922     if( index == count )
       
   923         {   
       
   924         if( iLastItemFlag )
       
   925             {
       
   926             index = count - 1;
       
   927             iLastItemFlag = EFalse;
       
   928             }
       
   929         else
       
   930             {
       
   931             return;//do nothing let list box handle this.
       
   932             }
       
   933         }
       
   934 
       
   935     CVIMPSTUiListBoxModel* model =
       
   936         static_cast<CVIMPSTUiListBoxModel*>( iListBox->Model() );
       
   937 
       
   938     if( model )
       
   939         {
       
   940         index = model->VisibleItemIndex( index );
       
   941         }
       
   942     
       
   943     iListBox->ScrollToMakeItemVisible( index );
       
   944     SetCurrentItemIndex(index);
       
   945     iListBox->DrawNow();
       
   946 
       
   947     }
       
   948 
       
   949 // ---------------------------------------------------------
       
   950 // CVIMPSTUiSingleListBoxTabViewControl::GetFocussedId()
       
   951 // To get the pointer to the iFocussedID
       
   952 // ---------------------------------------------------------
       
   953 TPtrC CVIMPSTUiSingleListBoxTabViewControl::GetFocussedId()
       
   954     {
       
   955     TInt index = CurrentItemIndex();
       
   956     if( index < 0 )
       
   957 	    {
       
   958 	    index = 0;	
       
   959 	    }
       
   960     return iCommandHandler.GetProcessInterface().GetItemUserId(  index );
       
   961     }
       
   962 // ---------------------------------------------------------
       
   963 // CVIMPSTUiSingleListBoxTabViewControl::SetFocussedId()
       
   964 // Saves the Contact ID in iFocussedID
       
   965 // ---------------------------------------------------------
       
   966 void CVIMPSTUiSingleListBoxTabViewControl::SetFocussedId(const TDesC& aContact)
       
   967     {
       
   968     TInt index = iCommandHandler.GetProcessInterface().GetSelectedItemIndex( aContact );
       
   969     if( index < 0 )
       
   970 	    {
       
   971 	    index = 0;	
       
   972 	    }
       
   973     SetCurrentItemIndex( index );
       
   974     SetFocusAndMakeItemVisible();
       
   975     }
       
   976 
       
   977 // --------------------------------------------------------------------
       
   978 // CVIMPSTUiSingleListBoxTabViewControl::SetClrFindPaneFlag(TBool aFlag)
       
   979 // --------------------------------------------------------------------
       
   980 
       
   981 void CVIMPSTUiSingleListBoxTabViewControl::SetClrFindPaneFlag(TBool aFlag)
       
   982     {
       
   983     iClrFindPaneFlag = aFlag;
       
   984     }
       
   985 // ---------------------------------------------------------
       
   986 // CVIMPSTUiDoubleListBoxTabViewControl::CoeControl()
       
   987 // ---------------------------------------------------------
       
   988 
       
   989 CCoeControl* CVIMPSTUiSingleListBoxTabViewControl::CoeControl()
       
   990     { 
       
   991     return this; // return this pointer since its a parent class pointer of  CCoeControl
       
   992     }
       
   993 // ---------------------------------------------------------
       
   994 // CVIMPSTUiSingleListBoxTabViewControl::SetCbaLockL()
       
   995 // Sets the lock status of cba keys.
       
   996 // ---------------------------------------------------------
       
   997 //
       
   998 void CVIMPSTUiSingleListBoxTabViewControl::SetCbaLockL( TBool aLock )
       
   999     {
       
  1000     iCbaLock = aLock;
       
  1001     if( !aLock )
       
  1002         {
       
  1003         UpdateCbaL();
       
  1004         }
       
  1005     }
       
  1006 // ---------------------------------------------------------
       
  1007 // CVIMPSTUiSingleListBoxTabViewControl::UpdateCbaL()
       
  1008 // Updates Softkeys according to current focus.
       
  1009 // ---------------------------------------------------------
       
  1010 //
       
  1011 void CVIMPSTUiSingleListBoxTabViewControl::UpdateCbaL( TBool aUseDefaultCba /*= EFalse*/ )
       
  1012     {
       
  1013 	TRACER_AUTO;
       
  1014     TInt cbaRes = R_SERVTAB_SOFTKEYS_OPTIONS_EXIT__EMPTY;
       
  1015     iCurrentCmdToExe = -1;
       
  1016     if( !iCbaLock )
       
  1017         {
       
  1018         TInt index = CurrentItemIndex();
       
  1019         //if invalid index then dont set any command
       
  1020         if(KErrNotFound == index)
       
  1021             {
       
  1022             if ( iCba )
       
  1023                 {               
       
  1024                 iCba->SetCommandSetL( cbaRes );
       
  1025                 iCba->DrawNow();                
       
  1026                 }
       
  1027             return; 
       
  1028             }
       
  1029         
       
  1030         TVIMPSTEnums::TItem itemtype = iArrayProcess.GetType(index);
       
  1031         TVIMPSTEnums::TVIMPSTRegistrationState servicestate = iEngine.ServiceState();
       
  1032         TBool updateinvalid( iLastFocusedItemType == TVIMPSTEnums::EInvalid );
       
  1033 //         if ( !iCba )
       
  1034 //            {
       
  1035 //            iCba = CEikButtonGroupContainer::Current();
       
  1036 //            }
       
  1037 
       
  1038         // default softkeys
       
  1039         if( aUseDefaultCba || updateinvalid )
       
  1040             {
       
  1041             if( aUseDefaultCba )
       
  1042                 {
       
  1043                 iLastFocusedItemType = TVIMPSTEnums::EOwnStatusItem;
       
  1044                 }
       
  1045             else
       
  1046                 {
       
  1047                 iLastFocusedItemType = itemtype;
       
  1048                 }
       
  1049 
       
  1050             if( iCba )
       
  1051                 {
       
  1052                if ( itemtype == TVIMPSTEnums::EOwnStatusItem &&  TVIMPSTEnums::ESVCENetworkConnecting == servicestate )
       
  1053                     {
       
  1054                     if(iTabbedView.CancelLoginSupportedL())
       
  1055                         {
       
  1056                         cbaRes = R_SERVTAB_SOFTKEYS_OPTION_CANCEL__EXIT;
       
  1057                         iCurrentCmdToExe = ECmdCancelLogin;
       
  1058                         }
       
  1059                     else
       
  1060                         {
       
  1061                         cbaRes = R_SERVTAB_SOFTKEYS_OPTIONS_EXIT__EMPTY;
       
  1062                         iCurrentCmdToExe = -1;
       
  1063                         }
       
  1064                     }
       
  1065                     else if ( itemtype == TVIMPSTEnums::EOwnStatusItem &&  TVIMPSTEnums::ESVCEWaitingForNetwork == servicestate )
       
  1066                         {
       
  1067                         cbaRes = R_SERVTAB_SOFTKEYS_OPTION_CHANGECONN__EXIT;
       
  1068                         iCurrentCmdToExe = ECmdChangeConnectioninOnlineState;
       
  1069                         }
       
  1070                     else 
       
  1071                       {
       
  1072                       cbaRes = R_SERVTAB_SOFTKEYS_OPTION_LOGIN__EXIT;
       
  1073                       iCurrentCmdToExe = ECmdLogin;
       
  1074                       }
       
  1075                 iCba->SetCommandSetL( cbaRes );
       
  1076                 iCba->DrawNow();
       
  1077                 }
       
  1078             }
       
  1079 
       
  1080         // collapse softkey ( when focus is on contact )
       
  1081         else if( updateinvalid || itemtype == TVIMPSTEnums::EContactItem )
       
  1082             {
       
  1083             iLastFocusedItemType = itemtype;
       
  1084             if( iCba )
       
  1085                 {
       
  1086                 // Options/Collapse/Chat
       
  1087                 if(TVIMPSTEnums::ESVCERegistered == servicestate)
       
  1088                     {
       
  1089                     // im is supported
       
  1090                     if(iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EIM))
       
  1091                         {
       
  1092                         iCba->SetCommandSetL( R_SERVTAB_SOFTKEYS_OPTION_OPENCONV__EXIT );
       
  1093                         iCurrentCmdToExe = ECmdOpenConversation;
       
  1094                         }
       
  1095                     else //im is not supporteed
       
  1096                         {
       
  1097                         iCba->SetCommandSetL( R_SERVTAB_SOFTKEYS_OPTIONS_DETAILS__EXIT );
       
  1098                         iCurrentCmdToExe = ECmdContactDetails;
       
  1099                         }
       
  1100                     }
       
  1101                 else if(TVIMPSTEnums::ESVCENotRegistered == servicestate)
       
  1102                     {
       
  1103                     iCba->SetCommandSetL( R_SERVTAB_SOFTKEYS_OPTIONS_DETAILS__EXIT );
       
  1104                     iCurrentCmdToExe = ECmdContactDetails;
       
  1105                     }
       
  1106                 iCba->DrawNow();
       
  1107                 }
       
  1108             }
       
  1109         else if(  itemtype == TVIMPSTEnums::EUnknonContactItem  )
       
  1110             {
       
  1111             iLastFocusedItemType = itemtype;
       
  1112             if(TVIMPSTEnums::ESVCERegistered == servicestate && 
       
  1113                     iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EIM))
       
  1114                 {
       
  1115                 iCba->SetCommandSetL( R_SERVTAB_SOFTKEYS_OPTION_OPENCONV__EXIT );
       
  1116                 iCurrentCmdToExe = ECmdOpenConversation;
       
  1117                 }
       
  1118             else //im is not supporteed
       
  1119                 {
       
  1120                 iCba->SetCommandSetL( R_SERVTAB_SOFTKEYS_OPTIONS_EXIT__EMPTY );
       
  1121                 iCurrentCmdToExe = -1;
       
  1122                 }                     
       
  1123             iCba->DrawNow();   
       
  1124             }
       
  1125         // Focus on own contact item
       
  1126         else if( updateinvalid || itemtype == TVIMPSTEnums::EOwnStatusItem )
       
  1127             {
       
  1128             iLastFocusedItemType = itemtype;
       
  1129             if( iCba )
       
  1130                 {
       
  1131                 if ( itemtype == TVIMPSTEnums::EOwnStatusItem &&  TVIMPSTEnums::ESVCERegistered == servicestate )
       
  1132                     {
       
  1133                     // Own status
       
  1134                    // Options/Back/Change status
       
  1135                    //Get Presence SubService           
       
  1136                    MVIMPSTEngineSubService* subService =          
       
  1137                                (iEngine.SubService(TVIMPSTEnums::EPresence));
       
  1138                    TBool changeownstatussupported = EFalse;
       
  1139                    if(subService)
       
  1140                        {
       
  1141                        MVIMPSTEnginePresenceSubService& presence = 
       
  1142                                MVIMPSTEnginePresenceSubService::Cast (*subService);
       
  1143                        changeownstatussupported = presence.IsChangeOwnStatusSupported();
       
  1144                        }
       
  1145                    if(changeownstatussupported)
       
  1146                        {
       
  1147                        cbaRes = R_SERVTAB_SOFTKEYS_OPTIONS_EXIT__CHANGESTATUS;
       
  1148                        iCurrentCmdToExe = ECmdChangeStatus;
       
  1149                        }
       
  1150                    //else its cbres is set to options exit empty
       
  1151                     }
       
  1152               else if ( itemtype == TVIMPSTEnums::EOwnStatusItem &&  TVIMPSTEnums::ESVCENetworkConnecting == servicestate )
       
  1153                     {
       
  1154                     if(iTabbedView.CancelLoginSupportedL())
       
  1155                         {
       
  1156                         cbaRes = R_SERVTAB_SOFTKEYS_OPTION_CANCEL__EXIT;
       
  1157                         iCurrentCmdToExe = ECmdCancelLogin;
       
  1158                         }
       
  1159                     else
       
  1160                         {
       
  1161                         cbaRes = R_SERVTAB_SOFTKEYS_OPTIONS_EXIT__EMPTY;
       
  1162                         iCurrentCmdToExe = -1;
       
  1163                         }
       
  1164                     }
       
  1165               else if ( itemtype == TVIMPSTEnums::EOwnStatusItem &&  TVIMPSTEnums::ESVCEWaitingForNetwork == servicestate )
       
  1166                     {
       
  1167                     cbaRes = R_SERVTAB_SOFTKEYS_OPTION_CHANGECONN__EXIT;
       
  1168                     iCurrentCmdToExe = ECmdChangeConnectioninOnlineState;
       
  1169                     }
       
  1170               else 
       
  1171                   {
       
  1172                   cbaRes = R_SERVTAB_SOFTKEYS_OPTION_LOGIN__EXIT;
       
  1173                   iCurrentCmdToExe = ECmdLogin;
       
  1174                   }
       
  1175                 //add for connecting state and waiting for connection state.
       
  1176                 iCba->SetCommandSetL( cbaRes );
       
  1177                 iCba->DrawNow();
       
  1178                 }
       
  1179             }
       
  1180         }
       
  1181     }
       
  1182     
       
  1183 // ---------------------------------------------------------
       
  1184 // CVIMPSTUiSingleListBoxTabViewControl::HandleAvatarRefreshL()
       
  1185 // ---------------------------------------------------------
       
  1186 void CVIMPSTUiSingleListBoxTabViewControl::HandleAvatarRefreshL( const TDesC&/* aUserId */,TBool /*aBlock*/)
       
  1187 	{
       
  1188 	//no avatar implementation for single list box.
       
  1189 	}
       
  1190 
       
  1191 // End of File