diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-22 20:35:07 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-22 20:35:07 +0200 |
commit | 5dc6151910f5583d1abe559337a6cd89139b149e (patch) | |
tree | 9ff0e75dcb34ee003b5cc16b5a12df6b5068716d /framework/src/domain/mime/mailtemplates.cpp | |
parent | e754d1b038c16db15811c50d6035c6900626e478 (diff) | |
download | kube-5dc6151910f5583d1abe559337a6cd89139b149e.tar.gz kube-5dc6151910f5583d1abe559337a6cd89139b149e.zip |
Also load slightly more complex mails.
And convert simple html to plaintext.
Diffstat (limited to 'framework/src/domain/mime/mailtemplates.cpp')
-rw-r--r-- | framework/src/domain/mime/mailtemplates.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
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 | } | ||