uiservicetab/vimpstui/src/cvimpstuitabbedview.cpp
changeset 15 81eeb8c83ce5
parent 0 5e5d6b214f4f
equal deleted inserted replaced
0:5e5d6b214f4f 15:81eeb8c83ce5
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Implementation for CVIMPSTUiTabbedView
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "cvimpstuitabbedview.h"
       
    21 
       
    22 #include "cvimpstcmdhandler.h"
       
    23 #include "mvimpstuitabbedviewcontrol.h"
       
    24 #include "mvimpstuitabcontrolfactory.h"
       
    25 #include "vimpstcmd.hrh"
       
    26 #include "mvimpstcmd.h"
       
    27 #include "mvimpstengine.h"
       
    28 #include "mvimpstenginesearchmgrextention.h"
       
    29 
       
    30 #include "vimpstui.hrh"
       
    31 #include "vimpstextentionuiuid.h"
       
    32 #include "tvimpstconsts.h"
       
    33 #include "cvimpstuiextensionservice.h"
       
    34 #include "cvimpstuibranddata.h"
       
    35 #include "mvimpstprocessarray.h"
       
    36 #include "vimpstutilsdialog.h"
       
    37 #include "vimpstutilswaitnote.h"
       
    38 #include "vimpstcmd.hrh"
       
    39 #include "cvimpstuisearchfieldaray.h"
       
    40 #include "mvimpstuisearchfield.h"
       
    41 #include "cvimpstuisearchquerydialog.h"
       
    42 #include "cvimpstuiavatarselectionhandler.h" // avatar selection
       
    43 #include "cvimpstuistatuspanehandler.h"
       
    44 
       
    45 
       
    46 #include "mvimpstengineextentionfeatures.h"
       
    47 #include "mvimpststoragevpbkstorehandler.h"
       
    48 
       
    49 // System includes
       
    50 #include <akntoolbar.h>             //CAknToolbar
       
    51 #include <eikcolib.h>               //CEikAppUiFactory
       
    52 
       
    53 #include <coecntrl.h>
       
    54 #include <eikmenup.h>
       
    55 #include <AknGlobalNote.h>
       
    56 #include <eikbtgpc.h>
       
    57 #include <avkon.rsg>
       
    58 #include <aknnotewrappers.h> 
       
    59 #include <AknQueryDialog.h> 
       
    60 #include <StringLoader.h>
       
    61 #include <eikenv.h>
       
    62 #include <e32property.h>
       
    63 #include <apgtask.h>
       
    64 #include <aknmessagequerydialog.h>
       
    65 
       
    66 // Pbk2
       
    67 #include <MPbk2AppUi.h>
       
    68 #include <CPbk2UIExtensionView.h>
       
    69 #include <MPbk2ViewActivationTransaction.h>
       
    70 #include <MPbk2ViewExplorer.h>
       
    71 #include <CPbk2ViewState.h>
       
    72 #include <MPbk2StartupMonitor.h>
       
    73 #include <Pbk2Commands.hrh>
       
    74 #include <MVPbkStoreContact.h>
       
    75 
       
    76 #include <MPbk2ApplicationServices.h>
       
    77 #include <MPbk2CommandHandler.h>
       
    78 // xSP extension manager
       
    79 #include "MxSPViewMapper.h"
       
    80 #include "MxSPContactManager.h"
       
    81 #include "cvimpststoragemanagerfactory.h"
       
    82 #include "mvimpststorageserviceview.h"
       
    83 #include "cvimpstuimenuextension.h"
       
    84 
       
    85 //resource
       
    86 #include <ExtensionManagerRes.rsg>
       
    87 #include <vimpstuires.rsg>
       
    88 
       
    89 //CCA
       
    90 #include <mccaparameter.h>
       
    91 #include <ccafactory.h>
       
    92 #include <mccaconnection.h>
       
    93 
       
    94 #include "vimpstdebugprint.h"
       
    95 
       
    96 //AIW - VOIP
       
    97 #include <aiwdialdataext.h>
       
    98 #include <aknPopup.h>
       
    99 #include <AiwCommon.hrh>
       
   100 #include <AiwServiceHandler.h>
       
   101 #include <aiwdialdata.h>
       
   102 #include <MVPbkStoreContact.h>
       
   103 
       
   104 //browser launch
       
   105 #include <BrowserLauncher.h>
       
   106 #include "cvimpstuitermsofusedialoghandler.h"
       
   107 #include <cvimpstsettingsstore.h>
       
   108 #include <aknmessagequerydialog.h>
       
   109 #include "tvimpstconsts.h"
       
   110 // avatar
       
   111 #include "mvimpstenginepresencesubservice.h"
       
   112 #include "mvimpstenginesubservice.h"
       
   113 #include "mvimpstengineimsubservice.h"
       
   114 #include "cvimpstuicontactselection.h"
       
   115 
       
   116 #include    <vimpstui.mbg>
       
   117 // help launch
       
   118 #include <hlplch.h>
       
   119 #include <coehelp.h>
       
   120 #include "meco.hlp.hrh"
       
   121 
       
   122 #include    <AiwGenericParam.h>
       
   123 #include    <AiwCommon.hrh>                //KAiwCmdCall
       
   124 #include    <AiwContactAssignDataTypes.h>
       
   125 #include 	<commonphoneparser.h>
       
   126 
       
   127 using namespace AiwContactAssign;
       
   128 using namespace Phonebook2;
       
   129 
       
   130 const TInt KBufLen(512);
       
   131 
       
   132 
       
   133 // ================= MEMBER FUNCTIONS =======================
       
   134 
       
   135 
       
   136 // --------------------------------------------------------------------------
       
   137 // CVIMPSTUiTabbedView::CVIMPSTUiTabbedView
       
   138 // --------------------------------------------------------------------------
       
   139 //
       
   140 CVIMPSTUiTabbedView::CVIMPSTUiTabbedView( 
       
   141 MxSPViewMapper& aMapper, 
       
   142 MxSPContactManager& aContactManager, 
       
   143 TUint aTabbedViewId,
       
   144 TUint aServiceId,
       
   145 CPbk2UIExtensionView& aView,
       
   146 TUid /*aId*/,
       
   147 CVIMPSTUIExtensionService& aServiceData,
       
   148 MVIMPSTEngine& aEngine,
       
   149 MVIMPSTCmdHandler& aCommandHandler,
       
   150 CVIMPSTUIMenuExtension& aMenuExtension) :
       
   151 CxSPBaseView( aMapper, aContactManager, aView ),
       
   152 iViewId( aTabbedViewId ),
       
   153 iServiceId(aServiceId),
       
   154 iEngine(aEngine),
       
   155 iExtensionService( aServiceData ),
       
   156 iCommandHandler( aCommandHandler),
       
   157 iMenuExtension(aMenuExtension),
       
   158 iSelectedAction( KErrNotFound )
       
   159 
       
   160             {
       
   161             iFixedToolbar = NULL;
       
   162             iIsToolBarHidden = ETrue;
       
   163             }
       
   164 
       
   165 
       
   166 // --------------------------------------------------------------------------
       
   167 // CVIMPSTUiTabbedView::ConstructL
       
   168 // --------------------------------------------------------------------------
       
   169 //
       
   170 inline void CVIMPSTUiTabbedView::ConstructL()
       
   171     {
       
   172     ViewBaseConstructL( KIMCONTACTSEXTNIMPLEMENTATIONUID, iViewId );   
       
   173     
       
   174     iCommandHandler.RegisterEventObserverL(this);
       
   175 
       
   176     iPreviousState = TVIMPSTEnums::ESVCENotRegistered; 
       
   177 
       
   178     iServiceHandler = CAiwServiceHandler::NewL();    
       
   179 
       
   180     iServiceHandler->AttachL( R_IM_APP_INTEREST );
       
   181     iServiceHandler->AttachMenuL( R_SERVTAB_TABBED_VIEW_MENU, 
       
   182             R_IM_APP_INTEREST );   
       
   183 
       
   184     iServiceHandler->AttachL( R_AIWASSIGNMENT_INTEREST );    
       
   185    	
       
   186 	iServiceHandler->AttachL( R_AIWSELECT_INTEREST );
       
   187 
       
   188     iStatusMessage = HBufC::NewL( KStatusTextLength ); 
       
   189 
       
   190     iStatusPaneHandler = CCVIMPSTUiStatusPaneHandler::NewL();
       
   191 
       
   192     //Get SearchMgr
       
   193     MVIMPSTEngineExtentionFeatures* feature = iEngine.ExtentionFeatures(TVIMPSTEnums::ESearch);
       
   194     if (feature)
       
   195         {
       
   196         MVIMPSTEngineSearchMgrExtention& searchMgr = 
       
   197         MVIMPSTEngineSearchMgrExtention::Cast
       
   198         (*feature);	
       
   199 
       
   200         searchMgr.RegisterObserver(this);   	
       
   201         }
       
   202     iSettingsStore = CVIMPSTSettingsStore::NewL();
       
   203     
       
   204 	iBrandHandler = CVIMPSTUiBrandData::NewL( iEngine );
       
   205 	
       
   206 	iAppUi = CCoeEnv::Static()->AppUi();
       
   207 	
       
   208 	CFbsBitmap *bitmap, *mask;
       
   209 	iBrandHandler->GetBrandBitmapsL( &bitmap, &mask);
       
   210 	iStatusPaneHandler->SetPictureL( bitmap, mask );
       
   211 	
       
   212 	iIsServiceHandleReSet = EFalse;
       
   213 	
       
   214 	iContainerCreationStarted = EFalse;
       
   215     }
       
   216 
       
   217 
       
   218 // --------------------------------------------------------------------------
       
   219 // CVIMPSTUiTabbedView::NewL
       
   220 // --------------------------------------------------------------------------
       
   221 //
       
   222 CVIMPSTUiTabbedView* CVIMPSTUiTabbedView::NewL( MxSPViewMapper& aMapper, 
       
   223         MxSPContactManager& aContactManager, 
       
   224         TUint aTabbedViewId,
       
   225         TUint aServiceId,
       
   226         CPbk2UIExtensionView& aView,
       
   227         TUid aId,
       
   228         CVIMPSTUIExtensionService& aServiceData,
       
   229         MVIMPSTEngine& aEngine,
       
   230         MVIMPSTCmdHandler& aCommandHandler,
       
   231         CVIMPSTUIMenuExtension& aMenuExtension)
       
   232     {
       
   233     CVIMPSTUiTabbedView* self = new(ELeave) CVIMPSTUiTabbedView( aMapper, 
       
   234             aContactManager,
       
   235             aTabbedViewId,
       
   236             aServiceId, 
       
   237             aView, 
       
   238             aId,
       
   239             aServiceData,
       
   240             aEngine,
       
   241             aCommandHandler,
       
   242             aMenuExtension);
       
   243     CleanupStack::PushL(self);
       
   244     self->ConstructL();
       
   245     CleanupStack::Pop(self);
       
   246     return self;
       
   247     }
       
   248 
       
   249 
       
   250 // --------------------------------------------------------------------------
       
   251 // CVIMPSTUiTabbedView::~CVIMPSTUiTabbedView
       
   252 // --------------------------------------------------------------------------
       
   253 //
       
   254 CVIMPSTUiTabbedView::~CVIMPSTUiTabbedView()
       
   255     {
       
   256     delete iContactSelection;
       
   257     delete iFriendRequestId;
       
   258     
       
   259     delete iSelectedData.iPackedLinks;
       
   260     iSelectedData.iXSPList.ResetAndDestroy();
       
   261   
       
   262   	delete iQueryResult;  
       
   263     //Get SearchMgr
       
   264     MVIMPSTEngineExtentionFeatures* feature = iEngine.ExtentionFeatures(TVIMPSTEnums::ESearch);
       
   265     if (feature)
       
   266         {
       
   267         MVIMPSTEngineSearchMgrExtention& searchMgr = 
       
   268         MVIMPSTEngineSearchMgrExtention::Cast
       
   269         (*feature);	
       
   270 
       
   271         searchMgr.UnRegisterObserver(this);   	
       
   272         }
       
   273 
       
   274     if(iParameter!=NULL)
       
   275         iParameter->Close();    
       
   276     if(iConnection!=NULL)
       
   277         {
       
   278         iConnection->Close();
       
   279         iConnection = NULL;
       
   280         }
       
   281 
       
   282     if (iContainer && iAppUi )
       
   283         {
       
   284         iAppUi->RemoveFromStack( iContainer->CoeControl() );
       
   285         delete iContainer;
       
   286         iContainerCreationStarted = EFalse;
       
   287         }
       
   288     delete iBrandHandler;
       
   289     iCommandHandler.UnRegisterEventObserver(this);	
       
   290 
       
   291     if ( iFixedToolbar )
       
   292         {
       
   293         iFixedToolbar->SetToolbarObserver( NULL );
       
   294         delete iFixedToolbar;
       
   295         iFixedToolbar = NULL;
       
   296         }
       
   297 
       
   298     if (iServiceHandler)
       
   299         {
       
   300         iServiceHandler->Reset();
       
   301         delete iServiceHandler;	
       
   302         iServiceHandler = NULL;
       
   303         }
       
   304 
       
   305     delete iContact;
       
   306 
       
   307     if(iFocussedIDHistory)
       
   308         {
       
   309         delete iFocussedIDHistory;
       
   310         iFocussedIDHistory = NULL;
       
   311         }
       
   312     delete iBrLauncher; 
       
   313     delete iUserId;
       
   314    
       
   315     if(iSettingsStore)
       
   316         {
       
   317         delete iSettingsStore;
       
   318         iSettingsStore = NULL;
       
   319         }
       
   320     delete iStatusPaneHandler;
       
   321 
       
   322     delete iAiwParamList;
       
   323     
       
   324     if(iStatusMessage)
       
   325 	    {
       
   326 	    delete iStatusMessage; 
       
   327 	    }
       
   328 
       
   329     }
       
   330 
       
   331 
       
   332 
       
   333 // --------------------------------------------------------------------------
       
   334 // CVIMPSTUiTabbedView::DynInitMenuPaneL
       
   335 // --------------------------------------------------------------------------
       
   336 //
       
   337 void CVIMPSTUiTabbedView::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   338     {    
       
   339     // AIW knows its own submenu hooks, so we can return from 
       
   340     // here if AIW handled this.
       
   341     ReInitializeServiceHandlerL();
       
   342     
       
   343     iMenuExtension.ResetAIWCommandMap();
       
   344     
       
   345     if ( iServiceHandler->HandleSubmenuL( *aMenuPane ) )
       
   346         {
       
   347         return;
       
   348         }
       
   349 
       
   350     TBool imService     = iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EIM);
       
   351     TBool voipService   = iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EVoip);
       
   352     TBool presenceService = iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EPresence);
       
   353     TVIMPSTEnums::TVIMPSTRegistrationState serviceTabState = 
       
   354     							iEngine.ServiceState();
       
   355 
       
   356     TInt itemIndex = CurrentItemIndex();
       
   357     // fetch the item and process correct type    
       
   358     TVIMPSTEnums::TItem itemType = iCommandHandler.GetProcessInterface().GetType(itemIndex);        
       
   359     TVIMPSTEnums::TOnlineStatus onlinestatus = iCommandHandler.GetProcessInterface().GetOnlineStatusL(itemIndex);        
       
   360 
       
   361     switch( aResourceId)
       
   362         {
       
   363         case R_EXTENSION_MANAGER_MENU:
       
   364             { 
       
   365             aMenuPane->AddMenuItemsL(R_SERVTAB_TABBED_VIEW_MENU);
       
   366             aMenuPane->AddMenuItemsL(R_TABBED_VIEW_GENERAL_MENU);
       
   367 
       
   368 			aMenuPane->SetItemDimmed(ECmdGetBlockedList, ETrue);
       
   369             //based on sevice states decide what all submenu should be shown
       
   370             //and main menu's to be shown
       
   371             switch (serviceTabState)
       
   372                 {
       
   373                 case TVIMPSTEnums::ESVCENotRegistered:
       
   374                     {                   
       
   375                     aMenuPane->SetItemDimmed(ECmdCreateNewOption, ETrue);
       
   376                     aMenuPane->SetItemDimmed(ECmdMyAvatar, ETrue);
       
   377                     aMenuPane->SetItemDimmed(ECmdChangeStatus, ETrue);
       
   378                     aMenuPane->SetItemDimmed(ECmdLogout, ETrue);
       
   379                     aMenuPane->SetItemDimmed(ECmdCancelLogin, ETrue);
       
   380                     aMenuPane->SetItemDimmed(ECmdChangeConnectioninOnlineState, ETrue);
       
   381                     aMenuPane->SetItemDimmed(ECmdChangeConnectioninWaitingState, ETrue);
       
   382                     break;	
       
   383                     }
       
   384                 case TVIMPSTEnums::ESVCERegistered:
       
   385                     { 
       
   386                     if (!presenceService)
       
   387                         {
       
   388                         aMenuPane->SetItemDimmed(ECmdMyAvatar, ETrue);	
       
   389                         aMenuPane->SetItemDimmed(ECmdChangeStatus, ETrue);	
       
   390                         }
       
   391                     else
       
   392                         {
       
   393                         //find whether avatar is supported  
       
   394                          	//Get Presence SubService  			
       
   395 					   	MVIMPSTEngineSubService* subService =    	   
       
   396 					   	   					(iEngine.SubService(TVIMPSTEnums::EPresence));
       
   397 					    if(subService)
       
   398 					        {
       
   399 					        MVIMPSTEnginePresenceSubService& presence = 
       
   400 					        		MVIMPSTEnginePresenceSubService::Cast (*subService);
       
   401 					        
       
   402 					        aMenuPane->SetItemDimmed(ECmdMyAvatar, !presence.IsAvatarSupported() ); 
       
   403 					        }   
       
   404         
       
   405         	           }		           		
       
   406                     aMenuPane->SetItemDimmed(ECmdLogin, ETrue);
       
   407                     aMenuPane->SetItemDimmed(ECmdCancelLogin, ETrue);
       
   408        		
       
   409 		       		if (!ChangeConnectionSupportedL())
       
   410 		           		{
       
   411 		           		aMenuPane->SetItemDimmed(ECmdChangeConnectioninOnlineState, ETrue);
       
   412 		           		}
       
   413 		           		
       
   414 		       		aMenuPane->SetItemDimmed(ECmdChangeConnectioninWaitingState, ETrue);
       
   415                     if(iEngine.IsBlockSupportedL())
       
   416                         {
       
   417 						aMenuPane->SetItemDimmed(ECmdGetBlockedList, EFalse);
       
   418                         }
       
   419                     break;	
       
   420                     }
       
   421                 case TVIMPSTEnums::ESVCENetworkConnecting:
       
   422                     {                  
       
   423                     aMenuPane->SetItemDimmed(ECmdChangeStatus, ETrue);
       
   424                     aMenuPane->SetItemDimmed(ECmdCreateNewOption, ETrue);
       
   425                     aMenuPane->SetItemDimmed(ECmdMyAvatar, ETrue);
       
   426                     aMenuPane->SetItemDimmed(ECmdLogin, ETrue);
       
   427                     aMenuPane->SetItemDimmed(ECmdLogout, ETrue);
       
   428                     aMenuPane->SetItemDimmed(ECmdSettings, ETrue);	           		
       
   429 		       		aMenuPane->SetItemDimmed(ECmdChangeConnectioninOnlineState, ETrue);   
       
   430 		       		aMenuPane->SetItemDimmed(ECmdChangeConnectioninWaitingState, ETrue);        		
       
   431                     if( !CancelLoginSupportedL())
       
   432                         {
       
   433                         aMenuPane->SetItemDimmed(ECmdCancelLogin, ETrue);
       
   434                         }
       
   435                     break;	
       
   436                     }
       
   437                 case TVIMPSTEnums::ESVCEWaitingForNetwork:
       
   438                 case TVIMPSTEnums::ESVCEUpdatingContacts:
       
   439                     {
       
   440                     aMenuPane->SetItemDimmed(ECmdChangeStatus, ETrue);
       
   441                     aMenuPane->SetItemDimmed(ECmdCreateNewOption, ETrue);
       
   442                     aMenuPane->SetItemDimmed(ECmdMyAvatar, ETrue);
       
   443                     aMenuPane->SetItemDimmed(ECmdLogin, ETrue);
       
   444                     aMenuPane->SetItemDimmed(ECmdCancelLogin, ETrue);
       
   445 		       		aMenuPane->SetItemDimmed(ECmdChangeConnectioninOnlineState, ETrue);	           		
       
   446 		       		if (!ChangeConnectionSupportedL())
       
   447 		           		{
       
   448 		           		aMenuPane->SetItemDimmed(ECmdChangeConnectioninWaitingState, ETrue);
       
   449 		           		}
       
   450                     break;	
       
   451                     }
       
   452                 case TVIMPSTEnums::ESVCENetworkDisConnecting:
       
   453                     {                   
       
   454                     aMenuPane->SetItemDimmed(ECmdChangeStatus, ETrue);
       
   455                     aMenuPane->SetItemDimmed(ECmdCreateNewOption, ETrue);
       
   456                     aMenuPane->SetItemDimmed(ECmdMyAvatar, ETrue);
       
   457                     aMenuPane->SetItemDimmed(ECmdLogin, ETrue);
       
   458                     aMenuPane->SetItemDimmed(ECmdCancelLogin, ETrue);
       
   459                     aMenuPane->SetItemDimmed(ECmdSettings, ETrue);	
       
   460                     aMenuPane->SetItemDimmed(ECmdLogout, ETrue);
       
   461 		       		aMenuPane->SetItemDimmed(ECmdChangeConnectioninWaitingState, ETrue);
       
   462 		       		aMenuPane->SetItemDimmed(ECmdChangeConnectioninOnlineState, ETrue);	           		
       
   463                     break;	
       
   464                     }
       
   465                 default:
       
   466                     {
       
   467                     break;	
       
   468                     }
       
   469                 }
       
   470             // common to all 
       
   471             aMenuPane->SetItemDimmed(ECmdContactAddAsFriend, ETrue);
       
   472             aMenuPane->SetItemDimmed(KAiwCmdCall, ETrue);
       
   473             aMenuPane->SetItemDimmed(ECmdCloseConversation, ETrue);
       
   474             aMenuPane->SetItemDimmed(ECmdContactDetails, ETrue);
       
   475             aMenuPane->SetItemDimmed(ECmdOpenFriendRequest, ETrue);
       
   476             aMenuPane->SetItemDimmed(ECmdContactEdit, ETrue);
       
   477             aMenuPane->SetItemDimmed(ECmdAIWAddToContact, ETrue); 
       
   478             aMenuPane->SetItemDimmed(ECmdAIWLinkToContact, ETrue);
       
   479             aMenuPane->SetItemDimmed(ECmdBlock, ETrue);
       
   480             aMenuPane->SetItemDimmed(ECmdUnBlock, ETrue);
       
   481             aMenuPane->SetItemDimmed(ECmdContactDelete, ETrue);
       
   482             //based on items in focus decide what main menu items needs to be shown
       
   483             switch(itemType)
       
   484                 {	            	
       
   485                 case TVIMPSTEnums::EOwnStatusItem:
       
   486                 case TVIMPSTEnums::EInvalid:     // this case comes when no matched found for findpane characters
       
   487                     {
       
   488                     break;	
       
   489                     }
       
   490                 case TVIMPSTEnums::EContactItem:
       
   491                     {      
       
   492                     //conversation related menu   
       
   493                     MVIMPSTStorageServiceView* storage = 
       
   494                     CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);
       
   495                     TBool localstore = EFalse;
       
   496                     if (storage)
       
   497                         {
       
   498                         localstore = storage->IsLocalStore();
       
   499                         }
       
   500                     if (TVIMPSTEnums::ESVCERegistered == serviceTabState)
       
   501                         {
       
   502                         TPtrC selectedItem = iCommandHandler.GetProcessInterface().
       
   503                         GetItemUserId(itemIndex);
       
   504                         if( selectedItem != KNullDesC )
       
   505                             {
       
   506                             if (imService)
       
   507                                 {
       
   508                                 if ( iCommandHandler.GetProcessInterface().IsConversationExist( itemIndex ) )
       
   509                                     {
       
   510                                     aMenuPane->SetItemDimmed(ECmdCloseConversation, EFalse);	
       
   511                                     }
       
   512                                 }
       
   513                             }
       
   514                         if(voipService)
       
   515                             {
       
   516                             TInt index;
       
   517                             aMenuPane->MenuItemExists(KAiwCmdCall, index);
       
   518                             aMenuPane->SetItemDimmed(KAiwCmdCall, EFalse);
       
   519 
       
   520                             CAiwDialDataExt* dialDataExt = CAiwDialDataExt::NewL();
       
   521                             CleanupStack::PushL( dialDataExt );
       
   522                             dialDataExt->SetServiceId( iServiceId );
       
   523                             ReInitializeServiceHandlerL();
       
   524                             CAiwGenericParamList& paramList = iServiceHandler->InParamListL();
       
   525                             dialDataExt->FillInParamListL( paramList );                          
       
   526                             TAiwVariant variant;
       
   527                             TAiwGenericParam param ( EGenericParamSIPAddress, variant );
       
   528                             paramList.AppendL( param );
       
   529                             iServiceHandler->InitializeMenuPaneL( *aMenuPane, 
       
   530                                     R_SERVTAB_TABBED_VIEW_MENU,
       
   531                                     // Must not overlap with the other menu ids!
       
   532                                     ECmdAIWRangeStart,
       
   533                                     paramList );
       
   534 
       
   535                             CleanupStack::PopAndDestroy( dialDataExt );	
       
   536 
       
   537                             CEikMenuPaneItem::SData& data = aMenuPane->ItemDataByIndexL(index);
       
   538                             //add to AIW command map of the menuextension manager
       
   539                             iMenuExtension.AddToAIWCommandMap(KAiwCmdCall,data.iCommandId);
       
   540                             }                            
       
   541 
       
   542                         aMenuPane->SetItemDimmed(ECmdContactDetails, EFalse);  
       
   543                         
       
   544                             if (localstore)
       
   545                                 {
       
   546                                 //ContactEdit is enabled only for localstore
       
   547                                 aMenuPane->SetItemDimmed(ECmdContactEdit, EFalse);
       
   548                                 }
       
   549                             if(iEngine.IsBlockSupportedL())
       
   550                                 {
       
   551                                 TVIMPSTEnums::TOnlineStatus status = iCommandHandler.GetProcessInterface().GetOnlineStatusL(itemIndex); 
       
   552                                 if(TVIMPSTEnums::EBlocked == status )
       
   553                                     {
       
   554                                     aMenuPane->SetItemDimmed(ECmdUnBlock, EFalse);
       
   555                                     }
       
   556                                 else if( selectedItem .Length() )
       
   557                                     {
       
   558                                     aMenuPane->SetItemDimmed(ECmdBlock, EFalse);
       
   559                                     }
       
   560                                 }
       
   561                             aMenuPane->SetItemDimmed(ECmdContactDelete, EFalse);    
       
   562                             
       
   563                       
       
   564                         if (!localstore)
       
   565                             {
       
   566                             aMenuPane->SetItemDimmed(ECmdAIWAddToContact, EFalse);  
       
   567                             aMenuPane->SetItemDimmed(ECmdAIWLinkToContact, EFalse);
       
   568                             }
       
   569                         }
       
   570                     else if (TVIMPSTEnums::ESVCENotRegistered == serviceTabState)
       
   571                         {
       
   572                         if(!presenceService)
       
   573                             {
       
   574                             if (localstore)
       
   575                                 {
       
   576                                 //ContactEdit is enabled only for localstore
       
   577                                 aMenuPane->SetItemDimmed(ECmdContactEdit, EFalse);
       
   578                                 }                            
       
   579                             }
       
   580                         }
       
   581                     
       
   582 					break;	
       
   583                     }
       
   584                 case TVIMPSTEnums::EUnknonContactItem :
       
   585                     {
       
   586                     aMenuPane->SetItemDimmed(ECmdContactAddAsFriend, EFalse);
       
   587                     aMenuPane->SetItemDimmed(ECmdContactDetails, ETrue);
       
   588                     aMenuPane->SetItemDimmed(ECmdOpenFriendRequest, ETrue);
       
   589                     aMenuPane->SetItemDimmed(ECmdContactEdit, ETrue);
       
   590                     aMenuPane->SetItemDimmed(ECmdAIWAddToContact, ETrue); 
       
   591                     aMenuPane->SetItemDimmed(ECmdAIWLinkToContact, ETrue);
       
   592                     aMenuPane->SetItemDimmed(ECmdBlock, ETrue);
       
   593                     aMenuPane->SetItemDimmed(ECmdUnBlock, ETrue);
       
   594                     aMenuPane->SetItemDimmed(ECmdContactDelete, ETrue);
       
   595                     if( iEngine.IsBlockSupportedL() )
       
   596                         {
       
   597                         aMenuPane->SetItemDimmed(ECmdBlock, EFalse);
       
   598                         }
       
   599                     if (imService)
       
   600                         {                            
       
   601                         if (iCommandHandler.GetProcessInterface().IsConversationExist( itemIndex ))
       
   602                             {
       
   603                             aMenuPane->SetItemDimmed(ECmdCloseConversation, EFalse);    
       
   604                             }
       
   605                         }
       
   606                     if(voipService)
       
   607                         {
       
   608 						TInt index;
       
   609                         aMenuPane->MenuItemExists(KAiwCmdCall, index);
       
   610 								
       
   611                         aMenuPane->SetItemDimmed(KAiwCmdCall, EFalse);
       
   612 
       
   613                         CAiwDialDataExt* dialDataExt = CAiwDialDataExt::NewL();
       
   614                         CleanupStack::PushL( dialDataExt );
       
   615                         dialDataExt->SetServiceId( iServiceId );
       
   616                         ReInitializeServiceHandlerL();
       
   617                         CAiwGenericParamList& paramList = iServiceHandler->InParamListL();
       
   618                         dialDataExt->FillInParamListL( paramList );                          
       
   619                         TAiwVariant variant;
       
   620                         TAiwGenericParam param ( EGenericParamSIPAddress, variant );
       
   621                         paramList.AppendL( param );
       
   622                         iServiceHandler->InitializeMenuPaneL( *aMenuPane, 
       
   623                                 R_SERVTAB_TABBED_VIEW_MENU,
       
   624                                 // Must not overlap with the other menu ids!
       
   625                                 ECmdAIWRangeStart,
       
   626                                 paramList );
       
   627                         CleanupStack::PopAndDestroy( dialDataExt ); 
       
   628 						
       
   629 						CEikMenuPaneItem::SData& data = aMenuPane->ItemDataByIndexL(index);
       
   630 					    //add to AIW command map of the menuextension manager
       
   631                         iMenuExtension.AddToAIWCommandMap(KAiwCmdCall,data.iCommandId);
       
   632  
       
   633                         }  
       
   634                     break;
       
   635                     }
       
   636                 case TVIMPSTEnums::EFriendRequestItem:
       
   637                     {
       
   638                     aMenuPane->SetItemDimmed(ECmdContactDetails, ETrue);
       
   639                     aMenuPane->SetItemDimmed(ECmdContactEdit, ETrue);
       
   640                     aMenuPane->SetItemDimmed(ECmdAIWAddToContact, ETrue); 
       
   641                     aMenuPane->SetItemDimmed(ECmdAIWLinkToContact, ETrue);
       
   642                     aMenuPane->SetItemDimmed(ECmdBlock, ETrue);
       
   643                     aMenuPane->SetItemDimmed(ECmdUnBlock, ETrue);
       
   644                     aMenuPane->SetItemDimmed(ECmdContactDelete, ETrue);
       
   645                     aMenuPane->SetItemDimmed(ECmdOpenFriendRequest, EFalse);
       
   646                     if(iEngine.IsBlockSupportedL())
       
   647                         {
       
   648                         aMenuPane->SetItemDimmed(ECmdBlock, EFalse);
       
   649                         }
       
   650                     break;  
       
   651                     }
       
   652                 default:
       
   653                     {
       
   654                     break;	
       
   655                     }
       
   656                 }
       
   657             // append the servicetab options(R_TABBED_VIEW_OPTIONS_MENU) and tabbed 
       
   658             // viem(R_SERVTAB_TABBED_VIEW_MENU) menu items and the the service
       
   659             // specific options and then settings,help and exit.(R_TABBED_VIEW_GENERAL_MENU)
       
   660             iMenuExtension.OfferMenuPaneToPlugins(ECmdCancelLogin,*aMenuPane,iServiceId);
       
   661 
       
   662             break;	
       
   663             }
       
   664 
       
   665         case R_SERVTAB_CREATENEW_OPTION_SUBMENU:
       
   666             {
       
   667 
       
   668             aMenuPane->SetItemDimmed(ECmdAddContact, ETrue);
       
   669             aMenuPane->SetItemDimmed(ECmdAddFromPhoneBook, ETrue);
       
   670             aMenuPane->SetItemDimmed(ECmdSearch, ETrue);					           		
       
   671 
       
   672             if (TVIMPSTEnums::ESVCERegistered == serviceTabState)            	
       
   673                 {
       
   674                 aMenuPane->SetItemDimmed(ECmdAddContact, EFalse);
       
   675                 aMenuPane->SetItemDimmed(ECmdAddFromPhoneBook, EFalse);
       
   676 
       
   677                 //make search request using search manager in engine   	
       
   678                 MVIMPSTEngineExtentionFeatures* feature = 
       
   679                 iEngine.ExtentionFeatures(TVIMPSTEnums::ESearch);
       
   680 
       
   681                 if (feature)
       
   682                     {
       
   683                     if ( TVIMPSTEnums::ESupported == feature->IsSupported() )
       
   684                         {
       
   685                         aMenuPane->SetItemDimmed(ECmdSearch, EFalse);//show if search is supported. 
       
   686                         }
       
   687                     }
       
   688                 }
       
   689             break;	
       
   690             }
       
   691 
       
   692         case R_SERVTAB_CHANGEAVATAR_SUBMENU: 
       
   693             {            	
       
   694             if ((TVIMPSTEnums::ESVCERegistered != serviceTabState) ||
       
   695                     (!presenceService))
       
   696                 {
       
   697                 aMenuPane->SetItemDimmed(ECmdAvatarGallery, ETrue);	
       
   698                 aMenuPane->SetItemDimmed(ECmdAvatarNewPhoto, ETrue);	
       
   699                 aMenuPane->SetItemDimmed(ECmdDefaultAvatar, ETrue);	
       
   700                 }            
       
   701             break;	
       
   702             }
       
   703 
       
   704         case R_TABBED_VIEW_GENERAL_MENU:
       
   705             {
       
   706             switch (serviceTabState)
       
   707                 {
       
   708                 case TVIMPSTEnums::ESVCENotRegistered:
       
   709                     {
       
   710                     aMenuPane->SetItemDimmed(ECmdLogout, ETrue);
       
   711                     aMenuPane->SetItemDimmed(ECmdCancelLogin, ETrue);
       
   712 					aMenuPane->SetItemDimmed(ECmdGetBlockedList, ETrue);
       
   713                     break;	
       
   714                     }
       
   715                 case TVIMPSTEnums::ESVCERegistered:
       
   716                     {
       
   717                     aMenuPane->SetItemDimmed(ECmdLogin, ETrue);
       
   718                     aMenuPane->SetItemDimmed(ECmdCancelLogin, ETrue);
       
   719                     break;	
       
   720                     }
       
   721                 case TVIMPSTEnums::ESVCENetworkConnecting:
       
   722                     {
       
   723                     aMenuPane->SetItemDimmed(ECmdLogin, ETrue);
       
   724 					aMenuPane->SetItemDimmed(ECmdGetBlockedList, ETrue);
       
   725                     aMenuPane->SetItemDimmed(ECmdLogout, ETrue);
       
   726                     aMenuPane->SetItemDimmed(ECmdSettings, ETrue);	           		
       
   727                     if( !CancelLoginSupportedL())
       
   728                         {
       
   729                         aMenuPane->SetItemDimmed(ECmdCancelLogin, ETrue);
       
   730                         }
       
   731                     break;	
       
   732                     }
       
   733                 case TVIMPSTEnums::ESVCEWaitingForNetwork:
       
   734                 case TVIMPSTEnums::ESVCEUpdatingContacts:
       
   735                     {
       
   736                     aMenuPane->SetItemDimmed(ECmdLogin, ETrue);
       
   737                     aMenuPane->SetItemDimmed(ECmdCancelLogin, ETrue);
       
   738 					aMenuPane->SetItemDimmed(ECmdGetBlockedList, ETrue);
       
   739                     break;	
       
   740                     }
       
   741                 case TVIMPSTEnums::ESVCENetworkDisConnecting:
       
   742                     {
       
   743                     aMenuPane->SetItemDimmed(ECmdLogin, ETrue);
       
   744                     aMenuPane->SetItemDimmed(ECmdCancelLogin, ETrue);
       
   745                     aMenuPane->SetItemDimmed(ECmdSettings, ETrue);
       
   746 					aMenuPane->SetItemDimmed(ECmdGetBlockedList, ETrue);
       
   747                     aMenuPane->SetItemDimmed(ECmdLogout, ETrue);
       
   748                     break;	
       
   749                     }
       
   750                 default:
       
   751                     {
       
   752                     break;	
       
   753                     }
       
   754 
       
   755 
       
   756                 }
       
   757             break;	
       
   758             }
       
   759         }                
       
   760 
       
   761     }
       
   762 
       
   763 // --------------------------------------------------------------------------
       
   764 // CVIMPSTUiTabbedView::HandleCommandL
       
   765 // --------------------------------------------------------------------------
       
   766 //
       
   767 void CVIMPSTUiTabbedView::HandleCommandL(TInt aCommand)
       
   768     {
       
   769     //offer to extensions first, then to aiw.
       
   770     if(iMenuExtension.OfferHandleCommandToPlugins(aCommand))
       
   771         {
       
   772         //command is executed, hence return.
       
   773         return;
       
   774         }
       
   775     ReInitializeServiceHandlerL();
       
   776     TInt serviceCommandId =iServiceHandler->ServiceCmdByMenuCmd(aCommand);
       
   777 
       
   778     if ( iContainer && serviceCommandId == KAiwCmdCall )
       
   779         {
       
   780        	MakeVoipCallL();
       
   781         return;
       
   782         }	
       
   783     
       
   784     if( iContainer )
       
   785         {
       
   786         iContainer->SetClrFindPaneFlag(ETrue);
       
   787         }
       
   788     
       
   789     switch (aCommand)
       
   790         {
       
   791         case ECmdLogin:
       
   792             {						
       
   793             LoginL();			
       
   794             break;
       
   795             }
       
   796         case ECmdSearch:
       
   797             {
       
   798             SearchContactsL();						
       
   799             break;
       
   800             }
       
   801         case ECmdAddFromPhoneBook:
       
   802             {
       
   803            
       
   804             LaunchFetchDialogL();						
       
   805             break;
       
   806             }
       
   807         case EAknCmdHelp:
       
   808             {
       
   809             TBool imSupported = iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EIM);
       
   810             TBool voipSupported = iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EVoip);
       
   811             if ( imSupported )
       
   812                 { 
       
   813                 if (  voipSupported  )
       
   814                     { // both Im and VOIP are enabled 
       
   815                     LaunchHelpL( KSERVTAB_HLP_MAIN_VIEW_VOIPIM );
       
   816                     }
       
   817                 else
       
   818                     {// only IM is enabled
       
   819                     LaunchHelpL( KSERVTAB_HLP_MAIN_VIEW_IM );
       
   820                     }
       
   821                 }
       
   822             else if ( voipSupported )
       
   823                 { // only VOIP is enabled
       
   824                 LaunchHelpL( KSERVTAB_HLP_MAIN_VIEW_VOIP );
       
   825                 }   
       
   826             
       
   827             break;
       
   828             }
       
   829         case EAknCmdExit:
       
   830         case EAknSoftkeyExit:
       
   831             { 
       
   832             //exit from phone book.
       
   833             Pbk2AppUi()->HandleCommandL( EAknSoftkeyExit );
       
   834 
       
   835             break;
       
   836             }
       
   837         case ECmdSettings:
       
   838             {
       
   839              LaunchSettingsViewL();
       
   840              break;
       
   841             }		
       
   842 
       
   843         case ECmdLogout:
       
   844             {                        
       
   845             // this is for actual network logout          
       
   846             iCommandHandler.HandleCommandL(ELogoutService, this, &iServiceId);
       
   847             break;
       
   848             } 
       
   849 
       
   850         case ECmdContactDetails:        
       
   851             {
       
   852             TInt index = KErrNotFound;                        
       
   853             if (iContainer)
       
   854                 {				
       
   855                 index = iContainer->CurrentItemIndex(); 
       
   856                 }
       
   857             if(KErrNotFound != index)
       
   858                 {
       
   859                 TLaunchCCAData data;
       
   860                 data.iIndex = index;
       
   861                 iConnection = TCCAFactory::NewConnectionL();
       
   862                 data.iConnection = iConnection;
       
   863                 iCommandHandler.HandleCommandL(ELaunchCCA, this, &data );
       
   864                 }
       
   865             break;
       
   866             }
       
   867         case ECmdOpenConversation:
       
   868             {
       
   869             if( iContainer )
       
   870                 {
       
   871                 iContainer->SendMessageL();
       
   872                 }
       
   873 
       
   874             break;
       
   875             }
       
   876 
       
   877         case ECmdAddContact:
       
   878             {
       
   879             AddContactL( R_IM_ADD_CONTACT_MANUAL_QUERY );
       
   880             break;
       
   881             }
       
   882 
       
   883         case ECmdContactEdit:
       
   884             { 
       
   885             EditContactL();           
       
   886             break;
       
   887             }
       
   888         case ECmdContactDelete:        
       
   889             {
       
   890             if( iContainer )
       
   891                 {
       
   892                 iContainer->SetClrFindPaneFlag(EFalse);
       
   893                 }
       
   894             DeleteContactL();
       
   895             break;
       
   896             }
       
   897         case ECmdChangeStatus:
       
   898             {
       
   899             ChangeStatusProcessL();
       
   900             break;
       
   901             } 
       
   902         case ECmdCancelLogin:
       
   903             {
       
   904             iCommandHandler.HandleCommandL( ECancelLogin , this , NULL );
       
   905             break;
       
   906             }                     
       
   907 
       
   908         case ECmdOpenFriendRequest:
       
   909             {
       
   910             ProcessFriendRequestL();
       
   911             break;
       
   912             }
       
   913 
       
   914         case ECmdAvatarGallery:
       
   915         case ECmdAvatarNewPhoto:     
       
   916             {
       
   917             CAvatarSelectionHandler* avatarHandler = CAvatarSelectionHandler::NewLC();
       
   918             HBufC* avatarFile = avatarHandler->HandleAvatarSelectionL( aCommand );
       
   919             if( avatarFile ) // if user selected the image 
       
   920                 {
       
   921                 CleanupStack::PushL( avatarFile ); 
       
   922                 if(iWaitNote)
       
   923 	                {
       
   924 	                delete iWaitNote;
       
   925 	                iWaitNote = NULL;	
       
   926 	                }
       
   927                 iWaitNote = CVIMPSTUtilsWaitNote::ShowWaitNoteL( R_QTN_SERVTAB_CHANGE_AVATAR_CHANGING, EFalse , ETrue );
       
   928                 ChangeOwnAvatarL( *avatarFile , avatarHandler->MimeTypeL() );
       
   929                 CleanupStack::PopAndDestroy(); //avatarFile
       
   930                 }
       
   931 	        CleanupStack::PopAndDestroy(); // avatarHandler
       
   932             break;
       
   933             }
       
   934        case ECmdDefaultAvatar:
       
   935             {
       
   936             ChangeOwnAvatarL( KNullDesC , KNullDesC8 );
       
   937             break;
       
   938             }        
       
   939 
       
   940         case ECmdCloseConversation:
       
   941             {
       
   942             CloseConversationL();
       
   943             break;
       
   944             }
       
   945     	case ECmdChangeConnectioninWaitingState:
       
   946 		case ECmdChangeConnectioninOnlineState:
       
   947 			{
       
   948 			iEngine.ChangeConnectionL();
       
   949 			break;	
       
   950 			}
       
   951 		case ECmdBlock:        
       
   952             {
       
   953             if( iContainer )
       
   954                 {
       
   955                 iContainer->SetClrFindPaneFlag(EFalse);
       
   956                 }
       
   957             BlockContactL(ETrue);
       
   958             break;
       
   959             }
       
   960 		case ECmdUnBlock:        
       
   961             {
       
   962             if( iContainer )
       
   963                 {
       
   964                 iContainer->SetClrFindPaneFlag(EFalse);
       
   965                 }
       
   966             BlockContactL();
       
   967             break;
       
   968             }
       
   969         case ECmdGetBlockedList:
       
   970 	        {
       
   971 			ShowBlockedContactListL();
       
   972 			break;
       
   973 	        }
       
   974         case ECmdAIWAddToContact:
       
   975        	case ECmdAIWLinkToContact:
       
   976         	{
       
   977             CreateOrLinkToPhoneBookL(aCommand);
       
   978            	break;	
       
   979         	}
       
   980        	case ECmdContactAddAsFriend:
       
   981        	    {
       
   982        	    TInt index = KErrNotFound;                        
       
   983        	    if (iContainer)
       
   984        	        {               
       
   985        	        index = iContainer->CurrentItemIndex(); 
       
   986        	        }
       
   987        	    MVIMPSTProcessArray& arrayprocess = iCommandHandler.GetProcessInterface();
       
   988        	    TVIMPSTEnums::TItem itemType = arrayprocess.GetType( index );
       
   989        	    if( itemType ==  TVIMPSTEnums::EUnknonContactItem ) 
       
   990        	        {
       
   991        	        TPtrC userId = arrayprocess.GetItemUserId( index );
       
   992        	        AddContactL( R_IM_ADD_CONTACT_MANUAL_QUERY , userId );
       
   993        	        }
       
   994        	    break;
       
   995        	    }
       
   996 			       	case EAknCmdHideInBackground:
       
   997        	    {
       
   998        	    //in case of EAknCmdHideInBackground phonebook be in 
       
   999        	    //background and all the child application should close
       
  1000 
       
  1001        	    if(iConnection)//  close connection to close cca
       
  1002        	        {
       
  1003        	        iConnection->Close();
       
  1004        	        iConnection = NULL;
       
  1005        	        }
       
  1006        	    if (iServiceHandler)//reset selectionhandler so that it closes all the phonebook forms if open
       
  1007        	        {
       
  1008        	        iServiceHandler->Reset();
       
  1009        	        iIsServiceHandleReSet = ETrue;
       
  1010        	        }
       
  1011        	    
       
  1012             Pbk2AppUi()->HandleCommandL( aCommand );
       
  1013 
       
  1014        	    break;
       
  1015        	    }
       
  1016         default:
       
  1017             {
       
  1018             Pbk2AppUi()->HandleCommandL( aCommand );
       
  1019             break;
       
  1020             }
       
  1021         }
       
  1022     }
       
  1023 
       
  1024 
       
  1025 
       
  1026 // --------------------------------------------------------------------------
       
  1027 // CVIMPSTUiTabbedView::DoActivateViewL
       
  1028 // --------------------------------------------------------------------------
       
  1029 //
       
  1030 void CVIMPSTUiTabbedView::DoActivateViewL( const TVwsViewId& aPrevViewId,
       
  1031         TUid /*aCustomMessageId*/,
       
  1032         const TDesC8& aCustomMessage)
       
  1033     {	
       
  1034     // When ST is launched from widget or universal indicator plugin
       
  1035     // user clicks twice continuously, then DoActivateL is called
       
  1036     // twice, as iContainer is NULL since construction is not complete
       
  1037     // then it creates two controls (containers), hence to avoid this
       
  1038     // situation, we are checking if construction of iContainer has 
       
  1039     // started, then we ignore DoActivateL second time.  
       
  1040     MPbk2ViewActivationTransaction* viewActivationTransaction =
       
  1041     Pbk2AppUi()->Pbk2ViewExplorer()->HandleViewActivationLC(
       
  1042             iView.Id(),
       
  1043             aPrevViewId,
       
  1044             &iEngine.ServiceName(),
       
  1045             NULL,
       
  1046             EUpdateAll );
       
  1047 
       
  1048     // Notifies startup monitor of view activation
       
  1049     if( Pbk2AppUi()->Pbk2StartupMonitor() )
       
  1050         {
       
  1051         Pbk2AppUi()->Pbk2StartupMonitor()->
       
  1052         NotifyViewActivationL( iView.Id() );
       
  1053         }
       
  1054     
       
  1055     iView.Cba()->SetCommandSetL( R_IM_CONTACTS_TABBED_VIEW_SOFTKEYS );
       
  1056 	
       
  1057 	ReadAndSetOwnUserIdL();
       
  1058 
       
  1059     if (!iContainer&& !iContainerCreationStarted)
       
  1060         {
       
  1061         iContainerCreationStarted = ETrue;
       
  1062         iContainer = MVIMPSTUiTabbedViewControlFactory::NewTabControlL(*this,
       
  1063                 &iView,iCommandHandler, iServiceId,
       
  1064                 *iBrandHandler, iEngine);
       
  1065         // take the control pointer
       
  1066         CCoeControl* cCoeControl = iContainer->CoeControl();
       
  1067         iAppUi->AddToStackL( iView, cCoeControl );
       
  1068         cCoeControl->SetMopParent( &iView );        
       
  1069         cCoeControl->SetRect( iView.ClientRect() ); 
       
  1070         cCoeControl->ActivateL();
       
  1071         } 
       
  1072      iStatusPaneHandler->SetTextL( iEngine.ServiceName() );
       
  1073     // Commit application-wide state changes
       
  1074     viewActivationTransaction->Commit();
       
  1075     CleanupStack::PopAndDestroy(); //viewActivationTransaction    
       
  1076     
       
  1077     //CreateToolBarL();
       
  1078     
       
  1079     if(TVIMPSTEnums::ESVCERegistered  == iEngine.ServiceState())
       
  1080         {
       
  1081         if(iIsToolBarHidden)
       
  1082             {
       
  1083             ShowHideFixedToolbarL(ETrue);
       
  1084             }
       
  1085         }
       
  1086     else
       
  1087         {
       
  1088         if(!iIsToolBarHidden)
       
  1089             {
       
  1090             ShowHideFixedToolbarL(EFalse);
       
  1091             }
       
  1092         }
       
  1093     
       
  1094     if(iContainer && iFocussedIDHistory )
       
  1095         {
       
  1096         iContainer->SetFocussedId( iFocussedIDHistory->Des() );
       
  1097         } 
       
  1098     
       
  1099     /*
       
  1100      * aCustomMessage has following format if it is coming from Service Widget
       
  1101      * when you click on widget 
       
  1102      * we need to unpack data in similar format 
       
  1103      * version number --> stream.WriteInt8L(1);
       
  1104      * EEnd --> stream.WriteInt8L( 0 );
       
  1105      * Service Id --> stream.WriteInt32L( iServiceId );
       
  1106      * 
       
  1107      * If function call is coming from other than service widget then 
       
  1108      * aCustomMessage will not have data in above format
       
  1109      */
       
  1110     
       
  1111     if(aCustomMessage.Length())
       
  1112         {        
       
  1113         RDesReadStream stream( aCustomMessage);
       
  1114         stream.PushL();
       
  1115         TInt serviceId = KErrNotFound;
       
  1116         TRAP_IGNORE( const TUint versionNumber = stream.ReadUint8L(); //equal to 1
       
  1117         TInt type = stream.ReadInt8L(); // equal to eend
       
  1118         serviceId = stream.ReadInt32L(); );
       
  1119         CleanupStack::PopAndDestroy();//stream
       
  1120         if( serviceId ==  iServiceId  )
       
  1121             {
       
  1122             // this case will get excuted only when there is 
       
  1123             // fresh login from service widget for first time only
       
  1124             // uid has been taken for autologin 
       
  1125             // if the service id is matches to aCustomMessage 
       
  1126             // it is auto login ,called from service widget
       
  1127             // start the login procedure            
       
  1128             LoginL();            
       
  1129             }       
       
  1130         }
       
  1131     UpdateToolbarL();	
       
  1132     }
       
  1133 
       
  1134 // --------------------------------------------------------------------------
       
  1135 // CVIMPSTUiTabbedView::DoDeactivate
       
  1136 // --------------------------------------------------------------------------
       
  1137 //
       
  1138 void CVIMPSTUiTabbedView::DoDeactivate()
       
  1139     {
       
  1140 
       
  1141     if(iFixedToolbar)
       
  1142         {
       
  1143         iIsToolBarHidden = ETrue;
       
  1144         delete iFixedToolbar;
       
  1145         iFixedToolbar = NULL;
       
  1146         }   
       
  1147     
       
  1148     if (iContainer)
       
  1149         {   
       
  1150         delete iFocussedIDHistory;
       
  1151     	iFocussedIDHistory = NULL;
       
  1152         TRAP_IGNORE( iFocussedIDHistory = iContainer->GetFocussedId().AllocL() );
       
  1153         iAppUi->RemoveFromStack( iContainer->CoeControl() );
       
  1154         delete iContainer;
       
  1155         iContainer = NULL;
       
  1156         iContainerCreationStarted = EFalse;
       
  1157         }
       
  1158     }
       
  1159 
       
  1160 // --------------------------------------------------------------------------
       
  1161 // CVIMPSTUiTabbedView::HandleForegroundEventL
       
  1162 // --------------------------------------------------------------------------
       
  1163 // 
       
  1164 TAny* CVIMPSTUiTabbedView::UIExtensionViewExtension(
       
  1165                 TUid aExtensionUid )
       
  1166     {
       
  1167     if (aExtensionUid == KMPbk2UIExtensionView2Uid)
       
  1168         {
       
  1169         return static_cast<MPbk2UIExtensionView2*>(this);
       
  1170         }
       
  1171     return NULL;
       
  1172     }
       
  1173 // --------------------------------------------------------------------------
       
  1174 // CVIMPSTUiTabbedView::HandleForegroundEventL
       
  1175 // --------------------------------------------------------------------------
       
  1176 //
       
  1177  
       
  1178  void CVIMPSTUiTabbedView::HandleForegroundEventL(TBool aForeground)
       
  1179 	 {
       
  1180 	 if( aForeground && TVIMPSTEnums::ESVCENotRegistered == iEngine.ServiceState() )
       
  1181 		 {
       
  1182 		 // user might has changed the setting read the new and refresh the view
       
  1183 		 // user can change setting in offline only
       
  1184 		 ReadAndSetOwnUserIdL();	
       
  1185 		 }
       
  1186 	 }
       
  1187 
       
  1188 // --------------------------------------------------------------------------
       
  1189 // CVIMPSTUiTabbedView::HandleCommandKeyL
       
  1190 // --------------------------------------------------------------------------
       
  1191 //
       
  1192 TBool CVIMPSTUiTabbedView::HandleCommandKeyL(const TKeyEvent& aKeyEvent, TEventCode /*aType*/)
       
  1193     {
       
  1194     TBool result = EFalse;
       
  1195     switch (aKeyEvent.iCode)
       
  1196         {        
       
  1197         default:
       
  1198             {
       
  1199             break;
       
  1200             }
       
  1201         }
       
  1202     return result;
       
  1203     }
       
  1204 
       
  1205 // --------------------------------------------------------------------------
       
  1206 // CVIMPSTUiTabbedView::HandleStatusPaneSizeChange
       
  1207 // --------------------------------------------------------------------------
       
  1208 //
       
  1209 void CVIMPSTUiTabbedView::HandleStatusPaneSizeChange()
       
  1210     {
       
  1211     // Resize the container to fill the client rectangle
       
  1212     if (iContainer)
       
  1213         {
       
  1214         iContainer->CoeControl()->SetRect( iView.ClientRect() );         
       
  1215         }
       
  1216     }    
       
  1217 
       
  1218 // --------------------------------------------------------------------------
       
  1219 // CVIMPSTUiTabbedView::CommandHandlerL
       
  1220 // --------------------------------------------------------------------------
       
  1221 //
       
  1222 MVIMPSTCmdHandler& CVIMPSTUiTabbedView::CommandHandlerL()
       
  1223     {    
       
  1224     return iCommandHandler;
       
  1225     }
       
  1226 
       
  1227 
       
  1228 // --------------------------------------------------------------------------
       
  1229 // CVIMPSTUiTabbedView::CommandFinishedL
       
  1230 // --------------------------------------------------------------------------
       
  1231 //
       
  1232 
       
  1233 void CVIMPSTUiTabbedView::CommandFinishedL(
       
  1234         const MVIMPSTCmd& aCommand )
       
  1235     {
       
  1236 
       
  1237     //handle the observer for commands issues thro HandleCommandL()
       
  1238 
       
  1239     switch (aCommand.CommandId())
       
  1240         {
       
  1241         case ELoginService:
       
  1242             {
       
  1243             //login command is complete
       
  1244             //use aCommand.Result() to get the data     
       
  1245             //Ownership is not given to the caller            
       
  1246             break;
       
  1247             }
       
  1248         case ELogoutService:
       
  1249             {
       
  1250             //logout command is complete
       
  1251             //use aCommand.Result() to get the data 
       
  1252             //Ownership is not given to the caller               
       
  1253             break;
       
  1254             } 
       
  1255         case ECmdProcessAcceptedContactNew: // accept create new 
       
  1256         case ECmdProcessAcceptedContactExist: // update existing
       
  1257         case ECmdProcessSelectedContactNew: 
       
  1258         case ECmdProcessSelectedContactExist:// add from phonebook
       
  1259         case EAddContact:
       
  1260             {
       
  1261             //addcontact command is complete
       
  1262             //use aCommand.Result() to get the data 
       
  1263             //Ownership is not given to the caller
       
  1264             //some error occured.
       
  1265             if (iWaitNote)
       
  1266                 {
       
  1267                 delete iWaitNote;
       
  1268                 iWaitNote = NULL;   
       
  1269                 }
       
  1270             if(aCommand.Result() != KErrNone) 
       
  1271                 {
       
  1272                 ShowErrorNoteL( aCommand.Result() );
       
  1273                 }
       
  1274             break;
       
  1275             } 
       
  1276         case EDeleteContact:
       
  1277             {
       
  1278             //addcontact command is complete
       
  1279             //use aCommand.Result() to get the data 
       
  1280             //Ownership is not given to the caller  
       
  1281             //some error occured.
       
  1282             if (iWaitNote)
       
  1283                 {
       
  1284                 delete iWaitNote;
       
  1285                 iWaitNote = NULL;   
       
  1286                 }
       
  1287             if(aCommand.Result() != KErrNone) 
       
  1288                 {
       
  1289                 HBufC* prompt = NULL;
       
  1290                 prompt = StringLoader::LoadLC( R_IM_ERROR_SERVICE_ERR  );
       
  1291                 TInt ret( VIMPSTUtilsDialog::DisplayErrorNoteL( *prompt ) );
       
  1292                 CleanupStack::PopAndDestroy(prompt);
       
  1293                 }
       
  1294             break;
       
  1295             } 
       
  1296         case EChangeOwnStatus: 
       
  1297             {
       
  1298             TInt error = aCommand.Result();
       
  1299             if( KErrNone == error )
       
  1300                 {
       
  1301                 // show confirmation note
       
  1302                 HBufC* text = CEikonEnv::Static()->AllocReadResourceLC( R_QTN_CHAT_CHANGE_STATUS_CHANGED );
       
  1303                 CAknConfirmationNote* dlg = new( ELeave )CAknConfirmationNote();
       
  1304                 dlg->ExecuteLD( *text );
       
  1305                 CleanupStack::PopAndDestroy( text );
       
  1306                 //get the status from the engine and update in the ui.
       
  1307                 if(iContainer)
       
  1308                     {
       
  1309                     iContainer->HandleItemAdditionL();
       
  1310                     }
       
  1311 
       
  1312                 }
       
  1313             else if( KErrCancel == error )
       
  1314                 {
       
  1315                 // user cancelled, status was not updated
       
  1316                 HBufC* text = NULL;
       
  1317                 text = StringLoader::LoadLC( R_QTN_IM_CHANGE_STATUS_NOT_CHANGED );
       
  1318                 VIMPSTUtilsDialog::DisplayNoteDialogL( *text  );
       
  1319                 CleanupStack::PopAndDestroy(); //onlineText
       
  1320                 }
       
  1321             else
       
  1322                 {
       
  1323                 // change status failed
       
  1324                 HBufC* failed = StringLoader::LoadLC( R_QTN_CHAT_CHANGE_STATUS_FAILED );
       
  1325                 VIMPSTUtilsDialog::DisplayErrorNoteL( *failed );
       
  1326                 CleanupStack::PopAndDestroy( failed );
       
  1327                 }
       
  1328             break;
       
  1329             }
       
  1330         case EChangeOwnMessage:
       
  1331             {
       
  1332             TInt error = aCommand.Result();
       
  1333             if( KErrNone == error )
       
  1334                 {
       
  1335                 // show note qtn_chat_change_message_changing
       
  1336                 HBufC* prompt = NULL;
       
  1337                 prompt = StringLoader::LoadLC( R_QTN_CHAT_CHANGE_MESSAGE_CHANGED );
       
  1338                 VIMPSTUtilsDialog::DisplayNoteDialogL( *prompt);
       
  1339                 CleanupStack::PopAndDestroy(prompt);
       
  1340                 }
       
  1341             else if( KErrCancel == error)
       
  1342                 {
       
  1343                 HBufC* prompt = NULL;
       
  1344                 prompt = StringLoader::LoadLC( R_QTN_IM_CHANGE_STATUS_NOT_CHANGED );
       
  1345                 VIMPSTUtilsDialog::DisplayNoteDialogL( *prompt);
       
  1346                 CleanupStack::PopAndDestroy(prompt);
       
  1347                 }
       
  1348             else
       
  1349                 {
       
  1350                 HBufC* prompt = NULL;
       
  1351                 prompt = StringLoader::LoadLC( R_QTN_CHAT_CHANGE_MESSAGE_FAILED );
       
  1352                 VIMPSTUtilsDialog::DisplayNoteDialogL(*prompt );
       
  1353                 CleanupStack::PopAndDestroy(prompt);
       
  1354                 }
       
  1355 
       
  1356             break;
       
  1357             }
       
  1358         case ESearch:
       
  1359             {
       
  1360             // Search command is complete
       
  1361             //use aCommand.Result() to get the data 
       
  1362             if(iWaitNote)
       
  1363                 {
       
  1364                 delete iWaitNote;
       
  1365                 iWaitNote = NULL;	
       
  1366                 }
       
  1367             if(aCommand.Result() != KErrNone) 
       
  1368                 {
       
  1369                 HBufC* prompt = NULL;
       
  1370                 prompt = StringLoader::LoadLC(R_QTN_CHAT_ERROR_NOT_SUP_FUNCTIONS );
       
  1371                 VIMPSTUtilsDialog::DisplayErrorNoteL( *prompt ) ;
       
  1372                 CleanupStack::PopAndDestroy(prompt);
       
  1373                 LaunchViewL(iExtensionService.TabbedViewId());
       
  1374                 } 
       
  1375             }
       
  1376         case EFriendRejected:
       
  1377         case EFriendAccpeted:
       
  1378             {
       
  1379             if(iWaitNote)
       
  1380           	     {
       
  1381           	     delete iWaitNote;
       
  1382           	     iWaitNote = NULL;   
       
  1383           	     }
       
  1384 		    if( ( aCommand.Result() != KErrNone ) && ( aCommand.CommandId() == EFriendAccpeted  ) ) 
       
  1385                 {
       
  1386                 HBufC* prompt = StringLoader::LoadLC( R_QTN_SERVTAB_SAVING_CONTACT_FAILED );
       
  1387                 VIMPSTUtilsDialog::DisplayErrorNoteL( *prompt ) ;
       
  1388                 CleanupStack::PopAndDestroy(prompt);
       
  1389                 } 
       
  1390             break;
       
  1391             }
       
  1392         case EChangeOwnAvtar:
       
  1393             {
       
  1394             if(aCommand.Result() == KErrNone)  // successfull show confirmation note
       
  1395                 {
       
  1396                 if(iWaitNote)
       
  1397                     {
       
  1398                     delete iWaitNote;
       
  1399                     iWaitNote = NULL;   
       
  1400                     }
       
  1401                 } 
       
  1402             else  // show error note
       
  1403                 {
       
  1404                 HBufC* prompt  = StringLoader::LoadLC( R_QTN_SERVTAB_ERROR_UPDATE_AVATAR );
       
  1405                 VIMPSTUtilsDialog::DisplayErrorNoteL( *prompt ) ;
       
  1406                 CleanupStack::PopAndDestroy(prompt);
       
  1407                 }
       
  1408             break;
       
  1409             }
       
  1410         case ECmdBlockContact:
       
  1411            {
       
  1412            //blockcontact command is complete
       
  1413            //use aCommand.Result() to get the data 
       
  1414            //Ownership is not given to the caller  
       
  1415            //some error occured.
       
  1416            if(iWaitNote)
       
  1417                {
       
  1418                delete iWaitNote;
       
  1419                iWaitNote = NULL;   
       
  1420                }
       
  1421            if(aCommand.Result() != KErrNone) 
       
  1422                {
       
  1423                HBufC* prompt = NULL;
       
  1424                prompt = StringLoader::LoadLC( R_QTN_CHAT_BLOCKING_FAILED  );
       
  1425                TInt ret( VIMPSTUtilsDialog::DisplayErrorNoteL( *prompt ) );
       
  1426                CleanupStack::PopAndDestroy(prompt);
       
  1427                }
       
  1428            break;
       
  1429            } 
       
  1430         case ECmdUnBlockContact:
       
  1431            {
       
  1432            if(iWaitNote)
       
  1433                {
       
  1434                delete iWaitNote;
       
  1435                iWaitNote = NULL;   
       
  1436                }
       
  1437            //unblockcontact command is complete
       
  1438            //use aCommand.Result() to get the data 
       
  1439            //Ownership is not given to the caller  
       
  1440            //some error occured.
       
  1441            if(aCommand.Result() != KErrNone) 
       
  1442                {
       
  1443                HBufC* prompt = NULL;
       
  1444                prompt = StringLoader::LoadLC( R_QTN_CHAT_UNBLOCKING_FAILED  );
       
  1445                TInt ret( VIMPSTUtilsDialog::DisplayErrorNoteL( *prompt ) );
       
  1446                CleanupStack::PopAndDestroy(prompt);
       
  1447                }
       
  1448            break;
       
  1449            } 
       
  1450         default:
       
  1451             { 
       
  1452             //should never be here.           
       
  1453             break;
       
  1454             }
       
  1455         }
       
  1456     }
       
  1457     
       
  1458 // --------------------------------------------------------------------------
       
  1459 // CVIMPSTUiTabbedView::ShowErrorNoteL
       
  1460 // --------------------------------------------------------------------------
       
  1461 void CVIMPSTUiTabbedView::ShowErrorNoteL(TInt aError )
       
  1462 	{
       
  1463 	HBufC* textResource = NULL;
       
  1464 	switch( aError)
       
  1465 		{
       
  1466 		case EErrExistInBlockList:
       
  1467 			{
       
  1468 			textResource = StringLoader::LoadLC( R_QTN_SERVTAB_ADD_FRIEND_BLOCKED);
       
  1469 			break;	
       
  1470 			}
       
  1471 		case KErrAlreadyExists :
       
  1472 		case EErrExistInContactList:
       
  1473 			{
       
  1474 			textResource = StringLoader::LoadLC( R_QTN_SERTAB_CONTACT_ALREADY_EXISTS_ERROR_NOTE);
       
  1475 			break;	
       
  1476 			}
       
  1477 		default :
       
  1478 			{
       
  1479 			textResource = StringLoader::LoadLC( R_QTN_SERVTAB_SAVING_CONTACT_FAILED );
       
  1480 			break;	
       
  1481 			}
       
  1482 		}
       
  1483 	if( textResource )
       
  1484 		{
       
  1485 		CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
       
  1486 		note->ExecuteLD( *textResource );
       
  1487 		CleanupStack::PopAndDestroy( textResource );
       
  1488 		}
       
  1489 	}
       
  1490     
       
  1491 // --------------------------------------------------------------------------
       
  1492 // CVIMPSTUiTabbedView::HandleCommandEventL
       
  1493 // --------------------------------------------------------------------------
       
  1494 //
       
  1495 void CVIMPSTUiTabbedView::HandleCommandEventL(TVIMPSTEnums::TVIMPSTRegistrationState aState, TInt /*aServiceError*/) 
       
  1496     {    
       
  1497     switch (aState)	
       
  1498         {
       
  1499         case TVIMPSTEnums::ESVCERegistered:
       
  1500             {
       
  1501             // this is to make sure that it always has the user id
       
  1502             // some services they do not have the user id in offline case
       
  1503             // like skype ,get the user if service is logged in
       
  1504             if( !iUserId || iUserId->Length() == 0 )
       
  1505 	            {
       
  1506 	            // read if user id is empty only
       
  1507 	            ReadAndSetOwnUserIdL();	
       
  1508 	            }
       
  1509             TInt isSuccessfulLogin = 0;
       
  1510             iSettingsStore->GetL(iServiceId, EServiceSuccessfullLogin, isSuccessfulLogin);
       
  1511             if(!isSuccessfulLogin)
       
  1512                 {
       
  1513                 isSuccessfulLogin = 1;
       
  1514                 iSettingsStore->SetL(iServiceId, EServiceSuccessfullLogin, isSuccessfulLogin);
       
  1515                 }
       
  1516             if(iIsToolBarHidden)
       
  1517                 {
       
  1518                 ShowHideFixedToolbarL(ETrue);
       
  1519                 }
       
  1520             break;
       
  1521             }
       
  1522         case TVIMPSTEnums::ESVCENotRegistered:
       
  1523             {
       
  1524              // might user has choosen some diff user id while login
       
  1525             // set to store and engine etc
       
  1526             ReadAndSetOwnUserIdL();
       
  1527         	
       
  1528 		 	// no need to hide the tool bar here as its already called while in the 
       
  1529 		 	// disconnecting state.
       
  1530 		 	// assume in some cornere scenario, where network is lost, and the ui does not 
       
  1531 		 	// get a callback for disconnecting state then we need to call hidetoolbar in this case.
       
  1532 		 	// hence the flag iIsToolBarHidden will set it when ever the tool bar is hidden 
       
  1533 		 	if(!iIsToolBarHidden)
       
  1534 		 	    {
       
  1535 		 	    ShowHideFixedToolbarL(EFalse);
       
  1536 		 	    }
       
  1537             break;	
       
  1538             }
       
  1539         case TVIMPSTEnums::ESVCENetworkConnecting:
       
  1540             {
       
  1541             // might user has choosen some diff user id while login
       
  1542             // set to store and engine etc
       
  1543             ReadAndSetOwnUserIdL();
       
  1544             break;
       
  1545             }
       
  1546         case TVIMPSTEnums::ESVCEWaitingForNetwork:
       
  1547             {
       
  1548             break;
       
  1549             }
       
  1550         case TVIMPSTEnums::ESVCENetworkDisConnecting:
       
  1551             {
       
  1552             if(!iIsToolBarHidden)
       
  1553                 {
       
  1554                 ShowHideFixedToolbarL(EFalse);
       
  1555                 }
       
  1556             break;
       
  1557             }
       
  1558         case TVIMPSTEnums::ESVCEUpdatingContacts:
       
  1559             {
       
  1560             // might user has choosen some diff user id while login
       
  1561             // set to store and engine etc 
       
  1562             // this is to make sure that it always has the user id
       
  1563             // some services they do not have the user id in offline case
       
  1564             // like skype ,get the user if service is logged in
       
  1565             if( !iUserId || iUserId->Length() == 0 )
       
  1566 	            {
       
  1567 	            // read if user id is empty only
       
  1568 	            ReadAndSetOwnUserIdL();	
       
  1569 	            }
       
  1570             break;
       
  1571             }	
       
  1572         default:
       
  1573             {
       
  1574             //should never be here.
       
  1575             break;
       
  1576             }
       
  1577 
       
  1578         }
       
  1579     if(iContainer)
       
  1580         {
       
  1581         iContainer->HandleItemAdditionL();        
       
  1582         }
       
  1583 
       
  1584     }
       
  1585 
       
  1586 // --------------------------------------------------------------------------
       
  1587 // CVIMPSTUiTabbedView::CurrentItemIndex
       
  1588 // --------------------------------------------------------------------------
       
  1589 //
       
  1590 TInt CVIMPSTUiTabbedView:: CurrentItemIndex()
       
  1591     {
       
  1592     TInt index = KErrNone;
       
  1593     iContainer?(index = iContainer->CurrentItemIndex()):(index = KErrNotFound);
       
  1594     return index;
       
  1595     }
       
  1596 
       
  1597 
       
  1598 // --------------------------------------------------------------------------
       
  1599 // CVIMPSTUiTabbedView::ReadAndSetOwnUserIdL()
       
  1600 // --------------------------------------------------------------------------
       
  1601 //
       
  1602 void CVIMPSTUiTabbedView::ReadAndSetOwnUserIdL()
       
  1603     {
       
  1604     if( iUserId )
       
  1605 		{
       
  1606 		delete iUserId;	
       
  1607 		iUserId = NULL;
       
  1608 		}
       
  1609  	iUserId = iEngine.GetOwnUserIdFromCChOrStorageL();
       
  1610  	iEngine.SetOwnUserIdIfChangedL( *iUserId );
       
  1611     }
       
  1612 // --------------------------------------------------------------------------
       
  1613 // CVIMPSTUiTabbedView::AddContactL
       
  1614 // --------------------------------------------------------------------------
       
  1615 //
       
  1616 void CVIMPSTUiTabbedView::AddContactL( const TInt aResouceId, const TDesC& aUserId )
       
  1617     {
       
  1618     MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);    
       
  1619     if (storage)
       
  1620         {
       
  1621         if (!storage->IsLocalStore())
       
  1622             {
       
  1623             HBufC* userid = HBufC::NewL(KUsernameMaxLength);
       
  1624     		CleanupStack::PushL( userid );
       
  1625     		TPtr useridPtr( userid->Des() );
       
  1626 			
       
  1627             useridPtr.Copy( aUserId.Left( KUsernameMaxLength ) );
       
  1628             TInt result = 0;
       
  1629             if( useridPtr == KNullDesC )
       
  1630                 {
       
  1631                 CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( useridPtr, CAknQueryDialog::ENoTone );
       
  1632                 dlg->SetPredictiveTextInputPermitted( ETrue ); // T9
       
  1633                 result = dlg->ExecuteLD( aResouceId );
       
  1634                 }
       
  1635             if( ( result == EAknSoftkeyOk ) || ( result == EAknSoftkeyYes )  || ( useridPtr != KNullDesC ) )
       
  1636                 {
       
  1637                 TPtrC ownUserId = storage->OwnContactL().UserId();
       
  1638                 if(useridPtr.Compare( ownUserId ) == 0) //Do not add own data item to contact list
       
  1639                     {
       
  1640                     //show note "Own Data Item cannot be added"
       
  1641                     HBufC* failed = StringLoader::LoadLC( R_QTN_SERVTAB_ERROR_ADDOWN );
       
  1642                     VIMPSTUtilsDialog::DisplayErrorNoteL( *failed );
       
  1643                     CleanupStack::PopAndDestroy( failed );
       
  1644                     }
       
  1645                 else
       
  1646                     {
       
  1647                     CVIMPSTUtilsWaitNote* note = CVIMPSTUtilsWaitNote::ShowWaitNoteLC( R_QTN_SERVTAB_SAVING_CONTACT ,ETrue);
       
  1648                     iCommandHandler.HandleCommandL(EAddContact, this, userid ); 
       
  1649                     CleanupStack::PopAndDestroy( note );
       
  1650                     }
       
  1651              	}
       
  1652 		    CleanupStack::PopAndDestroy(userid);
       
  1653             }
       
  1654     else // server store
       
  1655                
       
  1656         {
       
  1657                 ////////////////////////////////////////////
       
  1658                 ReInitializeServiceHandlerL();
       
  1659                 TUint assignFlags = 0;
       
  1660                 //for unknown item createnew/update existing querry is shown
       
  1661                 // check whether the selected contact is unknown
       
  1662                 if( iCommandHandler.GetProcessInterface().GetType(iContainer->CurrentItemIndex()) ==  TVIMPSTEnums::EUnknonContactItem ) 
       
  1663                     {
       
  1664                     iSelectedAction = ShowNewUpdateQueryL();
       
  1665                     if(CVIMPSTUiTabbedView::EInvitAcceptCreateNew == iSelectedAction )//create new 
       
  1666                         {
       
  1667                         assignFlags |= ECreateNewContact;
       
  1668                         iSelectedAction = EContactCreateNew;
       
  1669                         }
       
  1670                     else if(CVIMPSTUiTabbedView::EInvitAcceptUpdateExisting == iSelectedAction ) // update existing
       
  1671                         {
       
  1672                         iSelectedAction = EContactAddFromContacts;
       
  1673                         }
       
  1674                     else // selected cancle option
       
  1675                         {
       
  1676                         return;
       
  1677                         }
       
  1678                     }
       
  1679                 else // not unknown contact
       
  1680                     {
       
  1681                     iSelectedAction = EContactCreateNew;
       
  1682                     assignFlags |= ECreateNewContact;
       
  1683                     }
       
  1684                 //show the phonebook dialog for create new/update existing option
       
  1685     if(iAiwParamList)
       
  1686         {
       
  1687     delete iAiwParamList;
       
  1688     iAiwParamList = NULL;
       
  1689                 }        
       
  1690             iAiwParamList = CAiwGenericParamList::NewL();
       
  1691             iAiwParamList->AppendL(
       
  1692                     TAiwGenericParam(
       
  1693                             EGenericParamContactAssignData,
       
  1694                             TAiwVariant(TAiwSingleContactAssignDataV1Pckg(
       
  1695                                     TAiwSingleContactAssignDataV1().SetFlags( assignFlags )))));
       
  1696             
       
  1697             if( aUserId.Length() > 0 )
       
  1698                 {
       
  1699                 // add user id in impp field
       
  1700                 TBuf<KBufLen> xspId; //xsp max length
       
  1701                 xspId.Append(iEngine.ServiceName());
       
  1702                 xspId.Append(KColon);
       
  1703                 xspId.Append(aUserId);
       
  1704 
       
  1705                 iAiwParamList->AppendL(
       
  1706                         TAiwGenericParam(
       
  1707                                 EGenericParamXSpId,
       
  1708                                 TAiwVariant(xspId) ) );
       
  1709                 }
       
  1710             iServiceHandler->ExecuteServiceCmdL(
       
  1711                     KAiwCmdAssign,
       
  1712                     *iAiwParamList,
       
  1713                     iServiceHandler->OutParamListL(),
       
  1714                     0,
       
  1715                     this);
       
  1716             }
       
  1717         }
       
  1718     }
       
  1719 
       
  1720 // --------------------------------------------------------------------------
       
  1721 // CVIMPSTUiTabbedView::CreateOrLinkToPhoneBookL
       
  1722 // --------------------------------------------------------------------------
       
  1723 //
       
  1724 void CVIMPSTUiTabbedView::CreateOrLinkToPhoneBookL(TInt aCommand )
       
  1725 	{
       
  1726 	TInt index = CurrentItemIndex();
       
  1727 	if( index <= 0 )
       
  1728 		{
       
  1729 		return;
       
  1730 		}
       
  1731 	TUint assignFlags = 0;
       
  1732     if(ECmdAIWAddToContact == aCommand )//create new option
       
  1733         {
       
  1734         assignFlags |= ECreateNewContact;
       
  1735         }
       
  1736 	TPtrC itemUserId = iCommandHandler.GetProcessInterface().GetItemUserId(index) ;
       
  1737 	if(iAiwParamList)
       
  1738 		{
       
  1739 		delete iAiwParamList;
       
  1740 		iAiwParamList = NULL;
       
  1741 		}   
       
  1742 	iAiwParamList = CAiwGenericParamList::NewL();
       
  1743 	iAiwParamList->AppendL(
       
  1744 	TAiwGenericParam(
       
  1745 	EGenericParamContactAssignData,
       
  1746 	TAiwVariant(TAiwSingleContactAssignDataV1Pckg(
       
  1747 	TAiwSingleContactAssignDataV1().SetFlags( assignFlags )))));
       
  1748 
       
  1749 	TBuf<KBufLen> xspid;
       
  1750 	xspid.Append(iEngine.ServiceName());
       
  1751 	xspid.Append(KColon);
       
  1752 	xspid.Append(itemUserId);
       
  1753 	ReInitializeServiceHandlerL();
       
  1754 	iAiwParamList->AppendL(
       
  1755 						TAiwGenericParam(
       
  1756 						EGenericParamXSpId,
       
  1757 						TAiwVariant(xspid))  );
       
  1758 
       
  1759 	iServiceHandler->ExecuteServiceCmdL( KAiwCmdAssign,
       
  1760 					                     *iAiwParamList,
       
  1761 					                     iServiceHandler->OutParamListL(),
       
  1762 					                     0,
       
  1763 					                     this);
       
  1764 	}
       
  1765 
       
  1766 // --------------------------------------------------------------------------
       
  1767 // CVIMPSTUiTabbedView::EditContactL
       
  1768 // --------------------------------------------------------------------------
       
  1769 //
       
  1770 void CVIMPSTUiTabbedView::EditContactL()
       
  1771     {
       
  1772     MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId);    
       
  1773     if (storage)
       
  1774         {        
       
  1775         if( storage->IsLocalStore())
       
  1776             {
       
  1777             iSelectedAction = KErrNotFound;
       
  1778             TInt index = CurrentItemIndex();
       
  1779         	MVPbkContactLink* contactLink = iCommandHandler.GetProcessInterface().ContactLink(index);        	
       
  1780         	//show the phonebook dialog for edit existing data
       
  1781             if(iAiwParamList)
       
  1782                 {
       
  1783                 delete iAiwParamList;
       
  1784                 iAiwParamList = NULL;
       
  1785                 }        
       
  1786             iAiwParamList = CAiwGenericParamList::NewL();
       
  1787 			iAiwParamList->AppendL(
       
  1788                     TAiwGenericParam(
       
  1789                             EGenericParamContactAssignData,
       
  1790                             TAiwVariant(TAiwSingleContactAssignDataV1Pckg(
       
  1791                                     TAiwSingleContactAssignDataV1().SetFlags( EskipInfoNotes )))));
       
  1792 
       
  1793 			HBufC8* packedLinks = contactLink->PackLC();
       
  1794 		    iAiwParamList->AppendL(
       
  1795                     TAiwGenericParam(
       
  1796                             EGenericParamContactLinkArray,
       
  1797                             TAiwVariant(*packedLinks) ) );
       
  1798 		    ReInitializeServiceHandlerL();
       
  1799 
       
  1800             iServiceHandler->ExecuteServiceCmdL(
       
  1801                     KAiwCmdAssign,
       
  1802                     *iAiwParamList,
       
  1803                     iServiceHandler->OutParamListL(),
       
  1804                     0,
       
  1805                     this);
       
  1806 		    CleanupStack::PopAndDestroy(); // packedLinks
       
  1807             }
       
  1808        }
       
  1809     }
       
  1810 
       
  1811 
       
  1812 
       
  1813 
       
  1814 // --------------------------------------------------------------------------
       
  1815 // CVIMPSTUiTabbedView::AddContactL
       
  1816 // --------------------------------------------------------------------------
       
  1817 void CVIMPSTUiTabbedView::AddContactL(RPointerArray<HBufC> aContacts)
       
  1818     {
       
  1819     TInt count = aContacts.Count();
       
  1820 
       
  1821     switch( count )
       
  1822         {
       
  1823         case 0://no xsp found.
       
  1824             {
       
  1825             //launch add manually dialog.
       
  1826             AddContactL( R_IM_ADD_CONTACT_MANUAL_QUERY );//to do replace with some thing else.
       
  1827             break;
       
  1828             }
       
  1829         case 1://1 xsp foud.
       
  1830             {
       
  1831             //add new contact.
       
  1832             HBufC* xspId = aContacts[0];
       
  1833             AddContactL( R_IM_ADD_CONTACT_MANUAL_QUERY, *xspId );
       
  1834             break;
       
  1835             }
       
  1836         default :// > 1 xsp found.
       
  1837             {
       
  1838             //show single selection dialog
       
  1839             TInt selectionIndex = 0;
       
  1840             CDesCArray* xspIds = new( ELeave )CDesCArrayFlat( count );
       
  1841             CleanupStack::PushL( xspIds );
       
  1842 
       
  1843             //add all xsp(s) from aContacts to xspIds.
       
  1844             for( TInt i = 0 ; i < count ; i++ )
       
  1845                 {
       
  1846                 xspIds->AppendL( *aContacts[i] );
       
  1847                 }
       
  1848 
       
  1849             HBufC* titleText = StringLoader::LoadLC( R_QTN_SERVTAB_SELECT_USER );
       
  1850 
       
  1851             TInt ret = VIMPSTUtilsDialog::DisplayListQueryDialogL( &selectionIndex,
       
  1852                     xspIds,
       
  1853                     R_IM_LIST_SELECT_STATUS_MESSAGE_DLG,
       
  1854                     *titleText,
       
  1855                     KNullDesC,
       
  1856                     ETrue );
       
  1857             CleanupStack::PopAndDestroy( titleText );
       
  1858 
       
  1859 
       
  1860             if ( ret == EAknSoftkeyOk || ret == EAknSoftkeyDone || ret == EAknSoftkeySelect )
       
  1861                 {
       
  1862                 TPtrC selectedXspid = (*xspIds)[selectionIndex];
       
  1863                 AddContactL( R_IM_ADD_CONTACT_MANUAL_QUERY, selectedXspid );
       
  1864                 }
       
  1865             CleanupStack::PopAndDestroy(xspIds);
       
  1866             break;
       
  1867             }
       
  1868         }    
       
  1869     }
       
  1870 
       
  1871 // --------------------------------------------------------------------------
       
  1872 // CVIMPSTUiTabbedView::CopyToPhoneBookL
       
  1873 // --------------------------------------------------------------------------
       
  1874 //
       
  1875 void CVIMPSTUiTabbedView::CopyToPhoneBookL()
       
  1876     {
       
  1877     TInt index = CurrentItemIndex();
       
  1878 
       
  1879     TPtrC name( KNullDesC );
       
  1880     if( index <= 0 )
       
  1881         {
       
  1882         // return if item not found
       
  1883         return; 
       
  1884         }
       
  1885 
       
  1886     TPtrC seletctedItem = iCommandHandler.GetProcessInterface().GetItemUserId(index) ;
       
  1887 
       
  1888     MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL(iServiceId) ;
       
  1889     if(storage)
       
  1890         {
       
  1891         MVIMPSTStorageContact* contact = storage->FindContactByUserId(seletctedItem);
       
  1892         if(contact)
       
  1893             {
       
  1894             CVIMPSTUtilsWaitNote* note = CVIMPSTUtilsWaitNote::ShowWaitNoteLC( R_QTN_SERVTAB_SAVING_CONTACT ,ETrue);
       
  1895             iCommandHandler.HandleCommandL(EAddToPbk, this, contact );
       
  1896             CleanupStack::PopAndDestroy(note);
       
  1897             }
       
  1898         }
       
  1899     }
       
  1900 
       
  1901 // --------------------------------------------------------------------------
       
  1902 // CVIMPSTUiTabbedView::DeleteContactL
       
  1903 // --------------------------------------------------------------------------
       
  1904 //
       
  1905 void CVIMPSTUiTabbedView:: DeleteContactL()
       
  1906     {
       
  1907     TInt index = CurrentItemIndex();
       
  1908     HBufC* deletePrompt = NULL;
       
  1909     TPtrC name( KNullDesC );
       
  1910 
       
  1911     if(iContainer)
       
  1912         {
       
  1913         iContainer->CheckAndSetLastItemFlag();
       
  1914         }
       
  1915     if( index <= 0 )
       
  1916         {
       
  1917         // return if item not found
       
  1918         return;	
       
  1919         }
       
  1920 
       
  1921     TPtrC seletctedItem = iCommandHandler.GetProcessInterface().GetItemUserId(index) ;
       
  1922     name.Set( seletctedItem );
       
  1923 
       
  1924     deletePrompt = StringLoader::LoadLC( R_QTN_SERVTAB_DELETE_CONTACT, name, CCoeEnv::Static() );
       
  1925     TInt ret( VIMPSTUtilsDialog::DisplayQueryDialogL(R_GENERIC_YES_NO_CONFIRMATION_QUERY, *deletePrompt ) );
       
  1926     CleanupStack::PopAndDestroy( deletePrompt );
       
  1927 
       
  1928     MVPbkContactLink* contactLink = iCommandHandler.GetProcessInterface().ContactLink(index);
       
  1929 
       
  1930     if( ( ret == EAknSoftkeyOk ) || ( ret == EAknSoftkeyYes ) )
       
  1931         {
       
  1932         if(iWaitNote)
       
  1933             {
       
  1934             delete iWaitNote;
       
  1935             iWaitNote = NULL;
       
  1936             }
       
  1937         iWaitNote = CVIMPSTUtilsWaitNote::ShowWaitNoteL( R_QTN_CHAT_DELETING_CONTACT ,ETrue);
       
  1938         iCommandHandler.HandleCommandL(EDeleteContact, this, &contactLink );
       
  1939         }
       
  1940     }
       
  1941 
       
  1942 
       
  1943 
       
  1944 // -----------------------------------------------------------------------------
       
  1945 // CVIMPSTUiTabbedView::ChangeStatusProcessL
       
  1946 // (other items were commented in a header).
       
  1947 // -----------------------------------------------------------------------------
       
  1948 //
       
  1949 void CVIMPSTUiTabbedView::ChangeStatusProcessL()
       
  1950     {
       
  1951     if( iEngine.ServiceState() )
       
  1952         {
       
  1953         // Check variation
       
  1954         TInt showAppearOffline = 1;
       
  1955         TInt showAway = 1 ;   
       
  1956         TInt showBusy = 1;
       
  1957 
       
  1958         TInt awayIndex( 0 );
       
  1959         TInt busyIndex( 0 );
       
  1960         TInt appOfflineIndex( 0 );
       
  1961 
       
  1962         // first icon is online
       
  1963         // calculate indexes for other icons
       
  1964         if ( showAway)
       
  1965             {
       
  1966             awayIndex++;
       
  1967             busyIndex++;
       
  1968             appOfflineIndex++;
       
  1969             }
       
  1970         else
       
  1971             {
       
  1972             awayIndex = -1;
       
  1973             }
       
  1974 
       
  1975         if ( showBusy )
       
  1976             {
       
  1977             busyIndex++;
       
  1978             appOfflineIndex++;
       
  1979             }
       
  1980         else
       
  1981             {
       
  1982             busyIndex = -1;
       
  1983             }
       
  1984 
       
  1985         if ( showAppearOffline )
       
  1986             {
       
  1987             appOfflineIndex++;
       
  1988             }
       
  1989         else
       
  1990             {
       
  1991             appOfflineIndex = -1;
       
  1992             }
       
  1993 
       
  1994         TInt status( 0 );
       
  1995         CAknListQueryDialog* dlg = new ( ELeave )
       
  1996         CAknListQueryDialog( &status );
       
  1997         dlg->PrepareLC( R_IM_STATUS_CHANGE_DLG );
       
  1998 
       
  1999         // Format the texts
       
  2000         // Create a array for texts
       
  2001         CDesCArray* listItemsArray =
       
  2002         new ( ELeave ) CDesCArrayFlat( KAmountOfOwnStatusStates );
       
  2003         CleanupStack::PushL( listItemsArray );
       
  2004 
       
  2005         // Online
       
  2006         HBufC* onlineText = NULL;
       
  2007         onlineText = StringLoader::LoadLC( R_QTN_CHAT_CHANGE_OWN_ONLINE );
       
  2008 
       
  2009         HBufC* itemTxtOnline =
       
  2010         HBufC::NewLC( KTabFormatLenght + onlineText->Length() );
       
  2011         TPtr itemTxtPtrOnline( itemTxtOnline->Des() );
       
  2012 
       
  2013         itemTxtPtrOnline.Format( KTabFormat, KOnlineIconIndex );
       
  2014         itemTxtPtrOnline.Append( *onlineText );
       
  2015         listItemsArray->AppendL( itemTxtPtrOnline );
       
  2016         CleanupStack::PopAndDestroy( itemTxtOnline );
       
  2017         CleanupStack::PopAndDestroy( onlineText );
       
  2018 
       
  2019         // Away
       
  2020         if ( showAway )
       
  2021             {
       
  2022             HBufC* awayText = NULL;
       
  2023             awayText = StringLoader::LoadLC( R_QTN_CHAT_CHANGE_OWN_AWAY );
       
  2024 
       
  2025             HBufC* itemTxtAway = HBufC::NewLC(
       
  2026                     KTabFormatLenght + awayText->Length() );
       
  2027             TPtr itemTxtPtrAway( itemTxtAway->Des() );
       
  2028 
       
  2029             itemTxtPtrAway.Format( KTabFormat, awayIndex );
       
  2030             itemTxtPtrAway.Append( *awayText );
       
  2031             listItemsArray->AppendL( itemTxtPtrAway );
       
  2032             CleanupStack::PopAndDestroy( itemTxtAway );
       
  2033             CleanupStack::PopAndDestroy( awayText );
       
  2034             }
       
  2035 
       
  2036         // Busy
       
  2037         if ( showBusy )
       
  2038             {
       
  2039             HBufC* busyText = NULL;
       
  2040             busyText = StringLoader::LoadLC( R_QTN_SERVTAB_CHANGE_OWN_DND );
       
  2041 
       
  2042             HBufC* itemTextBusy = HBufC::NewLC(
       
  2043                     KTabFormatLenght + busyText->Length() );
       
  2044             TPtr itemTxtPtrBusy( itemTextBusy->Des() );
       
  2045 
       
  2046             itemTxtPtrBusy.Format( KTabFormat, busyIndex );
       
  2047             itemTxtPtrBusy.Append( *busyText );
       
  2048             listItemsArray->AppendL( itemTxtPtrBusy );
       
  2049             CleanupStack::PopAndDestroy( itemTextBusy );
       
  2050             CleanupStack::PopAndDestroy( busyText );
       
  2051             }
       
  2052         // Appear offline
       
  2053         if ( showAppearOffline )
       
  2054             {
       
  2055             HBufC* offlineText = NULL;
       
  2056             offlineText = StringLoader::LoadLC( R_QTN_CHAT_CHANGE_OWN_APPEAR_OFFLINE );
       
  2057 
       
  2058             HBufC* itemTextOffline = HBufC::NewLC(
       
  2059                     KTabFormatLenght + offlineText->Length() );
       
  2060             TPtr itemTxtPtrOffline( itemTextOffline->Des() );
       
  2061 
       
  2062             itemTxtPtrOffline.Format( KTabFormat, appOfflineIndex );
       
  2063             itemTxtPtrOffline.Append( *offlineText );
       
  2064             listItemsArray->AppendL( itemTxtPtrOffline );
       
  2065             CleanupStack::PopAndDestroy( itemTextOffline );
       
  2066             CleanupStack::PopAndDestroy( offlineText );
       
  2067             }
       
  2068 
       
  2069         // Set the array
       
  2070         dlg->SetOwnershipType( ELbmOwnsItemArray );
       
  2071         CleanupStack::Pop( listItemsArray );
       
  2072         dlg->SetItemTextArray( listItemsArray );
       
  2073 
       
  2074         // Add icons
       
  2075         CArrayPtr< CGulIcon >* icons = LoadOwnStatusIconsL();
       
  2076 
       
  2077 
       
  2078         dlg->SetIconArrayL( icons ); // transfers ownership
       
  2079         // TODO::get own status
       
  2080 
       
  2081         // get dialog's listbox
       
  2082         CEikListBox* listBox = dlg->ListBox();
       
  2083 
       
  2084         //listBox->SetCurrentItemIndex( 0 );
       
  2085 
       
  2086         TInt result = dlg->RunLD();
       
  2087 
       
  2088         //structure to pack status and status text.
       
  2089         TStatusAndStatusText statusAndSatatustext;
       
  2090 
       
  2091         TInt error( KErrNone );
       
  2092         if ( ( result == EAknSoftkeyOk ) ||
       
  2093                 ( result == EAknSoftkeySelect ) )
       
  2094             {
       
  2095             if ( status == 0 )                    
       
  2096                 {
       
  2097                 TInt autoStatusMsgEnabledForOnline = 1; /*IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_ONLINE_AUTO );*/
       
  2098                 if( autoStatusMsgEnabledForOnline )
       
  2099                     {
       
  2100                     error = AskStatusMessageL( TVIMPSTEnums::EOnline, EFalse );
       
  2101                     } 
       
  2102                 if( error == KErrNone )
       
  2103                     {
       
  2104                     statusAndSatatustext.iStatus  = TVIMPSTEnums::EOnline;
       
  2105                     statusAndSatatustext.iStatusText.Copy(iStatusMessage->Des());
       
  2106                     CVIMPSTUtilsWaitNote* note = CVIMPSTUtilsWaitNote::ShowWaitNoteLC( R_QTN_CHAT_CHANGE_STATUS_CHANGING );
       
  2107                     error = iCommandHandler.HandleCommandL(EChangeOwnStatus, this, &statusAndSatatustext);
       
  2108                     CleanupStack::PopAndDestroy( note );
       
  2109                     }
       
  2110                 }
       
  2111             else if ( status == awayIndex ) // Away 
       
  2112                 { 
       
  2113                 // can't get here unless Away is enabled  
       
  2114                 TInt autoStatusMsgEnabledForAway = 1;
       
  2115                 //IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_AWAY_AUTO );
       
  2116                 if( autoStatusMsgEnabledForAway )
       
  2117                     {                
       
  2118                     error = AskStatusMessageL( TVIMPSTEnums::EAway, EFalse );
       
  2119                     }
       
  2120                 if( error == KErrNone )
       
  2121                     {
       
  2122                     statusAndSatatustext.iStatus  = TVIMPSTEnums::EAway;
       
  2123                     statusAndSatatustext.iStatusText.Copy(iStatusMessage->Des());
       
  2124                     CVIMPSTUtilsWaitNote* note = CVIMPSTUtilsWaitNote::ShowWaitNoteLC( R_QTN_CHAT_CHANGE_STATUS_CHANGING );
       
  2125                     error = iCommandHandler.HandleCommandL(EChangeOwnStatus, this, &statusAndSatatustext);
       
  2126                     CleanupStack::PopAndDestroy( note );
       
  2127                     }
       
  2128                 }
       
  2129 
       
  2130             else if ( status == busyIndex ) // Busy 
       
  2131                 {
       
  2132                 // can't get here unless Busy is enabled
       
  2133                 TInt autoStatusMsgEnabledForBusy = 1;
       
  2134                 //IMUtils::IntResourceValueL( RSC_CHAT_VARIATION_BUSY_AUTO  );
       
  2135                 if( autoStatusMsgEnabledForBusy )
       
  2136                     {
       
  2137                     error = AskStatusMessageL( TVIMPSTEnums::EBusy, EFalse );
       
  2138                     }
       
  2139                 if( error == KErrNone )
       
  2140                     {
       
  2141                     statusAndSatatustext.iStatus  = TVIMPSTEnums::EBusy;
       
  2142                     statusAndSatatustext.iStatusText.Copy(iStatusMessage->Des());
       
  2143                     CVIMPSTUtilsWaitNote* note = CVIMPSTUtilsWaitNote::ShowWaitNoteLC( R_QTN_CHAT_CHANGE_STATUS_CHANGING );
       
  2144                     error = iCommandHandler.HandleCommandL(EChangeOwnStatus, this, &statusAndSatatustext);
       
  2145                     CleanupStack::PopAndDestroy( note );
       
  2146 
       
  2147                     }
       
  2148                 }
       
  2149             else if ( status == appOfflineIndex ) //appearOffline
       
  2150                 {
       
  2151 
       
  2152                 statusAndSatatustext.iStatus  = TVIMPSTEnums::EInvisible;
       
  2153                 statusAndSatatustext.iStatusText.Copy(iStatusMessage->Des());
       
  2154                 CVIMPSTUtilsWaitNote* note = CVIMPSTUtilsWaitNote::ShowWaitNoteLC( R_QTN_CHAT_CHANGE_STATUS_CHANGING );
       
  2155                 error = iCommandHandler.HandleCommandL(EChangeOwnStatus, this, &statusAndSatatustext);
       
  2156                 CleanupStack::PopAndDestroy( note );
       
  2157                 }
       
  2158             else
       
  2159                 {
       
  2160                 HBufC* text = NULL;
       
  2161                 text = StringLoader::LoadLC( R_QTN_IM_CHANGE_STATUS_NOT_CHANGED );
       
  2162                 VIMPSTUtilsDialog::DisplayNoteDialogL( *text );
       
  2163                 CleanupStack::PopAndDestroy( text );
       
  2164                 }
       
  2165             //iUISessionManager->SetStatusPaneIconsL();
       
  2166             }
       
  2167         }
       
  2168     }
       
  2169 
       
  2170 // ---------------------------------------------------------
       
  2171 // CVIMPSTUiTabbedView::LoadOwnStatusIconsL
       
  2172 // ---------------------------------------------------------
       
  2173 //
       
  2174 CAknIconArray* CVIMPSTUiTabbedView::LoadOwnStatusIconsL()
       
  2175     {
       
  2176 
       
  2177     CAknIconArray* icons = iBrandHandler->LoadOwnStatusIconsLC();
       
  2178     CleanupStack::Pop( icons );
       
  2179     return icons;
       
  2180     }
       
  2181 
       
  2182 // ---------------------------------------------------------
       
  2183 // CVIMPSTUiTabbedView::AskStatusMessageL()
       
  2184 // (other items were commented in a header).
       
  2185 // ---------------------------------------------------------
       
  2186 //
       
  2187 TInt CVIMPSTUiTabbedView::AskStatusMessageL( TVIMPSTEnums::TOnlineStatus aStatus,
       
  2188         TBool aUpdateToNetwork )
       
  2189     {
       
  2190     CDesCArray* statusMessages = new( ELeave )CDesCArrayFlat(4);
       
  2191     CleanupStack::PushL( statusMessages );
       
  2192 
       
  2193     HBufC* firstLine = StringLoader::LoadLC( R_QTN_CHAT_CHANGE_NEW_MESSAGE );
       
  2194     statusMessages->AppendL( *firstLine );
       
  2195     CleanupStack::PopAndDestroy( firstLine );
       
  2196 
       
  2197     // Read status messages
       
  2198     ReadStatusMessagesL( *statusMessages, aStatus );
       
  2199 
       
  2200     // show the query
       
  2201     TInt selectionIndex( statusMessages->Count() > 1 ? 1 : 0 );
       
  2202 
       
  2203     // Force to continue if selection query is not shown
       
  2204     TInt ret = EAknSoftkeyOk;
       
  2205 
       
  2206     if( selectionIndex == 1 )
       
  2207         {
       
  2208         // There were previous status messages, show selection query
       
  2209         HBufC* titleText = StringLoader::LoadLC( R_QTN_CHAT_CHANGE_SELECT_MESSAGE );
       
  2210         ret = VIMPSTUtilsDialog::DisplayListQueryDialogL( &selectionIndex, statusMessages,
       
  2211                 R_IM_LIST_SELECT_STATUS_MESSAGE_DLG,
       
  2212                 *titleText, KNullDesC, ETrue );
       
  2213         CleanupStack::PopAndDestroy( titleText );
       
  2214         }
       
  2215 
       
  2216     if ( !( ret == EAknSoftkeyOk || ret == EAknSoftkeyDone || ret == EAknSoftkeySelect ) )
       
  2217         {
       
  2218         CleanupStack::PopAndDestroy( statusMessages );
       
  2219         return KErrCancel;
       
  2220         }
       
  2221 
       
  2222     TPtr statusTxt( iStatusMessage->Des() );
       
  2223     statusTxt.Zero();
       
  2224 
       
  2225     if( selectionIndex != 0 )
       
  2226         {
       
  2227         statusTxt.Copy( ( *statusMessages) [ selectionIndex ] );
       
  2228         }
       
  2229 
       
  2230     TInt result = VIMPSTUtilsDialog::DisplayTextQueryDialogL(
       
  2231             statusTxt ,
       
  2232             R_QTN_CHAT_CHANGE_STATUS_MESSAGE,
       
  2233             R_IM_ENTER_STATUS_MESSAGE_QUERY,
       
  2234             ETrue, // T9
       
  2235             ETrue // LSK always visible
       
  2236     );
       
  2237 
       
  2238     if ( (result == EAknSoftkeyOk || result == EAknSoftkeyDone )&&(iEngine.ServiceState()))
       
  2239         {
       
  2240 
       
  2241         // Delete first line.
       
  2242         statusMessages->Delete( 0 );
       
  2243         statusMessages->InsertL( 0, statusTxt );
       
  2244         WriteStatusMessagesL( *statusMessages, aStatus );            
       
  2245         if( aUpdateToNetwork ) 
       
  2246             {
       
  2247             CVIMPSTUtilsWaitNote* note = CVIMPSTUtilsWaitNote::ShowWaitNoteLC( R_QTN_CHAT_CHANGE_MESSAGE_CHANGING );
       
  2248             //structure to pack status and status text.
       
  2249             TStatusAndStatusText statusAndSatatustext;
       
  2250             statusAndSatatustext.iStatus  = aStatus;
       
  2251             statusAndSatatustext.iStatusText.Copy( statusTxt );
       
  2252             iCommandHandler.HandleCommandL(EChangeOwnMessage, this, &statusAndSatatustext);
       
  2253             CleanupStack::PopAndDestroy( note );
       
  2254             }
       
  2255         }
       
  2256     else
       
  2257         {
       
  2258         CleanupStack::PopAndDestroy();//statusMessages
       
  2259         return KErrCancel;
       
  2260         }
       
  2261     CleanupStack::PopAndDestroy(); //statusMessages
       
  2262     return KErrNone;
       
  2263     }
       
  2264 
       
  2265 // -----------------------------------------------------------------------------
       
  2266 // CVIMPSTUiTabbedView::ReadStatusMessagesL
       
  2267 // (other items were commented in a header).
       
  2268 // -----------------------------------------------------------------------------
       
  2269 //
       
  2270 void CVIMPSTUiTabbedView::ReadStatusMessagesL( CDesCArray& aArray, TVIMPSTEnums::TOnlineStatus aStatus)
       
  2271     {
       
  2272     RBuf buffer;
       
  2273     buffer.CreateL( RProperty::KMaxPropertySize );
       
  2274     CleanupClosePushL( buffer );
       
  2275             TInt err(KErrNone);
       
  2276             switch ( aStatus )
       
  2277                 {
       
  2278                 case TVIMPSTEnums::EOnline:
       
  2279                     {
       
  2280                     err = iSettingsStore->GetL( iServiceId, EServiceOwnStatusMessagesOnline, buffer ); 
       
  2281                     break;
       
  2282                     }
       
  2283                 case TVIMPSTEnums::EBusy:
       
  2284                     {
       
  2285                     err = iSettingsStore->GetL( iServiceId, EServiceOwnStatusMessagesBusy, buffer ); 
       
  2286                     break;
       
  2287                     }
       
  2288                 case TVIMPSTEnums::EAway:
       
  2289                     {
       
  2290                     err = iSettingsStore->GetL( iServiceId, EServiceOwnStatusMessagesAway, buffer ); 
       
  2291                     break;
       
  2292                     }
       
  2293                 }
       
  2294     TBuf< KStatusMessageHeaderLength > header;
       
  2295 
       
  2296     TInt countOfMessages( 0 );
       
  2297     TInt offset( 1 ); // First character is for header length
       
  2298     TInt headerLength( 0 );
       
  2299     if( err == KErrNone && buffer.Length() )
       
  2300         {
       
  2301         TLex lexer( buffer.Left( 1 ) );
       
  2302         err = lexer.Val( headerLength );
       
  2303         }
       
  2304     else
       
  2305         {
       
  2306         err = KErrEof;
       
  2307         }
       
  2308     while( err == KErrNone && countOfMessages < KMaxStatusMessageCount )
       
  2309         {
       
  2310         TPtrC ptr( buffer.Mid( offset ) );
       
  2311         if( ptr.Length() > headerLength )
       
  2312             {
       
  2313             header.Copy( ptr.Left( headerLength ) );
       
  2314             header.Trim();
       
  2315             TLex lexer( header );
       
  2316             offset += headerLength;
       
  2317             TInt messageLength( 0 );
       
  2318             err = lexer.Val( messageLength );
       
  2319             if( err == KErrNone )
       
  2320                 {
       
  2321                 ptr.Set( buffer.Mid( offset ) );
       
  2322                 if( ptr.Length() >= messageLength )
       
  2323                     {
       
  2324                     if (messageLength)
       
  2325                         {
       
  2326                         aArray.AppendL( ptr.Left( messageLength ) );
       
  2327                         ++countOfMessages; // this should be increased only for not null messages.
       
  2328                         }
       
  2329                     offset += messageLength;
       
  2330                     }
       
  2331                 else
       
  2332                     {
       
  2333                     err = KErrEof;
       
  2334                     }
       
  2335                 }
       
  2336             }
       
  2337         else
       
  2338             {
       
  2339             err = KErrEof;
       
  2340             }
       
  2341         }
       
  2342     CleanupStack::PopAndDestroy(); //buffer
       
  2343     }
       
  2344 
       
  2345 // -----------------------------------------------------------------------------
       
  2346 // CVIMPSTUiTabbedView::WriteStatusMessagesL
       
  2347 // (other items were commented in a header).
       
  2348 // -----------------------------------------------------------------------------
       
  2349 //
       
  2350 
       
  2351 void CVIMPSTUiTabbedView::WriteStatusMessagesL( MDesCArray& aArray, TVIMPSTEnums::TOnlineStatus aStatus )
       
  2352     {
       
  2353 
       
  2354     TPtrC firstLine = aArray.MdcaPoint( 0 );
       
  2355     TInt countOfMessages( 0 );
       
  2356     TInt arrayCount( aArray.MdcaCount() );
       
  2357     TInt index( 0 );
       
  2358 
       
  2359     RBuf buffer;
       
  2360     buffer.CreateL( RProperty::KMaxPropertySize );
       
  2361     CleanupClosePushL( buffer );
       
  2362 
       
  2363     TBuf< KStatusMessageHeaderLength > header;
       
  2364     // Read the array and append the buffer
       
  2365     while( index < arrayCount && countOfMessages < KMaxStatusMessageCount )
       
  2366         {
       
  2367         if( index == 0 )
       
  2368             {
       
  2369             header.Format( KStatusMessageHeaderLengthFormat,
       
  2370                     KStatusMessageHeaderLength );
       
  2371             buffer.Append( header );
       
  2372             }
       
  2373         TPtrC message = aArray.MdcaPoint( index );
       
  2374         if( index == 0 || message.CompareF( firstLine ) != 0 )
       
  2375             {
       
  2376             header.Format( KStatusMessageHeaderFormat, message.Length() );
       
  2377             buffer.Append( header );
       
  2378             buffer.Append( message );
       
  2379             //skipping increase of countOfMessages is to get one more status message if it is null.
       
  2380             if( message.Length() ) // null status message
       
  2381                 {
       
  2382                 ++countOfMessages;
       
  2383                 }
       
  2384             }
       
  2385         ++index;
       
  2386                 }
       
  2387             switch ( aStatus )
       
  2388                 {
       
  2389                 case TVIMPSTEnums::EOnline:
       
  2390                     {
       
  2391                     iSettingsStore->SetL( iServiceId, EServiceOwnStatusMessagesOnline, buffer ); 
       
  2392                     break;
       
  2393                     }
       
  2394                 case TVIMPSTEnums::EBusy:
       
  2395                     {
       
  2396                     iSettingsStore->SetL( iServiceId, EServiceOwnStatusMessagesBusy, buffer ); 
       
  2397                     break;
       
  2398                     }
       
  2399                 case TVIMPSTEnums::EAway:
       
  2400                     {
       
  2401                     iSettingsStore->SetL( iServiceId, EServiceOwnStatusMessagesAway, buffer ); 
       
  2402                     break;
       
  2403                     }
       
  2404                 }
       
  2405     CleanupStack::PopAndDestroy(); // buffer
       
  2406     }
       
  2407 
       
  2408 
       
  2409 // -----------------------------------------------------------------------------
       
  2410 // CVIMPSTUiTabbedView::ChangeOwnStatusMessageL
       
  2411 // (other items were commented in a header).
       
  2412 // -----------------------------------------------------------------------------
       
  2413 //
       
  2414 void CVIMPSTUiTabbedView::ChangeOwnStatusMessageL()
       
  2415     {
       
  2416     TVIMPSTEnums::TOnlineStatus status = iCommandHandler.GetProcessInterface().GetOnlineStatusL( 0 ); //0 for own status item
       
  2417     // ETrue meaning network change required
       
  2418     AskStatusMessageL(status, ETrue);
       
  2419     }
       
  2420 // -----------------------------------------------------------------------------
       
  2421 // CVIMPSTUiTabbedView::ChangeOwnAvatarL
       
  2422 // (other items were commented in a header).
       
  2423 // -----------------------------------------------------------------------------
       
  2424 //
       
  2425 void CVIMPSTUiTabbedView::ChangeOwnAvatarL(const TDesC& aFileName, const TDesC8& aMimeType )
       
  2426 	{
       
  2427 	MVIMPSTProcessArray& arrayprocess = iCommandHandler.GetProcessInterface();
       
  2428 	TAvatarData avatarData;
       
  2429 	avatarData.iStatus = arrayprocess.GetOnlineStatusL(0);
       
  2430 	avatarData.iStatusText.Copy( arrayprocess.StatusTextL(0) );
       
  2431 	avatarData.iFileName.Set(aFileName);
       
  2432 	avatarData.iMimeType.Set(aMimeType);
       
  2433 	iCommandHandler.HandleCommandL(EChangeOwnAvtar, this, &avatarData);   
       
  2434 	}
       
  2435 // -----------------------------------------------------------------------------
       
  2436 // CVIMPSTUiTabbedView::GetServiceState
       
  2437 // (other items were commented in a header).
       
  2438 // -----------------------------------------------------------------------------
       
  2439 //
       
  2440 TVIMPSTEnums::TVIMPSTRegistrationState CVIMPSTUiTabbedView::GetServiceState()
       
  2441     {
       
  2442     return iEngine.ServiceState();
       
  2443     }
       
  2444 
       
  2445 
       
  2446 // --------------------------------------------------------------------------
       
  2447 // CVIMPSTUiTabbedView::SearchContactsL
       
  2448 // --------------------------------------------------------------------------
       
  2449 //
       
  2450 void CVIMPSTUiTabbedView:: SearchContactsL()
       
  2451 	{
       
  2452 	CVIMPSTUiSearchFieldArray& fieldArray = iExtensionService.GetSearchFieldArray(); 
       
  2453 
       
  2454 	if( !fieldArray.Count() )
       
  2455 		{
       
  2456 		return;	
       
  2457 		}
       
  2458 	
       
  2459 	if(!iIsToolBarHidden)
       
  2460 	    {
       
  2461 	    ShowHideFixedToolbarL(EFalse);
       
  2462 	    }
       
  2463 
       
  2464 	if (iContainer)
       
  2465 		{
       
  2466 		iContainer->DeactivateFindPaneL();
       
  2467 		}
       
  2468 
       
  2469 	fieldArray.ResetFieldData();
       
  2470 	fieldArray.SetSearchType( EIMBasicSearch );
       
  2471 	//Launch the search view with search dialog
       
  2472 	LaunchViewL( iExtensionService.SearchViewId() );
       
  2473 	            
       
  2474 	}
       
  2475 
       
  2476 // ---------------------------------------------------------------------------
       
  2477 // CVIMPSTUiTabbedView::LaunchViewL()
       
  2478 // ---------------------------------------------------------------------------
       
  2479 // 
       
  2480 void CVIMPSTUiTabbedView::LaunchViewL( TInt aViewId )
       
  2481     {
       
  2482 
       
  2483     CPbk2ViewState* state = CPbk2ViewState::NewLC( );
       
  2484 
       
  2485     TInt searchViewId;
       
  2486     TInt err = iMapper.GetNewView( 
       
  2487             KIMCONTACTSEXTNIMPLEMENTATIONUID, 
       
  2488             aViewId, 
       
  2489             searchViewId );
       
  2490     User::LeaveIfError( err );                        
       
  2491     Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()->ActivatePhonebook2ViewL
       
  2492     (TUid::Uid(searchViewId), state);
       
  2493 
       
  2494     CleanupStack::PopAndDestroy( state );
       
  2495     }
       
  2496 
       
  2497 // ---------------------------------------------------------
       
  2498 // CVIMPSTUiTabbedView::CreateToolBarL
       
  2499 // ---------------------------------------------------------
       
  2500 //
       
  2501 void CVIMPSTUiTabbedView::CreateToolBarL()
       
  2502     {
       
  2503     if ( AknLayoutUtils::PenEnabled() )
       
  2504         {
       
  2505         TInt resourceId = 0;
       
  2506         if(iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EIM) && 
       
  2507                 !iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EVoip))
       
  2508             {
       
  2509             resourceId = R_IM_APP_TOOLBAR;
       
  2510             }
       
  2511         else if(iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EVoip) && 
       
  2512                 !iEngine.IsSubServiceSupportedL(TVIMPSTEnums::EIM))
       
  2513             {
       
  2514             resourceId = R_VOIP_APP_TOOLBAR;
       
  2515             }
       
  2516         else           
       
  2517             {
       
  2518             resourceId = R_IM_VOIP_APP_TOOLBAR;
       
  2519             }
       
  2520         if ( resourceId != 0 && !iFixedToolbar )
       
  2521             {              
       
  2522             CAknToolbar* temp = iFixedToolbar;
       
  2523 
       
  2524             iFixedToolbar = CAknToolbar::NewL( resourceId );
       
  2525             iFixedToolbar->SetToolbarObserver( this ); 
       
  2526             iFixedToolbar->SetCloseOnAllCommands( EFalse );
       
  2527             CEikAppUiFactory* appUiFactory = 
       
  2528             static_cast<CEikAppUiFactory*>(CEikonEnv::Static()->AppUiFactory() );                  
       
  2529             appUiFactory->SetViewFixedToolbar( iFixedToolbar );
       
  2530 
       
  2531             iFixedToolbar->SetToolbarVisibility( EFalse, EFalse );
       
  2532             delete temp;
       
  2533             temp = NULL;
       
  2534             }
       
  2535         }
       
  2536     else
       
  2537         {
       
  2538         delete iFixedToolbar;
       
  2539         iFixedToolbar = NULL;
       
  2540         }
       
  2541     }
       
  2542 
       
  2543 // ---------------------------------------------------------
       
  2544 // CVIMPSTUiTabbedView::UpdateToolbarL
       
  2545 // ---------------------------------------------------------
       
  2546 //
       
  2547 void CVIMPSTUiTabbedView::UpdateToolbarL()
       
  2548     {
       
  2549     if ( AknLayoutUtils::PenEnabled() && iFixedToolbar && iContainer )    
       
  2550         {
       
  2551         TInt currentItemIndex = iContainer->CurrentItemIndex();        
       
  2552         TVIMPSTEnums::TItem itemType = iCommandHandler.GetProcessInterface().GetType(currentItemIndex);         
       
  2553         TVIMPSTEnums::TOnlineStatus onlinestatus = iCommandHandler.GetProcessInterface().GetOnlineStatusL(currentItemIndex);        
       
  2554         TBool imEnabled = iEngine.IsSubServiceEnabled(TVIMPSTEnums::EIM);
       
  2555         TBool voipEnabled = iEngine.IsSubServiceEnabled(TVIMPSTEnums::EVoip);
       
  2556         TPtrC selectedItem = iCommandHandler.GetProcessInterface().GetItemUserId(currentItemIndex);
       
  2557         
       
  2558         if(voipEnabled && imEnabled)
       
  2559             {                
       
  2560             if( TVIMPSTEnums::EOwnStatusItem == itemType ||
       
  2561                     TVIMPSTEnums::EFriendRequestItem == itemType ||
       
  2562                     KErrNotFound == currentItemIndex )
       
  2563                 {
       
  2564                 iFixedToolbar->SetItemDimmed( ECmdToolbarVoipCall, ETrue, EFalse );
       
  2565                 iFixedToolbar->SetItemDimmed( ECmdToolbarChat, ETrue, EFalse );
       
  2566                 iFixedToolbar->SetItemDimmed( ECmdToolbarDetails, ETrue, EFalse );
       
  2567                 }
       
  2568             else if( TVIMPSTEnums::EUnknonContactItem == itemType  )
       
  2569                 {  
       
  2570                 iFixedToolbar->SetItemDimmed(ECmdToolbarVoipCall, EFalse, EFalse); 
       
  2571                 iFixedToolbar->SetItemDimmed(ECmdToolbarChat, EFalse, EFalse); 
       
  2572                 iFixedToolbar->SetItemDimmed(ECmdToolbarDetails, ETrue, EFalse);                 
       
  2573                 }
       
  2574             else if( TVIMPSTEnums::EContactItem == itemType )
       
  2575                 {  
       
  2576                 if( selectedItem != KNullDesC  &&  TVIMPSTEnums::EServiceOut != onlinestatus )
       
  2577                     {
       
  2578                   
       
  2579                     iFixedToolbar->SetItemDimmed(ECmdToolbarChat, EFalse, EFalse);
       
  2580                     }
       
  2581                 else
       
  2582                     {
       
  2583                     iFixedToolbar->SetItemDimmed(ECmdToolbarChat, ETrue, EFalse);
       
  2584                     }
       
  2585                 iFixedToolbar->SetItemDimmed(ECmdToolbarDetails, EFalse, EFalse); 
       
  2586                 iFixedToolbar->SetItemDimmed(ECmdToolbarVoipCall, EFalse, EFalse); 
       
  2587                 }  
       
  2588             else
       
  2589                 {  
       
  2590                 iFixedToolbar->SetItemDimmed(ECmdToolbarVoipCall, ETrue, EFalse); 
       
  2591                 iFixedToolbar->SetItemDimmed(ECmdToolbarChat, ETrue, EFalse);
       
  2592                 iFixedToolbar->SetItemDimmed(ECmdToolbarDetails, EFalse, EFalse);                 
       
  2593                 }  
       
  2594             }
       
  2595         else if(imEnabled && !voipEnabled)
       
  2596             {                   
       
  2597             if( TVIMPSTEnums::EOwnStatusItem == itemType ||
       
  2598                     TVIMPSTEnums::EFriendRequestItem == itemType ||
       
  2599                     KErrNotFound == currentItemIndex)
       
  2600                 {
       
  2601                 iFixedToolbar->SetItemDimmed( ECmdToolbarChat, ETrue, EFalse );
       
  2602                 iFixedToolbar->SetItemDimmed( ECmdToolbarDetails, ETrue, EFalse );               
       
  2603                 }
       
  2604             else if( TVIMPSTEnums::EUnknonContactItem == itemType  )
       
  2605                 {  
       
  2606                 iFixedToolbar->SetItemDimmed(ECmdToolbarChat, EFalse, EFalse); 
       
  2607                 iFixedToolbar->SetItemDimmed(ECmdToolbarDetails, ETrue, EFalse);                 
       
  2608                 }
       
  2609             else if( TVIMPSTEnums::EContactItem == itemType )
       
  2610                 {
       
  2611                 iFixedToolbar->SetItemDimmed( ECmdToolbarDetails, EFalse, EFalse );
       
  2612                 if( selectedItem != KNullDesC && TVIMPSTEnums::EServiceOut != onlinestatus )
       
  2613                     {
       
  2614                     iFixedToolbar->SetItemDimmed(ECmdToolbarChat, EFalse, EFalse);
       
  2615                     }
       
  2616                 else
       
  2617                     {
       
  2618                     iFixedToolbar->SetItemDimmed(ECmdToolbarChat, ETrue, EFalse);
       
  2619                     }
       
  2620                 }   
       
  2621             }
       
  2622         else if( voipEnabled && !imEnabled )
       
  2623             {               
       
  2624             if( (TVIMPSTEnums::EOwnStatusItem == itemType ||
       
  2625                     TVIMPSTEnums::EFriendRequestItem == itemType ||
       
  2626                     KErrNotFound == currentItemIndex) && !iAddContact )
       
  2627                 {
       
  2628                 iFixedToolbar->SetItemDimmed( ECmdToolbarNewContact, EFalse, EFalse );
       
  2629                 iFixedToolbar->SetItemDimmed( ECmdToolbarVoipCall, ETrue, EFalse );
       
  2630                 iFixedToolbar->SetItemDimmed( ECmdToolbarDetails, ETrue, EFalse );               
       
  2631                 }   
       
  2632             else if( TVIMPSTEnums::EUnknonContactItem == itemType  )
       
  2633                 {  
       
  2634                 iFixedToolbar->SetItemDimmed( ECmdToolbarNewContact, EFalse, EFalse );
       
  2635                 iFixedToolbar->SetItemDimmed(ECmdToolbarVoipCall, EFalse, EFalse );
       
  2636                 iFixedToolbar->SetItemDimmed(ECmdToolbarDetails, ETrue, EFalse);                 
       
  2637                 }
       
  2638             else if( TVIMPSTEnums::EContactItem == itemType )
       
  2639                 {
       
  2640                 iFixedToolbar->SetItemDimmed( ECmdToolbarNewContact, EFalse, EFalse );
       
  2641                 iFixedToolbar->SetItemDimmed( ECmdToolbarDetails, EFalse, EFalse );
       
  2642                 iFixedToolbar->SetItemDimmed(ECmdToolbarVoipCall, EFalse, EFalse);  
       
  2643                 } 
       
  2644             }
       
  2645         else
       
  2646             {               
       
  2647             if( (TVIMPSTEnums::EOwnStatusItem == itemType ||
       
  2648                     TVIMPSTEnums::EFriendRequestItem == itemType ||
       
  2649                     KErrNotFound == currentItemIndex) && !iAddContact )
       
  2650                 {
       
  2651                 iFixedToolbar->SetItemDimmed( ECmdToolbarNewContact, EFalse, EFalse );
       
  2652                 } 
       
  2653             else if( TVIMPSTEnums::EUnknonContactItem == itemType  )
       
  2654                 {  
       
  2655                 iFixedToolbar->SetItemDimmed( ECmdToolbarNewContact, EFalse, EFalse);
       
  2656                 }
       
  2657             else
       
  2658                 {
       
  2659                 iFixedToolbar->SetItemDimmed( ECmdToolbarNewContact, EFalse, EFalse );
       
  2660                 iFixedToolbar->SetItemDimmed( ECmdToolbarDetails, EFalse, EFalse );
       
  2661                 }
       
  2662             }
       
  2663         iFixedToolbar->DrawNow();
       
  2664         }
       
  2665     }
       
  2666 // ---------------------------------------------------------
       
  2667 // CVIMPSTUiTabbedView::DynInitToolbarL
       
  2668 // ---------------------------------------------------------
       
  2669 //
       
  2670 void CVIMPSTUiTabbedView::DynInitToolbarL( TInt /*aResourceId*/, CAknToolbar* /*aToolbar*/ )
       
  2671     {
       
  2672     if ( AknLayoutUtils::PenEnabled() )
       
  2673         {
       
  2674         UpdateToolbarL();
       
  2675         }
       
  2676     }
       
  2677 
       
  2678 // ---------------------------------------------------------
       
  2679 // CVIMPSTUiTabbedView::OfferToolbarEventL
       
  2680 // ---------------------------------------------------------
       
  2681 //        
       
  2682 void CVIMPSTUiTabbedView::OfferToolbarEventL( TInt aCommand )
       
  2683     {
       
  2684     if ( AknLayoutUtils::PenEnabled() )
       
  2685         {
       
  2686         switch( aCommand )
       
  2687             {
       
  2688             case ECmdToolbarVoipCall:
       
  2689                 {
       
  2690                 MakeVoipCallL();
       
  2691                 break;
       
  2692                 }
       
  2693             case ECmdToolbarChat:
       
  2694                 {
       
  2695                 HandleCommandL( ECmdOpenConversation );
       
  2696                 break;
       
  2697                 }
       
  2698             case ECmdToolbarDetails:
       
  2699                 {
       
  2700                 HandleCommandL( ECmdContactDetails );//EChatLaunchCCA
       
  2701 
       
  2702                 break;
       
  2703                 }
       
  2704             case ECmdToolbarNewContact:
       
  2705                 {
       
  2706                 HandleCommandL ( ECmdAddContact );
       
  2707                 break;
       
  2708                 }
       
  2709             }  
       
  2710         }
       
  2711     }
       
  2712 
       
  2713 // ---------------------------------------------------------
       
  2714 // CVIMPSTUiTabbedView::ShowHideFixedToolbarL
       
  2715 // ---------------------------------------------------------
       
  2716 //     
       
  2717 void CVIMPSTUiTabbedView::ShowHideFixedToolbarL(TBool aShow)
       
  2718     { 
       
  2719     if ( iFixedToolbar && iContainer )
       
  2720         {    	
       
  2721         iFixedToolbar->HideItemsAndDrawOnlyBackground( !aShow );
       
  2722         if(aShow)
       
  2723             {
       
  2724             iFixedToolbar->SetToolbarVisibility( aShow, !aShow);
       
  2725             }
       
  2726         iContainer->CoeControl()->SetRect( iView.ClientRect() );
       
  2727         iContainer->CoeControl()->DrawDeferred();
       
  2728         iIsToolBarHidden = !aShow;
       
  2729         }
       
  2730 
       
  2731     }
       
  2732 
       
  2733 // ---------------------------------------------------------
       
  2734 // CVIMPSTUiTabbedView::ProcessFriendRequestL
       
  2735 // ---------------------------------------------------------
       
  2736 // 
       
  2737 void CVIMPSTUiTabbedView::ProcessFriendRequestL()
       
  2738     {
       
  2739     TInt index = CurrentItemIndex();    
       
  2740     if( index <= 0 )
       
  2741         {
       
  2742         // return if item not found
       
  2743         return; 
       
  2744         }
       
  2745     MVIMPSTProcessArray& arrayprocess = iCommandHandler.GetProcessInterface();
       
  2746     if( iFriendRequestId )
       
  2747 	    {
       
  2748 	    delete iFriendRequestId;
       
  2749 	    iFriendRequestId = NULL;	
       
  2750 	    }
       
  2751     iFriendRequestId = arrayprocess.GetItemUserId(index).AllocL() ;
       
  2752 
       
  2753     if( !iFriendRequestId )
       
  2754         {
       
  2755         return;
       
  2756         }
       
  2757 
       
  2758     HBufC* queryTxt = StringLoader::LoadLC( R_SERVTAB_FRIEND_REQUEST_CONF, *iFriendRequestId );
       
  2759 
       
  2760     //ask the query and send the response back to the server.
       
  2761     TInt response = VIMPSTUtilsDialog::DisplayQueryDialogL(R_SERVTAB_GENERIC_ACCEPT_DECLINE_CONFIRMATION_QUERY,*queryTxt);
       
  2762     CleanupStack::PopAndDestroy(queryTxt);
       
  2763 
       
  2764     if((EAknSoftkeyYes == response)||(EAknSoftkeyOk == response ) )
       
  2765         {
       
  2766         
       
  2767         MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL( iEngine.ServiceId() ) ;
       
  2768         if( storage && storage->IsLocalStore() )//if local store popup create new/update existing dialog 
       
  2769            {
       
  2770             iSelectedAction = ShowNewUpdateQueryL();
       
  2771             TUint assignFlags = 0;
       
  2772             if(CVIMPSTUiTabbedView::EInvitAcceptCreateNew == iSelectedAction )//create new option
       
  2773                 {
       
  2774                 assignFlags |= ECreateNewContact;
       
  2775                 }
       
  2776             else if(CVIMPSTUiTabbedView::EInvitAcceptUpdateExisting == iSelectedAction ) //if update existing is selected
       
  2777                 {
       
  2778                 assignFlags = 0;
       
  2779                 }
       
  2780             else                                //if the selection dialog is cancelled then just do nothing
       
  2781                 {
       
  2782                 return;
       
  2783                 }
       
  2784             //show the phonebook dialog for create new/update existing option
       
  2785             if(iAiwParamList)
       
  2786                 {
       
  2787                 delete iAiwParamList;
       
  2788                 iAiwParamList = NULL;
       
  2789                 }        
       
  2790             iAiwParamList = CAiwGenericParamList::NewL();
       
  2791 
       
  2792             iAiwParamList->AppendL(
       
  2793                     TAiwGenericParam(
       
  2794                             EGenericParamContactAssignData,
       
  2795                             TAiwVariant(TAiwSingleContactAssignDataV1Pckg(
       
  2796                                     TAiwSingleContactAssignDataV1().SetFlags( assignFlags )))));
       
  2797 
       
  2798             TBuf<KBufLen> xspId; //xsp max length
       
  2799             xspId.Append(iEngine.ServiceName());
       
  2800             xspId.Append(KColon);
       
  2801             xspId.Append(*iFriendRequestId);
       
  2802 
       
  2803             iAiwParamList->AppendL(
       
  2804                     TAiwGenericParam(
       
  2805                             EGenericParamXSpId,
       
  2806                             TAiwVariant(xspId))
       
  2807             );
       
  2808             ReInitializeServiceHandlerL();
       
  2809             iServiceHandler->ExecuteServiceCmdL(
       
  2810                     KAiwCmdAssign,
       
  2811                     *iAiwParamList,
       
  2812                     iServiceHandler->OutParamListL(),
       
  2813                     0,
       
  2814                     this);
       
  2815             // remove of friend request is done in HnadleNotify aiw call back
       
  2816             // to handle the cancel of selection dialog
       
  2817             }
       
  2818         else // in case of server store
       
  2819             {
       
  2820             if( iWaitNote )
       
  2821 		        {
       
  2822 		        delete iWaitNote;
       
  2823 		        iWaitNote = NULL;
       
  2824 		        }
       
  2825         	iWaitNote = CVIMPSTUtilsWaitNote::ShowWaitNoteL( R_QTN_SERVTAB_SAVING_CONTACT, ETrue, EFalse );
       
  2826             iCommandHandler.HandleCommandL(EFriendAccpeted, this, iFriendRequestId);
       
  2827             }
       
  2828 
       
  2829         }
       
  2830     //response value comes as zero if user rejects the request
       
  2831     else if( EAknSoftkeyCancel == response || 0 == response) // rejected the request
       
  2832         {
       
  2833         if(iWaitNote)
       
  2834             {
       
  2835             delete iWaitNote;
       
  2836             iWaitNote = NULL;	
       
  2837             }
       
  2838         iWaitNote = CVIMPSTUtilsWaitNote::ShowWaitNoteL( R_QTN_SERVTAB_DECLINING_INVITE, ETrue , EFalse );;
       
  2839         iCommandHandler.HandleCommandL(EFriendRejected, this, iFriendRequestId );
       
  2840         }
       
  2841    
       
  2842 
       
  2843     }
       
  2844 
       
  2845 // ---------------------------------------------------------
       
  2846 // CVIMPSTUiTabbedView::HandleSearchResultL()
       
  2847 // ---------------------------------------------------------
       
  2848 //
       
  2849 void CVIMPSTUiTabbedView::HandleSearchResultL(RArray<TVIMPSTSearchData> /*aSearchData*/ )
       
  2850     {
       
  2851     // no implemetation
       
  2852     }
       
  2853 
       
  2854 
       
  2855 // ---------------------------------------------------------
       
  2856 // CVIMPSTUiTabbedView::HandleSearchFinishedL()
       
  2857 // ---------------------------------------------------------
       
  2858 //
       
  2859 void CVIMPSTUiTabbedView::HandleSearchFinishedL(TInt /*aError*/)
       
  2860     {
       
  2861     // no implemetation
       
  2862     }
       
  2863 
       
  2864 // ---------------------------------------------------------
       
  2865 // CVIMPSTUiSearchView::HandleSearchKeysEventL()
       
  2866 // ---------------------------------------------------------
       
  2867 //
       
  2868 void CVIMPSTUiTabbedView::HandleSearchKeysEventL( RArray<TInt>& aEnumKeysArray, RPointerArray<HBufC>& aLebelKeysArray )
       
  2869     {
       
  2870     iExtensionService.SetSearchFieldsDataL(aEnumKeysArray, aLebelKeysArray );
       
  2871     }
       
  2872 
       
  2873 // ---------------------------------------------------------
       
  2874 // CVIMPSTUiSearchView::ShowURLQueryL()
       
  2875 // ---------------------------------------------------------
       
  2876 //
       
  2877 void CVIMPSTUiTabbedView::ShowURLQueryL( )
       
  2878     {    
       
  2879     // Open browser with the specified URL
       
  2880     RBuf buffer;
       
  2881     buffer.CreateL( RProperty::KMaxPropertySize );
       
  2882     CleanupClosePushL( buffer );
       
  2883     iSettingsStore->GetL(iServiceId, EServiceURLLink, buffer);      
       
  2884     HBufC16* url = HBufC::NewL(buffer.Length());
       
  2885     url = buffer.Alloc();
       
  2886     OpenWebBrowserL( *url );           
       
  2887     CleanupStack::PopAndDestroy( ); //buffer   
       
  2888     }
       
  2889 
       
  2890 // -----------------------------------------------------------------------------
       
  2891 // CVIMPSTUiTabbedView::OpenWebBrowserL
       
  2892 // -----------------------------------------------------------------------------
       
  2893 //
       
  2894 void CVIMPSTUiTabbedView::OpenWebBrowserL( const TDesC& aUrl )
       
  2895     {
       
  2896     if( !iBrLauncher )
       
  2897         {
       
  2898         iBrLauncher = CBrowserLauncher::NewL();             
       
  2899         }
       
  2900     //Asynchronous operation to launch the browser with aUrl
       
  2901     iBrLauncher->LaunchBrowserEmbeddedL( aUrl,this,this );    
       
  2902     }
       
  2903 
       
  2904 
       
  2905 // -----------------------------------------------------------------------------
       
  2906 // CVIMPSTUiTabbedView::LoginL
       
  2907 // -----------------------------------------------------------------------------
       
  2908 //
       
  2909 void CVIMPSTUiTabbedView::LoginL()
       
  2910     {
       
  2911     TBool IsPasswordSet = iEngine.IsPasswordAvailableL();
       
  2912 
       
  2913     if(iUserId)
       
  2914         {
       
  2915         delete iUserId;
       
  2916         iUserId = NULL;
       
  2917         }
       
  2918    
       
  2919     iUserId = iEngine.GetOwnUserIdFromCChOrStorageL();
       
  2920     
       
  2921     
       
  2922     TBool urlNeedtoShow = IsURLQueryToBeShownL();
       
  2923     //first login : userid is not initialized and password is not set.
       
  2924     TBool doLogin = ETrue;
       
  2925     if( urlNeedtoShow &&  (!IsPasswordSet) && (iUserId->Length() == 0))
       
  2926         {       
       
  2927         TInt menuChoise( KErrCancel );
       
  2928         ShowUseExistingOrCreateNewMenuL( menuChoise );
       
  2929         switch(menuChoise )
       
  2930             {
       
  2931             case CVIMPSTUiTabbedView::EXmppMenuValuesCreateNew:
       
  2932                 {
       
  2933                 doLogin = EFalse;
       
  2934                 ShowURLQueryL();
       
  2935                 break;
       
  2936                 }
       
  2937             case CVIMPSTUiTabbedView::EXmppMenuValuesUseExisting:
       
  2938                 {
       
  2939                 // login must be called
       
  2940                 doLogin = ETrue;
       
  2941                 break;
       
  2942                 }
       
  2943             default: // user has cancelled the createnew and i have acccount query
       
  2944                 doLogin = EFalse;
       
  2945                 break;             
       
  2946 			}
       
  2947         }
       
  2948      if( doLogin )
       
  2949         {
       
  2950         TInt error = ShowTermsofuseL();
       
  2951         if(KErrNone == error)
       
  2952             {
       
  2953             if( urlNeedtoShow  )
       
  2954                 {
       
  2955                 // Url query has been shown and accep by user
       
  2956                 iSettingsStore->SetL(iServiceId, EURLRegistrationOff, ETrue);
       
  2957                 }
       
  2958             iCommandHandler.HandleCommandL(ELoginService, this, &iServiceId); 
       
  2959             }
       
  2960         }
       
  2961     }
       
  2962 
       
  2963 
       
  2964 // -----------------------------------------------------------------------------
       
  2965 // CVIMPSTUiTabbedView::IsURLQueryToBeShownL
       
  2966 // -----------------------------------------------------------------------------
       
  2967 //
       
  2968 TBool CVIMPSTUiTabbedView::IsURLQueryToBeShownL()
       
  2969     {
       
  2970     TBool urlQueryShown = EFalse;
       
  2971     
       
  2972     RBuf buffer;
       
  2973     buffer.CreateL( RProperty::KMaxPropertySize );
       
  2974     CleanupClosePushL( buffer );
       
  2975     iSettingsStore->GetL(iServiceId, EServiceURLLink, buffer); 
       
  2976     
       
  2977     //get the url from the cenrep.
       
  2978     TInt isURLQueryDisabled = EFalse;
       
  2979     iSettingsStore->GetL(iServiceId, EURLRegistrationOff, isURLQueryDisabled);
       
  2980     
       
  2981     if(buffer.Length() && !isURLQueryDisabled)
       
  2982         {
       
  2983         urlQueryShown = ETrue;
       
  2984         }
       
  2985     CleanupStack::PopAndDestroy(); //buffer
       
  2986     return urlQueryShown;
       
  2987     }
       
  2988 
       
  2989 // ---------------------------------------------------------------------------
       
  2990 // CVIMPSTUiTabbedView::ShowUseExistingOrCreateNewMenuL
       
  2991 // return values <0 -> error
       
  2992 //               0 -> use existing
       
  2993 //               1 -> create new
       
  2994 // ---------------------------------------------------------------------------
       
  2995 //
       
  2996 void CVIMPSTUiTabbedView::ShowUseExistingOrCreateNewMenuL( TInt& aMenuChoise )
       
  2997     {
       
  2998     TInt rvalue( KErrGeneral );
       
  2999 
       
  3000     CAknSinglePopupMenuStyleListBox* accountList =
       
  3001     new ( ELeave ) CAknSinglePopupMenuStyleListBox;
       
  3002     CleanupStack::PushL( accountList );
       
  3003 
       
  3004     CAknPopupList* popupList =
       
  3005     CAknPopupList::NewL( accountList, R_AVKON_SOFTKEYS_OK_BACK );
       
  3006     CleanupStack::PushL( popupList );
       
  3007 
       
  3008     accountList->ConstructL(  popupList, EAknListBoxMenuList);
       
  3009 
       
  3010     // construct listbox item array
       
  3011     CDesCArray *itemList = new (ELeave) CDesCArrayFlat( 2 );
       
  3012     CleanupStack::PushL( itemList );
       
  3013     TBuf<KMaxListItemLength> item;
       
  3014 
       
  3015     // First listbox item
       
  3016     HBufC* text1 = StringLoader::LoadLC( R_QTN_USE_EXISTING );
       
  3017     itemList->AppendL( *text1 );
       
  3018     CleanupStack::PopAndDestroy( text1 );
       
  3019 
       
  3020     // Second listbox item
       
  3021     HBufC* text2 = StringLoader::LoadLC( R_QTN_CREATE_NEW );
       
  3022     itemList->AppendL( *text2 );
       
  3023     CleanupStack::PopAndDestroy( text2 );
       
  3024 
       
  3025     // Set items and ownership
       
  3026     accountList->Model()->SetItemTextArray( itemList );
       
  3027     accountList->Model()->SetOwnershipType( ELbmOwnsItemArray );
       
  3028     CleanupStack::Pop( itemList );
       
  3029 
       
  3030     HBufC* title = StringLoader::LoadLC( R_QTN_SELECT_ACTION );
       
  3031     popupList->SetTitleL( *title );
       
  3032     CleanupStack::PopAndDestroy( title );
       
  3033 
       
  3034     TInt popupOk = popupList->ExecuteLD();
       
  3035 
       
  3036     if ( popupOk )
       
  3037         {
       
  3038         rvalue = accountList->CurrentItemIndex();
       
  3039         }
       
  3040     else
       
  3041         {
       
  3042         rvalue = KErrCancel;
       
  3043         }
       
  3044 
       
  3045     CleanupStack::Pop( popupList );
       
  3046     CleanupStack::PopAndDestroy( accountList );
       
  3047 
       
  3048     aMenuChoise = rvalue;
       
  3049     }
       
  3050 // ---------------------------------------------------------------------------
       
  3051 // CVIMPSTUiTabbedView::ShowNewUpdateQueryL
       
  3052 // return values <0 -> error
       
  3053 //               0 ->create new
       
  3054 //               1 -> update existing
       
  3055 // ---------------------------------------------------------------------------
       
  3056 //
       
  3057 TInt CVIMPSTUiTabbedView::ShowNewUpdateQueryL()
       
  3058     {
       
  3059     TInt retValue( KErrCancel );
       
  3060 
       
  3061     CAknSinglePopupMenuStyleListBox* selectionList =
       
  3062                 new ( ELeave ) CAknSinglePopupMenuStyleListBox;
       
  3063     CleanupStack::PushL( selectionList );
       
  3064 
       
  3065     CAknPopupList* popupList = CAknPopupList::NewL( 
       
  3066                                              selectionList,
       
  3067                                              R_AVKON_SOFTKEYS_SELECT_CANCEL );
       
  3068     CleanupStack::PushL( popupList );
       
  3069 
       
  3070     selectionList->ConstructL(  popupList, EAknListBoxMenuList );
       
  3071 
       
  3072     // construct listbox item array
       
  3073     CDesCArray *itemList = new (ELeave) CDesCArrayFlat( 2 );
       
  3074     CleanupStack::PushL( itemList );
       
  3075     
       
  3076     // First listbox item
       
  3077     HBufC* newItem = StringLoader::LoadLC( R_QTN_CREATE_NEW_CONTACT  );
       
  3078     itemList->AppendL( *newItem );
       
  3079     CleanupStack::PopAndDestroy( newItem );
       
  3080     
       
  3081     // Second listbox item
       
  3082     HBufC* updateItem = StringLoader::LoadLC( R_QTN_UPDATE_EXISTING  );
       
  3083     itemList->AppendL( *updateItem );
       
  3084     CleanupStack::PopAndDestroy( updateItem );
       
  3085 
       
  3086     // Set items and ownership
       
  3087     selectionList->Model()->SetItemTextArray( itemList );
       
  3088     selectionList->Model()->SetOwnershipType( ELbmOwnsItemArray );
       
  3089     CleanupStack::Pop( itemList ); // ownership is transfered to selectionList
       
  3090 
       
  3091     HBufC* title = StringLoader::LoadLC( R_QTN_SELECT_ACTION );
       
  3092     popupList->SetTitleL( *title );
       
  3093     CleanupStack::PopAndDestroy( title );
       
  3094 
       
  3095     TInt response = popupList->ExecuteLD();
       
  3096 
       
  3097     if ( response )
       
  3098         {
       
  3099         retValue = selectionList->CurrentItemIndex();
       
  3100         }
       
  3101     CleanupStack::Pop( popupList ); // onership given to selectionList
       
  3102     CleanupStack::PopAndDestroy( selectionList ); // selectionList
       
  3103 
       
  3104     return retValue;
       
  3105     }
       
  3106 // CVIMPSTUiTabbedView::ShowLoginDialogL
       
  3107 // ---------------------------------------------------------------------------
       
  3108 //
       
  3109 void CVIMPSTUiTabbedView::ShowLoginDialogL( TDes& aUserName, TDes& aPassword )
       
  3110     {
       
  3111     HBufC* userName = HBufC::NewLC( KUsernameMaxLength );
       
  3112     HBufC* passWord = HBufC::NewLC( KPasswordMaxLength );
       
  3113 
       
  3114     TPtr ptrUserName = userName->Des(); 
       
  3115     TPtr ptrPassWord = passWord->Des();
       
  3116 
       
  3117     if( aUserName.Length()== 0 )
       
  3118         {
       
  3119         CAknMultiLineDataQueryDialog* dlg = CAknMultiLineDataQueryDialog::NewL( ptrUserName,
       
  3120                 ptrPassWord );
       
  3121         if ( dlg->ExecuteLD( R_LOGIN_DIALOG ) )
       
  3122             {
       
  3123             aUserName.Copy( ptrUserName.LeftTPtr( aUserName.MaxLength() ) );
       
  3124             aPassword.Copy( ptrPassWord.LeftTPtr( aPassword.MaxLength() ) );
       
  3125             }
       
  3126         else
       
  3127             {
       
  3128             User::Leave( KErrCancel );
       
  3129             }
       
  3130         }
       
  3131     else
       
  3132         {
       
  3133         CAknMultiLineDataQueryDialog* dlg = CAknMultiLineDataQueryDialog::NewL( aUserName,
       
  3134                 aPassword );
       
  3135         if ( dlg->ExecuteLD( R_LOGIN_DIALOG ) )
       
  3136             {
       
  3137             aUserName.Copy( aUserName.LeftTPtr( aUserName.MaxLength() ) );
       
  3138             aPassword.Copy( aPassword.LeftTPtr( aPassword.MaxLength() ) );
       
  3139             }
       
  3140         else
       
  3141             {
       
  3142             User::Leave( KErrCancel );
       
  3143             }
       
  3144         }
       
  3145     CleanupStack::PopAndDestroy( passWord );
       
  3146     CleanupStack::PopAndDestroy( userName );
       
  3147     }
       
  3148 // ----------------------------------------------------
       
  3149 // CVIMPSTUiTabbedView::HandleContentL
       
  3150 // Handles the content coming from the embedded browser.
       
  3151 // Returns EFalse: content will be passed on to framework
       
  3152 // ----------------------------------------------------
       
  3153 //
       
  3154 TBool CVIMPSTUiTabbedView::HandleContentL( 
       
  3155         const TDesC& /*aFileName*/, 
       
  3156         const CAiwGenericParamList& /*aParamList*/, 
       
  3157         TBool& aContinue )
       
  3158     {
       
  3159     // Close browser after downloading content
       
  3160     aContinue = EFalse;
       
  3161     return EFalse;
       
  3162     }
       
  3163 
       
  3164 // ----------------------------------------------------
       
  3165 // CVIMPSTUiTabbedView::DownloadedContentHandlerReserved1
       
  3166 // ( Reserved for future use )
       
  3167 // ----------------------------------------------------
       
  3168 //
       
  3169 TAny* CVIMPSTUiTabbedView::DownloadedContentHandlerReserved1( TAny* /*aAnyParam*/ )
       
  3170     {
       
  3171     // Empty implementation.
       
  3172     return NULL;
       
  3173     }
       
  3174 
       
  3175 // ---------------------------------------------------------------------------
       
  3176 // CVIMPSTUiTabbedView::CloseConversation
       
  3177 // ---------------------------------------------------------------------------
       
  3178 //
       
  3179 void CVIMPSTUiTabbedView::CloseConversationL()
       
  3180     {
       
  3181     TInt index = CurrentItemIndex();    
       
  3182     if( index <= 0 )
       
  3183         {
       
  3184         // return if item not found
       
  3185         return; 
       
  3186         }
       
  3187     MVIMPSTProcessArray& arrayprocess = iCommandHandler.GetProcessInterface();
       
  3188     TPtrC itemId = arrayprocess.GetItemUserId(index);
       
  3189 
       
  3190     if(itemId.Length() == 0)
       
  3191         {
       
  3192         return;
       
  3193         }
       
  3194 
       
  3195     HBufC* queryTxt = StringLoader::LoadLC( R_QTN_SERVTAB_CLOSE_CONV, itemId );
       
  3196 
       
  3197     //ask the query and send the response back to the server.
       
  3198     TInt response = VIMPSTUtilsDialog::DisplayQueryDialogL(R_GENERIC_YES_NO_CONFIRMATION_QUERY,*queryTxt);
       
  3199     CleanupStack::PopAndDestroy(queryTxt);
       
  3200 
       
  3201     if( (EAknSoftkeyYes == response)||(EAknSoftkeyOk == response ) )
       
  3202         {
       
  3203         iCommandHandler.HandleCommandL(ECloseConversation, this, &itemId ); 
       
  3204         } 
       
  3205 
       
  3206     }
       
  3207 
       
  3208 // ----------------------------------------------------
       
  3209 // CVIMPSTUiTabbedView::HandleServerAppExit
       
  3210 // ( Reserved for future use )
       
  3211 // ----------------------------------------------------
       
  3212 //
       
  3213 void CVIMPSTUiTabbedView::HandleServerAppExit( TInt /*aReason*/ )
       
  3214     {
       
  3215     TInt error = KErrNone;
       
  3216     TRAPD(leaveErr,error = ShowTermsofuseL());
       
  3217     if(KErrNone == error && KErrNone == leaveErr)
       
  3218         {
       
  3219         TRAP_IGNORE(iCommandHandler.HandleCommandL(ELoginService, this, &iServiceId)); 
       
  3220         }
       
  3221     }
       
  3222     
       
  3223 // ----------------------------------------------------
       
  3224 // CVIMPSTUiTabbedView::ShowTermsofuseL
       
  3225 // ( Reserved for future use )
       
  3226 // ----------------------------------------------------
       
  3227 //
       
  3228 TInt CVIMPSTUiTabbedView::ShowTermsofuseL()
       
  3229     {
       
  3230     TInt retVal = KErrNone;
       
  3231     // get the  ETOUDlgOff if its set don't show TOU dialog else show TOU 
       
  3232     TInt termsOfUseDisabled = KErrNone;
       
  3233     iSettingsStore->GetL(iServiceId, ETOUDlgOff, termsOfUseDisabled);
       
  3234     if( !termsOfUseDisabled)
       
  3235         {
       
  3236         HBufC* termsOfUsetext = iBrandHandler->GetToUStringL();
       
  3237         if( termsOfUsetext )
       
  3238 	        {
       
  3239 	        CleanupStack::PushL(termsOfUsetext);
       
  3240 	        retVal = CVIMPSTUiTermsOfUseDialogHandler::HandleTermsOfUseDialogLD(
       
  3241                    												*iSettingsStore,
       
  3242                    												 *iUserId, 
       
  3243                    												 iServiceId, 
       
  3244                    												 termsOfUsetext ); // termsOfUsetext ownership is transfered	
       
  3245 	        CleanupStack::Pop(); // termsOfUsetext ownership is transfered
       
  3246 	        }
       
  3247         }
       
  3248     return retVal;
       
  3249     }
       
  3250 // ----------------------------------------------------
       
  3251 // CVIMPSTUiTabbedView::MakeVoipCallL
       
  3252 // ( Reserved for future use )
       
  3253 // ----------------------------------------------------
       
  3254 //
       
  3255 void CVIMPSTUiTabbedView::MakeVoipCallL()
       
  3256     {
       
  3257     // making voip call will take in three steps
       
  3258     // pop up the selection dialog
       
  3259     // select adress
       
  3260     // create a call
       
  3261     TInt index = CurrentItemIndex();  
       
  3262     //Index should always be greater than zero
       
  3263     //Negative index means item not found.
       
  3264     if(index <= 0 )
       
  3265         {
       
  3266         return;
       
  3267         }
       
  3268     MVIMPSTProcessArray& processArray = iCommandHandler.GetProcessInterface();
       
  3269     TVIMPSTEnums::TItem itemType = processArray.GetType( index ) ;
       
  3270     
       
  3271     if( itemType == TVIMPSTEnums::EContactItem )
       
  3272         {
       
  3273         iSelectedAction = CVIMPSTUiTabbedView::ECreateXSPCall;
       
  3274         TUint fetchFlags = 0;
       
  3275         TAiwSingleItemSelectionDataV3 data;
       
  3276         data.SetFlags(fetchFlags);
       
  3277         data.SetCommAddressSelectType(EAiwCommVOIPCall);
       
  3278         ReInitializeServiceHandlerL();
       
  3279         CAiwGenericParamList& inParamList = iServiceHandler->InParamListL();
       
  3280         // Set service data
       
  3281         inParamList.AppendL(TAiwGenericParam(EGenericParamContactSelectionData,
       
  3282                 TAiwVariant(TAiwSingleItemSelectionDataV3Pckg(data))));
       
  3283 
       
  3284         HBufC8* pack = processArray.ContactLink(index )->PackLC();
       
  3285         // Set contactlink
       
  3286         inParamList.AppendL(TAiwGenericParam(EGenericParamContactLinkArray,
       
  3287                 TAiwVariant(*pack)));
       
  3288 
       
  3289         iServiceHandler->ExecuteServiceCmdL(KAiwCmdSelect, inParamList,
       
  3290                 iServiceHandler->OutParamListL(), 0, this);
       
  3291         CleanupStack::PopAndDestroy( pack );
       
  3292         }
       
  3293     else if( itemType == TVIMPSTEnums::EUnknonContactItem )
       
  3294         {
       
  3295         TPtrC unknownId = processArray.GetItemUserId( index );
       
  3296         ExecuteAiwCallL( unknownId );
       
  3297         }
       
  3298     }
       
  3299 // ---------------------------------------------------------
       
  3300 // CVIMPSTUiTabbedView::ExecuteAiwCallL
       
  3301 // ---------------------------------------------------------
       
  3302 void CVIMPSTUiTabbedView::ExecuteAiwCallL( const TDesC& aSelectedAddress )
       
  3303 	{
       
  3304 	//aSelectedAdress will be an xsp id of format "ServiceName:UserId"
       
  3305 	//here we need to truncate the servicename and pass only the UserId
       
  3306     //Find if aSelectedAdress of type "ServiceName:UserId"
       
  3307 	//if true, then remove the service part
       
  3308     TInt phoneNumberStart = aSelectedAddress.Locate(':');
       
  3309     HBufC* numBuf = NULL;
       
  3310     
       
  3311     if ( KErrNotFound != phoneNumberStart )
       
  3312         {
       
  3313         phoneNumberStart++; //To get rid of ':'
       
  3314         numBuf = aSelectedAddress.Right( 
       
  3315                                 aSelectedAddress.Length() - phoneNumberStart 
       
  3316                                 ).AllocLC();
       
  3317         }
       
  3318     else
       
  3319         {
       
  3320         numBuf = aSelectedAddress.AllocLC();
       
  3321         }
       
  3322     
       
  3323     TPtr numDesc( numBuf->Des ());
       
  3324 	CommonPhoneParser::ParsePhoneNumber ( numDesc,
       
  3325 			CommonPhoneParser::EPhoneClientNumber); 
       
  3326 
       
  3327 	CAiwDialDataExt* dialDataExt = CAiwDialDataExt::NewLC();
       
  3328 	dialDataExt->SetPhoneNumberL ( numBuf->Des ());
       
  3329     dialDataExt->SetServiceId(iServiceId);
       
  3330     dialDataExt->SetCallType( CAiwDialData::EAIWVoiP);
       
  3331 
       
  3332 	dialDataExt->SetWindowGroup ( CCoeEnv::Static()->RootWin().Identifier() );
       
  3333 	ReInitializeServiceHandlerL();
       
  3334 	CAiwGenericParamList& paramList = iServiceHandler->InParamListL();
       
  3335 	dialDataExt->FillInParamListL ( paramList);
       
  3336 	iServiceHandler->ExecuteServiceCmdL ( KAiwCmdCall, 
       
  3337 										 paramList,
       
  3338 										 iServiceHandler->OutParamListL(), 
       
  3339 										 0, 
       
  3340 										 NULL);
       
  3341 	CleanupStack::PopAndDestroy(dialDataExt);
       
  3342 	CleanupStack::PopAndDestroy(numBuf);
       
  3343 	}
       
  3344 
       
  3345 // ---------------------------------------------------------
       
  3346 // CVIMPSTUiTabbedView::LaunchHelpL()
       
  3347 // Function launches help application using the HlpLauncher.
       
  3348 // @params: Reference to a descriptor, serves as context.
       
  3349 // ---------------------------------------------------------
       
  3350 //
       
  3351 
       
  3352 void CVIMPSTUiTabbedView::LaunchHelpL( const TDesC& aContext )
       
  3353     {
       
  3354     CArrayFix< TCoeHelpContext >* cntx = new( ELeave ) CArrayFixFlat< TCoeHelpContext >( KHelpContextSize );
       
  3355     CleanupStack::PushL( cntx );
       
  3356 
       
  3357     TUid KHelpUid = { KHELPUID };
       
  3358     cntx->AppendL( TCoeHelpContext( KHelpUid, aContext ) );
       
  3359     CleanupStack::Pop( cntx );
       
  3360 
       
  3361     //and launch help - takes ownership of context array
       
  3362     HlpLauncher::LaunchHelpApplicationL( CEikonEnv::Static()->WsSession(), cntx );    
       
  3363     }
       
  3364 
       
  3365 // ----------------------------------------------------
       
  3366 // CVIMPSTUiTabbedView::SettingsStore()
       
  3367 // ----------------------------------------------------
       
  3368 //
       
  3369 MVIMPSTSettingsStore* CVIMPSTUiTabbedView::SettingsStore()
       
  3370     {
       
  3371     return iSettingsStore;
       
  3372     }
       
  3373 
       
  3374 // ----------------------------------------------------
       
  3375 // CVIMPSTUiTabbedView::CancelLoginSupportedL()
       
  3376 // ----------------------------------------------------
       
  3377 //
       
  3378 TBool CVIMPSTUiTabbedView::CancelLoginSupportedL()
       
  3379     {
       
  3380     TInt cancelNotSupported(KErrNone);
       
  3381     TBool returnValue = ETrue;
       
  3382     // read from the cenrep settings 
       
  3383     TInt err = iSettingsStore->GetL(iServiceId, EServiceCancelLoginNotSupported,cancelNotSupported);
       
  3384     // if any error  OR  cancelNotSupported = 1 then 
       
  3385     if ( err || cancelNotSupported )
       
  3386         {
       
  3387         returnValue =  EFalse; // SOME Error or cancel is not supported : return EFalse
       
  3388         }
       
  3389     return returnValue; // cancel is supported : return ETrue
       
  3390     }
       
  3391 
       
  3392 
       
  3393 // ----------------------------------------------------
       
  3394 // CVIMPSTUiTabbedView::ChangeConnectionSupportedL()
       
  3395 // ----------------------------------------------------
       
  3396 //
       
  3397 TBool CVIMPSTUiTabbedView::ChangeConnectionSupportedL()
       
  3398     {
       
  3399     TInt changeConnectionSupported(KErrNone);
       
  3400     TBool returnValue = ETrue;
       
  3401     // read from the cenrep settings 
       
  3402     TInt err = iSettingsStore->GetL(iServiceId, EServiceChangeConnectionNotSupported,changeConnectionSupported);
       
  3403     // if any error  OR  cancelNotSupported = 1 then 
       
  3404     if ( err || changeConnectionSupported )
       
  3405         {
       
  3406         returnValue =  EFalse; // SOME Error or cancel is not supported : return EFalse
       
  3407         }
       
  3408     return returnValue; // cancel is supported : return ETrue
       
  3409     }
       
  3410 
       
  3411 // ----------------------------------------------------
       
  3412 // CVIMPSTUiTabbedView::HandleNotifyL()
       
  3413 // ----------------------------------------------------
       
  3414 //
       
  3415 TInt CVIMPSTUiTabbedView::HandleNotifyL(
       
  3416         TInt aCmdId,
       
  3417         TInt aEventId,
       
  3418         CAiwGenericParamList& aEventParamList,
       
  3419         const CAiwGenericParamList& /* aInParamList */)
       
  3420 	{
       
  3421 	TInt result = 0;
       
  3422 		if( (aCmdId == KAiwCmdSelect) && (aEventId == KAiwEventCompleted && iSelectedAction == ECreateXSPCall ))
       
  3423 			{
       
  3424 			if( iQueryResult )
       
  3425 				{
       
  3426 				delete iQueryResult;
       
  3427 				iQueryResult = NULL;	
       
  3428 				}
       
  3429 			TInt index = 1; // Get field data from index 1
       
  3430 			const TAiwGenericParam* param =
       
  3431 			aEventParamList.FindFirst(index, EGenericParamContactFieldData);
       
  3432 			if (KErrNotFound != index)
       
  3433 				{
       
  3434 				TInt length = param->Value().AsDes().Length();
       
  3435 				iQueryResult = HBufC::NewL(length);
       
  3436 				iQueryResult->Des().Append( param->Value().AsDes() );
       
  3437 				// Data must be found!
       
  3438 				if (0 >= iQueryResult->Length())
       
  3439 					{
       
  3440 					User::Leave(KErrGeneral);
       
  3441 					}
       
  3442 				if( !iContactSelection )
       
  3443 					{
       
  3444 					iContactSelection = CVIMPSTUiContactSelection::NewL(*this);	//register for the contactselection
       
  3445 					}
       
  3446 				iContactSelection->IssueRequest(); 	
       
  3447 				}
       
  3448 			else
       
  3449 				{
       
  3450 				User::Leave(KErrNotFound);
       
  3451 				}
       
  3452 			result = ETrue;
       
  3453 			}
       
  3454 		
       
  3455 		else if (aCmdId == KAiwCmdAssign || aCmdId == KAiwCmdSelect )
       
  3456 		{
       
  3457 		if (aEventId == KAiwEventCompleted )
       
  3458 			{
       
  3459 			if( iSelectedAction == CVIMPSTUiTabbedView::EInvitAcceptUpdateExisting || 
       
  3460 				iSelectedAction == CVIMPSTUiTabbedView::EInvitAcceptCreateNew || 
       
  3461 				iSelectedAction == CVIMPSTUiTabbedView::EContactCreateNew ||
       
  3462 				iSelectedAction == CVIMPSTUiTabbedView::EContactAddFromContacts )
       
  3463 				{
       
  3464 				// action has been completed ,
       
  3465 				// this will be excuted only if invitation accepted using update existing contact
       
  3466 				TInt paramIndex = 0;
       
  3467 				const TAiwGenericParam* contactParam = aEventParamList.FindFirst(
       
  3468 				paramIndex, EGenericParamContactLinkArray );//get the contact link
       
  3469 				TPtrC8 packLink = contactParam->Value().AsData();
       
  3470 				delete iSelectedData.iPackedLinks;
       
  3471 				iSelectedData.iPackedLinks = NULL; 
       
  3472 				if( packLink.Length() )
       
  3473 						{
       
  3474 						iSelectedData.iPackedLinks = packLink.AllocL();
       
  3475 						if( !iContactSelection )
       
  3476 							{
       
  3477 							iContactSelection = CVIMPSTUiContactSelection::NewL(*this);	//register for the contactselection
       
  3478 							}
       
  3479 						iContactSelection->IssueRequest(); 	
       
  3480 						}
       
  3481 				}
       
  3482 			result = ETrue;
       
  3483 			}
       
  3484 		else if (aEventId == KAiwEventQueryExit)
       
  3485 		    {
       
  3486 		    // Send an exit command in order to close CCA and Phonebook2        
       
  3487 		    CAknAppUi* appUi = static_cast<CAknAppUi*>( CCoeEnv::Static()->AppUi() );
       
  3488 
       
  3489 		    if ( appUi )
       
  3490 		        {
       
  3491 		        appUi->ProcessCommandL( EAknCmdExit );
       
  3492 		        }
       
  3493 		    result = ETrue;
       
  3494 		    }
       
  3495 		else if(aEventId == KAiwEventOutParamCheck)
       
  3496 		    {
       
  3497 		        result = ETrue;
       
  3498 		    }
       
  3499 		}
       
  3500     if(aEventId == KAiwEventCanceled)
       
  3501 		{
       
  3502 		result = ETrue;
       
  3503 		}
       
  3504 	return result;
       
  3505 	}
       
  3506 // --------------------------------------------------------------------------
       
  3507 // CVIMPSTUiTabbedView::BlockContactL
       
  3508 // --------------------------------------------------------------------------
       
  3509 //
       
  3510 void CVIMPSTUiTabbedView::BlockContactL(TBool aBlock /* = EFalse */)
       
  3511     {
       
  3512     TInt index = CurrentItemIndex();
       
  3513     if(iContainer)
       
  3514         {
       
  3515         iContainer->CheckAndSetLastItemFlag();
       
  3516         }
       
  3517     if( index <= 0 )
       
  3518         {
       
  3519         // return if item not found
       
  3520         // 0 for own item which can not be blocked
       
  3521         return; 
       
  3522         }   
       
  3523          if(iWaitNote)
       
  3524              {
       
  3525              delete iWaitNote;
       
  3526              iWaitNote = NULL;
       
  3527              }
       
  3528 
       
  3529     MVIMPSTProcessArray& arrayprocess = iCommandHandler.GetProcessInterface();
       
  3530     HBufC* contactId =  arrayprocess.GetItemUserId(index).AllocLC();
       
  3531 
       
  3532     if( contactId->Length() )
       
  3533         {
       
  3534         if(aBlock )
       
  3535             {
       
  3536             // load, format and show confirmation note
       
  3537             HBufC* prompt = StringLoader::LoadLC( R_QTN_SERVTAB_BLOCKING, *contactId );
       
  3538             iWaitNote = CVIMPSTUtilsWaitNote::ShowWaitNoteL( *prompt, ETrue, EFalse );
       
  3539           //  iCommandHandler.HandleCommandL(ECmdBlockContact, this, &(contactId) );
       
  3540             iCommandHandler.HandleCommandL(ECmdBlockContact, this, contactId );
       
  3541             CleanupStack::PopAndDestroy();// prompt
       
  3542             
       
  3543         	if(iContainer)
       
  3544                 {
       
  3545                 
       
  3546 		iContainer->HandleAvatarDeleteL(*contactId);
       
  3547                 }
       
  3548             }
       
  3549         else 
       
  3550             {
       
  3551             HBufC* unBprompt = StringLoader::LoadLC( R_QTN_CHAT_UNBLOCKING, *contactId );
       
  3552             // load, format and show confirmation note
       
  3553             iWaitNote = CVIMPSTUtilsWaitNote::ShowWaitNoteL( *unBprompt, ETrue, EFalse );
       
  3554             iCommandHandler.HandleCommandL(ECmdUnBlockContact, this, contactId );
       
  3555             CleanupStack::PopAndDestroy();// unBprompt
       
  3556             }
       
  3557         }
       
  3558     CleanupStack::PopAndDestroy(); //contactId
       
  3559     } 
       
  3560     
       
  3561 // --------------------------------------------------------------------------
       
  3562 // CVIMPSTUiTabbedView::ShowBlockedContactListL
       
  3563 // --------------------------------------------------------------------------
       
  3564 void CVIMPSTUiTabbedView::ShowBlockedContactListL()
       
  3565 	{
       
  3566 	if(!iIsToolBarHidden)
       
  3567 	    {
       
  3568 	    ShowHideFixedToolbarL(EFalse);
       
  3569 	    }
       
  3570 
       
  3571 	if (iContainer)
       
  3572 		{
       
  3573 		iContainer->DeactivateFindPaneL();
       
  3574 		}
       
  3575 
       
  3576 	//Launch the search view with search dialog
       
  3577 	LaunchViewL( iExtensionService.BlockViewId() );
       
  3578 	}
       
  3579 	
       
  3580 // --------------------------------------------------------------------------
       
  3581 // CVIMPSTUiTabbedView::HandleContactSelectionCompleteL
       
  3582 // --------------------------------------------------------------------------
       
  3583 void CVIMPSTUiTabbedView::HandleContactSelectionCompleteL()
       
  3584 	{
       
  3585 	 CHAT_DP_FUNC_ENTER("CVIMPSTUiTabbedView::HandleContactSelectionCompleteL");
       
  3586 	 if( iWaitNote )
       
  3587 	        {
       
  3588 	        delete iWaitNote;
       
  3589 	        iWaitNote = NULL;
       
  3590 	        }
       
  3591      if( iSelectedAction == CVIMPSTUiTabbedView::EInvitAcceptUpdateExisting || iSelectedAction == CVIMPSTUiTabbedView::EInvitAcceptCreateNew)
       
  3592         {
       
  3593         iWaitNote = CVIMPSTUtilsWaitNote::ShowWaitNoteL( R_QTN_SERVTAB_SAVING_CONTACT, ETrue, EFalse );
       
  3594 
       
  3595         if ( iSelectedData.iPackedLinks )                     //add the selected contact to the service tab
       
  3596             {
       
  3597             CHAT_DP_FUNC_DP("CVIMPSTUiTabbedView","process contact");
       
  3598             if( iSelectedAction == CVIMPSTUiTabbedView::EInvitAcceptCreateNew )
       
  3599                    {
       
  3600                  iCommandHandler.HandleCommandL( ECmdProcessAcceptedContactNew, this, (TAny*)&iSelectedData );
       
  3601                    }
       
  3602             else
       
  3603                    {
       
  3604                  iCommandHandler.HandleCommandL( ECmdProcessAcceptedContactExist, this, (TAny*)&iSelectedData );
       
  3605                    }
       
  3606             delete iSelectedData.iPackedLinks;  
       
  3607             iSelectedData.iPackedLinks = NULL;           
       
  3608             } 
       
  3609         iSelectedData.iXSPList.ResetAndDestroy();
       
  3610        
       
  3611         //invitation has been accepted using update existing contact
       
  3612         // updation is successful
       
  3613         // send accepted request to command/engine/server   
       
  3614         CHAT_DP_FUNC_DP("HandleSessionContextEventL","frnrequest accepted");
       
  3615         iCommandHandler.HandleCommandL(EFriendAccpeted, this, iFriendRequestId );
       
  3616         }
       
  3617      else if(  iSelectedAction == CVIMPSTUiTabbedView::EContactCreateNew ||  iSelectedAction == CVIMPSTUiTabbedView::EContactAddFromContacts)
       
  3618          {
       
  3619          MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL( iEngine.ServiceId() ) ;
       
  3620          TBool localStore = EFalse;
       
  3621          if( storage )
       
  3622              {
       
  3623              localStore = storage->IsLocalStore();
       
  3624              }
       
  3625          if( localStore )//for server store wait note is shown by AddContactL function
       
  3626              {
       
  3627              if(iWaitNote)
       
  3628                  {
       
  3629                  delete iWaitNote;
       
  3630                  iWaitNote = NULL;
       
  3631                  }
       
  3632              iWaitNote = CVIMPSTUtilsWaitNote::ShowWaitNoteL( R_QTN_SERVTAB_SAVING_CONTACT, ETrue, EFalse );
       
  3633              }
       
  3634 
       
  3635          if ( iSelectedData.iPackedLinks )                     //add the selected contact to the service tab
       
  3636              {
       
  3637              CHAT_DP_FUNC_DP("CVIMPSTUiTabbedView","process contact");
       
  3638              if( iSelectedAction == CVIMPSTUiTabbedView::EContactCreateNew )
       
  3639                  {
       
  3640                  iCommandHandler.HandleCommandL( ECmdProcessSelectedContactNew, this, (TAny*)&iSelectedData );
       
  3641                  }
       
  3642              else
       
  3643                  {
       
  3644                  iCommandHandler.HandleCommandL( ECmdProcessSelectedContactExist, this, (TAny*)&iSelectedData );
       
  3645                  }
       
  3646              delete iSelectedData.iPackedLinks;  
       
  3647              iSelectedData.iPackedLinks = NULL;
       
  3648              //server store xspid will be stored in iSelectedData.iXSPList and adding it to UI
       
  3649              if( !localStore && iSelectedAction == CVIMPSTUiTabbedView::EContactAddFromContacts)
       
  3650                  {
       
  3651                  AddContactL( iSelectedData.iXSPList );
       
  3652                  }       
       
  3653              iSelectedData.iXSPList.ResetAndDestroy();
       
  3654 
       
  3655              } 
       
  3656          // this is for adding a fresh contact for local store
       
  3657 	     // read the data from link and send it to server for updation	
       
  3658          }
       
  3659 	 else if( iSelectedAction == CVIMPSTUiTabbedView::ECreateXSPCall && iQueryResult )
       
  3660 		 {
       
  3661 		 // make a call here
       
  3662 		 ExecuteAiwCallL(*iQueryResult );
       
  3663 		 delete iQueryResult;
       
  3664 		 iQueryResult = NULL;	
       
  3665 		 }
       
  3666     iSelectedAction = KErrNotFound;  // This is to clear the previous selected action.
       
  3667     CHAT_DP_FUNC_DONE("CVIMPSTUiTabbedView::HandleContactSelectionCompleteL");  
       
  3668 	}
       
  3669 
       
  3670 // --------------------------------------------------------------------------
       
  3671 // CVIMPSTUiTabbedView::LaunchSettingsViewL
       
  3672 // --------------------------------------------------------------------------
       
  3673 void CVIMPSTUiTabbedView::LaunchSettingsViewL()
       
  3674     {
       
  3675     /*
       
  3676     If settingsui is already opened, instead of starting with StartDocument just bring csc to foreground and send message
       
  3677     (csc opens correct settings ui even when itīs already open)What comes to coming back to meco tab by pressing Back in 
       
  3678     settingsui i made change that tab view is opened by using RxSPViewServices in csc side and csc is closed after that.
       
  3679     I found only one problem while testing this solution, that is if phonebook is closed when settingsui is still open. 
       
  3680     In that case settingsui stays in background, but even then when Back is pressed on settingsui correct tab is opened 
       
  3681     (phonebook is reopened using RxSPViewServices)
       
  3682     
       
  3683     **************************************************************************************
       
  3684     CSC team agreed to provide new generic CSC view launcher API, once CSC provide new API
       
  3685     below code need to remove and new API will be called.
       
  3686     ***************************************************************************************
       
  3687     */
       
  3688         
       
  3689     _LIT(KStartupParams, "ACTION=4 SERID=");
       
  3690     _LIT8(KStartupParams8, "ACTION=4 SERID=");
       
  3691     //Take CSC UID (In future if this UID change , we also need to change it otherwise we will not be able
       
  3692     //to launch CSC settings.
       
  3693     const TUid KCSCAppUid = { 0x10275458 };
       
  3694     RWsSession ws;
       
  3695     User::LeaveIfError( ws.Connect() );
       
  3696     CleanupClosePushL( ws );
       
  3697     TApaTaskList list( ws );
       
  3698 
       
  3699     TApaTask task( list.FindApp( KCSCAppUid ) );
       
  3700 
       
  3701     if ( task.Exists() )
       
  3702         {
       
  3703         TBuf8<255> params8;
       
  3704         params8.Copy( KStartupParams8 );
       
  3705         params8.AppendNum( iServiceId );
       
  3706        //Bring CSC to foreground if already open
       
  3707         task.BringToForeground();
       
  3708         task.SendMessage( 
       
  3709                 TUid::Uid( KUidApaMessageSwitchOpenFileValue ), params8 );
       
  3710         }
       
  3711     else
       
  3712         {
       
  3713         RApaLsSession session;
       
  3714         CleanupClosePushL( session );                       
       
  3715         User::LeaveIfError(session.Connect());
       
  3716 
       
  3717         TUid appUid = KCSCAppUid;
       
  3718         TThreadId threadId;
       
  3719         TFileName fileName;
       
  3720 
       
  3721         fileName.Copy( KStartupParams ); 
       
  3722         fileName.AppendNum( iServiceId );
       
  3723 
       
  3724         User::LeaveIfError(
       
  3725                 session.StartDocument( fileName, appUid, threadId ) );
       
  3726 
       
  3727         session.Close();                       
       
  3728         CleanupStack::PopAndDestroy( &session );
       
  3729         }
       
  3730 
       
  3731     CleanupStack::PopAndDestroy( &ws );
       
  3732 
       
  3733     }//End LaunchSettingsUiL() 
       
  3734 	// --------------------------------------------------------------------------
       
  3735 // CVIMPSTUiTabbedView::ReInitializeServiceHandlerL()
       
  3736 // --------------------------------------------------------------------------
       
  3737 
       
  3738 void CVIMPSTUiTabbedView::ReInitializeServiceHandlerL()
       
  3739     {
       
  3740     if(iIsServiceHandleReSet )
       
  3741         {
       
  3742         if(iServiceHandler)
       
  3743             {
       
  3744             iServiceHandler->AttachL( R_IM_APP_INTEREST );
       
  3745             iServiceHandler->AttachMenuL( R_SERVTAB_TABBED_VIEW_MENU, 
       
  3746                 R_IM_APP_INTEREST );   
       
  3747             
       
  3748             iServiceHandler->AttachL( R_AIWASSIGNMENT_INTEREST );    
       
  3749             
       
  3750             iServiceHandler->AttachL( R_AIWSELECT_INTEREST );
       
  3751             iIsServiceHandleReSet = EFalse;
       
  3752             }
       
  3753         }
       
  3754     }
       
  3755 	// --------------------------------------------------------------------------
       
  3756 	// CVIMPSTUiTabbedView::LaunchFetchDialogL()
       
  3757 	// --------------------------------------------------------------------------
       
  3758 
       
  3759 void CVIMPSTUiTabbedView::LaunchFetchDialogL()
       
  3760     {
       
  3761     iSelectedAction = EContactAddFromContacts;
       
  3762     MVIMPSTStorageServiceView* storage = CVIMPSTStorageManagerFactory::ContactListInterfaceL( iEngine.ServiceId() ) ;
       
  3763     TBool localStore = EFalse;
       
  3764     if( storage )
       
  3765         {
       
  3766         localStore = storage->IsLocalStore();
       
  3767         }
       
  3768     
       
  3769     if( localStore )
       
  3770         {
       
  3771         //multiple item fetch.
       
  3772         TUint fetchFlags = 0;
       
  3773         fetchFlags |= ::EExcludeGroupsView;
       
  3774         
       
  3775         ExecuteMultipleItemFetchL( TAiwMultipleEntrySelectionDataV2().SetFlags( fetchFlags ) );
       
  3776         }
       
  3777     else
       
  3778         {
       
  3779         //single item fetch.
       
  3780         TUint fetchFlags = 0;
       
  3781 
       
  3782         ExecuteSingleItemFetchL( TAiwSingleEntrySelectionDataV2().SetFlags( fetchFlags ) );
       
  3783         }
       
  3784 
       
  3785     }
       
  3786 	// --------------------------------------------------------------------------
       
  3787 	// CVIMPSTUiTabbedView::ExecuteSingleItemFetchL
       
  3788 	// --------------------------------------------------------------------------
       
  3789 
       
  3790 void CVIMPSTUiTabbedView::ExecuteSingleItemFetchL( TAiwSingleEntrySelectionDataV2 aData )
       
  3791     {
       
  3792     if(iAiwParamList)
       
  3793            {
       
  3794            delete iAiwParamList;
       
  3795            iAiwParamList = NULL;
       
  3796            }        
       
  3797        iAiwParamList = CAiwGenericParamList::NewL();
       
  3798        iAiwParamList->AppendL(
       
  3799             TAiwGenericParam(
       
  3800             EGenericParamContactSelectionData,
       
  3801             TAiwVariant(TAiwSingleEntrySelectionDataV2Pckg(aData))));
       
  3802 
       
  3803        ReInitializeServiceHandlerL();
       
  3804     iServiceHandler->ExecuteServiceCmdL(
       
  3805                                          KAiwCmdSelect,
       
  3806                                          *iAiwParamList,
       
  3807                                          iServiceHandler->OutParamListL(),
       
  3808                                          0,
       
  3809                                          this
       
  3810                                          );
       
  3811 
       
  3812     }
       
  3813 // --------------------------------------------------------------------------
       
  3814 // CVIMPSTUiTabbedView::ExecuteMultipleItemFetchL
       
  3815 // --------------------------------------------------------------------------
       
  3816 void CVIMPSTUiTabbedView::ExecuteMultipleItemFetchL( TAiwMultipleEntrySelectionDataV2 aData )
       
  3817     {
       
  3818     if(iAiwParamList)
       
  3819         {
       
  3820         delete iAiwParamList;
       
  3821         iAiwParamList = NULL;
       
  3822         }        
       
  3823     iAiwParamList = CAiwGenericParamList::NewL();
       
  3824     ReInitializeServiceHandlerL();
       
  3825     iAiwParamList->AppendL(
       
  3826             TAiwGenericParam(
       
  3827                     EGenericParamContactSelectionData,
       
  3828                     TAiwVariant(TAiwMultipleEntrySelectionDataV2Pckg(aData))));
       
  3829 
       
  3830   
       
  3831     iServiceHandler->ExecuteServiceCmdL(
       
  3832             KAiwCmdSelect,
       
  3833             *iAiwParamList,
       
  3834             iServiceHandler->OutParamListL(),
       
  3835             0,
       
  3836             this
       
  3837     );
       
  3838     }
       
  3839 //  End of File