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