diff options
-rw-r--r-- | framework/src/domain/composercontroller.cpp | 2 | ||||
-rw-r--r-- | framework/src/domain/mime/mailtemplates.cpp | 22 | ||||
-rw-r--r-- | framework/src/domain/mime/mailtemplates.h | 1 |
3 files changed, 19 insertions, 6 deletions
diff --git a/framework/src/domain/composercontroller.cpp b/framework/src/domain/composercontroller.cpp index 9e006af4..43701d36 100644 --- a/framework/src/domain/composercontroller.cpp +++ b/framework/src/domain/composercontroller.cpp | |||
@@ -337,7 +337,7 @@ void ComposerController::setMessage(const KMime::Message::Ptr &msg) | |||
337 | mBccModel->setStringList(getStringListFromAddresses(msg->bcc(true)->asUnicodeString())); | 337 | mBccModel->setStringList(getStringListFromAddresses(msg->bcc(true)->asUnicodeString())); |
338 | 338 | ||
339 | setSubject(msg->subject(true)->asUnicodeString()); | 339 | setSubject(msg->subject(true)->asUnicodeString()); |
340 | setBody(msg->body()); | 340 | setBody(MailTemplates::plaintextContent(msg)); |
341 | 341 | ||
342 | //TODO use ObjecTreeParser to get encrypted attachments as well | 342 | //TODO use ObjecTreeParser to get encrypted attachments as well |
343 | foreach (const auto &att, msg->attachments()) { | 343 | foreach (const auto &att, msg->attachments()) { |
diff --git a/framework/src/domain/mime/mailtemplates.cpp b/framework/src/domain/mime/mailtemplates.cpp index cb298231..5d91a7f0 100644 --- a/framework/src/domain/mime/mailtemplates.cpp +++ b/framework/src/domain/mime/mailtemplates.cpp | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <QWebEngineScript> | 30 | #include <QWebEngineScript> |
31 | #include <QSysInfo> | 31 | #include <QSysInfo> |
32 | #include <QTextCodec> | 32 | #include <QTextCodec> |
33 | #include <QTextDocument> | ||
33 | 34 | ||
34 | #include <KCodecs/KCharsets> | 35 | #include <KCodecs/KCharsets> |
35 | #include <KMime/Types> | 36 | #include <KMime/Types> |
@@ -784,11 +785,6 @@ void MailTemplates::reply(const KMime::Message::Ptr &origMsg, const std::functio | |||
784 | 785 | ||
785 | auto definedLocale = QLocale::system(); | 786 | auto definedLocale = QLocale::system(); |
786 | 787 | ||
787 | //TODO set empty source instead | ||
788 | MimeTreeParser::ObjectTreeParser otp; | ||
789 | otp.setAllowAsync(false); | ||
790 | otp.parseObjectTree(origMsg.data()); | ||
791 | |||
792 | //Add quoted body | 788 | //Add quoted body |
793 | QString plainBody; | 789 | QString plainBody; |
794 | QString htmlBody; | 790 | QString htmlBody; |
@@ -803,6 +799,8 @@ void MailTemplates::reply(const KMime::Message::Ptr &origMsg, const std::functio | |||
803 | //Strip signature for replies | 799 | //Strip signature for replies |
804 | const bool stripSignature = true; | 800 | const bool stripSignature = true; |
805 | 801 | ||
802 | MimeTreeParser::ObjectTreeParser otp; | ||
803 | otp.parseObjectTree(origMsg.data()); | ||
806 | const auto plainTextContent = otp.plainTextContent(); | 804 | const auto plainTextContent = otp.plainTextContent(); |
807 | const auto htmlContent = otp.htmlContent(); | 805 | const auto htmlContent = otp.htmlContent(); |
808 | 806 | ||
@@ -832,3 +830,17 @@ void MailTemplates::reply(const KMime::Message::Ptr &origMsg, const std::functio | |||
832 | }); | 830 | }); |
833 | }); | 831 | }); |
834 | } | 832 | } |
833 | |||
834 | QString MailTemplates::plaintextContent(const KMime::Message::Ptr &msg) | ||
835 | { | ||
836 | MimeTreeParser::ObjectTreeParser otp; | ||
837 | otp.parseObjectTree(msg.data()); | ||
838 | const auto plain = otp.plainTextContent(); | ||
839 | if (plain.isEmpty()) { | ||
840 | //Maybe not as good as the webengine version, but works at least for simple html content | ||
841 | QTextDocument doc; | ||
842 | doc.setHtml(otp.htmlContent()); | ||
843 | return doc.toPlainText(); | ||
844 | } | ||
845 | return plain; | ||
846 | } | ||
diff --git a/framework/src/domain/mime/mailtemplates.h b/framework/src/domain/mime/mailtemplates.h index db269c96..4f559bb6 100644 --- a/framework/src/domain/mime/mailtemplates.h +++ b/framework/src/domain/mime/mailtemplates.h | |||
@@ -26,4 +26,5 @@ | |||
26 | namespace MailTemplates | 26 | namespace MailTemplates |
27 | { | 27 | { |
28 | void reply(const KMime::Message::Ptr &origMsg, const std::function<void(const KMime::Message::Ptr &result)> &callback); | 28 | void reply(const KMime::Message::Ptr &origMsg, const std::function<void(const KMime::Message::Ptr &result)> &callback); |
29 | QString plaintextContent(const KMime::Message::Ptr &origMsg); | ||
29 | }; | 30 | }; |