summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/mimetreeparser/otp/bodypartformatter_impl.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-23 21:00:50 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-23 21:00:50 +0200
commit31bf3102fe8f8cdd3f1448f0f22f182d0c2820d2 (patch)
treeb5b508c3f065e0f51c8ce40aaf97d7070b5f9ef5 /framework/src/domain/mimetreeparser/otp/bodypartformatter_impl.cpp
parent1948369d4da2d0bc23b6af93683982b0e65d4992 (diff)
downloadkube-31bf3102fe8f8cdd3f1448f0f22f182d0c2820d2.tar.gz
kube-31bf3102fe8f8cdd3f1448f0f22f182d0c2820d2.zip
Moved MIME related stuff to a mime subdir
Diffstat (limited to 'framework/src/domain/mimetreeparser/otp/bodypartformatter_impl.cpp')
-rw-r--r--framework/src/domain/mimetreeparser/otp/bodypartformatter_impl.cpp193
1 files changed, 0 insertions, 193 deletions
diff --git a/framework/src/domain/mimetreeparser/otp/bodypartformatter_impl.cpp b/framework/src/domain/mimetreeparser/otp/bodypartformatter_impl.cpp
deleted file mode 100644
index c8622ba3..00000000
--- a/framework/src/domain/mimetreeparser/otp/bodypartformatter_impl.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
1/* -*- c++ -*-
2 bodypartformatter.cpp
3
4 This file is part of KMail, the KDE mail client.
5 Copyright (c) 2003 Marc Mutz <mutz@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, version 2, as
9 published by the Free Software Foundation.
10
11 KMail is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 In addition, as a special exception, the copyright holders give
21 permission to link the code of this program with any edition of
22 the Qt library by Trolltech AS, Norway (or with modified versions
23 of Qt that use the same license as Qt), and distribute linked
24 combinations including the two. You must obey the GNU General
25 Public License in all respects for all of the code used other than
26 Qt. If you modify this file, you may extend this exception to
27 your version of the file, but you are not obligated to do so. If
28 you do not wish to do so, delete this exception statement from
29 your version.
30*/
31
32#include "mimetreeparser_debug.h"
33
34#include "applicationpgpencrypted.h"
35#include "applicationpkcs7mime.h"
36#include "mailman.h"
37#include "multipartalternative.h"
38#include "multipartmixed.h"
39#include "multipartencrypted.h"
40#include "multipartsigned.h"
41#include "texthtml.h"
42#include "textplain.h"
43
44#include "bodypartformatter.h"
45#include "bodypart.h"
46
47#include "bodypartformatterbasefactory.h"
48#include "bodypartformatterbasefactory_p.h"
49
50#include "attachmentstrategy.h"
51#include "objecttreeparser.h"
52#include "messagepart.h"
53
54#include <KMime/Content>
55
56using namespace MimeTreeParser;
57
58namespace
59{
60class AnyTypeBodyPartFormatter
61 : public MimeTreeParser::Interface::BodyPartFormatter
62{
63 static const AnyTypeBodyPartFormatter *self;
64public:
65 Result format(Interface::BodyPart *, HtmlWriter *) const Q_DECL_OVERRIDE
66 {
67 qCDebug(MIMETREEPARSER_LOG) << "Acting as a Interface::BodyPartFormatter!";
68 return AsIcon;
69 }
70
71 // unhide the overload with three arguments
72 using MimeTreeParser::Interface::BodyPartFormatter::format;
73
74 void adaptProcessResult(ProcessResult &result) const Q_DECL_OVERRIDE
75 {
76 result.setNeverDisplayInline(true);
77 }
78 static const MimeTreeParser::Interface::BodyPartFormatter *create()
79 {
80 if (!self) {
81 self = new AnyTypeBodyPartFormatter();
82 }
83 return self;
84 }
85};
86
87const AnyTypeBodyPartFormatter *AnyTypeBodyPartFormatter::self = nullptr;
88
89class ImageTypeBodyPartFormatter
90 : public MimeTreeParser::Interface::BodyPartFormatter
91{
92 static const ImageTypeBodyPartFormatter *self;
93public:
94 Result format(Interface::BodyPart *, HtmlWriter *) const Q_DECL_OVERRIDE
95 {
96 return AsIcon;
97 }
98
99 // unhide the overload with three arguments
100 using MimeTreeParser::Interface::BodyPartFormatter::format;
101
102 void adaptProcessResult(ProcessResult &result) const Q_DECL_OVERRIDE
103 {
104 result.setNeverDisplayInline(false);
105 result.setIsImage(true);
106 }
107 static const MimeTreeParser::Interface::BodyPartFormatter *create()
108 {
109 if (!self) {
110 self = new ImageTypeBodyPartFormatter();
111 }
112 return self;
113 }
114};
115
116const ImageTypeBodyPartFormatter *ImageTypeBodyPartFormatter::self = nullptr;
117
118class MessageRfc822BodyPartFormatter
119 : public MimeTreeParser::Interface::BodyPartFormatter
120{
121 static const MessageRfc822BodyPartFormatter *self;
122public:
123 Interface::MessagePart::Ptr process(Interface::BodyPart &) const Q_DECL_OVERRIDE;
124 MimeTreeParser::Interface::BodyPartFormatter::Result format(Interface::BodyPart *, HtmlWriter *) const Q_DECL_OVERRIDE;
125 using MimeTreeParser::Interface::BodyPartFormatter::format;
126 static const MimeTreeParser::Interface::BodyPartFormatter *create();
127};
128
129const MessageRfc822BodyPartFormatter *MessageRfc822BodyPartFormatter::self;
130
131const MimeTreeParser::Interface::BodyPartFormatter *MessageRfc822BodyPartFormatter::create()
132{
133 if (!self) {
134 self = new MessageRfc822BodyPartFormatter();
135 }
136 return self;
137}
138
139Interface::MessagePart::Ptr MessageRfc822BodyPartFormatter::process(Interface::BodyPart &part) const
140{
141 const KMime::Message::Ptr message = part.content()->bodyAsMessage();
142 return MessagePart::Ptr(new EncapsulatedRfc822MessagePart(part.objectTreeParser(), part.content(), message));
143}
144
145Interface::BodyPartFormatter::Result MessageRfc822BodyPartFormatter::format(Interface::BodyPart *part, HtmlWriter *writer) const
146{
147 Q_UNUSED(writer)
148 const ObjectTreeParser *otp = part->objectTreeParser();
149 const auto p = process(*part);
150 const auto mp = static_cast<MessagePart *>(p.data());
151 if (mp) {
152 if (!otp->attachmentStrategy()->inlineNestedMessages() && !otp->showOnlyOneMimePart()) {
153 return Failed;
154 } else {
155 mp->html(true);
156 return Ok;
157 }
158 } else {
159 return Failed;
160 }
161}
162
163typedef TextPlainBodyPartFormatter ApplicationPgpBodyPartFormatter;
164
165} // anon namespace
166
167void BodyPartFormatterBaseFactoryPrivate::messageviewer_create_builtin_bodypart_formatters()
168{
169 insert("application", "octet-stream", AnyTypeBodyPartFormatter::create());
170 insert("application", "pgp", ApplicationPgpBodyPartFormatter::create());
171 insert("application", "pkcs7-mime", ApplicationPkcs7MimeBodyPartFormatter::create());
172 insert("application", "x-pkcs7-mime", ApplicationPkcs7MimeBodyPartFormatter::create());
173 insert("application", "pgp-encrypted", ApplicationPGPEncryptedBodyPartFormatter::create());
174 insert("application", "*", AnyTypeBodyPartFormatter::create());
175
176 insert("text", "html", TextHtmlBodyPartFormatter::create());
177 insert("text", "rtf", AnyTypeBodyPartFormatter::create());
178 insert("text", "plain", MailmanBodyPartFormatter::create());
179 insert("text", "plain", TextPlainBodyPartFormatter::create());
180 insert("text", "*", MailmanBodyPartFormatter::create());
181 insert("text", "*", TextPlainBodyPartFormatter::create());
182
183 insert("image", "*", ImageTypeBodyPartFormatter::create());
184
185 insert("message", "rfc822", MessageRfc822BodyPartFormatter::create());
186 insert("message", "*", AnyTypeBodyPartFormatter::create());
187
188 insert("multipart", "alternative", MultiPartAlternativeBodyPartFormatter::create());
189 insert("multipart", "encrypted", MultiPartEncryptedBodyPartFormatter::create());
190 insert("multipart", "signed", MultiPartSignedBodyPartFormatter::create());
191 insert("multipart", "*", MultiPartMixedBodyPartFormatter::create());
192 insert("*", "*", AnyTypeBodyPartFormatter::create());
193}