imstutils/imconversationview/imcvuiapp/src/cimcvappview.cpp
changeset 0 5e5d6b214f4f
child 3 3aab497fdbb7
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     1 /*
       
     2 * Copyright (c) 2007-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:  conversation main view
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include	"cimcvappview.h"
       
    20 #include    "cimcvmenuextensionmanager.h"
       
    21 
       
    22 #include	"cimcvappviewcontainer.h"
       
    23 #include 	"cimcvappui.h"
       
    24 #include 	"cimcvengine.h"
       
    25 #include 	"mimcvenginechatinterface.h"
       
    26 #include 	"imcvuiapp.hrh"
       
    27 #include 	"imcvuiliterals.h"
       
    28 #include 	"imcvlogger.h"
       
    29 #include 	"cimcvappstatuspanehandler.h"
       
    30 #include 	"cimcvappmessageextensionshandler.h"
       
    31 #include 	"imcvuiapputils.h"
       
    32 #include 	"imcvuiappnotemapper.h"
       
    33 #include 	"mimcvenginemessagehandler.h"
       
    34 #include 	"imcvuiapp.h"
       
    35 
       
    36 #include	<aknnotewrappers.h>
       
    37 #include    <CommonUiInternalCRKeys.h>
       
    38 #include    <AknIconUtils.h>
       
    39 #include    <finditem.hrh>
       
    40 #include    <finditemmenu.h>
       
    41 #include 	<imcvuiapp.mbg>
       
    42 
       
    43 #include 	<imcvuiapp.rsg>
       
    44 #include	<imerrors.hrh>
       
    45 //brandingserver
       
    46 #include 	<mbsaccess.h>
       
    47 #include    "conversations.h"
       
    48 
       
    49 #include    <conversations.mbg>
       
    50 #include 	<StringLoader.h> 
       
    51 #include 	<aknEditStateIndicator.h>
       
    52 #include 	<AknIndicatorContainer.h>
       
    53 // help launch
       
    54 #include <hlplch.h>
       
    55 #include <coehelp.h>
       
    56 #include "meco.hlp.hrh"
       
    57 
       
    58 #include "imcvuicommonuids.h"
       
    59 #include "cimcvappmessageeditor.h"
       
    60 #include <akntoolbar.h>
       
    61 
       
    62 #include <ccafactory.h>
       
    63 #include <mccaconnection.h>
       
    64 #include <mccaparameter.h>
       
    65 #include "vimpstdetailsviewpluginuids.hrh"
       
    66 #include "mimcvenginemessagecontainerinfo.h"
       
    67 #include "mimcvenginemessageswriteinterface.h"
       
    68 #include "cimcvenginefactory.h"
       
    69 #include "mimcvenginefactory.h"
       
    70 #include <imconnectionproviderconsts.h>
       
    71 #include <e32property.h>
       
    72 
       
    73 // Dll Uid of vimpstui, to maintain uniqueness of help uid
       
    74 const TUid KHelpUid = { 0x2001FDC2 } ;  
       
    75 // ============================ MEMBER FUNCTIONS ===============================
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CIMCVAppView::CIMCVAppView()
       
    79 // C++ default constructor can NOT contain any code, that
       
    80 // might leave.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CIMCVAppView::CIMCVAppView()
       
    84     {
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CIMCVAppView::ConstructL()
       
    89 // Symbian 2nd phase constructor can leave.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CIMCVAppView::ConstructL( TInt aAvkonViewResourceId, TUid aViewId, 
       
    93              CIMCVAppMessageExtensionsHandler& aMessageHandler )
       
    94 	{
       
    95 	IM_CV_LOGS(TXT("CIMCVAppView::ConstructL() start") );
       
    96 	
       
    97 	iRTContainerCache = CIMCVAppRichTextContainerCache::NewL();
       
    98 	
       
    99 	iViewId = aViewId;
       
   100 	
       
   101 	BaseConstructL( aAvkonViewResourceId );
       
   102 
       
   103 	iExtensionHandler = &aMessageHandler;
       
   104     
       
   105     iFindContextMenu = new( ELeave ) CEikMenuBar;
       
   106     iFindContextMenu->ConstructL( this, 0, R_CONVERSATIONVIEW_MENUBAR_FINDITEMUI );
       
   107 		                  
       
   108 	iEngineFactory = CIMCVEngineFactory::InstanceL(); 
       
   109 	iEngineFactory->RegisterServiceObserver( this );
       
   110 		
       
   111 	iFindMenu = CFindItemMenu::NewL( EIMCVCmdFindMenuPlaceHolder ); 
       
   112     iFindMenu->AttachItemFinderMenuL( R_CONVERSATIONVIEW_VIEW_MENU );
       
   113     iFindMenu->AttachItemFinderMenuL( R_CONVERSATIONVIEW_MENUBAR_FINDITEMUI );
       
   114     // automatic finder on by default
       
   115     iFindMenu->HandleItemFinderCommandL( EFindItemCmdEnableAutoFind );
       
   116     iItemFinder = CItemFinder::NewL();
       
   117     
       
   118 	iAppUi = static_cast <CIMCVAppUi*> ( CCoeEnv::Static()->AppUi() );
       
   119 		
       
   120 	iRecipientUserId = HBufC::NewL(512);
       
   121 	
       
   122 	 // to set the tile, label icon in title pane
       
   123     iStatusPane = CIMCVAppStatusPaneHandler::NewL(*iEngineFactory) ;
       
   124 	
       
   125     if ( AknLayoutUtils::PenEnabled() )
       
   126         {
       
   127         Toolbar()->SetToolbarObserver(this);       
       
   128         }    
       
   129     iFromMe = NULL; 
       
   130     iToMe = NULL;
       
   131 
       
   132     //Creates manager for menu extension
       
   133     iMenuExtManager = CIMCVMenuExtensionManager::NewL();
       
   134     
       
   135     iConvViewDel = EFalse;
       
   136     iDetailViewOpen = EFalse;
       
   137 	IM_CV_LOGS(TXT("CIMCVAppView::ConstructL() end") );	
       
   138 	}
       
   139 
       
   140 // ---------------------------------------------------------
       
   141 // CIMCVAppView::~CIMCVAppView()
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 CIMCVAppView::~CIMCVAppView()
       
   145     {  
       
   146     if( iEngineFactory )
       
   147         {
       
   148         iEngineFactory->UnRegisterServiceObserver();
       
   149         iEngineFactory = NULL;
       
   150         }
       
   151    
       
   152     if(iRTContainerCache)
       
   153         {
       
   154         delete iRTContainerCache;
       
   155         }
       
   156     delete iStatusPane;
       
   157     if ( iContainer && iAppUi )
       
   158         {
       
   159         iAppUi->RemoveFromViewStack( *this, iContainer );
       
   160         delete iContainer;
       
   161         iContainer = NULL;
       
   162         }
       
   163     if ( iFindContextMenu && iAppUi )
       
   164         {
       
   165         iAppUi->RemoveFromStack( iFindContextMenu );
       
   166         }
       
   167     delete iFindContextMenu;
       
   168 
       
   169     delete iFindMenu;
       
   170     delete iItemFinder;
       
   171     delete iRecipientUserId;
       
   172 
       
   173     if(iParameter)
       
   174         {
       
   175         iParameter->Close();
       
   176         iParameter = NULL;
       
   177         }
       
   178     if(iConnection)
       
   179         {
       
   180         iConnection->Close();
       
   181         iConnection = NULL;
       
   182         }
       
   183     if(iFromMe)
       
   184         {
       
   185         delete iFromMe;
       
   186         }
       
   187     if(iToMe)
       
   188         {
       
   189         delete iToMe;
       
   190         }
       
   191     if(iMenuExtManager)
       
   192         {
       
   193         delete iMenuExtManager;
       
   194         }
       
   195     }
       
   196 
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CIMCVAppView::HandleCbaChangeL()
       
   200 // (other items were commented in a header).
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 void CIMCVAppView::HandleCbaChangeL( TInt aResourceId )
       
   204     {
       
   205    	IM_CV_LOGS(TXT("CIMCVAppView::HandleCbaChangeL() start") );
       
   206     Cba()->SetCommandSetL( aResourceId );
       
   207     Cba()->DrawNow();
       
   208     IM_CV_LOGS(TXT("CIMCVAppView::HandleCbaChangeL() end") );
       
   209     }
       
   210 
       
   211 
       
   212 // ---------------------------------------------------------
       
   213 // CIMCVAppView::DynInitMenuPaneL
       
   214 // Called when menupane is about to be shown.
       
   215 // ---------------------------------------------------------
       
   216 //
       
   217 void CIMCVAppView::DynInitMenuPaneL( 
       
   218                 TInt aResourceId,CEikMenuPane* aMenuPane )
       
   219     {    
       
   220     IM_CV_LOGS(TXT("CIMCVAppView::DynInitMenuPaneL() start") );   
       
   221     if( !iContainer )
       
   222         {
       
   223         return;
       
   224         }
       
   225     switch( aResourceId )
       
   226 	    {
       
   227 	    case R_CONVERSATIONVIEW_VIEW_MENU:
       
   228 		    {
       
   229 		    if( iContainer->Editor().Editor().TextLength() > 0 )
       
   230 			    {
       
   231 			    aMenuPane->SetItemDimmed(EIMCVCmdSend, EFalse);	
       
   232 			    }
       
   233 		    else
       
   234 			    {
       
   235 			    aMenuPane->SetItemDimmed(EIMCVCmdSend, ETrue);	
       
   236 			    }
       
   237 			// "insert smiley"            
       
   238 		    if( !iContainer->Editor().Editor().IsFocused() )
       
   239                 {
       
   240                 aMenuPane->SetItemDimmed( 
       
   241                                 EIMCVCmdSmiley, ETrue );
       
   242                 }
       
   243             else
       
   244                 {            
       
   245                 aMenuPane->SetItemDimmed( EIMCVCmdSmiley, EFalse );
       
   246                 }
       
   247             // item finder menu
       
   248             aMenuPane->SetItemDimmed( EIMCVCmdFindMenuPlaceHolder, ETrue);
       
   249             
       
   250             if( iContainer->IsStopped() )
       
   251                 {
       
   252                 UpdateItemTypeL();            
       
   253                 iFindMenu->AddItemFindMenuL( iItemFinder, aMenuPane, 
       
   254                     EIMCVCmdFindMenuPlaceHolder, 
       
   255                     KNullDesC ); // we can ignore the sender here
       
   256                 }   
       
   257             //offers CV MenuPane to plugins to add their options
       
   258             iMenuExtManager->OfferMenuPaneToPlugins(EIMCVCmdSmiley,*aMenuPane,iServiceId);
       
   259 		    break;	
       
   260 		    }
       
   261 	    case R_CONVERSATIONVIEW_FINDITEMUI_MENU :       
       
   262 	        {
       
   263             if( iContainer->IsStopped() )
       
   264                 {
       
   265                 UpdateItemTypeL();            
       
   266                 iFindMenu->AddItemFindMenuL( iItemFinder, aMenuPane, 
       
   267                     EIMCVCmdFindMenuPlaceHolder,
       
   268                     KNullDesC, // we can ignore the sender here
       
   269                     EFalse, ETrue ); // context menu
       
   270                 }
       
   271             break;
       
   272             }
       
   273 	    
       
   274 		default:
       
   275             {
       
   276             // update find menu
       
   277             iFindMenu->UpdateItemFinderMenuL( aResourceId, aMenuPane );
       
   278             break;
       
   279             }
       
   280 	
       
   281 	    }
       
   282     IM_CV_LOGS(TXT("CIMCVAppView::DynInitMenuPaneL() end") );
       
   283     }
       
   284     
       
   285 
       
   286 // --------------------------------------------------------------------------
       
   287 // CVIMPSTCmdCCA::LaunchCcaL
       
   288 // --------------------------------------------------------------------------
       
   289 //
       
   290 void CIMCVAppView::LaunchCcaL()
       
   291     {   
       
   292 
       
   293 
       
   294     if(!iConnection)
       
   295         {
       
   296         iConnection = TCCAFactory::NewConnectionL();
       
   297         }
       
   298 
       
   299     if ( iParameter )
       
   300         {
       
   301         iParameter->Close();
       
   302         iParameter = NULL;
       
   303         }
       
   304 
       
   305     // The lifetime of this cmd object is too short to hold
       
   306     // iParameterRef, caller of this must own it    
       
   307     iParameter = TCCAFactory::NewParameterL();
       
   308     iParameter->SetConnectionFlag(MCCAParameter::ENormal);
       
   309     iParameter->SetContactDataFlag(MCCAParameter::EContactLink);
       
   310 
       
   311     TUid uid( TUid::Null() );
       
   312     uid.iUid = KVIMPSTDetailsViewPluginImplmentationUid  + iServiceId ; // service details view implementation uid
       
   313     iParameter->SetLaunchedViewUid( uid );
       
   314 
       
   315    // RProperty::Set(KMeCoPropertyUid, KMeCoConvViewServiceIdKey, iServiceId ); 
       
   316     MIMCVEngineMessageReadInterface& readInterface = 
       
   317         		iActiveChatInterface->MessageReadInterfaceL( iServiceId, *iRecipientUserId );
       
   318     HBufC8* link8 = readInterface.ContactLink().AllocLC();
       
   319     HBufC16* link16 = HBufC16::NewLC( link8->Length() );
       
   320     link16->Des().Copy( *link8 );
       
   321     iParameter->SetContactDataL( *link16 );
       
   322     CleanupStack::PopAndDestroy( 2 );  //pop and destroy link8 and link16
       
   323 
       
   324     // Sync call
       
   325     iConnection->LaunchApplicationL(*iParameter);
       
   326     
       
   327     iDetailViewOpen = ETrue;
       
   328     }
       
   329 // ---------------------------------------------------------
       
   330 // CIMCVAppView::HandleCommandL(TInt aCommand)
       
   331 // Handles commands
       
   332 // (other items were commented in a header).
       
   333 // ---------------------------------------------------------
       
   334 //
       
   335 void CIMCVAppView::HandleCommandL( TInt aCommand )
       
   336     {
       
   337     IM_CV_LOGS(TXT("CIMCVAppView::HandleCommandL() start") );
       
   338     
       
   339     //Offer commands to menu extension plugins
       
   340     if(iMenuExtManager->OfferHandleCommandToPlugins(aCommand))
       
   341         {
       
   342         //command is executed, hence return.
       
   343         return;
       
   344         }
       
   345     
       
   346     switch ( aCommand )
       
   347     	{
       
   348     	
       
   349     	case EIMCVCmdToolbarDetails:
       
   350     	    //Launch the cca
       
   351     	    LaunchCcaL();
       
   352     	    break;
       
   353     	// flow through
       
   354     	case EIMCVCmdSend:
       
   355     	case EIMCVCmdToolbarSend:
       
   356     	case EAknSoftkeySend:
       
   357 			{
       
   358 			if( iContainer )
       
   359 			    {
       
   360 			    iContainer->SendMessageL();
       
   361 			    }
       
   362 		   	break;
       
   363         	}
       
   364     	case EIMCVCmdToolbarInsertSmiley:	
       
   365     	case EIMCVCmdSmiley	:
       
   366 			{			
       
   367 			TBool dialogCancelled = EFalse;
       
   368 			TSize size (iContainer->TextRect ().Height(), iContainer->TextRect ().Height() );
       
   369 			iContainer->SmileyDialogLaunched (ETrue);
       
   370 			iExtensionHandler->InsertExtensionL( iContainer->Editor().Editor(), 
       
   371 												iServiceId,
       
   372 	                                           EMessageExtensionSmiley,
       
   373 	                                           dialogCancelled,
       
   374 	                                           size);
       
   375 	        iContainer->UpdateCbaL();
       
   376 	        // Resize icons, use reading pane text line element as parent
       
   377 	        
       
   378 	        if ( !dialogCancelled )
       
   379 	            {
       
   380 	            iContainer->RefreshEditorL();
       
   381 	            iContainer->Editor().SetFocus(ETrue);
       
   382 	            }
       
   383 			iContainer->SmileyDialogLaunched (EFalse);
       
   384 			iContainer->UpdateChatViewL();
       
   385 	            
       
   386 			break;
       
   387 			}
       
   388     	case EIMCVCmdCloseConversation:
       
   389 	    	{
       
   390             HBufC* queryTxt = StringLoader::LoadLC( R_CHAT_CQUERY_CLOSE_CONV, *iRecipientUserId );
       
   391             TInt response = DisplayQueryDialogL(
       
   392                                                 R_GENERIC_YES_NO_CONFIRMATION_QUERY,
       
   393                                                 *queryTxt );
       
   394             CleanupStack::PopAndDestroy( queryTxt );                             
       
   395             if(response)
       
   396                 { 
       
   397                 iViewDeactivated = ETrue;
       
   398                 TInt error = iContainer->CloseConversationL( *iRecipientUserId );
       
   399                 iActiveChatInterface->DeleteChatL( iServiceId, *iRecipientUserId );
       
   400                 ViewRefreshL();
       
   401                 // set this to KNullDesC since conversation is getting closed.
       
   402                 iRecipientUserId->Des().Copy( KNullDesC());
       
   403                 // after closing conversation application will go to servicetab
       
   404                 if( error== KErrNone )
       
   405                     {
       
   406                     iAppUi->HandleCommandL( EAknSoftkeyBack );
       
   407                     }
       
   408                 }
       
   409 	    	break;	
       
   410 	    	} 
       
   411         	// flow through
       
   412         case EFindItemCmdEnableAutoFind:
       
   413         case EFindItemCmdDisableAutoFind:
       
   414             {
       
   415             if( iContainer )
       
   416                 {
       
   417                 iContainer->SetItemHighlightL( 
       
   418                         aCommand == EFindItemCmdEnableAutoFind );
       
   419                 iFindMenu->HandleItemFinderCommandL( aCommand );
       
   420                 if( MenuBar()->IsDisplayed() )
       
   421                     {
       
   422                     MenuBar()->StopDisplayingMenuBar();
       
   423                     }
       
   424                 if( iFindContextMenu->IsDisplayed() )
       
   425                     {
       
   426                     iFindContextMenu->StopDisplayingMenuBar();
       
   427                     }
       
   428                 }
       
   429             break;
       
   430             }
       
   431         case EIMCVCmdCall:
       
   432             {
       
   433             UpdateItemTypeL();
       
   434             CItemFinder::CFindItemExt& item = iItemFinder->CurrentItemExt();
       
   435             if(item.iItemType == CItemFinder::EEmailAddress)
       
   436                 {
       
   437                 iFindMenu->HandleVoIPCallL( *iItemFinder->CurrentItemExt().iItemDescriptor );
       
   438                 }
       
   439             else
       
   440                 {
       
   441                 iFindMenu->HandleCallL( *iItemFinder->CurrentItemExt().iItemDescriptor );
       
   442                 }
       
   443             break;
       
   444             }      
       
   445 	    case EAknCmdHelp:
       
   446 	    	{
       
   447 	    	LaunchHelpL( KSERVTAB_HLP_CONVERSATION );
       
   448 	    	break;	
       
   449 	    	} 
       
   450 
       
   451 	    case EEikCmdExit:
       
   452 	    case EAknSoftkeyExit:
       
   453 	    case EAknCmdExit:
       
   454 	    case EAknSoftkeyBack:
       
   455 			{
       
   456 			iViewDeactivated = ETrue;
       
   457 			if( iFindMenu->CommandIsValidL( aCommand ) )
       
   458 			    {
       
   459 			    iFindMenu->HandleItemFinderCommandL( aCommand );
       
   460 			    }
       
   461 			iContainer->StoreEditorMessageL();
       
   462 			ViewRefreshL();
       
   463 			iAppUi->HandleCommandL( aCommand );   		
       
   464 			break;	
       
   465 			}
       
   466     
       
   467         default:
       
   468             {
       
   469             //As per new UI spec change own status is not avilable in conversation
       
   470             //view menu  
       
   471              // check if it is find menu command
       
   472             if( iFindMenu->CommandIsValidL( aCommand ) )
       
   473                 {
       
   474                 Toolbar()->HideItemsAndDrawOnlyBackground(ETrue);
       
   475                 iFindMenu->HandleItemFinderCommandL( aCommand );
       
   476                 Toolbar()->HideItemsAndDrawOnlyBackground(EFalse);
       
   477 
       
   478                 }
       
   479             else
       
   480 	            {
       
   481 	            iAppUi->HandleCommandL( aCommand );
       
   482 	            }
       
   483                            
       
   484             break;
       
   485             }
       
   486     	}
       
   487     IM_CV_LOGS(TXT("CIMCVAppView::HandleCommandL() end") );	
       
   488     }
       
   489 
       
   490 // ---------------------------------------------------------
       
   491 // CIMCVAppView::HandleForegroundEventL
       
   492 // (other items were commented in a header).
       
   493 // ---------------------------------------------------------
       
   494 //
       
   495 void CIMCVAppView::HandleForegroundEventL( TBool aForeground )
       
   496     {
       
   497     IM_CV_LOGS(TXT("CIMCVAppView::HandleForegroundEventL() start") );   
       
   498   
       
   499     if(aForeground && iDetailViewOpen)
       
   500         {
       
   501         iDetailViewOpen = EFalse;
       
   502         }
       
   503     
       
   504     if(iConvViewDel)
       
   505         {
       
   506         TApaTask task(iEikonEnv->WsSession());
       
   507         task.SetWgId( CEikonEnv::Static()->RootWin().Identifier());
       
   508         task.SendToBackground();
       
   509         iConvViewDel = EFalse;
       
   510         return;
       
   511         }
       
   512     
       
   513     if (!aForeground)
       
   514 	    {	    
       
   515 	    if (iStatusPane)
       
   516 		    {
       
   517 		    iStatusPane->SendBackGroundL();
       
   518 		    }
       
   519 	    iViewDeactivated = ETrue;
       
   520 		}
       
   521 	else
       
   522 		{
       
   523 		SetStatusPaneIconsL();
       
   524 		if (iStatusPane)
       
   525 		    {
       
   526 		    iStatusPane->BringToForegroundL();
       
   527 		    }		
       
   528 		iViewDeactivated = EFalse;	
       
   529 		}			    	
       
   530 
       
   531     if( iContainer )
       
   532         {
       
   533         //don't read messages if we're not in foreground
       
   534      //   iContainer->FetchMessages( aForeground );
       
   535         }
       
   536         
       
   537     IM_CV_LOGS(TXT("CIMCVAppView::HandleForegroundEventL() end") );
       
   538     }
       
   539 
       
   540     
       
   541 
       
   542 // ---------------------------------------------------------
       
   543 // CIMCVAppView::DoActivateL(...)
       
   544 // Handles view activation
       
   545 // (other items were commented in a header).
       
   546 // ---------------------------------------------------------
       
   547 //
       
   548 void CIMCVAppView::DoActivateL(
       
   549         const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/,
       
   550         const TDesC8& aCustomMessage)
       
   551     {
       
   552     IM_CV_LOGS(TXT("CIMCVAppView::DoActivateL() start") );
       
   553     // Register switch back if conversation view is opened from phonebook im service tab
       
   554     // in case if something lost
       
   555 	
       
   556     ActivateViewL(ViewId());    
       
   557     
       
   558     
       
   559     TPckgBuf<TIMCVUiParams> params;
       
   560     params.Copy( aCustomMessage );
       
   561 
       
   562     //Get the service id  - this property is published by imcvlauncher
       
   563      TInt error = RProperty::Get( KMeCoPropertyUid, KMeCoConvViewServiceIdKey, iServiceId );
       
   564      User::LeaveIfError(error);
       
   565       
       
   566     TPtrC recieptId = params().iBuddyId;
       
   567     TPtrC buddyName = params().iBuddyName;
       
   568     TPtrC8 contactlinkPtr = params().iContactLink;
       
   569     //CCH has logged in, but conversation is not binded to the connection
       
   570     //so we need to login in conversation view, for the user to use this  view to 
       
   571     //send the message  
       
   572     iActiveEngine = &iEngineFactory->GetServiceEngineL( iServiceId );
       
   573     iActiveEngine->ResolveServiceStateL();    
       
   574 	/* Get the active chat recipient id from the engine factory so that we check if 
       
   575 	   container should switch */
       
   576 	
       
   577 	TPtrC activeRecipientId = iEngineFactory->GetActiveItemL ();
       
   578    	// store previous view details if launch from service tab
       
   579     iAppUi->StorePreviousViewDetails(params().iAppUid, params().iViewUid ); 
       
   580     
       
   581 	iRecipientUserId->Des().Copy(recieptId);
       
   582     
       
   583     // subscribe for presence notification
       
   584     if ( iActiveEngine->IsLoggedIn() )
       
   585 	    {
       
   586 	    IM_CV_LOGS(TXT("CIMCVAppView::DoActivateL() LOGGED IN..  BEFORE subscribing.. *****************") );
       
   587 	    iActiveEngine->MessageHandler().SubscribePresenceL( recieptId );
       
   588 		IM_CV_LOGS(TXT("CIMCVAppView::DoActivateL() LOGGED IN..  AFTER subscribing.. *****************") );
       
   589 	    }
       
   590     iActiveChatInterface = &iActiveEngine->ChatInterface();
       
   591     // To prevent looping between this view and refresh view
       
   592     // resolve message read interface
       
   593     MIMCVEngineMessageReadInterface& readInterface = 
       
   594         iActiveChatInterface->MessageReadInterfaceL( iServiceId, *iRecipientUserId, buddyName, contactlinkPtr );
       
   595     MIMCVEngineMessageWriteInterface& writeInterface = 
       
   596         iActiveChatInterface->MessageWriteInterfaceL( iServiceId, *iRecipientUserId, buddyName, contactlinkPtr );
       
   597     
       
   598     TPtrC displayId = readInterface.Name();   
       
   599     
       
   600     if (iStatusPane)
       
   601 		{		
       
   602 		iStatusPane->SetTitleL( displayId );
       
   603 		//hide navi pane decorators
       
   604   
       
   605     	iStatusPane->IMessageIndicator()->AddObserver( this );
       
   606     	//if activation is from contact list and not from switching between
       
   607 	    //tabs then create tabs and show them
       
   608 		iStatusPane->ShowTabGroupL( iRecipientUserId->Des());
       
   609 		iStatusPane->AddObserver(this) ;	
       
   610 		}
       
   611         SetStatusPaneIconsL();
       
   612     // When forwarding from contact to contact DoDeactivate is never called.
       
   613     // We have to cleanup the necessary stuff ourself.
       
   614 
       
   615    	if( !iContainer )
       
   616         {
       
   617         iContainer = CIMCVAppViewContainer::NewL( ClientRect(),iActiveEngine,
       
   618                                         &readInterface,&writeInterface, 
       
   619                                         this, *iExtensionHandler,Cba(),
       
   620                                         *iRecipientUserId,this, iRTContainerCache,
       
   621                                         iFromMe, iToMe);    
       
   622 		iAppUi->AddToViewStackL( *this, iContainer );
       
   623 		iAppUi->AddToStackL( *this, iFindContextMenu, ECoeStackPriorityDefault, 
       
   624 							  ECoeStackFlagRefusesFocus );
       
   625 
       
   626 		IM_CV_LOGS(TXT("CIMCVAppView::DoActivateL() creating iContainer") );
       
   627 
       
   628         }
       
   629 	else 
       
   630 		{
       
   631 			IM_CV_LOGS(TXT("CIMCVAppView::DoActivateL() CONTAINER exist******************************") );
       
   632 			// If the recipient ID does not match the active chat, then switch the container */
       
   633 			if (0 != recieptId.Compare(activeRecipientId))
       
   634 				{
       
   635 				IM_CV_LOGS(TXT("CIMCVAppView::DoActivateL() SWITCHING TAB ******************************") );
       
   636 				iContainer->SwitchViewL (&readInterface, &writeInterface, recieptId);
       
   637 				}
       
   638 		}
       
   639 	// Restore find state
       
   640     TInt findState = IMCVUiAppUtils::CRKeyL( KCRUidCommonUi, KCuiAutomaticHighlight );
       
   641     iContainer->SetItemHighlightL( findState );
       
   642     
       
   643 
       
   644     // start a conversation since we have single conversation at a time
       
   645 
       
   646   	iContainer->StartConversationL ();
       
   647 
       
   648    readInterface.SetActive (ETrue);
       
   649    	if( recieptId == KNullDesC )
       
   650 	    {
       
   651 	    // open from idle 
       
   652 	    // not valid user id selected
       
   653 	    // Construct view identification for buddylist view activation
       
   654 		// launch servicetab for buddy list selection
       
   655 		TVwsViewId viewIdentification(KPhonebook2AppUid,KUidIMServiceTabViewUid );
       
   656 		ActivateViewL( viewIdentification );
       
   657 		// close cv ,no user defined for this
       
   658 	    iAppUi->ShutDownAndCloseApplicationL();	
       
   659 	    }
       
   660    	MenuBar()->SetContextMenuTitleResourceId( R_CONVERSATIONVIEW_MENUBAR_FINDITEMUI );   
       
   661    	UpdateToolbarButtonsStateL();
       
   662     IM_CV_LOGS(TXT("CIMCVAppView::DoActivateL() end") );
       
   663     }
       
   664 
       
   665 // ---------------------------------------------------------
       
   666 // CIMCVAppView::HandleCommandL()
       
   667 // Handles view deactivation
       
   668 // ---------------------------------------------------------
       
   669 //
       
   670 void CIMCVAppView::DoDeactivate()
       
   671     {
       
   672     IM_CV_LOGS(TXT("CIMCVAppView::DoDeactivate() start") );	
       
   673     //TSW bug Id - KBAA-6TM946
       
   674 	if (iStatusPane)
       
   675 		{
       
   676 		iStatusPane->RemoveObserver(this);
       
   677 		iStatusPane->IMessageIndicator()->AddObserver( NULL );
       
   678 	    iStatusPane->HideFadeText();		
       
   679 		}
       
   680 		
       
   681     if ( iContainer )
       
   682 		{            
       
   683 		iAppUi->RemoveFromViewStack( *this, iContainer );
       
   684 		// not in a middle of sending message
       
   685 		delete iContainer;
       
   686 		iContainer = NULL;
       
   687 		      
       
   688 		}
       
   689      if ( iFindContextMenu )
       
   690         {
       
   691         iAppUi->RemoveFromViewStack( *this, iFindContextMenu );
       
   692         }
       
   693    
       
   694      IM_CV_LOGS(TXT("CIMCVAppView::DoDeactivate() end") );
       
   695      }
       
   696 
       
   697 // ---------------------------------------------------------
       
   698 // CIMCVAPPView::Id()
       
   699 // (other items were commented in a header).
       
   700 // ---------------------------------------------------------
       
   701 //
       
   702 TUid CIMCVAppView::Id() const
       
   703 	{
       
   704 	return iViewId;
       
   705 	}
       
   706 // ---------------------------------------------------------
       
   707 // CIMCVAppView::ActiveEngine()
       
   708 // (other items were commented in a header).
       
   709 // ---------------------------------------------------------
       
   710 //
       
   711 CIMCVEngine& CIMCVAppView::ActiveEngine() const
       
   712     {
       
   713     return *iActiveEngine;
       
   714     }
       
   715 // ---------------------------------------------------------
       
   716 // CIMCVAppView::SetStatusPaneIconsL()
       
   717 // (other items were commented in a header).
       
   718 // ---------------------------------------------------------
       
   719 //
       
   720 void CIMCVAppView::SetStatusPaneIconsL()
       
   721 	{
       
   722 	IM_CV_LOGS(TXT("CIMCVAppView::SetStatusPaneIconsL() Start ") );
       
   723 	if(! iStatusPane )
       
   724 		{
       
   725 		return;			
       
   726 		}
       
   727 	
       
   728 	if (!iActiveEngine)
       
   729 		return;
       
   730 	// if the status is EServiceOut then no need to set the icon, only title needs to be set.
       
   731 	if(EServiceOut == iActiveEngine->MessageHandler().GetPresenceStatus())
       
   732 	    {
       
   733 	    return;
       
   734 	    }
       
   735 	// Load status icon
       
   736 	CGulIcon* connStatusIcon = 	LoadBitmapL( );
       
   737 	connStatusIcon->SetBitmapsOwnedExternally( EFalse );
       
   738 	CleanupStack::PushL( connStatusIcon );
       
   739 
       
   740 	// in portrait mode we are setting the status icon to status pane
       
   741 	iStatusPane->SetPicture( connStatusIcon->Bitmap(), 
       
   742 										 connStatusIcon->Mask() 
       
   743 										 );
       
   744 	// ownership was transferred
       
   745 	connStatusIcon->SetBitmapsOwnedExternally( ETrue );    
       
   746 
       
   747 	CleanupStack::PopAndDestroy( connStatusIcon );
       
   748 	
       
   749 	IM_CV_LOGS(TXT("CIMCVAppView::SetStatusPaneIconsL() End ") );
       
   750 	}
       
   751 
       
   752 // -----------------------------------------------------------------------------
       
   753 // CIMCVAppView::LoadDefaultBitmapL
       
   754 // (other items were commented in a header).
       
   755 // -----------------------------------------------------------------------------
       
   756 //
       
   757 CGulIcon* CIMCVAppView::LoadBitmapL( )
       
   758 	{
       
   759 	IM_CV_LOGS(TXT("CIMCVAppView::LoadBitmapL() Start ") );
       
   760 	CGulIcon* gulIcon;
       
   761 	HBufC8* brandIconId = HBufC8::NewLC(KVIMPSTUISPSMaxPropertyLength);
       
   762 	TPtr8 brandIconIdPtr = brandIconId->Des();
       
   763 	TIMCVOnlineStatus status = 	iActiveEngine->MessageHandler().GetPresenceStatus();
       
   764 	// default offline
       
   765 	switch( status ) 
       
   766 		{
       
   767 		case EOnline:
       
   768 			{
       
   769 			brandIconIdPtr.Copy(KEMbmConversationsQgnpropimfriendon);
       
   770 			break;	
       
   771 			}
       
   772 		case EInvisible:
       
   773 			{
       
   774 			brandIconIdPtr.Copy(KEMbmConversationsQgnpropimfriendinvisible);	
       
   775 			break;	
       
   776 			}
       
   777 		case EAway:
       
   778 			{
       
   779 			brandIconIdPtr.Copy(KEMbmConversationsQgnpropimfriendaway);		
       
   780 			break;	
       
   781 			}
       
   782 		case EBusy:
       
   783 		case EDoNotDisturb:
       
   784 			{
       
   785 			brandIconIdPtr.Copy(KEMbmConversationsQgnpropimfriendbusy);
       
   786 			break;	
       
   787 			}
       
   788 		case EOnPhone:
       
   789 			{
       
   790 			brandIconIdPtr.Copy(KEMbmConversationsQgnpropimfriendonmobile);
       
   791 			break;	
       
   792 			}
       
   793 		case EBlock:
       
   794 		    {
       
   795 		     brandIconIdPtr.Copy(KEMbmConversationsQgnpropimuserblocked);	 
       
   796 		    break;
       
   797 		    }
       
   798 		case ECallForward:
       
   799 		    {
       
   800 		    brandIconIdPtr.Copy(KEMbmConversationsQgnpropimusercallforward);  
       
   801 		    break;
       
   802 		    }
       
   803 		case EOffline :
       
   804 		default:
       
   805 			{
       
   806 			brandIconIdPtr.Copy(KEMbmConversationsQgnpropimfriendoff);
       
   807 			// offline only
       
   808 			}
       
   809 		}
       
   810 
       
   811 
       
   812     IM_CV_LOGS(TXT("CIMCVAppView::LoadBitmapL()::if(iAppUi->BrandingAccess()) Start ") );    
       
   813     gulIcon = iActiveEngine->GetPresenceIconL( *brandIconId );
       
   814     IM_CV_LOGS(TXT("CIMCVAppView::LoadBitmapL()::if(iAppUi->BrandingAccess()) End ") );
       
   815 
       
   816     CleanupStack::PopAndDestroy(brandIconId);
       
   817     IM_CV_LOGS(TXT("CIMCVAppView::LoadBitmapL() End ") );
       
   818     return gulIcon;
       
   819     }
       
   820 
       
   821 // ---------------------------------------------------------
       
   822 // CIMCVAppView::UpdateItemTypeL
       
   823 // (other items were commented in a header).
       
   824 // ---------------------------------------------------------
       
   825 //
       
   826 void CIMCVAppView::UpdateItemTypeL()
       
   827     {    
       
   828     if( !iContainer )
       
   829         {
       
   830         return;
       
   831         }
       
   832     CItemFinder::CFindItemExt& item = iItemFinder->CurrentItemExt();
       
   833     switch(  iContainer->SelectedItemType() )
       
   834         {
       
   835         case CFindItemEngine::EFindItemSearchPhoneNumberBin:
       
   836             {
       
   837             item.iItemType = CItemFinder::EPhoneNumber;
       
   838             break;
       
   839             }                
       
   840         case CFindItemEngine::EFindItemSearchMailAddressBin:
       
   841             {
       
   842             item.iItemType = CItemFinder::EEmailAddress;
       
   843             break;
       
   844             }
       
   845         case CFindItemEngine::EFindItemSearchURLBin:
       
   846             {
       
   847             item.iItemType = CItemFinder::EUrlAddress;
       
   848             break;
       
   849             }
       
   850         case CFindItemEngine::EFindItemSearchScheme:
       
   851             {
       
   852             item.iItemType = CItemFinder::EUriScheme;
       
   853             break;
       
   854             }
       
   855         case KErrNotFound:  // flowthrough
       
   856         default:
       
   857             {
       
   858             item.iItemType = CItemFinder::ENoneSelected;
       
   859             break;
       
   860             }    
       
   861         }
       
   862     delete item.iItemDescriptor;
       
   863     item.iItemDescriptor = NULL;
       
   864     item.iItemDescriptor = iContainer->SelectedItemL();  // takes the ownership
       
   865     
       
   866     // this logic comes from CItemFinder::ResolveAndSetItemTypeL.
       
   867     // should be in ItemFinder engine, but for some reason it isn't,
       
   868     // so, next few lines are copypasted from AknItemFinder.cpp..    
       
   869     if( item.iItemType == CItemFinder::EUrlAddress ) 
       
   870         { 
       
   871         // old url types need prefix in order to work w/ schemehandler
       
   872         const TDesC& pref = item.iItemDescriptor->Des().Left( 4 );
       
   873         
       
   874 		//fix for bug id  TJUO-79NETM ( Instant Messaging - 
       
   875 		// IM opening rtsp link from message don't work)		
       
   876 		//To avoid adding :http://" to rtsp links, we check it before it is done
       
   877 		//and return. 
       
   878         if (pref.CompareF (KIMRTSP().Left (4)) == 0)
       
   879 	        {
       
   880         	return;
       
   881 	        }
       
   882         
       
   883         if ( pref.CompareF( KIMHTTPPREFIX().Left( 4 ) ) != 0 )
       
   884             {
       
   885             HBufC* tmp = item.iItemDescriptor->ReAlloc( 
       
   886                         item.iItemDescriptor->Length() + KIMHTTPPREFIX().Length() );
       
   887             if( tmp )
       
   888                 {
       
   889                 // realloc succeeded
       
   890                 item.iItemDescriptor = tmp;
       
   891                 item.iItemDescriptor->Des().Insert( 0, KIMHTTPPREFIX );
       
   892                 }
       
   893             }        
       
   894         }
       
   895     if( item.iItemType == CItemFinder::EUriScheme )
       
   896         {
       
   897         // some schemes (ie. "old ones") have special handling 
       
   898         const TDesC& pref = item.iItemDescriptor->Des().Left( 4 );
       
   899         if ( pref.CompareF( KIMHTTPPREFIX().Left( 4 ) ) == 0 
       
   900             || pref.CompareF( KIMRTSP ) == 0 )
       
   901             {
       
   902             item.iItemType = CItemFinder::EUrlAddress;
       
   903             }
       
   904         }
       
   905     }
       
   906 
       
   907 // -----------------------------------------------------------------------------
       
   908 // CIMCVAppView::DisplayQueryDialogL
       
   909 // (other items were commented in a header).
       
   910 // -----------------------------------------------------------------------------
       
   911 //
       
   912 TInt CIMCVAppView::DisplayQueryDialogL( TInt aDialogResourceId, 
       
   913             							const TDesC& aPrompt )
       
   914 	{
       
   915 	CAknQueryDialog* dlg = new (ELeave) CAknQueryDialog(
       
   916 											CAknQueryDialog::ENoTone );
       
   917 	CleanupStack::PushL( dlg );
       
   918 	if( aPrompt != KNullDesC )
       
   919 		{		
       
   920 		dlg->SetPromptL( aPrompt );		
       
   921 		}
       
   922 	CleanupStack::Pop( dlg );
       
   923 	return dlg->ExecuteLD( aDialogResourceId );
       
   924 	}
       
   925     
       
   926 // ---------------------------------------------------------
       
   927 // CIMCVAppView::ShowPopUpMenuL()
       
   928 // This method shows popup menu
       
   929 // (other items were commented in a header).
       
   930 // ---------------------------------------------------------
       
   931 //
       
   932 void CIMCVAppView::ShowPopUpMenuL( )
       
   933     {
       
   934     if( iContainer && iContainer->SelectedItemType() != KErrNotFound )
       
   935         {
       
   936 #ifndef RD_30_DISABLE_TOUCH
       
   937         MenuBar()->StopDisplayingMenuBar();
       
   938         MenuBar()->TryDisplayContextMenuBarL();
       
   939 #else
       
   940         iFindContextMenu->StopDisplayingMenuBar();
       
   941         iFindContextMenu->TryDisplayMenuBarL();
       
   942 #endif
       
   943         }
       
   944     }
       
   945 
       
   946 // ---------------------------------------------------------
       
   947 // CIMCVAppView::SwitchTabL
       
   948 // (other items were commented in a header).
       
   949 // ---------------------------------------------------------
       
   950 //
       
   951 void CIMCVAppView::SwitchTabL(TInt aActiveServiceId ,const TDesC& aChatId, const TInt /*aTabIndex*/)
       
   952 	{
       
   953 	//change the contact id based on tteh currenttab    	
       
   954 	iRecipientUserId->Des().Copy(aChatId);
       
   955     if( aActiveServiceId != iServiceId )
       
   956         {
       
   957         SwitchToValidServiceL( aActiveServiceId );
       
   958         }
       
   959     // subscribe for presence notification
       
   960     if (iActiveEngine->IsLoggedIn())
       
   961 	    {
       
   962 	    iActiveEngine->MessageHandler().SubscribePresenceL( aChatId );
       
   963 	    }
       
   964     // To prevent looping between this view and refresh view
       
   965     // resolve message read interface
       
   966     MIMCVEngineMessageReadInterface& readInterface = 
       
   967         iActiveChatInterface->MessageReadInterfaceL( iServiceId, *iRecipientUserId );
       
   968     MIMCVEngineMessageWriteInterface& writeInterface = 
       
   969     iActiveChatInterface->MessageWriteInterfaceL( iServiceId, *iRecipientUserId );
       
   970                 
       
   971    	TPtrC displayId = readInterface.Name();
       
   972     
       
   973     if (iStatusPane)
       
   974 	    {
       
   975 	    iStatusPane->SetTitleL( displayId );
       
   976 	    }
       
   977     SetStatusPaneIconsL();
       
   978     
       
   979     //remove the controls from view stack
       
   980     if ( iContainer )
       
   981         {            
       
   982         iAppUi->RemoveFromViewStack( *this, iContainer );        
       
   983         }
       
   984 
       
   985     if ( iFindContextMenu )
       
   986         {
       
   987         iAppUi->RemoveFromViewStack( *this, iFindContextMenu );
       
   988         }
       
   989 	
       
   990 	//again add those controls to view stack
       
   991 	if ( iContainer )
       
   992         {
       
   993         iContainer->SwitchViewL(&readInterface, &writeInterface, *iRecipientUserId );            
       
   994         iAppUi->AddToViewStackL( *this, iContainer );      
       
   995         }
       
   996     
       
   997     if ( iFindContextMenu )
       
   998         {
       
   999         iAppUi->AddToStackL( *this, iFindContextMenu, ECoeStackPriorityDefault, 
       
  1000                           ECoeStackFlagRefusesFocus );
       
  1001         }
       
  1002     UpdateToolbarButtonsStateL();
       
  1003   	}    
       
  1004 
       
  1005 
       
  1006 // ---------------------------------------------------------
       
  1007 // CIMCVAppView::NotifyWhenCompleted()
       
  1008 // (other items were commented in a header).
       
  1009 // ---------------------------------------------------------
       
  1010 //
       
  1011 void CIMCVAppView::NotifyWhenCompleted()
       
  1012     {
       
  1013     MAknEditingStateIndicator* editStateIndicator = 
       
  1014                                     CAknEnv::Static()->EditingStateIndicator();                                   
       
  1015     
       
  1016     if ( editStateIndicator )
       
  1017         {
       
  1018         CAknIndicatorContainer* indicatorContainer = editStateIndicator->IndicatorContainer();
       
  1019               
       
  1020         if (( indicatorContainer ) && (iStatusPane))
       
  1021             {
       
  1022             iStatusPane->HideFadeText();
       
  1023             iStatusPane->HideNavipaneIndicators();            
       
  1024             }
       
  1025         }
       
  1026     
       
  1027     if ( iContainer )
       
  1028         {
       
  1029         CEikRichTextEditor& editor = iContainer->Editor().Editor();
       
  1030 
       
  1031 		if (!editor.IsFocused())
       
  1032 			{
       
  1033 			editor.SetAknEditorFlags( editor.AknEdwinFlags()|EAknEditorFlagNoEditIndicators );	
       
  1034 			if (iStatusPane)
       
  1035 				{
       
  1036 				TRAP_IGNORE( iStatusPane->ShowTabL() );
       
  1037 				}
       
  1038 			}
       
  1039 		else
       
  1040 			{
       
  1041 			editor.SetAknEditorFlags( editor.AknEdwinFlags()&~EAknEditorFlagNoEditIndicators );			
       
  1042 			}
       
  1043         }
       
  1044     
       
  1045     
       
  1046     }
       
  1047 
       
  1048 
       
  1049 // ---------------------------------------------------------
       
  1050 // CIMCVAppView::NotifyWhenStarted()
       
  1051 // (other items were commented in a header).
       
  1052 // ---------------------------------------------------------
       
  1053 //
       
  1054 void CIMCVAppView::NotifyWhenStarted()
       
  1055     {    
       
  1056     if ( iContainer )
       
  1057         {
       
  1058         CEikRichTextEditor& editor = iContainer->Editor().Editor();
       
  1059 		if (editor.IsFocused())
       
  1060 			{
       
  1061 			editor.SetAknEditorFlags( editor.AknEdwinFlags()|EAknEditorFlagNoEditIndicators );
       
  1062 			}
       
  1063         }
       
  1064     }
       
  1065         
       
  1066 // ---------------------------------------------------------
       
  1067 // CIMCVAppView::ViewRefresh()
       
  1068 // This method refreshes the view.
       
  1069 // (other items were commented in a header).
       
  1070 // ---------------------------------------------------------
       
  1071 void CIMCVAppView::ViewRefreshL()
       
  1072     {
       
  1073     IM_CV_LOGS(TXT("CIMCVAppView::ViewRefreshL() start") );
       
  1074     
       
  1075      if ( iContainer )
       
  1076         {            
       
  1077         iAppUi->RemoveFromViewStack( *this, iContainer );
       
  1078         // not in a middle of sending message
       
  1079         delete iContainer;
       
  1080         iContainer = NULL;                  
       
  1081         }
       
  1082      if ( iFindContextMenu )
       
  1083         {
       
  1084         iAppUi->RemoveFromViewStack( *this, iFindContextMenu );
       
  1085         }
       
  1086   
       
  1087      UpdateToolbarButtonsStateL();
       
  1088      IM_CV_LOGS(TXT("CIMCVAppView::ViewRefreshL() End") );
       
  1089     }
       
  1090     
       
  1091 // ---------------------------------------------------------
       
  1092 // CVIMPSTUiTabbedView::LaunchHelpL()
       
  1093 // Function launches help application using the HlpLauncher.
       
  1094 // @params: Reference to a descriptor, serves as context.
       
  1095 // ---------------------------------------------------------
       
  1096 //
       
  1097 
       
  1098 
       
  1099 void CIMCVAppView::LaunchHelpL( const TDesC& aContext )
       
  1100     {
       
  1101     CArrayFix< TCoeHelpContext >* cntx = new( ELeave ) CArrayFixFlat< TCoeHelpContext >( KHelpContextSize );
       
  1102     CleanupStack::PushL( cntx );
       
  1103 
       
  1104     cntx->AppendL( TCoeHelpContext( KHelpUid, aContext ) );
       
  1105     CleanupStack::Pop( cntx );
       
  1106     
       
  1107     //and launch help - takes ownership of context array
       
  1108     HlpLauncher::LaunchHelpApplicationL( CEikonEnv::Static()->WsSession(), cntx );    
       
  1109     }
       
  1110 // ---------------------------------------------------------
       
  1111 // CVIMPSTUiTabbedView::ShowMeL()
       
  1112 // Function launches help application using the HlpLauncher.
       
  1113 // @params: Reference to a descriptor, serves as context.
       
  1114 // ---------------------------------------------------------
       
  1115 //    
       
  1116 void CIMCVAppView::ShowMeL( const TDesC8& aParamData )
       
  1117 	{
       
  1118     IM_CV_LOGS(TXT("CIMCVAppView::ShowMeL() Start" ));
       
  1119 	TPckgBuf<TIMCVUiParams> params;
       
  1120     params.Copy( aParamData );
       
  1121    
       
  1122     if(iAppUi) 
       
  1123         {
       
  1124         IM_CV_LOGS(TXT("CIMCVAppView::ShowMeL() Inside if(iAppUi)" ));
       
  1125         if(iConnection)
       
  1126             {
       
  1127             iConnection->Close();
       
  1128             iConnection = NULL;
       
  1129             }
       
  1130         // show me may called before ActivateViewL is called
       
  1131         //Get the service id  - this property is published by imcvlauncher
       
  1132         TInt error = RProperty::Get( KMeCoPropertyUid, KMeCoConvViewServiceIdKey, iServiceId );
       
  1133         User::LeaveIfError(error);
       
  1134         TInt serviceId = iActiveEngine->GetServiceId();
       
  1135 		if( serviceId != iServiceId )
       
  1136 			{
       
  1137 			SwitchToValidServiceL( iServiceId );
       
  1138 			}
       
  1139 		/* Get the current active REcipient ID, if that is not matching, then launch cv */
       
  1140 		TPtrC activeRecipientId = iEngineFactory->GetActiveItemL ();
       
  1141 	//	IM_CV_LOGS(TXT("CIMCVAppView::SHOWMEL() ACTIVE RECIPIENT ID %S *****************"), &activeRecipientId );
       
  1142 		
       
  1143         TPtrC recieptId = params().iBuddyId;  
       
  1144         TPtrC displayName = params().iBuddyName;
       
  1145         iRecipientUserId->Des().Copy(recieptId);
       
  1146         // show me may called before ActivateViewL is called
       
  1147         // if its only update, which is true only when a contact is edited.
       
  1148         IM_CV_LOGS(TXT("CIMCVAppView::ShowMeL() Inside if(iAppUi) : %d" ), params().iUpdate);
       
  1149 
       
  1150         if(params().iUpdate )
       
  1151             {
       
  1152             IM_CV_LOGS(TXT("CIMCVAppView::ShowMeL() if(params().iUpdate)" ));
       
  1153 
       
  1154             MIMCVEngineMessageWriteInterface& messageWriteInterface = iActiveChatInterface->
       
  1155                                                                         MessageWriteInterfaceL(params().iServiceId,recieptId);
       
  1156             messageWriteInterface.SetNameL(displayName);
       
  1157             if(iStatusPane)
       
  1158                 {
       
  1159                 // refresh the view if the update has tacke place when the conversation view is open.
       
  1160                 IM_CV_LOGS(TXT("CIMCVAppView::ShowMeL() calling RefreshTabL)" ));
       
  1161                 iStatusPane->RefreshTabL(recieptId,displayName);
       
  1162                 }
       
  1163           
       
  1164             }
       
  1165         else
       
  1166             {
       
  1167             IM_CV_LOGS(TXT("CIMCVAppView::ShowMeL() else" ));
       
  1168             iAppUi->StorePreviousViewDetails(params().iAppUid, params().iViewUid );
       
  1169             if ( (!iViewDeactivated) && (iRecipientUserId) && 
       
  1170                    (serviceId == iServiceId) && 
       
  1171                    (0 == recieptId.Compare(activeRecipientId)) )
       
  1172                 {       
       
  1173                 SetStatusPaneIconsL();
       
  1174                 if (iStatusPane)
       
  1175                     {
       
  1176                     iStatusPane->BringToForegroundL();  
       
  1177                     }
       
  1178                 iAppUi->BringToForeground(TUid::Uid(KIMCVUIAPPEXEUID3));
       
  1179                 // when view moved to background ,active conversation was deactivated
       
  1180                 // comming to forground activate it
       
  1181                 iActiveEngine->MessageHandler().StartNewConversationL( recieptId );           
       
  1182                 }
       
  1183             else
       
  1184                {
       
  1185                IM_CV_LOGS(TXT("CIMCVAppView::ShowMeL() NOT MATCHING AT ALL" ));
       
  1186                iAppUi->ActivateLocalViewL(KUidConversationsView, KNullUid, aParamData);                
       
  1187                }
       
  1188             UpdateToolbarButtonsStateL();
       
  1189             }
       
  1190         }
       
  1191 	IM_CV_LOGS(TXT("CIMCVAppView::ShowMeL() End" ));
       
  1192 	}
       
  1193 // ---------------------------------------------------------
       
  1194 // CVIMPSTUiTabbedView::SwitchToValidServiceL()
       
  1195 // Function launches help application using the HlpLauncher.
       
  1196 // @params: Reference to a descriptor, serves as context.
       
  1197 // ---------------------------------------------------------
       
  1198 //    	
       
  1199 void CIMCVAppView::SwitchToValidServiceL( TInt aServiceId )
       
  1200     {
       
  1201     if( aServiceId <= 0 )
       
  1202         {
       
  1203         return;
       
  1204         }
       
  1205     iServiceId = aServiceId;
       
  1206     iActiveEngine = &iEngineFactory->GetServiceEngineL( iServiceId );
       
  1207     iActiveEngine->ResolveServiceStateL();    
       
  1208     iActiveChatInterface = &iActiveEngine->ChatInterface();
       
  1209     if( iContainer )
       
  1210         {
       
  1211         // resolve message read interface
       
  1212         iContainer->SetServiceParametersL( iActiveEngine );
       
  1213         }
       
  1214     }
       
  1215 // ---------------------------------------------------------
       
  1216 // CVIMPSTUiTabbedView::OfferTabEventL()
       
  1217 // Function launches help application using the HlpLauncher.
       
  1218 // @params: Reference to a descriptor, serves as context.
       
  1219 // ---------------------------------------------------------
       
  1220 //    
       
  1221 TKeyResponse CIMCVAppView::OfferTabEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
       
  1222     {
       
  1223     TKeyResponse keyResponse = EKeyWasConsumed;
       
  1224      
       
  1225     CAknTabGroup* tabGroup= NULL;
       
  1226     if(iStatusPane)
       
  1227         {
       
  1228         tabGroup = iStatusPane->TabGroup();
       
  1229         
       
  1230     
       
  1231         if(tabGroup)
       
  1232             {
       
  1233             keyResponse = tabGroup->OfferKeyEventL(aKeyEvent,aType);
       
  1234             }
       
  1235         }
       
  1236     
       
  1237     return keyResponse;
       
  1238 
       
  1239     }
       
  1240 
       
  1241 // ---------------------------------------------------------------------------
       
  1242 // CIMCVAppView::UpdateToolbarButtonsState
       
  1243 // ---------------------------------------------------------------------------
       
  1244 //
       
  1245 void CIMCVAppView::UpdateToolbarButtonsStateL()
       
  1246     {
       
  1247     if ( iContainer && iRecipientUserId )        
       
  1248         {
       
  1249         MIMCVEngineMessageReadInterface& readInterface = 
       
  1250             iActiveChatInterface->MessageReadInterfaceL( iServiceId, *iRecipientUserId );
       
  1251 
       
  1252         if ( readInterface.ContactLink().Length()> 0 )
       
  1253             {
       
  1254             Toolbar()->SetItemDimmed(EIMCVCmdToolbarDetails, EFalse, ETrue);
       
  1255             }
       
  1256         else {
       
  1257             Toolbar()->SetItemDimmed(EIMCVCmdToolbarDetails, ETrue, ETrue);
       
  1258             }
       
  1259         
       
  1260         TBool needToDimSendBtn = ETrue;
       
  1261         if(iContainer->Editor().TextLength()> 0)
       
  1262             {
       
  1263             needToDimSendBtn = EFalse;    
       
  1264             } 
       
  1265         Toolbar()->SetItemDimmed( EIMCVCmdToolbarSend, needToDimSendBtn, ETrue );
       
  1266         }
       
  1267     }
       
  1268 
       
  1269 // -----------------------------------------------------------------------------
       
  1270 // CIMCVAppView: HandleNewServiceL
       
  1271 // -----------------------------------------------------------------------------
       
  1272 //
       
  1273 void CIMCVAppView::HandleNewServiceL( TInt aServiceId )  
       
  1274     {
       
  1275     if( iExtensionHandler )
       
  1276         {
       
  1277         iExtensionHandler->CreateServiceSmileyL( aServiceId );
       
  1278         }
       
  1279     }
       
  1280 // -----------------------------------------------------------------------------
       
  1281 // CIMCVAppView: HandleServiceDeletedL
       
  1282 // -----------------------------------------------------------------------------
       
  1283 //
       
  1284 void CIMCVAppView::HandleServiceDeletedL( TInt aServiceId ) 
       
  1285     {
       
  1286     if( iExtensionHandler )
       
  1287         {
       
  1288         iExtensionHandler->DeleteServiceSmileyL( aServiceId );
       
  1289         }
       
  1290     }
       
  1291 
       
  1292 // -----------------------------------------------------------------------------
       
  1293 // CIMCVAppView::HandlePresenceChangedL
       
  1294 // (other items were commented in a header).
       
  1295 // -----------------------------------------------------------------------------
       
  1296 //
       
  1297 void CIMCVAppView::HandlePresenceChangedL(TInt aServiceId, const TDesC& aBuddyId )
       
  1298     {
       
  1299     IM_CV_LOGS(TXT("CIMCVAppView::HandlePresenceChangedL() start") );
       
  1300     if ( (iServiceId == aServiceId ) && ( iRecipientUserId->Compare( aBuddyId ) == 0 ) )
       
  1301         {
       
  1302         SetStatusPaneIconsL();
       
  1303         }
       
  1304     if (iContainer)
       
  1305         {
       
  1306         CIMCVEngine& engine = iEngineFactory->GetServiceEngineL( aServiceId );
       
  1307         iContainer->InsertStatusChangedMessageL(engine, aServiceId, aBuddyId );
       
  1308         }
       
  1309     IM_CV_LOGS(TXT("CIMCVAppView::HandlePresenceChangedL() End") );
       
  1310     }
       
  1311 // ---------------------------------------------------------
       
  1312 // CIMCVAppView::HandleOperationCompletdL
       
  1313 // Handles operation completion
       
  1314 // ---------------------------------------------------------
       
  1315 //
       
  1316 void CIMCVAppView::HandleOperationCompletdL(TInt /*aServiceId*/, MIMCVEngineMessage::TMessagerType /*aType*/ , TInt aResult )
       
  1317     {
       
  1318     IM_CV_LOGS(TXT("CIMCVAppView::HandleOperationCompletdL() start") ); 
       
  1319     
       
  1320     if( aResult!= KErrNone )
       
  1321         {
       
  1322         // show the corresponding error or information note
       
  1323         IMCVUiAppNoteMapper::ShowNoteL( aResult,*iRecipientUserId );    
       
  1324         }
       
  1325 
       
  1326     IM_CV_LOGS(TXT("CIMCVAppView::HandleOperationCompletdL() end") );  
       
  1327     }
       
  1328 
       
  1329 // -----------------------------------------------------------------------------
       
  1330 // CIMCVAppView::HandleConnectionTerminatedL
       
  1331 // (other items were commented in a header).
       
  1332 // -----------------------------------------------------------------------------
       
  1333 //
       
  1334 void CIMCVAppView::HandleConnectionEventL( TInt aServiceId, TIMCVConnectionState aState, TInt aReason )
       
  1335     {
       
  1336     IM_CV_LOGS(TXT("CIMCVAppView::HandleConnectionEventL() start") );
       
  1337 
       
  1338     switch (aState)
       
  1339         {
       
  1340         case EUnKnown:
       
  1341             break;
       
  1342         case ELoggedIn:
       
  1343             // Nothing to be done.
       
  1344             break;
       
  1345         case ELoggedOut:
       
  1346         case EForcedLoggedOut:
       
  1347             {
       
  1348             /*
       
  1349              * Only when the application is in Foreground, we need to show the note
       
  1350              * before closing the application. Once after that we need to shutdown the 
       
  1351              * application
       
  1352              */
       
  1353             if ( iAppUi->IsAppInForeground() && ( aServiceId == iServiceId ) )
       
  1354                 {
       
  1355                 // active service 
       
  1356                 if (KErrNone != aReason)
       
  1357                     IMCVUiAppNoteMapper::ShowNoteL( aReason , KNullDesC );
       
  1358                 }
       
  1359 			// This will be deleted by Engine factory later.
       
  1360 			//iActiveEngine = NULL;
       
  1361 			break;
       
  1362             }
       
  1363         }
       
  1364     IM_CV_LOGS(TXT("CIMCVAppView::HandleConnectionEventL() End") );
       
  1365     }
       
  1366 
       
  1367 // -----------------------------------------------------------------------------
       
  1368 // CIMCVAppView: HandleChatListEvent
       
  1369 // -----------------------------------------------------------------------------
       
  1370 //
       
  1371 void CIMCVAppView::HandleChatListEvent(TInt aServiceId,TChatListEventType aEvent, 
       
  1372                                       MIMCVEngineMessageReadInterface* aContainerInfo
       
  1373                                      ) 
       
  1374     {
       
  1375     IM_CV_LOGS (TXT("CIMCVAPPVIEW "));
       
  1376     // Handles the close Conversation event triggered from service tab.    
       
  1377     switch (aEvent)
       
  1378         {
       
  1379         case EChatItemDeleted:
       
  1380             {               
       
  1381             DeleteContainerCache( aContainerInfo->TargetId().Target(),aServiceId );
       
  1382             break;
       
  1383             }
       
  1384         case EChatAllItemDeleted:
       
  1385             {               
       
  1386 			IM_CV_LOGS (TXT("CIMCVAPPVIEW  :: DELETE ALL CHATS ***************************"));
       
  1387             iRTContainerCache->DeleteAllServiceContainer( aServiceId );
       
  1388             break;
       
  1389             }
       
  1390         default:
       
  1391             break;
       
  1392         }
       
  1393     
       
  1394     }
       
  1395 
       
  1396 //--------------------------------------------------------------------------------
       
  1397 //CIMCVAppView::DeleteContainerCache
       
  1398 //--------------------------------------------------------------------------------
       
  1399 void CIMCVAppView::DeleteContainerCache(const TDesC& aPrimaryKey, TInt aServiceId )
       
  1400     {
       
  1401     iRTContainerCache->DeleteContainer( aPrimaryKey,aServiceId );
       
  1402     //iActiveEngine->MessageHandler().CloseConversationL( *iRecipientUserId );
       
  1403     ViewRefreshL();
       
  1404     iRecipientUserId->Des().Copy( KNullDesC());
       
  1405 
       
  1406     if( !iViewDeactivated ) //if conv. view is active, we should go back to ST..
       
  1407         {
       
  1408         //this will execute when Back operation from Detail view is performed before call back (xsp id deletion call back)
       
  1409         //reaches the conv. view.
       
  1410         //In this case Conv. view will be active view and Conv. view need to be closed in this scenario.
       
  1411         TApaTask task(iEikonEnv->WsSession());
       
  1412         task.SetWgId( CEikonEnv::Static()->RootWin().Identifier());
       
  1413         task.SendToBackground();
       
  1414         }
       
  1415     else    //if view is not active (Current view is detail view).
       
  1416         {
       
  1417         if(iDetailViewOpen)
       
  1418             {
       
  1419             //xsp id deleted from detail view.
       
  1420             //conv. view need to be closed when doing back operation from detail view.
       
  1421             iConvViewDel = ETrue;
       
  1422             }
       
  1423         }
       
  1424     
       
  1425     iViewDeactivated = ETrue;
       
  1426     }
       
  1427 //  End of File