emailuis/emailui/src/FreestyleEmailUiHtmlViewerContainer.cpp
changeset 4 e7aa27f58ae1
parent 3 a4d6f1ea0416
child 8 e1b6206813b4
equal deleted inserted replaced
3:a4d6f1ea0416 4:e7aa27f58ae1
   149     iMessageParts.Close();
   149     iMessageParts.Close();
   150     delete iEventHandler;
   150     delete iEventHandler;
   151     delete iBrCtlInterface;
   151     delete iBrCtlInterface;
   152     iConnection.Close();
   152     iConnection.Close();
   153     iSocketServer.Close();
   153     iSocketServer.Close();
   154     
   154     delete iStatusIndicator;
   155     delete iOverlayControlNext;
   155     delete iOverlayControlNext;
   156     delete iOverlayControlPrev;
   156     delete iOverlayControlPrev;
   157     }
   157     }
   158 
   158 
   159 // <cmail> Because of browser changes, followings must be performed before iAppUi.exit()
   159 // <cmail> Because of browser changes, followings must be performed before iAppUi.exit()
   194 
   194 
   195     // Set browsercontrol to whole screen
   195     // Set browsercontrol to whole screen
   196     TRect rect( TPoint(), Size() );
   196     TRect rect( TPoint(), Size() );
   197 
   197 
   198     iBrCtlInterface = CreateBrowserControlL( this, rect, brCtlCapabilities,
   198     iBrCtlInterface = CreateBrowserControlL( this, rect, brCtlCapabilities,
   199         TBrCtlDefs::ECommandIdBase, NULL, this, this );
   199         TBrCtlDefs::ECommandIdBase, NULL, this, this, NULL, NULL, this, NULL );
   200 
   200 
   201     iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsEmbedded, ETrue );
   201     iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsEmbedded, ETrue );
   202     iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsAutoLoadImages, ETrue );
   202     iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsAutoLoadImages, ETrue );
   203     iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsPageOverview, EFalse );
   203     iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsPageOverview, EFalse );
   204     iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsTextWrapEnabled, ETrue );
   204     iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsTextWrapEnabled, ETrue );
   214     TRect prevButtonRect = OverlayButtonRect( ETrue );
   214     TRect prevButtonRect = OverlayButtonRect( ETrue );
   215     iOverlayControlPrev = COverlayControl::NewL( this, this, prevButtonRect,
   215     iOverlayControlPrev = COverlayControl::NewL( this, this, prevButtonRect,
   216             EMbmFreestyleemailuiQgn_indi_cmail_arrow_previous,
   216             EMbmFreestyleemailuiQgn_indi_cmail_arrow_previous,
   217             EMbmFreestyleemailuiQgn_indi_cmail_arrow_previous_mask );
   217             EMbmFreestyleemailuiQgn_indi_cmail_arrow_previous_mask );
   218     iScrollPosition = 0;
   218     iScrollPosition = 0;
       
   219     iAttachmentDownloadImageHandle = 0;
   219     ActivateL();
   220     ActivateL();
   220     }
   221     }
   221 
   222 
   222 void CFsEmailUiHtmlViewerContainer::MakeVisible( TBool aVisible )
   223 void CFsEmailUiHtmlViewerContainer::MakeVisible( TBool aVisible )
   223     {
   224     {
   360     // Remove all previously created files from temporary HTML folder
   361     // Remove all previously created files from temporary HTML folder
   361     EmptyTempHtmlFolderL();
   362     EmptyTempHtmlFolderL();
   362 
   363 
   363     CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL();
   364     CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL();
   364 
   365 
   365     TBool bodyPartAvailable( EFalse );
       
   366     if ( htmlBodyPart )
   366     if ( htmlBodyPart )
   367         {
   367         {
   368         CleanupStack::PushL( htmlBodyPart );
   368         CleanupStack::PushL( htmlBodyPart );
   369         
   369         
   370         RFile htmlFile = htmlBodyPart->GetContentFileL();
   370         RFile htmlFile = htmlBodyPart->GetContentFileL();
   371         CleanupClosePushL( htmlFile );
   371         CleanupClosePushL( htmlFile );
   372         
   372         
   373         // Copy html body part to email html file
   373         // Copy html body part to email html file
   374         CopyFileToHtmlFileL( htmlFile, KBodyHtmlFile, *htmlBodyPart );
   374         CopyFileToHtmlFileL( htmlFile, KBodyHtmlFile, *htmlBodyPart );
   375         bodyPartAvailable = ETrue;
       
   376         
   375         
   377         CleanupStack::PopAndDestroy( &htmlFile );
   376         CleanupStack::PopAndDestroy( &htmlFile );
   378         CleanupStack::PopAndDestroy( htmlBodyPart );
   377         CleanupStack::PopAndDestroy( htmlBodyPart );
   379         }
   378         }
   380     else
   379     else
   396             textBodyPart->GetContentToBufferL(bufPtr,0);
   395             textBodyPart->GetContentToBufferL(bufPtr,0);
   397             HBufC8* contentBuffer8=HBufC8::NewLC(contentBuffer->Length());
   396             HBufC8* contentBuffer8=HBufC8::NewLC(contentBuffer->Length());
   398             
   397             
   399             contentBuffer8->Des().Copy(*contentBuffer);         
   398             contentBuffer8->Des().Copy(*contentBuffer);         
   400             CopyFileToHtmlFileL( *contentBuffer8, KBodyHtmlFile, *textBodyPart );
   399             CopyFileToHtmlFileL( *contentBuffer8, KBodyHtmlFile, *textBodyPart );
   401             bodyPartAvailable = ETrue;
       
   402             
   400             
   403             CleanupStack::PopAndDestroy( contentBuffer8 );
   401             CleanupStack::PopAndDestroy( contentBuffer8 );
   404             CleanupStack::PopAndDestroy( contentBuffer );
   402             CleanupStack::PopAndDestroy( contentBuffer );
   405             CleanupStack::PopAndDestroy( textBodyPart ); 
   403             CleanupStack::PopAndDestroy( textBodyPart ); 
   406             }
   404             }
   407         }
   405         else
       
   406             {
       
   407             WriteEmptyBodyHtmlL( KBodyHtmlFile );
       
   408             }
       
   409         }
       
   410 
   408     // pass the emailHtmlFile to the browser for it to load
   411     // pass the emailHtmlFile to the browser for it to load
   409     if ( bodyPartAvailable )
   412     TPath emailHtmlFile;
   410         {
   413     emailHtmlFile.Copy( iHtmlFolderPath );
   411         TPath emailHtmlFile;
   414     if ( direction == TBidiText::ELeftToRight )
   412         emailHtmlFile.Copy( iHtmlFolderPath );
   415         {
   413         if ( direction == TBidiText::ELeftToRight )
   416         emailHtmlFile.Append( KMessageHtmlFile );
   414             {
   417         }
   415             emailHtmlFile.Append( KMessageHtmlFile );
   418     else
   416             }
   419         {
   417         else
   420         emailHtmlFile.Append( KMessageHtmlRTLFile );
   418             {
   421         }
   419             emailHtmlFile.Append( KMessageHtmlRTLFile );
   422     LoadContentFromFileL( emailHtmlFile );
   420             }
       
   421         LoadContentFromFileL( emailHtmlFile );
       
   422         }
       
   423     
   423     
   424     UpdateOverlayButtons( ETrue );
   424     UpdateOverlayButtons( ETrue );
   425     }
   425     }
   426 
   426 
   427 // ---------------------------------------------------------------------------
   427 // ---------------------------------------------------------------------------
   454         case 0:
   454         case 0:
   455             {
   455             {
   456             return iBrCtlInterface;
   456             return iBrCtlInterface;
   457             }
   457             }
   458         case 1:
   458         case 1:
   459             if ( iAttachmentStatus )
   459             if ( iStatusIndicator )
   460                 return iAttachmentStatus;
   460                 return iStatusIndicator;
   461             else
   461             else
   462                 return NULL;
   462                 return NULL;
   463         default:
   463         default:
   464             {
   464             {
   465             return NULL;
   465             return NULL;
   472 // ---------------------------------------------------------------------------
   472 // ---------------------------------------------------------------------------
   473 //
   473 //
   474 TInt CFsEmailUiHtmlViewerContainer::CountComponentControls() const
   474 TInt CFsEmailUiHtmlViewerContainer::CountComponentControls() const
   475     {
   475     {
   476     FUNC_LOG;
   476     FUNC_LOG;
   477     if ( iAttachmentStatus )
   477     if ( iStatusIndicator )
   478         {
   478         {
   479         return 2;
   479         return 2;
   480         }
   480         }
   481     else 
   481     else 
   482         {
   482         {
   532             TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) )
   532             TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) )
   533             }
   533             }
   534     
   534     
   535     UpdateOverlayButtons( IsVisible() );
   535     UpdateOverlayButtons( IsVisible() );
   536     
   536     
   537     if ( iAttachmentStatus )
   537     if ( iStatusIndicator )
   538         {
   538         {
   539         TRect rect = CalcAttachmentStatusRect();
   539         TRect rect = CalcAttachmentStatusRect();
   540         iAttachmentStatus->SetRect( rect );
   540         iStatusIndicator->SetRect( rect );
   541         }
   541         }
   542     }
   542     }
   543 
   543 
   544 // ---------------------------------------------------------------------------
   544 // ---------------------------------------------------------------------------
   545 // From CCoeControl.
   545 // From CCoeControl.
  1709         }
  1709         }
  1710     TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) );
  1710     TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) );
  1711     SetRect( iAppUi.ClientRect() );
  1711     SetRect( iAppUi.ClientRect() );
  1712     }
  1712     }
  1713 
  1713 
  1714 void CFsEmailUiHtmlViewerContainer::ShowAttacthmentDownloadStatusL( 
  1714 void CFsEmailUiHtmlViewerContainer::ShowAttachmentDownloadStatusL( 
  1715         TFSProgress::TFSProgressStatus aProgressStatus, 
  1715         TFSProgress::TFSProgressStatus aProgressStatus, 
  1716         const TAttachmentData& aAttachmentData )
  1716         const TAttachmentData& aAttachmentData )
  1717     {
  1717     {
  1718     TBool freshDraw = EFalse;
  1718     TBool freshDraw = EFalse;
  1719     
  1719     //If the indicator was displaying fetching body then we will be displaying a different indicator
  1720     if ( !iAttachmentStatus )
  1720     //this is just to make sure the image is updated
       
  1721     if(iStatusIndicator)
       
  1722         {
       
  1723         if (iStatusIndicator->Image())
       
  1724             {
       
  1725             if(iStatusIndicator->Image()->Handle() != iAttachmentDownloadImageHandle)
       
  1726                 {
       
  1727                 freshDraw = ETrue;
       
  1728                 }
       
  1729             }
       
  1730         }
       
  1731     if ( !iStatusIndicator )
  1721         {
  1732         {
  1722         TRect rect = CalcAttachmentStatusRect();
  1733         TRect rect = CalcAttachmentStatusRect();
  1723         iAttachmentStatus = CFreestyleEmailUiAknStatusIndicator::NewL( rect, this );
  1734         iStatusIndicator = CFreestyleEmailUiAknStatusIndicator::NewL( rect, this );
  1724         freshDraw = ETrue;
  1735         freshDraw = ETrue;
  1725         }    
  1736         }    
  1726     
  1737     
  1727     if ( !iAttachmentStatus->IsVisible() 
  1738     if ( !iStatusIndicator->IsVisible() 
  1728          || ( aAttachmentData.downloadProgress == KNone ) 
  1739          || ( aAttachmentData.downloadProgress == KNone ) 
  1729          || ( aProgressStatus == TFSProgress::EFSStatus_RequestCancelled ) )
  1740          || ( aProgressStatus == TFSProgress::EFSStatus_RequestCancelled ) )
  1730         {
  1741         {
  1731         freshDraw = ETrue;
  1742         freshDraw = ETrue;
  1732         }
  1743         }
  1784                 }
  1795                 }
  1785             else
  1796             else
  1786                 {
  1797                 {
  1787                 iAppUi.FsTextureManager()->ProvideBitmapL(EAttachmentsDownload, image, imageMask );
  1798                 iAppUi.FsTextureManager()->ProvideBitmapL(EAttachmentsDownload, image, imageMask );
  1788                 }
  1799                 }
  1789             iAttachmentStatus->ShowIndicatorL( image, imageMask, statusText, duration );
  1800             if(image)
       
  1801                 {
       
  1802                 iAttachmentDownloadImageHandle = image->Handle();
       
  1803                 }
       
  1804             iStatusIndicator->ShowIndicatorL( image, imageMask, statusText, duration );
  1790             }
  1805             }
  1791         else
  1806         else
  1792             {
  1807             {
  1793             iAttachmentStatus->SetTextL( statusText );
  1808             iStatusIndicator->SetTextL( statusText );
  1794             if ( duration > -1 )
  1809             if ( duration > -1 )
  1795                 {
  1810                 {
  1796                 iAttachmentStatus->HideIndicator( duration );
  1811                 iStatusIndicator->HideIndicator( duration );
  1797                 }
  1812                 }
  1798             }
  1813             }
  1799         }
  1814         }
  1800     
  1815     
  1801     CleanupStack::Pop( statusText );
  1816     CleanupStack::Pop( statusText );
  1802     }
  1817     }
  1803 
  1818 
  1804 TBool CFsEmailUiHtmlViewerContainer::AttacthmentDownloadStatusVisible()
  1819 TBool CFsEmailUiHtmlViewerContainer::AttachmentDownloadStatusVisible()
  1805     {
  1820     {
  1806     if ( iAttachmentStatus )
  1821     if ( iStatusIndicator )
  1807         {
  1822         {
  1808         return iAttachmentStatus->IsVisible();
  1823         return iStatusIndicator->IsVisible();
  1809         }
  1824         }
  1810     else
  1825     else
  1811         {
  1826         {
  1812         return EFalse;
  1827         return EFalse;
  1813         }
  1828         }
  1814     }
  1829     }
  1815 
  1830 
  1816 void CFsEmailUiHtmlViewerContainer::HideAttacthmentDownloadStatus()
  1831 void CFsEmailUiHtmlViewerContainer::HideDownloadStatus()
  1817     {
  1832     {
  1818     if ( iAttachmentStatus )
  1833     if ( iStatusIndicator )
  1819         {
  1834         {
  1820         iAttachmentStatus->MakeVisible( EFalse );
  1835         iStatusIndicator->MakeVisible( EFalse );
  1821         }
  1836         }
  1822     }
  1837     }
  1823 
  1838 
  1824 TRect CFsEmailUiHtmlViewerContainer::CalcAttachmentStatusRect()
  1839 TRect CFsEmailUiHtmlViewerContainer::CalcAttachmentStatusRect()
  1825     {
  1840     {
  1956     CleanupStack::PushL( handler );
  1971     CleanupStack::PushL( handler );
  1957     handler->HandleUrlStandaloneL();
  1972     handler->HandleUrlStandaloneL();
  1958     CleanupStack::PopAndDestroy( handler );
  1973     CleanupStack::PopAndDestroy( handler );
  1959     }
  1974     }
  1960 
  1975 
       
  1976 void CFsEmailUiHtmlViewerContainer::WriteEmptyBodyHtmlL( const TDesC& aFileName )
       
  1977     {
       
  1978     FUNC_LOG;
       
  1979     TFileName targetFileName;
       
  1980     targetFileName.Copy( iTempHtmlFolderPath );
       
  1981     targetFileName.Append( aFileName );
       
  1982     
       
  1983     RFile targetFile;
       
  1984     CleanupClosePushL( targetFile );
       
  1985     User::LeaveIfError( targetFile.Replace( iFs, targetFileName, EFileWrite ) );
       
  1986     User::LeaveIfError( targetFile.Write( KHTMLEmptyContent ) );   
       
  1987     CleanupStack::PopAndDestroy( &targetFile );    
       
  1988     }
       
  1989 
       
  1990 void CFsEmailUiHtmlViewerContainer::DisplayStatusIndicatorL()
       
  1991     {
       
  1992     TRect rect = CalcAttachmentStatusRect();  
       
  1993     if(!iStatusIndicator)
       
  1994         {
       
  1995         iStatusIndicator  = CFreestyleEmailUiAknStatusIndicator::NewL( rect, this );
       
  1996         }  
       
  1997     CFbsBitmap* image = NULL;
       
  1998     CFbsBitmap* imageMask = NULL;
       
  1999     TInt duration = KStatusIndicatorDefaultDuration;
       
  2000     HBufC* statusText = NULL;
       
  2001     statusText = StringLoader::LoadL(R_FREESTYLE_EMAIL_UI_VIEWER_FETCHING_CONTENT_TEXT);
       
  2002     iAppUi.FsTextureManager()->ProvideBitmapL(EStatusTextureSynchronising, image, imageMask );
       
  2003     iStatusIndicator->ShowIndicatorL( image, imageMask, statusText, duration );
       
  2004     }