From ad387cce77cf788fbad2da27c987f78dac4db477 Mon Sep 17 00:00:00 2001 From: "Hoa V. DINH" Date: Wed, 13 Nov 2013 00:54:48 -0800 Subject: Fixed #260: added ability to render a message without stripping spaces --- src/core/imap/MCIMAPSession.cc | 20 +++++++++++--------- src/core/imap/MCIMAPSession.h | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src/core/imap') diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 95662f3b..6c553e65 100755 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -3417,7 +3417,7 @@ String * IMAPSession::plainTextRendering(IMAPMessage * message, String * folder, return plainTextString; } -String * IMAPSession::plainTextBodyRendering(IMAPMessage * message, String * folder, ErrorCode * pError) +String * IMAPSession::plainTextBodyRendering(IMAPMessage * message, String * folder, bool stripWhitespace, ErrorCode * pError) { String * htmlBodyString = htmlBodyRendering(message, folder, pError); @@ -3427,14 +3427,16 @@ String * IMAPSession::plainTextBodyRendering(IMAPMessage * message, String * fol String * plainTextBodyString = htmlBodyString->flattenHTML(); - plainTextBodyString->replaceOccurrencesOfString(MCSTR("\t"), MCSTR(" ")); - plainTextBodyString->replaceOccurrencesOfString(MCSTR("\n"), MCSTR(" ")); - plainTextBodyString->replaceOccurrencesOfString(MCSTR("\v"), MCSTR(" ")); - plainTextBodyString->replaceOccurrencesOfString(MCSTR("\f"), MCSTR(" ")); - plainTextBodyString->replaceOccurrencesOfString(MCSTR("\r"), MCSTR(" ")); - - while (plainTextBodyString->replaceOccurrencesOfString(MCSTR(" "), MCSTR(" ")) > 0) { - /* do nothing */ + if (stripWhitespace) { + plainTextBodyString->replaceOccurrencesOfString(MCSTR("\t"), MCSTR(" ")); + plainTextBodyString->replaceOccurrencesOfString(MCSTR("\n"), MCSTR(" ")); + plainTextBodyString->replaceOccurrencesOfString(MCSTR("\v"), MCSTR(" ")); + plainTextBodyString->replaceOccurrencesOfString(MCSTR("\f"), MCSTR(" ")); + plainTextBodyString->replaceOccurrencesOfString(MCSTR("\r"), MCSTR(" ")); + + while (plainTextBodyString->replaceOccurrencesOfString(MCSTR(" "), MCSTR(" ")) > 0) { + /* do nothing */ + } } return plainTextBodyString; diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index 3c819616..a8a7279b 100755 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -175,9 +175,9 @@ namespace mailcore { /** Text rendering of the message.*/ virtual String * plainTextRendering(IMAPMessage * message, String * folder, ErrorCode * pError); - /** Text rendering of the body of the message. All end of line will be removed and white spaces cleaned up. + /** Text rendering of the body of the message. All end of line will be removed and white spaces cleaned up if requested. This method can be used to generate the summary of the message.*/ - virtual String * plainTextBodyRendering(IMAPMessage * message, String * folder, ErrorCode * pError); + virtual String * plainTextBodyRendering(IMAPMessage * message, String * folder, bool stripWhitespace, ErrorCode * pError); /** Enable automatic query of the capabilities of the IMAP server when set to true. */ virtual void setAutomaticConfigurationEnabled(bool enabled); -- cgit v1.2.3