summaryrefslogtreecommitdiffstats
path: root/framework/src
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src')
-rw-r--r--framework/src/domain/mime/mimetreeparser/CMakeLists.txt1
-rw-r--r--framework/src/domain/mime/mimetreeparser/bodypartformatter_impl.cpp48
-rw-r--r--framework/src/domain/mime/mimetreeparser/multipartmixed.cpp57
-rw-r--r--framework/src/domain/mime/mimetreeparser/multipartmixed.h39
4 files changed, 47 insertions, 98 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/CMakeLists.txt b/framework/src/domain/mime/mimetreeparser/CMakeLists.txt
index c3f317ee..432234cf 100644
--- a/framework/src/domain/mime/mimetreeparser/CMakeLists.txt
+++ b/framework/src/domain/mime/mimetreeparser/CMakeLists.txt
@@ -17,7 +17,6 @@ set(libmimetreeparser_SRCS
17 mailman.cpp 17 mailman.cpp
18 multipartalternative.cpp 18 multipartalternative.cpp
19 multipartencrypted.cpp 19 multipartencrypted.cpp
20 multipartmixed.cpp
21 multipartsigned.cpp 20 multipartsigned.cpp
22 textplain.cpp 21 textplain.cpp
23 texthtml.cpp 22 texthtml.cpp
diff --git a/framework/src/domain/mime/mimetreeparser/bodypartformatter_impl.cpp b/framework/src/domain/mime/mimetreeparser/bodypartformatter_impl.cpp
index 3522a144..882dfc05 100644
--- a/framework/src/domain/mime/mimetreeparser/bodypartformatter_impl.cpp
+++ b/framework/src/domain/mime/mimetreeparser/bodypartformatter_impl.cpp
@@ -35,7 +35,6 @@
35#include "applicationpkcs7mime.h" 35#include "applicationpkcs7mime.h"
36#include "mailman.h" 36#include "mailman.h"
37#include "multipartalternative.h" 37#include "multipartalternative.h"
38#include "multipartmixed.h"
39#include "multipartencrypted.h" 38#include "multipartencrypted.h"
40#include "multipartsigned.h" 39#include "multipartsigned.h"
41#include "texthtml.h" 40#include "texthtml.h"
@@ -113,6 +112,52 @@ public:
113 112
114const HeadersBodyPartFormatter *HeadersBodyPartFormatter::self = nullptr; 113const HeadersBodyPartFormatter *HeadersBodyPartFormatter::self = nullptr;
115 114
115class MultiPartRelatedBodyPartFormatter: public MimeTreeParser::Interface::BodyPartFormatter {
116 static const MultiPartRelatedBodyPartFormatter *self;
117public:
118 MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE {
119 if (part.content()->contents().isEmpty()) {
120 return MessagePart::Ptr();
121 }
122 //We rely on the order of the parts.
123 //Theoretically there could also be a Start parameter which would break this..
124 //https://tools.ietf.org/html/rfc2387#section-4
125 return MimeMessagePart::Ptr(new MimeMessagePart(part.objectTreeParser(), part.content()->contents().at(0), true));
126 }
127
128 static const MimeTreeParser::Interface::BodyPartFormatter *create() {
129 if (!self) {
130 self = new MultiPartRelatedBodyPartFormatter();
131 }
132 return self;
133 }
134};
135
136const MultiPartRelatedBodyPartFormatter *MultiPartRelatedBodyPartFormatter::self = nullptr;
137
138class MultiPartMixedBodyPartFormatter: public MimeTreeParser::Interface::BodyPartFormatter {
139 static const MultiPartMixedBodyPartFormatter *self;
140public:
141 MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE {
142 if (part.content()->contents().isEmpty()) {
143 return {};
144 }
145 //FIXME sometimes we get attachments in here as well
146 //TODO look for attachment parts anyways
147 // normal treatment of the parts in the mp/mixed container
148 return MimeMessagePart::Ptr(new MimeMessagePart(part.objectTreeParser(), part.content()->contents().at(0), false));
149 }
150
151 static const MimeTreeParser::Interface::BodyPartFormatter *create() {
152 if (!self) {
153 self = new MultiPartMixedBodyPartFormatter();
154 }
155 return self;
156 }
157};
158
159const MultiPartMixedBodyPartFormatter *MultiPartMixedBodyPartFormatter::self = nullptr;
160
116} // anon namespace 161} // anon namespace
117 162
118void BodyPartFormatterBaseFactoryPrivate::messageviewer_create_builtin_bodypart_formatters() 163void BodyPartFormatterBaseFactoryPrivate::messageviewer_create_builtin_bodypart_formatters()
@@ -140,6 +185,7 @@ void BodyPartFormatterBaseFactoryPrivate::messageviewer_create_builtin_bodypart_
140 insert("multipart", "alternative", MultiPartAlternativeBodyPartFormatter::create()); 185 insert("multipart", "alternative", MultiPartAlternativeBodyPartFormatter::create());
141 insert("multipart", "encrypted", MultiPartEncryptedBodyPartFormatter::create()); 186 insert("multipart", "encrypted", MultiPartEncryptedBodyPartFormatter::create());
142 insert("multipart", "signed", MultiPartSignedBodyPartFormatter::create()); 187 insert("multipart", "signed", MultiPartSignedBodyPartFormatter::create());
188 insert("multipart", "related", MultiPartRelatedBodyPartFormatter::create());
143 insert("multipart", "*", MultiPartMixedBodyPartFormatter::create()); 189 insert("multipart", "*", MultiPartMixedBodyPartFormatter::create());
144 insert("*", "*", AnyTypeBodyPartFormatter::create()); 190 insert("*", "*", AnyTypeBodyPartFormatter::create());
145} 191}
diff --git a/framework/src/domain/mime/mimetreeparser/multipartmixed.cpp b/framework/src/domain/mime/mimetreeparser/multipartmixed.cpp
deleted file mode 100644
index 4231021e..00000000
--- a/framework/src/domain/mime/mimetreeparser/multipartmixed.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 Copyright (c) 2016 Sandro Knauß <sknauss@kde.org>
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
20#include "multipartmixed.h"
21
22#include "objecttreeparser.h"
23#include "messagepart.h"
24
25#include <KMime/Content>
26
27#include "mimetreeparser_debug.h"
28
29using namespace MimeTreeParser;
30
31const MultiPartMixedBodyPartFormatter *MultiPartMixedBodyPartFormatter::self;
32
33const Interface::BodyPartFormatter *MultiPartMixedBodyPartFormatter::create()
34{
35 if (!self) {
36 self = new MultiPartMixedBodyPartFormatter();
37 }
38 return self;
39}
40MessagePart::Ptr MultiPartMixedBodyPartFormatter::process(Interface::BodyPart &part) const
41{
42 if (part.content()->contents().isEmpty()) {
43 return MessagePart::Ptr();
44 }
45
46 //In case of multipart/related we relay on the order of the parts.
47 //Theoretically there could also be a Start parameter which would break this..
48 //https://tools.ietf.org/html/rfc2387#section-4
49 bool showOnlyOneMimePart = [&] {
50 if (auto ct = part.content()->contentType(false)) {
51 return ct->mimeType() == "multipart/related";
52 }
53 return false;
54 }();
55 // normal treatment of the parts in the mp/mixed container
56 return MimeMessagePart::Ptr(new MimeMessagePart(part.objectTreeParser(), part.content()->contents().at(0), showOnlyOneMimePart));
57}
diff --git a/framework/src/domain/mime/mimetreeparser/multipartmixed.h b/framework/src/domain/mime/mimetreeparser/multipartmixed.h
deleted file mode 100644
index 7dfd85f6..00000000
--- a/framework/src/domain/mime/mimetreeparser/multipartmixed.h
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 Copyright (c) 2016 Sandro Knauß <sknauss@kde.org>
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
20#ifndef __MIMETREEPARSER_BODYFORAMATTER_MULTIPARTMIXED_H__
21#define __MIMETREEPARSER_BODYFORAMATTER_MULTIPARTMIXED_H__
22
23#include "bodypartformatter.h"
24#include "bodypart.h"
25
26namespace MimeTreeParser
27{
28
29class MultiPartMixedBodyPartFormatter : public Interface::BodyPartFormatter
30{
31 static const MultiPartMixedBodyPartFormatter *self;
32public:
33 MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE;
34 static const Interface::BodyPartFormatter *create();
35};
36
37}
38
39#endif