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