63 // Constants used in html content modification |
63 // Constants used in html content modification |
64 const TInt KMaxCharsToSearch( 200 ); |
64 const TInt KMaxCharsToSearch( 200 ); |
65 _LIT8( KStartTag, "<html" ); |
65 _LIT8( KStartTag, "<html" ); |
66 _LIT8( KHeadTag, "<head>"); |
66 _LIT8( KHeadTag, "<head>"); |
67 _LIT8( KHtmlHeader1, "<html><head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset="); |
67 _LIT8( KHtmlHeader1, "<html><head><title></title><meta http-equiv=\"Content-Type\" content=\"text/html; charset="); |
68 _LIT8( KHtmlHeader2, "\"/></head><body>\xD\xA"); |
68 _LIT8( KHtmlHeader2, "\"/></head><body bgcolor=\"#ECECEC\">\xD\xA"); |
69 _LIT8( KHtmlHeader3, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%S\">\n"); |
69 _LIT8( KHtmlHeader3, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=%S\">\n"); |
70 _LIT8( KHtmlEndTags, "\xD\xA</body></html>\xD\xA"); |
70 _LIT8( KHtmlEndTags, "\xD\xA</body></html>\xD\xA"); |
71 _LIT8( KCharsetTag8, "charset"); |
71 _LIT8( KCharsetTag8, "charset"); |
72 _LIT( KCharsetTag, "charset"); |
72 _LIT( KCharsetTag, "charset"); |
73 _LIT8( KHTMLEmptyContent, "<HTML><BODY></BODY></HTML>"); |
73 _LIT8( KHTMLEmptyContent, "<html><body></body></html>"); |
74 _LIT( KHTMLDataScheme, "data:0"); |
74 _LIT( KHTMLDataScheme, "data:0"); |
75 |
75 |
76 |
76 |
77 _LIT( KHtmlLineBreak, "<br>" ); |
77 _LIT( KHtmlLineBreak, "<br>" ); |
78 _LIT( KHtmlLineBreakCRLF, "<br>\xD\xA" ); |
78 _LIT( KHtmlLineBreakCRLF, "<br>\xD\xA" ); |
84 |
84 |
85 _LIT( KURLDisplayImages, "cmail://displayImages/" ); |
85 _LIT( KURLDisplayImages, "cmail://displayImages/" ); |
86 _LIT( KURLLoadImages, "cmail://loadImages/" ); |
86 _LIT( KURLLoadImages, "cmail://loadImages/" ); |
87 _LIT( KURLCollapseHeader, "cmail://collapseHeader/" ); |
87 _LIT( KURLCollapseHeader, "cmail://collapseHeader/" ); |
88 _LIT( KURLExpandHeader, "cmail://expandHeader/" ); |
88 _LIT( KURLExpandHeader, "cmail://expandHeader/" ); |
|
89 _LIT( KURLExpandItem, "cmail://expand_" ); |
|
90 _LIT( KURLItemTo, "to" ); |
|
91 _LIT( KURLItemCc, "cc" ); |
|
92 _LIT( KURLItemBcc, "bcc" ); |
|
93 _LIT( KURLItemAttachments, "attachments" ); |
89 |
94 |
90 const TText KGreaterThan = 0x3e; |
95 const TText KGreaterThan = 0x3e; |
91 const TText KLessThan = 0x3c; |
96 const TText KLessThan = 0x3c; |
92 const TText KAmpersand = 0x26; |
97 const TText KAmpersand = 0x26; |
93 const TText KQuotation = 0x22; |
98 const TText KQuotation = 0x22; |
99 const TReal KOverlayButtonMarginY = 0.01; // 1% |
104 const TReal KOverlayButtonMarginY = 0.01; // 1% |
100 const TReal KOverlayButtonSizeP = 0.15; // 15% |
105 const TReal KOverlayButtonSizeP = 0.15; // 15% |
101 const TReal KOverlayButtonSizeLs = 0.20; // 25% |
106 const TReal KOverlayButtonSizeLs = 0.20; // 25% |
102 |
107 |
103 |
108 |
104 const TInt KStatusIndicatorHeight = 50; |
109 const TInt KStatusIndicatorHeight = 55; |
105 const TInt KStatusIndicatorXMargin = 50; |
110 const TInt KStatusIndicatorXMargin = 58; |
|
111 const TInt KStatusIndicatorBottomMargin = 6; |
106 |
112 |
107 // CONSTANTS |
113 // CONSTANTS |
108 // Zoom levels available on the UI |
114 // Zoom levels available on the UI |
109 const TInt KZoomLevels[] = { 75, 100, 125, 150 }; |
115 const TInt KZoomLevels[] = { 75, 100, 125, 150 }; |
110 const TInt KZoomLevelCount = sizeof( KZoomLevels ) / sizeof( TInt ); |
116 const TInt KZoomLevelCount = sizeof( KZoomLevels ) / sizeof( TInt ); |
111 const TInt KZoomLevelIndex100 = 100; // 100 in array KZoomLevels |
117 const TInt KZoomLevelIndex100 = 1; // 100 in array KZoomLevels |
112 |
118 |
113 // CEUiHtmlViewerSettingsKeyListener |
119 // CEUiHtmlViewerSettingsKeyListener |
114 |
120 |
115 // --------------------------------------------------------------------------- |
121 // --------------------------------------------------------------------------- |
116 // |
122 // |
651 { |
657 { |
652 iScrollPosition = 0; |
658 iScrollPosition = 0; |
653 } |
659 } |
654 const TInt visibleWidth(iAppUi.ClientRect().Width()); |
660 const TInt visibleWidth(iAppUi.ClientRect().Width()); |
655 CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, visibleWidth, iScrollPosition, |
661 CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, visibleWidth, iScrollPosition, |
656 iViewerSettings->AutoLoadImages() || iAppUi.DisplayImagesCache().Contains(*iMessage), |
662 iViewerSettings->AutoLoadImages() || iAppUi.DisplayImagesCache().Contains(*iMessage), iFlags ); |
657 iHeaderExpanded ); |
663 |
658 |
|
659 // Remove all previously created files from temporary HTML folder |
664 // Remove all previously created files from temporary HTML folder |
660 EmptyTempHtmlFolderL(); |
665 EmptyTempHtmlFolderL(); |
661 |
666 |
662 TRAPD( error, PrepareBodyHtmlL( KBodyHtmlFile ) ); |
667 TRAPD( error, PrepareBodyHtmlL( KBodyHtmlFile ) ); |
663 if ( error != KErrNone ) |
668 if ( error != KErrNone ) |
944 { |
949 { |
945 CFSMailMessagePart* part = iMessage->ChildPartL( aPart.iMessagePartId ); |
950 CFSMailMessagePart* part = iMessage->ChildPartL( aPart.iMessagePartId ); |
946 CleanupStack::PushL( part ); |
951 CleanupStack::PushL( part ); |
947 RFile contentFile = part->GetContentFileL(); |
952 RFile contentFile = part->GetContentFileL(); |
948 CleanupClosePushL( contentFile ); |
953 CleanupClosePushL( contentFile ); |
949 HBufC8* content = ReadContentFromFileLC( contentFile ); |
954 HBufC8* content = ReadContentFromFileLC( contentFile, *part ); |
950 linkContent->HandleResolveComplete( |
955 linkContent->HandleResolveComplete( |
951 part->GetContentType(), KNullDesC(), content ); |
956 part->GetContentType(), KNullDesC(), content ); |
952 CleanupStack::PopAndDestroy( content ); |
957 CleanupStack::PopAndDestroy( content ); |
953 CleanupStack::PopAndDestroy( &contentFile ); |
958 CleanupStack::PopAndDestroy( &contentFile ); |
954 CleanupStack::PopAndDestroy( part ); |
959 CleanupStack::PopAndDestroy( part ); |
1124 |
1129 |
1125 RFile htmlFile = aHtmlBodyPart.GetContentFileL(); |
1130 RFile htmlFile = aHtmlBodyPart.GetContentFileL(); |
1126 CleanupClosePushL( htmlFile ); |
1131 CleanupClosePushL( htmlFile ); |
1127 |
1132 |
1128 // Read content from given source file |
1133 // Read content from given source file |
1129 HBufC8* content = ReadContentFromFileLC( htmlFile ); |
1134 HBufC8* content = ReadContentFromFileLC( htmlFile, aHtmlBodyPart ); |
1130 |
1135 |
1131 // Write content to target file |
1136 // Write content to target file |
1132 WriteContentToFileL( *content, targetFileName, aHtmlBodyPart ); |
1137 WriteContentToFileL( *content, targetFileName, aHtmlBodyPart ); |
1133 |
1138 |
1134 CleanupStack::PopAndDestroy( content ); |
1139 CleanupStack::PopAndDestroy( content ); |
1146 FUNC_LOG; |
1151 FUNC_LOG; |
1147 TFileName targetFileName; |
1152 TFileName targetFileName; |
1148 targetFileName.Copy( iTempHtmlFolderPath ); |
1153 targetFileName.Copy( iTempHtmlFolderPath ); |
1149 targetFileName.Append( aHtmlFileName ); |
1154 targetFileName.Append( aHtmlFileName ); |
1150 |
1155 |
1151 HBufC* content = HBufC::NewLC( aTextBodyPart.FetchedContentSize() ); |
1156 TInt contentsize = aTextBodyPart.FetchedContentSize(); |
|
1157 |
|
1158 TInt limit(0); |
|
1159 TInt err = iViewerSettings->Repository().Get( KFreestyleMaxBodySize , limit ); |
|
1160 limit *= KKilo; // cenrep value is in kB, 0 means unlimited |
|
1161 |
|
1162 if ( limit == 0 || err ) |
|
1163 { |
|
1164 limit = KMaxTInt; |
|
1165 } |
|
1166 |
|
1167 TInt size = Min(limit,contentsize); |
|
1168 HBufC* content = HBufC::NewLC( size ); |
1152 TPtr contentPtr( content->Des() ); |
1169 TPtr contentPtr( content->Des() ); |
1153 |
1170 |
1154 aTextBodyPart.GetContentToBufferL( contentPtr, 0 ); |
1171 aTextBodyPart.GetContentToBufferL( contentPtr, 0 ); |
1155 |
1172 //When we found EFSMsgFlag_BodyTruncated was set, add "--Message too long--" in the end of plain html view |
|
1173 if ( limit < contentsize ) |
|
1174 { |
|
1175 HBufC* addingText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEW_ADDITIONAL_INFO ); |
|
1176 TInt pos = limit - addingText->Length(); |
|
1177 contentPtr.Replace(pos,addingText->Length(),*addingText); |
|
1178 CleanupStack::PopAndDestroy( addingText ); |
|
1179 aTextBodyPart.SetFlag(EFSMsgFlag_BodyTruncated); |
|
1180 } |
|
1181 |
1156 ConvertToHTML( *content, targetFileName, aTextBodyPart ); |
1182 ConvertToHTML( *content, targetFileName, aTextBodyPart ); |
1157 |
|
1158 CleanupStack::PopAndDestroy( content ); |
1183 CleanupStack::PopAndDestroy( content ); |
1159 |
1184 |
1160 } |
1185 } |
1161 |
1186 |
1162 // --------------------------------------------------------------------------- |
1187 // --------------------------------------------------------------------------- |
1163 // Reads given file content to buffer and return pointer to it |
1188 // Reads given file content to buffer and return pointer to it |
1164 // --------------------------------------------------------------------------- |
1189 // --------------------------------------------------------------------------- |
1165 // |
1190 // |
1166 HBufC8* CFsEmailUiHtmlViewerContainer::ReadContentFromFileLC( RFile& aFile ) |
1191 HBufC8* CFsEmailUiHtmlViewerContainer::ReadContentFromFileLC( RFile& aFile, CFSMailMessagePart& aHtmlBodyPart ) |
1167 { |
1192 { |
1168 FUNC_LOG; |
1193 FUNC_LOG; |
1169 TInt size = 0; |
1194 TInt fileSize = 0; |
1170 User::LeaveIfError( aFile.Size( size ) ); |
1195 |
|
1196 TInt limit(0); |
|
1197 TInt err = iViewerSettings->Repository().Get( KFreestyleMaxBodySize , limit ); |
|
1198 limit *= KKilo; // cenrep value is in kB, 0 means unlimited |
|
1199 |
|
1200 User::LeaveIfError( aFile.Size( fileSize ) ); |
|
1201 if ( limit == 0 || err ) |
|
1202 { |
|
1203 limit = KMaxTInt; |
|
1204 } |
|
1205 |
|
1206 TInt size = Min( limit, fileSize ); // read no more than limit bytes.. |
|
1207 |
|
1208 |
|
1209 if ( size < fileSize ) |
|
1210 { |
|
1211 aHtmlBodyPart.SetFlag( EFSMsgFlag_BodyTruncated ); |
|
1212 } |
|
1213 |
1171 HBufC8* buffer = HBufC8::NewLC( size ); |
1214 HBufC8* buffer = HBufC8::NewLC( size ); |
1172 TPtr8 ptr = buffer->Des(); |
1215 TPtr8 ptr = buffer->Des(); |
1173 User::LeaveIfError( aFile.Read( ptr, size ) ); |
1216 User::LeaveIfError( aFile.Read( ptr, size ) ); |
1174 return buffer; |
1217 return buffer; |
1175 } |
1218 } |
1251 } |
1294 } |
1252 } |
1295 } |
1253 |
1296 |
1254 // Write the original content |
1297 // Write the original content |
1255 User::LeaveIfError( targetFile.Write( buffer ) ); |
1298 User::LeaveIfError( targetFile.Write( buffer ) ); |
1256 |
1299 //When we found EFSMsgFlag_BodyTruncated was set, add "--Message too long--" in the end of html view |
|
1300 if( aHtmlBodyPart.GetFlags()&EFSMsgFlag_BodyTruncated ) |
|
1301 { |
|
1302 HBufC* addingText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEW_ADDITIONAL_INFO ); |
|
1303 HBufC8* addingText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *addingText ); |
|
1304 CleanupStack::PopAndDestroy( addingText ); |
|
1305 CleanupStack::PushL( addingText8 ); |
|
1306 User::LeaveIfError( targetFile.Write( *addingText8 ) ); |
|
1307 CleanupStack::PopAndDestroy( addingText8 ); |
|
1308 } |
1257 // Write ending metadata if needed |
1309 // Write ending metadata if needed |
1258 if ( modificationNeeded ) |
1310 if ( modificationNeeded || (aHtmlBodyPart.GetFlags()&EFSMsgFlag_BodyTruncated) ) |
1259 { |
1311 { |
1260 INFO("Add end tags"); |
1312 INFO("Add end tags"); |
1261 User::LeaveIfError( targetFile.Write( KHtmlEndTags ) ); |
1313 User::LeaveIfError( targetFile.Write( KHtmlEndTags ) ); |
1262 } |
1314 } |
1263 |
1315 |
1361 FUNC_LOG; |
1413 FUNC_LOG; |
1362 if ( aAttachment.FetchLoadState() == EFSFull ) |
1414 if ( aAttachment.FetchLoadState() == EFSFull ) |
1363 { |
1415 { |
1364 RFile attachmentFile = aAttachment.GetContentFileL(); |
1416 RFile attachmentFile = aAttachment.GetContentFileL(); |
1365 CleanupClosePushL( attachmentFile ); |
1417 CleanupClosePushL( attachmentFile ); |
1366 HBufC8* content = ReadContentFromFileLC( attachmentFile ); |
1418 HBufC8* content = ReadContentFromFileLC( attachmentFile, aAttachment ); |
1367 aEmbeddedLinkContent.HandleResolveComplete( |
1419 aEmbeddedLinkContent.HandleResolveComplete( |
1368 aAttachment.GetContentType(), KNullDesC(), content ); |
1420 aAttachment.GetContentType(), KNullDesC(), content ); |
1369 CleanupStack::PopAndDestroy( content ); |
1421 CleanupStack::PopAndDestroy( content ); |
1370 CleanupStack::PopAndDestroy( &attachmentFile ); |
1422 CleanupStack::PopAndDestroy( &attachmentFile ); |
1371 } |
1423 } |
1607 headerHtmlFile.Append( KHeaderHtmlFile ); |
1659 headerHtmlFile.Append( KHeaderHtmlFile ); |
1608 |
1660 |
1609 TRAP_IGNORE( CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, |
1661 TRAP_IGNORE( CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, |
1610 headerHtmlFile, iAppUi.ClientRect().Width(), iScrollPosition, |
1662 headerHtmlFile, iAppUi.ClientRect().Width(), iScrollPosition, |
1611 iViewerSettings->AutoLoadImages() || iAppUi.DisplayImagesCache().Contains(*iMessage), |
1663 iViewerSettings->AutoLoadImages() || iAppUi.DisplayImagesCache().Contains(*iMessage), |
1612 iHeaderExpanded ) ) |
1664 iFlags ) ) |
1613 |
1665 |
1614 |
1666 |
1615 if(!iEventHandler->IsMenuVisible()) |
1667 if(!iEventHandler->IsMenuVisible()) |
1616 { |
1668 { |
1617 TRAP_IGNORE( ReloadPageL() ); |
1669 TRAP_IGNORE( ReloadPageL() ); |
1618 } |
1670 } |
1619 else |
1671 else |
1773 } |
1825 } |
1774 } |
1826 } |
1775 |
1827 |
1776 TRect CFsEmailUiHtmlViewerContainer::CalcAttachmentStatusRect() |
1828 TRect CFsEmailUiHtmlViewerContainer::CalcAttachmentStatusRect() |
1777 { |
1829 { |
1778 TRect rect = Rect(); |
1830 TRect rect( Rect() ); |
1779 TPoint topLeft = rect.iTl; |
1831 TPoint topLeft = rect.iTl; |
1780 TPoint bottomRight = rect.iBr; |
1832 TPoint bottomRight = rect.iBr; |
1781 |
|
1782 TPoint statusTopLeft( topLeft.iX + KStatusIndicatorXMargin, bottomRight.iY - KStatusIndicatorHeight + 1 ); |
1833 TPoint statusTopLeft( topLeft.iX + KStatusIndicatorXMargin, bottomRight.iY - KStatusIndicatorHeight + 1 ); |
1783 TPoint statusBottomRight( bottomRight.iX - KStatusIndicatorXMargin, bottomRight.iY ); |
1834 TPoint statusBottomRight( bottomRight.iX - KStatusIndicatorXMargin, bottomRight.iY ); |
1784 return TRect( statusTopLeft, statusBottomRight ); |
1835 rect = TRect(statusTopLeft, statusBottomRight); |
|
1836 rect.Move(0, -KStatusIndicatorBottomMargin); |
|
1837 return rect; |
1785 } |
1838 } |
1786 |
1839 |
1787 void CFsEmailUiHtmlViewerContainer::TouchFeedback() |
1840 void CFsEmailUiHtmlViewerContainer::TouchFeedback() |
1788 { |
1841 { |
1789 iTouchFeedBack->InstantFeedback(this, ETouchFeedbackBasic); |
1842 iTouchFeedBack->InstantFeedback(this, ETouchFeedbackBasic); |
1820 return ETrue; |
1873 return ETrue; |
1821 } |
1874 } |
1822 else if (aUrl.Compare(KURLCollapseHeader()) == 0) |
1875 else if (aUrl.Compare(KURLCollapseHeader()) == 0) |
1823 { |
1876 { |
1824 TouchFeedback(); |
1877 TouchFeedback(); |
1825 iHeaderExpanded = EFalse; |
1878 iFlags.ClearAll(); |
1826 return ETrue; |
1879 return ETrue; |
1827 } |
1880 } |
1828 else if (aUrl.Compare(KURLExpandHeader()) == 0) |
1881 else if (aUrl.Compare(KURLExpandHeader()) == 0) |
1829 { |
1882 { |
1830 TouchFeedback(); |
1883 TouchFeedback(); |
1831 iHeaderExpanded = ETrue; |
1884 iFlags.Set( CFreestyleMessageHeaderHTML::EHeaderExpanded ); |
1832 return ETrue; |
1885 return ETrue; |
1833 } |
1886 } |
1834 else if (aUrl.Left(index).CompareF(KURLSchemeCmail) == 0) |
1887 else if ( aUrl.Find( KURLExpandItem() ) == 0 ) { |
|
1888 const TPtrC item( aUrl.Mid( KURLExpandItem().Length() ) ); |
|
1889 if ( item.Find( KURLItemTo() ) == 0 ) |
|
1890 { |
|
1891 iFlags.Assign( CFreestyleMessageHeaderHTML::EToExpanded, ETrue ); |
|
1892 } |
|
1893 else if ( item.Find( KURLItemCc() ) == 0 ) |
|
1894 { |
|
1895 iFlags.Assign( CFreestyleMessageHeaderHTML::ECcExpanded, ETrue ); |
|
1896 } |
|
1897 else if ( item.Find( KURLItemBcc() ) == 0 ) |
|
1898 { |
|
1899 iFlags.Assign( CFreestyleMessageHeaderHTML::EBccExpanded, ETrue ); |
|
1900 } |
|
1901 else if ( item.Find( KURLItemAttachments() ) == 0 ) |
|
1902 { |
|
1903 iFlags.Assign( CFreestyleMessageHeaderHTML::EAttachmentExpanded, ETrue ); |
|
1904 } |
|
1905 return ETrue; |
|
1906 } else if (aUrl.Left(index).CompareF(KURLSchemeCmail) == 0) |
1835 { |
1907 { |
1836 TInt bodyIndex = aUrl.Find(KURLTypeBody); |
1908 TInt bodyIndex = aUrl.Find(KURLTypeBody); |
1837 if (bodyIndex == KErrNotFound) |
1909 if (bodyIndex == KErrNotFound) |
1838 { |
1910 { |
1839 return EFalse; |
1911 return EFalse; |
2008 CFbsBitmap* image = NULL; |
2080 CFbsBitmap* image = NULL; |
2009 CFbsBitmap* imageMask = NULL; |
2081 CFbsBitmap* imageMask = NULL; |
2010 HBufC* statusText = NULL; |
2082 HBufC* statusText = NULL; |
2011 statusText = StringLoader::LoadL(R_FREESTYLE_EMAIL_UI_VIEWER_FETCHING_CONTENT_TEXT); |
2083 statusText = StringLoader::LoadL(R_FREESTYLE_EMAIL_UI_VIEWER_FETCHING_CONTENT_TEXT); |
2012 iAppUi.FsTextureManager()->ProvideBitmapL(EStatusTextureSynchronising, image, imageMask ); |
2084 iAppUi.FsTextureManager()->ProvideBitmapL(EStatusTextureSynchronising, image, imageMask ); |
2013 iStatusIndicator->ShowIndicatorL( image, imageMask, statusText, aDuration ); |
2085 iStatusIndicator->ShowIndicatorL( image, imageMask, statusText, aDuration, ETrue ); |
2014 } |
2086 } |
2015 |
2087 |
2016 void CFsEmailUiHtmlViewerContainer::MailListModelUpdatedL() |
2088 void CFsEmailUiHtmlViewerContainer::MailListModelUpdatedL() |
2017 { |
2089 { |
2018 FUNC_LOG; |
2090 FUNC_LOG; |