emailuis/emailui/src/FreestyleEmailUiHtmlViewerView.cpp
changeset 3 a4d6f1ea0416
parent 2 5253a20d2a1e
child 4 e7aa27f58ae1
equal deleted inserted replaced
2:5253a20d2a1e 3:a4d6f1ea0416
    54 #include "FreestyleEmailUiUtilities.h"
    54 #include "FreestyleEmailUiUtilities.h"
    55 #include "FreestyleEmailUiShortcutBinding.h"
    55 #include "FreestyleEmailUiShortcutBinding.h"
    56 #include "FreestyleEmailCenRepHandler.h"
    56 #include "FreestyleEmailCenRepHandler.h"
    57 #include "FreestyleEmailUiAttachmentsListModel.h"
    57 #include "FreestyleEmailUiAttachmentsListModel.h"
    58 #include "FreestyleEmailUiConstants.h"
    58 #include "FreestyleEmailUiConstants.h"
    59 #include "FreestyleAttachmentDownloadProgressBar.h"
       
    60 #include "FSEmail.pan"
    59 #include "FSEmail.pan"
    61 #include "CFSMailCommon.h"
    60 #include "CFSMailCommon.h"
    62 
    61 
    63 #include "FreestyleEmailUiMailViewerConstants.h"
    62 #include "FreestyleEmailUiMailViewerConstants.h"
    64 #include "FSDelayedLoader.h"
    63 #include "FSDelayedLoader.h"
   112         {
   111         {
   113         iContainer->CancelFetch();
   112         iContainer->CancelFetch();
   114         }
   113         }
   115     delete iContainer;
   114     delete iContainer;
   116     delete iAttachmentsListModel;
   115     delete iAttachmentsListModel;
   117     delete iProgressBar;
       
   118 
   116 
   119     delete iOpenMessages;
   117     delete iOpenMessages;
   120     iOpenMessages = NULL;
   118     iOpenMessages = NULL;
   121     delete iEmbeddedMessages;
   119     delete iEmbeddedMessages;
   122     iEmbeddedMessages = NULL;
   120     iEmbeddedMessages = NULL;
   123     iMessage = NULL;
   121     iMessage = NULL;
   124     
   122     
   125     delete iMailBox; 
   123     delete iMailBox; 
   126     iMailBox = NULL;
   124     iMailBox = NULL;
   127     delete iAsyncCallback;
   125     delete iAsyncCallback;
   128 
       
   129 
       
   130    
       
   131     }
   126     }
   132 
   127 
   133 void CFsEmailUiHtmlViewerView::ConstructL()
   128 void CFsEmailUiHtmlViewerView::ConstructL()
   134     {
   129     {
   135     FUNC_LOG;
   130     FUNC_LOG;
   449     {
   444     {
   450     FUNC_LOG;
   445     FUNC_LOG;
   451 
   446 
   452     if ( iContainer )
   447     if ( iContainer )
   453         {
   448         {
       
   449         iContainer->HideAttacthmentDownloadStatus();
   454         iContainer->MakeVisible( EFalse );
   450         iContainer->MakeVisible( EFalse );
   455         iAppUi.RemoveFromStack( iContainer );
   451         iAppUi.RemoveFromStack( iContainer );
   456         }
   452         }
   457     }
   453     }
   458 
   454 
  1653         TFsEmailUiUtility::ShowInfoNoteL( R_FSE_VIEWER_NOTE_ATTACHMENT_DOWNLOADING_PROGRESS );
  1649         TFsEmailUiUtility::ShowInfoNoteL( R_FSE_VIEWER_NOTE_ATTACHMENT_DOWNLOADING_PROGRESS );
  1654         }
  1650         }
  1655     else if ( aAttachment.downloadProgress != KComplete )
  1651     else if ( aAttachment.downloadProgress != KComplete )
  1656         {
  1652         {
  1657         DownloadAttachmentL( aAttachment );
  1653         DownloadAttachmentL( aAttachment );
       
  1654         if ( iContainer && !iContainer->AttacthmentDownloadStatusVisible() )
       
  1655             {
       
  1656             iContainer->ShowAttacthmentDownloadStatusL( TFSProgress::EFSStatus_Status, aAttachment );
       
  1657             }
  1658         }
  1658         }
  1659     else
  1659     else
  1660         {
  1660         {
  1661         TFsEmailUiUtility::OpenAttachmentL( aAttachment.partData );
  1661         TFsEmailUiUtility::OpenAttachmentL( aAttachment.partData );
  1662         }
  1662         }
  1667     TFileName fileName;
  1667     TFileName fileName;
  1668     if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) )
  1668     if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) )
  1669         {
  1669         {
  1670         TInt savedCount( 0 );
  1670         TInt savedCount( 0 );
  1671         TBool downloadRequired = iAttachmentsListModel->SaveAttachmentL( aAttachment, fileName, savedCount );
  1671         TBool downloadRequired = iAttachmentsListModel->SaveAttachmentL( aAttachment, fileName, savedCount );
       
  1672         if ( downloadRequired && iContainer && !iContainer->AttacthmentDownloadStatusVisible() )
       
  1673             {
       
  1674             iContainer->ShowAttacthmentDownloadStatusL( TFSProgress::EFSStatus_Status, aAttachment );
       
  1675             }
       
  1676         
  1672         if ( savedCount )
  1677         if ( savedCount )
  1673             {
  1678             {
  1674             TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( savedCount );        
  1679             TFsEmailUiUtility::ShowFilesSavedToFolderNoteL( savedCount );        
  1675             }
  1680             }
  1676         }
  1681         }
  1680     {
  1685     {
  1681     TFileName fileName;
  1686     TFileName fileName;
  1682     if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) )
  1687     if ( TFsEmailUiUtility::ShowSaveFolderDialogL( fileName ) )
  1683         {
  1688         {
  1684         TBool downloadRequired = iAttachmentsListModel->SaveAllAttachmentsL( fileName );
  1689         TBool downloadRequired = iAttachmentsListModel->SaveAllAttachmentsL( fileName );
       
  1690         if ( downloadRequired && iContainer && !iContainer->AttacthmentDownloadStatusVisible() )
       
  1691             {
       
  1692             for ( TInt i = 0; i < iAttachmentsListModel->GetModel().Count(); i++ )
       
  1693                 {
       
  1694                 const TAttachmentData& attachment = iAttachmentsListModel->GetModel()[i];
       
  1695                 if ( attachment.downloadProgress < KComplete )
       
  1696                     {
       
  1697                     iContainer->ShowAttacthmentDownloadStatusL( TFSProgress::EFSStatus_Status, attachment );
       
  1698                     break;
       
  1699                     }
       
  1700                 }
       
  1701             }
  1685         }
  1702         }
  1686     }
  1703     }
  1687 
  1704 
  1688 void CFsEmailUiHtmlViewerView::RemoveAttachmentContentL( const TAttachmentData& aAttachment )
  1705 void CFsEmailUiHtmlViewerView::RemoveAttachmentContentL( const TAttachmentData& aAttachment )
  1689     {
  1706     {
  1715         const TPartData& aPart, 
  1732         const TPartData& aPart, 
  1716         const TFSProgress& aEvent )
  1733         const TFSProgress& aEvent )
  1717     {
  1734     {
  1718     FUNC_LOG;
  1735     FUNC_LOG;
  1719     
  1736     
  1720     if ( iMessage )
  1737     if ( !iMessage || !iContainer || ( aEvent.iError != KErrNone ) )
  1721         {
  1738         return;
  1722         if ( !iProgressBar )
  1739     
  1723             {
  1740     TAttachmentData* attachment = NULL;
  1724             iProgressBar = CFreestyleAttachmentDownloadProgressBar::NewL();
  1741     const RArray<TAttachmentData>& attachments = iAttachmentsListModel->GetModel();
  1725             }
  1742     for ( TInt i=0; i < attachments.Count(); i++ )
  1726         
  1743         {
  1727         for ( TInt i=0; i < iAttachmentsListModel->GetModel().Count(); i++ )
  1744         if ( attachments[i].partData == aPart )
  1728             {
  1745             {
  1729             if ( iAttachmentsListModel->GetModel()[i].partData == aPart )
  1746             attachment = CONST_CAST( TAttachmentData*, &iAttachmentsListModel->GetModel()[i] );
  1730                 {
  1747             break;
  1731                 TAttachmentData& attachment = CONST_CAST( TAttachmentData&, iAttachmentsListModel->GetModel()[i] );
  1748             }
  1732                 
  1749         }
  1733                 if ( aEvent.iError )
  1750     
       
  1751     if ( attachment )
       
  1752         {
       
  1753         switch ( aEvent.iProgressStatus )
       
  1754             {
       
  1755             case TFSProgress::EFSStatus_Status:
       
  1756                 {
       
  1757                 if ( aEvent.iMaxCount > 0 && aEvent.iCounter > 0 )
  1734                     {
  1758                     {
  1735                     iProgressBar->HideL();
  1759                     attachment->downloadProgress = KComplete * aEvent.iCounter / aEvent.iMaxCount;
  1736                     }
  1760                     }
  1737                 else
  1761                 else
  1738                     {
  1762                     {
  1739                     switch ( aEvent.iProgressStatus )
  1763                     attachment->downloadProgress = KNone;
  1740                         {
       
  1741                         case TFSProgress::EFSStatus_Status:
       
  1742                             {
       
  1743                             if ( aEvent.iMaxCount > 0 && aEvent.iCounter > 0 )
       
  1744                                 {
       
  1745                                 attachment.downloadProgress = KComplete * aEvent.iCounter / aEvent.iMaxCount;
       
  1746                                 }
       
  1747                             else
       
  1748                                 {
       
  1749                                 attachment.downloadProgress = KNone;
       
  1750                                 }
       
  1751                             iProgressBar->UpdateL( attachment );
       
  1752                             }
       
  1753                         break;
       
  1754                         
       
  1755                         case TFSProgress::EFSStatus_RequestComplete:
       
  1756                             {
       
  1757                             attachment.downloadProgress = KComplete;
       
  1758                             iProgressBar->UpdateL( attachment );
       
  1759                             }
       
  1760                         break;
       
  1761                         
       
  1762                         case TFSProgress::EFSStatus_RequestCancelled:
       
  1763                             {
       
  1764                             iProgressBar->HideL();
       
  1765                             }
       
  1766                         break;
       
  1767                         
       
  1768                         default:                            
       
  1769                             break;
       
  1770                         }
       
  1771                     }
  1764                     }
       
  1765                 }
       
  1766             break;
       
  1767             
       
  1768             case TFSProgress::EFSStatus_RequestComplete:
       
  1769                 {
       
  1770                 attachment->downloadProgress = KComplete;
       
  1771                 }
       
  1772             break;
       
  1773             
       
  1774             default:
  1772                 break;
  1775                 break;
  1773                 }
  1776             }
  1774             }
  1777         
       
  1778         iContainer->ShowAttacthmentDownloadStatusL( aEvent.iProgressStatus, *attachment );
  1775         }
  1779         }
  1776     }
  1780     }
  1777 
  1781 
  1778 void CFsEmailUiHtmlViewerView::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart )
  1782 void CFsEmailUiHtmlViewerView::RequestResponseL( const TFSProgress& aEvent, const TPartData& aPart )
  1779     {
  1783     {