emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp
changeset 4 e7aa27f58ae1
parent 3 a4d6f1ea0416
child 8 e1b6206813b4
equal deleted inserted replaced
3:a4d6f1ea0416 4:e7aa27f58ae1
    60 #include "CFSMailCommon.h"
    60 #include "CFSMailCommon.h"
    61 
    61 
    62 #include "FreestyleEmailUiMailViewerConstants.h"
    62 #include "FreestyleEmailUiMailViewerConstants.h"
    63 #include "FSDelayedLoader.h"
    63 #include "FSDelayedLoader.h"
    64 #include "FreestyleMessageHeaderURL.h"
    64 #include "FreestyleMessageHeaderURL.h"
       
    65 #include "FreestyleEmailUiAknStatusIndicator.h"
    65 #include <akntoolbar.h>
    66 #include <akntoolbar.h>
    66 // CONSTANTS
    67 // CONSTANTS
    67 // Zoom levels available on the UI
    68 // Zoom levels available on the UI
    68 const TInt KZoomLevels[] = { 75, 100, 125, 150 };
    69 const TInt KZoomLevels[] = { 75, 100, 125, 150 };
    69 const TInt KZoomLevelCount = sizeof( KZoomLevels ) / sizeof( TInt );
    70 const TInt KZoomLevelCount = sizeof( KZoomLevels ) / sizeof( TInt );
   444     {
   445     {
   445     FUNC_LOG;
   446     FUNC_LOG;
   446 
   447 
   447     if ( iContainer )
   448     if ( iContainer )
   448         {
   449         {
   449         iContainer->HideAttacthmentDownloadStatus();
   450         iContainer->HideDownloadStatus();
   450         iContainer->MakeVisible( EFalse );
   451         iContainer->MakeVisible( EFalse );
   451         iAppUi.RemoveFromStack( iContainer );
   452         iAppUi.RemoveFromStack( iContainer );
   452         }
   453         }
   453     }
   454     }
   454 
   455 
   474 //
   475 //
   475 void CFsEmailUiHtmlViewerView::ChildDoActivateL( const TVwsViewId& /*aPrevViewId*/,
   476 void CFsEmailUiHtmlViewerView::ChildDoActivateL( const TVwsViewId& /*aPrevViewId*/,
   476         TUid aCustomMessageId, const TDesC8& aCustomMessage )
   477         TUid aCustomMessageId, const TDesC8& aCustomMessage )
   477     {
   478     {
   478     FUNC_LOG;
   479     FUNC_LOG;
   479     
       
   480     TBool bodypartNotFound ( EFalse );
       
   481     
   480     
   482     if ( iMrObserverToInform && 
   481     if ( iMrObserverToInform && 
   483          aCustomMessageId == KStartViewerReturnToPreviousMsg )
   482          aCustomMessageId == KStartViewerReturnToPreviousMsg )
   484         {
   483         {
   485         // If returning from view launched by MRUI, complete the ongoing
   484         // If returning from view launched by MRUI, complete the ongoing
   521     
   520     
   522     if ( !iContainer )
   521     if ( !iContainer )
   523         {
   522         {
   524         iContainer = CFsEmailUiHtmlViewerContainer::NewL( iAppUi, *this );
   523         iContainer = CFsEmailUiHtmlViewerContainer::NewL( iAppUi, *this );
   525         }
   524         }
   526     else if ( iContainer ) // Container exists, make sure that it has a correct rect
   525    
   527         {
       
   528         iContainer->SetRect( ContainerRect() );
       
   529         }
       
   530 
       
   531     // Check whether this activation is actually for a meeting request
   526     // Check whether this activation is actually for a meeting request
   532     TBool openedInMrViewer( EFalse );    
   527     TBool openedInMrViewer( EFalse );    
   533     if ( THtmlViewerActivationData::EMailMessage == iActivationData.iActivationDataType )
   528     if ( THtmlViewerActivationData::EMailMessage == iActivationData.iActivationDataType )
   534         {
   529         {
   535         openedInMrViewer = IsOpenedInMRViewerL();
   530         openedInMrViewer = IsOpenedInMRViewerL();
   596             		{
   591             		{
   597 		            iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
   592 		            iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
   598 		            TPartData msgPartData( iActivationData.iMailBoxId, iActivationData.iFolderId, iActivationData.iMessageId);
   593 		            TPartData msgPartData( iActivationData.iMailBoxId, iActivationData.iFolderId, iActivationData.iMessageId);
   599 		            iAttachmentsListModel->UpdateListL( msgPartData );
   594 		            iAttachmentsListModel->UpdateListL( msgPartData );
   600                        
   595                        
   601             		TRAPD( error, LoadContentFromMailMessageL( iMessage, ETrue ) );
   596             		LoadContentFromMailMessageL( iMessage, ETrue );
   602             		if ( error == KErrNotFound || error == KErrInUse || error == KErrLocked )
       
   603             		    {
       
   604             		    bodypartNotFound = ETrue;
       
   605             		    }
       
   606             		else if ( error != KErrNone)
       
   607             		    {
       
   608             		    User::Leave( error );
       
   609             		    }
       
   610             		}
   597             		}
   611                 
   598                 
   612                 }
   599                 }
   613             else
   600             else
   614                 {
   601                 {
   652             else{
   639             else{
   653                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );         
   640                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );         
   654                 }                
   641                 }                
   655             
   642             
   656     
   643     
   657             TRAPD( error, LoadContentFromMailMessageL( iOpenMessages->Head(), ETrue ) );
   644             LoadContentFromMailMessageL( iOpenMessages->Head(), ETrue );
   658             if ( error == KErrNotFound || error == KErrInUse || error == KErrLocked )
       
   659                 {
       
   660                 bodypartNotFound = ETrue;
       
   661                 }
       
   662             else if ( error != KErrNone)
       
   663                 {
       
   664                 User::Leave( error );
       
   665                 }
       
   666             
   645             
   667             // update tool bar as some action menu boton should not appear in embbeded messages.
   646             // update tool bar as some action menu boton should not appear in embbeded messages.
   668             UpdateToolbarL();
   647             UpdateToolbarL();
   669             
   648             
   670             }
   649             }
   708                 }
   687                 }
   709         CleanupStack::PopAndDestroy( displayName );
   688         CleanupStack::PopAndDestroy( displayName );
   710             }
   689             }
   711         }
   690         }
   712     
   691     
   713     if ( !openedInMrViewer )
   692     if ( !openedInMrViewer && iMessage)
   714         {
   693         {
   715         CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL();
   694         CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL();
   716         TFetchedType type;
   695         TFetchedType type;
   717         if( htmlBodyPart )
   696         if ( htmlBodyPart )
   718             {
   697             {
   719             type = EMessageHtmlBodyPart;
   698             type = EMessageHtmlBodyPart;
       
   699             delete htmlBodyPart;
   720             }
   700             }
   721         else
   701         else
   722             {
   702             {
   723             type = EMessagePlainTextBodyPart;
   703             type = EMessagePlainTextBodyPart;
   724             }
   704             }
   725         if( !MessageStructureKnown(*iMessage) )
   705 
   726             {
   706         if ( !MessageStructureKnown(*iMessage) )
       
   707             {
       
   708             iContainer->DisplayStatusIndicatorL();
   727             StartWaitedFetchingL(EMessageStructure);
   709             StartWaitedFetchingL(EMessageStructure);
   728             iFetchingAlready = ETrue;
   710             iFetchingAlready = ETrue;
   729             }
   711             }
   730         else if ( bodypartNotFound )
   712         else 
   731             {
   713             {
   732             iAsyncProcessComplete = EFalse;
   714             TBool bodypartNotFound ( EFalse );
   733             iFetchingAlready = EFalse;
   715             if ( type == EMessagePlainTextBodyPart )
   734             iStartAsyncFetchType = type;
   716                 {
   735             if(iMessage)
   717                 CFSMailMessagePart* textBodyPart = iMessage->PlainTextBodyPartL();
   736                 {
   718                 if ( textBodyPart )
   737                 StartFetchingMessagePartL( *iMessage, type );
   719                     {
       
   720                     delete textBodyPart;
       
   721                     }
       
   722                 else
       
   723                     {
       
   724                     bodypartNotFound = ETrue;
       
   725                     }                
       
   726                 }
       
   727             
       
   728             if ( bodypartNotFound )
       
   729                 {
       
   730                 iAsyncProcessComplete = EFalse;
       
   731                 iFetchingAlready = EFalse;
       
   732                 iStartAsyncFetchType = type;
       
   733                 if(iMessage)
       
   734                     {
       
   735                     StartFetchingMessagePartL( *iMessage, type );
       
   736                     }
   738                 }
   737                 }
   739             }
   738             }
   740        }
   739        }
   741     iNextOrPrevMessageSelected = EFalse;
   740     iNextOrPrevMessageSelected = EFalse;
       
   741     
       
   742     //update rect only if it has changed from previous time.
       
   743     if ( iContainer->Rect() != ContainerRect()  )
       
   744         {
       
   745         iContainer->SetRect( ContainerRect() );
       
   746         }
       
   747 
       
   748     
   742     }
   749     }
   743 
   750 
   744 // -----------------------------------------------------------------------------
   751 // -----------------------------------------------------------------------------
   745 // CFsEmailUiHtmlViewerView::OfferToolbarEventL
   752 // CFsEmailUiHtmlViewerView::OfferToolbarEventL
   746 // -----------------------------------------------------------------------------
   753 // -----------------------------------------------------------------------------
  1649         TFsEmailUiUtility::ShowInfoNoteL( R_FSE_VIEWER_NOTE_ATTACHMENT_DOWNLOADING_PROGRESS );
  1656         TFsEmailUiUtility::ShowInfoNoteL( R_FSE_VIEWER_NOTE_ATTACHMENT_DOWNLOADING_PROGRESS );
  1650         }
  1657         }
  1651     else if ( aAttachment.downloadProgress != KComplete )
  1658     else if ( aAttachment.downloadProgress != KComplete )
  1652         {
  1659         {
  1653         DownloadAttachmentL( aAttachment );
  1660         DownloadAttachmentL( aAttachment );
  1654         if ( iContainer && !iContainer->AttacthmentDownloadStatusVisible() )
  1661         if ( iContainer && !iContainer->AttachmentDownloadStatusVisible() )
  1655             {
  1662             {
  1656             iContainer->ShowAttacthmentDownloadStatusL( TFSProgress::EFSStatus_Status, aAttachment );
  1663             iContainer->ShowAttachmentDownloadStatusL( TFSProgress::EFSStatus_Status, aAttachment );
  1657             }
  1664             }
  1658         }
  1665         }
  1659     else
  1666     else
  1660         {
  1667         {
  1661         TFsEmailUiUtility::OpenAttachmentL( aAttachment.partData );
  1668         TFsEmailUiUtility::OpenAttachmentL( aAttachment.partData );
  1667     TFileName fileName;
  1674     TFileName fileName;
  1668     if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) )
  1675     if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) )
  1669         {
  1676         {
  1670         TInt savedCount( 0 );
  1677         TInt savedCount( 0 );
  1671         TBool downloadRequired = iAttachmentsListModel->SaveAttachmentL( aAttachment, fileName, savedCount );
  1678         TBool downloadRequired = iAttachmentsListModel->SaveAttachmentL( aAttachment, fileName, savedCount );
  1672         if ( downloadRequired && iContainer && !iContainer->AttacthmentDownloadStatusVisible() )
  1679         if ( downloadRequired && iContainer && !iContainer->AttachmentDownloadStatusVisible() )
  1673             {
  1680             {
  1674             iContainer->ShowAttacthmentDownloadStatusL( TFSProgress::EFSStatus_Status, aAttachment );
  1681             iContainer->ShowAttachmentDownloadStatusL( TFSProgress::EFSStatus_Status, aAttachment );
  1675             }
  1682             }
  1676         
  1683         
  1677         if ( savedCount )
  1684         if ( savedCount )
  1678             {
  1685             {
  1679             TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( savedCount );        
  1686             TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( savedCount );        
  1685     {
  1692     {
  1686     TFileName fileName;
  1693     TFileName fileName;
  1687     if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) )
  1694     if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) )
  1688         {
  1695         {
  1689         TBool downloadRequired = iAttachmentsListModel->SaveAllAttachmentsL( fileName );
  1696         TBool downloadRequired = iAttachmentsListModel->SaveAllAttachmentsL( fileName );
  1690         if ( downloadRequired && iContainer && !iContainer->AttacthmentDownloadStatusVisible() )
  1697         if ( downloadRequired && iContainer && !iContainer->AttachmentDownloadStatusVisible() )
  1691             {
  1698             {
  1692             for ( TInt i = 0; i < iAttachmentsListModel->GetModel().Count(); i++ )
  1699             for ( TInt i = 0; i < iAttachmentsListModel->GetModel().Count(); i++ )
  1693                 {
  1700                 {
  1694                 const TAttachmentData& attachment = iAttachmentsListModel->GetModel()[i];
  1701                 const TAttachmentData& attachment = iAttachmentsListModel->GetModel()[i];
  1695                 if ( attachment.downloadProgress < KComplete )
  1702                 if ( attachment.downloadProgress < KComplete )
  1696                     {
  1703                     {
  1697                     iContainer->ShowAttacthmentDownloadStatusL( TFSProgress::EFSStatus_Status, attachment );
  1704                     iContainer->ShowAttachmentDownloadStatusL( TFSProgress::EFSStatus_Status, attachment );
  1698                     break;
  1705                     break;
  1699                     }
  1706                     }
  1700                 }
  1707                 }
  1701             }
  1708             }
  1702         }
  1709         }
  1773             
  1780             
  1774             default:
  1781             default:
  1775                 break;
  1782                 break;
  1776             }
  1783             }
  1777         
  1784         
  1778         iContainer->ShowAttacthmentDownloadStatusL( aEvent.iProgressStatus, *attachment );
  1785         iContainer->ShowAttachmentDownloadStatusL( aEvent.iProgressStatus, *attachment );
  1779         }
  1786         }
  1780     }
  1787     }
  1781 
  1788 
  1782 void CFsEmailUiHtmlViewerView::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart )
  1789 void CFsEmailUiHtmlViewerView::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart )
  1783     {
  1790     {
  2183 // -----------------------------------------------------------------------------
  2190 // -----------------------------------------------------------------------------
  2184 void CFsEmailUiHtmlViewerView::StartFetchingMessagePartL( CFSMailMessage& aMessagePtr,
  2191 void CFsEmailUiHtmlViewerView::StartFetchingMessagePartL( CFSMailMessage& aMessagePtr,
  2185                                             TFetchedType aFetchedContentType )
  2192                                             TFetchedType aFetchedContentType )
  2186     {
  2193     {
  2187     FUNC_LOG;
  2194     FUNC_LOG;
       
  2195     iContainer->DisplayStatusIndicatorL();
  2188     if( aFetchedContentType == EMessagePlainTextBodyPart )
  2196     if( aFetchedContentType == EMessagePlainTextBodyPart )
  2189         {
  2197         {
  2190         CFSMailMessagePart* textPart = aMessagePtr.PlainTextBodyPartL();
  2198         CFSMailMessagePart* textPart = aMessagePtr.PlainTextBodyPartL();
  2191         CleanupStack::PushL( textPart );
  2199         CleanupStack::PushL( textPart );
  2192         TFSMailMsgId textPartId = textPart->GetPartId();
  2200         TFSMailMsgId textPartId = textPart->GetPartId();
  2293                 UpdateMessagePtrL( mailboxId, folderId, messageId );
  2301                 UpdateMessagePtrL( mailboxId, folderId, messageId );
  2294                 reloadContent = ETrue;
  2302                 reloadContent = ETrue;
  2295                 }
  2303                 }
  2296             }
  2304             }
  2297         }
  2305         }
  2298     
  2306     if(iContainer)
       
  2307         {
       
  2308         iContainer->HideDownloadStatus();
       
  2309         }
  2299     if ( reloadContent )
  2310     if ( reloadContent )
  2300         {
  2311         {
  2301     
  2312     
  2302         if (  iContainer )
  2313         if (  iContainer )
  2303             {
  2314             {
  2304             iContainer->ResetContent();
  2315             iContainer->ResetContent();                
  2305             }
  2316 			if( iMessage )
  2306                 
  2317 				{
  2307         if( iMessage )
  2318 				LoadContentFromMailMessageL( iMessage , EFalse);  
  2308             {
  2319 				SetMskL();
  2309             LoadContentFromMailMessageL( iMessage , EFalse);  
  2320 				}
  2310             SetMskL();
       
  2311             }
  2321             }
  2312         }
  2322         }
  2313             
  2323             
  2314     
  2324     
  2315     if(iAsyncProcessComplete && iWaitDialog && iDialogNotDismissed)
  2325     if(iAsyncProcessComplete && iWaitDialog && iDialogNotDismissed)
  2668             }
  2678             }
  2669             break;
  2679             break;
  2670         case EESMRCmdDownloadAttachment:
  2680         case EESMRCmdDownloadAttachment:
  2671         case EESMRCmdDownloadAllAttachments:
  2681         case EESMRCmdDownloadAllAttachments:
  2672             {
  2682             {
  2673             if(iAttachmentsListModel == NULL)
  2683             if( !iAttachmentsListModel )
  2674                 {
  2684                 {
  2675                 iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
  2685                 iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
  2676                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );
  2686                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );
  2677                 }
  2687                 }
  2678             // Check that message has attachments to display
  2688             // Check that message has attachments to display
  2685             }
  2695             }
  2686             break;
  2696             break;
  2687         case EESMRCmdSaveAttachment:
  2697         case EESMRCmdSaveAttachment:
  2688         case EESMRCmdSaveAllAttachments:
  2698         case EESMRCmdSaveAllAttachments:
  2689             {
  2699             {
  2690             if(iAttachmentsListModel == NULL)
  2700             if( !iAttachmentsListModel )
  2691                 {
  2701                 {
  2692                 iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
  2702                 iAttachmentsListModel = CFSEmailUiAttachmentsListModel::NewL( iAppUi, *this );
  2693                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );
  2703                 iAttachmentsListModel->UpdateListL( iOpenMessages->Head() );
  2694                 }
  2704                 }
  2695             // Check that message has attachments to display
  2705             // Check that message has attachments to display