211 headerHtmlFile.Append( KHeaderHtmlFile ); |
211 headerHtmlFile.Append( KHeaderHtmlFile ); |
212 |
212 |
213 // insert email header into email.html file |
213 // insert email header into email.html file |
214 // CFreestyleMessageHeaderHTML will replace contents of email.html |
214 // CFreestyleMessageHeaderHTML will replace contents of email.html |
215 // So, no need to clear the contents |
215 // So, no need to clear the contents |
216 CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile ); |
216 CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, iAppUi.ClientRect().Width() ); |
217 |
217 |
218 // Remove all previously created files from temporary HTML folder |
218 // Remove all previously created files from temporary HTML folder |
219 EmptyTempHtmlFolderL(); |
219 EmptyTempHtmlFolderL(); |
220 |
220 |
221 CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL(); |
221 CFSMailMessagePart* htmlBodyPart = iMessage->HtmlBodyPartL(); |
222 |
222 |
|
223 TBool bodyPartAvailable( EFalse ); |
223 if ( htmlBodyPart ) |
224 if ( htmlBodyPart ) |
224 { |
225 { |
225 CleanupStack::PushL( htmlBodyPart ); |
226 CleanupStack::PushL( htmlBodyPart ); |
226 |
227 |
227 RFile htmlFile = htmlBodyPart->GetContentFileL(); |
228 RFile htmlFile = htmlBodyPart->GetContentFileL(); |
228 CleanupClosePushL( htmlFile ); |
229 CleanupClosePushL( htmlFile ); |
229 |
230 |
230 // Copy html body part to email html file |
231 // Copy html body part to email html file |
231 CopyFileToHtmlFileL( htmlFile, KBodyHtmlFile, *htmlBodyPart ); |
232 CopyFileToHtmlFileL( htmlFile, KBodyHtmlFile, *htmlBodyPart ); |
|
233 bodyPartAvailable = ETrue; |
232 |
234 |
233 CleanupStack::PopAndDestroy( &htmlFile ); |
235 CleanupStack::PopAndDestroy( &htmlFile ); |
234 CleanupStack::PopAndDestroy( htmlBodyPart ); |
236 CleanupStack::PopAndDestroy( htmlBodyPart ); |
235 } |
237 } |
236 else |
238 else |
252 textBodyPart->GetContentToBufferL(bufPtr,0); |
254 textBodyPart->GetContentToBufferL(bufPtr,0); |
253 HBufC8* contentBuffer8=HBufC8::NewLC(contentBuffer->Length()); |
255 HBufC8* contentBuffer8=HBufC8::NewLC(contentBuffer->Length()); |
254 |
256 |
255 contentBuffer8->Des().Copy(*contentBuffer); |
257 contentBuffer8->Des().Copy(*contentBuffer); |
256 CopyFileToHtmlFileL( *contentBuffer8, KBodyHtmlFile, *textBodyPart ); |
258 CopyFileToHtmlFileL( *contentBuffer8, KBodyHtmlFile, *textBodyPart ); |
|
259 bodyPartAvailable = ETrue; |
257 |
260 |
258 CleanupStack::PopAndDestroy( contentBuffer8 ); |
261 CleanupStack::PopAndDestroy( contentBuffer8 ); |
259 CleanupStack::PopAndDestroy( contentBuffer ); |
262 CleanupStack::PopAndDestroy( contentBuffer ); |
260 CleanupStack::PopAndDestroy( textBodyPart ); |
263 CleanupStack::PopAndDestroy( textBodyPart ); |
261 } |
264 } |
262 |
265 |
263 } |
266 } |
264 // pass the emailHtmlFile to the browser for it to load |
267 // pass the emailHtmlFile to the browser for it to load |
265 TPath emailHtmlFile; |
268 if ( bodyPartAvailable ) |
266 emailHtmlFile.Copy( iHtmlFolderPath ); |
269 { |
267 emailHtmlFile.Append( KMessageHtmlFile ); |
270 TPath emailHtmlFile; |
268 LoadContentFromFileL( emailHtmlFile ); |
271 emailHtmlFile.Copy( iHtmlFolderPath ); |
|
272 emailHtmlFile.Append( KMessageHtmlFile ); |
|
273 LoadContentFromFileL( emailHtmlFile ); |
|
274 } |
269 } |
275 } |
270 |
276 |
271 // --------------------------------------------------------------------------- |
277 // --------------------------------------------------------------------------- |
272 // Reset content |
278 // Reset content |
273 // --------------------------------------------------------------------------- |
279 // --------------------------------------------------------------------------- |
994 RFile targetFile; |
1000 RFile targetFile; |
995 CleanupClosePushL( targetFile ); |
1001 CleanupClosePushL( targetFile ); |
996 |
1002 |
997 User::LeaveIfError( targetFile.Replace( iFs, aFileName, EFileWrite ) ); |
1003 User::LeaveIfError( targetFile.Replace( iFs, aFileName, EFileWrite ) ); |
998 |
1004 |
999 HBufC8* charSet = GetCharacterSetL( aHtmlBodyPart ); |
1005 HBufC8* charSet = GetCharacterSetL( aHtmlBodyPart ); |
1000 CleanupStack::PushL( charSet ); |
1006 CleanupStack::PushL( charSet ); |
1001 |
1007 |
1002 User::LeaveIfError( targetFile.Write( KHtmlHeader1 ) ); |
1008 User::LeaveIfError( targetFile.Write( KHtmlHeader1 ) ); |
1003 User::LeaveIfError( targetFile.Write( *charSet ) ); |
1009 User::LeaveIfError( targetFile.Write( *charSet ) ); |
1004 User::LeaveIfError( targetFile.Write( KHtmlHeader2 ) ); |
1010 User::LeaveIfError( targetFile.Write( KHtmlHeader2 ) ); |
1006 |
1012 |
1007 |
1013 |
1008 // Write the original content |
1014 // Write the original content |
1009 for(int i=0;i<aContent.Length();i++) |
1015 for(int i=0;i<aContent.Length();i++) |
1010 { |
1016 { |
1011 if( i==aContent.Length()-1 ) |
1017 if( i==aContent.Length()-1 ) |
1012 { |
1018 { |
1013 aContent.Mid( i,1 ).CompareC( _L8("\x01" ) )==0 ? |
1019 aContent.Mid( i,1 ).CompareC( _L8("\x01" ) )==0 ? |
1014 User::LeaveIfError( targetFile.Write( _L8("<br>") ) ): |
1020 User::LeaveIfError( targetFile.Write( _L8("<br>") ) ): |
1015 User::LeaveIfError( targetFile.Write( aContent.Mid(i,1) ) ); |
1021 User::LeaveIfError( targetFile.Write( aContent.Mid(i,1) ) ); |
1016 } |
1022 } |
1017 else |
1023 else |
1018 { |
1024 { |
1019 if(aContent.Mid( i,1 ).CompareC( _L8("\x01" ) )==0 || |
1025 if(aContent.Mid( i,1 ).CompareC( _L8("\x01" ) )==0 || |
1020 aContent.Mid( i,2 ).CompareC( _L8("\x0D\x0A" ) )==0 ) |
1026 aContent.Mid( i,2 ).CompareC( _L8("\x0D\x0A" ) )==0 ) |
1021 { |
1027 { |
1022 User::LeaveIfError( targetFile.Write( _L8("<br>") )); |
1028 User::LeaveIfError( targetFile.Write( _L8("<br>") )); |
1023 } |
1029 } |
1024 else |
1030 else |
1025 { |
1031 { |
1026 User::LeaveIfError( targetFile.Write( aContent.Mid(i,1) ) ); |
1032 User::LeaveIfError( targetFile.Write( aContent.Mid(i,1) ) ); |
1027 } |
1033 } |
1028 } |
1034 } |
1029 } |
1035 } |
1030 INFO("Add end tags"); |
1036 INFO("Add end tags"); |
1031 User::LeaveIfError( targetFile.Write( KHtmlEndTags ) ); |
1037 User::LeaveIfError( targetFile.Write( KHtmlEndTags ) ); |
1032 |
1038 |
1033 |
1039 |
1100 TUid uid; |
1106 TUid uid; |
1101 uid.iUid = KCharacterSetIdentifierUtf8; |
1107 uid.iUid = KCharacterSetIdentifierUtf8; |
1102 TRAP_IGNORE( iBrCtlInterface->LoadDataL(KHTMLDataScheme, KHTMLEmptyContent, _L8("text/html"), uid) ); |
1108 TRAP_IGNORE( iBrCtlInterface->LoadDataL(KHTMLDataScheme, KHTMLEmptyContent, _L8("text/html"), uid) ); |
1103 } |
1109 } |
1104 } |
1110 } |
|
1111 |
|
1112 void CFsEmailUiHtmlViewerContainer::HandleResourceChange( TInt aType ) |
|
1113 { |
|
1114 CCoeControl::HandleResourceChange( aType ); |
|
1115 |
|
1116 if ( aType == CFsEmailUiViewBase::EScreenLayoutChanged ) |
|
1117 { |
|
1118 // only update header if we get a layout change from email ui |
|
1119 if ( iMessage ) |
|
1120 { |
|
1121 // update the width in header part and reload |
|
1122 TPath headerHtmlFile; |
|
1123 headerHtmlFile.Copy( iHtmlFolderPath ); |
|
1124 headerHtmlFile.Append( KHeaderHtmlFile ); |
|
1125 |
|
1126 TRAP_IGNORE( CFreestyleMessageHeaderHTML::ExportL( *iMessage, iFs, headerHtmlFile, iAppUi.ClientRect().Width() ) ) |
|
1127 |
|
1128 TPath emailHtmlFile; |
|
1129 emailHtmlFile.Copy( iHtmlFolderPath ); |
|
1130 emailHtmlFile.Append( KMessageHtmlFile ); |
|
1131 |
|
1132 TRAP_IGNORE( LoadContentFromFileL( emailHtmlFile ) ) |
|
1133 |
|
1134 SetRect( iAppUi.ClientRect() ); |
|
1135 } |
|
1136 } |
|
1137 } |