214 // |
214 // |
215 // --------------------------------------------------------------------------- |
215 // --------------------------------------------------------------------------- |
216 // |
216 // |
217 void CEUiHtmlViewerSettings::AddKeyListenerL( TUint32 aKey ) |
217 void CEUiHtmlViewerSettings::AddKeyListenerL( TUint32 aKey ) |
218 { |
218 { |
219 CEUiHtmlViewerSettingsKeyListener* listener = new (ELeave) CEUiHtmlViewerSettingsKeyListener(*this, aKey); |
219 CEUiHtmlViewerSettingsKeyListener* listener = |
220 CleanupStack::PushL(listener); |
220 new (ELeave) CEUiHtmlViewerSettingsKeyListener( *this, aKey ); |
221 iKeyListeners.AppendL(listener); |
221 CleanupStack::PushL( listener ); |
222 CleanupStack::Pop(); // listener |
222 iKeyListeners.AppendL( listener ); |
223 UpdateValue(aKey); |
223 CleanupStack::Pop( listener ); |
|
224 UpdateValue( aKey ); |
224 } |
225 } |
225 |
226 |
226 // --------------------------------------------------------------------------- |
227 // --------------------------------------------------------------------------- |
227 // |
228 // |
228 // --------------------------------------------------------------------------- |
229 // --------------------------------------------------------------------------- |
500 //Enable advance pointer info for multi-touch. |
502 //Enable advance pointer info for multi-touch. |
501 Window().EnableAdvancedPointers(); |
503 Window().EnableAdvancedPointers(); |
502 #endif |
504 #endif |
503 |
505 |
504 |
506 |
505 SetRect( iView.ContainerRect() ); |
|
506 CreateBrowserControlInterfaceL(); |
|
507 |
|
508 iEventHandler = CFreestyleMessageHeaderURLEventHandler::NewL( iAppUi, iView ); |
507 iEventHandler = CFreestyleMessageHeaderURLEventHandler::NewL( iAppUi, iView ); |
509 |
508 |
510 TRect nextButtonRect = OverlayButtonRect( EFalse ); |
509 TRect nextButtonRect = OverlayButtonRect( EFalse ); |
511 iOverlayControlNext = COverlayControl::NewL( this, this, nextButtonRect, |
510 iOverlayControlNext = COverlayControl::NewL( this, this, nextButtonRect, |
512 EMbmFreestyleemailuiQgn_indi_cmail_arrow_next, |
511 EMbmFreestyleemailuiQgn_indi_cmail_arrow_next, |
1169 TPtr contentPtr( content->Des() ); |
1175 TPtr contentPtr( content->Des() ); |
1170 |
1176 |
1171 aTextBodyPart.GetContentToBufferL( contentPtr, 0 ); |
1177 aTextBodyPart.GetContentToBufferL( contentPtr, 0 ); |
1172 //When we found EFSMsgFlag_BodyTruncated was set, add "--Message too long--" in the end of plain html view |
1178 //When we found EFSMsgFlag_BodyTruncated was set, add "--Message too long--" in the end of plain html view |
1173 if ( limit < contentsize ) |
1179 if ( limit < contentsize ) |
1174 { |
1180 { |
1175 HBufC* addingText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEW_ADDITIONAL_INFO ); |
1181 // Disable this is PS1 until we have translations available |
1176 TInt pos = limit - addingText->Length(); |
1182 // HBufC* addingText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEW_ADDITIONAL_INFO , limit/KKilo ); |
1177 contentPtr.Replace(pos,addingText->Length(),*addingText); |
1183 // TInt pos = contentPtr.Length() - addingText->Length(); |
1178 CleanupStack::PopAndDestroy( addingText ); |
1184 // contentPtr.Replace(pos,addingText->Length(),*addingText); |
|
1185 // CleanupStack::PopAndDestroy( addingText ); |
1179 aTextBodyPart.SetFlag(EFSMsgFlag_BodyTruncated); |
1186 aTextBodyPart.SetFlag(EFSMsgFlag_BodyTruncated); |
1180 } |
1187 } |
1181 |
1188 |
1182 ConvertToHTML( *content, targetFileName, aTextBodyPart ); |
1189 ConvertToHTML( *content, targetFileName, aTextBodyPart ); |
1183 CleanupStack::PopAndDestroy( content ); |
1190 CleanupStack::PopAndDestroy( content ); |
1184 |
|
1185 } |
1191 } |
1186 |
1192 |
1187 // --------------------------------------------------------------------------- |
1193 // --------------------------------------------------------------------------- |
1188 // Reads given file content to buffer and return pointer to it |
1194 // Reads given file content to buffer and return pointer to it |
1189 // --------------------------------------------------------------------------- |
1195 // --------------------------------------------------------------------------- |
1190 // |
1196 // |
1191 HBufC8* CFsEmailUiHtmlViewerContainer::ReadContentFromFileLC( RFile& aFile, CFSMailMessagePart& aHtmlBodyPart ) |
1197 HBufC8* CFsEmailUiHtmlViewerContainer::ReadContentFromFileLC( RFile& aFile, |
|
1198 CFSMailMessagePart& aBodyPart ) |
1192 { |
1199 { |
1193 FUNC_LOG; |
1200 FUNC_LOG; |
1194 TInt fileSize = 0; |
1201 TInt fileSize = 0; |
|
1202 User::LeaveIfError( aFile.Size( fileSize ) ); |
|
1203 |
|
1204 HBufC* contentType = aBodyPart.GetContentType().AllocLC(); |
|
1205 TInt length = contentType->Locate(';'); |
|
1206 if( length >= 0 ) |
|
1207 { |
|
1208 contentType->Des().SetLength( length ); |
|
1209 } |
|
1210 TBool body = KFSMailContentTypeTextPlain().CompareF( contentType->Des() ) == 0 || |
|
1211 KFSMailContentTypeTextHtml().CompareF( contentType->Des() ) == 0; |
|
1212 CleanupStack::PopAndDestroy( contentType ); |
1195 |
1213 |
1196 TInt limit(0); |
1214 if ( body ) |
1197 TInt err = iViewerSettings->Repository().Get( KFreestyleMaxBodySize , limit ); |
1215 { |
1198 limit *= KKilo; // cenrep value is in kB, 0 means unlimited |
1216 // limit message size if not done already by plugins |
1199 |
1217 TInt limit(0); |
1200 User::LeaveIfError( aFile.Size( fileSize ) ); |
1218 TInt err = iViewerSettings->Repository().Get( KFreestyleMaxBodySize , limit ); |
1201 if ( limit == 0 || err ) |
1219 limit *= KKilo; // cenrep value is in kB, 0 means unlimited |
1202 { |
1220 |
1203 limit = KMaxTInt; |
1221 if ( limit == 0 || err ) |
1204 } |
1222 { |
1205 |
1223 limit = KMaxTInt; |
1206 TInt size = Min( limit, fileSize ); // read no more than limit bytes.. |
1224 } |
1207 |
1225 fileSize = Min( limit, fileSize ); // read no more than limit bytes.. |
1208 |
1226 |
1209 if ( size < fileSize ) |
1227 TInt contentSize = aBodyPart.ContentSize(); |
1210 { |
1228 TInt fetchedSize = aBodyPart.FetchedContentSize(); |
1211 aHtmlBodyPart.SetFlag( EFSMsgFlag_BodyTruncated ); |
1229 |
1212 } |
1230 if ( ( limit!=KMaxTInt && fileSize < contentSize ) |
1213 |
1231 || ( fetchedSize < contentSize ) ) |
1214 HBufC8* buffer = HBufC8::NewLC( size ); |
1232 { |
|
1233 aBodyPart.SetFlag( EFSMsgFlag_BodyTruncated ); |
|
1234 } |
|
1235 } |
|
1236 HBufC8* buffer = HBufC8::NewLC( fileSize ); |
1215 TPtr8 ptr = buffer->Des(); |
1237 TPtr8 ptr = buffer->Des(); |
1216 User::LeaveIfError( aFile.Read( ptr, size ) ); |
1238 User::LeaveIfError( aFile.Read( ptr, fileSize ) ); |
1217 return buffer; |
1239 return buffer; |
1218 } |
1240 } |
1219 |
1241 |
1220 // --------------------------------------------------------------------------- |
1242 // --------------------------------------------------------------------------- |
1221 // Writes buffer content to given file |
1243 // Writes buffer content to given file |
1294 } |
1316 } |
1295 } |
1317 } |
1296 |
1318 |
1297 // Write the original content |
1319 // Write the original content |
1298 User::LeaveIfError( targetFile.Write( buffer ) ); |
1320 User::LeaveIfError( targetFile.Write( buffer ) ); |
1299 //When we found EFSMsgFlag_BodyTruncated was set, add "--Message too long--" in the end of html view |
1321 if( aHtmlBodyPart.GetFlags() & EFSMsgFlag_BodyTruncated ) |
1300 if( aHtmlBodyPart.GetFlags()&EFSMsgFlag_BodyTruncated ) |
|
1301 { |
1322 { |
1302 HBufC* addingText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEW_ADDITIONAL_INFO ); |
1323 //When we found EFSMsgFlag_BodyTruncated was set, add "--- Message limited to %N kB ---" in the end of html view |
1303 HBufC8* addingText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *addingText ); |
1324 TInt limit(0); |
1304 CleanupStack::PopAndDestroy( addingText ); |
1325 TInt err = iViewerSettings->Repository().Get( KFreestyleMaxBodySize , limit ); |
1305 CleanupStack::PushL( addingText8 ); |
1326 limit *= KKilo; // cenrep value is in kB, 0 means unlimited |
1306 User::LeaveIfError( targetFile.Write( *addingText8 ) ); |
1327 if ( limit == 0 || err ) |
1307 CleanupStack::PopAndDestroy( addingText8 ); |
1328 { |
|
1329 limit = KMaxTInt; |
|
1330 } |
|
1331 |
|
1332 // Disable this is PS1 until we have translations available |
|
1333 // HBufC* addingText = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEW_ADDITIONAL_INFO, limit/KKilo ); |
|
1334 // HBufC8* addingText8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *addingText ); |
|
1335 // CleanupStack::PopAndDestroy( addingText ); |
|
1336 // CleanupStack::PushL( addingText8 ); |
|
1337 // User::LeaveIfError( targetFile.Write( *addingText8 ) ); |
|
1338 // CleanupStack::PopAndDestroy( addingText8 ); |
1308 } |
1339 } |
1309 // Write ending metadata if needed |
1340 // Write ending metadata if needed |
1310 if ( modificationNeeded || (aHtmlBodyPart.GetFlags()&EFSMsgFlag_BodyTruncated) ) |
1341 if ( modificationNeeded || (aHtmlBodyPart.GetFlags()&EFSMsgFlag_BodyTruncated) ) |
1311 { |
1342 { |
1312 INFO("Add end tags"); |
1343 INFO("Add end tags"); |