20 #include <AknsDrawUtils.h> |
20 #include <AknsDrawUtils.h> |
21 #include <coemain.h> |
21 #include <coemain.h> |
22 #include <commdbconnpref.h> |
22 #include <commdbconnpref.h> |
23 #include <bautils.h> |
23 #include <bautils.h> |
24 #include <biditext.h> |
24 #include <biditext.h> |
|
25 #include <stringloader.h> |
|
26 #include <e32base.h> |
|
27 #include <badesca.h> |
|
28 |
25 //<cmail> |
29 //<cmail> |
26 #include "CFSMailMessage.h" |
30 #include "CFSMailMessage.h" |
27 //</cmail> |
31 //</cmail> |
28 #include <brctlinterface.h> |
32 #include <brctlinterface.h> |
29 #include <sysutil.h> |
33 #include <sysutil.h> |
30 #include <SchemeHandler.h> |
34 #include <SchemeHandler.h> |
31 |
35 |
|
36 #include <FreestyleEmailUi.rsg> |
|
37 |
32 #include "FreestyleEmailUiAppui.h" |
38 #include "FreestyleEmailUiAppui.h" |
33 #include "FreestyleEmailUiUtilities.h" |
39 #include "FreestyleEmailUiUtilities.h" |
34 #include "FreestyleEmailUiHtmlViewerContainer.h" |
40 #include "FreestyleEmailUiHtmlViewerContainer.h" |
35 #include "FreestyleEmailUiHtmlViewerView.h" |
41 #include "FreestyleEmailUiHtmlViewerView.h" |
36 #include "FreestyleEmailUiShortcutBinding.h" |
42 #include "FreestyleEmailUiShortcutBinding.h" |
37 |
43 |
38 #include "FreestyleMessageHeaderHTML.h" |
44 #include "FreestyleMessageHeaderHTML.h" |
39 #include "FreestyleMessageHeaderURLEventHandler.h" |
45 #include "FreestyleMessageHeaderURLEventHandler.h" |
|
46 #include "FreestyleEmailUiAknStatusIndicator.h" |
|
47 #include "FreestyleEmailUiAttachmentsListModel.h" |
40 |
48 |
41 _LIT( KContentIdPrefix, "cid:" ); |
49 _LIT( KContentIdPrefix, "cid:" ); |
42 _LIT( KCDrive, "c:" ); |
50 _LIT( KCDrive, "c:" ); |
43 _LIT( KHtmlPath, "HtmlFile\\" ); |
51 _LIT( KHtmlPath, "HtmlFile\\" ); |
44 _LIT( KTempHtmlPath, "temp\\" ); |
52 _LIT( KTempHtmlPath, "temp\\" ); |
70 _LIT8( KHtmlLessThan, "<" ); |
78 _LIT8( KHtmlLessThan, "<" ); |
71 _LIT8( KHtmlGreaterThan, ">" ); |
79 _LIT8( KHtmlGreaterThan, ">" ); |
72 _LIT8( KHtmlAmpersand, "&" ); |
80 _LIT8( KHtmlAmpersand, "&" ); |
73 _LIT8( KHtmlQuotation, """ ); |
81 _LIT8( KHtmlQuotation, """ ); |
74 _LIT8( KHtmlLinkTag, "<a href=\"%S\">" ); |
82 _LIT8( KHtmlLinkTag, "<a href=\"%S\">" ); |
|
83 _LIT8( KHtmlLinkTagWWW, "<a href=\"%S%S\">" ); |
75 _LIT8( KHtmlLinkEndTag, "</a>" ); |
84 _LIT8( KHtmlLinkEndTag, "</a>" ); |
76 _LIT( KURLTypeBody, "body"); |
85 _LIT( KURLTypeBody, "body"); |
77 |
86 |
78 const TText8 KGreaterThan = 0x3e; |
87 const TText8 KGreaterThan = 0x3e; |
79 const TText8 KLessThan = 0x3c; |
88 const TText8 KLessThan = 0x3c; |
86 const TText8 KHT = 0x09; // Horizontal Tab |
95 const TText8 KHT = 0x09; // Horizontal Tab |
87 const TReal KOverlayButtonMarginX = 0.01; // 1% |
96 const TReal KOverlayButtonMarginX = 0.01; // 1% |
88 const TReal KOverlayButtonMarginY = 0.01; // 1% |
97 const TReal KOverlayButtonMarginY = 0.01; // 1% |
89 const TReal KOverlayButtonSizeP = 0.15; // 15% |
98 const TReal KOverlayButtonSizeP = 0.15; // 15% |
90 const TReal KOverlayButtonSizeLs = 0.20; // 25% |
99 const TReal KOverlayButtonSizeLs = 0.20; // 25% |
91 const TReal KOverlayButtonPosP = 0.88; |
100 |
92 const TReal KOverlayButtonPosLs = 0.85; |
101 |
|
102 const TInt KStatusIndicatorHeight = 50; |
|
103 const TInt KStatusIndicatorXMargin = 50; |
93 |
104 |
94 // --------------------------------------------------------------------------- |
105 // --------------------------------------------------------------------------- |
95 // Two-phased constructor. |
106 // Two-phased constructor. |
96 // --------------------------------------------------------------------------- |
107 // --------------------------------------------------------------------------- |
97 // |
108 // |
1352 } |
1381 } |
1353 |
1382 |
1354 if ( url.CompareC( KWww ) != KErrNone ) // if token=www., validate format |
1383 if ( url.CompareC( KWww ) != KErrNone ) // if token=www., validate format |
1355 { // www.x |
1384 { // www.x |
1356 RBuf8 urlBuf; |
1385 RBuf8 urlBuf; |
1357 urlBuf.CreateL( KHtmlLinkTag().Length() + url.Length() * 2 |
1386 TBool wwwLink( EFalse ); |
1358 + KHtmlLinkEndTag().Length() + KHtmlLineBreak().Length() ); |
1387 if ( url.Left( KWww().Length() ).CompareF( KWww ) == 0 ) |
|
1388 { |
|
1389 wwwLink = ETrue; |
|
1390 //Hyperlinks beginning with www. needs http:// prefix |
|
1391 urlBuf.CreateL( KHtmlLinkTagWWW().Length() + url.Length() * 2 |
|
1392 + KHtmlLinkEndTag().Length() + KHtmlLineBreak().Length() + KHttp().Length() ); |
|
1393 } |
|
1394 else |
|
1395 { |
|
1396 urlBuf.CreateL( KHtmlLinkTag().Length() + url.Length() * 2 |
|
1397 + KHtmlLinkEndTag().Length() + KHtmlLineBreak().Length() ); |
|
1398 } |
1359 urlBuf.CleanupClosePushL(); |
1399 urlBuf.CleanupClosePushL(); |
1360 // Format html link |
1400 // Format html link |
1361 urlBuf.AppendFormat( KHtmlLinkTag, &url ); |
1401 if ( wwwLink ) |
|
1402 { |
|
1403 urlBuf.AppendFormat( KHtmlLinkTagWWW, &KHttp, &url ); |
|
1404 } |
|
1405 else |
|
1406 { |
|
1407 urlBuf.AppendFormat( KHtmlLinkTag, &url ); |
|
1408 } |
1362 urlBuf.Append( url ); |
1409 urlBuf.Append( url ); |
1363 urlBuf.Append( KHtmlLinkEndTag ); |
1410 urlBuf.Append( KHtmlLinkEndTag ); |
1364 if ( lineBreakPos != KErrNotFound ) |
1411 if ( lineBreakPos != KErrNotFound ) |
1365 { // Add line break if removed earlier |
1412 { // Add line break if removed earlier |
1366 urlBuf.Append( KHtmlLineBreak ); |
1413 urlBuf.Append( KHtmlLineBreak ); |
1442 { // Token takes up the whole segment, or first pass( first segment |
1489 { // Token takes up the whole segment, or first pass( first segment |
1443 // with last token where hyperlink does not end within segment's |
1490 // with last token where hyperlink does not end within segment's |
1444 // boundaries, move to next segment |
1491 // boundaries, move to next segment |
1445 nextPos += nextSegment.Length(); |
1492 nextPos += nextSegment.Length(); |
1446 nextSegment.Set( aSource.Ptr( nextPos ) ); |
1493 nextSegment.Set( aSource.Ptr( nextPos ) ); |
|
1494 if( nextSegment.Length() == 0 ) |
|
1495 { |
|
1496 break; |
|
1497 } |
1447 lexNextSegment.Assign( nextSegment ); |
1498 lexNextSegment.Assign( nextSegment ); |
1448 nextNextToken.Set( lexNextSegment.NextToken() ); |
1499 nextNextToken.Set( lexNextSegment.NextToken() ); |
1449 if ( firstPass ) |
1500 if ( firstPass ) |
1450 { |
1501 { |
1451 firstPass = EFalse; |
1502 firstPass = EFalse; |
1466 } |
1517 } |
1467 |
1518 |
1468 if ( endOfUrlPos != KErrNotFound ) |
1519 if ( endOfUrlPos != KErrNotFound ) |
1469 { // Handle hyperlink that is within 2K limit |
1520 { // Handle hyperlink that is within 2K limit |
1470 RBuf8 urlBuf; |
1521 RBuf8 urlBuf; |
1471 urlBuf.CreateL( KHtmlLinkTag().Length() + url.Length() * 2 |
1522 TBool wwwLink( EFalse ); |
1472 + KHtmlLinkEndTag().Length() + KHtmlLineBreak().Length() ); |
1523 |
|
1524 if ( url.Left( KWww().Length() ).CompareF( KWww ) == 0 ) |
|
1525 { |
|
1526 wwwLink = ETrue; |
|
1527 urlBuf.CreateL( KHtmlLinkTagWWW().Length() + url.Length() * 2 |
|
1528 + KHtmlLinkEndTag().Length() + KHtmlLineBreak().Length() + KHttp().Length() ); |
|
1529 } |
|
1530 else |
|
1531 { |
|
1532 urlBuf.CreateL( KHtmlLinkTag().Length() + url.Length() * 2 |
|
1533 + KHtmlLinkEndTag().Length() + KHtmlLineBreak().Length() ); |
|
1534 } |
|
1535 |
1473 urlBuf.CleanupClosePushL(); |
1536 urlBuf.CleanupClosePushL(); |
1474 // Format html link |
1537 // Format html link |
1475 urlBuf.AppendFormat( KHtmlLinkTag, &url ); |
1538 if ( wwwLink ) |
|
1539 { |
|
1540 urlBuf.AppendFormat( KHtmlLinkTagWWW, &KHttp, &url ); |
|
1541 } |
|
1542 else |
|
1543 { |
|
1544 urlBuf.AppendFormat( KHtmlLinkTag, &url ); |
|
1545 } |
|
1546 |
1476 urlBuf.Append( url ); |
1547 urlBuf.Append( url ); |
1477 urlBuf.Append( KHtmlLinkEndTag ); |
1548 urlBuf.Append( KHtmlLinkEndTag ); |
1478 urlBuf.Append( KHtmlLineBreak ); |
1549 urlBuf.Append( KHtmlLineBreak ); |
1479 |
1550 |
1480 TInt offset = lexSegment.Offset() - nextToken.Length(); |
1551 TInt offset = lexSegment.Offset() - nextToken.Length(); |
1636 { |
1707 { |
1637 emailHtmlFile.Append( KMessageHtmlRTLFile ); |
1708 emailHtmlFile.Append( KMessageHtmlRTLFile ); |
1638 } |
1709 } |
1639 TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) ); |
1710 TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) ); |
1640 SetRect( iAppUi.ClientRect() ); |
1711 SetRect( iAppUi.ClientRect() ); |
|
1712 } |
|
1713 |
|
1714 void CFsEmailUiHtmlViewerContainer::ShowAttacthmentDownloadStatusL( |
|
1715 TFSProgress::TFSProgressStatus aProgressStatus, |
|
1716 const TAttachmentData& aAttachmentData ) |
|
1717 { |
|
1718 TBool freshDraw = EFalse; |
|
1719 |
|
1720 if ( !iAttachmentStatus ) |
|
1721 { |
|
1722 TRect rect = CalcAttachmentStatusRect(); |
|
1723 iAttachmentStatus = CFreestyleEmailUiAknStatusIndicator::NewL( rect, this ); |
|
1724 freshDraw = ETrue; |
|
1725 } |
|
1726 |
|
1727 if ( !iAttachmentStatus->IsVisible() |
|
1728 || ( aAttachmentData.downloadProgress == KNone ) |
|
1729 || ( aProgressStatus == TFSProgress::EFSStatus_RequestCancelled ) ) |
|
1730 { |
|
1731 freshDraw = ETrue; |
|
1732 } |
|
1733 |
|
1734 TInt duration = KStatusIndicatorDefaultDuration; |
|
1735 if ( ( aAttachmentData.downloadProgress == TFSProgress::EFSStatus_RequestComplete ) |
|
1736 || ( aProgressStatus == TFSProgress::EFSStatus_RequestCancelled ) |
|
1737 || ( aAttachmentData.downloadProgress == KComplete ) ) |
|
1738 { |
|
1739 duration = KStatusIndicatorAutomaticHidingDuration; |
|
1740 } |
|
1741 |
|
1742 HBufC* statusText = NULL; |
|
1743 switch ( aProgressStatus ) |
|
1744 { |
|
1745 case TFSProgress::EFSStatus_Status: |
|
1746 case TFSProgress::EFSStatus_RequestComplete: |
|
1747 { |
|
1748 CDesCArray* descArray = new (ELeave) CDesCArrayFlat( 1 ); |
|
1749 CleanupStack::PushL( descArray ); |
|
1750 descArray->AppendL( aAttachmentData.fileName ); |
|
1751 CArrayFix<TInt>* intArray = new (ELeave) CArrayFixFlat<TInt>( 1 ); |
|
1752 CleanupStack::PushL( intArray ); |
|
1753 intArray->AppendL( aAttachmentData.downloadProgress ); |
|
1754 |
|
1755 statusText = StringLoader::LoadL( R_FSE_VIEWER_ATTACHMENTS_LIST_DOWNLOAD, |
|
1756 *descArray, |
|
1757 *intArray ); |
|
1758 CleanupStack::PopAndDestroy( intArray ); |
|
1759 CleanupStack::PopAndDestroy( descArray ); |
|
1760 CleanupStack::PushL( statusText ); |
|
1761 } |
|
1762 break; |
|
1763 |
|
1764 case TFSProgress::EFSStatus_RequestCancelled: |
|
1765 { |
|
1766 statusText = aAttachmentData.fileName.AllocLC(); |
|
1767 } |
|
1768 break; |
|
1769 |
|
1770 default: |
|
1771 statusText = KNullDesC().AllocLC(); |
|
1772 break; |
|
1773 } |
|
1774 |
|
1775 if ( statusText->Length() > 0 ) |
|
1776 { |
|
1777 if ( freshDraw ) |
|
1778 { |
|
1779 CFbsBitmap* image = NULL; |
|
1780 CFbsBitmap* imageMask = NULL; |
|
1781 if ( aProgressStatus == TFSProgress::EFSStatus_RequestCancelled ) |
|
1782 { |
|
1783 iAppUi.FsTextureManager()->ProvideBitmapL(EAttachmentsCancelDownload, image, imageMask ); |
|
1784 } |
|
1785 else |
|
1786 { |
|
1787 iAppUi.FsTextureManager()->ProvideBitmapL(EAttachmentsDownload, image, imageMask ); |
|
1788 } |
|
1789 iAttachmentStatus->ShowIndicatorL( image, imageMask, statusText, duration ); |
|
1790 } |
|
1791 else |
|
1792 { |
|
1793 iAttachmentStatus->SetTextL( statusText ); |
|
1794 if ( duration > -1 ) |
|
1795 { |
|
1796 iAttachmentStatus->HideIndicator( duration ); |
|
1797 } |
|
1798 } |
|
1799 } |
|
1800 |
|
1801 CleanupStack::Pop( statusText ); |
|
1802 } |
|
1803 |
|
1804 TBool CFsEmailUiHtmlViewerContainer::AttacthmentDownloadStatusVisible() |
|
1805 { |
|
1806 if ( iAttachmentStatus ) |
|
1807 { |
|
1808 return iAttachmentStatus->IsVisible(); |
|
1809 } |
|
1810 else |
|
1811 { |
|
1812 return EFalse; |
|
1813 } |
|
1814 } |
|
1815 |
|
1816 void CFsEmailUiHtmlViewerContainer::HideAttacthmentDownloadStatus() |
|
1817 { |
|
1818 if ( iAttachmentStatus ) |
|
1819 { |
|
1820 iAttachmentStatus->MakeVisible( EFalse ); |
|
1821 } |
|
1822 } |
|
1823 |
|
1824 TRect CFsEmailUiHtmlViewerContainer::CalcAttachmentStatusRect() |
|
1825 { |
|
1826 TRect rect = Rect(); |
|
1827 TPoint topLeft = rect.iTl; |
|
1828 TPoint bottomRight = rect.iBr; |
|
1829 |
|
1830 TPoint statusTopLeft( topLeft.iX + KStatusIndicatorXMargin, bottomRight.iY - KStatusIndicatorHeight + 1 ); |
|
1831 TPoint statusBottomRight( bottomRight.iX - KStatusIndicatorXMargin, bottomRight.iY ); |
|
1832 return TRect( statusTopLeft, statusBottomRight ); |
1641 } |
1833 } |
1642 |
1834 |
1643 /** |
1835 /** |
1644 * The body fetch link is cmail://body/fetch. Look for the URL separator |
1836 * The body fetch link is cmail://body/fetch. Look for the URL separator |
1645 * and the presence of cmail and body on the url. |
1837 * and the presence of cmail and body on the url. |