summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/mime/mimetreeparser/otp/bodypartformatter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser/otp/bodypartformatter.cpp')
-rw-r--r--framework/src/domain/mime/mimetreeparser/otp/bodypartformatter.cpp147
1 files changed, 0 insertions, 147 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/otp/bodypartformatter.cpp b/framework/src/domain/mime/mimetreeparser/otp/bodypartformatter.cpp
deleted file mode 100644
index 63d7e92c..00000000
--- a/framework/src/domain/mime/mimetreeparser/otp/bodypartformatter.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
1/* -*- mode: C++; c-file-style: "gnu" -*-
2 bodypartformatter.cpp
3
4 This file is part of KMail's plugin interface.
5 Copyright (c) 2016 Sandro Knauß <sknauss@kde.org>
6
7 KMail is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 KMail is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21 In addition, as a special exception, the copyright holders give
22 permission to link the code of this program with any edition of
23 the Qt library by Trolltech AS, Norway (or with modified versions
24 of Qt that use the same license as Qt), and distribute linked
25 combinations including the two. You must obey the GNU General
26 Public License in all respects for all of the code used other than
27 Qt. If you modify this file, you may extend this exception to
28 your version of the file, but you are not obligated to do so. If
29 you do not wish to do so, delete this exception statement from
30 your version.
31*/
32
33#include "bodypartformatter.h"
34
35#include "bodypart.h"
36#include "queuehtmlwriter.h"
37#include "objecttreeparser.h"
38
39using namespace MimeTreeParser::Interface;
40
41namespace MimeTreeParser
42{
43namespace Interface
44{
45
46class MessagePartPrivate
47{
48public:
49 MessagePartPrivate(const BodyPart *part)
50 : mHtmlWriter(nullptr)
51 , mPart(part)
52 , mParentPart(nullptr)
53 , mCreatedWriter(false)
54 {
55 }
56
57 ~MessagePartPrivate()
58 {
59 if (mCreatedWriter) {
60 delete mHtmlWriter;
61 }
62 }
63
64 MimeTreeParser::HtmlWriter *htmlWriter()
65 {
66 if (!mHtmlWriter && mPart) {
67 mHtmlWriter = mPart->objectTreeParser()->htmlWriter();
68 }
69 return mHtmlWriter;
70 }
71
72 MimeTreeParser::HtmlWriter *mHtmlWriter;
73 const BodyPart *mPart;
74 MessagePart *mParentPart;
75 bool mCreatedWriter;
76
77};
78}
79}
80
81MessagePart::MessagePart()
82 : QObject()
83 , d(new MessagePartPrivate(nullptr))
84{
85}
86
87MessagePart::MessagePart(const BodyPart &part)
88 : QObject()
89 , d(new MessagePartPrivate(&part))
90{
91}
92
93MessagePart::~MessagePart()
94{
95 delete d;
96}
97
98void MessagePart::html(bool decorate)
99{
100 Q_UNUSED(decorate);
101 static_cast<QueueHtmlWriter *>(d->mHtmlWriter)->replay();
102}
103
104QString MessagePart::text() const
105{
106 return QString();
107}
108
109MessagePart *MessagePart::parentPart() const
110{
111 return d->mParentPart;
112}
113
114void MessagePart::setParentPart(MessagePart *parentPart)
115{
116 d->mParentPart = parentPart;
117}
118
119QString MessagePart::htmlContent() const
120{
121 return text();
122}
123
124QString MessagePart::plaintextContent() const
125{
126 return text();
127}
128
129MimeTreeParser::HtmlWriter *MessagePart::htmlWriter() const
130{
131 return d->htmlWriter();
132}
133
134void MessagePart::setHtmlWriter(MimeTreeParser::HtmlWriter *htmlWriter) const
135{
136 if (d->mHtmlWriter) {
137 d->mHtmlWriter = htmlWriter;
138 }
139}
140
141MessagePart::Ptr BodyPartFormatter::process(BodyPart &part) const
142{
143 auto mp = MessagePart::Ptr(new MessagePart(part));
144 mp->setHtmlWriter(new QueueHtmlWriter(mp->htmlWriter()));
145 mp->d->mCreatedWriter = true;
146 return mp;
147}