diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-29 16:17:04 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-04 12:57:04 +0200 |
commit | e452707fdfbd61be1e5633b516b653b7337e7865 (patch) | |
tree | 1e1d4b48ebf8d381f292436f2ba04b8763edc5de /framework/src/domain/mime/mailtemplates.cpp | |
parent | 5a1033bdace740799a6e03389bee30e5a4de5d44 (diff) | |
download | kube-e452707fdfbd61be1e5633b516b653b7337e7865.tar.gz kube-e452707fdfbd61be1e5633b516b653b7337e7865.zip |
Reduced the messagetreeparser to aproximately what we actually require
While in a much more managable state it's still not pretty.
However, further refactoring can now gradually happen as we need to do
further work on it.
Things that should happen eventually:
* Simplify the logic that creates the messageparts (we don't need the whole formatter plugin complexity)
* Get rid of the nodehelper (let the parts hold the necessary data)
* Get rid of partmetadata (let the part handleit)
Diffstat (limited to 'framework/src/domain/mime/mailtemplates.cpp')
-rw-r--r-- | framework/src/domain/mime/mailtemplates.cpp | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/framework/src/domain/mime/mailtemplates.cpp b/framework/src/domain/mime/mailtemplates.cpp index 254dbba3..cb298231 100644 --- a/framework/src/domain/mime/mailtemplates.cpp +++ b/framework/src/domain/mime/mailtemplates.cpp | |||
@@ -34,10 +34,7 @@ | |||
34 | #include <KCodecs/KCharsets> | 34 | #include <KCodecs/KCharsets> |
35 | #include <KMime/Types> | 35 | #include <KMime/Types> |
36 | 36 | ||
37 | #include "stringhtmlwriter.h" | 37 | #include <mimetreeparser/objecttreeparser.h> |
38 | #include "objecttreesource.h" | ||
39 | |||
40 | #include <otp/objecttreeparser.h> | ||
41 | 38 | ||
42 | namespace KMime { | 39 | namespace KMime { |
43 | namespace Types { | 40 | namespace Types { |
@@ -788,10 +785,7 @@ void MailTemplates::reply(const KMime::Message::Ptr &origMsg, const std::functio | |||
788 | auto definedLocale = QLocale::system(); | 785 | auto definedLocale = QLocale::system(); |
789 | 786 | ||
790 | //TODO set empty source instead | 787 | //TODO set empty source instead |
791 | StringHtmlWriter htmlWriter; | 788 | MimeTreeParser::ObjectTreeParser otp; |
792 | MimeTreeParser::NodeHelper nodeHelper; | ||
793 | ObjectTreeSource source(&htmlWriter); | ||
794 | MimeTreeParser::ObjectTreeParser otp(&source, &nodeHelper); | ||
795 | otp.setAllowAsync(false); | 789 | otp.setAllowAsync(false); |
796 | otp.parseObjectTree(origMsg.data()); | 790 | otp.parseObjectTree(origMsg.data()); |
797 | 791 | ||
@@ -813,12 +807,12 @@ void MailTemplates::reply(const KMime::Message::Ptr &origMsg, const std::functio | |||
813 | const auto htmlContent = otp.htmlContent(); | 807 | const auto htmlContent = otp.htmlContent(); |
814 | 808 | ||
815 | plainMessageText(plainTextContent, htmlContent, stripSignature, [=] (const QString &body) { | 809 | plainMessageText(plainTextContent, htmlContent, stripSignature, [=] (const QString &body) { |
816 | //Quoted body | 810 | //Quoted body */ |
817 | QString plainQuote = quotedPlainText(body, origMsg->from()->displayString()); | 811 | QString plainQuote = quotedPlainText(body, origMsg->from()->displayString()); |
818 | if (plainQuote.endsWith(QLatin1Char('\n'))) { | 812 | if (plainQuote.endsWith(QLatin1Char('\n'))) { |
819 | plainQuote.chop(1); | 813 | plainQuote.chop(1); |
820 | } | 814 | } |
821 | //The plain body is complete | 815 | //The plain body is complete */ |
822 | auto plainBodyResult = plainBody + plainQuote; | 816 | auto plainBodyResult = plainBody + plainQuote; |
823 | htmlMessageText(plainTextContent, htmlContent, stripSignature, [=] (const QString &body, const QString &headElement) { | 817 | htmlMessageText(plainTextContent, htmlContent, stripSignature, [=] (const QString &body, const QString &headElement) { |
824 | //The html body is complete | 818 | //The html body is complete |
@@ -829,7 +823,7 @@ void MailTemplates::reply(const KMime::Message::Ptr &origMsg, const std::functio | |||
829 | makeValidHtml(htmlBodyResult, headElement); | 823 | makeValidHtml(htmlBodyResult, headElement); |
830 | } | 824 | } |
831 | 825 | ||
832 | //Assemble the message | 826 | //Assemble the message */ |
833 | addProcessedBodyToMessage(msg, plainBodyResult, htmlBodyResult, false); | 827 | addProcessedBodyToMessage(msg, plainBodyResult, htmlBodyResult, false); |
834 | applyCharset(msg, origMsg); | 828 | applyCharset(msg, origMsg); |
835 | msg->assemble(); | 829 | msg->assemble(); |