emailuis/emailui/src/FreestyleEmailUiMailViewerVisualiser.cpp
changeset 4 e7aa27f58ae1
parent 0 8466d47a6819
child 8 e1b6206813b4
equal deleted inserted replaced
3:a4d6f1ea0416 4:e7aa27f58ae1
    36 #include <aknlistquerydialog.h>
    36 #include <aknlistquerydialog.h>
    37 //<cmail>
    37 //<cmail>
    38 #include "fssmileydictionary.h"
    38 #include "fssmileydictionary.h"
    39 ///</cmail>
    39 ///</cmail>
    40 #include <commonphoneparser.h>
    40 #include <commonphoneparser.h>
    41 #include <BrowserLauncher.h>
    41 #include <browserlauncher.h>
    42 //<cmail>
    42 //<cmail>
    43 #include "CFSMailMessagePart.h"
    43 #include "CFSMailMessagePart.h"
    44 #include "CFSMailClient.h"
    44 #include "CFSMailClient.h"
    45 //</cmail>
    45 //</cmail>
    46 #include <apgcli.h>
    46 #include <apgcli.h>
    81 // for opening normal browser
    81 // for opening normal browser
    82 #include <BrowserOverriddenSettings.h>
    82 #include <BrowserOverriddenSettings.h>
    83 #include <BrowserLauncher.h>
    83 #include <BrowserLauncher.h>
    84 
    84 
    85 // for bookmarks
    85 // for bookmarks
    86 #include <FavouritesLimits.h>	// KBrowserBookmarks
    86 #include <FavouritesLimits.h>   // KBrowserBookmarks
    87 #include <FavouritesDb.h>
    87 #include <FavouritesDb.h>
    88 
    88 
    89 // for fonts
    89 // for fonts
    90 #include <AknFontAccess.h>
    90 #include <AknFontAccess.h>
    91 #include <AknLayoutFont.h>
    91 #include <AknLayoutFont.h>
   158 
   158 
   159 // -----------------------------------------------------------------------------
   159 // -----------------------------------------------------------------------------
   160 // CFSEmailUiMailViewerVisualiser::NewLC
   160 // CFSEmailUiMailViewerVisualiser::NewLC
   161 // -----------------------------------------------------------------------------
   161 // -----------------------------------------------------------------------------
   162 CFSEmailUiMailViewerVisualiser* CFSEmailUiMailViewerVisualiser::NewLC( CAlfEnv& aEnv, CFreestyleEmailUiAppUi& aAppUi, CAlfControlGroup& aMailViewerControlGroup )
   162 CFSEmailUiMailViewerVisualiser* CFSEmailUiMailViewerVisualiser::NewLC( CAlfEnv& aEnv, CFreestyleEmailUiAppUi& aAppUi, CAlfControlGroup& aMailViewerControlGroup )
   163 	{
   163     {
   164     FUNC_LOG;
   164     FUNC_LOG;
   165     CFSEmailUiMailViewerVisualiser* self = new (ELeave) CFSEmailUiMailViewerVisualiser( aEnv, aAppUi, aMailViewerControlGroup );
   165     CFSEmailUiMailViewerVisualiser* self = new (ELeave) CFSEmailUiMailViewerVisualiser( aEnv, aAppUi, aMailViewerControlGroup );
   166     CleanupStack::PushL( self );
   166     CleanupStack::PushL( self );
   167     self->ConstructL();
   167     self->ConstructL();
   168     return self;
   168     return self;
   169 	}
   169     }
   170 
   170 
   171 // -----------------------------------------------------------------------------
   171 // -----------------------------------------------------------------------------
   172 // CFSEmailUiMailViewerVisualiser::ConstructL
   172 // CFSEmailUiMailViewerVisualiser::ConstructL
   173 // -----------------------------------------------------------------------------
   173 // -----------------------------------------------------------------------------
   174 void CFSEmailUiMailViewerVisualiser::ConstructL()
   174 void CFSEmailUiMailViewerVisualiser::ConstructL()
   175 	{
   175     {
   176     FUNC_LOG;
   176     FUNC_LOG;
   177     BaseConstructL( R_FSEMAILUI_MAIL_VIEWER_VIEW );
   177     BaseConstructL( R_FSEMAILUI_MAIL_VIEWER_VIEW );
   178 	iMessage = NULL;
   178     iMessage = NULL;
   179 	iNextOrPevMessageSelected = EFalse;
   179     iNextOrPevMessageSelected = EFalse;
   180 	iFirstStartCompleted = EFalse;
   180     iFirstStartCompleted = EFalse;
   181 	}
   181     }
   182 
   182 
   183 // -----------------------------------------------------------------------------
   183 // -----------------------------------------------------------------------------
   184 // CFSEmailUiMailViewerVisualiser::DoFirstStartL()
   184 // CFSEmailUiMailViewerVisualiser::DoFirstStartL()
   185 // Purpose of this function is to do first start only when viewer is
   185 // Purpose of this function is to do first start only when viewer is
   186 // really needed to be shown. Implemented to make app start up faster.
   186 // really needed to be shown. Implemented to make app start up faster.
   206 
   206 
   207     //here is set menu for msk
   207     //here is set menu for msk
   208     MenuBar()->SetContextMenuTitleResourceId( R_FSEMAILUI_MAILVIEWER_MSK_MENUBAR );
   208     MenuBar()->SetContextMenuTitleResourceId( R_FSEMAILUI_MAILVIEWER_MSK_MENUBAR );
   209 
   209 
   210     iFirstStartCompleted = ETrue;
   210     iFirstStartCompleted = ETrue;
   211 	}
   211     }
   212 
   212 
   213 // -----------------------------------------------------------------------------
   213 // -----------------------------------------------------------------------------
   214 // CFSEmailUiMailViewerVisualiser::CFSEmailUiMailViewerVisualiser
   214 // CFSEmailUiMailViewerVisualiser::CFSEmailUiMailViewerVisualiser
   215 // -----------------------------------------------------------------------------
   215 // -----------------------------------------------------------------------------
   216 CFSEmailUiMailViewerVisualiser::CFSEmailUiMailViewerVisualiser( CAlfEnv& aEnv,
   216 CFSEmailUiMailViewerVisualiser::CFSEmailUiMailViewerVisualiser( CAlfEnv& aEnv,
   228 
   228 
   229 // -----------------------------------------------------------------------------
   229 // -----------------------------------------------------------------------------
   230 // CFSEmailUiMailViewerVisualiser::~CFSEmailUiMailViewerVisualiser
   230 // CFSEmailUiMailViewerVisualiser::~CFSEmailUiMailViewerVisualiser
   231 // -----------------------------------------------------------------------------
   231 // -----------------------------------------------------------------------------
   232 CFSEmailUiMailViewerVisualiser::~CFSEmailUiMailViewerVisualiser()
   232 CFSEmailUiMailViewerVisualiser::~CFSEmailUiMailViewerVisualiser()
   233 	{
   233     {
   234     FUNC_LOG;
   234     FUNC_LOG;
   235         //<cmail> notewrapper is replaced by iWaitDialog
   235         //<cmail> notewrapper is replaced by iWaitDialog
   236 	//delete iAsyncWaitNote;
   236     //delete iAsyncWaitNote;
   237         //</cmail>
   237         //</cmail>
   238 	if( iIBServiceHandler )
   238     if( iIBServiceHandler )
   239 		{
   239         {
   240 		iIBServiceHandler->Reset();
   240         iIBServiceHandler->Reset();
   241 		delete iIBServiceHandler;
   241         delete iIBServiceHandler;
   242 		}
   242         }
   243 
   243 
   244 	if ( iAsyncCallback )
   244     if ( iAsyncCallback )
   245 	    {
   245         {
   246 	    iAsyncCallback->Cancel();
   246         iAsyncCallback->Cancel();
   247 	    delete iAsyncCallback;
   247         delete iAsyncCallback;
   248 	    }
   248         }
   249 
   249 
   250 	iDownloadProgressControlGroup = NULL; // owned by AlfEnv
   250     iDownloadProgressControlGroup = NULL; // owned by AlfEnv
   251 	}
   251     }
   252 
   252 
   253 void CFSEmailUiMailViewerVisualiser::PrepareForExit()
   253 void CFSEmailUiMailViewerVisualiser::PrepareForExit()
   254     {
   254     {
   255     FUNC_LOG;
   255     FUNC_LOG;
   256     delete iSmDictionary;
   256     delete iSmDictionary;
   257     iSmDictionary = NULL;
   257     iSmDictionary = NULL;
   258     delete iNewMailTempAddress;
   258     delete iNewMailTempAddress;
   259     iNewMailTempAddress = NULL;
   259     iNewMailTempAddress = NULL;
   260 
   260 
   261     // Text viewer control need to be removed control group and deleted here,
   261     // Text viewer control need to be removed control group and deleted here,
   262 	// because akn physics (used by text viewer control) object's destructor
   262     // because akn physics (used by text viewer control) object's destructor
   263 	// ends up calling CoeEnv->AppUi, so AppUi must be alive when deleting
   263     // ends up calling CoeEnv->AppUi, so AppUi must be alive when deleting
   264 	// text viewer control
   264     // text viewer control
   265     if ( iTextViewerControl )
   265     if ( iTextViewerControl )
   266         {
   266         {
   267         ControlGroup().Remove( iTextViewerControl );
   267         ControlGroup().Remove( iTextViewerControl );
   268         }
   268         }
   269 
   269 
   328         UpdateDownloadIndicatorL( aEvent.iProgressStatus );
   328         UpdateDownloadIndicatorL( aEvent.iProgressStatus );
   329 
   329 
   330         // <cmail> Action menu is dismissed if it's opened on an attachment
   330         // <cmail> Action menu is dismissed if it's opened on an attachment
   331         // and the download has completed (to prevent canceling after completion).
   331         // and the download has completed (to prevent canceling after completion).
   332         SViewerHeadingHotSpotData currentHeaderHotSpotData;
   332         SViewerHeadingHotSpotData currentHeaderHotSpotData;
   333 		CFindItemEngine::SFoundItem currentBodyHotSpotData;
   333         CFindItemEngine::SFoundItem currentBodyHotSpotData;
   334 
   334 
   335         THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL(
   335         THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL(
   336             currentHeaderHotSpotData, currentBodyHotSpotData );
   336             currentHeaderHotSpotData, currentBodyHotSpotData );
   337 
   337 
   338         if( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete &&
   338         if( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete &&
   345             // close actions menu if open
   345             // close actions menu if open
   346             CEikMenuBar* menu = MenuBar();
   346             CEikMenuBar* menu = MenuBar();
   347 
   347 
   348             if( menu->IsDisplayed() )
   348             if( menu->IsDisplayed() )
   349                 {
   349                 {
   350         		menu->MenuPane()->CloseCascadeMenu();
   350                 menu->MenuPane()->CloseCascadeMenu();
   351                 }
   351                 }
   352             }
   352             }
   353         // </cmail>
   353         // </cmail>
   354         }
   354         }
   355     }
   355     }
   357 // -----------------------------------------------------------------------------
   357 // -----------------------------------------------------------------------------
   358 // CFSEmailUiMailViewerVisualiser::RequestResponseL
   358 // CFSEmailUiMailViewerVisualiser::RequestResponseL
   359 // for MFSMailRequestObserver callback
   359 // for MFSMailRequestObserver callback
   360 // -----------------------------------------------------------------------------
   360 // -----------------------------------------------------------------------------
   361 void CFSEmailUiMailViewerVisualiser::RequestResponseL( TFSProgress aEvent, TInt aRequestId )
   361 void CFSEmailUiMailViewerVisualiser::RequestResponseL( TFSProgress aEvent, TInt aRequestId )
   362 	{
   362     {
   363     FUNC_LOG;
   363     FUNC_LOG;
   364     if ( iFirstStartCompleted ) // Safety
   364     if ( iFirstStartCompleted ) // Safety
   365         {
   365         {
   366         if ( aRequestId == iCurrentPlainTextBodyFetchRequestId && iFetchingPlainTextMessageBody )
   366         if ( aRequestId == iCurrentPlainTextBodyFetchRequestId && iFetchingPlainTextMessageBody )
   367             {
   367             {
   454         }
   454         }
   455     //<cmail>
   455     //<cmail>
   456     if(iAsyncProcessComplete && iWaitDialog && iDialogNotDismissed)
   456     if(iAsyncProcessComplete && iWaitDialog && iDialogNotDismissed)
   457         iWaitDialog->ProcessFinishedL(); // deletes the dialog
   457         iWaitDialog->ProcessFinishedL(); // deletes the dialog
   458     //</cmail>
   458     //</cmail>
   459 	}
   459     }
   460 
   460 
   461 
   461 
   462 // -----------------------------------------------------------------------------
   462 // -----------------------------------------------------------------------------
   463 // CFSEmailUiMailViewerVisualiser::FolderSelectedL
   463 // CFSEmailUiMailViewerVisualiser::FolderSelectedL
   464 // -----------------------------------------------------------------------------
   464 // -----------------------------------------------------------------------------
   465 void CFSEmailUiMailViewerVisualiser::FolderSelectedL(
   465 void CFSEmailUiMailViewerVisualiser::FolderSelectedL(
   466 	TFSMailMsgId aSelectedFolderId, TFSEmailUiCtrlBarResponse aResponse )
   466     TFSMailMsgId aSelectedFolderId, TFSEmailUiCtrlBarResponse aResponse )
   467 	{
   467     {
   468     FUNC_LOG;
   468     FUNC_LOG;
   469 
   469 
   470     if ( iMoveToFolderOngoing )
   470     if ( iMoveToFolderOngoing )
   471 		{
   471         {
   472 		iMoveToFolderOngoing = EFalse;
   472         iMoveToFolderOngoing = EFalse;
   473 		if ( !iMovingMeetingRequest )
   473         if ( !iMovingMeetingRequest )
   474 			{
   474             {
   475 			switch ( aResponse )
   475             switch ( aResponse )
   476 				{
   476                 {
   477 				case EFSEmailUiCtrlBarResponseSelect:
   477                 case EFSEmailUiCtrlBarResponseSelect:
   478 					{
   478                     {
   479 					iMoveDestinationFolder = aSelectedFolderId;
   479                     iMoveDestinationFolder = aSelectedFolderId;
   480 					iAsyncCallback->Cancel(); // cancel any outstanding callback just to be safe
   480                     iAsyncCallback->Cancel(); // cancel any outstanding callback just to be safe
   481 					iAsyncCallback->Set( TCallBack( MoveToFolderAndExitL, this ) );
   481                     iAsyncCallback->Set( TCallBack( MoveToFolderAndExitL, this ) );
   482 					iAsyncCallback->CallBack();
   482                     iAsyncCallback->CallBack();
   483 					}
   483                     }
   484 					break;
   484                     break;
   485                 case EFSEmailUiCtrlBarResponseCancel:
   485                 case EFSEmailUiCtrlBarResponseCancel:
   486 				default:
   486                 default:
   487 					break;
   487                     break;
   488 				}
   488                 }
   489 			}
   489             }
   490 		else
   490         else
   491 		 	{
   491             {
   492 		 	iMovingMeetingRequest = EFalse;
   492             iMovingMeetingRequest = EFalse;
   493 			switch ( aResponse )
   493             switch ( aResponse )
   494 				{
   494                 {
   495 				case EFSEmailUiCtrlBarResponseCancel:
   495                 case EFSEmailUiCtrlBarResponseCancel:
   496 					iOpResult.iResultCode = KErrCancel;
   496                     iOpResult.iResultCode = KErrCancel;
   497 					break;
   497                     break;
   498 				case EFSEmailUiCtrlBarResponseSelect:
   498                 case EFSEmailUiCtrlBarResponseSelect:
   499 					{
   499                     {
   500 					// Do moving here, do not exit, because mrui exists itself.
   500                     // Do moving here, do not exit, because mrui exists itself.
   501 					iOpResult.iResultCode = KErrNone;
   501                     iOpResult.iResultCode = KErrNone;
   502 					iMoveDestinationFolder = aSelectedFolderId;
   502                     iMoveDestinationFolder = aSelectedFolderId;
   503 				    RArray<TFSMailMsgId> messageIds;
   503                     RArray<TFSMailMsgId> messageIds;
   504 					CleanupClosePushL( messageIds );
   504                     CleanupClosePushL( messageIds );
   505 					messageIds.Append( iMessage->GetMessageId() );
   505                     messageIds.Append( iMessage->GetMessageId() );
   506 					// Trap is needed because protocol might return KErrNotSupported
   506                     // Trap is needed because protocol might return KErrNotSupported
   507 					// if move away from current folder is not supprted
   507                     // if move away from current folder is not supprted
   508 					TRAPD(errMove, iAppUi.GetActiveMailbox()->MoveMessagesL( messageIds,
   508                     TRAPD(errMove, iAppUi.GetActiveMailbox()->MoveMessagesL( messageIds,
   509 			                                          iMessage->GetFolderId(), iMoveDestinationFolder ));
   509                                                       iMessage->GetFolderId(), iMoveDestinationFolder ));
   510 	        		if ( errMove != KErrNotSupported )
   510                     if ( errMove != KErrNotSupported )
   511 		       			{
   511                         {
   512 	        			if ( errMove == KErrNone )
   512                         if ( errMove == KErrNone )
   513 			       			{
   513                             {
   514 						    TFsEmailUiUtility::DisplayMsgsMovedNoteL( 1, iMoveDestinationFolder, ETrue );
   514                             TFsEmailUiUtility::DisplayMsgsMovedNoteL( 1, iMoveDestinationFolder, ETrue );
   515 			       			}
   515                             }
   516 		       			else
   516                         else
   517 		       				{
   517                             {
   518 		       				User::Leave( errMove );
   518                             User::Leave( errMove );
   519 		       				}
   519                             }
   520 		       			}
   520                         }
   521 					CleanupStack::PopAndDestroy( &messageIds );
   521                     CleanupStack::PopAndDestroy( &messageIds );
   522 					}
   522                     }
   523 					break;
   523                     break;
   524 				default:
   524                 default:
   525 					break;
   525                     break;
   526 				}
   526                 }
   527 		 	}
   527             }
   528 		}
   528         }
   529 
   529 
   530 	}
   530     }
   531 
   531 
   532 // ---------------------------------------------------------------------------
   532 // ---------------------------------------------------------------------------
   533 // From MFSEmailUiContactHandlerObserver
   533 // From MFSEmailUiContactHandlerObserver
   534 // The ownership of the CLS items in the contacts array is transferred to the
   534 // The ownership of the CLS items in the contacts array is transferred to the
   535 // observer, and they must be deleted by the observer.
   535 // observer, and they must be deleted by the observer.
   560     FUNC_LOG;
   560     FUNC_LOG;
   561     CFSEmailUiMailViewerVisualiser* self =
   561     CFSEmailUiMailViewerVisualiser* self =
   562         static_cast<CFSEmailUiMailViewerVisualiser*>(aMailViewerVisualiser);
   562         static_cast<CFSEmailUiMailViewerVisualiser*>(aMailViewerVisualiser);
   563 
   563 
   564     RArray<TFSMailMsgId> messageIds;
   564     RArray<TFSMailMsgId> messageIds;
   565 	CleanupClosePushL( messageIds );
   565     CleanupClosePushL( messageIds );
   566     messageIds.Append( self->iMessage->GetMessageId() );
   566     messageIds.Append( self->iMessage->GetMessageId() );
   567 
   567 
   568 	// Trap is needed because protocol might return KErrNotSupported
   568     // Trap is needed because protocol might return KErrNotSupported
   569 	// if move away from current folder is not supprted
   569     // if move away from current folder is not supprted
   570 	TRAPD(errMove, self->iAppUi.GetActiveMailbox()->MoveMessagesL( messageIds,
   570     TRAPD(errMove, self->iAppUi.GetActiveMailbox()->MoveMessagesL( messageIds,
   571                                                      self->iMessage->GetFolderId(),
   571                                                      self->iMessage->GetFolderId(),
   572                                                      self->iMoveDestinationFolder ) );
   572                                                      self->iMoveDestinationFolder ) );
   573 	if ( errMove != KErrNotSupported )
   573     if ( errMove != KErrNotSupported )
   574 		{
   574         {
   575 		if ( errMove == KErrNone )
   575         if ( errMove == KErrNone )
   576 			{
   576             {
   577 			// move successfull, display note
   577             // move successfull, display note
   578 		    TFsEmailUiUtility::DisplayMsgsMovedNoteL( 1, self->iMoveDestinationFolder, ETrue );
   578             TFsEmailUiUtility::DisplayMsgsMovedNoteL( 1, self->iMoveDestinationFolder, ETrue );
   579 			}
   579             }
   580 		else
   580         else
   581 			{
   581             {
   582 			// Leave with any other err code than KErrNone or KErrNotSupported.
   582             // Leave with any other err code than KErrNone or KErrNotSupported.
   583 			User::Leave( errMove );
   583             User::Leave( errMove );
   584 			}
   584             }
   585 		}
   585         }
   586 	CleanupStack::PopAndDestroy( &messageIds );
   586     CleanupStack::PopAndDestroy( &messageIds );
   587 
   587 
   588     // return to previous view
   588     // return to previous view
   589     self->HandleCommandL( EAknSoftkeyBack );
   589     self->HandleCommandL( EAknSoftkeyBack );
   590 
   590 
   591     return KErrNone;
   591     return KErrNone;
   593 
   593 
   594 // -----------------------------------------------------------------------------
   594 // -----------------------------------------------------------------------------
   595 // CFSEmailUiMailViewerVisualiser::OpenFolderListForMessageMovingL
   595 // CFSEmailUiMailViewerVisualiser::OpenFolderListForMessageMovingL
   596 // -----------------------------------------------------------------------------
   596 // -----------------------------------------------------------------------------
   597 TBool CFSEmailUiMailViewerVisualiser::OpenFolderListForMessageMovingL()
   597 TBool CFSEmailUiMailViewerVisualiser::OpenFolderListForMessageMovingL()
   598 	{
   598     {
   599     FUNC_LOG;
   599     FUNC_LOG;
   600 	TBool ret = EFalse;
   600     TBool ret = EFalse;
   601 	// Ignore if mailbox doesn't support moving or we are viewing embedded message
   601     // Ignore if mailbox doesn't support moving or we are viewing embedded message
   602 	if ( iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder ) &&
   602     if ( iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder ) &&
   603 	        !iEmbeddedMessageMode )
   603             !iEmbeddedMessageMode )
   604 	    {
   604         {
   605 	    // Activate folder selection view and handle moving after callback gets destination
   605         // Activate folder selection view and handle moving after callback gets destination
   606 	    iMoveToFolderOngoing = ETrue;
   606         iMoveToFolderOngoing = ETrue;
   607 	    TFolderListActivationData folderListData;
   607         TFolderListActivationData folderListData;
   608 	    folderListData.iCallback = this;
   608         folderListData.iCallback = this;
   609 	    CFSMailFolder* folder = iAppUi.GetMailClient()->GetFolderByUidL( iMessage->GetMailBoxId(), iMessage->GetFolderId() );
   609         CFSMailFolder* folder = iAppUi.GetMailClient()->GetFolderByUidL( iMessage->GetMailBoxId(), iMessage->GetFolderId() );
   610 	    folderListData.iSourceFolderType = TFSFolderType( folder->GetFolderType() );
   610         folderListData.iSourceFolderType = TFSFolderType( folder->GetFolderType() );
   611 	    delete folder;
   611         delete folder;
   612 	    const TPckgBuf<TFolderListActivationData> pkgOut( folderListData );
   612         const TPckgBuf<TFolderListActivationData> pkgOut( folderListData );
   613 	    iAppUi.EnterFsEmailViewL( FolderListId, KFolderListMoveMessage, pkgOut );
   613         iAppUi.EnterFsEmailViewL( FolderListId, KFolderListMoveMessage, pkgOut );
   614 	    ret = ETrue;
   614         ret = ETrue;
   615 	    }
   615         }
   616 	return ret;
   616     return ret;
   617 	}
   617     }
   618 
   618 
   619 
   619 
   620 // -----------------------------------------------------------------------------
   620 // -----------------------------------------------------------------------------
   621 // CFSEmailUiMailViewerVisualiser::ViewerControl
   621 // CFSEmailUiMailViewerVisualiser::ViewerControl
   622 // -----------------------------------------------------------------------------
   622 // -----------------------------------------------------------------------------
   623 CAlfControl* CFSEmailUiMailViewerVisualiser::ViewerControl()
   623 CAlfControl* CFSEmailUiMailViewerVisualiser::ViewerControl()
   624 	{
   624     {
   625     FUNC_LOG;
   625     FUNC_LOG;
   626 	return iTextViewerControl;
   626     return iTextViewerControl;
   627 	}
   627     }
   628 
   628 
   629 // -----------------------------------------------------------------------------
   629 // -----------------------------------------------------------------------------
   630 // CFSEmailUiMailViewerVisualiser::Id
   630 // CFSEmailUiMailViewerVisualiser::Id
   631 // -----------------------------------------------------------------------------
   631 // -----------------------------------------------------------------------------
   632 TUid CFSEmailUiMailViewerVisualiser::Id() const
   632 TUid CFSEmailUiMailViewerVisualiser::Id() const
   633 	{
   633     {
   634     FUNC_LOG;
   634     FUNC_LOG;
   635 	return MailViewerId;
   635     return MailViewerId;
   636 	}
   636     }
   637 
   637 
   638 // -----------------------------------------------------------------------------
   638 // -----------------------------------------------------------------------------
   639 // CFSEmailUiMailViewerVisualiser::ChildDoActivateL
   639 // CFSEmailUiMailViewerVisualiser::ChildDoActivateL
   640 // -----------------------------------------------------------------------------
   640 // -----------------------------------------------------------------------------
   641 // <cmail> Toolbar
   641 // <cmail> Toolbar
   646 // </cmail> Toolbar
   646 // </cmail> Toolbar
   647 void CFSEmailUiMailViewerVisualiser::ChildDoActivateL(
   647 void CFSEmailUiMailViewerVisualiser::ChildDoActivateL(
   648     const TVwsViewId& aPrevViewId,
   648     const TVwsViewId& aPrevViewId,
   649     TUid aCustomMessageId,
   649     TUid aCustomMessageId,
   650     const TDesC8& aCustomMessage )
   650     const TDesC8& aCustomMessage )
   651 	{
   651     {
   652     FUNC_LOG;
   652     FUNC_LOG;
   653 
   653 
   654     // Read the activation parameters
   654     // Read the activation parameters
   655     TMsgViewerActivationData activationData;
   655     TMsgViewerActivationData activationData;
   656     if ( &aCustomMessage && aCustomMessage.Length() )
   656     if ( &aCustomMessage && aCustomMessage.Length() )
   790         // Set email indicator off.. user has checked the new emails
   790         // Set email indicator off.. user has checked the new emails
   791         TFsEmailUiUtility::ToggleEmailIconL( EFalse );
   791         TFsEmailUiUtility::ToggleEmailIconL( EFalse );
   792         }
   792         }
   793 
   793 
   794     iNextOrPevMessageSelected = EFalse;
   794     iNextOrPevMessageSelected = EFalse;
   795 	}
   795     }
   796 
   796 
   797 // -----------------------------------------------------------------------------
   797 // -----------------------------------------------------------------------------
   798 // CFSEmailUiMailViewerVisualiser::OfferToolbarEventL
   798 // CFSEmailUiMailViewerVisualiser::OfferToolbarEventL
   799 // -----------------------------------------------------------------------------
   799 // -----------------------------------------------------------------------------
   800 void CFSEmailUiMailViewerVisualiser::OfferToolbarEventL( TInt aCommand )
   800 void CFSEmailUiMailViewerVisualiser::OfferToolbarEventL( TInt aCommand )
   838 
   838 
   839 // -----------------------------------------------------------------------------
   839 // -----------------------------------------------------------------------------
   840 // CFSEmailUiMailViewerVisualiser::ChildDoDeactivate
   840 // CFSEmailUiMailViewerVisualiser::ChildDoDeactivate
   841 // -----------------------------------------------------------------------------
   841 // -----------------------------------------------------------------------------
   842 void CFSEmailUiMailViewerVisualiser::ChildDoDeactivate()
   842 void CFSEmailUiMailViewerVisualiser::ChildDoDeactivate()
   843 	{
   843     {
   844     FUNC_LOG;
   844     FUNC_LOG;
   845 	CancelFetchings();
   845     CancelFetchings();
   846 	if ( iFetchingAnimationTimer )
   846     if ( iFetchingAnimationTimer )
   847 	    {
   847         {
   848 	    iFetchingAnimationTimer->Stop();
   848         iFetchingAnimationTimer->Stop();
   849 	    }
   849         }
   850 	if ( iDownloadProgressIndicator )
   850     if ( iDownloadProgressIndicator )
   851 	    {
   851         {
   852 	    iDownloadProgressIndicator->HideIndicator();
   852         iDownloadProgressIndicator->HideIndicator();
   853 	    }
   853         }
   854 
   854 
   855 	// Hide this view's navipane
   855     // Hide this view's navipane
   856 	HideNaviPane();
   856     HideNaviPane();
   857 
   857 
   858 	// set view itself as toolbar observer again (e.g. MRGUI could have been changed it)
   858     // set view itself as toolbar observer again (e.g. MRGUI could have been changed it)
   859 	Toolbar()->SetToolbarObserver( this );
   859     Toolbar()->SetToolbarObserver( this );
   860 	}
   860     }
   861 
   861 
   862 // -----------------------------------------------------------------------------
   862 // -----------------------------------------------------------------------------
   863 // CFSEmailUiMailViewerVisualiser::HideNaviPane
   863 // CFSEmailUiMailViewerVisualiser::HideNaviPane
   864 // -----------------------------------------------------------------------------
   864 // -----------------------------------------------------------------------------
   865 void CFSEmailUiMailViewerVisualiser::HideNaviPane()
   865 void CFSEmailUiMailViewerVisualiser::HideNaviPane()
   891 // CFSEmailUiMailViewerVisualiser::HandleMrCommandL
   891 // CFSEmailUiMailViewerVisualiser::HandleMrCommandL
   892 // Handle accept/decline/tentative/remove commands given for meeting request
   892 // Handle accept/decline/tentative/remove commands given for meeting request
   893 // message directly from list UI.
   893 // message directly from list UI.
   894 // -----------------------------------------------------------------------------
   894 // -----------------------------------------------------------------------------
   895 void CFSEmailUiMailViewerVisualiser::HandleMrCommandL(
   895 void CFSEmailUiMailViewerVisualiser::HandleMrCommandL(
   896 	TInt aCommandId,
   896     TInt aCommandId,
   897     TFSMailMsgId aMailboxId,
   897     TFSMailMsgId aMailboxId,
   898     TFSMailMsgId aFolderId,
   898     TFSMailMsgId aFolderId,
   899     TFSMailMsgId aMessageId )
   899     TFSMailMsgId aMessageId )
   900     {
   900     {
   901     FUNC_LOG;
   901     FUNC_LOG;
   902 
   902 
   903     // All items should be run
   903     // All items should be run
   904     if ( !iFirstStartCompleted )
   904     if ( !iFirstStartCompleted )
   905     	{
   905         {
   906     	DoFirstStartL();
   906         DoFirstStartL();
   907         }
   907         }
   908 
   908 
   909 	UpdateMessagePtrL( aMailboxId, aFolderId, aMessageId );
   909     UpdateMessagePtrL( aMailboxId, aFolderId, aMessageId );
   910 
   910 
   911     if ( aCommandId == EFsEmailUiCmdCalRemoveFromCalendar )
   911     if ( aCommandId == EFsEmailUiCmdCalRemoveFromCalendar )
   912         {
   912         {
   913         iAppUi.MrViewerInstanceL()->RemoveMeetingRequestFromCalendarL(
   913         iAppUi.MrViewerInstanceL()->RemoveMeetingRequestFromCalendarL(
   914 			*iMessage, *this );
   914             *iMessage, *this );
   915         }
   915         }
   916     else
   916     else
   917         {
   917         {
   918         TESMRAttendeeStatus respondStatus;
   918         TESMRAttendeeStatus respondStatus;
   919         if ( aCommandId == EFsEmailUiCmdCalActionsAccept )
   919         if ( aCommandId == EFsEmailUiCmdCalActionsAccept )
   927         else // ( aCommandId == EFsEmailUiCmdCalActionsDecline )
   927         else // ( aCommandId == EFsEmailUiCmdCalActionsDecline )
   928             {
   928             {
   929             respondStatus = EESMRAttendeeStatusDecline;
   929             respondStatus = EESMRAttendeeStatusDecline;
   930             }
   930             }
   931         iAppUi.MrViewerInstanceL()->ResponseToMeetingRequestL(
   931         iAppUi.MrViewerInstanceL()->ResponseToMeetingRequestL(
   932         	respondStatus, *iMessage, *this );
   932             respondStatus, *iMessage, *this );
   933         }
   933         }
   934     }
   934     }
   935 
   935 
   936 // -----------------------------------------------------------------------------
   936 // -----------------------------------------------------------------------------
   937 // CFSEmailUiMailViewerVisualiser::HandleTextViewerEventL
   937 // CFSEmailUiMailViewerVisualiser::HandleTextViewerEventL
   938 // From viewer observer for CFsTextViewer callbacks
   938 // From viewer observer for CFsTextViewer callbacks
   939 // -----------------------------------------------------------------------------
   939 // -----------------------------------------------------------------------------
   940 void CFSEmailUiMailViewerVisualiser::HandleTextViewerEventL( TFsTextViewerEvent aEvent )
   940 void CFSEmailUiMailViewerVisualiser::HandleTextViewerEventL( TFsTextViewerEvent aEvent )
   941 	{
   941     {
   942     FUNC_LOG;
   942     FUNC_LOG;
   943     if ( iFirstStartCompleted ) // Safety
   943     if ( iFirstStartCompleted ) // Safety
   944         {
   944         {
   945         if ( aEvent == EFsTextViewerHotspotClicked )
   945         if ( aEvent == EFsTextViewerHotspotClicked )
   946             {
   946             {
   986             {
   986             {
   987             // Hide action menu icon if current hotspot does not have action menu.
   987             // Hide action menu icon if current hotspot does not have action menu.
   988             SetActionMenuIconVisbilityL();
   988             SetActionMenuIconVisbilityL();
   989             }
   989             }
   990         }
   990         }
   991 	}
   991     }
   992 
   992 
   993 // -----------------------------------------------------------------------------
   993 // -----------------------------------------------------------------------------
   994 // CFSEmailUiMailViewerVisualiser::HandleHeaderHotspotActionL
   994 // CFSEmailUiMailViewerVisualiser::HandleHeaderHotspotActionL
   995 // Handle appropriate command for the selected header hotspot, if the currently
   995 // Handle appropriate command for the selected header hotspot, if the currently
   996 // focused item has some action specified. Returns ETrue, if current item has
   996 // focused item has some action specified. Returns ETrue, if current item has
  1034     return actionTaken;
  1034     return actionTaken;
  1035     }
  1035     }
  1036 
  1036 
  1037 // Helper funcitons to get viewed message ID and Folder id
  1037 // Helper funcitons to get viewed message ID and Folder id
  1038 TFSMailMsgId CFSEmailUiMailViewerVisualiser::ViewedMessageFolderId()
  1038 TFSMailMsgId CFSEmailUiMailViewerVisualiser::ViewedMessageFolderId()
  1039 	{
  1039     {
  1040     FUNC_LOG;
  1040     FUNC_LOG;
  1041 	TFSMailMsgId ret;
  1041     TFSMailMsgId ret;
  1042 	if ( iMessage )
  1042     if ( iMessage )
  1043 		{
  1043         {
  1044 		ret = iMessage->GetFolderId();
  1044         ret = iMessage->GetFolderId();
  1045 		}
  1045         }
  1046 	return ret;
  1046     return ret;
  1047 	}
  1047     }
  1048 
  1048 
  1049 TFSMailMsgId CFSEmailUiMailViewerVisualiser::ViewedMessageId()
  1049 TFSMailMsgId CFSEmailUiMailViewerVisualiser::ViewedMessageId()
  1050 	{
  1050     {
  1051     FUNC_LOG;
  1051     FUNC_LOG;
  1052 	TFSMailMsgId ret;
  1052     TFSMailMsgId ret;
  1053 	if ( iMessage )
  1053     if ( iMessage )
  1054 		{
  1054         {
  1055 		ret = iMessage->GetMessageId();
  1055         ret = iMessage->GetMessageId();
  1056 		}
  1056         }
  1057 	return ret;
  1057     return ret;
  1058 	}
  1058     }
  1059 
  1059 
  1060 // -----------------------------------------------------------------------------
  1060 // -----------------------------------------------------------------------------
  1061 // CFSEmailUiMailViewerVisualiser::RefreshL
  1061 // CFSEmailUiMailViewerVisualiser::RefreshL
  1062 // -----------------------------------------------------------------------------
  1062 // -----------------------------------------------------------------------------
  1063 void CFSEmailUiMailViewerVisualiser::RefreshL( TBool aFirstRefresh /*= EFalse*/ )
  1063 void CFSEmailUiMailViewerVisualiser::RefreshL( TBool aFirstRefresh /*= EFalse*/ )
  1069         //<cmail>
  1069         //<cmail>
  1070         //TInt waitNoteId = KErrNotFound;
  1070         //TInt waitNoteId = KErrNotFound;
  1071         //</cmail>
  1071         //</cmail>
  1072         if ( TFsEmailUiUtility::IsMessageBodyLargeL( iMessage ) )
  1072         if ( TFsEmailUiUtility::IsMessageBodyLargeL( iMessage ) )
  1073             {
  1073             {
  1074 	        //<cmail> using normal wait note instead of using global
  1074             //<cmail> using normal wait note instead of using global
  1075 	        //waitNoteId = TFsEmailUiUtility::ShowGlobalWaitNoteLC( R_FSE_WAIT_OPENING_TEXT );
  1075             //waitNoteId = TFsEmailUiUtility::ShowGlobalWaitNoteLC( R_FSE_WAIT_OPENING_TEXT );
  1076             iWaitDialogOpening = new(ELeave)CAknWaitDialog(
  1076             iWaitDialogOpening = new(ELeave)CAknWaitDialog(
  1077                                 (REINTERPRET_CAST(CEikDialog**,&iWaitDialogOpening)));
  1077                                 (REINTERPRET_CAST(CEikDialog**,&iWaitDialogOpening)));
  1078 	        HBufC* noteText = StringLoader::LoadLC( R_FSE_WAIT_OPENING_TEXT );
  1078             HBufC* noteText = StringLoader::LoadLC( R_FSE_WAIT_OPENING_TEXT );
  1079             iWaitDialogOpening->SetTextL(*noteText);
  1079             iWaitDialogOpening->SetTextL(*noteText);
  1080             //iWaitDialogOpening->DrawableWindow()->SetOrdinalPosition(0);
  1080             //iWaitDialogOpening->DrawableWindow()->SetOrdinalPosition(0);
  1081 	        CleanupStack::PopAndDestroy(noteText);
  1081             CleanupStack::PopAndDestroy(noteText);
  1082             iWaitDialogOpening->ExecuteLD(R_FSE_WAIT_DIALOG_NO_CANCEL);
  1082             iWaitDialogOpening->ExecuteLD(R_FSE_WAIT_DIALOG_NO_CANCEL);
  1083 	        //</cmail>
  1083             //</cmail>
  1084             }
  1084             }
  1085 
  1085 
  1086         // Do the update
  1086         // Do the update
  1087         UpdateMailViewerL();
  1087         UpdateMailViewerL();
  1088         AddBackgroundPicturesL();
  1088         AddBackgroundPicturesL();
  1096             iAsyncCallback->Set( TCallBack( DoPostRefresh, this ) );
  1096             iAsyncCallback->Set( TCallBack( DoPostRefresh, this ) );
  1097             iAsyncCallback->CallBack();
  1097             iAsyncCallback->CallBack();
  1098             }
  1098             }
  1099 
  1099 
  1100         // Close the wait note if it was opened
  1100         // Close the wait note if it was opened
  1101 		if ( iWaitDialogOpening )//<cmail>
  1101         if ( iWaitDialogOpening )//<cmail>
  1102             {
  1102             {
  1103 		    //<cmail>
  1103             //<cmail>
  1104 		    //CleanupStack::PopAndDestroy( (TAny*)waitNoteId );
  1104             //CleanupStack::PopAndDestroy( (TAny*)waitNoteId );
  1105             iWaitDialogOpening->ProcessFinishedL(); //it destroys the waitnote also
  1105             iWaitDialogOpening->ProcessFinishedL(); //it destroys the waitnote also
  1106 		    //</cmail>
  1106             //</cmail>
  1107             }
  1107             }
  1108         }
  1108         }
  1109     }
  1109     }
  1110 
  1110 
  1111 // -----------------------------------------------------------------------------
  1111 // -----------------------------------------------------------------------------
  1152 // CFSEmailUiMailViewerVisualiser::CheckMessageStructureL
  1152 // CFSEmailUiMailViewerVisualiser::CheckMessageStructureL
  1153 // Starts fetching message structure if it is unknown.
  1153 // Starts fetching message structure if it is unknown.
  1154 // If the structure is known but message body is not fetched yet, start fetching it.
  1154 // If the structure is known but message body is not fetched yet, start fetching it.
  1155 // -----------------------------------------------------------------------------
  1155 // -----------------------------------------------------------------------------
  1156 void CFSEmailUiMailViewerVisualiser::CheckMessageStructureL()
  1156 void CFSEmailUiMailViewerVisualiser::CheckMessageStructureL()
  1157 	{
  1157     {
  1158     FUNC_LOG;
  1158     FUNC_LOG;
  1159 	if ( iFirstStartCompleted && iMessage )
  1159     if ( iFirstStartCompleted && iMessage )
  1160 		{
  1160         {
  1161 		if ( !MessageStructureKnown( *iMessage ) )
  1161         if ( !MessageStructureKnown( *iMessage ) )
  1162 			{ // fetch structure
  1162             { // fetch structure
  1163 			StartWaitedFetchingL( EMessageStructure );
  1163             StartWaitedFetchingL( EMessageStructure );
  1164 			}
  1164             }
  1165 		else if ( StartFetchingBodyAfterOpeningL() )
  1165         else if ( StartFetchingBodyAfterOpeningL() )
  1166 			{
  1166             {
  1167 			iViewerRichText->AppendFetchingMoreTextL();
  1167             iViewerRichText->AppendFetchingMoreTextL();
  1168 			StartFetchingMessagePartL( *iMessage, EMessagePlainTextBodyPart );
  1168             StartFetchingMessagePartL( *iMessage, EMessagePlainTextBodyPart );
  1169 			iFetchingAnimationTimer->Start( KAnimationRefreshTimeIntervalInMilliseconds );
  1169             iFetchingAnimationTimer->Start( KAnimationRefreshTimeIntervalInMilliseconds );
  1170 			}
  1170             }
  1171 		}
  1171         }
  1172 	}
  1172     }
  1173 
  1173 
  1174 // -----------------------------------------------------------------------------
  1174 // -----------------------------------------------------------------------------
  1175 // CFSEmailUiMailViewerVisualiser::UpdateDownloadIndicatorL
  1175 // CFSEmailUiMailViewerVisualiser::UpdateDownloadIndicatorL
  1176 // Show or hide download progress indicator popup and update its contents if
  1176 // Show or hide download progress indicator popup and update its contents if
  1177 // necessary.
  1177 // necessary.
  1238 // -----------------------------------------------------------------------------
  1238 // -----------------------------------------------------------------------------
  1239 // CFSEmailUiMailViewerVisualiser::DynInitMenuPaneL
  1239 // CFSEmailUiMailViewerVisualiser::DynInitMenuPaneL
  1240 // For dynamically dimm/undimm menu options according to currect message and focus in the viewer
  1240 // For dynamically dimm/undimm menu options according to currect message and focus in the viewer
  1241 // -----------------------------------------------------------------------------
  1241 // -----------------------------------------------------------------------------
  1242 void CFSEmailUiMailViewerVisualiser::DynInitMenuPaneL(
  1242 void CFSEmailUiMailViewerVisualiser::DynInitMenuPaneL(
  1243 	TInt aResourceId, CEikMenuPane* aMenuPane )
  1243     TInt aResourceId, CEikMenuPane* aMenuPane )
  1244 	{
  1244     {
  1245     FUNC_LOG;
  1245     FUNC_LOG;
  1246 	if ( !iMessage || !iTextViewer )
  1246     if ( !iMessage || !iTextViewer )
  1247 	    {
  1247         {
  1248 	    User::Leave( KErrNotReady );
  1248         User::Leave( KErrNotReady );
  1249 	    }
  1249         }
  1250 
  1250 
  1251 	if ( aResourceId == R_FSEMAILUI_MAILVIEWER_MENUPANE )
  1251     if ( aResourceId == R_FSEMAILUI_MAILVIEWER_MENUPANE )
  1252 		{
  1252         {
  1253 		
  1253         
  1254 	    if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
  1254         if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
  1255 		   {
  1255            {
  1256 		   // remove help support in pf5250
  1256            // remove help support in pf5250
  1257 		   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
  1257            aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
  1258 		   }
  1258            }
  1259 	    
  1259         
  1260         // Folder independent options
  1260         // Folder independent options
  1261 
  1261 
  1262 		// hide/show MessageReader
  1262         // hide/show MessageReader
  1263 		TBool hideMessageReader = iEmbeddedMessageMode || !iAppUi.MessageReaderSupportsFreestyle();
  1263         TBool hideMessageReader = iEmbeddedMessageMode || !iAppUi.MessageReaderSupportsFreestyle();
  1264 		aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, hideMessageReader );
  1264         aMenuPane->SetItemDimmed( EFsEmailUiCmdReadEmail, hideMessageReader );
  1265 
  1265 
  1266 		// hide/show actions sub menu
  1266         // hide/show actions sub menu
  1267 		TBool hideActions = !ShowActionsMenuInOptionsL();
  1267         TBool hideActions = !ShowActionsMenuInOptionsL();
  1268 		aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, hideActions );
  1268         aMenuPane->SetItemDimmed( EFsEmailUiCmdMailActions, hideActions );
  1269 
  1269 
  1270 		// hide/show next and previous message options
  1270         // hide/show next and previous message options
  1271 		TBool hideNext = !ShowNextMessageMenuInOptions();
  1271         TBool hideNext = !ShowNextMessageMenuInOptions();
  1272 		aMenuPane->SetItemDimmed( EFsEmailUiCmdNextMessage, hideNext );
  1272         aMenuPane->SetItemDimmed( EFsEmailUiCmdNextMessage, hideNext );
  1273 		TBool hidePrev = !ShowPreviousMessageMenuInOptions();
  1273         TBool hidePrev = !ShowPreviousMessageMenuInOptions();
  1274 		aMenuPane->SetItemDimmed( EFsEmailUiCmdPreviousMessage, hidePrev );
  1274         aMenuPane->SetItemDimmed( EFsEmailUiCmdPreviousMessage, hidePrev );
  1275 
  1275 
  1276         // hide/show copy to clipboard
  1276         // hide/show copy to clipboard
  1277         TBool hideCopyToClipBoard = !IsCopyToClipBoardAvailableL();
  1277         TBool hideCopyToClipBoard = !IsCopyToClipBoardAvailableL();
  1278         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCopyToClipboard, hideCopyToClipBoard );
  1278         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCopyToClipboard, hideCopyToClipBoard );
  1279 
  1279 
  1280 
  1280 
  1281 		// Folder dependent options
  1281         // Folder dependent options
  1282 		TFSMailMsgId currentMessageFolderId = iMessage->GetFolderId();
  1282         TFSMailMsgId currentMessageFolderId = iMessage->GetFolderId();
  1283 		CFSMailFolder* currentFolder = NULL;
  1283         CFSMailFolder* currentFolder = NULL;
  1284 		if ( !iEmbeddedMessageMode )
  1284         if ( !iEmbeddedMessageMode )
  1285 		    {
  1285             {
  1286             TRAP_IGNORE( currentFolder = iAppUi.GetMailClient()->GetFolderByUidL(
  1286             TRAP_IGNORE( currentFolder = iAppUi.GetMailClient()->GetFolderByUidL(
  1287                     iMessage->GetMailBoxId(), currentMessageFolderId ) );
  1287                     iMessage->GetMailBoxId(), currentMessageFolderId ) );
  1288 		    }
  1288             }
  1289 		CleanupStack::PushL( currentFolder );
  1289         CleanupStack::PushL( currentFolder );
  1290 		if ( !currentFolder || currentFolder->GetFolderType() == EFSOutbox )
  1290         if ( !currentFolder || currentFolder->GetFolderType() == EFSOutbox )
  1291 			{ // outbox folder or embedded message
  1291             { // outbox folder or embedded message
  1292 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, ETrue );
  1292             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, ETrue );
  1293 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, ETrue );
  1293             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReply, ETrue );
  1294 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
  1294             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, ETrue );
  1295 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward2, ETrue );
  1295             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward2, ETrue );
  1296             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, !currentFolder );
  1296             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, !currentFolder );
  1297 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsDelete, !currentFolder );
  1297             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsDelete, !currentFolder );
  1298 			}
  1298             }
  1299 		else
  1299         else
  1300 			{ // other folders
  1300             { // other folders
  1301 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );
  1301             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveToDrafts, ETrue );
  1302 
  1302 
  1303 			// hide reply all if there's no multiple recipients
  1303             // hide reply all if there's no multiple recipients
  1304 			TInt numRecipients(0);
  1304             TInt numRecipients(0);
  1305             if ( iMessage )
  1305             if ( iMessage )
  1306                 {
  1306                 {
  1307                 //Get # of recipients
  1307                 //Get # of recipients
  1308                 numRecipients =TFsEmailUiUtility::CountRecepients( iMessage );
  1308                 numRecipients =TFsEmailUiUtility::CountRecepients( iMessage );
  1309                 if ( numRecipients == 1 )
  1309                 if ( numRecipients == 1 )
  1332                             }
  1332                             }
  1333                         }
  1333                         }
  1334                     }
  1334                     }
  1335                 }
  1335                 }
  1336 
  1336 
  1337 			TBool hideReplyAll = ( numRecipients <= 1 );
  1337             TBool hideReplyAll = ( numRecipients <= 1 );
  1338 		    aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, hideReplyAll );
  1338             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsReplyAll, hideReplyAll );
  1339 
  1339 
  1340             // In Sent folder, option forward is shown above options reply and reply all
  1340             // In Sent folder, option forward is shown above options reply and reply all
  1341             TBool forwardAboveReply = ( currentFolder->GetFolderType() == EFSSentFolder );
  1341             TBool forwardAboveReply = ( currentFolder->GetFolderType() == EFSSentFolder );
  1342             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, !forwardAboveReply );
  1342             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward, !forwardAboveReply );
  1343             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward2, forwardAboveReply );
  1343             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsForward2, forwardAboveReply );
  1344 			}
  1344             }
  1345 		CleanupStack::PopAndDestroy( currentFolder );
  1345         CleanupStack::PopAndDestroy( currentFolder );
  1346 		}
  1346         }
  1347 
  1347 
  1348 	if ( aResourceId == R_FSEMAILUI_MAILVIEWER_SUBMENU_MORE )
  1348     if ( aResourceId == R_FSEMAILUI_MAILVIEWER_SUBMENU_MORE )
  1349 		{
  1349         {
  1350 		TFSMailMsgId currentMessageFolderId = iMessage->GetFolderId();
  1350         TFSMailMsgId currentMessageFolderId = iMessage->GetFolderId();
  1351         CFSMailFolder* currentFolder = NULL;
  1351         CFSMailFolder* currentFolder = NULL;
  1352         if ( !iEmbeddedMessageMode )
  1352         if ( !iEmbeddedMessageMode )
  1353             {
  1353             {
  1354             TRAP_IGNORE( currentFolder = iAppUi.GetMailClient()->GetFolderByUidL(
  1354             TRAP_IGNORE( currentFolder = iAppUi.GetMailClient()->GetFolderByUidL(
  1355                     iMessage->GetMailBoxId(), currentMessageFolderId ) );
  1355                     iMessage->GetMailBoxId(), currentMessageFolderId ) );
  1356             }
  1356             }
  1357 		CleanupStack::PushL( currentFolder );
  1357         CleanupStack::PushL( currentFolder );
  1358 		if ( !currentFolder || currentFolder->GetFolderType() == EFSOutbox )
  1358         if ( !currentFolder || currentFolder->GetFolderType() == EFSOutbox )
  1359 			{  // outbox folder or embedded message
  1359             {  // outbox folder or embedded message
  1360 			aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, ETrue );
  1360             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, ETrue );
  1361 			aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, ETrue );
  1361             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, ETrue );
  1362 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, ETrue );
  1362             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, ETrue );
  1363 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
  1363             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, ETrue );
  1364 // <cmail> Prevent Download Manager opening with attachments
  1364 // <cmail> Prevent Download Manager opening with attachments
  1365 //			aMenuPane->SetItemDimmed( EFsEmailUiCmdDownloadManager, ETrue );
  1365 //          aMenuPane->SetItemDimmed( EFsEmailUiCmdDownloadManager, ETrue );
  1366 // </cmail> Prevent Download Manager opening with attachments
  1366 // </cmail> Prevent Download Manager opening with attachments
  1367 			}
  1367             }
  1368 		else // other folders
  1368         else // other folders
  1369 			{
  1369             {
  1370 			// show read/unread according to current state
  1370             // show read/unread according to current state
  1371 			TBool messageIsRead = iMessage->IsFlagSet( EFSMsgFlag_Read );
  1371             TBool messageIsRead = iMessage->IsFlagSet( EFSMsgFlag_Read );
  1372 			aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, messageIsRead );
  1372             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsRead, messageIsRead );
  1373 			aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !messageIsRead );
  1373             aMenuPane->SetItemDimmed( EFsEmailUiCmdMarkAsUnread, !messageIsRead );
  1374 
  1374 
  1375 			// show/hide move message
  1375             // show/hide move message
  1376 			TBool hideMove = !iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder );
  1376             TBool hideMove = !iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder );
  1377 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, hideMove );
  1377             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsMoveMessage, hideMove );
  1378 
  1378 
  1379 			// show/hide flag for followup
  1379             // show/hide flag for followup
  1380 			TBool hideFlag = !TFsEmailUiUtility::IsFollowUpSupported( *iMailBox );
  1380             TBool hideFlag = !TFsEmailUiUtility::IsFollowUpSupported( *iMailBox );
  1381 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, hideFlag );
  1381             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsFlag, hideFlag );
  1382 
  1382 
  1383 			// hide/show download manager option
  1383             // hide/show download manager option
  1384 // <cmail> Prevent Download Manager opening with attachments
  1384 // <cmail> Prevent Download Manager opening with attachments
  1385 //			TBool hideDownloadMan = !ShowDownloadManagerMenuInOptions();
  1385 //          TBool hideDownloadMan = !ShowDownloadManagerMenuInOptions();
  1386 //			aMenuPane->SetItemDimmed( EFsEmailUiCmdDownloadManager, hideDownloadMan );
  1386 //          aMenuPane->SetItemDimmed( EFsEmailUiCmdDownloadManager, hideDownloadMan );
  1387 // </cmail>
  1387 // </cmail>
  1388 			}
  1388             }
  1389 		CleanupStack::PopAndDestroy( currentFolder );
  1389         CleanupStack::PopAndDestroy( currentFolder );
  1390 		}
  1390         }
  1391 
  1391 
  1392 	if ( aResourceId == R_FSEMAILUI_MAILVIEWER_SUBMENU_ACTIONS )
  1392     if ( aResourceId == R_FSEMAILUI_MAILVIEWER_SUBMENU_ACTIONS )
  1393 		{
  1393         {
  1394 		// All menu items are hidden by default.
  1394         // All menu items are hidden by default.
  1395 		// Undimm items that should be visible in action menu.
  1395         // Undimm items that should be visible in action menu.
  1396 		SViewerHeadingHotSpotData currentHeaderHotSpotData;
  1396         SViewerHeadingHotSpotData currentHeaderHotSpotData;
  1397 		CFindItemEngine::SFoundItem currentBodyHotSpotData;
  1397         CFindItemEngine::SFoundItem currentBodyHotSpotData;
  1398 		THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL(
  1398         THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL(
  1399 			currentHeaderHotSpotData, currentBodyHotSpotData );
  1399             currentHeaderHotSpotData, currentBodyHotSpotData );
  1400 
  1400 
  1401 		TBool remoteLookupAvailable =
  1401         TBool remoteLookupAvailable =
  1402 			TFsEmailUiUtility::IsRemoteLookupSupported( *iMailBox );
  1402             TFsEmailUiUtility::IsRemoteLookupSupported( *iMailBox );
  1403 
  1403 
  1404 		if ( ( hotspotType == EHeaderHotspot && (
  1404         if ( ( hotspotType == EHeaderHotspot && (
  1405 			currentHeaderHotSpotData.iType == ETypeFromAddressDisplayName ||
  1405             currentHeaderHotSpotData.iType == ETypeFromAddressDisplayName ||
  1406 			currentHeaderHotSpotData.iType == ETypeToAddressDisplayName ||
  1406             currentHeaderHotSpotData.iType == ETypeToAddressDisplayName ||
  1407 			currentHeaderHotSpotData.iType == ETypeCcAddressDisplayName ||
  1407             currentHeaderHotSpotData.iType == ETypeCcAddressDisplayName ||
  1408 			currentHeaderHotSpotData.iType == ETypeBccAddressDisplayName ||
  1408             currentHeaderHotSpotData.iType == ETypeBccAddressDisplayName ||
  1409 			currentHeaderHotSpotData.iType == ETypeEmailAddress )  )
  1409             currentHeaderHotSpotData.iType == ETypeEmailAddress )  )
  1410 			||
  1410             ||
  1411 			( hotspotType == EBodyHotspot &&
  1411             ( hotspotType == EBodyHotspot &&
  1412 			  currentBodyHotSpotData.iItemType ==
  1412               currentBodyHotSpotData.iItemType ==
  1413 				CFindItemEngine::EFindItemSearchMailAddressBin ) )
  1413                 CFindItemEngine::EFindItemSearchMailAddressBin ) )
  1414 			{
  1414             {
  1415 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCall, EFalse );
  1415             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCall, EFalse );
  1416 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCreateMessage, EFalse );
  1416             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCreateMessage, EFalse );
  1417 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCreateMail, EFalse );
  1417             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCreateMail, EFalse );
  1418 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsContactDetails, EFalse );
  1418             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsContactDetails, EFalse );
  1419 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact2, EFalse );
  1419             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact2, EFalse );
  1420 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, !remoteLookupAvailable );
  1420             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, !remoteLookupAvailable );
  1421 			}
  1421             }
  1422 		else if ( hotspotType == EHeaderHotspot &&
  1422         else if ( hotspotType == EHeaderHotspot &&
  1423                   currentHeaderHotSpotData.iType == ETypeAttachment )
  1423                   currentHeaderHotSpotData.iType == ETypeAttachment )
  1424 			{
  1424             {
  1425 			TBool hideOpen = !ShowOpenAttachmentOptionL();
  1425             TBool hideOpen = !ShowOpenAttachmentOptionL();
  1426    			aMenuPane->SetItemDimmed( EFsEmailUiCmdOpenAttachment, hideOpen );
  1426             aMenuPane->SetItemDimmed( EFsEmailUiCmdOpenAttachment, hideOpen );
  1427 			TBool hideDownload = !ShowDownloadOptionL();
  1427             TBool hideDownload = !ShowDownloadOptionL();
  1428 			aMenuPane->SetItemDimmed( EFsEmailUiCmdDownload, hideDownload );
  1428             aMenuPane->SetItemDimmed( EFsEmailUiCmdDownload, hideDownload );
  1429 			TBool hideCancel = !ShowCancelDownloadOption();
  1429             TBool hideCancel = !ShowCancelDownloadOption();
  1430 			aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelDownload, hideCancel );
  1430             aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelDownload, hideCancel );
  1431 			TBool hideSave = !ShowSaveAttachmentOptionL();
  1431             TBool hideSave = !ShowSaveAttachmentOptionL();
  1432 		    aMenuPane->SetItemDimmed( EFsEmailUiCmdSave, hideSave );
  1432             aMenuPane->SetItemDimmed( EFsEmailUiCmdSave, hideSave );
  1433 
  1433 
  1434 		    TBool hideRemove = hideOpen;
  1434             TBool hideRemove = hideOpen;
  1435             aMenuPane->SetItemDimmed( EFsEmailUiCmdClearFetchedAttachment, hideRemove );
  1435             aMenuPane->SetItemDimmed( EFsEmailUiCmdClearFetchedAttachment, hideRemove );
  1436 			}
  1436             }
  1437 		else if ( hotspotType == EHeaderHotspot &&
  1437         else if ( hotspotType == EHeaderHotspot &&
  1438 		          currentHeaderHotSpotData.iType == ETypeAttachments )
  1438                   currentHeaderHotSpotData.iType == ETypeAttachments )
  1439 			{
  1439             {
  1440 			TBool hideOpen = !ShowOpenAttachmentOptionL();
  1440             TBool hideOpen = !ShowOpenAttachmentOptionL();
  1441    			aMenuPane->SetItemDimmed( EFsEmailUiCmdOpenAttachmentList, hideOpen );
  1441             aMenuPane->SetItemDimmed( EFsEmailUiCmdOpenAttachmentList, hideOpen );
  1442 			TBool hideDownload = !ShowDownloadOptionL();
  1442             TBool hideDownload = !ShowDownloadOptionL();
  1443 			aMenuPane->SetItemDimmed( EFsEmailUiCmdDownloadAll, hideDownload );
  1443             aMenuPane->SetItemDimmed( EFsEmailUiCmdDownloadAll, hideDownload );
  1444 			TBool hideCancel = !ShowCancelDownloadOption();
  1444             TBool hideCancel = !ShowCancelDownloadOption();
  1445 			aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelAllDownloads, hideCancel );
  1445             aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelAllDownloads, hideCancel );
  1446 			TBool hideSave = !ShowSaveAttachmentOptionL();
  1446             TBool hideSave = !ShowSaveAttachmentOptionL();
  1447 		    aMenuPane->SetItemDimmed( EFsEmailUiCmdSaveAll, hideSave );
  1447             aMenuPane->SetItemDimmed( EFsEmailUiCmdSaveAll, hideSave );
  1448 			}
  1448             }
  1449 		else if ( hotspotType == EBodyHotspot &&
  1449         else if ( hotspotType == EBodyHotspot &&
  1450 				  currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchPhoneNumberBin )
  1450                   currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchPhoneNumberBin )
  1451 			{
  1451             {
  1452 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCall, EFalse );
  1452             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCall, EFalse );
  1453 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, EFalse );
  1453             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, EFalse );
  1454 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCreateMessage, EFalse );
  1454             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCreateMessage, EFalse );
  1455 			aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, !remoteLookupAvailable );
  1455             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, !remoteLookupAvailable );
  1456 			}
  1456             }
  1457 		else if ( hotspotType == EBodyHotspot &&
  1457         else if ( hotspotType == EBodyHotspot &&
  1458 				  ( currentBodyHotSpotData.iItemType ==
  1458                   ( currentBodyHotSpotData.iItemType ==
  1459 				  	CFindItemEngine::EFindItemSearchURLBin ||
  1459                     CFindItemEngine::EFindItemSearchURLBin ||
  1460 				  	currentBodyHotSpotData.iItemType ==
  1460                     currentBodyHotSpotData.iItemType ==
  1461 				  	CFindItemEngine::EFindItemSearchScheme ) )
  1461                     CFindItemEngine::EFindItemSearchScheme ) )
  1462 			{
  1462             {
  1463 			// Handle action menu for different search scheme, e.g mailto: and call:
  1463             // Handle action menu for different search scheme, e.g mailto: and call:
  1464 			TInt schemaLinkType = ResolveBodyTextSchemaUrlTypeL( currentBodyHotSpotData );
  1464             TInt schemaLinkType = ResolveBodyTextSchemaUrlTypeL( currentBodyHotSpotData );
  1465 			switch ( schemaLinkType )
  1465             switch ( schemaLinkType )
  1466 				{
  1466                 {
  1467 				case EFocusOnEMailInBodyText:
  1467                 case EFocusOnEMailInBodyText:
  1468 					{
  1468                     {
  1469 					aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCall, EFalse );
  1469                     aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCall, EFalse );
  1470 					aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCreateMessage, EFalse );
  1470                     aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCreateMessage, EFalse );
  1471 					aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsContactDetails, EFalse );
  1471                     aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsContactDetails, EFalse );
  1472 					aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact2, EFalse );
  1472                     aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact2, EFalse );
  1473 					aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, !remoteLookupAvailable );
  1473                     aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, !remoteLookupAvailable );
  1474 					}
  1474                     }
  1475 					break;
  1475                     break;
  1476 				case EFocusOnNumberWithinMessage:
  1476                 case EFocusOnNumberWithinMessage:
  1477 					{
  1477                     {
  1478 					aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCall, EFalse );
  1478                     aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCall, EFalse );
  1479 					aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, EFalse );
  1479                     aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddContact, EFalse );
  1480 					// Drop out "Create message" selection for SIP addresses
  1480                     // Drop out "Create message" selection for SIP addresses
  1481 					HBufC* schemeText = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  1481                     HBufC* schemeText = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  1482 					if ( schemeText && schemeText->FindC( KVoipPrefix ) != 0 )
  1482                     if ( schemeText && schemeText->FindC( KVoipPrefix ) != 0 )
  1483 						{
  1483                         {
  1484 						aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCreateMessage, EFalse );
  1484                         aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCreateMessage, EFalse );
  1485 						}
  1485                         }
  1486 					CleanupStack::PopAndDestroy( schemeText );
  1486                     CleanupStack::PopAndDestroy( schemeText );
  1487 					aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, !remoteLookupAvailable );
  1487                     aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsRemoteLookup, !remoteLookupAvailable );
  1488 					}
  1488                     }
  1489 					break;
  1489                     break;
  1490 				default:
  1490                 default:
  1491 					{
  1491                     {
  1492 					aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpenWeb, EFalse );
  1492                     aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsOpenWeb, EFalse );
  1493 
  1493 
  1494 					// Handle intranet browsing item by using AIW service
  1494                     // Handle intranet browsing item by using AIW service
  1495 					// handler's InitializeMenuPaneL-function, it will remove
  1495                     // handler's InitializeMenuPaneL-function, it will remove
  1496 					// the IB menu item if IB is not available, or make the
  1496                     // the IB menu item if IB is not available, or make the
  1497 					// item visible if IB is available
  1497                     // item visible if IB is available
  1498 			        if ( iIBServiceHandler && iIBServiceHandler->IsAiwMenu( aResourceId ) )
  1498                     if ( iIBServiceHandler && iIBServiceHandler->IsAiwMenu( aResourceId ) )
  1499 			            {
  1499                         {
  1500 			            TAiwGenericParam param( EGenericParamURL );
  1500                         TAiwGenericParam param( EGenericParamURL );
  1501 			            CAiwGenericParamList* list = CAiwGenericParamList::NewLC();
  1501                         CAiwGenericParamList* list = CAiwGenericParamList::NewLC();
  1502 			            list->AppendL( param );
  1502                         list->AppendL( param );
  1503 			            iIBServiceHandler->InitializeMenuPaneL( *aMenuPane, aResourceId,
  1503                         iIBServiceHandler->InitializeMenuPaneL( *aMenuPane, aResourceId,
  1504 			                    EFsEmailUiCmdActionsOpenInIntranetMenu, *list, ETrue );
  1504                                 EFsEmailUiCmdActionsOpenInIntranetMenu, *list, ETrue );
  1505 			            CleanupStack::PopAndDestroy( list );
  1505                         CleanupStack::PopAndDestroy( list );
  1506 			            }
  1506                         }
  1507 
  1507 
  1508 					aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddBookmark, EFalse );
  1508                     aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsAddBookmark, EFalse );
  1509 					}
  1509                     }
  1510 					break;
  1510                     break;
  1511 				}
  1511                 }
  1512 			}
  1512             }
  1513 		}
  1513         }
  1514 
  1514 
  1515 	iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane,
  1515     iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane,
  1516 		CFSEmailUiShortcutBinding::EContextMailViewer );
  1516         CFSEmailUiShortcutBinding::EContextMailViewer );
  1517 	}
  1517     }
  1518 
  1518 
  1519 
  1519 
  1520 // -----------------------------------------------------------------------------
  1520 // -----------------------------------------------------------------------------
  1521 // CFSEmailUiMailViewerVisualiser::HandleCommandL
  1521 // CFSEmailUiMailViewerVisualiser::HandleCommandL
  1522 // Handles menu selections
  1522 // Handles menu selections
  1523 // -----------------------------------------------------------------------------
  1523 // -----------------------------------------------------------------------------
  1524 void CFSEmailUiMailViewerVisualiser::HandleCommandL( TInt aCommand )
  1524 void CFSEmailUiMailViewerVisualiser::HandleCommandL( TInt aCommand )
  1525     {
  1525     {
  1526     FUNC_LOG;
  1526     FUNC_LOG;
  1527 	if ( !iAppUi.ViewSwitchingOngoing() )
  1527     if ( !iAppUi.ViewSwitchingOngoing() )
  1528     	{
  1528         {
  1529 	    switch ( aCommand )
  1529         switch ( aCommand )
  1530 	        {
  1530             {
  1531 	        case EAknSoftkeyBack:
  1531             case EAknSoftkeyBack:
  1532 	        	{
  1532                 {
  1533 	        	// Set empty MSK when navigating back
  1533                 // Set empty MSK when navigating back
  1534 	        	ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1534                 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  1535 	        	// Cancel MR viewer launching if Back is pressed in the middle
  1535                 // Cancel MR viewer launching if Back is pressed in the middle
  1536 	        	// of launching process.
  1536                 // of launching process.
  1537 	            CancelPendingMrCommandL();
  1537                 CancelPendingMrCommandL();
  1538 	        	NavigateBackL();
  1538                 NavigateBackL();
  1539 	 			}
  1539                 }
  1540 	        	break;
  1540                 break;
  1541 	        // top level options
  1541             // top level options
  1542 	        case EFsEmailUiCmdActionsMoveToDrafts:
  1542             case EFsEmailUiCmdActionsMoveToDrafts:
  1543 	        	{
  1543                 {
  1544 	        	TFsEmailUiUtility::MoveMessageToDraftsL(
  1544                 TFsEmailUiUtility::MoveMessageToDraftsL(
  1545 	        		*iAppUi.GetActiveMailbox(), *iMessage );
  1545                     *iAppUi.GetActiveMailbox(), *iMessage );
  1546 	        	}
  1546                 }
  1547 	        	break;
  1547                 break;
  1548 	       	case EFsEmailUiCmdCalActionsReplyAsMail:
  1548             case EFsEmailUiCmdCalActionsReplyAsMail:
  1549 			case EFsEmailUiCmdActionsReply:
  1549             case EFsEmailUiCmdActionsReply:
  1550 				{
  1550                 {
  1551 				if ( !iEmbeddedMessageMode )
  1551                 if ( !iEmbeddedMessageMode )
  1552 				    {
  1552                     {
  1553                     TEditorLaunchParams params;
  1553                     TEditorLaunchParams params;
  1554                     params.iMailboxId = iAppUi.GetActiveMailboxId();
  1554                     params.iMailboxId = iAppUi.GetActiveMailboxId();
  1555                     params.iMsgId = iMessage->GetMessageId();
  1555                     params.iMsgId = iMessage->GetMessageId();
  1556                     params.iActivatedExternally = EFalse;
  1556                     params.iActivatedExternally = EFalse;
  1557                     iAppUi.LaunchEditorL( KEditorCmdReply, params );
  1557                     iAppUi.LaunchEditorL( KEditorCmdReply, params );
  1558 				    }
  1558                     }
  1559 				}
  1559                 }
  1560 	            break;
  1560                 break;
  1561 			case EFsEmailUiCmdActionsReplyAll:
  1561             case EFsEmailUiCmdActionsReplyAll:
  1562 				{
  1562                 {
  1563 				if ( !iEmbeddedMessageMode )
  1563                 if ( !iEmbeddedMessageMode )
  1564 				    {
  1564                     {
  1565                     TEditorLaunchParams params;
  1565                     TEditorLaunchParams params;
  1566                     params.iMailboxId = iAppUi.GetActiveMailboxId();
  1566                     params.iMailboxId = iAppUi.GetActiveMailboxId();
  1567                     params.iMsgId = iMessage->GetMessageId();
  1567                     params.iMsgId = iMessage->GetMessageId();
  1568                     params.iActivatedExternally = EFalse;
  1568                     params.iActivatedExternally = EFalse;
  1569                     iAppUi.LaunchEditorL( KEditorCmdReplyAll, params );
  1569                     iAppUi.LaunchEditorL( KEditorCmdReplyAll, params );
  1570 				    }
  1570                     }
  1571 				}
  1571                 }
  1572 	            break;
  1572                 break;
  1573 	       	case EFsEmailUiCmdCalActionsForwardAsMail:
  1573             case EFsEmailUiCmdCalActionsForwardAsMail:
  1574 			case EFsEmailUiCmdActionsForward:
  1574             case EFsEmailUiCmdActionsForward:
  1575 			case EFsEmailUiCmdActionsForward2:
  1575             case EFsEmailUiCmdActionsForward2:
  1576 				{
  1576                 {
  1577 				if ( !iEmbeddedMessageMode )
  1577                 if ( !iEmbeddedMessageMode )
  1578 				    {
  1578                     {
  1579                     TEditorLaunchParams params;
  1579                     TEditorLaunchParams params;
  1580                     params.iMailboxId = iAppUi.GetActiveMailboxId();
  1580                     params.iMailboxId = iAppUi.GetActiveMailboxId();
  1581                     params.iMsgId = iMessage->GetMessageId();
  1581                     params.iMsgId = iMessage->GetMessageId();
  1582                     params.iActivatedExternally = EFalse;
  1582                     params.iActivatedExternally = EFalse;
  1583                     iAppUi.LaunchEditorL( KEditorCmdForward, params );
  1583                     iAppUi.LaunchEditorL( KEditorCmdForward, params );
  1584 				    }
  1584                     }
  1585 				}
  1585                 }
  1586 	            break;
  1586                 break;
  1587 			case EFsEmailUiCmdActionsDelete:
  1587             case EFsEmailUiCmdActionsDelete:
  1588 				{
  1588                 {
  1589 				DeleteMailL( *iMessage, ETrue );
  1589                 DeleteMailL( *iMessage, ETrue );
  1590 				}
  1590                 }
  1591 	            break;
  1591                 break;
  1592 	        case EFsEmailUiCmdActionsCopyToClipboard:
  1592             case EFsEmailUiCmdActionsCopyToClipboard:
  1593 	        	{
  1593                 {
  1594 	        	CopyCurrentHotspotToClipBoardL();
  1594                 CopyCurrentHotspotToClipBoardL();
  1595 	        	}
  1595                 }
  1596 	        	break;
  1596                 break;
  1597 	        case EFsEmailUiCmdPreviousMessage:
  1597             case EFsEmailUiCmdPreviousMessage:
  1598 	        	{
  1598                 {
  1599 				ShowPreviousMessageL();
  1599                 ShowPreviousMessageL();
  1600 	        	}
  1600                 }
  1601 	        	break;
  1601                 break;
  1602 	        case EFsEmailUiCmdNextMessage:
  1602             case EFsEmailUiCmdNextMessage:
  1603 	        	{
  1603                 {
  1604 				ShowNextMessageL();
  1604                 ShowNextMessageL();
  1605 				}
  1605                 }
  1606 	        	break;
  1606                 break;
  1607 	        case EFsEmailUiCmdHelp:
  1607             case EFsEmailUiCmdHelp:
  1608 	        	{
  1608                 {
  1609 	        	TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
  1609                 TFsEmailUiUtility::LaunchHelpL( KFSE_HLP_LAUNCHER_GRID );
  1610 	        	}
  1610                 }
  1611 	        	break;
  1611                 break;
  1612 	        case EFsEmailUiCmdExit:
  1612             case EFsEmailUiCmdExit:
  1613 			    {
  1613                 {
  1614 		    	iAppUi.Exit();
  1614                 iAppUi.Exit();
  1615 		        }
  1615                 }
  1616 		        break;
  1616                 break;
  1617 	        case EFsEmailUiCmdReadEmail:
  1617             case EFsEmailUiCmdReadEmail:
  1618 	        	{
  1618                 {
  1619 	        	iAppUi.StartReadingEmailsL();
  1619                 iAppUi.StartReadingEmailsL();
  1620 	        	}
  1620                 }
  1621 	        	break;
  1621                 break;
  1622 
  1622 
  1623 			// "actions" -sub menu options
  1623             // "actions" -sub menu options
  1624 	        case EFsEmailUiCmdActionsCall:
  1624             case EFsEmailUiCmdActionsCall:
  1625 	        	{
  1625                 {
  1626 				CallHotSpotAddressL();
  1626                 CallHotSpotAddressL();
  1627 	        	}
  1627                 }
  1628 				break;
  1628                 break;
  1629 			case EFsEmailUiCmdActionsCreateMessage:
  1629             case EFsEmailUiCmdActionsCreateMessage:
  1630 				{
  1630                 {
  1631 				CreateMessageL();
  1631                 CreateMessageL();
  1632 				}
  1632                 }
  1633 				break;
  1633                 break;
  1634 			case EFsEmailUiCmdActionsCreateMail:
  1634             case EFsEmailUiCmdActionsCreateMail:
  1635 			    {
  1635                 {
  1636 			    ComposeMailL();
  1636                 ComposeMailL();
  1637 			    }
  1637                 }
  1638 			    break;
  1638                 break;
  1639 	        case EFsEmailUiCmdActionsContactDetails:
  1639             case EFsEmailUiCmdActionsContactDetails:
  1640 	        	{
  1640                 {
  1641 				OpenContactDetailsL();
  1641                 OpenContactDetailsL();
  1642 	        	}
  1642                 }
  1643 				break;
  1643                 break;
  1644 	        case EFsEmailUiCmdActionsAddContact:
  1644             case EFsEmailUiCmdActionsAddContact:
  1645 	        case EFsEmailUiCmdActionsAddContact2:
  1645             case EFsEmailUiCmdActionsAddContact2:
  1646 	        	{
  1646                 {
  1647 				SViewerHeadingHotSpotData currentHeaderHotSpotData;
  1647                 SViewerHeadingHotSpotData currentHeaderHotSpotData;
  1648 				CFindItemEngine::SFoundItem currentBodyHotSpotData;
  1648                 CFindItemEngine::SFoundItem currentBodyHotSpotData;
  1649 				THotspotType hotspotType =
  1649                 THotspotType hotspotType =
  1650 					iViewerRichText->FindCurrentHotSpotL(
  1650                     iViewerRichText->FindCurrentHotSpotL(
  1651 						currentHeaderHotSpotData, currentBodyHotSpotData );
  1651                         currentHeaderHotSpotData, currentBodyHotSpotData );
  1652 		     	if ( hotspotType == EHeaderHotspot )
  1652                 if ( hotspotType == EHeaderHotspot )
  1653 	        		{
  1653                     {
  1654 					HBufC* emailAddress =
  1654                     HBufC* emailAddress =
  1655 						iViewerRichText->GetHeaderHotspotEmailAddressLC(
  1655                         iViewerRichText->GetHeaderHotspotEmailAddressLC(
  1656 							currentHeaderHotSpotData );
  1656                             currentHeaderHotSpotData );
  1657 					SaveEmailAsContactL( *emailAddress );
  1657                     SaveEmailAsContactL( *emailAddress );
  1658 					CleanupStack::PopAndDestroy( emailAddress );
  1658                     CleanupStack::PopAndDestroy( emailAddress );
  1659 					}
  1659                     }
  1660 	        	else if ( hotspotType == EBodyHotspot )
  1660                 else if ( hotspotType == EBodyHotspot )
  1661 	        		{
  1661                     {
  1662 					HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  1662                     HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  1663 						currentBodyHotSpotData );
  1663                         currentBodyHotSpotData );
  1664 					if ( currentBodyHotSpotData.iItemType ==
  1664                     if ( currentBodyHotSpotData.iItemType ==
  1665 						CFindItemEngine::EFindItemSearchPhoneNumberBin )
  1665                         CFindItemEngine::EFindItemSearchPhoneNumberBin )
  1666 						{
  1666                         {
  1667 						SavePhoneNumberAsContactL( *hotspotText );
  1667                         SavePhoneNumberAsContactL( *hotspotText );
  1668 						}
  1668                         }
  1669 					else if ( currentBodyHotSpotData.iItemType ==
  1669                     else if ( currentBodyHotSpotData.iItemType ==
  1670 						CFindItemEngine::EFindItemSearchMailAddressBin )
  1670                         CFindItemEngine::EFindItemSearchMailAddressBin )
  1671 						{
  1671                         {
  1672 						SaveEmailAsContactL( *hotspotText );
  1672                         SaveEmailAsContactL( *hotspotText );
  1673 						}
  1673                         }
  1674 					else if ( currentBodyHotSpotData.iItemType ==
  1674                     else if ( currentBodyHotSpotData.iItemType ==
  1675 							CFindItemEngine::EFindItemSearchScheme)
  1675                             CFindItemEngine::EFindItemSearchScheme)
  1676 						{
  1676                         {
  1677 						if ( hotspotText->FindC( KMailtoPrefix ) == 0 )
  1677                         if ( hotspotText->FindC( KMailtoPrefix ) == 0 )
  1678 							{
  1678                             {
  1679 							// Save email address, prefix is stripped in SaveEmailAsContactL
  1679                             // Save email address, prefix is stripped in SaveEmailAsContactL
  1680 							SaveEmailAsContactL( *hotspotText );
  1680                             SaveEmailAsContactL( *hotspotText );
  1681 							}
  1681                             }
  1682 						else if ( hotspotText->FindC( KCallPrefix ) == 0 ||
  1682                         else if ( hotspotText->FindC( KCallPrefix ) == 0 ||
  1683 								  hotspotText->FindC( KTelPrefix ) == 0  ||
  1683                                   hotspotText->FindC( KTelPrefix ) == 0  ||
  1684 								  hotspotText->FindC( KSmsPrefix ) == 0 ||
  1684                                   hotspotText->FindC( KSmsPrefix ) == 0 ||
  1685 								  hotspotText->FindC( KMmsPrefix ) == 0 )
  1685                                   hotspotText->FindC( KMmsPrefix ) == 0 )
  1686 							{
  1686                             {
  1687 							// Save phone nukmber, prefix is stripped in SavePhoneNumberAsContactL
  1687                             // Save phone nukmber, prefix is stripped in SavePhoneNumberAsContactL
  1688 							SavePhoneNumberAsContactL( *hotspotText );
  1688                             SavePhoneNumberAsContactL( *hotspotText );
  1689 							}
  1689                             }
  1690 						}
  1690                         }
  1691 	 	      		CleanupStack::PopAndDestroy( hotspotText );
  1691                     CleanupStack::PopAndDestroy( hotspotText );
  1692 	        		}
  1692                     }
  1693 	        	}
  1693                 }
  1694 				break;
  1694                 break;
  1695 	 	    case EFsEmailUiCmdActionsRemoteLookup:
  1695             case EFsEmailUiCmdActionsRemoteLookup:
  1696 	        	{
  1696                 {
  1697 				SViewerHeadingHotSpotData currentHeaderHotSpotData;
  1697                 SViewerHeadingHotSpotData currentHeaderHotSpotData;
  1698 				CFindItemEngine::SFoundItem currentBodyHotSpotData;
  1698                 CFindItemEngine::SFoundItem currentBodyHotSpotData;
  1699 				THotspotType hotspotType =
  1699                 THotspotType hotspotType =
  1700 					iViewerRichText->FindCurrentHotSpotL(
  1700                     iViewerRichText->FindCurrentHotSpotL(
  1701 						currentHeaderHotSpotData, currentBodyHotSpotData );
  1701                         currentHeaderHotSpotData, currentBodyHotSpotData );
  1702 		     	if ( hotspotType == EHeaderHotspot )
  1702                 if ( hotspotType == EHeaderHotspot )
  1703 	        		{
  1703                     {
  1704 					HBufC* emailAddress =
  1704                     HBufC* emailAddress =
  1705 						iViewerRichText->GetHeaderHotspotEmailAddressLC(
  1705                         iViewerRichText->GetHeaderHotspotEmailAddressLC(
  1706 							currentHeaderHotSpotData );
  1706                             currentHeaderHotSpotData );
  1707 					LaunchRemoteLookupL( *emailAddress );
  1707                     LaunchRemoteLookupL( *emailAddress );
  1708 					CleanupStack::PopAndDestroy( emailAddress );
  1708                     CleanupStack::PopAndDestroy( emailAddress );
  1709 	      			}
  1709                     }
  1710 	        	else if ( hotspotType == EBodyHotspot )
  1710                 else if ( hotspotType == EBodyHotspot )
  1711 	        		{
  1711                     {
  1712 					HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  1712                     HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  1713 						currentBodyHotSpotData );
  1713                         currentBodyHotSpotData );
  1714 					LaunchRemoteLookupL( *hotspotText );
  1714                     LaunchRemoteLookupL( *hotspotText );
  1715 	 	      		CleanupStack::PopAndDestroy( hotspotText );
  1715                     CleanupStack::PopAndDestroy( hotspotText );
  1716 		       		}
  1716                     }
  1717 	 		  	}
  1717                 }
  1718 				break;
  1718                 break;
  1719 	 	    case EFsEmailUiCmdActionsOpenHtmlViewer:
  1719             case EFsEmailUiCmdActionsOpenHtmlViewer:
  1720 	 	        {
  1720                 {
  1721 	 	        LaunchHtmlViewerL();
  1721                 LaunchHtmlViewerL();
  1722 	 	        }
  1722                 }
  1723 	 	        break;
  1723                 break;
  1724 	        case EFsEmailUiCmdActionsOpenWeb:
  1724             case EFsEmailUiCmdActionsOpenWeb:
  1725 	        	{
  1725                 {
  1726 				CFindItemEngine::SFoundItem currentBodyHotSpotData;
  1726                 CFindItemEngine::SFoundItem currentBodyHotSpotData;
  1727 				TBool bodyHotSpotFound =
  1727                 TBool bodyHotSpotFound =
  1728 					iViewerRichText->FindCurrentBodyHotSpotL(
  1728                     iViewerRichText->FindCurrentBodyHotSpotL(
  1729 						currentBodyHotSpotData );
  1729                         currentBodyHotSpotData );
  1730 				OpenHotSpotUrlInBrowserL( currentBodyHotSpotData );
  1730                 OpenHotSpotUrlInBrowserL( currentBodyHotSpotData );
  1731 	        	}
  1731                 }
  1732 				break;
  1732                 break;
  1733 	        case EFsEmailUiCmdActionsOpenInIntranetMenu:
  1733             case EFsEmailUiCmdActionsOpenInIntranetMenu:
  1734 	        	{
  1734                 {
  1735 				OpenLinkInIntranetL( ETrue );
  1735                 OpenLinkInIntranetL( ETrue );
  1736 		       	}
  1736                 }
  1737 				break;
  1737                 break;
  1738 	        case EFsEmailUiCmdActionsAddBookmark:
  1738             case EFsEmailUiCmdActionsAddBookmark:
  1739 	        	{
  1739                 {
  1740 				CFindItemEngine::SFoundItem currentBodyHotSpotData;
  1740                 CFindItemEngine::SFoundItem currentBodyHotSpotData;
  1741 				TBool bodyHotSpotFound =
  1741                 TBool bodyHotSpotFound =
  1742 					iViewerRichText->FindCurrentBodyHotSpotL(
  1742                     iViewerRichText->FindCurrentBodyHotSpotL(
  1743 						currentBodyHotSpotData );
  1743                         currentBodyHotSpotData );
  1744 				AddToBookmarksL( currentBodyHotSpotData );
  1744                 AddToBookmarksL( currentBodyHotSpotData );
  1745 		       	}
  1745                 }
  1746 				break;
  1746                 break;
  1747 	        case EAknSoftkeyOpen:
  1747             case EAknSoftkeyOpen:
  1748 	        case EFsEmailUiCmdOpenAttachment:
  1748             case EFsEmailUiCmdOpenAttachment:
  1749 	            {
  1749                 {
  1750 	            OpenAttachmentL();
  1750                 OpenAttachmentL();
  1751 	            }
  1751                 }
  1752 	            break;
  1752                 break;
  1753 			case EFsEmailUiCmdOpenAttachmentList:
  1753             case EFsEmailUiCmdOpenAttachmentList:
  1754 				{
  1754                 {
  1755 				OpenAttachmentsViewL();
  1755                 OpenAttachmentsViewL();
  1756 				}
  1756                 }
  1757 				break;
  1757                 break;
  1758 			case EFsEmailUiCmdDownload:
  1758             case EFsEmailUiCmdDownload:
  1759 	        case EFsEmailUiCmdDownloadAll:
  1759             case EFsEmailUiCmdDownloadAll:
  1760 				{
  1760                 {
  1761 				StartDowloadingAttachmentsL();
  1761                 StartDowloadingAttachmentsL();
  1762 				}
  1762                 }
  1763 				break;
  1763                 break;
  1764 	        case EFsEmailUiCmdCancelDownload:
  1764             case EFsEmailUiCmdCancelDownload:
  1765 	        case EFsEmailUiCmdCancelAllDownloads:
  1765             case EFsEmailUiCmdCancelAllDownloads:
  1766 		       	{
  1766                 {
  1767 				CancelDowloadingAttachmentsL();
  1767                 CancelDowloadingAttachmentsL();
  1768 	        	}
  1768                 }
  1769 				break;
  1769                 break;
  1770 	        case EFsEmailUiCmdSave:
  1770             case EFsEmailUiCmdSave:
  1771 	        case EFsEmailUiCmdSaveAll:
  1771             case EFsEmailUiCmdSaveAll:
  1772 	        	{
  1772                 {
  1773 				SaveAllAttachmentsL();
  1773                 SaveAllAttachmentsL();
  1774 	        	}
  1774                 }
  1775 				break;
  1775                 break;
  1776 	        case EFsEmailUiCmdClearFetchedAttachment:
  1776             case EFsEmailUiCmdClearFetchedAttachment:
  1777 	            {
  1777                 {
  1778 	            RemoveFetchedAttachmentL();
  1778                 RemoveFetchedAttachmentL();
  1779 	            }
  1779                 }
  1780 	            break;
  1780                 break;
  1781 
  1781 
  1782 			// "more" -sub menu options
  1782             // "more" -sub menu options
  1783 	        case EFsEmailUiCmdMarkAsUnread:
  1783             case EFsEmailUiCmdMarkAsUnread:
  1784 	        	{
  1784                 {
  1785 	        	ChangeMsgReadStatusL( EFalse, EFalse );
  1785                 ChangeMsgReadStatusL( EFalse, EFalse );
  1786 	        	}
  1786                 }
  1787 				break;
  1787                 break;
  1788 	        case EFsEmailUiCmdMarkAsRead:
  1788             case EFsEmailUiCmdMarkAsRead:
  1789 	        	{
  1789                 {
  1790 	        	ChangeMsgReadStatusL( ETrue, EFalse );
  1790                 ChangeMsgReadStatusL( ETrue, EFalse );
  1791 	        	}
  1791                 }
  1792 				break;
  1792                 break;
  1793 			case EFsEmailUiCmdActionsMoveMessage:
  1793             case EFsEmailUiCmdActionsMoveMessage:
  1794 				{
  1794                 {
  1795                 OpenFolderListForMessageMovingL();
  1795                 OpenFolderListForMessageMovingL();
  1796 				}
  1796                 }
  1797 				break;
  1797                 break;
  1798 	        case EFsEmailUiCmdActionsFlag:
  1798             case EFsEmailUiCmdActionsFlag:
  1799 		        {
  1799                 {
  1800 	       		SetMessageFollowupFlagL();
  1800                 SetMessageFollowupFlagL();
  1801 		        }
  1801                 }
  1802 		        break;
  1802                 break;
  1803 			case EFsEmailUiCmdCompose:
  1803             case EFsEmailUiCmdCompose:
  1804 				{
  1804                 {
  1805 				iAppUi.CreateNewMailL();
  1805                 iAppUi.CreateNewMailL();
  1806 				}
  1806                 }
  1807 				break;
  1807                 break;
  1808 			case EFsEmailUiCmdComposeTo:
  1808             case EFsEmailUiCmdComposeTo:
  1809 			    {
  1809                 {
  1810 			    ComposeMailL();
  1810                 ComposeMailL();
  1811 			    }
  1811                 }
  1812 			    break;
  1812                 break;
  1813 	       	case EFsEmailUiCmdMessageDetails:
  1813             case EFsEmailUiCmdMessageDetails:
  1814 	       	case EFsEmailUiCmdViewAll:
  1814             case EFsEmailUiCmdViewAll:
  1815 				{
  1815                 {
  1816 				TUid activationCmdId = KStartMsgDetailsToBeginning;
  1816                 TUid activationCmdId = KStartMsgDetailsToBeginning;
  1817 				if ( aCommand == EFsEmailUiCmdViewAll )
  1817                 if ( aCommand == EFsEmailUiCmdViewAll )
  1818 				    {
  1818                     {
  1819                     SViewerHeadingHotSpotData currentHeaderHotSpotData;
  1819                     SViewerHeadingHotSpotData currentHeaderHotSpotData;
  1820                     iViewerRichText->FindCurrentHeaderHotSpotL( currentHeaderHotSpotData );
  1820                     iViewerRichText->FindCurrentHeaderHotSpotL( currentHeaderHotSpotData );
  1821                     if( currentHeaderHotSpotData.iType == ETypeToNMoreRecipients )
  1821                     if( currentHeaderHotSpotData.iType == ETypeToNMoreRecipients )
  1822                         {
  1822                         {
  1823                         activationCmdId = KStartMsgDetailsToTo;
  1823                         activationCmdId = KStartMsgDetailsToTo;
  1828                         }
  1828                         }
  1829                     else if( currentHeaderHotSpotData.iType == ETypeBccNMoreRecipients )
  1829                     else if( currentHeaderHotSpotData.iType == ETypeBccNMoreRecipients )
  1830                         {
  1830                         {
  1831                         activationCmdId = KStartMsgDetailsToBcc;
  1831                         activationCmdId = KStartMsgDetailsToBcc;
  1832                         }
  1832                         }
  1833 				    }
  1833                     }
  1834 
  1834 
  1835                 TMsgDetailsActivationData msgDetailsData;
  1835                 TMsgDetailsActivationData msgDetailsData;
  1836 	  			msgDetailsData.iMailBoxId = iMessage->GetMailBoxId();
  1836                 msgDetailsData.iMailBoxId = iMessage->GetMailBoxId();
  1837 	  			msgDetailsData.iFolderId = iMessage->GetFolderId();
  1837                 msgDetailsData.iFolderId = iMessage->GetFolderId();
  1838 	  			msgDetailsData.iMessageId = iMessage->GetMessageId();
  1838                 msgDetailsData.iMessageId = iMessage->GetMessageId();
  1839 				const TPckgBuf<TMsgDetailsActivationData> pkgOut( msgDetailsData );
  1839                 const TPckgBuf<TMsgDetailsActivationData> pkgOut( msgDetailsData );
  1840 				iAppUi.EnterFsEmailViewL(
  1840                 iAppUi.EnterFsEmailViewL(
  1841 					MsgDetailsViewId, activationCmdId,  pkgOut );
  1841                     MsgDetailsViewId, activationCmdId,  pkgOut );
  1842 				}
  1842                 }
  1843 				break;
  1843                 break;
  1844 // <cmail> Prevent Download Manager opening with attachments
  1844 // <cmail> Prevent Download Manager opening with attachments
  1845 //			case EFsEmailUiCmdDownloadManager:
  1845 //          case EFsEmailUiCmdDownloadManager:
  1846 //				{
  1846 //              {
  1847 //	  			iAppUi.EnterFsEmailViewL( DownloadManagerViewId );
  1847 //              iAppUi.EnterFsEmailViewL( DownloadManagerViewId );
  1848 //				}
  1848 //              }
  1849 //				break;
  1849 //              break;
  1850 // </cmail>
  1850 // </cmail>
  1851             case EFsEmailUiCmdMarkAsReadUnreadToggle:
  1851             case EFsEmailUiCmdMarkAsReadUnreadToggle:
  1852                 {
  1852                 {
  1853                 if ( iMessage && !iEmbeddedMessageMode )
  1853                 if ( iMessage && !iEmbeddedMessageMode )
  1854                     {
  1854                     {
  1871             case EFsEmailUiCmdGoToTop:
  1871             case EFsEmailUiCmdGoToTop:
  1872                 {
  1872                 {
  1873                 // <cmail>
  1873                 // <cmail>
  1874                 // Do nothing if focus is already in top
  1874                 // Do nothing if focus is already in top
  1875                 if ( iTextViewer->GetFirstDisplayedLine() > 1 )
  1875                 if ( iTextViewer->GetFirstDisplayedLine() > 1 )
  1876                 	{
  1876                     {
  1877                     iTextViewer->FocusLineL( 1 );
  1877                     iTextViewer->FocusLineL( 1 );
  1878                 	}
  1878                     }
  1879                 }
  1879                 }
  1880                 // </cmail>
  1880                 // </cmail>
  1881                 break;
  1881                 break;
  1882             case EFsEmailUiCmdGoToBottom:
  1882             case EFsEmailUiCmdGoToBottom:
  1883                 {
  1883                 {
  1893             // keys by iCodes. This doesn't fit our concept at least in product where iCode
  1893             // keys by iCodes. This doesn't fit our concept at least in product where iCode
  1894             // of certain keys contains the value of the character found behind Fn on that key,
  1894             // of certain keys contains the value of the character found behind Fn on that key,
  1895             // and the Fn mappings vary between variants.
  1895             // and the Fn mappings vary between variants.
  1896             // Similar mechanism is used inside AknFep with key codes EKeyF19...EKeyF24,
  1896             // Similar mechanism is used inside AknFep with key codes EKeyF19...EKeyF24,
  1897             // so collisions with these must be avoided.
  1897             // so collisions with these must be avoided.
  1898 	        case EFsEmailUiCmdScrollUp:
  1898             case EFsEmailUiCmdScrollUp:
  1899 	            {
  1899                 {
  1900 	            TKeyEvent simEvent = { KKeyCodeArtificialScrollUp, EStdKeyNull, 0, 0 };
  1900                 TKeyEvent simEvent = { KKeyCodeArtificialScrollUp, EStdKeyNull, 0, 0 };
  1901 	            iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1901                 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1902 	            }
  1902                 }
  1903 	            break;
  1903                 break;
  1904 	        case EFsEmailUiCmdScrollDown:
  1904             case EFsEmailUiCmdScrollDown:
  1905 	            {
  1905                 {
  1906 	            TKeyEvent simEvent = { KKeyCodeArtificialScrollDown, EStdKeyNull, 0, 0 };
  1906                 TKeyEvent simEvent = { KKeyCodeArtificialScrollDown, EStdKeyNull, 0, 0 };
  1907 	            iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1907                 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1908 	            }
  1908                 }
  1909                 break;
  1909                 break;
  1910 	        case EFsEmailUiCmdPageUp:
  1910             case EFsEmailUiCmdPageUp:
  1911                 {
  1911                 {
  1912                 TKeyEvent simEvent = { EKeyPageUp, EStdKeyNull, 0, 0 };
  1912                 TKeyEvent simEvent = { EKeyPageUp, EStdKeyNull, 0, 0 };
  1913                 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1913                 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1914                 }
  1914                 }
  1915                 break;
  1915                 break;
  1916 	        case EFsEmailUiCmdPageDown:
  1916             case EFsEmailUiCmdPageDown:
  1917                 {
  1917                 {
  1918                 TKeyEvent simEvent = { EKeyPageDown, EStdKeyNull, 0, 0 };
  1918                 TKeyEvent simEvent = { EKeyPageDown, EStdKeyNull, 0, 0 };
  1919                 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1919                 iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1920                 // Check if we reached the end of truncated message body
  1920                 // Check if we reached the end of truncated message body
  1921                 StartFetchingRemaininBodyLinesIfAtBottomL();
  1921                 StartFetchingRemaininBodyLinesIfAtBottomL();
  1922                 }
  1922                 }
  1923                 break;
  1923                 break;
  1924 
  1924 
  1925             default:
  1925             default:
  1926 	        	break;
  1926                 break;
  1927 	        }
  1927             }
  1928         }
  1928         }
  1929     }
  1929     }
  1930 
  1930 
  1931 
  1931 
  1932 void CFSEmailUiMailViewerVisualiser::ComposeMailL()
  1932 void CFSEmailUiMailViewerVisualiser::ComposeMailL()
  1988 
  1988 
  1989 
  1989 
  1990 
  1990 
  1991 
  1991 
  1992 void CFSEmailUiMailViewerVisualiser::ProcessAsyncCommandL( TESMRIcalViewerOperationType aCommandId,
  1992 void CFSEmailUiMailViewerVisualiser::ProcessAsyncCommandL( TESMRIcalViewerOperationType aCommandId,
  1993 		                								 const CFSMailMessage& aMessage,
  1993                                                          const CFSMailMessage& aMessage,
  1994                 										 MESMRIcalViewerObserver* aObserver )
  1994                                                          MESMRIcalViewerObserver* aObserver )
  1995 	{
  1995     {
  1996 	FUNC_LOG;
  1996     FUNC_LOG;
  1997 	if ( aObserver )
  1997     if ( aObserver )
  1998 		{
  1998         {
  1999 		iMrObserverToInform = aObserver;
  1999         iMrObserverToInform = aObserver;
  2000 		}
  2000         }
  2001 	// we must cast constness away from message because of flaws in MRUI API
  2001     // we must cast constness away from message because of flaws in MRUI API
  2002 	CFSMailMessage* messagePtr = const_cast<CFSMailMessage*>(&aMessage);
  2002     CFSMailMessage* messagePtr = const_cast<CFSMailMessage*>(&aMessage);
  2003 	if ( messagePtr )
  2003     if ( messagePtr )
  2004 		{
  2004         {
  2005         // Fill in result struct
  2005         // Fill in result struct
  2006         iOpResult.iOpType = aCommandId;
  2006         iOpResult.iOpType = aCommandId;
  2007         iOpResult.iMessage = messagePtr;
  2007         iOpResult.iMessage = messagePtr;
  2008         iOpResult.iResultCode = KErrNotFound;
  2008         iOpResult.iResultCode = KErrNotFound;
  2009 
  2009 
  2010         switch ( aCommandId )
  2010         switch ( aCommandId )
  2011 			{
  2011             {
  2012             case EESMRCmdMailMessageDetails:
  2012             case EESMRCmdMailMessageDetails:
  2013                 {
  2013                 {
  2014                 iOpResult.iResultCode = KErrNone;
  2014                 iOpResult.iResultCode = KErrNone;
  2015                 TMsgDetailsActivationData msgDetailsData;
  2015                 TMsgDetailsActivationData msgDetailsData;
  2016                 msgDetailsData.iMailBoxId = messagePtr->GetMailBoxId();
  2016                 msgDetailsData.iMailBoxId = messagePtr->GetMailBoxId();
  2098                     CompletePendingMrCommand();
  2098                     CompletePendingMrCommand();
  2099 // </cmail>
  2099 // </cmail>
  2100                     }
  2100                     }
  2101                 }
  2101                 }
  2102                 break;
  2102                 break;
  2103 			case EESMRCmdDownloadManager:
  2103             case EESMRCmdDownloadManager:
  2104 				{
  2104                 {
  2105 				// Check that there is something in dwnld manager to show
  2105                 // Check that there is something in dwnld manager to show
  2106 				if ( ShowDownloadManagerMenuInOptions() )
  2106                 if ( ShowDownloadManagerMenuInOptions() )
  2107 				    {
  2107                     {
  2108 				    iOpResult.iResultCode = KErrNone;
  2108                     iOpResult.iResultCode = KErrNone;
  2109 				    iAppUi.EnterFsEmailViewL( DownloadManagerViewId );
  2109                     iAppUi.EnterFsEmailViewL( DownloadManagerViewId );
  2110 				    }
  2110                     }
  2111 				}
  2111                 }
  2112 				break;
  2112                 break;
  2113             case EESMRCmdMailComposeMessage:
  2113             case EESMRCmdMailComposeMessage:
  2114                 {
  2114                 {
  2115                 iOpResult.iResultCode = KErrNone;
  2115                 iOpResult.iResultCode = KErrNone;
  2116                 iAppUi.CreateNewMailL();
  2116                 iAppUi.CreateNewMailL();
  2117                 }
  2117                 }
  2118                 break;
  2118                 break;
  2119 			case EESMRCmdMailReply:
  2119             case EESMRCmdMailReply:
  2120 			case EESMRCmdMailReplyAll:
  2120             case EESMRCmdMailReplyAll:
  2121 			case EESMRCmdMailForwardAsMessage:
  2121             case EESMRCmdMailForwardAsMessage:
  2122 				{
  2122                 {
  2123 				// Fill result codes for mrui
  2123                 // Fill result codes for mrui
  2124 				iOpResult.iResultCode = KErrNone;
  2124                 iOpResult.iResultCode = KErrNone;
  2125 				// Fill launc params
  2125                 // Fill launc params
  2126 	    		TEditorLaunchParams params;
  2126                 TEditorLaunchParams params;
  2127 	    		params.iMailboxId = iAppUi.GetActiveMailboxId();
  2127                 params.iMailboxId = iAppUi.GetActiveMailboxId();
  2128 	    		params.iActivatedExternally = EFalse;
  2128                 params.iActivatedExternally = EFalse;
  2129 	    		params.iMsgId = messagePtr->GetMessageId();
  2129                 params.iMsgId = messagePtr->GetMessageId();
  2130 				if ( aCommandId == EESMRCmdMailForwardAsMessage )
  2130                 if ( aCommandId == EESMRCmdMailForwardAsMessage )
  2131 					{
  2131                     {
  2132 		    		iAppUi.LaunchEditorL( KEditorCmdForward, params );
  2132                     iAppUi.LaunchEditorL( KEditorCmdForward, params );
  2133 					}
  2133                     }
  2134 				else if ( aCommandId == EESMRCmdMailReply )
  2134                 else if ( aCommandId == EESMRCmdMailReply )
  2135 					{
  2135                     {
  2136 		    		iAppUi.LaunchEditorL( KEditorCmdReply, params );
  2136                     iAppUi.LaunchEditorL( KEditorCmdReply, params );
  2137 					}
  2137                     }
  2138 				else if ( aCommandId == EESMRCmdMailReplyAll )
  2138                 else if ( aCommandId == EESMRCmdMailReplyAll )
  2139 					{
  2139                     {
  2140 		    		iAppUi.LaunchEditorL( KEditorCmdReplyAll, params );
  2140                     iAppUi.LaunchEditorL( KEditorCmdReplyAll, params );
  2141 					}
  2141                     }
  2142 				}
  2142                 }
  2143 				break;
  2143                 break;
  2144 	  		case EESMRCmdMailPreviousMessage:
  2144             case EESMRCmdMailPreviousMessage:
  2145 	  		    {
  2145                 {
  2146                 iNextOrPevMessageSelected = ETrue; // prevent back navigation when operation completed received
  2146                 iNextOrPevMessageSelected = ETrue; // prevent back navigation when operation completed received
  2147                 ShowPreviousMessageL();
  2147                 ShowPreviousMessageL();
  2148                 iOpResult.iResultCode = KErrNone;
  2148                 iOpResult.iResultCode = KErrNone;
  2149                 CompletePendingMrCommand();
  2149                 CompletePendingMrCommand();
  2150 	  		    }
  2150                 }
  2151 	  		    break;
  2151                 break;
  2152 			case EESMRCmdMailNextMessage:
  2152             case EESMRCmdMailNextMessage:
  2153 				{
  2153                 {
  2154 				iNextOrPevMessageSelected = ETrue; // prevent back navigation when operation completed received
  2154                 iNextOrPevMessageSelected = ETrue; // prevent back navigation when operation completed received
  2155 				ShowNextMessageL();
  2155                 ShowNextMessageL();
  2156                 iOpResult.iResultCode = KErrNone;
  2156                 iOpResult.iResultCode = KErrNone;
  2157 				CompletePendingMrCommand();
  2157                 CompletePendingMrCommand();
  2158                 }
  2158                 }
  2159 				break;
  2159                 break;
  2160 			default:
  2160             default:
  2161 				break;
  2161                 break;
  2162 			}
  2162             }
  2163 		}
  2163         }
  2164 
  2164 
  2165 	// Complete immediately if handling command failed. It makes no harm if following
  2165     // Complete immediately if handling command failed. It makes no harm if following
  2166 	// function gets called several times in some case.
  2166     // function gets called several times in some case.
  2167 	if ( iOpResult.iResultCode < 0 )
  2167     if ( iOpResult.iResultCode < 0 )
  2168 	    {
  2168         {
  2169 	    CompletePendingMrCommand();
  2169         CompletePendingMrCommand();
  2170 	    }
  2170         }
  2171 	}
  2171     }
  2172 
  2172 
  2173 
  2173 
  2174 void CFSEmailUiMailViewerVisualiser::ProcessSyncCommandL(
  2174 void CFSEmailUiMailViewerVisualiser::ProcessSyncCommandL(
  2175 	TESMRIcalViewerOperationType aCommandId,
  2175     TESMRIcalViewerOperationType aCommandId,
  2176 	const CFSMailMessage& aMessage )
  2176     const CFSMailMessage& aMessage )
  2177 	{
  2177     {
  2178     FUNC_LOG;
  2178     FUNC_LOG;
  2179 	if ( &aMessage )
  2179     if ( &aMessage )
  2180 		{
  2180         {
  2181 		switch ( aCommandId )
  2181         switch ( aCommandId )
  2182 			{
  2182             {
  2183 			case EESMRCmdMailMarkUnread:
  2183             case EESMRCmdMailMarkUnread:
  2184 				{
  2184                 {
  2185 				ChangeMsgReadStatusL( EFalse, ETrue );
  2185                 ChangeMsgReadStatusL( EFalse, ETrue );
  2186 				}
  2186                 }
  2187 				break;
  2187                 break;
  2188 			case EESMRCmdMailMarkRead:
  2188             case EESMRCmdMailMarkRead:
  2189 				{
  2189                 {
  2190 				ChangeMsgReadStatusL( ETrue, ETrue );
  2190                 ChangeMsgReadStatusL( ETrue, ETrue );
  2191 				}
  2191                 }
  2192 				break;
  2192                 break;
  2193 			case EESMRCmdMailFlagMessage:
  2193             case EESMRCmdMailFlagMessage:
  2194 				{
  2194                 {
  2195 		 		if ( iMessage )
  2195                 if ( iMessage )
  2196 					{
  2196                     {
  2197 					if ( !iFlagSelectionHanler )
  2197                     if ( !iFlagSelectionHanler )
  2198 						{
  2198                         {
  2199 						// Create when used for the first time
  2199                         // Create when used for the first time
  2200 						iFlagSelectionHanler =
  2200                         iFlagSelectionHanler =
  2201 							CFlagSelectionGlobalNoteHandler::NewL( *this );
  2201                             CFlagSelectionGlobalNoteHandler::NewL( *this );
  2202 						}
  2202                         }
  2203 					// Call to LaunchFlagListQueryDialogL will lead
  2203                     // Call to LaunchFlagListQueryDialogL will lead
  2204 					// to FlagselectionCompleteL
  2204                     // to FlagselectionCompleteL
  2205 					iFlagSelectionHanler->LaunchFlagListQueryDialogL();
  2205                     iFlagSelectionHanler->LaunchFlagListQueryDialogL();
  2206 					}
  2206                     }
  2207 				}
  2207                 }
  2208 				break;
  2208                 break;
  2209 			default:
  2209             default:
  2210 				break;
  2210                 break;
  2211 			}
  2211             }
  2212 		}
  2212         }
  2213 	}
  2213     }
  2214 
  2214 
  2215 
  2215 
  2216 // ---------------------------------------------------------------------------
  2216 // ---------------------------------------------------------------------------
  2217 // CanProcessCommand
  2217 // CanProcessCommand
  2218 // Callback from meeting request UI. Determines what functionality is provided
  2218 // Callback from meeting request UI. Determines what functionality is provided
  2219 // to mrui by this UI
  2219 // to mrui by this UI
  2220 // ---------------------------------------------------------------------------
  2220 // ---------------------------------------------------------------------------
  2221 //
  2221 //
  2222 TBool CFSEmailUiMailViewerVisualiser::CanProcessCommand(
  2222 TBool CFSEmailUiMailViewerVisualiser::CanProcessCommand(
  2223 	TESMRIcalViewerOperationType aCommandId  ) const
  2223     TESMRIcalViewerOperationType aCommandId  ) const
  2224 	{
  2224     {
  2225     FUNC_LOG;
  2225     FUNC_LOG;
  2226 	TBool ret( EFalse );
  2226     TBool ret( EFalse );
  2227 	TInt numRecipients(0);
  2227     TInt numRecipients(0);
  2228 	switch ( aCommandId )
  2228     switch ( aCommandId )
  2229 		{
  2229         {
  2230 		case EESMRCmdMailReply:
  2230         case EESMRCmdMailReply:
  2231 		    ret = ETrue;
  2231             ret = ETrue;
  2232 		    break;
  2232             break;
  2233 		case EESMRCmdMailReplyAll:
  2233         case EESMRCmdMailReplyAll:
  2234 			//Get # of recipients
  2234             //Get # of recipients
  2235 		    if ( iMessage )
  2235             if ( iMessage )
  2236                 {
  2236                 {
  2237                 numRecipients=TFsEmailUiUtility::CountRecepients( iMessage );
  2237                 numRecipients=TFsEmailUiUtility::CountRecepients( iMessage );
  2238                 if ( numRecipients == 1 )
  2238                 if ( numRecipients == 1 )
  2239                     {
  2239                     {
  2240                     //check if the malbox ownmailaddress is same as the recipients email address. If not, then assume that the
  2240                     //check if the malbox ownmailaddress is same as the recipients email address. If not, then assume that the
  2260                             numRecipients++;
  2260                             numRecipients++;
  2261                             }
  2261                             }
  2262                         }
  2262                         }
  2263                     }
  2263                     }
  2264                 }
  2264                 }
  2265 			ret = ( iMessage && numRecipients > 1 );
  2265             ret = ( iMessage && numRecipients > 1 );
  2266 			break;
  2266             break;
  2267 		case EESMRCmdDownloadManager:
  2267         case EESMRCmdDownloadManager:
  2268 			ret = ShowDownloadManagerMenuInOptions();
  2268             ret = ShowDownloadManagerMenuInOptions();
  2269 			break;
  2269             break;
  2270 // <cmail>
  2270 // <cmail>
  2271 		case EESMRCmdOpenAttachment:
  2271         case EESMRCmdOpenAttachment:
  2272     	case EESMRCmdSaveAttachment:
  2272         case EESMRCmdSaveAttachment:
  2273     	case EESMRCmdSaveAllAttachments:
  2273         case EESMRCmdSaveAllAttachments:
  2274     	case EESMRCmdDownloadAttachment:
  2274         case EESMRCmdDownloadAttachment:
  2275     	case EESMRCmdDownloadAllAttachments:
  2275         case EESMRCmdDownloadAllAttachments:
  2276 // </cmail>
  2276 // </cmail>
  2277 		case EESMRCmdOpenAttachmentView:
  2277         case EESMRCmdOpenAttachmentView:
  2278 			ret = ETrue;
  2278             ret = ETrue;
  2279 			break;
  2279             break;
  2280 		case EESMRCmdMailComposeMessage:
  2280         case EESMRCmdMailComposeMessage:
  2281 			ret = ETrue;
  2281             ret = ETrue;
  2282 			break;
  2282             break;
  2283 		case EESMRCmdMailMarkUnread:
  2283         case EESMRCmdMailMarkUnread:
  2284 			{
  2284             {
  2285 			ret = EFalse;
  2285             ret = EFalse;
  2286 			if ( iMessage && iMessage->IsFlagSet(EFSMsgFlag_Read) )
  2286             if ( iMessage && iMessage->IsFlagSet(EFSMsgFlag_Read) )
  2287 				{
  2287                 {
  2288 				// Read, unread should be available
  2288                 // Read, unread should be available
  2289 				ret = ETrue;
  2289                 ret = ETrue;
  2290 				}
  2290                 }
  2291 			}
  2291             }
  2292 			break;
  2292             break;
  2293 		case EESMRCmdMailMarkRead:
  2293         case EESMRCmdMailMarkRead:
  2294 			{
  2294             {
  2295 			ret = EFalse;
  2295             ret = EFalse;
  2296 			if ( iMessage && !iMessage->IsFlagSet(EFSMsgFlag_Read) )
  2296             if ( iMessage && !iMessage->IsFlagSet(EFSMsgFlag_Read) )
  2297 				{
  2297                 {
  2298 				// Read, unread should be available
  2298                 // Read, unread should be available
  2299 				ret = ETrue;
  2299                 ret = ETrue;
  2300 				}
  2300                 }
  2301 			}
  2301             }
  2302 			break;
  2302             break;
  2303 		case EESMRCmdMailMoveMessage:
  2303         case EESMRCmdMailMoveMessage:
  2304 			{
  2304             {
  2305 			ret = EFalse;
  2305             ret = EFalse;
  2306 			if ( iMessage )
  2306             if ( iMessage )
  2307 				{
  2307                 {
  2308 				// confirmed pointer exists, check whether mb has capa
  2308                 // confirmed pointer exists, check whether mb has capa
  2309 				ret = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder );
  2309                 ret = iAppUi.GetActiveMailbox()->HasCapability( EFSMBoxCapaMoveToFolder );
  2310 				}
  2310                 }
  2311 			}
  2311             }
  2312 			break;
  2312             break;
  2313 		case EESMRCmdMailForwardAsMessage:
  2313         case EESMRCmdMailForwardAsMessage:
  2314 			ret = ETrue;
  2314             ret = ETrue;
  2315 			break;
  2315             break;
  2316 		case EESMRCmdMailFlagMessage:
  2316         case EESMRCmdMailFlagMessage:
  2317 			ret = TFsEmailUiUtility::IsFollowUpSupported( *iMailBox );
  2317             ret = TFsEmailUiUtility::IsFollowUpSupported( *iMailBox );
  2318 			break;
  2318             break;
  2319 	    case EESMRCmdMailMessageDetails:
  2319         case EESMRCmdMailMessageDetails:
  2320 			ret = ETrue;
  2320             ret = ETrue;
  2321 			break;
  2321             break;
  2322 		case EESMRCmdMailDelete:
  2322         case EESMRCmdMailDelete:
  2323 			ret = ETrue;
  2323             ret = ETrue;
  2324 			break;
  2324             break;
  2325    		case EESMRCmdMailPreviousMessage:
  2325         case EESMRCmdMailPreviousMessage:
  2326    		    ret = ShowPreviousMessageMenuInOptions();
  2326             ret = ShowPreviousMessageMenuInOptions();
  2327    		    break;
  2327             break;
  2328  		case EESMRCmdMailNextMessage:
  2328         case EESMRCmdMailNextMessage:
  2329  		    ret = ShowNextMessageMenuInOptions();
  2329             ret = ShowNextMessageMenuInOptions();
  2330  			break;
  2330             break;
  2331 		default:
  2331         default:
  2332 			ret = EFalse;
  2332             ret = EFalse;
  2333 			break;
  2333             break;
  2334 		}
  2334         }
  2335 	return ret;
  2335     return ret;
  2336 	}
  2336     }
  2337 
  2337 
  2338 // -----------------------------------------------------------------------------
  2338 // -----------------------------------------------------------------------------
  2339 // CFSEmailUiMailViewerVisualiser::CompletePendingMrCommand()
  2339 // CFSEmailUiMailViewerVisualiser::CompletePendingMrCommand()
  2340 // -----------------------------------------------------------------------------
  2340 // -----------------------------------------------------------------------------
  2341 //
  2341 //
  2387             {
  2387             {
  2388             TInt noteTextId = R_FREESTYLE_EMAIL_CONFIRM_NOTE_MEETING_ON_CALENDAR_AFTER_SYNC;
  2388             TInt noteTextId = R_FREESTYLE_EMAIL_CONFIRM_NOTE_MEETING_ON_CALENDAR_AFTER_SYNC;
  2389             TRAP_IGNORE( TFsEmailUiUtility::ShowGlobalInfoNoteL( noteTextId ) );
  2389             TRAP_IGNORE( TFsEmailUiUtility::ShowGlobalInfoNoteL( noteTextId ) );
  2390             }
  2390             }
  2391         }
  2391         }
  2392 	}
  2392     }
  2393 
  2393 
  2394 // -----------------------------------------------------------------------------
  2394 // -----------------------------------------------------------------------------
  2395 // CFSEmailUiMailViewerVisualiser::OperationError()
  2395 // CFSEmailUiMailViewerVisualiser::OperationError()
  2396 // -----------------------------------------------------------------------------
  2396 // -----------------------------------------------------------------------------
  2397 //
  2397 //
  2398 void CFSEmailUiMailViewerVisualiser::OperationError( TIcalViewerOperationResult aResult )
  2398 void CFSEmailUiMailViewerVisualiser::OperationError( TIcalViewerOperationResult aResult )
  2399 	{
  2399     {
  2400     FUNC_LOG;
  2400     FUNC_LOG;
  2401     // Show message in standard mail viewer in case launchin MRUI fails for any
  2401     // Show message in standard mail viewer in case launchin MRUI fails for any
  2402 	// other reason than viewer being cancelled by calling CancelPendingMrCommand().
  2402     // other reason than viewer being cancelled by calling CancelPendingMrCommand().
  2403     if ( aResult.iOpType == EESMRViewLaunch )
  2403     if ( aResult.iOpType == EESMRViewLaunch )
  2404         {
  2404         {
  2405         iMrUiActive = EFalse;
  2405         iMrUiActive = EFalse;
  2406         if ( iAppUi.CurrentActiveView() == this && aResult.iResultCode != KErrCancel )
  2406         if ( iAppUi.CurrentActiveView() == this && aResult.iResultCode != KErrCancel )
  2407             {
  2407             {
  2412                 iAppUi.Display().Roster().ShowL( ControlGroup() );
  2412                 iAppUi.Display().Roster().ShowL( ControlGroup() );
  2413                 UpdateDownloadIndicatorL();
  2413                 UpdateDownloadIndicatorL();
  2414                 );
  2414                 );
  2415             }
  2415             }
  2416         }
  2416         }
  2417 	}
  2417     }
  2418 
  2418 
  2419 // -----------------------------------------------------------------------------
  2419 // -----------------------------------------------------------------------------
  2420 // CFSEmailUiMailViewerVisualiser::SetMskL()
  2420 // CFSEmailUiMailViewerVisualiser::SetMskL()
  2421 // -----------------------------------------------------------------------------
  2421 // -----------------------------------------------------------------------------
  2422 //
  2422 //
  2532                 ChangeMskCommandL( R_FSE_QTN_MSK_BODY_MENU );
  2532                 ChangeMskCommandL( R_FSE_QTN_MSK_BODY_MENU );
  2533                 }
  2533                 }
  2534             }
  2534             }
  2535         else
  2535         else
  2536             {
  2536             {
  2537 	    //it will set context menu for email (reply, forward, etc.)
  2537         //it will set context menu for email (reply, forward, etc.)
  2538             ChangeMskCommandL( R_FSE_QTN_MSK_BODY_MENU );
  2538             ChangeMskCommandL( R_FSE_QTN_MSK_BODY_MENU );
  2539             }
  2539             }
  2540         }
  2540         }
  2541     }
  2541     }
  2542 
  2542 
  2680         SetActionButtonIconAndHighLight();
  2680         SetActionButtonIconAndHighLight();
  2681 
  2681 
  2682         iTextViewer->SetTextL( &iViewerRichText->RichText(), iSmDictionary );
  2682         iTextViewer->SetTextL( &iViewerRichText->RichText(), iSmDictionary );
  2683 
  2683 
  2684         // ownerships are transfered to AlfEnviroment.
  2684         // ownerships are transfered to AlfEnviroment.
  2685 	    //<cmail> Compared to S60 3.2.3 in S60 5.0 Alf offers the key events in
  2685         //<cmail> Compared to S60 3.2.3 in S60 5.0 Alf offers the key events in
  2686 	    // opposite order.
  2686         // opposite order.
  2687         // Create control for capturing left and right navigation events
  2687         // Create control for capturing left and right navigation events
  2688         iControl = CFreestyleEmailUiMailViewerControl::NewL( iEnv, *this );
  2688         iControl = CFreestyleEmailUiMailViewerControl::NewL( iEnv, *this );
  2689         ControlGroup().AppendL( iControl );
  2689         ControlGroup().AppendL( iControl );
  2690         ControlGroup().AppendL( iTextViewerControl );
  2690         ControlGroup().AppendL( iTextViewerControl );
  2691         //</cmail>
  2691         //</cmail>
  2696 
  2696 
  2697 // -----------------------------------------------------------------------------
  2697 // -----------------------------------------------------------------------------
  2698 // CFSEmailUiMailViewerVisualiser::SetActionButtonIconAndHighLight
  2698 // CFSEmailUiMailViewerVisualiser::SetActionButtonIconAndHighLight
  2699 // -----------------------------------------------------------------------------
  2699 // -----------------------------------------------------------------------------
  2700 void CFSEmailUiMailViewerVisualiser::SetActionButtonIconAndHighLight()
  2700 void CFSEmailUiMailViewerVisualiser::SetActionButtonIconAndHighLight()
  2701 	{
  2701     {
  2702     FUNC_LOG;
  2702     FUNC_LOG;
  2703 	CFreestyleEmailUiTextureManager* textureMgr = iAppUi.FsTextureManager();
  2703     CFreestyleEmailUiTextureManager* textureMgr = iAppUi.FsTextureManager();
  2704     CFSEmailUiLayoutHandler* layoutMgr = iAppUi.LayoutHandler();
  2704     CFSEmailUiLayoutHandler* layoutMgr = iAppUi.LayoutHandler();
  2705 
  2705 
  2706     // get textures from texture manager
  2706     // get textures from texture manager
  2707 	CAlfTexture& menuTexture = textureMgr->TextureByIndex( EListControlMenuIcon );
  2707     CAlfTexture& menuTexture = textureMgr->TextureByIndex( EListControlMenuIcon );
  2708 	CAlfTexture& selectortexture = textureMgr->TextureByIndex( EViewerHighlightTexture );
  2708     CAlfTexture& selectortexture = textureMgr->TextureByIndex( EViewerHighlightTexture );
  2709 
  2709 
  2710     iTextViewer->SetLiteLineBg( selectortexture, layoutMgr->ViewerSelectorOpacity() );
  2710     iTextViewer->SetLiteLineBg( selectortexture, layoutMgr->ViewerSelectorOpacity() );
  2711 
  2711 
  2712 	iTextViewer->SetActionButton( menuTexture, 1  );
  2712     iTextViewer->SetActionButton( menuTexture, 1  );
  2713 	iTextViewer->SetActionButtonMargin( layoutMgr->ViewerActionMenuIconMargin() );
  2713     iTextViewer->SetActionButtonMargin( layoutMgr->ViewerActionMenuIconMargin() );
  2714 	TSize btnSize = layoutMgr->ViewerActionMenuIconSize();
  2714     TSize btnSize = layoutMgr->ViewerActionMenuIconSize();
  2715 	iTextViewer->SetActionButtonSize( btnSize.iWidth, btnSize.iHeight );
  2715     iTextViewer->SetActionButtonSize( btnSize.iWidth, btnSize.iHeight );
  2716 	}
  2716     }
  2717 
  2717 
  2718 // -----------------------------------------------------------------------------
  2718 // -----------------------------------------------------------------------------
  2719 // CFSEmailUiMailViewerVisualiser::LaunchActionMenuL
  2719 // CFSEmailUiMailViewerVisualiser::LaunchActionMenuL
  2720 // -----------------------------------------------------------------------------
  2720 // -----------------------------------------------------------------------------
  2721 void CFSEmailUiMailViewerVisualiser::LaunchActionMenuL()
  2721 void CFSEmailUiMailViewerVisualiser::LaunchActionMenuL()
  2722 	{
  2722     {
  2723     FUNC_LOG;
  2723     FUNC_LOG;
  2724 	// check that current hotspot is visible
  2724     // check that current hotspot is visible
  2725 	TInt ignoreThis; // not used here. Only return value is used not this mandatory reference parameter
  2725     TInt ignoreThis; // not used here. Only return value is used not this mandatory reference parameter
  2726 	TBool visibleHotsSpot = iTextViewer->GetVisibleFocusedHotspotLine( ignoreThis );
  2726     TBool visibleHotsSpot = iTextViewer->GetVisibleFocusedHotspotLine( ignoreThis );
  2727 	if( visibleHotsSpot )
  2727     if( visibleHotsSpot )
  2728 		{
  2728         {
  2729 		// Remove items
  2729         // Remove items
  2730 		CFSEmailUiActionMenu::RemoveAllL();
  2730         CFSEmailUiActionMenu::RemoveAllL();
  2731 
  2731 
  2732 		// check which hotspot is active.
  2732         // check which hotspot is active.
  2733 		SViewerHeadingHotSpotData currentHeaderHotSpotData;
  2733         SViewerHeadingHotSpotData currentHeaderHotSpotData;
  2734 		CFindItemEngine::SFoundItem currentBodyHotSpotData;
  2734         CFindItemEngine::SFoundItem currentBodyHotSpotData;
  2735 		THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL( currentHeaderHotSpotData, currentBodyHotSpotData );
  2735         THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL( currentHeaderHotSpotData, currentBodyHotSpotData );
  2736 
  2736 
  2737 		TActionMenuType currentActionMenuType = ENoActionMenuFocused;
  2737         TActionMenuType currentActionMenuType = ENoActionMenuFocused;
  2738 		if( hotspotType == EHeaderHotspot && (
  2738         if( hotspotType == EHeaderHotspot && (
  2739 			currentHeaderHotSpotData.iType == ETypeFromAddressDisplayName ||
  2739             currentHeaderHotSpotData.iType == ETypeFromAddressDisplayName ||
  2740 			currentHeaderHotSpotData.iType == ETypeToAddressDisplayName ||
  2740             currentHeaderHotSpotData.iType == ETypeToAddressDisplayName ||
  2741 			currentHeaderHotSpotData.iType == ETypeCcAddressDisplayName ||
  2741             currentHeaderHotSpotData.iType == ETypeCcAddressDisplayName ||
  2742 			currentHeaderHotSpotData.iType == ETypeBccAddressDisplayName ||
  2742             currentHeaderHotSpotData.iType == ETypeBccAddressDisplayName ||
  2743 			currentHeaderHotSpotData.iType == ETypeEmailAddress ) )
  2743             currentHeaderHotSpotData.iType == ETypeEmailAddress ) )
  2744 			{
  2744             {
  2745 			currentActionMenuType = EFocusOnNameInAddressField;
  2745             currentActionMenuType = EFocusOnNameInAddressField;
  2746 			}
  2746             }
  2747 		else if( hotspotType == EHeaderHotspot && (
  2747         else if( hotspotType == EHeaderHotspot && (
  2748 			currentHeaderHotSpotData.iType == ETypeAttachment ) )
  2748             currentHeaderHotSpotData.iType == ETypeAttachment ) )
  2749 			{
  2749             {
  2750 			currentActionMenuType =	EFocusOnAttachmentName;
  2750             currentActionMenuType = EFocusOnAttachmentName;
  2751 			}
  2751             }
  2752 		else if( hotspotType == EHeaderHotspot && (
  2752         else if( hotspotType == EHeaderHotspot && (
  2753 			currentHeaderHotSpotData.iType == ETypeAttachments ) )
  2753             currentHeaderHotSpotData.iType == ETypeAttachments ) )
  2754 			{
  2754             {
  2755 			currentActionMenuType =	EFocusOnAttachmentsText;
  2755             currentActionMenuType = EFocusOnAttachmentsText;
  2756 			}
  2756             }
  2757 		else if( hotspotType == EBodyHotspot &&
  2757         else if( hotspotType == EBodyHotspot &&
  2758 				currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchPhoneNumberBin )
  2758                 currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchPhoneNumberBin )
  2759 			{
  2759             {
  2760 			currentActionMenuType = EFocusOnNumberWithinMessage;
  2760             currentActionMenuType = EFocusOnNumberWithinMessage;
  2761 			}
  2761             }
  2762 		else if( hotspotType == EBodyHotspot && ( currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchURLBin ||
  2762         else if( hotspotType == EBodyHotspot && ( currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchURLBin ||
  2763 			   	 currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchScheme ) )
  2763                  currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchScheme ) )
  2764 			{
  2764             {
  2765 			TInt schemaLinkType = ResolveBodyTextSchemaUrlTypeL( currentBodyHotSpotData );
  2765             TInt schemaLinkType = ResolveBodyTextSchemaUrlTypeL( currentBodyHotSpotData );
  2766 			switch ( schemaLinkType )
  2766             switch ( schemaLinkType )
  2767 				{
  2767                 {
  2768 				case EFocusOnEMailInBodyText:
  2768                 case EFocusOnEMailInBodyText:
  2769 					currentActionMenuType = EFocusOnEMailInBodyText;
  2769                     currentActionMenuType = EFocusOnEMailInBodyText;
  2770 					break;
  2770                     break;
  2771 				case EFocusOnNumberWithinMessage:
  2771                 case EFocusOnNumberWithinMessage:
  2772 					currentActionMenuType = EFocusOnNumberWithinMessage;
  2772                     currentActionMenuType = EFocusOnNumberWithinMessage;
  2773 					break;
  2773                     break;
  2774 				default:
  2774                 default:
  2775 					currentActionMenuType = EFocusOnHyperLinkWithinMessage;
  2775                     currentActionMenuType = EFocusOnHyperLinkWithinMessage;
  2776 					break;
  2776                     break;
  2777 
  2777 
  2778 				}
  2778                 }
  2779 			}
  2779             }
  2780 		else if( hotspotType == EBodyHotspot &&
  2780         else if( hotspotType == EBodyHotspot &&
  2781 				currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchMailAddressBin )
  2781                 currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchMailAddressBin )
  2782 			{
  2782             {
  2783 			currentActionMenuType = EFocusOnEMailInBodyText;
  2783             currentActionMenuType = EFocusOnEMailInBodyText;
  2784 			}
  2784             }
  2785 
  2785 
  2786 
  2786 
  2787 		if( currentActionMenuType != ENoActionMenuFocused )
  2787         if( currentActionMenuType != ENoActionMenuFocused )
  2788 			{
  2788             {
  2789 			CreateActionMenuItemsL( currentActionMenuType );
  2789             CreateActionMenuItemsL( currentActionMenuType );
  2790 		    TActionMenuCustomItemId menuResult = CFSEmailUiActionMenu::ExecuteL( EFscCenter );
  2790             TActionMenuCustomItemId menuResult = CFSEmailUiActionMenu::ExecuteL( EFscCenter );
  2791 		    if ( menuResult != FsEActionMenuCasItemSelectedAndExecuted &&
  2791             if ( menuResult != FsEActionMenuCasItemSelectedAndExecuted &&
  2792 		    		menuResult != FsEActionMenuDismissed	)
  2792                     menuResult != FsEActionMenuDismissed    )
  2793 		    	{
  2793                 {
  2794 		    	HandleActionMenuCommandL( menuResult, currentActionMenuType );
  2794                 HandleActionMenuCommandL( menuResult, currentActionMenuType );
  2795 		    	}
  2795                 }
  2796 			}
  2796             }
  2797 		}
  2797         }
  2798 	}
  2798     }
  2799 
  2799 
  2800 // -----------------------------------------------------------------------------
  2800 // -----------------------------------------------------------------------------
  2801 // CFSEmailUiMailViewerVisualiser::ResolveBodyTextSchemaUrlTypeL
  2801 // CFSEmailUiMailViewerVisualiser::ResolveBodyTextSchemaUrlTypeL
  2802 // -----------------------------------------------------------------------------
  2802 // -----------------------------------------------------------------------------
  2803 TInt CFSEmailUiMailViewerVisualiser::ResolveBodyTextSchemaUrlTypeL( CFindItemEngine::SFoundItem aHotSpot )
  2803 TInt CFSEmailUiMailViewerVisualiser::ResolveBodyTextSchemaUrlTypeL( CFindItemEngine::SFoundItem aHotSpot )
  2804 	{
  2804     {
  2805     FUNC_LOG;
  2805     FUNC_LOG;
  2806 	TInt ret( EFocusOnHyperLinkWithinMessage );
  2806     TInt ret( EFocusOnHyperLinkWithinMessage );
  2807 	HBufC* schemeText = iViewerRichText->GetHotspotTextLC( aHotSpot );
  2807     HBufC* schemeText = iViewerRichText->GetHotspotTextLC( aHotSpot );
  2808 	if ( schemeText->FindC( KMailtoPrefix ) == 0 )
  2808     if ( schemeText->FindC( KMailtoPrefix ) == 0 )
  2809 		{
  2809         {
  2810 		ret = EFocusOnEMailInBodyText;
  2810         ret = EFocusOnEMailInBodyText;
  2811 		}
  2811         }
  2812 	else if ( schemeText->FindC( KCallPrefix ) == 0 ||
  2812     else if ( schemeText->FindC( KCallPrefix ) == 0 ||
  2813 			  schemeText->FindC( KTelPrefix ) == 0 ||
  2813               schemeText->FindC( KTelPrefix ) == 0 ||
  2814 			  schemeText->FindC( KSmsPrefix ) == 0 ||
  2814               schemeText->FindC( KSmsPrefix ) == 0 ||
  2815 			  schemeText->FindC( KMmsPrefix ) == 0 ||
  2815               schemeText->FindC( KMmsPrefix ) == 0 ||
  2816 			  schemeText->FindC( KVoipPrefix ) == 0 )
  2816               schemeText->FindC( KVoipPrefix ) == 0 )
  2817 		{
  2817         {
  2818 		ret = EFocusOnNumberWithinMessage;
  2818         ret = EFocusOnNumberWithinMessage;
  2819 		}
  2819         }
  2820 	else
  2820     else
  2821 		{
  2821         {
  2822 		ret = EFocusOnHyperLinkWithinMessage;
  2822         ret = EFocusOnHyperLinkWithinMessage;
  2823 		}
  2823         }
  2824 	CleanupStack::PopAndDestroy( schemeText );
  2824     CleanupStack::PopAndDestroy( schemeText );
  2825 	return ret;
  2825     return ret;
  2826 	}
  2826     }
  2827 
  2827 
  2828 // -----------------------------------------------------------------------------
  2828 // -----------------------------------------------------------------------------
  2829 // CFSEmailUiMailViewerVisualiser::SetActionMenuIconVisbilityL
  2829 // CFSEmailUiMailViewerVisualiser::SetActionMenuIconVisbilityL
  2830 // -----------------------------------------------------------------------------
  2830 // -----------------------------------------------------------------------------
  2831 void CFSEmailUiMailViewerVisualiser::SetActionMenuIconVisbilityL()
  2831 void CFSEmailUiMailViewerVisualiser::SetActionMenuIconVisbilityL()
  2846 
  2846 
  2847 // -----------------------------------------------------------------------------
  2847 // -----------------------------------------------------------------------------
  2848 // CFSEmailUiMailViewerVisualiser::CreateActionMenuItemsL
  2848 // CFSEmailUiMailViewerVisualiser::CreateActionMenuItemsL
  2849 // -----------------------------------------------------------------------------
  2849 // -----------------------------------------------------------------------------
  2850 void CFSEmailUiMailViewerVisualiser::CreateActionMenuItemsL(
  2850 void CFSEmailUiMailViewerVisualiser::CreateActionMenuItemsL(
  2851 	TActionMenuType aActionMenuType )
  2851     TActionMenuType aActionMenuType )
  2852 	{
  2852     {
  2853     FUNC_LOG;
  2853     FUNC_LOG;
  2854 	// See the ui spec for all the right action menus according to
  2854     // See the ui spec for all the right action menus according to
  2855 	// currently selected hotspot
  2855     // currently selected hotspot
  2856 	RArray<TActionMenuCustomItemId> uids;
  2856     RArray<TActionMenuCustomItemId> uids;
  2857 	CleanupClosePushL( uids );
  2857     CleanupClosePushL( uids );
  2858 	if ( aActionMenuType == EFocusOnNumberWithinMessage )
  2858     if ( aActionMenuType == EFocusOnNumberWithinMessage )
  2859 		{
  2859         {
  2860 		uids.Append( FsEActionMenuCall );
  2860         uids.Append( FsEActionMenuCall );
  2861 		uids.Append( FsEActionMenuAddToContacts );
  2861         uids.Append( FsEActionMenuAddToContacts );
  2862 		// Drop FsEActionMenuCreateMessage from sip: addresses
  2862         // Drop FsEActionMenuCreateMessage from sip: addresses
  2863 		// First check which hotspot is active.
  2863         // First check which hotspot is active.
  2864 		SViewerHeadingHotSpotData currentHeaderHotSpotData;
  2864         SViewerHeadingHotSpotData currentHeaderHotSpotData;
  2865 		CFindItemEngine::SFoundItem currentBodyHotSpotData;
  2865         CFindItemEngine::SFoundItem currentBodyHotSpotData;
  2866 		THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL(
  2866         THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL(
  2867 			currentHeaderHotSpotData, currentBodyHotSpotData );
  2867             currentHeaderHotSpotData, currentBodyHotSpotData );
  2868 		HBufC* schemeText = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  2868         HBufC* schemeText = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  2869 		if ( schemeText &&  schemeText->FindC( KVoipPrefix ) != 0 )
  2869         if ( schemeText &&  schemeText->FindC( KVoipPrefix ) != 0 )
  2870 			{
  2870             {
  2871 			uids.Append( FsEActionMenuCreateMessage );
  2871             uids.Append( FsEActionMenuCreateMessage );
  2872 			}
  2872             }
  2873 		CleanupStack::PopAndDestroy( schemeText );
  2873         CleanupStack::PopAndDestroy( schemeText );
  2874 		if ( TFsEmailUiUtility::IsRemoteLookupSupported( *iMailBox ) )
  2874         if ( TFsEmailUiUtility::IsRemoteLookupSupported( *iMailBox ) )
  2875 			{
  2875             {
  2876 			uids.Append( FsEActionMenuRemoteLookup );
  2876             uids.Append( FsEActionMenuRemoteLookup );
  2877 			}
  2877             }
  2878 		}
  2878         }
  2879 	else if ( aActionMenuType == EFocusOnNameInAddressField ||
  2879     else if ( aActionMenuType == EFocusOnNameInAddressField ||
  2880 			  aActionMenuType == EFocusOnEMailInBodyText )
  2880               aActionMenuType == EFocusOnEMailInBodyText )
  2881 		{
  2881         {
  2882 		uids.Append( FsEActionMenuCall );
  2882         uids.Append( FsEActionMenuCall );
  2883 		uids.Append( FsEActionMenuCreateMessage );
  2883         uids.Append( FsEActionMenuCreateMessage );
  2884 	    uids.Append( FsEActionMenuCreateEmail );
  2884         uids.Append( FsEActionMenuCreateEmail );
  2885 		uids.Append( FsEActionMenuContactDetails );
  2885         uids.Append( FsEActionMenuContactDetails );
  2886 		uids.Append( FsEActionMenuAddToContacts );
  2886         uids.Append( FsEActionMenuAddToContacts );
  2887 		if ( TFsEmailUiUtility::IsRemoteLookupSupported( *iMailBox ) )
  2887         if ( TFsEmailUiUtility::IsRemoteLookupSupported( *iMailBox ) )
  2888 			{
  2888             {
  2889 			uids.Append( FsEActionMenuRemoteLookup );
  2889             uids.Append( FsEActionMenuRemoteLookup );
  2890 			}
  2890             }
  2891 		}
  2891         }
  2892 	else if ( aActionMenuType == EFocusOnHyperLinkWithinMessage )
  2892     else if ( aActionMenuType == EFocusOnHyperLinkWithinMessage )
  2893 		{
  2893         {
  2894 		uids.Append( FsEActionMenuOpenInWeb );
  2894         uids.Append( FsEActionMenuOpenInWeb );
  2895 		uids.Append( FsEActionMenuOpenInIntranet );
  2895         uids.Append( FsEActionMenuOpenInIntranet );
  2896 		uids.Append( FsEActionMenuBookmark );
  2896         uids.Append( FsEActionMenuBookmark );
  2897 		}
  2897         }
  2898 	else if ( aActionMenuType == EFocusOnAttachmentName )
  2898     else if ( aActionMenuType == EFocusOnAttachmentName )
  2899 		{
  2899         {
  2900 		if ( ShowOpenAttachmentOptionL() )
       
  2901 		    {
       
  2902     		uids.Append( FsEActionAttachmentOpen );
       
  2903 		    }
       
  2904 		if ( ShowDownloadOptionL() )
       
  2905 			{
       
  2906 			uids.Append( FsEActionAttachmentDownload );
       
  2907 			}
       
  2908 		if ( ShowCancelDownloadOption() )
       
  2909 			{
       
  2910 			uids.Append( FsEActionAttachmentCancelDownload );
       
  2911 			}
       
  2912 		if ( ShowSaveAttachmentOptionL() )
       
  2913 		    {
       
  2914 		    uids.Append( FsEActionAttachmentSave );
       
  2915 		    }
       
  2916         if ( ShowOpenAttachmentOptionL() )
  2900         if ( ShowOpenAttachmentOptionL() )
  2917             {
  2901             {
       
  2902             uids.Append( FsEActionAttachmentOpen );
       
  2903             }
       
  2904         if ( ShowDownloadOptionL() )
       
  2905             {
       
  2906             uids.Append( FsEActionAttachmentDownload );
       
  2907             }
       
  2908         if ( ShowCancelDownloadOption() )
       
  2909             {
       
  2910             uids.Append( FsEActionAttachmentCancelDownload );
       
  2911             }
       
  2912         if ( ShowSaveAttachmentOptionL() )
       
  2913             {
       
  2914             uids.Append( FsEActionAttachmentSave );
       
  2915             }
       
  2916         if ( ShowOpenAttachmentOptionL() )
       
  2917             {
  2918             uids.Append( FsEActionAttachmentClearFetchedContent );
  2918             uids.Append( FsEActionAttachmentClearFetchedContent );
  2919             }
  2919             }
  2920 		}
  2920         }
  2921 	else if ( aActionMenuType == EFocusOnAttachmentsText )
  2921     else if ( aActionMenuType == EFocusOnAttachmentsText )
  2922 		{
  2922         {
  2923 		if ( ShowOpenAttachmentOptionL() )
  2923         if ( ShowOpenAttachmentOptionL() )
  2924 		    {
  2924             {
  2925     		uids.Append( FsEActionAttachmentViewAll );
  2925             uids.Append( FsEActionAttachmentViewAll );
  2926 		    }
  2926             }
  2927 		if ( ShowDownloadOptionL() )
  2927         if ( ShowDownloadOptionL() )
  2928 			{
  2928             {
  2929 			uids.Append( FsEActionAttachmentDownloadAll );
  2929             uids.Append( FsEActionAttachmentDownloadAll );
  2930 			}
  2930             }
  2931 		if ( ShowCancelDownloadOption() )
  2931         if ( ShowCancelDownloadOption() )
  2932 			{
  2932             {
  2933 			uids.Append( FsEActionAttachmentCancelAllDownloads );
  2933             uids.Append( FsEActionAttachmentCancelAllDownloads );
  2934 			}
  2934             }
  2935 		if ( ShowSaveAttachmentOptionL() )
  2935         if ( ShowSaveAttachmentOptionL() )
  2936 		    {
  2936             {
  2937 		    uids.Append( FsEActionAttachmentSaveAll );
  2937             uids.Append( FsEActionAttachmentSaveAll );
  2938 		    }
  2938             }
  2939 		}
  2939         }
  2940 
  2940 
  2941 	TInt uidsCount = uids.Count();
  2941     TInt uidsCount = uids.Count();
  2942 	for ( TInt i = 0; i <  uidsCount; i++ )
  2942     for ( TInt i = 0; i <  uidsCount; i++ )
  2943 		{
  2943         {
  2944 		CFSEmailUiActionMenu::AddCustomItemL( uids[i] );
  2944         CFSEmailUiActionMenu::AddCustomItemL( uids[i] );
  2945 		}
  2945         }
  2946 	CleanupStack::PopAndDestroy( &uids );
  2946     CleanupStack::PopAndDestroy( &uids );
  2947 	}
  2947     }
  2948 
  2948 
  2949 
  2949 
  2950 // -----------------------------------------------------------------------------
  2950 // -----------------------------------------------------------------------------
  2951 // CFSEmailUiMailViewerVisualiser::HandleActionMenuCommandL
  2951 // CFSEmailUiMailViewerVisualiser::HandleActionMenuCommandL
  2952 // -----------------------------------------------------------------------------
  2952 // -----------------------------------------------------------------------------
  2953 void CFSEmailUiMailViewerVisualiser::HandleActionMenuCommandL(
  2953 void CFSEmailUiMailViewerVisualiser::HandleActionMenuCommandL(
  2954 	TActionMenuCustomItemId aSelectedActionMenuItem,
  2954     TActionMenuCustomItemId aSelectedActionMenuItem,
  2955 	TActionMenuType aActionMenuType )
  2955     TActionMenuType aActionMenuType )
  2956 	{
  2956     {
  2957     FUNC_LOG;
  2957     FUNC_LOG;
  2958 	// check which hotspot is active.
  2958     // check which hotspot is active.
  2959 	SViewerHeadingHotSpotData currentHeaderHotSpotData;
  2959     SViewerHeadingHotSpotData currentHeaderHotSpotData;
  2960 	CFindItemEngine::SFoundItem currentBodyHotSpotData;
  2960     CFindItemEngine::SFoundItem currentBodyHotSpotData;
  2961 	THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL(
  2961     THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL(
  2962 		currentHeaderHotSpotData, currentBodyHotSpotData );
  2962         currentHeaderHotSpotData, currentBodyHotSpotData );
  2963 
  2963 
  2964 	if ( aActionMenuType == EFocusOnNumberWithinMessage )
  2964     if ( aActionMenuType == EFocusOnNumberWithinMessage )
  2965 		{
  2965         {
  2966 		switch ( aSelectedActionMenuItem  )
  2966         switch ( aSelectedActionMenuItem  )
  2967 			{
  2967             {
  2968 			case FsEActionMenuCall: // Call
  2968             case FsEActionMenuCall: // Call
  2969 				{
  2969                 {
  2970 				CallToBodyHotSpotNumberL( currentBodyHotSpotData );
  2970                 CallToBodyHotSpotNumberL( currentBodyHotSpotData );
  2971 				}
  2971                 }
  2972 				break;
  2972                 break;
  2973 			case FsEActionMenuAddToContacts: // Add to Contacts
  2973             case FsEActionMenuAddToContacts: // Add to Contacts
  2974 				{
  2974                 {
  2975 				HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  2975                 HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  2976 					currentBodyHotSpotData );
  2976                     currentBodyHotSpotData );
  2977 				SavePhoneNumberAsContactL( *hotspotText );
  2977                 SavePhoneNumberAsContactL( *hotspotText );
  2978 				CleanupStack::PopAndDestroy( hotspotText );
  2978                 CleanupStack::PopAndDestroy( hotspotText );
  2979 				}
  2979                 }
  2980 				break;
  2980                 break;
  2981 			case FsEActionMenuCreateMessage: // Create message
  2981             case FsEActionMenuCreateMessage: // Create message
  2982 				{
  2982                 {
  2983 				CreateMessageL();
  2983                 CreateMessageL();
  2984 				}
  2984                 }
  2985 				break;
  2985                 break;
  2986 			case FsEActionMenuRemoteLookup: // Remote lookup
  2986             case FsEActionMenuRemoteLookup: // Remote lookup
  2987 				{
  2987                 {
  2988 				HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  2988                 HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  2989 					currentBodyHotSpotData );
  2989                     currentBodyHotSpotData );
  2990 				LaunchRemoteLookupL( *hotspotText );
  2990                 LaunchRemoteLookupL( *hotspotText );
  2991 				CleanupStack::PopAndDestroy( hotspotText );
  2991                 CleanupStack::PopAndDestroy( hotspotText );
  2992 				}
  2992                 }
  2993 				break;
  2993                 break;
  2994 			}
  2994             }
  2995 		}
  2995         }
  2996 	else if ( aActionMenuType == EFocusOnNameInAddressField )
  2996     else if ( aActionMenuType == EFocusOnNameInAddressField )
  2997 		{
  2997         {
  2998 		switch( aSelectedActionMenuItem )
  2998         switch( aSelectedActionMenuItem )
  2999 			{
  2999             {
  3000 			case FsEActionMenuCall: // Call
  3000             case FsEActionMenuCall: // Call
  3001 				{
  3001                 {
  3002 				CallHotSpotAddressL();
  3002                 CallHotSpotAddressL();
  3003 				}
  3003                 }
  3004 				break;
  3004                 break;
  3005 			case FsEActionMenuCreateMessage: // Create message
  3005             case FsEActionMenuCreateMessage: // Create message
  3006 				{
  3006                 {
  3007 				CreateMessageL();
  3007                 CreateMessageL();
  3008 				}
  3008                 }
  3009 				break;
  3009                 break;
  3010             case FsEActionMenuCreateEmail: // Create message
  3010             case FsEActionMenuCreateEmail: // Create message
  3011                 {
  3011                 {
  3012                 ComposeMailL();
  3012                 ComposeMailL();
  3013                 }
  3013                 }
  3014                 break;
  3014                 break;
  3015 			case FsEActionMenuContactDetails: // Contact details
  3015             case FsEActionMenuContactDetails: // Contact details
  3016 				{
  3016                 {
  3017 				OpenContactDetailsL();
  3017                 OpenContactDetailsL();
  3018 				}
  3018                 }
  3019 				break;
  3019                 break;
  3020 			case FsEActionMenuAddToContacts: // Add to Contacts
  3020             case FsEActionMenuAddToContacts: // Add to Contacts
  3021 				{
  3021                 {
  3022 				HBufC* emailAddress =
  3022                 HBufC* emailAddress =
  3023 					iViewerRichText->GetHeaderHotspotEmailAddressLC(
  3023                     iViewerRichText->GetHeaderHotspotEmailAddressLC(
  3024 						currentHeaderHotSpotData );
  3024                         currentHeaderHotSpotData );
  3025 				SaveEmailAsContactL( *emailAddress );
  3025                 SaveEmailAsContactL( *emailAddress );
  3026 				CleanupStack::PopAndDestroy( emailAddress );
  3026                 CleanupStack::PopAndDestroy( emailAddress );
  3027 				}
  3027                 }
  3028 				break;
  3028                 break;
  3029 			case FsEActionMenuRemoteLookup: // Remote lookup
  3029             case FsEActionMenuRemoteLookup: // Remote lookup
  3030 				{
  3030                 {
  3031 				HBufC* emailAddress =
  3031                 HBufC* emailAddress =
  3032 					iViewerRichText->GetHeaderHotspotEmailAddressLC(
  3032                     iViewerRichText->GetHeaderHotspotEmailAddressLC(
  3033 						currentHeaderHotSpotData );
  3033                         currentHeaderHotSpotData );
  3034 				LaunchRemoteLookupL( *emailAddress );
  3034                 LaunchRemoteLookupL( *emailAddress );
  3035 				CleanupStack::PopAndDestroy( emailAddress );
  3035                 CleanupStack::PopAndDestroy( emailAddress );
  3036 				}
  3036                 }
  3037 				break;
  3037                 break;
  3038 			}
  3038             }
  3039 		}
  3039         }
  3040 	else if ( aActionMenuType == EFocusOnHyperLinkWithinMessage )
  3040     else if ( aActionMenuType == EFocusOnHyperLinkWithinMessage )
  3041 		{
  3041         {
  3042 		switch ( aSelectedActionMenuItem )
  3042         switch ( aSelectedActionMenuItem )
  3043 			{
  3043             {
  3044 			case FsEActionMenuOpenInWeb: // Open in web
  3044             case FsEActionMenuOpenInWeb: // Open in web
  3045 				{
  3045                 {
  3046 				OpenHotSpotUrlInBrowserL( currentBodyHotSpotData );
  3046                 OpenHotSpotUrlInBrowserL( currentBodyHotSpotData );
  3047 				}
  3047                 }
  3048 				break;
  3048                 break;
  3049 			case FsEActionMenuOpenInIntranet: // Open in intranet
  3049             case FsEActionMenuOpenInIntranet: // Open in intranet
  3050 				{
  3050                 {
  3051 				OpenLinkInIntranetL( EFalse );
  3051                 OpenLinkInIntranetL( EFalse );
  3052 				}
  3052                 }
  3053 				break;
  3053                 break;
  3054 			case FsEActionMenuBookmark: // Bookmark
  3054             case FsEActionMenuBookmark: // Bookmark
  3055 				{
  3055                 {
  3056 				AddToBookmarksL( currentBodyHotSpotData );
  3056                 AddToBookmarksL( currentBodyHotSpotData );
  3057 				}
  3057                 }
  3058 				break;
  3058                 break;
  3059 			}
  3059             }
  3060 		}
  3060         }
  3061 	else if ( aActionMenuType == EFocusOnAttachmentName ||
  3061     else if ( aActionMenuType == EFocusOnAttachmentName ||
  3062               aActionMenuType == EFocusOnAttachmentsText )
  3062               aActionMenuType == EFocusOnAttachmentsText )
  3063 		{
  3063         {
  3064 		switch ( aSelectedActionMenuItem )
  3064         switch ( aSelectedActionMenuItem )
  3065 			{
  3065             {
  3066 			case FsEActionAttachmentOpen: // Open single attachment
  3066             case FsEActionAttachmentOpen: // Open single attachment
  3067 			    {
  3067                 {
  3068 			    OpenAttachmentL();
  3068                 OpenAttachmentL();
  3069                 }
  3069                 }
  3070                 break;
  3070                 break;
  3071 			case FsEActionAttachmentViewAll: // Open attachments list
  3071             case FsEActionAttachmentViewAll: // Open attachments list
  3072 			    {
  3072                 {
  3073 			    OpenAttachmentsViewL();
  3073                 OpenAttachmentsViewL();
  3074 			    }
  3074                 }
  3075 				break;
  3075                 break;
  3076 			case FsEActionAttachmentDownload: // Dowload one
  3076             case FsEActionAttachmentDownload: // Dowload one
  3077 			case FsEActionAttachmentDownloadAll : /// all attachments
  3077             case FsEActionAttachmentDownloadAll : /// all attachments
  3078 				{
  3078                 {
  3079 				StartDowloadingAttachmentsL();
  3079                 StartDowloadingAttachmentsL();
  3080 				}
  3080                 }
  3081 				break;
  3081                 break;
  3082 			case FsEActionAttachmentCancelDownload: // Cancel one / all downloads
  3082             case FsEActionAttachmentCancelDownload: // Cancel one / all downloads
  3083 			case FsEActionAttachmentCancelAllDownloads:
  3083             case FsEActionAttachmentCancelAllDownloads:
  3084 				{
  3084                 {
  3085 				CancelDowloadingAttachmentsL();
  3085                 CancelDowloadingAttachmentsL();
  3086 				}
  3086                 }
  3087 				break;
  3087                 break;
  3088 			case FsEActionAttachmentSave: // Save one / all attachments
  3088             case FsEActionAttachmentSave: // Save one / all attachments
  3089 			case FsEActionAttachmentSaveAll:
  3089             case FsEActionAttachmentSaveAll:
  3090 				{
  3090                 {
  3091 				SaveAllAttachmentsL();
  3091                 SaveAllAttachmentsL();
  3092 				}
  3092                 }
  3093 				break;
  3093                 break;
  3094 			case FsEActionAttachmentClearFetchedContent:
  3094             case FsEActionAttachmentClearFetchedContent:
  3095 			    {
  3095                 {
  3096 			    RemoveFetchedAttachmentL();
  3096                 RemoveFetchedAttachmentL();
  3097 			    }
  3097                 }
  3098 			    break;
  3098                 break;
  3099 			}
  3099             }
  3100 		}
  3100         }
  3101 	else if ( aActionMenuType == EFocusOnEMailInBodyText )
  3101     else if ( aActionMenuType == EFocusOnEMailInBodyText )
  3102 		{
  3102         {
  3103 		switch ( aSelectedActionMenuItem )
  3103         switch ( aSelectedActionMenuItem )
  3104 			{
  3104             {
  3105 			case FsEActionMenuCall: // Call
  3105             case FsEActionMenuCall: // Call
  3106 				{
  3106                 {
  3107 				CallHotSpotAddressL();
  3107                 CallHotSpotAddressL();
  3108 				}
  3108                 }
  3109 				break;
  3109                 break;
  3110 			case FsEActionMenuCreateMessage: // Create message
  3110             case FsEActionMenuCreateMessage: // Create message
  3111 				{
  3111                 {
  3112 				CreateMessageL();
  3112                 CreateMessageL();
  3113 				}
  3113                 }
  3114 				break;
  3114                 break;
  3115             case FsEActionMenuCreateEmail: // Create message
  3115             case FsEActionMenuCreateEmail: // Create message
  3116                 {
  3116                 {
  3117                 ComposeMailL();
  3117                 ComposeMailL();
  3118                 }
  3118                 }
  3119                 break;
  3119                 break;
  3120 			case FsEActionMenuContactDetails: // Contact details
  3120             case FsEActionMenuContactDetails: // Contact details
  3121 				{
  3121                 {
  3122 				OpenContactDetailsL();
  3122                 OpenContactDetailsL();
  3123 				}
  3123                 }
  3124 				break;
  3124                 break;
  3125 			case FsEActionMenuAddToContacts: // Add to Contacts
  3125             case FsEActionMenuAddToContacts: // Add to Contacts
  3126 				{
  3126                 {
  3127 				HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  3127                 HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  3128 					currentBodyHotSpotData );
  3128                     currentBodyHotSpotData );
  3129 				if ( currentBodyHotSpotData.iItemType ==
  3129                 if ( currentBodyHotSpotData.iItemType ==
  3130 					CFindItemEngine::EFindItemSearchPhoneNumberBin )
  3130                     CFindItemEngine::EFindItemSearchPhoneNumberBin )
  3131 					{
  3131                     {
  3132 					SavePhoneNumberAsContactL( *hotspotText );
  3132                     SavePhoneNumberAsContactL( *hotspotText );
  3133 					}
  3133                     }
  3134 				else if ( currentBodyHotSpotData.iItemType ==
  3134                 else if ( currentBodyHotSpotData.iItemType ==
  3135 					CFindItemEngine::EFindItemSearchMailAddressBin )
  3135                     CFindItemEngine::EFindItemSearchMailAddressBin )
  3136 					{
  3136                     {
  3137 					SaveEmailAsContactL( *hotspotText );
  3137                     SaveEmailAsContactL( *hotspotText );
  3138 					}
  3138                     }
  3139 				else if ( currentBodyHotSpotData.iItemType ==
  3139                 else if ( currentBodyHotSpotData.iItemType ==
  3140 					CFindItemEngine::EFindItemSearchScheme )
  3140                     CFindItemEngine::EFindItemSearchScheme )
  3141 					{
  3141                     {
  3142 					if ( hotspotText->FindC( KMailtoPrefix ) == 0 )
  3142                     if ( hotspotText->FindC( KMailtoPrefix ) == 0 )
  3143 						{
  3143                         {
  3144 						// Save email as contact, address mailto: strip is done in SaveEmailAsContactL
  3144                         // Save email as contact, address mailto: strip is done in SaveEmailAsContactL
  3145 						SaveEmailAsContactL( *hotspotText );
  3145                         SaveEmailAsContactL( *hotspotText );
  3146 						}
  3146                         }
  3147 					}
  3147                     }
  3148 				CleanupStack::PopAndDestroy( hotspotText );
  3148                 CleanupStack::PopAndDestroy( hotspotText );
  3149 				}
  3149                 }
  3150 				break;
  3150                 break;
  3151 			case FsEActionMenuRemoteLookup: // Remote lookup
  3151             case FsEActionMenuRemoteLookup: // Remote lookup
  3152 				{
  3152                 {
  3153 				HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  3153                 HBufC* hotspotText = iViewerRichText->GetHotspotTextLC(
  3154 					currentBodyHotSpotData );
  3154                     currentBodyHotSpotData );
  3155 				LaunchRemoteLookupL( *hotspotText );
  3155                 LaunchRemoteLookupL( *hotspotText );
  3156 				CleanupStack::PopAndDestroy( hotspotText );
  3156                 CleanupStack::PopAndDestroy( hotspotText );
  3157 				}
  3157                 }
  3158 				break;
  3158                 break;
  3159 			}
  3159             }
  3160 		}
  3160         }
  3161 	}
  3161     }
  3162 
  3162 
  3163 // -----------------------------------------------------------------------------
  3163 // -----------------------------------------------------------------------------
  3164 // CFSEmailUiMailViewerVisualiser::OpenContactDetailsL
  3164 // CFSEmailUiMailViewerVisualiser::OpenContactDetailsL
  3165 // -----------------------------------------------------------------------------
  3165 // -----------------------------------------------------------------------------
  3166 void CFSEmailUiMailViewerVisualiser::OpenContactDetailsL()
  3166 void CFSEmailUiMailViewerVisualiser::OpenContactDetailsL()
  3167 	{
  3167     {
  3168     FUNC_LOG;
  3168     FUNC_LOG;
  3169 	SViewerHeadingHotSpotData currentHeaderHotSpotData;
  3169     SViewerHeadingHotSpotData currentHeaderHotSpotData;
  3170 	CFindItemEngine::SFoundItem currentBodyHotSpotData;
  3170     CFindItemEngine::SFoundItem currentBodyHotSpotData;
  3171 	THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL( currentHeaderHotSpotData, currentBodyHotSpotData );
  3171     THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL( currentHeaderHotSpotData, currentBodyHotSpotData );
  3172 
  3172 
  3173 	HBufC* emailAddress = NULL;
  3173     HBufC* emailAddress = NULL;
  3174 	if ( hotspotType == EHeaderHotspot )
  3174     if ( hotspotType == EHeaderHotspot )
  3175 		{
  3175         {
  3176 		emailAddress = iViewerRichText->GetHeaderHotspotEmailAddressLC( currentHeaderHotSpotData );
  3176         emailAddress = iViewerRichText->GetHeaderHotspotEmailAddressLC( currentHeaderHotSpotData );
  3177 		}
  3177         }
  3178 	else if ( hotspotType == EBodyHotspot )
  3178     else if ( hotspotType == EBodyHotspot )
  3179 		{
  3179         {
  3180 		emailAddress = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3180         emailAddress = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3181 		// Delete "mailto:" prefix if found
  3181         // Delete "mailto:" prefix if found
  3182 		if ( emailAddress->FindC( KMailtoPrefix ) == 0 )
  3182         if ( emailAddress->FindC( KMailtoPrefix ) == 0 )
  3183 			{
  3183             {
  3184 			emailAddress->Des().Delete( 0, KMailtoPrefix().Length() );
  3184             emailAddress->Des().Delete( 0, KMailtoPrefix().Length() );
  3185 			}
  3185             }
  3186 		}
  3186         }
  3187 	else
  3187     else
  3188 		{
  3188         {
  3189 		return;
  3189         return;
  3190 		}
  3190         }
  3191 
  3191 
  3192 	CFsDelayedLoader::InstanceL()->GetContactHandlerL()->ShowContactDetailsL(
  3192     CFsDelayedLoader::InstanceL()->GetContactHandlerL()->ShowContactDetailsL(
  3193 			*emailAddress, EContactUpdateEmail, NULL );
  3193             *emailAddress, EContactUpdateEmail, NULL );
  3194 
  3194 
  3195 	CleanupStack::PopAndDestroy( emailAddress );
  3195     CleanupStack::PopAndDestroy( emailAddress );
  3196 	}
  3196     }
  3197 
  3197 
  3198 // -----------------------------------------------------------------------------
  3198 // -----------------------------------------------------------------------------
  3199 // CFSEmailUiMailViewerVisualiser::LaunchHtmlViewerL
  3199 // CFSEmailUiMailViewerVisualiser::LaunchHtmlViewerL
  3200 // -----------------------------------------------------------------------------
  3200 // -----------------------------------------------------------------------------
  3201 void CFSEmailUiMailViewerVisualiser::LaunchHtmlViewerL()
  3201 void CFSEmailUiMailViewerVisualiser::LaunchHtmlViewerL()
  3202 	{
  3202     {
  3203     FUNC_LOG;
  3203     FUNC_LOG;
  3204 	if ( MessagePartFullyFetchedL( EMessageHtmlBodyPart ) )
  3204     if ( MessagePartFullyFetchedL( EMessageHtmlBodyPart ) )
  3205 		{
  3205         {
  3206 		THtmlViewerActivationData htmlData;
  3206         THtmlViewerActivationData htmlData;
  3207 		htmlData.iActivationDataType = THtmlViewerActivationData::EMailMessage;
  3207         htmlData.iActivationDataType = THtmlViewerActivationData::EMailMessage;
  3208 		htmlData.iMailBoxId = iMessage->GetMailBoxId();
  3208         htmlData.iMailBoxId = iMessage->GetMailBoxId();
  3209         htmlData.iFolderId = iMessage->GetFolderId();
  3209         htmlData.iFolderId = iMessage->GetFolderId();
  3210         htmlData.iMessageId = iMessage->GetMessageId();
  3210         htmlData.iMessageId = iMessage->GetMessageId();
  3211         htmlData.iEmbeddedMessageMode = iEmbeddedMessageMode;
  3211         htmlData.iEmbeddedMessageMode = iEmbeddedMessageMode;
  3212 		TPckgBuf<THtmlViewerActivationData> pckgData( htmlData );
  3212         TPckgBuf<THtmlViewerActivationData> pckgData( htmlData );
  3213 
  3213 
  3214 		iAppUi.EnterFsEmailViewL( HtmlViewerId, KHtmlViewerOpenNew, pckgData );
  3214         iAppUi.EnterFsEmailViewL( HtmlViewerId, KHtmlViewerOpenNew, pckgData );
  3215 		}
  3215         }
  3216 	else
  3216     else
  3217 		{
  3217         {
  3218 		StartWaitedFetchingL( EMessageHtmlBodyPart );
  3218         StartWaitedFetchingL( EMessageHtmlBodyPart );
  3219 		}
  3219         }
  3220 	}
  3220     }
  3221 
  3221 
  3222 // -----------------------------------------------------------------------------
  3222 // -----------------------------------------------------------------------------
  3223 // CFSEmailUiMailViewerVisualiser::LaunchRemoteLookupL
  3223 // CFSEmailUiMailViewerVisualiser::LaunchRemoteLookupL
  3224 // -----------------------------------------------------------------------------
  3224 // -----------------------------------------------------------------------------
  3225 void CFSEmailUiMailViewerVisualiser::LaunchRemoteLookupL( const TDesC& aDes ) const
  3225 void CFSEmailUiMailViewerVisualiser::LaunchRemoteLookupL( const TDesC& aDes ) const
  3226 	{
  3226     {
  3227     FUNC_LOG;
  3227     FUNC_LOG;
  3228 	// this method assumes that remote lookup is available with current plugin.
  3228     // this method assumes that remote lookup is available with current plugin.
  3229 	HBufC* textData = HBufC::NewLC( aDes.Length() );
  3229     HBufC* textData = HBufC::NewLC( aDes.Length() );
  3230 	textData->Des().Append( aDes );
  3230     textData->Des().Append( aDes );
  3231 	if ( textData->FindC( KMailtoPrefix ) == 0 )
  3231     if ( textData->FindC( KMailtoPrefix ) == 0 )
  3232 		{
  3232         {
  3233 		textData->Des().Delete( 0, KMailtoPrefix().Length() );
  3233         textData->Des().Delete( 0, KMailtoPrefix().Length() );
  3234 		}
  3234         }
  3235 	else if ( textData->FindC( KCallPrefix ) == 0 )
  3235     else if ( textData->FindC( KCallPrefix ) == 0 )
  3236 		{
  3236         {
  3237 		textData->Des().Delete( 0, KCallPrefix().Length() );
  3237         textData->Des().Delete( 0, KCallPrefix().Length() );
  3238 		}
  3238         }
  3239 	else if ( textData->FindC( KTelPrefix ) == 0 )
  3239     else if ( textData->FindC( KTelPrefix ) == 0 )
  3240 		{
  3240         {
  3241 		textData->Des().Delete( 0, KTelPrefix().Length() );
  3241         textData->Des().Delete( 0, KTelPrefix().Length() );
  3242 		}
  3242         }
  3243 	else if ( textData->FindC( KSmsPrefix ) == 0 )
  3243     else if ( textData->FindC( KSmsPrefix ) == 0 )
  3244 		{
  3244         {
  3245 		textData->Des().Delete( 0, KSmsPrefix().Length() );
  3245         textData->Des().Delete( 0, KSmsPrefix().Length() );
  3246 		}
  3246         }
  3247 	else if ( textData->FindC( KMmsPrefix ) == 0 )
  3247     else if ( textData->FindC( KMmsPrefix ) == 0 )
  3248 		{
  3248         {
  3249 		textData->Des().Delete( 0, KMmsPrefix().Length() );
  3249         textData->Des().Delete( 0, KMmsPrefix().Length() );
  3250 		}
  3250         }
  3251 	else if ( textData->FindC( KVoipPrefix ) == 0 )
  3251     else if ( textData->FindC( KVoipPrefix ) == 0 )
  3252 		{
  3252         {
  3253 		textData->Des().Delete( 0, KVoipPrefix().Length() );
  3253         textData->Des().Delete( 0, KVoipPrefix().Length() );
  3254 		}
  3254         }
  3255 
  3255 
  3256 	CFsDelayedLoader::InstanceL()->GetContactHandlerL()->LaunchRemoteLookupWithQueryL( *iMailBox, *textData );
  3256     CFsDelayedLoader::InstanceL()->GetContactHandlerL()->LaunchRemoteLookupWithQueryL( *iMailBox, *textData );
  3257 	CleanupStack::PopAndDestroy( textData );
  3257     CleanupStack::PopAndDestroy( textData );
  3258 	}
  3258     }
  3259 
  3259 
  3260 // -----------------------------------------------------------------------------
  3260 // -----------------------------------------------------------------------------
  3261 // CFSEmailUiMailViewerVisualiser::AddToBookmarksL
  3261 // CFSEmailUiMailViewerVisualiser::AddToBookmarksL
  3262 // -----------------------------------------------------------------------------
  3262 // -----------------------------------------------------------------------------
  3263 void CFSEmailUiMailViewerVisualiser::AddToBookmarksL(
  3263 void CFSEmailUiMailViewerVisualiser::AddToBookmarksL(
  3264 				const CFindItemEngine::SFoundItem& aBodyHotspotData ) const
  3264                 const CFindItemEngine::SFoundItem& aBodyHotspotData ) const
  3265 	{
  3265     {
  3266     FUNC_LOG;
  3266     FUNC_LOG;
  3267 	HBufC* hotspotText =
  3267     HBufC* hotspotText =
  3268 		iViewerRichText->GetHotspotTextLC( aBodyHotspotData );
  3268         iViewerRichText->GetHotspotTextLC( aBodyHotspotData );
  3269 
  3269 
  3270 	RFavouritesSession fSession;
  3270     RFavouritesSession fSession;
  3271 	User::LeaveIfError( fSession.Connect() );
  3271     User::LeaveIfError( fSession.Connect() );
  3272 	CleanupClosePushL( fSession );
  3272     CleanupClosePushL( fSession );
  3273 
  3273 
  3274 	RFavouritesDb favoris;
  3274     RFavouritesDb favoris;
  3275 	User::LeaveIfError( favoris.Open( fSession, KBrowserBookmarks ) );
  3275     User::LeaveIfError( favoris.Open( fSession, KBrowserBookmarks ) );
  3276 	CleanupClosePushL( favoris );
  3276     CleanupClosePushL( favoris );
  3277 
  3277 
  3278 	CFavouritesItem *favorisItem = CFavouritesItem::NewLC();
  3278     CFavouritesItem *favorisItem = CFavouritesItem::NewLC();
  3279 	favorisItem->SetType( CFavouritesItem::EItem );
  3279     favorisItem->SetType( CFavouritesItem::EItem );
  3280 	favorisItem->SetUrlL( *hotspotText );
  3280     favorisItem->SetUrlL( *hotspotText );
  3281     // Should be less than KFavouritesMaxName ( 50 )
  3281     // Should be less than KFavouritesMaxName ( 50 )
  3282 	if ( hotspotText->Length() > KFavouritesMaxName )
  3282     if ( hotspotText->Length() > KFavouritesMaxName )
  3283 		{
  3283         {
  3284 		favorisItem->SetNameL( hotspotText->Left( KFavouritesMaxName ) );
  3284         favorisItem->SetNameL( hotspotText->Left( KFavouritesMaxName ) );
  3285 		}
  3285         }
  3286 	else
  3286     else
  3287 		{
  3287         {
  3288      	favorisItem->SetNameL( *hotspotText );
  3288         favorisItem->SetNameL( *hotspotText );
  3289 		}
  3289         }
  3290 
  3290 
  3291 	favorisItem->SetParentFolder( KFavouritesRootUid );
  3291     favorisItem->SetParentFolder( KFavouritesRootUid );
  3292 
  3292 
  3293 	TInt error = favoris.Add( *favorisItem, ETrue );
  3293     TInt error = favoris.Add( *favorisItem, ETrue );
  3294 
  3294 
  3295 	CleanupStack::PopAndDestroy( favorisItem );
  3295     CleanupStack::PopAndDestroy( favorisItem );
  3296 	CleanupStack::PopAndDestroy( &favoris );
  3296     CleanupStack::PopAndDestroy( &favoris );
  3297 	CleanupStack::PopAndDestroy( &fSession );
  3297     CleanupStack::PopAndDestroy( &fSession );
  3298 
  3298 
  3299 	CleanupStack::PopAndDestroy( hotspotText );
  3299     CleanupStack::PopAndDestroy( hotspotText );
  3300 
  3300 
  3301 	if ( error == KErrNone )
  3301     if ( error == KErrNone )
  3302 		{
  3302         {
  3303 		TFsEmailUiUtility::ShowInfoNoteL(
  3303         TFsEmailUiUtility::ShowInfoNoteL(
  3304 			R_FREESTYLE_EMAIL_UI_VIEWER_BOOKMARK_ADDED, ETrue );
  3304             R_FREESTYLE_EMAIL_UI_VIEWER_BOOKMARK_ADDED, ETrue );
  3305 		}
  3305         }
  3306 	else // Error in bookmark creation, show could not complete message
  3306     else // Error in bookmark creation, show could not complete message
  3307 		{
  3307         {
  3308 		TFsEmailUiUtility::ShowErrorNoteL(
  3308         TFsEmailUiUtility::ShowErrorNoteL(
  3309 			R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
  3309             R_FREESTYLE_EMAIL_ERROR_GENERAL_UNABLE_TO_COMPLETE, ETrue );
  3310 		}
  3310         }
  3311 	}
  3311     }
  3312 
  3312 
  3313 // -----------------------------------------------------------------------------
  3313 // -----------------------------------------------------------------------------
  3314 // CFSEmailUiMailViewerVisualiser::CallHotSpotAddressL
  3314 // CFSEmailUiMailViewerVisualiser::CallHotSpotAddressL
  3315 // -----------------------------------------------------------------------------
  3315 // -----------------------------------------------------------------------------
  3316 void CFSEmailUiMailViewerVisualiser::CallHotSpotAddressL()
  3316 void CFSEmailUiMailViewerVisualiser::CallHotSpotAddressL()
  3317 	{
  3317     {
  3318     FUNC_LOG;
  3318     FUNC_LOG;
  3319 	SViewerHeadingHotSpotData currentHeaderHotSpotData;
  3319     SViewerHeadingHotSpotData currentHeaderHotSpotData;
  3320 	CFindItemEngine::SFoundItem currentBodyHotSpotData;
  3320     CFindItemEngine::SFoundItem currentBodyHotSpotData;
  3321 	THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL( currentHeaderHotSpotData, currentBodyHotSpotData );
  3321     THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL( currentHeaderHotSpotData, currentBodyHotSpotData );
  3322 
  3322 
  3323    if( hotspotType == EHeaderHotspot &&  currentHeaderHotSpotData.iType == ETypeFromAddressDisplayName )
  3323    if( hotspotType == EHeaderHotspot &&  currentHeaderHotSpotData.iType == ETypeFromAddressDisplayName )
  3324         {
  3324         {
  3325         HBufC* emailAddress = iViewerRichText->GetHeaderHotspotEmailAddressLC( currentHeaderHotSpotData );
  3325         HBufC* emailAddress = iViewerRichText->GetHeaderHotspotEmailAddressLC( currentHeaderHotSpotData );
  3326            CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( *emailAddress,
  3326            CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( *emailAddress,
  3327                     iAppUi.GetActiveMailbox(), this, ETrue /*use call sender text*/);
  3327                     iAppUi.GetActiveMailbox(), this, ETrue /*use call sender text*/);
  3328            CleanupStack::PopAndDestroy( emailAddress );
  3328            CleanupStack::PopAndDestroy( emailAddress );
  3329         }
  3329         }
  3330    else if( ( hotspotType == EHeaderHotspot &&
  3330    else if( ( hotspotType == EHeaderHotspot &&
  3331 			( currentHeaderHotSpotData.iType == ETypeToAddressDisplayName ||
  3331             ( currentHeaderHotSpotData.iType == ETypeToAddressDisplayName ||
  3332 			currentHeaderHotSpotData.iType == ETypeCcAddressDisplayName ||
  3332             currentHeaderHotSpotData.iType == ETypeCcAddressDisplayName ||
  3333 			currentHeaderHotSpotData.iType == ETypeBccAddressDisplayName ||
  3333             currentHeaderHotSpotData.iType == ETypeBccAddressDisplayName ||
  3334 			currentHeaderHotSpotData.iType == ETypeEmailAddress )
  3334             currentHeaderHotSpotData.iType == ETypeEmailAddress )
  3335 			)
  3335             )
  3336 		)
  3336         )
  3337 		{
  3337         {
  3338 		HBufC* emailAddress = iViewerRichText->GetHeaderHotspotEmailAddressLC( currentHeaderHotSpotData );
  3338         HBufC* emailAddress = iViewerRichText->GetHeaderHotspotEmailAddressLC( currentHeaderHotSpotData );
  3339 		CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( *emailAddress,
  3339         CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( *emailAddress,
  3340 				 iAppUi.GetActiveMailbox(), this, EFalse /*use call sender text*/);
  3340                  iAppUi.GetActiveMailbox(), this, EFalse /*use call sender text*/);
  3341 		CleanupStack::PopAndDestroy( emailAddress );
  3341         CleanupStack::PopAndDestroy( emailAddress );
  3342 		}
  3342         }
  3343 	else if( hotspotType == EBodyHotspot &&
  3343     else if( hotspotType == EBodyHotspot &&
  3344 				currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchMailAddressBin	)
  3344                 currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchMailAddressBin  )
  3345 		{
  3345         {
  3346 		HBufC* emailAddress = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3346         HBufC* emailAddress = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3347 		CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( *emailAddress,
  3347         CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( *emailAddress,
  3348 				 iAppUi.GetActiveMailbox(), this, EFalse );
  3348                  iAppUi.GetActiveMailbox(), this, EFalse );
  3349 		CleanupStack::PopAndDestroy( emailAddress );
  3349         CleanupStack::PopAndDestroy( emailAddress );
  3350 		}
  3350         }
  3351 	else if( hotspotType == EBodyHotspot &&
  3351     else if( hotspotType == EBodyHotspot &&
  3352 				currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchPhoneNumberBin )
  3352                 currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchPhoneNumberBin )
  3353 		{
  3353         {
  3354 		CallToBodyHotSpotNumberL( currentBodyHotSpotData );
  3354         CallToBodyHotSpotNumberL( currentBodyHotSpotData );
  3355 		}
  3355         }
  3356 	else if ( currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchScheme )
  3356     else if ( currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchScheme )
  3357 		{
  3357         {
  3358 		// Get scheme text and make sure there is "mailto:" text or "call:" text
  3358         // Get scheme text and make sure there is "mailto:" text or "call:" text
  3359 		HBufC* schemeText = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3359         HBufC* schemeText = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3360 		if ( schemeText &&  schemeText->FindC( KMailtoPrefix ) == 0 )
  3360         if ( schemeText &&  schemeText->FindC( KMailtoPrefix ) == 0 )
  3361 			{
  3361             {
  3362 			schemeText->Des().Delete( 0, KMailtoPrefix().Length() );
  3362             schemeText->Des().Delete( 0, KMailtoPrefix().Length() );
  3363 			CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( *schemeText,
  3363             CFsDelayedLoader::InstanceL()->GetContactHandlerL()->FindAndCallToContactByEmailL( *schemeText,
  3364 				 iAppUi.GetActiveMailbox(), this, EFalse);
  3364                  iAppUi.GetActiveMailbox(), this, EFalse);
  3365 			}
  3365             }
  3366 		else if ( schemeText->FindC( KCallPrefix ) == 0 ||
  3366         else if ( schemeText->FindC( KCallPrefix ) == 0 ||
  3367 				  schemeText->FindC( KTelPrefix ) == 0 ||
  3367                   schemeText->FindC( KTelPrefix ) == 0 ||
  3368 				  schemeText->FindC( KSmsPrefix ) == 0 ||
  3368                   schemeText->FindC( KSmsPrefix ) == 0 ||
  3369 				  schemeText->FindC( KMmsPrefix ) == 0 ||
  3369                   schemeText->FindC( KMmsPrefix ) == 0 ||
  3370 				  schemeText->FindC( KVoipPrefix ) == 0 )
  3370                   schemeText->FindC( KVoipPrefix ) == 0 )
  3371 			{
  3371             {
  3372 			CallToBodyHotSpotNumberL( currentBodyHotSpotData );
  3372             CallToBodyHotSpotNumberL( currentBodyHotSpotData );
  3373 			}
  3373             }
  3374 		CleanupStack::PopAndDestroy( schemeText );
  3374         CleanupStack::PopAndDestroy( schemeText );
  3375 		}
  3375         }
  3376 
  3376 
  3377 	}
  3377     }
  3378 
  3378 
  3379 // -----------------------------------------------------------------------------
  3379 // -----------------------------------------------------------------------------
  3380 // CFSEmailUiMailViewerVisualiser::CreateMessageL
  3380 // CFSEmailUiMailViewerVisualiser::CreateMessageL
  3381 // -----------------------------------------------------------------------------
  3381 // -----------------------------------------------------------------------------
  3382 void CFSEmailUiMailViewerVisualiser::CreateMessageL() const
  3382 void CFSEmailUiMailViewerVisualiser::CreateMessageL() const
  3383 	{
  3383     {
  3384     FUNC_LOG;
  3384     FUNC_LOG;
  3385 	SViewerHeadingHotSpotData currentHeaderHotSpotData;
  3385     SViewerHeadingHotSpotData currentHeaderHotSpotData;
  3386 	CFindItemEngine::SFoundItem currentBodyHotSpotData;
  3386     CFindItemEngine::SFoundItem currentBodyHotSpotData;
  3387 	THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL( currentHeaderHotSpotData, currentBodyHotSpotData );
  3387     THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL( currentHeaderHotSpotData, currentBodyHotSpotData );
  3388 
  3388 
  3389 	if( hotspotType == EHeaderHotspot )
  3389     if( hotspotType == EHeaderHotspot )
  3390 		{
  3390         {
  3391 		HBufC* emailAddress = iViewerRichText->GetHeaderHotspotEmailAddressLC( currentHeaderHotSpotData );
  3391         HBufC* emailAddress = iViewerRichText->GetHeaderHotspotEmailAddressLC( currentHeaderHotSpotData );
  3392 		CFSEmailUiContactHandler* cntHandlerInstance = CFsDelayedLoader::InstanceL()->GetContactHandlerL();
  3392         CFSEmailUiContactHandler* cntHandlerInstance = CFsDelayedLoader::InstanceL()->GetContactHandlerL();
  3393 		cntHandlerInstance->FindAndCreateMsgToContactByEmailL( *emailAddress, iAppUi.GetActiveMailbox() );
  3393         cntHandlerInstance->FindAndCreateMsgToContactByEmailL( *emailAddress, iAppUi.GetActiveMailbox() );
  3394 		CleanupStack::PopAndDestroy( emailAddress );
  3394         CleanupStack::PopAndDestroy( emailAddress );
  3395 		}
  3395         }
  3396 	else if( hotspotType == EBodyHotspot )
  3396     else if( hotspotType == EBodyHotspot )
  3397 		{
  3397         {
  3398 		// Sending based on email address, goes to contact handler
  3398         // Sending based on email address, goes to contact handler
  3399 		if ( currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchMailAddressBin )
  3399         if ( currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchMailAddressBin )
  3400 			{
  3400             {
  3401 			HBufC* emailAddress = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3401             HBufC* emailAddress = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3402 			CFSEmailUiContactHandler* cntHandlerInstance = CFsDelayedLoader::InstanceL()->GetContactHandlerL();
  3402             CFSEmailUiContactHandler* cntHandlerInstance = CFsDelayedLoader::InstanceL()->GetContactHandlerL();
  3403 			cntHandlerInstance->FindAndCreateMsgToContactByEmailL( *emailAddress, iAppUi.GetActiveMailbox() );
  3403             cntHandlerInstance->FindAndCreateMsgToContactByEmailL( *emailAddress, iAppUi.GetActiveMailbox() );
  3404 			CleanupStack::PopAndDestroy( emailAddress );
  3404             CleanupStack::PopAndDestroy( emailAddress );
  3405 			}
  3405             }
  3406 		// Sending based on found number, goes to utility class
  3406         // Sending based on found number, goes to utility class
  3407 		else if ( currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchPhoneNumberBin )
  3407         else if ( currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchPhoneNumberBin )
  3408 			{
  3408             {
  3409 			HBufC* hotspotText = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3409             HBufC* hotspotText = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3410 			TFsEmailUiUtility::ShowCreateMessageQueryL( *hotspotText );
  3410             TFsEmailUiUtility::ShowCreateMessageQueryL( *hotspotText );
  3411 			CleanupStack::PopAndDestroy( hotspotText );
  3411             CleanupStack::PopAndDestroy( hotspotText );
  3412 			}
  3412             }
  3413 		else if ( currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchScheme )
  3413         else if ( currentBodyHotSpotData.iItemType == CFindItemEngine::EFindItemSearchScheme )
  3414 			{
  3414             {
  3415 			// Get scheme text and make sure there is "mailto:" text or "call:" text
  3415             // Get scheme text and make sure there is "mailto:" text or "call:" text
  3416 			HBufC* schemeText = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3416             HBufC* schemeText = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  3417 			if ( schemeText && ( schemeText->FindC( KMailtoPrefix ) == 0 ||
  3417             if ( schemeText && ( schemeText->FindC( KMailtoPrefix ) == 0 ||
  3418 				 schemeText->FindC( KVoipPrefix ) == 0) )
  3418                  schemeText->FindC( KVoipPrefix ) == 0) )
  3419 				{
  3419                 {
  3420 				schemeText->Des().Delete( 0, KMailtoPrefix().Length() );
  3420                 schemeText->Des().Delete( 0, KMailtoPrefix().Length() );
  3421 				CFSEmailUiContactHandler* cntHandlerInstance = CFsDelayedLoader::InstanceL()->GetContactHandlerL();
  3421                 CFSEmailUiContactHandler* cntHandlerInstance = CFsDelayedLoader::InstanceL()->GetContactHandlerL();
  3422 				cntHandlerInstance->FindAndCreateMsgToContactByEmailL( *schemeText, iAppUi.GetActiveMailbox() );
  3422                 cntHandlerInstance->FindAndCreateMsgToContactByEmailL( *schemeText, iAppUi.GetActiveMailbox() );
  3423 				}
  3423                 }
  3424 			else if ( schemeText && schemeText->FindC( KCallPrefix ) == 0 )
  3424             else if ( schemeText && schemeText->FindC( KCallPrefix ) == 0 )
  3425 				{
  3425                 {
  3426 				schemeText->Des().Delete( 0, KCallPrefix().Length() );
  3426                 schemeText->Des().Delete( 0, KCallPrefix().Length() );
  3427 				TFsEmailUiUtility::ShowCreateMessageQueryL( *schemeText );
  3427                 TFsEmailUiUtility::ShowCreateMessageQueryL( *schemeText );
  3428 				}
  3428                 }
  3429 			else if ( schemeText && schemeText->FindC( KTelPrefix ) == 0 )
  3429             else if ( schemeText && schemeText->FindC( KTelPrefix ) == 0 )
  3430 				{
  3430                 {
  3431 				schemeText->Des().Delete( 0, KTelPrefix().Length() );
  3431                 schemeText->Des().Delete( 0, KTelPrefix().Length() );
  3432 				TFsEmailUiUtility::ShowCreateMessageQueryL( *schemeText );
  3432                 TFsEmailUiUtility::ShowCreateMessageQueryL( *schemeText );
  3433 				}
  3433                 }
  3434 			else if ( schemeText && schemeText->FindC( KSmsPrefix ) == 0 )
  3434             else if ( schemeText && schemeText->FindC( KSmsPrefix ) == 0 )
  3435 				{
  3435                 {
  3436 				schemeText->Des().Delete( 0, KSmsPrefix().Length() );
  3436                 schemeText->Des().Delete( 0, KSmsPrefix().Length() );
  3437 				TFsEmailUiUtility::ShowCreateMessageQueryL( *schemeText );
  3437                 TFsEmailUiUtility::ShowCreateMessageQueryL( *schemeText );
  3438 				}
  3438                 }
  3439 			else if ( schemeText && schemeText->FindC( KMmsPrefix ) == 0 )
  3439             else if ( schemeText && schemeText->FindC( KMmsPrefix ) == 0 )
  3440 				{
  3440                 {
  3441 				schemeText->Des().Delete( 0, KMmsPrefix().Length() );
  3441                 schemeText->Des().Delete( 0, KMmsPrefix().Length() );
  3442 				TFsEmailUiUtility::ShowCreateMessageQueryL( *schemeText );
  3442                 TFsEmailUiUtility::ShowCreateMessageQueryL( *schemeText );
  3443 				}
  3443                 }
  3444 			CleanupStack::PopAndDestroy( schemeText );
  3444             CleanupStack::PopAndDestroy( schemeText );
  3445 			}
  3445             }
  3446 		}
  3446         }
  3447 	}
  3447     }
  3448 
  3448 
  3449 TBool CFSEmailUiMailViewerVisualiser::IsCopyToClipBoardAvailableL() const
  3449 TBool CFSEmailUiMailViewerVisualiser::IsCopyToClipBoardAvailableL() const
  3450     {
  3450     {
  3451     FUNC_LOG;
  3451     FUNC_LOG;
  3452     TBool available = EFalse;
  3452     TBool available = EFalse;
  3496 
  3496 
  3497 // -----------------------------------------------------------------------------
  3497 // -----------------------------------------------------------------------------
  3498 // CFSEmailUiMailViewerVisualiser::CopyCurrentHotspotToClipBoardL
  3498 // CFSEmailUiMailViewerVisualiser::CopyCurrentHotspotToClipBoardL
  3499 // -----------------------------------------------------------------------------
  3499 // -----------------------------------------------------------------------------
  3500 void CFSEmailUiMailViewerVisualiser::CopyCurrentHotspotToClipBoardL() const
  3500 void CFSEmailUiMailViewerVisualiser::CopyCurrentHotspotToClipBoardL() const
  3501 	{
  3501     {
  3502     FUNC_LOG;
  3502     FUNC_LOG;
  3503     TInt ignoreThis( 0 );
  3503     TInt ignoreThis( 0 );
  3504     TBool visibleHotsSpot =
  3504     TBool visibleHotsSpot =
  3505         iTextViewer->GetVisibleFocusedHotspotLine( ignoreThis );
  3505         iTextViewer->GetVisibleFocusedHotspotLine( ignoreThis );
  3506 
  3506 
  3549             cb->CommitL();
  3549             cb->CommitL();
  3550             CleanupStack::PopAndDestroy( cb );
  3550             CleanupStack::PopAndDestroy( cb );
  3551             CleanupStack::PopAndDestroy( clipBoardText );
  3551             CleanupStack::PopAndDestroy( clipBoardText );
  3552             }
  3552             }
  3553         }
  3553         }
  3554 	}
  3554     }
  3555 
  3555 
  3556 // -----------------------------------------------------------------------------
  3556 // -----------------------------------------------------------------------------
  3557 // CFSEmailUiMailViewerVisualiser::ShowOpenAttachmentOptionL
  3557 // CFSEmailUiMailViewerVisualiser::ShowOpenAttachmentOptionL
  3558 // -----------------------------------------------------------------------------
  3558 // -----------------------------------------------------------------------------
  3559 TBool CFSEmailUiMailViewerVisualiser::ShowOpenAttachmentOptionL()
  3559 TBool CFSEmailUiMailViewerVisualiser::ShowOpenAttachmentOptionL()
  3560     {
  3560     {
  3561     FUNC_LOG;
  3561     FUNC_LOG;
  3562     TInt ret = EFalse;
  3562     TInt ret = EFalse;
  3563 
  3563 
  3564 	RPointerArray<CFSMailMessagePart> attachments;
  3564     RPointerArray<CFSMailMessagePart> attachments;
  3565 	CleanupResetAndDestroyClosePushL( attachments );
  3565     CleanupResetAndDestroyClosePushL( attachments );
  3566 	iMessage->AttachmentListL( attachments );
  3566     iMessage->AttachmentListL( attachments );
  3567 
  3567 
  3568     // The Open option is always available when focus on the multiple
  3568     // The Open option is always available when focus on the multiple
  3569     // attachments item.
  3569     // attachments item.
  3570     if ( attachments.Count() > 1 )
  3570     if ( attachments.Count() > 1 )
  3571         {
  3571         {
  3628 
  3628 
  3629 // -----------------------------------------------------------------------------
  3629 // -----------------------------------------------------------------------------
  3630 // CFSEmailUiMailViewerVisualiser::ShowDownloadOptionL
  3630 // CFSEmailUiMailViewerVisualiser::ShowDownloadOptionL
  3631 // -----------------------------------------------------------------------------
  3631 // -----------------------------------------------------------------------------
  3632 TBool CFSEmailUiMailViewerVisualiser::ShowDownloadOptionL()
  3632 TBool CFSEmailUiMailViewerVisualiser::ShowDownloadOptionL()
  3633 	{
  3633     {
  3634     FUNC_LOG;
  3634     FUNC_LOG;
  3635 	TBool retVal = EFalse;
  3635     TBool retVal = EFalse;
  3636 
  3636 
  3637 	TPartData partData = MailData();
  3637     TPartData partData = MailData();
  3638 
  3638 
  3639 	RPointerArray<CFSMailMessagePart> attachments;
  3639     RPointerArray<CFSMailMessagePart> attachments;
  3640 	CleanupResetAndDestroyClosePushL( attachments );
  3640     CleanupResetAndDestroyClosePushL( attachments );
  3641 	iMessage->AttachmentListL( attachments );
  3641     iMessage->AttachmentListL( attachments );
  3642 	TInt attachmentsCount = attachments.Count();
  3642     TInt attachmentsCount = attachments.Count();
  3643 	for ( TInt i = 0; i < attachmentsCount; i++ )
  3643     for ( TInt i = 0; i < attachmentsCount; i++ )
  3644 		{
  3644         {
  3645 		partData.iMessagePartId = attachments[i]->GetPartId();
  3645         partData.iMessagePartId = attachments[i]->GetPartId();
  3646 		if ( iAppUi.DownloadInfoMediator() && iAppUi.DownloadInfoMediator()->IsDownloadableL( partData ) )
  3646         if ( iAppUi.DownloadInfoMediator() && iAppUi.DownloadInfoMediator()->IsDownloadableL( partData ) )
  3647 			{
  3647             {
  3648 	    	retVal = ETrue;
  3648             retVal = ETrue;
  3649 	    	break;
  3649             break;
  3650 			}
  3650             }
  3651 		}
  3651         }
  3652 	CleanupStack::PopAndDestroy( &attachments );
  3652     CleanupStack::PopAndDestroy( &attachments );
  3653 	return retVal;
  3653     return retVal;
  3654 	}
  3654     }
  3655 
  3655 
  3656 
  3656 
  3657 // -----------------------------------------------------------------------------
  3657 // -----------------------------------------------------------------------------
  3658 // CFSEmailUiMailViewerVisualiser::ShowDownloadOptionL
  3658 // CFSEmailUiMailViewerVisualiser::ShowDownloadOptionL
  3659 // -----------------------------------------------------------------------------
  3659 // -----------------------------------------------------------------------------
  3685 
  3685 
  3686 // -----------------------------------------------------------------------------
  3686 // -----------------------------------------------------------------------------
  3687 // CFSEmailUiMailViewerVisualiser::ShowCancelDownloadOption
  3687 // CFSEmailUiMailViewerVisualiser::ShowCancelDownloadOption
  3688 // -----------------------------------------------------------------------------
  3688 // -----------------------------------------------------------------------------
  3689 TBool CFSEmailUiMailViewerVisualiser::ShowCancelDownloadOption()
  3689 TBool CFSEmailUiMailViewerVisualiser::ShowCancelDownloadOption()
  3690 	{
  3690     {
  3691     FUNC_LOG;
  3691     FUNC_LOG;
  3692 	TBool ret( EFalse );
  3692     TBool ret( EFalse );
  3693 	if ( iMessage && iAppUi.DownloadInfoMediator() )
  3693     if ( iMessage && iAppUi.DownloadInfoMediator() )
  3694 		{
  3694         {
  3695 		ret = iAppUi.DownloadInfoMediator()->IsAnyAttachmentDownloads(
  3695         ret = iAppUi.DownloadInfoMediator()->IsAnyAttachmentDownloads(
  3696 		        iMessage->GetMessageId() );
  3696                 iMessage->GetMessageId() );
  3697 		}
  3697         }
  3698 	return ret;
  3698     return ret;
  3699 	}
  3699     }
  3700 
  3700 
  3701 // -----------------------------------------------------------------------------
  3701 // -----------------------------------------------------------------------------
  3702 // CFSEmailUiMailViewerVisualiser::OpenAttachmentL
  3702 // CFSEmailUiMailViewerVisualiser::OpenAttachmentL
  3703 // -----------------------------------------------------------------------------
  3703 // -----------------------------------------------------------------------------
  3704 void CFSEmailUiMailViewerVisualiser::OpenAttachmentL()
  3704 void CFSEmailUiMailViewerVisualiser::OpenAttachmentL()
  3705 	{
  3705     {
  3706     FUNC_LOG;
  3706     FUNC_LOG;
  3707 	if ( !iMessage )
  3707     if ( !iMessage )
  3708 	    {
  3708         {
  3709 	    User::Leave( KErrNotReady );
  3709         User::Leave( KErrNotReady );
  3710 	    }
  3710         }
  3711 
  3711 
  3712 	RPointerArray<CFSMailMessagePart> attachments;
  3712     RPointerArray<CFSMailMessagePart> attachments;
  3713 	CleanupResetAndDestroyClosePushL( attachments );
  3713     CleanupResetAndDestroyClosePushL( attachments );
  3714 	iMessage->AttachmentListL( attachments );
  3714     iMessage->AttachmentListL( attachments );
  3715 
  3715 
  3716 	// start downloading if not yet downloaded.
  3716     // start downloading if not yet downloaded.
  3717 	if ( ShowDownloadOptionL() )
  3717     if ( ShowDownloadOptionL() )
  3718 		{
  3718         {
  3719 		StartDowloadingAttachmentsL();
  3719         StartDowloadingAttachmentsL();
  3720 		}
  3720         }
  3721 	else if ( ShowCancelDownloadOption() ) // show download ongoing info
  3721     else if ( ShowCancelDownloadOption() ) // show download ongoing info
  3722 		{
  3722         {
  3723 		TFsEmailUiUtility::ShowInfoNoteL(
  3723         TFsEmailUiUtility::ShowInfoNoteL(
  3724 			R_FSE_VIEWER_NOTE_ATTACHMENT_DOWNLOADING_PROGRESS );
  3724             R_FSE_VIEWER_NOTE_ATTACHMENT_DOWNLOADING_PROGRESS );
  3725 		}
  3725         }
  3726 	else // open if attachment is already downloaded
  3726     else // open if attachment is already downloaded
  3727 		{
  3727         {
  3728 		TInt attachmentsCount = attachments.Count();
  3728         TInt attachmentsCount = attachments.Count();
  3729 		if ( attachmentsCount )
  3729         if ( attachmentsCount )
  3730 			{
  3730             {
  3731 			// <cmail>
  3731             // <cmail>
  3732 			TFsEmailUiUtility::OpenAttachmentL( *attachments[attachmentsCount-1] );
  3732             TFsEmailUiUtility::OpenAttachmentL( *attachments[attachmentsCount-1] );
  3733 			// </cmail>
  3733             // </cmail>
  3734 			}
  3734             }
  3735 		}
  3735         }
  3736 
  3736 
  3737 	CleanupStack::PopAndDestroy( &attachments );
  3737     CleanupStack::PopAndDestroy( &attachments );
  3738 	}
  3738     }
  3739 
  3739 
  3740 // -----------------------------------------------------------------------------
  3740 // -----------------------------------------------------------------------------
  3741 // CFSEmailUiMailViewerVisualiser::OpenAttachmentsViewL
  3741 // CFSEmailUiMailViewerVisualiser::OpenAttachmentsViewL
  3742 // -----------------------------------------------------------------------------
  3742 // -----------------------------------------------------------------------------
  3743 void CFSEmailUiMailViewerVisualiser::OpenAttachmentsViewL()
  3743 void CFSEmailUiMailViewerVisualiser::OpenAttachmentsViewL()
  3744 	{
  3744     {
  3745     FUNC_LOG;
  3745     FUNC_LOG;
  3746 	// give pointer to current for attachments list view
  3746     // give pointer to current for attachments list view
  3747 	TAttachmentListActivationData params;
  3747     TAttachmentListActivationData params;
  3748 	params.iMailBoxId = iMessage->GetMailBoxId();
  3748     params.iMailBoxId = iMessage->GetMailBoxId();
  3749 	params.iFolderId = iMessage->GetFolderId();
  3749     params.iFolderId = iMessage->GetFolderId();
  3750 	params.iMessageId = iMessage->GetMessageId();
  3750     params.iMessageId = iMessage->GetMessageId();
  3751 	params.iEmbeddedMsgMode = iEmbeddedMessageMode;
  3751     params.iEmbeddedMsgMode = iEmbeddedMessageMode;
  3752 	// use package buffer to pass the params
  3752     // use package buffer to pass the params
  3753 	TPckgBuf<TAttachmentListActivationData> buf( params );
  3753     TPckgBuf<TAttachmentListActivationData> buf( params );
  3754 	TUid emptyCustomMessageId = { 0 };
  3754     TUid emptyCustomMessageId = { 0 };
  3755 	iAppUi.EnterFsEmailViewL(
  3755     iAppUi.EnterFsEmailViewL(
  3756 		AttachmentMngrViewId, emptyCustomMessageId, buf );
  3756         AttachmentMngrViewId, emptyCustomMessageId, buf );
  3757 	}
  3757     }
  3758 
  3758 
  3759 // -----------------------------------------------------------------------------
  3759 // -----------------------------------------------------------------------------
  3760 // CFSEmailUiMailViewerVisualiser::StartDowloadingAttachmentsL
  3760 // CFSEmailUiMailViewerVisualiser::StartDowloadingAttachmentsL
  3761 // -----------------------------------------------------------------------------
  3761 // -----------------------------------------------------------------------------
  3762 void CFSEmailUiMailViewerVisualiser::StartDowloadingAttachmentsL()
  3762 void CFSEmailUiMailViewerVisualiser::StartDowloadingAttachmentsL()
  3763 	{
  3763     {
  3764     FUNC_LOG;
  3764     FUNC_LOG;
  3765 	TPartData partData = MailData();
  3765     TPartData partData = MailData();
  3766 
  3766 
  3767 	RPointerArray<CFSMailMessagePart> attachments;
  3767     RPointerArray<CFSMailMessagePart> attachments;
  3768 	CleanupResetAndDestroyClosePushL( attachments );
  3768     CleanupResetAndDestroyClosePushL( attachments );
  3769 	iMessage->AttachmentListL( attachments );
  3769     iMessage->AttachmentListL( attachments );
  3770 	TInt attachmentsCount = attachments.Count();
  3770     TInt attachmentsCount = attachments.Count();
  3771 	for( TInt i = 0; i < attachmentsCount; i++)
  3771     for( TInt i = 0; i < attachmentsCount; i++)
  3772 		{
  3772         {
  3773 		if ( attachments[i]->FetchLoadState() == EFSNone ||
  3773         if ( attachments[i]->FetchLoadState() == EFSNone ||
  3774 	    	 attachments[i]->FetchLoadState() == EFSPartial )
  3774              attachments[i]->FetchLoadState() == EFSPartial )
  3775 			{
  3775             {
  3776 			partData.iMessagePartId = attachments[i]->GetPartId();
  3776             partData.iMessagePartId = attachments[i]->GetPartId();
  3777 			if ( iAppUi.DownloadInfoMediator() )
  3777             if ( iAppUi.DownloadInfoMediator() )
  3778 				{
  3778                 {
  3779 				iAppUi.DownloadInfoMediator()->DownloadL( partData );
  3779                 iAppUi.DownloadInfoMediator()->DownloadL( partData );
  3780 				}
  3780                 }
  3781 			}
  3781             }
  3782 		}
  3782         }
  3783 	CleanupStack::PopAndDestroy( &attachments );
  3783     CleanupStack::PopAndDestroy( &attachments );
  3784 	}
  3784     }
  3785 
  3785 
  3786 // -----------------------------------------------------------------------------
  3786 // -----------------------------------------------------------------------------
  3787 // CFSEmailUiMailViewerVisualiser::CancelDowloadingAttachmentsL
  3787 // CFSEmailUiMailViewerVisualiser::CancelDowloadingAttachmentsL
  3788 // -----------------------------------------------------------------------------
  3788 // -----------------------------------------------------------------------------
  3789 void CFSEmailUiMailViewerVisualiser::CancelDowloadingAttachmentsL()
  3789 void CFSEmailUiMailViewerVisualiser::CancelDowloadingAttachmentsL()
  3790 	{
  3790     {
  3791     FUNC_LOG;
  3791     FUNC_LOG;
  3792 	RPointerArray<CFSMailMessagePart> attachments;
  3792     RPointerArray<CFSMailMessagePart> attachments;
  3793 	CleanupResetAndDestroyClosePushL( attachments );
  3793     CleanupResetAndDestroyClosePushL( attachments );
  3794 	iMessage->AttachmentListL( attachments );
  3794     iMessage->AttachmentListL( attachments );
  3795 	TInt attachmentsCount = attachments.Count();
  3795     TInt attachmentsCount = attachments.Count();
  3796 
  3796 
  3797 	// ask confirmation for cancel
  3797     // ask confirmation for cancel
  3798 	TInt promptTextId = R_FSE_VIEWER_CANCEL_DOWNLOAD_QUERY;
  3798     TInt promptTextId = R_FSE_VIEWER_CANCEL_DOWNLOAD_QUERY;
  3799 	if ( attachmentsCount > 1 )
  3799     if ( attachmentsCount > 1 )
  3800 		{
  3800         {
  3801 		promptTextId = R_FSE_VIEWER_CANCEL_DOWNLOADS_QUERY;
  3801         promptTextId = R_FSE_VIEWER_CANCEL_DOWNLOADS_QUERY;
  3802 		}
  3802         }
  3803 
  3803 
  3804 	if ( TFsEmailUiUtility::ShowConfirmationQueryL(promptTextId) && iAppUi.DownloadInfoMediator() )
  3804     if ( TFsEmailUiUtility::ShowConfirmationQueryL(promptTextId) && iAppUi.DownloadInfoMediator() )
  3805 		{
  3805         {
  3806 		for ( TInt i = 0 ; i < attachmentsCount ; i++ )
  3806         for ( TInt i = 0 ; i < attachmentsCount ; i++ )
  3807 			{
  3807             {
  3808 			TFSPartFetchState fetchState = attachments[i]->FetchLoadState();
  3808             TFSPartFetchState fetchState = attachments[i]->FetchLoadState();
  3809 			if ( fetchState == EFSPartial || fetchState == EFSNone )
  3809             if ( fetchState == EFSPartial || fetchState == EFSNone )
  3810 				{
  3810                 {
  3811 		    	iAppUi.DownloadInfoMediator()->CancelDownloadL( attachments[i]->GetPartId() );
  3811                 iAppUi.DownloadInfoMediator()->CancelDownloadL( attachments[i]->GetPartId() );
  3812 				}
  3812                 }
  3813 			}
  3813             }
  3814 		}
  3814         }
  3815 	CleanupStack::PopAndDestroy( &attachments );
  3815     CleanupStack::PopAndDestroy( &attachments );
  3816 	}
  3816     }
  3817 
  3817 
  3818 // -----------------------------------------------------------------------------
  3818 // -----------------------------------------------------------------------------
  3819 // CFSEmailUiMailViewerVisualiser::SaveAllAttachmentsL
  3819 // CFSEmailUiMailViewerVisualiser::SaveAllAttachmentsL
  3820 // -----------------------------------------------------------------------------
  3820 // -----------------------------------------------------------------------------
  3821 void CFSEmailUiMailViewerVisualiser::SaveAllAttachmentsL()
  3821 void CFSEmailUiMailViewerVisualiser::SaveAllAttachmentsL()
  3822 	{
  3822     {
  3823     FUNC_LOG;
  3823     FUNC_LOG;
  3824 	TFileName fileName;
  3824     TFileName fileName;
  3825   	if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) )
  3825     if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) )
  3826 		{
  3826         {
  3827 		// start downloading attachemts which are not downloaded.
  3827         // start downloading attachemts which are not downloaded.
  3828 		// Save all attachment which all already downloaded
  3828         // Save all attachment which all already downloaded
  3829 		TPartData partData = MailData();
  3829         TPartData partData = MailData();
  3830 
  3830 
  3831 		RPointerArray<CFSMailMessagePart> attachments;
  3831         RPointerArray<CFSMailMessagePart> attachments;
  3832 		CleanupResetAndDestroyClosePushL( attachments );
  3832         CleanupResetAndDestroyClosePushL( attachments );
  3833 		iMessage->AttachmentListL( attachments );
  3833         iMessage->AttachmentListL( attachments );
  3834 		TInt attachmentsCount = attachments.Count();
  3834         TInt attachmentsCount = attachments.Count();
  3835 
  3835 
  3836         // <cmail> remove the MRUI part of the message so we
  3836         // <cmail> remove the MRUI part of the message so we
  3837 	    // don't save unnecessary .ics file
  3837         // don't save unnecessary .ics file
  3838         CFSMailMessagePart* calendarPart = iMessage->FindBodyPartL( KFSMailContentTypeTextCalendar );
  3838         CFSMailMessagePart* calendarPart = iMessage->FindBodyPartL( KFSMailContentTypeTextCalendar );
  3839         CleanupStack::PushL( calendarPart );
  3839         CleanupStack::PushL( calendarPart );
  3840         // </cmail>
  3840         // </cmail>
  3841 
  3841 
  3842 		TInt savedCount( 0 );
  3842         TInt savedCount( 0 );
  3843 		for ( TInt i = 0; i < attachmentsCount; i++ )
  3843         for ( TInt i = 0; i < attachmentsCount; i++ )
  3844 			{
  3844             {
  3845 			partData.iMessagePartId = attachments[i]->GetPartId();
  3845             partData.iMessagePartId = attachments[i]->GetPartId();
  3846 			if ( iAppUi.DownloadInfoMediator() && iAppUi.DownloadInfoMediator()->IsDownloadableL( partData ) )
  3846             if ( iAppUi.DownloadInfoMediator() && iAppUi.DownloadInfoMediator()->IsDownloadableL( partData ) )
  3847 				{ // start download and let mediator do the saving
  3847                 { // start download and let mediator do the saving
  3848 				iAppUi.DownloadInfoMediator()->DownloadAndSaveL( partData, fileName );
  3848                 iAppUi.DownloadInfoMediator()->DownloadAndSaveL( partData, fileName );
  3849 				}
  3849                 }
  3850 			else // save immediately.
  3850             else // save immediately.
  3851 				{
  3851                 {
  3852 				// <cmail>
  3852                 // <cmail>
  3853                 if( (calendarPart && partData.iMessagePartId != calendarPart->GetPartId() ||
  3853                 if( (calendarPart && partData.iMessagePartId != calendarPart->GetPartId() ||
  3854                     !calendarPart) && TFsEmailUiUtility::OkToSaveFileL( fileName, *attachments[i] ) )
  3854                     !calendarPart) && TFsEmailUiUtility::OkToSaveFileL( fileName, *attachments[i] ) )
  3855                     {
  3855                     {
  3856 		    		attachments[i]->CopyContentFileL( fileName );
  3856                     attachments[i]->CopyContentFileL( fileName );
  3857 		    		savedCount++;
  3857                     savedCount++;
  3858                     }
  3858                     }
  3859 				// </cmail>
  3859                 // </cmail>
  3860 				}
  3860                 }
  3861 			}
  3861             }
  3862         if ( savedCount )
  3862         if ( savedCount )
  3863             {
  3863             {
  3864             TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( savedCount );
  3864             TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( savedCount );
  3865             }
  3865             }
  3866         // <cmail>
  3866         // <cmail>
  3867         CleanupStack::PopAndDestroy( calendarPart );
  3867         CleanupStack::PopAndDestroy( calendarPart );
  3868         // </cmail>
  3868         // </cmail>
  3869 		CleanupStack::PopAndDestroy( &attachments );
  3869         CleanupStack::PopAndDestroy( &attachments );
  3870 		}
  3870         }
  3871 	}
  3871     }
  3872 
  3872 
  3873 // -----------------------------------------------------------------------------
  3873 // -----------------------------------------------------------------------------
  3874 // CFSEmailUiMailViewerVisualiser::RemoveFetchedAttachmentL
  3874 // CFSEmailUiMailViewerVisualiser::RemoveFetchedAttachmentL
  3875 // -----------------------------------------------------------------------------
  3875 // -----------------------------------------------------------------------------
  3876 void CFSEmailUiMailViewerVisualiser::RemoveFetchedAttachmentL()
  3876 void CFSEmailUiMailViewerVisualiser::RemoveFetchedAttachmentL()
  3896 
  3896 
  3897 // -----------------------------------------------------------------------------
  3897 // -----------------------------------------------------------------------------
  3898 // CFSEmailUiMailViewerVisualiser::MailData
  3898 // CFSEmailUiMailViewerVisualiser::MailData
  3899 // -----------------------------------------------------------------------------
  3899 // -----------------------------------------------------------------------------
  3900 TPartData CFSEmailUiMailViewerVisualiser::MailData()
  3900 TPartData CFSEmailUiMailViewerVisualiser::MailData()
  3901 	{
  3901     {
  3902     FUNC_LOG;
  3902     FUNC_LOG;
  3903 	TPartData newPartData;
  3903     TPartData newPartData;
  3904 	newPartData.iMailBoxId = iMessage->GetMailBoxId();
  3904     newPartData.iMailBoxId = iMessage->GetMailBoxId();
  3905 	newPartData.iFolderId = iMessage->GetFolderId();
  3905     newPartData.iFolderId = iMessage->GetFolderId();
  3906 	newPartData.iMessageId = iMessage->GetMessageId();
  3906     newPartData.iMessageId = iMessage->GetMessageId();
  3907 	return newPartData;
  3907     return newPartData;
  3908 	}
  3908     }
  3909 
  3909 
  3910 // -----------------------------------------------------------------------------
  3910 // -----------------------------------------------------------------------------
  3911 // CFSEmailUiMailViewerVisualiser::StartFetchingBodyAfterOpeningL
  3911 // CFSEmailUiMailViewerVisualiser::StartFetchingBodyAfterOpeningL
  3912 // -----------------------------------------------------------------------------
  3912 // -----------------------------------------------------------------------------
  3913 TBool CFSEmailUiMailViewerVisualiser::StartFetchingBodyAfterOpeningL() const
  3913 TBool CFSEmailUiMailViewerVisualiser::StartFetchingBodyAfterOpeningL() const
  3914 	{
  3914     {
  3915     FUNC_LOG;
  3915     FUNC_LOG;
  3916 	TBool retVal = EFalse;
  3916     TBool retVal = EFalse;
  3917 	CFSMailMessagePart* textPart = iMessage->PlainTextBodyPartL();
  3917     CFSMailMessagePart* textPart = iMessage->PlainTextBodyPartL();
  3918 	if ( textPart )
  3918     if ( textPart )
  3919 		{
  3919         {
  3920 		TFSPartFetchState currentPlainTextFetchState = textPart->FetchLoadState();
  3920         TFSPartFetchState currentPlainTextFetchState = textPart->FetchLoadState();
  3921 		if ( currentPlainTextFetchState == EFSNone )
  3921         if ( currentPlainTextFetchState == EFSNone )
  3922 			{
  3922             {
  3923 			retVal = ETrue;
  3923             retVal = ETrue;
  3924 			}
  3924             }
  3925 		}
  3925         }
  3926 	delete textPart;
  3926     delete textPart;
  3927 	return retVal;
  3927     return retVal;
  3928 	}
  3928     }
  3929 
  3929 
  3930 // -----------------------------------------------------------------------------
  3930 // -----------------------------------------------------------------------------
  3931 // CFSEmailUiMailViewerVisualiser::MessagePartFullyFetchedL
  3931 // CFSEmailUiMailViewerVisualiser::MessagePartFullyFetchedL
  3932 // -----------------------------------------------------------------------------
  3932 // -----------------------------------------------------------------------------
  3933 TBool CFSEmailUiMailViewerVisualiser::MessagePartFullyFetchedL( TFetchedContentType aFetchedContentType ) const
  3933 TBool CFSEmailUiMailViewerVisualiser::MessagePartFullyFetchedL( TFetchedContentType aFetchedContentType ) const
  3934 	{
  3934     {
  3935     FUNC_LOG;
  3935     FUNC_LOG;
  3936 	TBool retVal = ETrue;
  3936     TBool retVal = ETrue;
  3937 	if( aFetchedContentType == EMessagePlainTextBodyPart )
  3937     if( aFetchedContentType == EMessagePlainTextBodyPart )
  3938 		{
  3938         {
  3939 		CFSMailMessagePart* textPart = iMessage->PlainTextBodyPartL();
  3939         CFSMailMessagePart* textPart = iMessage->PlainTextBodyPartL();
  3940 		if( textPart )
  3940         if( textPart )
  3941 			{
  3941             {
  3942 			TFSPartFetchState currentPlainTextFetchState = textPart->FetchLoadState();
  3942             TFSPartFetchState currentPlainTextFetchState = textPart->FetchLoadState();
  3943 			if( currentPlainTextFetchState != EFSFull )
  3943             if( currentPlainTextFetchState != EFSFull )
  3944 				{
  3944                 {
  3945 				retVal = EFalse;
  3945                 retVal = EFalse;
  3946 				}
  3946                 }
  3947 			}
  3947             }
  3948 		delete textPart;
  3948         delete textPart;
  3949 		}
  3949         }
  3950 	else if( aFetchedContentType == EMessageHtmlBodyPart )
  3950     else if( aFetchedContentType == EMessageHtmlBodyPart )
  3951 		{
  3951         {
  3952 		CFSMailMessagePart* htmlPart = iMessage->HtmlBodyPartL();
  3952         CFSMailMessagePart* htmlPart = iMessage->HtmlBodyPartL();
  3953 		if( htmlPart )
  3953         if( htmlPart )
  3954 			{
  3954             {
  3955 			TFSPartFetchState currentHtmlTextFetchState = htmlPart->FetchLoadState();
  3955             TFSPartFetchState currentHtmlTextFetchState = htmlPart->FetchLoadState();
  3956 			if( currentHtmlTextFetchState != EFSFull )
  3956             if( currentHtmlTextFetchState != EFSFull )
  3957 				{
  3957                 {
  3958 				retVal = EFalse;
  3958                 retVal = EFalse;
  3959 				}
  3959                 }
  3960 			}
  3960             }
  3961 		delete htmlPart;
  3961         delete htmlPart;
  3962 		}
  3962         }
  3963 	else if( aFetchedContentType == EMessageStructure )
  3963     else if( aFetchedContentType == EMessageStructure )
  3964 		{
  3964         {
  3965 		retVal = MessageStructureKnown( *iMessage );
  3965         retVal = MessageStructureKnown( *iMessage );
  3966 		}
  3966         }
  3967 	else
  3967     else
  3968 		{
  3968         {
  3969 		User::Leave( KErrNotSupported );
  3969         User::Leave( KErrNotSupported );
  3970 		}
  3970         }
  3971 	return retVal;
  3971     return retVal;
  3972 	}
  3972     }
  3973 
  3973 
  3974 // -----------------------------------------------------------------------------
  3974 // -----------------------------------------------------------------------------
  3975 // CFSEmailUiMailViewerVisualiser::StartFetchingMessagePartL
  3975 // CFSEmailUiMailViewerVisualiser::StartFetchingMessagePartL
  3976 // -----------------------------------------------------------------------------
  3976 // -----------------------------------------------------------------------------
  3977 void CFSEmailUiMailViewerVisualiser::StartFetchingMessagePartL( CFSMailMessage& aMessagePtr,
  3977 void CFSEmailUiMailViewerVisualiser::StartFetchingMessagePartL( CFSMailMessage& aMessagePtr,
  3978 											TFetchedContentType aFetchedContentType )
  3978                                             TFetchedContentType aFetchedContentType )
  3979 	{
  3979     {
  3980     FUNC_LOG;
  3980     FUNC_LOG;
  3981 	if( aFetchedContentType == EMessagePlainTextBodyPart )
  3981     if( aFetchedContentType == EMessagePlainTextBodyPart )
  3982 		{
  3982         {
  3983 		CFSMailMessagePart* textPart = aMessagePtr.PlainTextBodyPartL();
  3983         CFSMailMessagePart* textPart = aMessagePtr.PlainTextBodyPartL();
  3984 		CleanupStack::PushL( textPart );
  3984         CleanupStack::PushL( textPart );
  3985 		TFSMailMsgId textPartId = textPart->GetPartId();
  3985         TFSMailMsgId textPartId = textPart->GetPartId();
  3986 		iFetchingPlainTextMessageBody = ETrue;
  3986         iFetchingPlainTextMessageBody = ETrue;
  3987 		iCurrentPlainTextBodyFetchRequestId = textPart->FetchMessagePartL( textPartId, *this, 0 );
  3987         iCurrentPlainTextBodyFetchRequestId = textPart->FetchMessagePartL( textPartId, *this, 0 );
  3988 		CleanupStack::PopAndDestroy( textPart );
  3988         CleanupStack::PopAndDestroy( textPart );
  3989 		}
  3989         }
  3990 	else if( aFetchedContentType == EMessageHtmlBodyPart )
  3990     else if( aFetchedContentType == EMessageHtmlBodyPart )
  3991 		{
  3991         {
  3992 		CFSMailMessagePart* htmlPart = aMessagePtr.HtmlBodyPartL();
  3992         CFSMailMessagePart* htmlPart = aMessagePtr.HtmlBodyPartL();
  3993 		CleanupStack::PushL( htmlPart );
  3993         CleanupStack::PushL( htmlPart );
  3994 		TFSMailMsgId htmlPartId = htmlPart->GetPartId();
  3994         TFSMailMsgId htmlPartId = htmlPart->GetPartId();
  3995 		iFetchingHtmlMessageBody = ETrue;
  3995         iFetchingHtmlMessageBody = ETrue;
  3996 		iCurrentHtmlBodyFetchRequestId = htmlPart->FetchMessagePartL( htmlPartId, *this, 0 );
  3996         iCurrentHtmlBodyFetchRequestId = htmlPart->FetchMessagePartL( htmlPartId, *this, 0 );
  3997 		CleanupStack::PopAndDestroy( htmlPart );
  3997         CleanupStack::PopAndDestroy( htmlPart );
  3998 		}
  3998         }
  3999 	else if( aFetchedContentType == EMessageStructure )
  3999     else if( aFetchedContentType == EMessageStructure )
  4000 		{
  4000         {
  4001 		StartFetchingMessageStructureL( aMessagePtr );
  4001         StartFetchingMessageStructureL( aMessagePtr );
  4002 		}
  4002         }
  4003 	else
  4003     else
  4004 		{
  4004         {
  4005 		User::Leave( KErrNotSupported );
  4005         User::Leave( KErrNotSupported );
  4006 		}
  4006         }
  4007 	}
  4007     }
  4008 
  4008 
  4009 // -----------------------------------------------------------------------------
  4009 // -----------------------------------------------------------------------------
  4010 // CFSEmailUiMailViewerVisualiser::CancelFetchings
  4010 // CFSEmailUiMailViewerVisualiser::CancelFetchings
  4011 // -----------------------------------------------------------------------------
  4011 // -----------------------------------------------------------------------------
  4012 void CFSEmailUiMailViewerVisualiser::CancelFetchings()
  4012 void CFSEmailUiMailViewerVisualiser::CancelFetchings()
  4013 	{
  4013     {
  4014     FUNC_LOG;
  4014     FUNC_LOG;
  4015 	if( iFetchingPlainTextMessageBody )
  4015     if( iFetchingPlainTextMessageBody )
  4016 		{
  4016         {
  4017 		TRAP_IGNORE( iAppUi.GetMailClient()->CancelL( iCurrentPlainTextBodyFetchRequestId ) );
  4017         TRAP_IGNORE( iAppUi.GetMailClient()->CancelL( iCurrentPlainTextBodyFetchRequestId ) );
  4018 		iFetchingPlainTextMessageBody = EFalse;
  4018         iFetchingPlainTextMessageBody = EFalse;
  4019 		}
  4019         }
  4020 	if( iFetchingHtmlMessageBody )
  4020     if( iFetchingHtmlMessageBody )
  4021 		{
  4021         {
  4022 		TRAP_IGNORE( iAppUi.GetMailClient()->CancelL( iCurrentHtmlBodyFetchRequestId ) );
  4022         TRAP_IGNORE( iAppUi.GetMailClient()->CancelL( iCurrentHtmlBodyFetchRequestId ) );
  4023 		iFetchingHtmlMessageBody = EFalse;
  4023         iFetchingHtmlMessageBody = EFalse;
  4024 		}
  4024         }
  4025 	if( iFetchingMessageStructure )
  4025     if( iFetchingMessageStructure )
  4026 		{
  4026         {
  4027 		TRAP_IGNORE( iAppUi.GetMailClient()->CancelL( iCurrentStructureFetchRequestId ) );
  4027         TRAP_IGNORE( iAppUi.GetMailClient()->CancelL( iCurrentStructureFetchRequestId ) );
  4028 		iFetchingMessageStructure = EFalse;
  4028         iFetchingMessageStructure = EFalse;
  4029 		}
  4029         }
  4030 	iAsyncProcessComplete = ETrue;
  4030     iAsyncProcessComplete = ETrue;
  4031 	//<cmail>
  4031     //<cmail>
  4032     if(iWaitDialog && iDialogNotDismissed)
  4032     if(iWaitDialog && iDialogNotDismissed)
  4033 	    TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); // deletes the dialog
  4033         TRAP_IGNORE(iWaitDialog->ProcessFinishedL()); // deletes the dialog
  4034 	//</cmail>
  4034     //</cmail>
  4035 	}
  4035     }
  4036 
  4036 
  4037 // -----------------------------------------------------------------------------
  4037 // -----------------------------------------------------------------------------
  4038 // CFSEmailUiMailViewerVisualiser::MessageStructureKnownL
  4038 // CFSEmailUiMailViewerVisualiser::MessageStructureKnownL
  4039 // -----------------------------------------------------------------------------
  4039 // -----------------------------------------------------------------------------
  4040 TBool CFSEmailUiMailViewerVisualiser::MessageStructureKnown( CFSMailMessage& aMsg ) const
  4040 TBool CFSEmailUiMailViewerVisualiser::MessageStructureKnown( CFSMailMessage& aMsg ) const
  4041 	{
  4041     {
  4042     FUNC_LOG;
  4042     FUNC_LOG;
  4043 	return TFsEmailUiUtility::IsMessageStructureKnown( aMsg );
  4043     return TFsEmailUiUtility::IsMessageStructureKnown( aMsg );
  4044 	}
  4044     }
  4045 
  4045 
  4046 // -----------------------------------------------------------------------------
  4046 // -----------------------------------------------------------------------------
  4047 // CFSEmailUiMailViewerVisualiser::StartFetchingMessageStructureL
  4047 // CFSEmailUiMailViewerVisualiser::StartFetchingMessageStructureL
  4048 // -----------------------------------------------------------------------------
  4048 // -----------------------------------------------------------------------------
  4049 void CFSEmailUiMailViewerVisualiser::StartFetchingMessageStructureL( CFSMailMessage& aMsg )
  4049 void CFSEmailUiMailViewerVisualiser::StartFetchingMessageStructureL( CFSMailMessage& aMsg )
  4050 	{
  4050     {
  4051     FUNC_LOG;
  4051     FUNC_LOG;
  4052 	TFSMailMsgId currentMailboxId = aMsg.GetMailBoxId();
  4052     TFSMailMsgId currentMailboxId = aMsg.GetMailBoxId();
  4053 	TFSMailMsgId currentMessageFolderId = aMsg.GetFolderId();
  4053     TFSMailMsgId currentMessageFolderId = aMsg.GetFolderId();
  4054 	CFSMailFolder* currentFolder  = iAppUi.GetMailClient()->GetFolderByUidL( currentMailboxId, currentMessageFolderId );
  4054     CFSMailFolder* currentFolder  = iAppUi.GetMailClient()->GetFolderByUidL( currentMailboxId, currentMessageFolderId );
  4055 	CleanupStack::PushL( currentFolder );
  4055     CleanupStack::PushL( currentFolder );
  4056 	RArray<TFSMailMsgId> messageIds;
  4056     RArray<TFSMailMsgId> messageIds;
  4057 	CleanupClosePushL( messageIds );
  4057     CleanupClosePushL( messageIds );
  4058 	messageIds.Append( aMsg.GetMessageId() );
  4058     messageIds.Append( aMsg.GetMessageId() );
  4059 	iFetchingMessageStructure = ETrue;
  4059     iFetchingMessageStructure = ETrue;
  4060 	iCurrentStructureFetchRequestId = currentFolder->FetchMessagesL( messageIds, EFSMsgDataStructure, *this );
  4060     iCurrentStructureFetchRequestId = currentFolder->FetchMessagesL( messageIds, EFSMsgDataStructure, *this );
  4061 	CleanupStack::PopAndDestroy( &messageIds );
  4061     CleanupStack::PopAndDestroy( &messageIds );
  4062 	CleanupStack::PopAndDestroy( currentFolder );
  4062     CleanupStack::PopAndDestroy( currentFolder );
  4063 	}
  4063     }
  4064 
  4064 
  4065 // -----------------------------------------------------------------------------
  4065 // -----------------------------------------------------------------------------
  4066 // CFSEmailUiMailViewerVisualiser::StartWaitedFetchingL
  4066 // CFSEmailUiMailViewerVisualiser::StartWaitedFetchingL
  4067 // -----------------------------------------------------------------------------
  4067 // -----------------------------------------------------------------------------
  4068 void CFSEmailUiMailViewerVisualiser::StartWaitedFetchingL( TFetchedContentType aFetchedContentType )
  4068 void CFSEmailUiMailViewerVisualiser::StartWaitedFetchingL( TFetchedContentType aFetchedContentType )
  4069 	{
  4069     {
  4070     FUNC_LOG;
  4070     FUNC_LOG;
  4071     iAsyncProcessComplete = EFalse;
  4071     iAsyncProcessComplete = EFalse;
  4072     iFetchingAlready = EFalse;
  4072     iFetchingAlready = EFalse;
  4073     iStartAsyncFetchType = aFetchedContentType;
  4073     iStartAsyncFetchType = aFetchedContentType;
  4074     //<cmail> in cmail we are using different wait dialog, since this wrapper dialog gives
  4074     //<cmail> in cmail we are using different wait dialog, since this wrapper dialog gives
  4084     iWaitDialog = new(ELeave)CAknWaitDialog(
  4084     iWaitDialog = new(ELeave)CAknWaitDialog(
  4085                    (REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), ETrue);
  4085                    (REINTERPRET_CAST(CEikDialog**,&iWaitDialog)), ETrue);
  4086     iWaitDialog->SetCallback(this);
  4086     iWaitDialog->SetCallback(this);
  4087     iDialogNotDismissed = ETrue;
  4087     iDialogNotDismissed = ETrue;
  4088     iWaitDialog->ExecuteLD(R_FSE_FETCHING_WAIT_DIALOG);
  4088     iWaitDialog->ExecuteLD(R_FSE_FETCHING_WAIT_DIALOG);
  4089 		StartFetchingMessagePartL( *iMessage, iStartAsyncFetchType );
  4089         StartFetchingMessagePartL( *iMessage, iStartAsyncFetchType );
  4090  		iFetchingAlready = ETrue;
  4090         iFetchingAlready = ETrue;
  4091     //</cmail>
  4091     //</cmail>
  4092 	}
  4092     }
  4093 
  4093 
  4094 // -----------------------------------------------------------------------------
  4094 // -----------------------------------------------------------------------------
  4095 // CFSEmailUiMailViewerVisualiser::StartFetchingRemaininBodyLinesIfAtBottomL
  4095 // CFSEmailUiMailViewerVisualiser::StartFetchingRemaininBodyLinesIfAtBottomL
  4096 // -----------------------------------------------------------------------------
  4096 // -----------------------------------------------------------------------------
  4097 void CFSEmailUiMailViewerVisualiser::StartFetchingRemaininBodyLinesIfAtBottomL()
  4097 void CFSEmailUiMailViewerVisualiser::StartFetchingRemaininBodyLinesIfAtBottomL()
  4117 
  4117 
  4118 // -----------------------------------------------------------------------------
  4118 // -----------------------------------------------------------------------------
  4119 // CFSEmailUiMailViewerVisualiser::TimerEventL
  4119 // CFSEmailUiMailViewerVisualiser::TimerEventL
  4120 // -----------------------------------------------------------------------------
  4120 // -----------------------------------------------------------------------------
  4121 void CFSEmailUiMailViewerVisualiser::TimerEventL( CFSEmailUiGenericTimer* aTriggeredTimer )
  4121 void CFSEmailUiMailViewerVisualiser::TimerEventL( CFSEmailUiGenericTimer* aTriggeredTimer )
  4122 	{
  4122     {
  4123     FUNC_LOG;
  4123     FUNC_LOG;
  4124 	if ( aTriggeredTimer == iFetchingAnimationTimer )
  4124     if ( aTriggeredTimer == iFetchingAnimationTimer )
  4125 	    {
  4125         {
  4126     	iViewerRichText->AppendFetchingMoreTextL();
  4126         iViewerRichText->AppendFetchingMoreTextL();
  4127     	iFetchingAnimationTimer->Start( KAnimationRefreshTimeIntervalInMilliseconds );
  4127         iFetchingAnimationTimer->Start( KAnimationRefreshTimeIntervalInMilliseconds );
  4128 	    }
  4128         }
  4129 	}
  4129     }
  4130 
  4130 
  4131 // MAknBackgroundProcess methods
  4131 // MAknBackgroundProcess methods
  4132 //
  4132 //
  4133 // -----------------------------------------------------------------------------
  4133 // -----------------------------------------------------------------------------
  4134 // CFSEmailUiMailViewerVisualiser::StepL
  4134 // CFSEmailUiMailViewerVisualiser::StepL
  4135 // -----------------------------------------------------------------------------
  4135 // -----------------------------------------------------------------------------
  4136 //<cmail>
  4136 //<cmail>
  4137 /*
  4137 /*
  4138 void CFSEmailUiMailViewerVisualiser::StepL()
  4138 void CFSEmailUiMailViewerVisualiser::StepL()
  4139 	{
  4139     {
  4140     FUNC_LOG;
  4140     FUNC_LOG;
  4141 	if( !iFetchingAlready )
  4141     if( !iFetchingAlready )
  4142 		{
  4142         {
  4143 		StartFetchingMessagePartL( *iMessage, iStartAsyncFetchType );
  4143         StartFetchingMessagePartL( *iMessage, iStartAsyncFetchType );
  4144  		iFetchingAlready = ETrue;
  4144         iFetchingAlready = ETrue;
  4145  		}
  4145         }
  4146  	}*/
  4146     }*/
  4147 //</cmail>
  4147 //</cmail>
  4148 
  4148 
  4149 // -----------------------------------------------------------------------------
  4149 // -----------------------------------------------------------------------------
  4150 // CFSEmailUiMailViewerVisualiser::IsProcessDone
  4150 // CFSEmailUiMailViewerVisualiser::IsProcessDone
  4151 // -----------------------------------------------------------------------------
  4151 // -----------------------------------------------------------------------------
  4153 /*
  4153 /*
  4154 TBool CFSEmailUiMailViewerVisualiser::IsProcessDone() const
  4154 TBool CFSEmailUiMailViewerVisualiser::IsProcessDone() const
  4155     {
  4155     {
  4156     FUNC_LOG;
  4156     FUNC_LOG;
  4157     return iAsyncProcessComplete;
  4157     return iAsyncProcessComplete;
  4158 	}*/
  4158     }*/
  4159 //</cmail>
  4159 //</cmail>
  4160 
  4160 
  4161 // -----------------------------------------------------------------------------
  4161 // -----------------------------------------------------------------------------
  4162 // CFSEmailUiMailViewerVisualiser::ProcessFinished
  4162 // CFSEmailUiMailViewerVisualiser::ProcessFinished
  4163 // -----------------------------------------------------------------------------
  4163 // -----------------------------------------------------------------------------
  4167 
  4167 
  4168 // -----------------------------------------------------------------------------
  4168 // -----------------------------------------------------------------------------
  4169 // CFSEmailUiMailViewerVisualiser::DialogDismissedL
  4169 // CFSEmailUiMailViewerVisualiser::DialogDismissedL
  4170 // -----------------------------------------------------------------------------
  4170 // -----------------------------------------------------------------------------
  4171 void CFSEmailUiMailViewerVisualiser::DialogDismissedL( TInt aButtonId )
  4171 void CFSEmailUiMailViewerVisualiser::DialogDismissedL( TInt aButtonId )
  4172 	{
  4172     {
  4173     FUNC_LOG;
  4173     FUNC_LOG;
  4174     iDialogNotDismissed = EFalse;
  4174     iDialogNotDismissed = EFalse;
  4175 	if( aButtonId == EAknSoftkeyCancel )
  4175     if( aButtonId == EAknSoftkeyCancel )
  4176 		{
  4176         {
  4177 		CancelFetchings();
  4177         CancelFetchings();
  4178 		}
  4178         }
  4179 	}
  4179     }
  4180 
  4180 
  4181 // -----------------------------------------------------------------------------
  4181 // -----------------------------------------------------------------------------
  4182 // CFSEmailUiMailViewerVisualiser::CycleError
  4182 // CFSEmailUiMailViewerVisualiser::CycleError
  4183 // -----------------------------------------------------------------------------
  4183 // -----------------------------------------------------------------------------
  4184 //<cmail>
  4184 //<cmail>
  4194 
  4194 
  4195 // -----------------------------------------------------------------------------
  4195 // -----------------------------------------------------------------------------
  4196 // CFSEmailUiMailViewerVisualiser::AddBackgroundPicturesL
  4196 // CFSEmailUiMailViewerVisualiser::AddBackgroundPicturesL
  4197 // -----------------------------------------------------------------------------
  4197 // -----------------------------------------------------------------------------
  4198 void CFSEmailUiMailViewerVisualiser::AddBackgroundPicturesL()
  4198 void CFSEmailUiMailViewerVisualiser::AddBackgroundPicturesL()
  4199 	{
  4199     {
  4200 	CAlfTexture& headerTexture = iAppUi.FsTextureManager()->TextureByIndex( EViewerTextureHeaderBackGround );
  4200     CAlfTexture& headerTexture = iAppUi.FsTextureManager()->TextureByIndex( EViewerTextureHeaderBackGround );
  4201 	CAlfTexture& backgroundTexture = iAppUi.FsTextureManager()->TextureByIndex( EBackgroundTextureMailList );
  4201     CAlfTexture& backgroundTexture = iAppUi.FsTextureManager()->TextureByIndex( EBackgroundTextureMailList );
  4202 
  4202 
  4203 	// add header texture
  4203     // add header texture
  4204 	// -1 is here for to bottom space icon
  4204     // -1 is here for to bottom space icon
  4205 	// // <cmail> S60 Skin support
  4205     // // <cmail> S60 Skin support
  4206 	//	iTextViewer->SetPartBgImageL( 0, iViewerRichText->HeaderLengthInCharacters()-2, headerTexture );
  4206     //  iTextViewer->SetPartBgImageL( 0, iViewerRichText->HeaderLengthInCharacters()-2, headerTexture );
  4207 	// </cmail>
  4207     // </cmail>
  4208 
  4208 
  4209 	// add bg texture
  4209     // add bg texture
  4210 	//<cmail> S60 skin support
  4210     //<cmail> S60 skin support
  4211 	//iTextViewer->SetBackgroundImageL( backgroundTexture );
  4211     //iTextViewer->SetBackgroundImageL( backgroundTexture );
  4212     //</cmail>
  4212     //</cmail>
  4213 	}
  4213     }
  4214 
  4214 
  4215 // -----------------------------------------------------------------------------
  4215 // -----------------------------------------------------------------------------
  4216 // CFSEmailUiMailViewerVisualiser::SetMessageFollowupFlagL
  4216 // CFSEmailUiMailViewerVisualiser::SetMessageFollowupFlagL
  4217 // -----------------------------------------------------------------------------
  4217 // -----------------------------------------------------------------------------
  4218 void CFSEmailUiMailViewerVisualiser::SetMessageFollowupFlagL()
  4218 void CFSEmailUiMailViewerVisualiser::SetMessageFollowupFlagL()
  4219 	{
  4219     {
  4220     FUNC_LOG;
  4220     FUNC_LOG;
  4221  	if ( iMessage &&
  4221     if ( iMessage &&
  4222  	     iTextViewer &&
  4222          iTextViewer &&
  4223  	     iViewerRichText &&
  4223          iViewerRichText &&
  4224  	     TFsEmailUiUtility::IsFollowUpSupported( *iMailBox ) &&
  4224          TFsEmailUiUtility::IsFollowUpSupported( *iMailBox ) &&
  4225  	     !iEmbeddedMessageMode )
  4225          !iEmbeddedMessageMode )
  4226 		{
  4226         {
  4227 		TFollowUpNewState newState = TFsEmailUiUtility::SetMessageFollowupFlagL( *iMessage );
  4227         TFollowUpNewState newState = TFsEmailUiUtility::SetMessageFollowupFlagL( *iMessage );
  4228 
  4228 
  4229 		switch ( newState )
  4229         switch ( newState )
  4230 			{
  4230             {
  4231 			case EFollowUp:
  4231             case EFollowUp:
  4232 				{
  4232                 {
  4233 				iViewerRichText->UpdateIconL( CFSEmailUiMailViewerRichText::EViewerIconFollowUp );
  4233                 iViewerRichText->UpdateIconL( CFSEmailUiMailViewerRichText::EViewerIconFollowUp );
  4234 				}
  4234                 }
  4235 				break;
  4235                 break;
  4236 			case EFollowUpComplete:
  4236             case EFollowUpComplete:
  4237 				{
  4237                 {
  4238 				iViewerRichText->UpdateIconL( CFSEmailUiMailViewerRichText::EViewerIconFollowUpComplete );
  4238                 iViewerRichText->UpdateIconL( CFSEmailUiMailViewerRichText::EViewerIconFollowUpComplete );
  4239 				}
  4239                 }
  4240 				break;
  4240                 break;
  4241 			case EFollowUpClear:
  4241             case EFollowUpClear:
  4242 				{
  4242                 {
  4243 				iViewerRichText->UpdateIconL( CFSEmailUiMailViewerRichText::EViewerIconFollowUpNone );
  4243                 iViewerRichText->UpdateIconL( CFSEmailUiMailViewerRichText::EViewerIconFollowUpNone );
  4244 				}
  4244                 }
  4245 				break;
  4245                 break;
  4246 			case EFollowUpNoChanges:
  4246             case EFollowUpNoChanges:
  4247 			default:
  4247             default:
  4248 				{
  4248                 {
  4249 				// do nothing.
  4249                 // do nothing.
  4250 				}
  4250                 }
  4251 				break;
  4251                 break;
  4252 			}
  4252             }
  4253 
  4253 
  4254 		if ( newState != EFollowUpNoChanges )
  4254         if ( newState != EFollowUpNoChanges )
  4255 		    {
  4255             {
  4256 		    // Update icon in viewer
  4256             // Update icon in viewer
  4257 	        TInt iconLine = iViewerRichText->FollowupIconLine();
  4257             TInt iconLine = iViewerRichText->FollowupIconLine();
  4258             iTextViewer->ReloadPicturesL( iconLine );
  4258             iTextViewer->ReloadPicturesL( iconLine );
  4259             // Notify appui of changed mail item
  4259             // Notify appui of changed mail item
  4260             SendEventToAppUiL( TFSEventMailChanged );
  4260             SendEventToAppUiL( TFSEventMailChanged );
  4261 		    }
  4261             }
  4262 		}
  4262         }
  4263 	}
  4263     }
  4264 
  4264 
  4265 // -----------------------------------------------------------------------------
  4265 // -----------------------------------------------------------------------------
  4266 // CFSEmailUiMailViewerVisualiser::DeleteMailL
  4266 // CFSEmailUiMailViewerVisualiser::DeleteMailL
  4267 // -----------------------------------------------------------------------------
  4267 // -----------------------------------------------------------------------------
  4268 TInt CFSEmailUiMailViewerVisualiser::DeleteMailL( CFSMailMessage& aMessagePtr, TBool aReturnPreviousView, TBool aDisableNote )
  4268 TInt CFSEmailUiMailViewerVisualiser::DeleteMailL( CFSMailMessage& aMessagePtr, TBool aReturnPreviousView, TBool aDisableNote )
  4269 	{
  4269     {
  4270     FUNC_LOG;
  4270     FUNC_LOG;
  4271 	TInt ret( KErrCancel );
  4271     TInt ret( KErrCancel );
  4272 
  4272 
  4273 	if ( iEmbeddedMessageMode )
  4273     if ( iEmbeddedMessageMode )
  4274 	    {
  4274         {
  4275 	    // embedded messages can't be deleted
  4275         // embedded messages can't be deleted
  4276 	    ret = KErrNotSupported;
  4276         ret = KErrNotSupported;
  4277 	    }
  4277         }
  4278 	else
  4278     else
  4279 	    {
  4279         {
  4280         TInt okToDelete( ETrue );
  4280         TInt okToDelete( ETrue );
  4281         if ( !aDisableNote )
  4281         if ( !aDisableNote )
  4282             {
  4282             {
  4283             if(iAppUi.GetCRHandler()->WarnBeforeDelete())
  4283             if(iAppUi.GetCRHandler()->WarnBeforeDelete())
  4284                 {
  4284                 {
  4309             // return to previous view
  4309             // return to previous view
  4310             if ( aReturnPreviousView )
  4310             if ( aReturnPreviousView )
  4311                 {
  4311                 {
  4312                 // return only if we are in mail viewer
  4312                 // return only if we are in mail viewer
  4313                 if ( iAppUi.CurrentActiveView()->Id() == MailViewerId )
  4313                 if ( iAppUi.CurrentActiveView()->Id() == MailViewerId )
  4314                 	{
  4314                     {
  4315                 	HandleCommandL( EAknSoftkeyBack );
  4315                     HandleCommandL( EAknSoftkeyBack );
  4316                 	}
  4316                     }
  4317                 }
  4317                 }
  4318             }
  4318             }
  4319         if ( okToDelete )
  4319         if ( okToDelete )
  4320             {
  4320             {
  4321             ret = KErrNone;
  4321             ret = KErrNone;
  4322             }
  4322             }
  4323 	    }
  4323         }
  4324 	return ret;
  4324     return ret;
  4325 	}
  4325     }
  4326 
  4326 
  4327 // -----------------------------------------------------------------------------
  4327 // -----------------------------------------------------------------------------
  4328 // CFSEmailUiMailViewerVisualiser::ShowActionsMenuInOptionsL
  4328 // CFSEmailUiMailViewerVisualiser::ShowActionsMenuInOptionsL
  4329 // -----------------------------------------------------------------------------
  4329 // -----------------------------------------------------------------------------
  4330 TBool CFSEmailUiMailViewerVisualiser::ShowActionsMenuInOptionsL() const
  4330 TBool CFSEmailUiMailViewerVisualiser::ShowActionsMenuInOptionsL() const
  4331 	{
  4331     {
  4332     FUNC_LOG;
  4332     FUNC_LOG;
  4333 	TBool retVal = ETrue;
  4333     TBool retVal = ETrue;
  4334 
  4334 
  4335 	SViewerHeadingHotSpotData currentHeaderHotSpotData;
  4335     SViewerHeadingHotSpotData currentHeaderHotSpotData;
  4336 	CFindItemEngine::SFoundItem currentBodyHotSpotData;
  4336     CFindItemEngine::SFoundItem currentBodyHotSpotData;
  4337 	THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL( currentHeaderHotSpotData, currentBodyHotSpotData );
  4337     THotspotType hotspotType = iViewerRichText->FindCurrentHotSpotL( currentHeaderHotSpotData, currentBodyHotSpotData );
  4338 
  4338 
  4339 	if( hotspotType == ENoHotspot || ( hotspotType == EHeaderHotspot && (
  4339     if( hotspotType == ENoHotspot || ( hotspotType == EHeaderHotspot && (
  4340 		currentHeaderHotSpotData.iType == ETypeToNMoreRecipients ||
  4340         currentHeaderHotSpotData.iType == ETypeToNMoreRecipients ||
  4341 		currentHeaderHotSpotData.iType == ETypeCcNMoreRecipients ||
  4341         currentHeaderHotSpotData.iType == ETypeCcNMoreRecipients ||
  4342 		currentHeaderHotSpotData.iType == ETypeBccNMoreRecipients ||
  4342         currentHeaderHotSpotData.iType == ETypeBccNMoreRecipients ||
  4343 		currentHeaderHotSpotData.iType == ETypeHtml ) ) )
  4343         currentHeaderHotSpotData.iType == ETypeHtml ) ) )
  4344 		{
  4344         {
  4345 		retVal = EFalse;
  4345         retVal = EFalse;
  4346 		}
  4346         }
  4347 	return retVal;
  4347     return retVal;
  4348 	}
  4348     }
  4349 
  4349 
  4350 // -----------------------------------------------------------------------------
  4350 // -----------------------------------------------------------------------------
  4351 // CFSEmailUiMailViewerVisualiser::ShowDownloadManagerMenuInOptions
  4351 // CFSEmailUiMailViewerVisualiser::ShowDownloadManagerMenuInOptions
  4352 // -----------------------------------------------------------------------------
  4352 // -----------------------------------------------------------------------------
  4353 TBool CFSEmailUiMailViewerVisualiser::ShowDownloadManagerMenuInOptions() const
  4353 TBool CFSEmailUiMailViewerVisualiser::ShowDownloadManagerMenuInOptions() const
  4354 	{
  4354     {
  4355     FUNC_LOG;
  4355     FUNC_LOG;
  4356 	TBool ret(EFalse);
  4356     TBool ret(EFalse);
  4357 /* <cmail> Download Manager blocked
  4357 /* <cmail> Download Manager blocked
  4358 	if ( iAppUi.DownloadInfoMediator() )
  4358     if ( iAppUi.DownloadInfoMediator() )
  4359 		{
  4359         {
  4360 		ret = iAppUi.DownloadInfoMediator()->IsAnyAttachmentDownloads();
  4360         ret = iAppUi.DownloadInfoMediator()->IsAnyAttachmentDownloads();
  4361 		}
  4361         }
  4362 </cmail> */
  4362 </cmail> */
  4363 	return ret;
  4363     return ret;
  4364 	}
  4364     }
  4365 
  4365 
  4366 // -----------------------------------------------------------------------------
  4366 // -----------------------------------------------------------------------------
  4367 // CFSEmailUiMailViewerVisualiser::ShowNextMessageMenuInOptions
  4367 // CFSEmailUiMailViewerVisualiser::ShowNextMessageMenuInOptions
  4368 // -----------------------------------------------------------------------------
  4368 // -----------------------------------------------------------------------------
  4369 TBool CFSEmailUiMailViewerVisualiser::ShowNextMessageMenuInOptions() const
  4369 TBool CFSEmailUiMailViewerVisualiser::ShowNextMessageMenuInOptions() const
  4370 	{
  4370     {
  4371     FUNC_LOG;
  4371     FUNC_LOG;
  4372 	TBool available = EFalse;
  4372     TBool available = EFalse;
  4373 	// Next/previous message options are inavailable in the embedded mode
  4373     // Next/previous message options are inavailable in the embedded mode
  4374 	if ( iMessage && !iEmbeddedMessageMode )
  4374     if ( iMessage && !iEmbeddedMessageMode )
  4375 	    {
  4375         {
  4376         TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  4376         TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  4377         TFSMailMsgId nextMsgId;
  4377         TFSMailMsgId nextMsgId;
  4378         TFSMailMsgId nextMsgFolderId;
  4378         TFSMailMsgId nextMsgFolderId;
  4379         available = iAppUi.IsNextMsgAvailable( currentMsgId, nextMsgId, nextMsgFolderId );
  4379         available = iAppUi.IsNextMsgAvailable( currentMsgId, nextMsgId, nextMsgFolderId );
  4380 	    }
  4380         }
  4381 	return available;
  4381     return available;
  4382 	}
  4382     }
  4383 
  4383 
  4384 // -----------------------------------------------------------------------------
  4384 // -----------------------------------------------------------------------------
  4385 // CFSEmailUiMailViewerVisualiser::ShowPreviousMessageMenuInOptions
  4385 // CFSEmailUiMailViewerVisualiser::ShowPreviousMessageMenuInOptions
  4386 // -----------------------------------------------------------------------------
  4386 // -----------------------------------------------------------------------------
  4387 TBool CFSEmailUiMailViewerVisualiser::ShowPreviousMessageMenuInOptions() const
  4387 TBool CFSEmailUiMailViewerVisualiser::ShowPreviousMessageMenuInOptions() const
  4388 	{
  4388     {
  4389     FUNC_LOG;
  4389     FUNC_LOG;
  4390     TBool available = EFalse;
  4390     TBool available = EFalse;
  4391     // Next/previous message options are inavailable in the embedded mode
  4391     // Next/previous message options are inavailable in the embedded mode
  4392     if ( iMessage && !iEmbeddedMessageMode )
  4392     if ( iMessage && !iEmbeddedMessageMode )
  4393         {
  4393         {
  4395         TFSMailMsgId prevMsgId;
  4395         TFSMailMsgId prevMsgId;
  4396         TFSMailMsgId prevMsgFolderId;
  4396         TFSMailMsgId prevMsgFolderId;
  4397         available = iAppUi.IsPreviousMsgAvailable( currentMsgId, prevMsgId, prevMsgFolderId );
  4397         available = iAppUi.IsPreviousMsgAvailable( currentMsgId, prevMsgId, prevMsgFolderId );
  4398         }
  4398         }
  4399     return available;
  4399     return available;
  4400 	}
  4400     }
  4401 
  4401 
  4402 
  4402 
  4403 // -----------------------------------------------------------------------------
  4403 // -----------------------------------------------------------------------------
  4404 // CFSEmailUiMailViewerVisualiser::ShowNextMessageL
  4404 // CFSEmailUiMailViewerVisualiser::ShowNextMessageL
  4405 // -----------------------------------------------------------------------------
  4405 // -----------------------------------------------------------------------------
  4406 void CFSEmailUiMailViewerVisualiser::ShowNextMessageL()
  4406 void CFSEmailUiMailViewerVisualiser::ShowNextMessageL()
  4407 	{
  4407     {
  4408     FUNC_LOG;
  4408     FUNC_LOG;
  4409 	if ( iMessage && !iEmbeddedMessageMode )
  4409     if ( iMessage && !iEmbeddedMessageMode )
  4410 		{
  4410         {
  4411 		TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  4411         TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  4412 		TFSMailMsgId nextMsgId;
  4412         TFSMailMsgId nextMsgId;
  4413 		TFSMailMsgId nextMsgFolderId;
  4413         TFSMailMsgId nextMsgFolderId;
  4414 		if ( iAppUi.IsNextMsgAvailable( currentMsgId, nextMsgId, nextMsgFolderId ) )
  4414         if ( iAppUi.IsNextMsgAvailable( currentMsgId, nextMsgId, nextMsgFolderId ) )
  4415 			{
  4415             {
  4416 			// Stop timer and cancel fetchings before showing next message
  4416             // Stop timer and cancel fetchings before showing next message
  4417 			iFetchingAnimationTimer->Stop();
  4417             iFetchingAnimationTimer->Stop();
  4418 			CancelFetchings();
  4418             CancelFetchings();
  4419 
  4419 
  4420 			// Change empty msk when moving to next
  4420             // Change empty msk when moving to next
  4421 			ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  4421             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  4422 
  4422 
  4423 			iAppUi.MoveToNextMsgL( currentMsgId, nextMsgId );
  4423             iAppUi.MoveToNextMsgL( currentMsgId, nextMsgId );
  4424 			// Next message is displayed in this view through doactivate, because view is re-activate by mail list
  4424             // Next message is displayed in this view through doactivate, because view is re-activate by mail list
  4425 			}
  4425             }
  4426 		}
  4426         }
  4427 	}
  4427     }
  4428 // -----------------------------------------------------------------------------
  4428 // -----------------------------------------------------------------------------
  4429 // CFSEmailUiMailViewerVisualiser::ShowPreviousMessageL
  4429 // CFSEmailUiMailViewerVisualiser::ShowPreviousMessageL
  4430 // -----------------------------------------------------------------------------
  4430 // -----------------------------------------------------------------------------
  4431 void CFSEmailUiMailViewerVisualiser::ShowPreviousMessageL()
  4431 void CFSEmailUiMailViewerVisualiser::ShowPreviousMessageL()
  4432 	{
  4432     {
  4433     FUNC_LOG;
  4433     FUNC_LOG;
  4434 	if ( iMessage && !iEmbeddedMessageMode )
  4434     if ( iMessage && !iEmbeddedMessageMode )
  4435 		{
  4435         {
  4436 		TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  4436         TFSMailMsgId currentMsgId = iMessage->GetMessageId();
  4437 		TFSMailMsgId prevMsgId;
  4437         TFSMailMsgId prevMsgId;
  4438 		TFSMailMsgId prevMsgFolderId;
  4438         TFSMailMsgId prevMsgFolderId;
  4439 		if ( iAppUi.IsPreviousMsgAvailable( currentMsgId, prevMsgId, prevMsgFolderId ) )
  4439         if ( iAppUi.IsPreviousMsgAvailable( currentMsgId, prevMsgId, prevMsgFolderId ) )
  4440 			{
  4440             {
  4441 			// Stop timer and cancel fetchings before showing prev message
  4441             // Stop timer and cancel fetchings before showing prev message
  4442 			iFetchingAnimationTimer->Stop();
  4442             iFetchingAnimationTimer->Stop();
  4443 			CancelFetchings();
  4443             CancelFetchings();
  4444 
  4444 
  4445 		    // Change empty msk when moving to previous
  4445             // Change empty msk when moving to previous
  4446 		    ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  4446             ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  4447 
  4447 
  4448 			iAppUi.MoveToPreviousMsgL( currentMsgId, prevMsgId );
  4448             iAppUi.MoveToPreviousMsgL( currentMsgId, prevMsgId );
  4449 			// Previous message is displayed in this view through doactivate, because view is re-activate by mail list
  4449             // Previous message is displayed in this view through doactivate, because view is re-activate by mail list
  4450 			}
  4450             }
  4451 		}
  4451         }
  4452 	}
  4452     }
  4453 
  4453 
  4454 // -----------------------------------------------------------------------------
  4454 // -----------------------------------------------------------------------------
  4455 // CFSEmailUiMailViewerVisualiser::UpdateMessagePtrL
  4455 // CFSEmailUiMailViewerVisualiser::UpdateMessagePtrL
  4456 // -----------------------------------------------------------------------------
  4456 // -----------------------------------------------------------------------------
  4457 void CFSEmailUiMailViewerVisualiser::UpdateMessagePtrL( TFSMailMsgId aNewMailboxId,
  4457 void CFSEmailUiMailViewerVisualiser::UpdateMessagePtrL( TFSMailMsgId aNewMailboxId,
  4627 
  4627 
  4628 // -----------------------------------------------------------------------------
  4628 // -----------------------------------------------------------------------------
  4629 // CFSEmailUiMailViewerVisualiser::HandleDynamicVariantSwitchL
  4629 // CFSEmailUiMailViewerVisualiser::HandleDynamicVariantSwitchL
  4630 // -----------------------------------------------------------------------------
  4630 // -----------------------------------------------------------------------------
  4631 void CFSEmailUiMailViewerVisualiser::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType /*aType*/ )
  4631 void CFSEmailUiMailViewerVisualiser::HandleDynamicVariantSwitchL( CFsEmailUiViewBase::TDynamicSwitchType /*aType*/ )
  4632 	{
  4632     {
  4633     FUNC_LOG;
  4633     FUNC_LOG;
  4634 	// Set scroll offset to match screen height
  4634     // Set scroll offset to match screen height
  4635 	if ( iFirstStartCompleted && iTextViewer && iMessage )
  4635     if ( iFirstStartCompleted && iTextViewer && iMessage )
  4636 	    {
  4636         {
  4637 	    // <cmail>
  4637         // <cmail>
  4638 	    TInt firstLine = iTextViewer->GetFirstDisplayedLine();        // get first line number
  4638         TInt firstLine = iTextViewer->GetFirstDisplayedLine();        // get first line number
  4639 	    TInt firstChar = iTextViewer->GetFirstCharInLine(firstLine);  // get first char offset
  4639         TInt firstChar = iTextViewer->GetFirstCharInLine(firstLine);  // get first char offset
  4640 	    // </cmail>
  4640         // </cmail>
  4641 
  4641 
  4642 	    iAppUi.Display().Roster().Hide( ControlGroup() );
  4642         iAppUi.Display().Roster().Hide( ControlGroup() );
  4643 	    RefreshL();
  4643         RefreshL();
  4644 
  4644 
  4645 	    // <cmail>
  4645         // <cmail>
  4646 	    TInt newLine = iTextViewer->GetLineNumber(firstChar);   // get the new line number for this offset
  4646         TInt newLine = iTextViewer->GetLineNumber(firstChar);   // get the new line number for this offset
  4647 	    if(newLine<0) newLine = firstLine;                       // in case of error go to the prev. line number
  4647         if(newLine<0) newLine = firstLine;                       // in case of error go to the prev. line number
  4648 	    iTextViewer->FocusLineL(newLine,ETrue);                  // focus on the found line number
  4648         iTextViewer->FocusLineL(newLine,ETrue);                  // focus on the found line number
  4649 	    // </cmail>
  4649         // </cmail>
  4650 	    // <cmail>
  4650         // <cmail>
  4651 	    SetActionMenuIconVisbilityL();
  4651         SetActionMenuIconVisbilityL();
  4652             // </cmail>
  4652             // </cmail>
  4653             iAppUi.Display().Roster().ShowL( ControlGroup() );
  4653             iAppUi.Display().Roster().ShowL( ControlGroup() );
  4654 	    iDownloadProgressIndicator->NotifyLayoutChange();
  4654         iDownloadProgressIndicator->NotifyLayoutChange();
  4655 	    }
  4655         }
  4656  	}
  4656     }
  4657 
  4657 
  4658 // -----------------------------------------------------------------------------
  4658 // -----------------------------------------------------------------------------
  4659 // CFSEmailUiMailViewerVisualiser::HandleDynamicVariantSwitchOnBackgroundL
  4659 // CFSEmailUiMailViewerVisualiser::HandleDynamicVariantSwitchOnBackgroundL
  4660 // -----------------------------------------------------------------------------
  4660 // -----------------------------------------------------------------------------
  4661 void CFSEmailUiMailViewerVisualiser::HandleDynamicVariantSwitchOnBackgroundL( CFsEmailUiViewBase::TDynamicSwitchType /*aType*/ )
  4661 void CFSEmailUiMailViewerVisualiser::HandleDynamicVariantSwitchOnBackgroundL( CFsEmailUiViewBase::TDynamicSwitchType /*aType*/ )
  4666 
  4666 
  4667 // -----------------------------------------------------------------------------
  4667 // -----------------------------------------------------------------------------
  4668 // CFSEmailUiMailViewerVisualiser::OpenLinkInIntranetL
  4668 // CFSEmailUiMailViewerVisualiser::OpenLinkInIntranetL
  4669 // -----------------------------------------------------------------------------
  4669 // -----------------------------------------------------------------------------
  4670 void CFSEmailUiMailViewerVisualiser::OpenLinkInIntranetL( TBool aMenuSelection )
  4670 void CFSEmailUiMailViewerVisualiser::OpenLinkInIntranetL( TBool aMenuSelection )
  4671 	{
  4671     {
  4672     FUNC_LOG;
  4672     FUNC_LOG;
  4673 	CFindItemEngine::SFoundItem currentBodyHotSpotData;
  4673     CFindItemEngine::SFoundItem currentBodyHotSpotData;
  4674 	TBool bodyHotSpotFound = iViewerRichText->FindCurrentBodyHotSpotL( currentBodyHotSpotData );
  4674     TBool bodyHotSpotFound = iViewerRichText->FindCurrentBodyHotSpotL( currentBodyHotSpotData );
  4675 	if ( bodyHotSpotFound )
  4675     if ( bodyHotSpotFound )
  4676 		{
  4676         {
  4677  		HBufC* intranetUrl = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  4677         HBufC* intranetUrl = iViewerRichText->GetHotspotTextLC( currentBodyHotSpotData );
  4678  		TInt len = intranetUrl->Length();
  4678         TInt len = intranetUrl->Length();
  4679  		HBufC8* eightBitUrl = HBufC8::NewLC( len );
  4679         HBufC8* eightBitUrl = HBufC8::NewLC( len );
  4680 		eightBitUrl->Des().Copy( *intranetUrl );
  4680         eightBitUrl->Des().Copy( *intranetUrl );
  4681 
  4681 
  4682 		TAiwGenericParam param( EGenericParamURL, TAiwVariant(*eightBitUrl) );
  4682         TAiwGenericParam param( EGenericParamURL, TAiwVariant(*eightBitUrl) );
  4683         CAiwGenericParamList& paramList = iIBServiceHandler->InParamListL();
  4683         CAiwGenericParamList& paramList = iIBServiceHandler->InParamListL();
  4684         paramList.AppendL( param );
  4684         paramList.AppendL( param );
  4685         if ( aMenuSelection )
  4685         if ( aMenuSelection )
  4686             {
  4686             {
  4687             iIBServiceHandler->ExecuteMenuCmdL( EFsEmailUiCmdActionsOpenInIntranetMenu,
  4687             iIBServiceHandler->ExecuteMenuCmdL( EFsEmailUiCmdActionsOpenInIntranetMenu,
  4690         else
  4690         else
  4691             {
  4691             {
  4692             iIBServiceHandler->ExecuteServiceCmdL( KAiwCmdView,
  4692             iIBServiceHandler->ExecuteServiceCmdL( KAiwCmdView,
  4693                 paramList, iIBServiceHandler->OutParamListL() );
  4693                 paramList, iIBServiceHandler->OutParamListL() );
  4694             }
  4694             }
  4695 		CleanupStack::PopAndDestroy( eightBitUrl );
  4695         CleanupStack::PopAndDestroy( eightBitUrl );
  4696 		CleanupStack::PopAndDestroy( intranetUrl );
  4696         CleanupStack::PopAndDestroy( intranetUrl );
  4697 		}
  4697         }
  4698 	}
  4698     }
  4699 
  4699 
  4700 // -----------------------------------------------------------------------------
  4700 // -----------------------------------------------------------------------------
  4701 // CFSEmailUiMailViewerVisualiser::ChangeMsgReadStatusL
  4701 // CFSEmailUiMailViewerVisualiser::ChangeMsgReadStatusL
  4702 // -----------------------------------------------------------------------------
  4702 // -----------------------------------------------------------------------------
  4703 void CFSEmailUiMailViewerVisualiser::ChangeMsgReadStatusL(
  4703 void CFSEmailUiMailViewerVisualiser::ChangeMsgReadStatusL(
  4704 	TBool aRead, TBool aCmdFromMrui )
  4704     TBool aRead, TBool aCmdFromMrui )
  4705 	{
  4705     {
  4706     FUNC_LOG;
  4706     FUNC_LOG;
  4707 	if ( iMessage && !iEmbeddedMessageMode )
  4707     if ( iMessage && !iEmbeddedMessageMode )
  4708 		{
  4708         {
  4709 		if ( aRead )
  4709         if ( aRead )
  4710  			{
  4710             {
  4711 			// Send flags, local and server
  4711             // Send flags, local and server
  4712  			iMessage->SetFlag( EFSMsgFlag_Read );
  4712             iMessage->SetFlag( EFSMsgFlag_Read );
  4713 			}
  4713             }
  4714 		else
  4714         else
  4715 			{
  4715             {
  4716 			// Send flags, local and server
  4716             // Send flags, local and server
  4717  			iMessage->ResetFlag( EFSMsgFlag_Read );
  4717             iMessage->ResetFlag( EFSMsgFlag_Read );
  4718 			}
  4718             }
  4719 		iMessage->SaveMessageL(); // Save read status
  4719         iMessage->SaveMessageL(); // Save read status
  4720 		SendEventToAppUiL( TFSEventMailChanged );
  4720         SendEventToAppUiL( TFSEventMailChanged );
  4721 
  4721 
  4722 		if ( !aCmdFromMrui && iViewerRichText && iTextViewer )
  4722         if ( !aCmdFromMrui && iViewerRichText && iTextViewer )
  4723 			{
  4723             {
  4724 			iViewerRichText->UpdateIconL(
  4724             iViewerRichText->UpdateIconL(
  4725 				CFSEmailUiMailViewerRichText::EViewerEmailStatus );
  4725                 CFSEmailUiMailViewerRichText::EViewerEmailStatus );
  4726 			TInt iconLine = iViewerRichText->EmailStatusIconLine();
  4726             TInt iconLine = iViewerRichText->EmailStatusIconLine();
  4727 	        iTextViewer->ReloadPicturesL( iconLine );
  4727             iTextViewer->ReloadPicturesL( iconLine );
  4728 			}
  4728             }
  4729 		}
  4729         }
  4730 	}
  4730     }
  4731 
  4731 
  4732 // -----------------------------------------------------------------------------
  4732 // -----------------------------------------------------------------------------
  4733 // CFSEmailUiMailViewerVisualiser::OpenHotSpotUrlInBrowserL
  4733 // CFSEmailUiMailViewerVisualiser::OpenHotSpotUrlInBrowserL
  4734 // -----------------------------------------------------------------------------
  4734 // -----------------------------------------------------------------------------
  4735 void CFSEmailUiMailViewerVisualiser::OpenHotSpotUrlInBrowserL(  CFindItemEngine::SFoundItem& aHotSpot  )
  4735 void CFSEmailUiMailViewerVisualiser::OpenHotSpotUrlInBrowserL(  CFindItemEngine::SFoundItem& aHotSpot  )
  4736 	{
  4736     {
  4737     FUNC_LOG;
  4737     FUNC_LOG;
  4738 	if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchURLBin ||
  4738     if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchURLBin ||
  4739 		 aHotSpot.iItemType == CFindItemEngine::EFindItemSearchScheme ) // Scheme is needed also
  4739          aHotSpot.iItemType == CFindItemEngine::EFindItemSearchScheme ) // Scheme is needed also
  4740 		{
  4740         {
  4741 		// use browser launcher API here
  4741         // use browser launcher API here
  4742 		HBufC* urlToOpen = iViewerRichText->GetHotspotTextLC( aHotSpot );
  4742         HBufC* urlToOpen = iViewerRichText->GetHotspotTextLC( aHotSpot );
  4743 		// Check if the address is rtsp url and send it media player
  4743         // Check if the address is rtsp url and send it media player
  4744 		if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchScheme &&
  4744         if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchScheme &&
  4745 			 urlToOpen->FindC( KRtspUrlPrefix ) == 0 )
  4745              urlToOpen->FindC( KRtspUrlPrefix ) == 0 )
  4746 			{
  4746             {
  4747 			RApaLsSession appArcSession;
  4747             RApaLsSession appArcSession;
  4748 			User::LeaveIfError( appArcSession.Connect() );
  4748             User::LeaveIfError( appArcSession.Connect() );
  4749 			TThreadId id;
  4749             TThreadId id;
  4750 			appArcSession.StartDocument( urlToOpen->Des(), KUidMediaPlayer , id );
  4750             appArcSession.StartDocument( urlToOpen->Des(), KUidMediaPlayer , id );
  4751 			appArcSession.Close();
  4751             appArcSession.Close();
  4752 			}
  4752             }
  4753 		else
  4753         else
  4754 			{
  4754             {
  4755 			// Check wheter the url text has some prefix (http, https, ftp, etc.).
  4755             // Check wheter the url text has some prefix (http, https, ftp, etc.).
  4756 			// If no prefix found, try with the default prefix http.
  4756             // If no prefix found, try with the default prefix http.
  4757 			TInt urlPos = urlToOpen->Find( KUrlPrefixIdentifier );
  4757             TInt urlPos = urlToOpen->Find( KUrlPrefixIdentifier );
  4758 			if ( urlPos == KErrNotFound )
  4758             if ( urlPos == KErrNotFound )
  4759 			    {
  4759                 {
  4760 			    HBufC* newBuf = urlToOpen->ReAllocL( urlToOpen->Length() + KHttpUrlPrefix().Length() );
  4760                 HBufC* newBuf = urlToOpen->ReAllocL( urlToOpen->Length() + KHttpUrlPrefix().Length() );
  4761 		        CleanupStack::Pop( urlToOpen );
  4761                 CleanupStack::Pop( urlToOpen );
  4762 		        urlToOpen = newBuf;
  4762                 urlToOpen = newBuf;
  4763 	            CleanupStack::PushL( urlToOpen );
  4763                 CleanupStack::PushL( urlToOpen );
  4764 	            TPtr urlToOpenPtr = urlToOpen->Des();
  4764                 TPtr urlToOpenPtr = urlToOpen->Des();
  4765 	            urlToOpenPtr.Insert( 0, KHttpUrlPrefix );
  4765                 urlToOpenPtr.Insert( 0, KHttpUrlPrefix );
  4766 			    }
  4766                 }
  4767 
  4767 
  4768 			// Use scheme handler to launch the browser as a stand alone application
  4768             // Use scheme handler to launch the browser as a stand alone application
  4769 	        CSchemeHandler* handler = CSchemeHandler::NewL( *urlToOpen );
  4769             CSchemeHandler* handler = CSchemeHandler::NewL( *urlToOpen );
  4770 	        CleanupStack::PushL( handler );
  4770             CleanupStack::PushL( handler );
  4771 	        handler->HandleUrlStandaloneL();
  4771             handler->HandleUrlStandaloneL();
  4772 	        CleanupStack::PopAndDestroy( handler );
  4772             CleanupStack::PopAndDestroy( handler );
  4773 			}
  4773             }
  4774 
  4774 
  4775 		CleanupStack::PopAndDestroy( urlToOpen );
  4775         CleanupStack::PopAndDestroy( urlToOpen );
  4776 		}
  4776         }
  4777 	}
  4777     }
  4778 
  4778 
  4779 // -----------------------------------------------------------------------------
  4779 // -----------------------------------------------------------------------------
  4780 // CFSEmailUiMailViewerVisualiser::CallToBodyHotSpotNumberL
  4780 // CFSEmailUiMailViewerVisualiser::CallToBodyHotSpotNumberL
  4781 // -----------------------------------------------------------------------------
  4781 // -----------------------------------------------------------------------------
  4782 void CFSEmailUiMailViewerVisualiser::CallToBodyHotSpotNumberL( CFindItemEngine::SFoundItem& aHotSpot )
  4782 void CFSEmailUiMailViewerVisualiser::CallToBodyHotSpotNumberL( CFindItemEngine::SFoundItem& aHotSpot )
  4783 	{
  4783     {
  4784     FUNC_LOG;
  4784     FUNC_LOG;
  4785 
  4785 
  4786 	if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchPhoneNumberBin )
  4786     if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchPhoneNumberBin )
  4787 		{
  4787         {
  4788 		HBufC* phoneNumber = iViewerRichText->GetHotspotTextLC( aHotSpot );
  4788         HBufC* phoneNumber = iViewerRichText->GetHotspotTextLC( aHotSpot );
  4789 		TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL(
  4789         TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL(
  4790 		        R_FREESTYLE_EMAIL_UI_VIEWER_CALL_HOTSPOT, *phoneNumber );
  4790                 R_FREESTYLE_EMAIL_UI_VIEWER_CALL_HOTSPOT, *phoneNumber );
  4791 		if ( answer )
  4791         if ( answer )
  4792 			{
  4792             {
  4793 	        TPtr numberPtr = phoneNumber->Des();
  4793             TPtr numberPtr = phoneNumber->Des();
  4794 		    CommonPhoneParser::ParsePhoneNumber( numberPtr,
  4794             CommonPhoneParser::ParsePhoneNumber( numberPtr,
  4795 		                          CommonPhoneParser::EPhoneClientNumber);
  4795                                   CommonPhoneParser::EPhoneClientNumber);
  4796 
  4796 
  4797 		    CFsDelayedLoader::InstanceL()->GetContactHandlerL()->MakeAiwCallL( NULL, *phoneNumber );
  4797             CFsDelayedLoader::InstanceL()->GetContactHandlerL()->MakeAiwCallL( NULL, *phoneNumber );
  4798 			}
  4798             }
  4799         CleanupStack::PopAndDestroy( phoneNumber );
  4799         CleanupStack::PopAndDestroy( phoneNumber );
  4800 		}
  4800         }
  4801 	else if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchScheme )
  4801     else if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchScheme )
  4802 		{
  4802         {
  4803 		TBool voipCall( EFalse );
  4803         TBool voipCall( EFalse );
  4804 		HBufC* schemeText = iViewerRichText->GetHotspotTextLC( aHotSpot );
  4804         HBufC* schemeText = iViewerRichText->GetHotspotTextLC( aHotSpot );
  4805 		// Strip scheme prefix text if found
  4805         // Strip scheme prefix text if found
  4806 		if ( schemeText && schemeText->FindC( KCallPrefix ) == 0 )
  4806         if ( schemeText && schemeText->FindC( KCallPrefix ) == 0 )
  4807 			{
  4807             {
  4808 			schemeText->Des().Delete( 0, KCallPrefix().Length() );
  4808             schemeText->Des().Delete( 0, KCallPrefix().Length() );
  4809 			}
  4809             }
  4810 		else if ( schemeText && schemeText->FindC( KTelPrefix ) == 0 )
  4810         else if ( schemeText && schemeText->FindC( KTelPrefix ) == 0 )
  4811 			{
  4811             {
  4812 			schemeText->Des().Delete( 0, KTelPrefix().Length() );
  4812             schemeText->Des().Delete( 0, KTelPrefix().Length() );
  4813 			}
  4813             }
  4814 		else if ( schemeText && schemeText->FindC( KSmsPrefix ) == 0 )
  4814         else if ( schemeText && schemeText->FindC( KSmsPrefix ) == 0 )
  4815 			{
  4815             {
  4816 			schemeText->Des().Delete( 0, KSmsPrefix().Length() );
  4816             schemeText->Des().Delete( 0, KSmsPrefix().Length() );
  4817 			}
  4817             }
  4818 		else if ( schemeText && schemeText->FindC( KMmsPrefix ) == 0 )
  4818         else if ( schemeText && schemeText->FindC( KMmsPrefix ) == 0 )
  4819 			{
  4819             {
  4820 			schemeText->Des().Delete( 0, KMmsPrefix().Length() );
  4820             schemeText->Des().Delete( 0, KMmsPrefix().Length() );
  4821 			}
  4821             }
  4822 		else if ( schemeText && schemeText->FindC( KVoipPrefix ) == 0 )
  4822         else if ( schemeText && schemeText->FindC( KVoipPrefix ) == 0 )
  4823 			{
  4823             {
  4824 			voipCall = ETrue;
  4824             voipCall = ETrue;
  4825 			schemeText->Des().Delete( 0, KVoipPrefix().Length() );
  4825             schemeText->Des().Delete( 0, KVoipPrefix().Length() );
  4826 			}
  4826             }
  4827 
  4827 
  4828 		TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL(
  4828         TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL(
  4829 		        R_FREESTYLE_EMAIL_UI_VIEWER_CALL_HOTSPOT, *schemeText );
  4829                 R_FREESTYLE_EMAIL_UI_VIEWER_CALL_HOTSPOT, *schemeText );
  4830 		if ( answer )
  4830         if ( answer )
  4831 			{
  4831             {
  4832 			if ( !voipCall )
  4832             if ( !voipCall )
  4833 				{
  4833                 {
  4834 				// use common phone parser for other than voip numbers
  4834                 // use common phone parser for other than voip numbers
  4835 		        TPtr numberPtr = schemeText->Des();
  4835                 TPtr numberPtr = schemeText->Des();
  4836 			    CommonPhoneParser::ParsePhoneNumber( numberPtr,
  4836                 CommonPhoneParser::ParsePhoneNumber( numberPtr,
  4837 		                         CommonPhoneParser::EPhoneClientNumber );
  4837                                  CommonPhoneParser::EPhoneClientNumber );
  4838 				}
  4838                 }
  4839 		    CFsDelayedLoader::InstanceL()->GetContactHandlerL()->MakeAiwCallL( NULL, *schemeText, voipCall );
  4839             CFsDelayedLoader::InstanceL()->GetContactHandlerL()->MakeAiwCallL( NULL, *schemeText, voipCall );
  4840 			}
  4840             }
  4841 		CleanupStack::PopAndDestroy( schemeText );
  4841         CleanupStack::PopAndDestroy( schemeText );
  4842 		}
  4842         }
  4843 	}
  4843     }
  4844 
  4844 
  4845 // -----------------------------------------------------------------------------
  4845 // -----------------------------------------------------------------------------
  4846 // CFSEmailUiMailViewerVisualiser::WriteEmailToHotSpotAddressL
  4846 // CFSEmailUiMailViewerVisualiser::WriteEmailToHotSpotAddressL
  4847 // -----------------------------------------------------------------------------
  4847 // -----------------------------------------------------------------------------
  4848 void CFSEmailUiMailViewerVisualiser::WriteEmailToHotSpotAddressL( CFindItemEngine::SFoundItem& aHotSpot )
  4848 void CFSEmailUiMailViewerVisualiser::WriteEmailToHotSpotAddressL( CFindItemEngine::SFoundItem& aHotSpot )
  4849 	{
  4849     {
  4850     FUNC_LOG;
  4850     FUNC_LOG;
  4851 	if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchMailAddressBin )
  4851     if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchMailAddressBin )
  4852 		{
  4852         {
  4853 		delete iNewMailTempAddress; iNewMailTempAddress = NULL;
  4853         delete iNewMailTempAddress; iNewMailTempAddress = NULL;
  4854 		iNewMailTempAddress = CFSMailAddress::NewL();
  4854         iNewMailTempAddress = CFSMailAddress::NewL();
  4855 		HBufC* mailAddress = iViewerRichText->GetHotspotTextLC( aHotSpot );
  4855         HBufC* mailAddress = iViewerRichText->GetHotspotTextLC( aHotSpot );
  4856 		iNewMailTempAddress->SetEmailAddress( *mailAddress );
  4856         iNewMailTempAddress->SetEmailAddress( *mailAddress );
  4857  		CleanupStack::PopAndDestroy( mailAddress );
  4857         CleanupStack::PopAndDestroy( mailAddress );
  4858 		iAppUi.LaunchEditorL( iNewMailTempAddress );
  4858         iAppUi.LaunchEditorL( iNewMailTempAddress );
  4859 		}
  4859         }
  4860 	else if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchScheme )
  4860     else if ( aHotSpot.iItemType == CFindItemEngine::EFindItemSearchScheme )
  4861 		{
  4861         {
  4862 		HBufC* schemeText = iViewerRichText->GetHotspotTextLC( aHotSpot );
  4862         HBufC* schemeText = iViewerRichText->GetHotspotTextLC( aHotSpot );
  4863 		if ( schemeText && schemeText->FindC( KMailtoPrefix ) == 0)
  4863         if ( schemeText && schemeText->FindC( KMailtoPrefix ) == 0)
  4864 			{
  4864             {
  4865 			schemeText->Des().Delete( 0, KMailtoPrefix().Length() );
  4865             schemeText->Des().Delete( 0, KMailtoPrefix().Length() );
  4866 			delete iNewMailTempAddress; iNewMailTempAddress = NULL;
  4866             delete iNewMailTempAddress; iNewMailTempAddress = NULL;
  4867 			iNewMailTempAddress = CFSMailAddress::NewL();
  4867             iNewMailTempAddress = CFSMailAddress::NewL();
  4868 			iNewMailTempAddress->SetEmailAddress( *schemeText );
  4868             iNewMailTempAddress->SetEmailAddress( *schemeText );
  4869 			iAppUi.LaunchEditorL( iNewMailTempAddress );
  4869             iAppUi.LaunchEditorL( iNewMailTempAddress );
  4870 			}
  4870             }
  4871 		CleanupStack::PopAndDestroy( schemeText );
  4871         CleanupStack::PopAndDestroy( schemeText );
  4872 		}
  4872         }
  4873 	}
  4873     }
  4874 
  4874 
  4875 void CFSEmailUiMailViewerVisualiser::SaveEmailAsContactL(
  4875 void CFSEmailUiMailViewerVisualiser::SaveEmailAsContactL(
  4876 	const TDesC& aEmailAddress )
  4876     const TDesC& aEmailAddress )
  4877 	{
  4877     {
  4878     FUNC_LOG;
  4878     FUNC_LOG;
  4879 	TAddToContactsType type;
  4879     TAddToContactsType type;
  4880 	// Query to "update existing" or "Create new"
  4880     // Query to "update existing" or "Create new"
  4881 	// --> EFALSE = user chose "cancel"
  4881     // --> EFALSE = user chose "cancel"
  4882 	if ( CFsDelayedLoader::InstanceL()->GetContactHandlerL()->
  4882     if ( CFsDelayedLoader::InstanceL()->GetContactHandlerL()->
  4883 		AddtoContactsQueryL( type ) )
  4883         AddtoContactsQueryL( type ) )
  4884 		{
  4884         {
  4885 		// Create buffer and strip scheme data such as mailto: and call:
  4885         // Create buffer and strip scheme data such as mailto: and call:
  4886 		HBufC* textData = aEmailAddress.AllocLC();
  4886         HBufC* textData = aEmailAddress.AllocLC();
  4887 		if ( textData->FindC( KMailtoPrefix ) == 0 )
  4887         if ( textData->FindC( KMailtoPrefix ) == 0 )
  4888 			{
  4888             {
  4889 			textData->Des().Delete( 0, KMailtoPrefix().Length() );
  4889             textData->Des().Delete( 0, KMailtoPrefix().Length() );
  4890 			}
  4890             }
  4891 		CFsDelayedLoader::InstanceL()->GetContactHandlerL()->AddToContactL(
  4891         CFsDelayedLoader::InstanceL()->GetContactHandlerL()->AddToContactL(
  4892 				*textData, EContactUpdateEmail, type, this );
  4892                 *textData, EContactUpdateEmail, type, this );
  4893 		CleanupStack::PopAndDestroy( textData );
  4893         CleanupStack::PopAndDestroy( textData );
  4894 		}
  4894         }
  4895 	}
  4895     }
  4896 
  4896 
  4897 void CFSEmailUiMailViewerVisualiser::SavePhoneNumberAsContactL(
  4897 void CFSEmailUiMailViewerVisualiser::SavePhoneNumberAsContactL(
  4898 	const TDesC& aPhoneNumber )
  4898     const TDesC& aPhoneNumber )
  4899 	{
  4899     {
  4900     FUNC_LOG;
  4900     FUNC_LOG;
  4901 	TAddToContactsType type;
  4901     TAddToContactsType type;
  4902 	// Query to "update existing" or "Create new"
  4902     // Query to "update existing" or "Create new"
  4903 	// --> EFALSE = user chose "cancel"
  4903     // --> EFALSE = user chose "cancel"
  4904 	if ( CFsDelayedLoader::InstanceL()->GetContactHandlerL()->
  4904     if ( CFsDelayedLoader::InstanceL()->GetContactHandlerL()->
  4905 		AddtoContactsQueryL( type ) )
  4905         AddtoContactsQueryL( type ) )
  4906 		{
  4906         {
  4907 		// Create buffer and strip scheme data such as mailto: and call:
  4907         // Create buffer and strip scheme data such as mailto: and call:
  4908 		HBufC* textData = aPhoneNumber.AllocLC();
  4908         HBufC* textData = aPhoneNumber.AllocLC();
  4909 		// Strip scheme prefix text if found
  4909         // Strip scheme prefix text if found
  4910 		if ( textData && textData->FindC( KCallPrefix ) == 0 )
  4910         if ( textData && textData->FindC( KCallPrefix ) == 0 )
  4911 			{
  4911             {
  4912 			textData->Des().Delete( 0, KCallPrefix().Length() );
  4912             textData->Des().Delete( 0, KCallPrefix().Length() );
  4913 			}
  4913             }
  4914 		else if ( textData && textData->FindC( KTelPrefix ) == 0 )
  4914         else if ( textData && textData->FindC( KTelPrefix ) == 0 )
  4915 			{
  4915             {
  4916 			textData->Des().Delete( 0, KTelPrefix().Length() );
  4916             textData->Des().Delete( 0, KTelPrefix().Length() );
  4917 			}
  4917             }
  4918 		else if ( textData && textData->FindC( KSmsPrefix ) == 0 )
  4918         else if ( textData && textData->FindC( KSmsPrefix ) == 0 )
  4919 			{
  4919             {
  4920 			textData->Des().Delete( 0, KSmsPrefix().Length() );
  4920             textData->Des().Delete( 0, KSmsPrefix().Length() );
  4921 			}
  4921             }
  4922 		else if ( textData && textData->FindC( KMmsPrefix ) == 0 )
  4922         else if ( textData && textData->FindC( KMmsPrefix ) == 0 )
  4923 			{
  4923             {
  4924 			textData->Des().Delete( 0, KMmsPrefix().Length() );
  4924             textData->Des().Delete( 0, KMmsPrefix().Length() );
  4925 			}
  4925             }
  4926 		CFsDelayedLoader::InstanceL()->GetContactHandlerL()->AddToContactL(
  4926         CFsDelayedLoader::InstanceL()->GetContactHandlerL()->AddToContactL(
  4927 			*textData, EContactUpdateNumber, type, this );
  4927             *textData, EContactUpdateNumber, type, this );
  4928 		CleanupStack::PopAndDestroy( textData );
  4928         CleanupStack::PopAndDestroy( textData );
  4929 		}
  4929         }
  4930 	}
  4930     }
  4931 
  4931 
  4932 
  4932 
  4933 void CFSEmailUiMailViewerVisualiser::FlagselectionCompleteL( TInt aSelection )
  4933 void CFSEmailUiMailViewerVisualiser::FlagselectionCompleteL( TInt aSelection )
  4934 	{
  4934     {
  4935     FUNC_LOG;
  4935     FUNC_LOG;
  4936 	// Set message follow up flag
  4936     // Set message follow up flag
  4937 	if ( iMessage && aSelection != KErrNotFound )
  4937     if ( iMessage && aSelection != KErrNotFound )
  4938 		{
  4938         {
  4939 		switch ( aSelection )
  4939         switch ( aSelection )
  4940 			{
  4940             {
  4941 			case EFollowUp:
  4941             case EFollowUp:
  4942 				{
  4942                 {
  4943 				iMessage->SetFlag( EFSMsgFlag_FollowUp );
  4943                 iMessage->SetFlag( EFSMsgFlag_FollowUp );
  4944 				iMessage->ResetFlag( EFSMsgFlag_FollowUpComplete );
  4944                 iMessage->ResetFlag( EFSMsgFlag_FollowUpComplete );
  4945 				iMessage->SaveMessageL();
  4945                 iMessage->SaveMessageL();
  4946 				}
  4946                 }
  4947 				break;
  4947                 break;
  4948 			case EFollowUpComplete:
  4948             case EFollowUpComplete:
  4949 				{
  4949                 {
  4950 				iMessage->SetFlag( EFSMsgFlag_FollowUpComplete );
  4950                 iMessage->SetFlag( EFSMsgFlag_FollowUpComplete );
  4951 				iMessage->ResetFlag( EFSMsgFlag_FollowUp );
  4951                 iMessage->ResetFlag( EFSMsgFlag_FollowUp );
  4952 				iMessage->SaveMessageL();
  4952                 iMessage->SaveMessageL();
  4953 				}
  4953                 }
  4954 				break;
  4954                 break;
  4955 			case EFollowUpClear:
  4955             case EFollowUpClear:
  4956 				{
  4956                 {
  4957 				iMessage->ResetFlag( EFSMsgFlag_FollowUp | EFSMsgFlag_FollowUpComplete );
  4957                 iMessage->ResetFlag( EFSMsgFlag_FollowUp | EFSMsgFlag_FollowUpComplete );
  4958 				iMessage->SaveMessageL();
  4958                 iMessage->SaveMessageL();
  4959 				}
  4959                 }
  4960 				break;
  4960                 break;
  4961 			default:
  4961             default:
  4962 				break;
  4962                 break;
  4963 			}
  4963             }
  4964 		}
  4964         }
  4965 	}
  4965     }
  4966 
  4966 
  4967 
  4967 
  4968 void CFSEmailUiMailViewerVisualiser::SetMailboxNameToStatusPaneL()
  4968 void CFSEmailUiMailViewerVisualiser::SetMailboxNameToStatusPaneL()
  4969 	{
  4969     {
  4970     FUNC_LOG;
  4970     FUNC_LOG;
  4971 	iAppUi.SetActiveMailboxNameToStatusPaneL();
  4971     iAppUi.SetActiveMailboxNameToStatusPaneL();
  4972 	}
  4972     }
  4973 
  4973 
  4974 void CFSEmailUiMailViewerVisualiser::GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const
  4974 void CFSEmailUiMailViewerVisualiser::GetParentLayoutsL( RPointerArray<CAlfVisual>& aLayoutArray ) const
  4975     {
  4975     {
  4976     if ( iTextViewer )
  4976     if ( iTextViewer )
  4977         {
  4977         {
  5085 void CFSEmailUiMailViewerVisualiser::HandleMailBoxEventL( TFSMailEvent aEvent,
  5085 void CFSEmailUiMailViewerVisualiser::HandleMailBoxEventL( TFSMailEvent aEvent,
  5086     TFSMailMsgId aMailbox, TAny* aParam1, TAny* /*aParam2*/, TAny* /*aParam3*/ )
  5086     TFSMailMsgId aMailbox, TAny* aParam1, TAny* /*aParam2*/, TAny* /*aParam3*/ )
  5087     {
  5087     {
  5088     FUNC_LOG;
  5088     FUNC_LOG;
  5089     if ( iFirstStartCompleted && iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() &&
  5089     if ( iFirstStartCompleted && iMessage && aMailbox.Id() == iAppUi.GetActiveMailboxId().Id() &&
  5090     	 aEvent == TFSEventMailDeleted && aParam1 ) // Safety, in list events that only concern active mailbox are handled
  5090          aEvent == TFSEventMailDeleted && aParam1 ) // Safety, in list events that only concern active mailbox are handled
  5091         {
  5091         {
  5092         TFSMailMsgId curMsgId = iMessage->GetMessageId();
  5092         TFSMailMsgId curMsgId = iMessage->GetMessageId();
  5093 		RArray<TFSMailMsgId>* removedEntries = static_cast<RArray<TFSMailMsgId>*>(aParam1);
  5093         RArray<TFSMailMsgId>* removedEntries = static_cast<RArray<TFSMailMsgId>*>(aParam1);
  5094 		for ( TInt i=0 ; i < removedEntries->Count() ; i++ )
  5094         for ( TInt i=0 ; i < removedEntries->Count() ; i++ )
  5095 			{
  5095             {
  5096 		    //<cmail>
  5096             //<cmail>
  5097 			if ( (curMsgId == (*removedEntries)[i]) &&
  5097             if ( (curMsgId == (*removedEntries)[i]) &&
  5098 					(iDeletedMessageFromMrui != curMsgId) )
  5098                     (iDeletedMessageFromMrui != curMsgId) )
  5099 				{
  5099                 {
  5100 				//</cmail>
  5100                 //</cmail>
  5101 	        	ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  5101                 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY );
  5102 	        	NavigateBackL();
  5102                 NavigateBackL();
  5103 				break;
  5103                 break;
  5104 				}
  5104                 }
  5105 			}
  5105             }
  5106         }
  5106         }
  5107     }
  5107     }
  5108 
  5108 
  5109 void CFSEmailUiMailViewerVisualiser::SendEventToAppUiL( TFSMailEvent aEventType )
  5109 void CFSEmailUiMailViewerVisualiser::SendEventToAppUiL( TFSMailEvent aEventType )
  5110     {
  5110     {
  5123 ///////////////////////////////////////////////////////////////////////////////////
  5123 ///////////////////////////////////////////////////////////////////////////////////
  5124 CFlagSelectionGlobalNoteHandler* CFlagSelectionGlobalNoteHandler::NewL( CFSEmailUiMailViewerVisualiser& aViewerVisualiser )
  5124 CFlagSelectionGlobalNoteHandler* CFlagSelectionGlobalNoteHandler::NewL( CFSEmailUiMailViewerVisualiser& aViewerVisualiser )
  5125     {
  5125     {
  5126     FUNC_LOG;
  5126     FUNC_LOG;
  5127     CFlagSelectionGlobalNoteHandler* self =
  5127     CFlagSelectionGlobalNoteHandler* self =
  5128        	 new (ELeave) CFlagSelectionGlobalNoteHandler( aViewerVisualiser );
  5128          new (ELeave) CFlagSelectionGlobalNoteHandler( aViewerVisualiser );
  5129     return self;
  5129     return self;
  5130     }
  5130     }
  5131 
  5131 
  5132 
  5132 
  5133 CFlagSelectionGlobalNoteHandler::~CFlagSelectionGlobalNoteHandler()
  5133 CFlagSelectionGlobalNoteHandler::~CFlagSelectionGlobalNoteHandler()
  5134 	{
  5134     {
  5135     FUNC_LOG;
  5135     FUNC_LOG;
  5136 	delete iPrompt;
  5136     delete iPrompt;
  5137 	delete iGlobalFlagQuery;
  5137     delete iGlobalFlagQuery;
  5138 	}
  5138     }
  5139 
  5139 
  5140 void CFlagSelectionGlobalNoteHandler::Cancel()
  5140 void CFlagSelectionGlobalNoteHandler::Cancel()
  5141 	{
  5141     {
  5142     FUNC_LOG;
  5142     FUNC_LOG;
  5143 	}
  5143     }
  5144 
  5144 
  5145 void CFlagSelectionGlobalNoteHandler::LaunchFlagListQueryDialogL()
  5145 void CFlagSelectionGlobalNoteHandler::LaunchFlagListQueryDialogL()
  5146 	{
  5146     {
  5147     FUNC_LOG;
  5147     FUNC_LOG;
  5148 	iSelection = 0;
  5148     iSelection = 0;
  5149 	if ( !iPrompt )
  5149     if ( !iPrompt )
  5150 		{
  5150         {
  5151 	    iPrompt = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_VIEWER_FLAG_DIALOG_HEADER );
  5151         iPrompt = StringLoader::LoadL( R_FREESTYLE_EMAIL_UI_VIEWER_FLAG_DIALOG_HEADER );
  5152 		}
  5152         }
  5153  	if ( !iGlobalFlagQuery )
  5153     if ( !iGlobalFlagQuery )
  5154 	 	{
  5154         {
  5155 	    iGlobalFlagQuery = CAknGlobalListQuery::NewL();
  5155         iGlobalFlagQuery = CAknGlobalListQuery::NewL();
  5156 		iGlobalFlagQuery->SetHeadingL( *iPrompt ); // Set query heading.
  5156         iGlobalFlagQuery->SetHeadingL( *iPrompt ); // Set query heading.
  5157  		}
  5157         }
  5158 
  5158 
  5159 	CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat( 3 );
  5159     CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat( 3 );
  5160 	CleanupStack::PushL( array );
  5160     CleanupStack::PushL( array );
  5161 	// Add follow up text
  5161     // Add follow up text
  5162 	HBufC* followUp = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FLAG_FOLLOW_UP );
  5162     HBufC* followUp = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FLAG_FOLLOW_UP );
  5163     array->AppendL( *followUp );
  5163     array->AppendL( *followUp );
  5164 	CleanupStack::PopAndDestroy( followUp );
  5164     CleanupStack::PopAndDestroy( followUp );
  5165 
  5165 
  5166 	// Add flag complete text
  5166     // Add flag complete text
  5167 	HBufC* completeFlag = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FLAG_COMPLETE );
  5167     HBufC* completeFlag = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FLAG_COMPLETE );
  5168     array->AppendL( *completeFlag );
  5168     array->AppendL( *completeFlag );
  5169 	CleanupStack::PopAndDestroy( completeFlag );
  5169     CleanupStack::PopAndDestroy( completeFlag );
  5170 
  5170 
  5171 	// Add clear flag text
  5171     // Add clear flag text
  5172 	HBufC* clearFlag = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FLAG_CLEAR );
  5172     HBufC* clearFlag = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_FLAG_CLEAR );
  5173     array->AppendL( *clearFlag );
  5173     array->AppendL( *clearFlag );
  5174 	CleanupStack::PopAndDestroy( clearFlag );
  5174     CleanupStack::PopAndDestroy( clearFlag );
  5175 
  5175 
  5176     // Show query
  5176     // Show query
  5177     iGlobalFlagQuery->ShowListQueryL( array, iStatus, iSelection );
  5177     iGlobalFlagQuery->ShowListQueryL( array, iStatus, iSelection );
  5178 	CleanupStack::PopAndDestroy( array );
  5178     CleanupStack::PopAndDestroy( array );
  5179 
  5179 
  5180 	// Set active
  5180     // Set active
  5181     SetActive();
  5181     SetActive();
  5182 	}
  5182     }
  5183 
  5183 
  5184 void CFlagSelectionGlobalNoteHandler::RunL()
  5184 void CFlagSelectionGlobalNoteHandler::RunL()
  5185 	{
  5185     {
  5186     FUNC_LOG;
  5186     FUNC_LOG;
  5187     TInt status = iStatus.Int();
  5187     TInt status = iStatus.Int();
  5188 	iViewerVisualiser.FlagselectionCompleteL( status );
  5188     iViewerVisualiser.FlagselectionCompleteL( status );
  5189 	}
  5189     }
  5190 
  5190 
  5191 void CFlagSelectionGlobalNoteHandler::DoCancel()
  5191 void CFlagSelectionGlobalNoteHandler::DoCancel()
  5192 	{
  5192     {
  5193     FUNC_LOG;
  5193     FUNC_LOG;
  5194 	}
  5194     }
  5195 
  5195 
  5196 TInt CFlagSelectionGlobalNoteHandler::RunError( TInt /*aError*/ )
  5196 TInt CFlagSelectionGlobalNoteHandler::RunError( TInt /*aError*/ )
  5197 	{
  5197     {
  5198     FUNC_LOG;
  5198     FUNC_LOG;
  5199 	TInt err( KErrNone );
  5199     TInt err( KErrNone );
  5200 	return err;
  5200     return err;
  5201 	}
  5201     }
  5202 
  5202 
  5203 CFlagSelectionGlobalNoteHandler::CFlagSelectionGlobalNoteHandler(  CFSEmailUiMailViewerVisualiser& aViewerVisualiser )
  5203 CFlagSelectionGlobalNoteHandler::CFlagSelectionGlobalNoteHandler(  CFSEmailUiMailViewerVisualiser& aViewerVisualiser )
  5204     : CActive ( EPriorityHigh ),
  5204     : CActive ( EPriorityHigh ),
  5205     iViewerVisualiser( aViewerVisualiser )
  5205     iViewerVisualiser( aViewerVisualiser )
  5206     {
  5206     {