diff options
Diffstat (limited to 'framework/mail/messageparser.cpp')
-rw-r--r-- | framework/mail/messageparser.cpp | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/framework/mail/messageparser.cpp b/framework/mail/messageparser.cpp deleted file mode 100644 index 89f67f38..00000000 --- a/framework/mail/messageparser.cpp +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include "messageparser.h" | ||
20 | |||
21 | #include "stringhtmlwriter.h" | ||
22 | #include "objecttreesource.h" | ||
23 | #include "csshelper.h" | ||
24 | |||
25 | #include <QFile> | ||
26 | #include <QImage> | ||
27 | #include <QDebug> | ||
28 | #include <QTime> | ||
29 | #include <MessageViewer/ObjectTreeParser> | ||
30 | |||
31 | MessageParser::MessageParser(QObject *parent) | ||
32 | : QObject(parent) | ||
33 | { | ||
34 | |||
35 | } | ||
36 | |||
37 | QString MessageParser::html() const | ||
38 | { | ||
39 | return mHtml; | ||
40 | } | ||
41 | |||
42 | QVariant MessageParser::message() const | ||
43 | { | ||
44 | return QVariant(); | ||
45 | } | ||
46 | |||
47 | void MessageParser::setMessage(const QVariant &message) | ||
48 | { | ||
49 | QTime time; | ||
50 | time.start(); | ||
51 | const auto mailData = KMime::CRLFtoLF(message.toByteArray()); | ||
52 | KMime::Message::Ptr msg(new KMime::Message); | ||
53 | msg->setContent(mailData); | ||
54 | msg->parse(); | ||
55 | qWarning() << "parsed: " << time.elapsed(); | ||
56 | |||
57 | // render the mail | ||
58 | StringHtmlWriter htmlWriter; | ||
59 | QImage paintDevice; | ||
60 | CSSHelper cssHelper(&paintDevice); | ||
61 | //temporary files only have the lifetime of the nodehelper, so we keep it around until the mail changes. | ||
62 | mNodeHelper = std::make_shared<MessageViewer::NodeHelper>(); | ||
63 | ObjectTreeSource source(&htmlWriter, &cssHelper); | ||
64 | MessageViewer::ObjectTreeParser otp(&source, mNodeHelper.get()); | ||
65 | |||
66 | htmlWriter.begin(QString()); | ||
67 | htmlWriter.queue(cssHelper.htmlHead(false)); | ||
68 | |||
69 | otp.parseObjectTree(msg.data()); | ||
70 | |||
71 | htmlWriter.queue(QStringLiteral("</body></html>")); | ||
72 | htmlWriter.end(); | ||
73 | |||
74 | mHtml = htmlWriter.html(); | ||
75 | emit htmlChanged(); | ||
76 | } | ||