diff options
author | Sandro Knauß <sknauss@kde.org> | 2016-07-22 13:23:17 +0200 |
---|---|---|
committer | Sandro Knauß <sknauss@kde.org> | 2016-07-22 13:23:17 +0200 |
commit | 903960116eb3329631702723bba11f5463eff573 (patch) | |
tree | 84e80e507289cfcb633ad09ffed03a2b1d077e83 /framework | |
parent | cf5b3e797421e7dbf2c0d7b1efff91fc07277652 (diff) | |
download | kube-903960116eb3329631702723bba11f5463eff573.tar.gz kube-903960116eb3329631702723bba11f5463eff573.zip |
fixes the build issues
Diffstat (limited to 'framework')
-rw-r--r-- | framework/domain/mimetreeparser/CMakeLists.txt | 2 | ||||
-rw-r--r-- | framework/domain/mimetreeparser/interface.cpp | 103 | ||||
-rw-r--r-- | framework/domain/mimetreeparser/interface.h | 21 | ||||
-rw-r--r-- | framework/domain/mimetreeparser/tests/interfacetest.cpp | 54 |
4 files changed, 115 insertions, 65 deletions
diff --git a/framework/domain/mimetreeparser/CMakeLists.txt b/framework/domain/mimetreeparser/CMakeLists.txt index 07ec28df..e1c04893 100644 --- a/framework/domain/mimetreeparser/CMakeLists.txt +++ b/framework/domain/mimetreeparser/CMakeLists.txt | |||
@@ -9,4 +9,4 @@ add_library(mimetreeparser SHARED ${mimetreeparser_SRCS}) | |||
9 | qt5_use_modules(mimetreeparser Core Gui) | 9 | qt5_use_modules(mimetreeparser Core Gui) |
10 | target_link_libraries(mimetreeparser KF5::Mime KF5::MimeTreeParser) | 10 | target_link_libraries(mimetreeparser KF5::Mime KF5::MimeTreeParser) |
11 | 11 | ||
12 | # add_subdirectory(tests) \ No newline at end of file | 12 | add_subdirectory(tests) \ No newline at end of file |
diff --git a/framework/domain/mimetreeparser/interface.cpp b/framework/domain/mimetreeparser/interface.cpp index aa7e3911..5cf36d10 100644 --- a/framework/domain/mimetreeparser/interface.cpp +++ b/framework/domain/mimetreeparser/interface.cpp | |||
@@ -141,7 +141,7 @@ Content::~Content() | |||
141 | { | 141 | { |
142 | } | 142 | } |
143 | 143 | ||
144 | QVector< Encryption > Content::encryptions() const | 144 | QVector<Encryption> Content::encryptions() const |
145 | { | 145 | { |
146 | if (d->mParent) { | 146 | if (d->mParent) { |
147 | return d->mParent->encryptions(); | 147 | return d->mParent->encryptions(); |
@@ -149,7 +149,7 @@ QVector< Encryption > Content::encryptions() const | |||
149 | return QVector<Encryption>(); | 149 | return QVector<Encryption>(); |
150 | } | 150 | } |
151 | 151 | ||
152 | QVector< Signature > Content::signatures() const | 152 | QVector<Signature> Content::signatures() const |
153 | { | 153 | { |
154 | if (d->mParent) { | 154 | if (d->mParent) { |
155 | return d->mParent->signatures(); | 155 | return d->mParent->signatures(); |
@@ -167,6 +167,19 @@ QByteArray Content::charset() const | |||
167 | return d->mCodec; | 167 | return d->mCodec; |
168 | } | 168 | } |
169 | 169 | ||
170 | HtmlContent::HtmlContent(const QByteArray& content, Part* parent) | ||
171 | : Content(content, parent) | ||
172 | { | ||
173 | |||
174 | } | ||
175 | |||
176 | PlainTextContent::PlainTextContent(const QByteArray& content, Part* parent) | ||
177 | : Content(content, parent) | ||
178 | { | ||
179 | |||
180 | } | ||
181 | |||
182 | |||
170 | class AlternativePartPrivate | 183 | class AlternativePartPrivate |
171 | { | 184 | { |
172 | public: | 185 | public: |
@@ -187,7 +200,7 @@ void AlternativePartPrivate::fillFrom(MimeTreeParser::AlternativeMessagePart::Pt | |||
187 | { | 200 | { |
188 | mTypes = QVector<QByteArray>() << "html" << "plaintext"; | 201 | mTypes = QVector<QByteArray>() << "html" << "plaintext"; |
189 | 202 | ||
190 | auto content = std::make_shared<HtmlContent>(part->htmlContent().toLocal8Bit(), q); | 203 | Content::Ptr content = std::make_shared<HtmlContent>(part->htmlContent().toLocal8Bit(), q); |
191 | mContent["html"].append(content); | 204 | mContent["html"].append(content); |
192 | content = std::make_shared<PlainTextContent>(part->plaintextContent().toLocal8Bit(), q); | 205 | content = std::make_shared<PlainTextContent>(part->plaintextContent().toLocal8Bit(), q); |
193 | mContent["plaintext"].append(content); | 206 | mContent["plaintext"].append(content); |
@@ -224,11 +237,6 @@ QVector<QByteArray> AlternativePart::availableContents() const | |||
224 | return d->types(); | 237 | return d->types(); |
225 | } | 238 | } |
226 | 239 | ||
227 | QVector<Content::Ptr> AlternativePart::content() const | ||
228 | { | ||
229 | return d->content(availableContents().first()); | ||
230 | } | ||
231 | |||
232 | QVector<Content::Ptr> AlternativePart::content(const QByteArray& ct) const | 240 | QVector<Content::Ptr> AlternativePart::content(const QByteArray& ct) const |
233 | { | 241 | { |
234 | return d->content(ct); | 242 | return d->content(ct); |
@@ -283,9 +291,12 @@ QVector<QByteArray> SinglePart::availableContents() const | |||
283 | return QVector<QByteArray>() << d->mType; | 291 | return QVector<QByteArray>() << d->mType; |
284 | } | 292 | } |
285 | 293 | ||
286 | QVector< Content::Ptr > SinglePart::content() const | 294 | QVector< Content::Ptr > SinglePart::content(const QByteArray &ct) const |
287 | { | 295 | { |
288 | return d->mContent; | 296 | if (ct == d->mType) { |
297 | return d->mContent; | ||
298 | } | ||
299 | return QVector<Content::Ptr>(); | ||
289 | } | 300 | } |
290 | 301 | ||
291 | QByteArray SinglePart::type() const | 302 | QByteArray SinglePart::type() const |
@@ -293,17 +304,6 @@ QByteArray SinglePart::type() const | |||
293 | return "SinglePart"; | 304 | return "SinglePart"; |
294 | } | 305 | } |
295 | 306 | ||
296 | class MimePartPrivate | ||
297 | { | ||
298 | public: | ||
299 | void fillFrom(MimeTreeParser::MessagePart::Ptr part); | ||
300 | }; | ||
301 | |||
302 | QByteArray MimePart::type() const | ||
303 | { | ||
304 | return "MimePart"; | ||
305 | } | ||
306 | |||
307 | ParserPrivate::ParserPrivate(Parser* parser) | 307 | ParserPrivate::ParserPrivate(Parser* parser) |
308 | : q(parser) | 308 | : q(parser) |
309 | , mNodeHelper(std::make_shared<MimeTreeParser::NodeHelper>()) | 309 | , mNodeHelper(std::make_shared<MimeTreeParser::NodeHelper>()) |
@@ -343,7 +343,7 @@ void ParserPrivate::createTree(const MimeTreeParser::MessagePart::Ptr &start, co | |||
343 | const auto html = mp.dynamicCast<MimeTreeParser::HtmlMessagePart>(); | 343 | const auto html = mp.dynamicCast<MimeTreeParser::HtmlMessagePart>(); |
344 | const auto attachment = mp.dynamicCast<MimeTreeParser::AttachmentMessagePart>(); | 344 | const auto attachment = mp.dynamicCast<MimeTreeParser::AttachmentMessagePart>(); |
345 | if (attachment) { | 345 | if (attachment) { |
346 | auto part = std::make_shared<AttachmentPart>(); | 346 | auto part = std::make_shared<SinglePart>(); |
347 | part->d->fillFrom(attachment); | 347 | part->d->fillFrom(attachment); |
348 | mTree->d->appendSubPart(part); | 348 | mTree->d->appendSubPart(part); |
349 | } else if (text) { | 349 | } else if (text) { |
@@ -376,20 +376,55 @@ Parser::~Parser() | |||
376 | 376 | ||
377 | QVector<Part::Ptr> Parser::collectContentParts() const | 377 | QVector<Part::Ptr> Parser::collectContentParts() const |
378 | { | 378 | { |
379 | return collect<Part>(d->mTree, [](const Part::Ptr &p){return p->availableContents().indexOf("html") > -1 || p->availableContents().indexOf("text") > -1;}, [](const Part::Ptr &p){return true;}); | 379 | return collect(d->mTree, [](const Part::Ptr &p){return p->type() != "EncapsulatedPart";}, |
380 | } | 380 | [](const Content::Ptr &content){ |
381 | 381 | const auto mime = content->mailMime(); | |
382 | template <typename T> | 382 | |
383 | QVector<typename T::Ptr> Parser::collect(const Part::Ptr &start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const typename T::Ptr &)> filter) const | 383 | if (!mime) { |
384 | { | 384 | return true; |
385 | QVector<typename T::Ptr> ret; | 385 | } |
386 | |||
387 | if (mime->isFirstTextPart()) { | ||
388 | return true; | ||
389 | } | ||
390 | const auto cd = mime->disposition(); | ||
391 | if (cd && cd == MailMime::Inline) { | ||
392 | // explict "inline" disposition: | ||
393 | return true; | ||
394 | } | ||
395 | if (cd && cd == MailMime::Attachment) { | ||
396 | // explicit "attachment" disposition: | ||
397 | return false; | ||
398 | } | ||
399 | |||
400 | const auto ct = mime->mimetype(); | ||
401 | if (ct.name().trimmed().toLower() == "text" && ct.name().trimmed().isEmpty() && | ||
402 | (!mime || mime->filename().trimmed().isEmpty())) { | ||
403 | // text/* w/o filename parameter: | ||
404 | return true; | ||
405 | } | ||
406 | return false; | ||
407 | }); | ||
408 | } | ||
409 | |||
410 | QVector<Part::Ptr> Parser::collect(const Part::Ptr &start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const Content::Ptr &)> filter) const | ||
411 | { | ||
412 | QVector<Part::Ptr> ret; | ||
386 | foreach (const auto &part, start->subParts()) { | 413 | foreach (const auto &part, start->subParts()) { |
387 | if (select(part)){ | 414 | QVector<QByteArray> contents; |
388 | const auto p = std::dynamic_pointer_cast<T>(part); | 415 | foreach(const auto &ct, part->availableContents()) { |
389 | if (p && filter(p)) { | 416 | foreach(const auto &content, part->content(ct)) { |
390 | ret.append(p); | 417 | if (filter(content)) { |
418 | contents.append(ct); | ||
419 | break; | ||
420 | } | ||
391 | } | 421 | } |
392 | ret += collect<T>(part, select, filter); | 422 | } |
423 | if (!contents.isEmpty()) { | ||
424 | ret.append(part); | ||
425 | } | ||
426 | if (select(part)){ | ||
427 | ret += collect(part, select, filter); | ||
393 | } | 428 | } |
394 | } | 429 | } |
395 | return ret; | 430 | return ret; |
diff --git a/framework/domain/mimetreeparser/interface.h b/framework/domain/mimetreeparser/interface.h index 5133b87e..f6ee41ee 100644 --- a/framework/domain/mimetreeparser/interface.h +++ b/framework/domain/mimetreeparser/interface.h | |||
@@ -41,9 +41,6 @@ class SinglePartPrivate; | |||
41 | class EncryptionPart; | 41 | class EncryptionPart; |
42 | class EncryptionPartPrivate; | 42 | class EncryptionPartPrivate; |
43 | 43 | ||
44 | class AttachmentPart; | ||
45 | class AttachmentPartPrivate; | ||
46 | |||
47 | class EncapsulatedPart; | 44 | class EncapsulatedPart; |
48 | class EncapsulatedPartPrivate; | 45 | class EncapsulatedPartPrivate; |
49 | 46 | ||
@@ -84,6 +81,7 @@ public: | |||
84 | QUrl label() const; | 81 | QUrl label() const; |
85 | QByteArray cid() const; | 82 | QByteArray cid() const; |
86 | QByteArray charset() const; | 83 | QByteArray charset() const; |
84 | QByteArray filename() const; | ||
87 | 85 | ||
88 | // Unique identifier to ecactly this KMime::Content | 86 | // Unique identifier to ecactly this KMime::Content |
89 | QByteArray link() const; | 87 | QByteArray link() const; |
@@ -95,6 +93,8 @@ public: | |||
95 | // overwrite default charset with given charset | 93 | // overwrite default charset with given charset |
96 | QString encodedContent(QByteArray charset) const; | 94 | QString encodedContent(QByteArray charset) const; |
97 | 95 | ||
96 | bool isFirstTextPart() const; | ||
97 | |||
98 | private: | 98 | private: |
99 | std::unique_ptr<MailMimePrivate> d; | 99 | std::unique_ptr<MailMimePrivate> d; |
100 | }; | 100 | }; |
@@ -127,12 +127,14 @@ private: | |||
127 | class PlainTextContent : public Content | 127 | class PlainTextContent : public Content |
128 | { | 128 | { |
129 | public: | 129 | public: |
130 | PlainTextContent(const QByteArray &content, Part *parent); | ||
130 | QByteArray type() const Q_DECL_OVERRIDE; | 131 | QByteArray type() const Q_DECL_OVERRIDE; |
131 | }; | 132 | }; |
132 | 133 | ||
133 | class HtmlContent : public Content | 134 | class HtmlContent : public Content |
134 | { | 135 | { |
135 | public: | 136 | public: |
137 | HtmlContent(const QByteArray &content, Part *parent); | ||
136 | QByteArray type() const Q_DECL_OVERRIDE; | 138 | QByteArray type() const Q_DECL_OVERRIDE; |
137 | }; | 139 | }; |
138 | 140 | ||
@@ -145,6 +147,7 @@ class CertContent : public Content | |||
145 | { | 147 | { |
146 | public: | 148 | public: |
147 | typedef std::shared_ptr<CertContent> Ptr; | 149 | typedef std::shared_ptr<CertContent> Ptr; |
150 | CertContent(const QByteArray &content, Part *parent); | ||
148 | 151 | ||
149 | QByteArray type() const Q_DECL_OVERRIDE; | 152 | QByteArray type() const Q_DECL_OVERRIDE; |
150 | enum CertType { | 153 | enum CertType { |
@@ -173,7 +176,8 @@ public: | |||
173 | virtual QByteArray type() const; | 176 | virtual QByteArray type() const; |
174 | 177 | ||
175 | virtual QVector<QByteArray> availableContents() const; | 178 | virtual QVector<QByteArray> availableContents() const; |
176 | virtual QVector<Content::Ptr> content() const; | 179 | virtual QVector<Content::Ptr> content(const QByteArray& ct) const; |
180 | QVector<Content::Ptr> content() const; | ||
177 | 181 | ||
178 | bool hasSubParts() const; | 182 | bool hasSubParts() const; |
179 | QVector<Part::Ptr> subParts() const; | 183 | QVector<Part::Ptr> subParts() const; |
@@ -196,9 +200,8 @@ public: | |||
196 | AlternativePart(); | 200 | AlternativePart(); |
197 | virtual ~AlternativePart(); | 201 | virtual ~AlternativePart(); |
198 | 202 | ||
199 | QVector<Content::Ptr> content() const Q_DECL_OVERRIDE; | ||
200 | QVector<QByteArray> availableContents() const Q_DECL_OVERRIDE; | 203 | QVector<QByteArray> availableContents() const Q_DECL_OVERRIDE; |
201 | QVector<Content::Ptr> content(const QByteArray& ct) const; | 204 | QVector<Content::Ptr> content(const QByteArray& ct) const Q_DECL_OVERRIDE; |
202 | 205 | ||
203 | QByteArray type() const Q_DECL_OVERRIDE; | 206 | QByteArray type() const Q_DECL_OVERRIDE; |
204 | 207 | ||
@@ -216,7 +219,7 @@ class SinglePart : public Part | |||
216 | SinglePart(); | 219 | SinglePart(); |
217 | virtual ~SinglePart(); | 220 | virtual ~SinglePart(); |
218 | 221 | ||
219 | QVector<Content::Ptr> content() const Q_DECL_OVERRIDE; | 222 | QVector<Content::Ptr> content(const QByteArray& ct) const Q_DECL_OVERRIDE; |
220 | QVector<QByteArray> availableContents() const Q_DECL_OVERRIDE; | 223 | QVector<QByteArray> availableContents() const Q_DECL_OVERRIDE; |
221 | 224 | ||
222 | QByteArray type() const Q_DECL_OVERRIDE; | 225 | QByteArray type() const Q_DECL_OVERRIDE; |
@@ -311,9 +314,9 @@ public: | |||
311 | 314 | ||
312 | Part::Ptr getPart(QUrl url); | 315 | Part::Ptr getPart(QUrl url); |
313 | 316 | ||
314 | template <typename T> QVector<typename T::Ptr> collect(const Part::Ptr &start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const typename T::Ptr &)> filter) const; | 317 | QVector<Part::Ptr> collect(const Part::Ptr &start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const Content::Ptr &)> filter) const; |
315 | //QVector<AttachmentPart::Ptr> collectAttachments(Part::Ptr start, std::function<bool(const Part::Ptr &)> select, std::function<bool(const AttachmentPart::Ptr &)> filter) const; | ||
316 | QVector<Part::Ptr> collectContentParts() const; | 318 | QVector<Part::Ptr> collectContentParts() const; |
319 | QVector<Part::Ptr> collectAttachmentParts() const; | ||
317 | //template <> QVector<ContentPart::Ptr> collect<ContentPart>() const; | 320 | //template <> QVector<ContentPart::Ptr> collect<ContentPart>() const; |
318 | 321 | ||
319 | //template <> static StatusObject<SignatureVerificationResult> verifySignature(const Signature signature) const; | 322 | //template <> static StatusObject<SignatureVerificationResult> verifySignature(const Signature signature) const; |
diff --git a/framework/domain/mimetreeparser/tests/interfacetest.cpp b/framework/domain/mimetreeparser/tests/interfacetest.cpp index 88691539..822d530c 100644 --- a/framework/domain/mimetreeparser/tests/interfacetest.cpp +++ b/framework/domain/mimetreeparser/tests/interfacetest.cpp | |||
@@ -48,34 +48,38 @@ private slots: | |||
48 | void testTextMail() | 48 | void testTextMail() |
49 | { | 49 | { |
50 | Parser parser(readMailFromFile("plaintext.mbox")); | 50 | Parser parser(readMailFromFile("plaintext.mbox")); |
51 | auto contentPart = parser.collectContentPart(); | 51 | auto contentPartList = parser.collectContentParts(); |
52 | QCOMPARE(contentPartList.size(), 1); | ||
53 | auto contentPart = contentPartList[0]; | ||
52 | QVERIFY((bool)contentPart); | 54 | QVERIFY((bool)contentPart); |
53 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); | 55 | QCOMPARE(contentPart->availableContents(), "plaintext"); |
54 | auto contentList = contentPart->content(ContentPart::PlainText); | 56 | auto contentList = contentPart->content("plaintext"); |
55 | QCOMPARE(contentList.size(), 1); | 57 | QCOMPARE(contentList.size(), 1); |
56 | QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/").toLocal8Bit()); | 58 | QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/").toLocal8Bit()); |
57 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 59 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); |
58 | QCOMPARE(contentList[0]->encryptions().size(), 0); | 60 | QCOMPARE(contentList[0]->encryptions().size(), 0); |
59 | QCOMPARE(contentList[0]->signatures().size(), 0); | 61 | QCOMPARE(contentList[0]->signatures().size(), 0); |
60 | 62 | ||
61 | contentList = contentPart->content(ContentPart::Html); | 63 | contentList = contentPart->content("html"); |
62 | QCOMPARE(contentList.size(), 0); | 64 | QCOMPARE(contentList.size(), 0); |
63 | } | 65 | } |
64 | 66 | ||
65 | void testTextAlternative() | 67 | void testTextAlternative() |
66 | { | 68 | { |
67 | Parser parser(readMailFromFile("alternative.mbox")); | 69 | Parser parser(readMailFromFile("alternative.mbox")); |
68 | auto contentPart = parser.collectContentPart(); | 70 | auto contentPartList = parser.collectContentParts(); |
71 | QCOMPARE(contentPartList.size(), 1); | ||
72 | auto contentPart = contentPartList[0]; | ||
69 | QVERIFY((bool)contentPart); | 73 | QVERIFY((bool)contentPart); |
70 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText | ContentPart::Html); | 74 | QCOMPARE(contentPart->availableContents(), QVector<QByteArray>() << "html" << "plaintext"); |
71 | auto contentList = contentPart->content(ContentPart::PlainText); | 75 | auto contentList = contentPart->content("plaintext"); |
72 | QCOMPARE(contentList.size(), 1); | 76 | QCOMPARE(contentList.size(), 1); |
73 | QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/\n").toLocal8Bit()); | 77 | QCOMPARE(contentList[0]->content(), QStringLiteral("If you can see this text it means that your email client couldn't display our newsletter properly.\nPlease visit this link to view the newsletter on our website: http://www.gog.com/newsletter/\n").toLocal8Bit()); |
74 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 78 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); |
75 | QCOMPARE(contentList[0]->encryptions().size(), 0); | 79 | QCOMPARE(contentList[0]->encryptions().size(), 0); |
76 | QCOMPARE(contentList[0]->signatures().size(), 0); | 80 | QCOMPARE(contentList[0]->signatures().size(), 0); |
77 | 81 | ||
78 | contentList = contentPart->content(ContentPart::Html); | 82 | contentList = contentPart->content("html"); |
79 | QCOMPARE(contentList.size(), 1); | 83 | QCOMPARE(contentList.size(), 1); |
80 | QCOMPARE(contentList[0]->content(), QStringLiteral("<html><body><p><span>HTML</span> text</p></body></html>\n\n").toLocal8Bit()); | 84 | QCOMPARE(contentList[0]->content(), QStringLiteral("<html><body><p><span>HTML</span> text</p></body></html>\n\n").toLocal8Bit()); |
81 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 85 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); |
@@ -86,14 +90,16 @@ private slots: | |||
86 | void testTextHtml() | 90 | void testTextHtml() |
87 | { | 91 | { |
88 | Parser parser(readMailFromFile("html.mbox")); | 92 | Parser parser(readMailFromFile("html.mbox")); |
89 | auto contentPart = parser.collectContentPart(); | 93 | auto contentPartList = parser.collectContentParts(); |
94 | QCOMPARE(contentPartList.size(), 1); | ||
95 | auto contentPart = contentPartList[0]; | ||
90 | QVERIFY((bool)contentPart); | 96 | QVERIFY((bool)contentPart); |
91 | QCOMPARE(contentPart->availableContents(), ContentPart::Html); | 97 | QCOMPARE(contentPart->availableContents(), "html"); |
92 | 98 | ||
93 | auto contentList = contentPart->content(ContentPart::PlainText); | 99 | auto contentList = contentPart->content("plaintext"); |
94 | QCOMPARE(contentList.size(), 0); | 100 | QCOMPARE(contentList.size(), 0); |
95 | 101 | ||
96 | contentList = contentPart->content(ContentPart::Html); | 102 | contentList = contentPart->content("html"); |
97 | QCOMPARE(contentList.size(), 1); | 103 | QCOMPARE(contentList.size(), 1); |
98 | QCOMPARE(contentList[0]->content(), QStringLiteral("<html><body><p><span>HTML</span> text</p></body></html>").toLocal8Bit()); | 104 | QCOMPARE(contentList[0]->content(), QStringLiteral("<html><body><p><span>HTML</span> text</p></body></html>").toLocal8Bit()); |
99 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 105 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); |
@@ -105,10 +111,12 @@ private slots: | |||
105 | { | 111 | { |
106 | Parser parser(readMailFromFile("smime-encrypted.mbox")); | 112 | Parser parser(readMailFromFile("smime-encrypted.mbox")); |
107 | printTree(parser.d->mTree,QString()); | 113 | printTree(parser.d->mTree,QString()); |
108 | auto contentPart = parser.collectContentPart(); | 114 | auto contentPartList = parser.collectContentParts(); |
115 | QCOMPARE(contentPartList.size(), 1); | ||
116 | auto contentPart = contentPartList[0]; | ||
109 | QVERIFY((bool)contentPart); | 117 | QVERIFY((bool)contentPart); |
110 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); | 118 | QCOMPARE(contentPart->availableContents(), "plaintext"); |
111 | auto contentList = contentPart->content(ContentPart::PlainText); | 119 | auto contentList = contentPart->content("plaintext"); |
112 | QCOMPARE(contentList.size(), 1); | 120 | QCOMPARE(contentList.size(), 1); |
113 | QCOMPARE(contentList[0]->content(), QStringLiteral("The quick brown fox jumped over the lazy dog.").toLocal8Bit()); | 121 | QCOMPARE(contentList[0]->content(), QStringLiteral("The quick brown fox jumped over the lazy dog.").toLocal8Bit()); |
114 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 122 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); |
@@ -118,10 +126,12 @@ private slots: | |||
118 | { | 126 | { |
119 | Parser parser(readMailFromFile("openpgp-encrypted-attachment-and-non-encrypted-attachment.mbox")); | 127 | Parser parser(readMailFromFile("openpgp-encrypted-attachment-and-non-encrypted-attachment.mbox")); |
120 | printTree(parser.d->mTree,QString()); | 128 | printTree(parser.d->mTree,QString()); |
121 | auto contentPart = parser.collectContentPart(); | 129 | auto contentPartList = parser.collectContentParts(); |
130 | QCOMPARE(contentPartList.size(), 1); | ||
131 | auto contentPart = contentPartList[0]; | ||
122 | QVERIFY((bool)contentPart); | 132 | QVERIFY((bool)contentPart); |
123 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); | 133 | QCOMPARE(contentPart->availableContents(), "plaintext"); |
124 | auto contentList = contentPart->content(ContentPart::PlainText); | 134 | auto contentList = contentPart->content("plaintext"); |
125 | QCOMPARE(contentList.size(), 1); | 135 | QCOMPARE(contentList.size(), 1); |
126 | QCOMPARE(contentList[0]->content(), QStringLiteral("test text").toLocal8Bit()); | 136 | QCOMPARE(contentList[0]->content(), QStringLiteral("test text").toLocal8Bit()); |
127 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 137 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); |
@@ -131,10 +141,12 @@ private slots: | |||
131 | { | 141 | { |
132 | Parser parser(readMailFromFile("openpgp-inline-charset-encrypted.mbox")); | 142 | Parser parser(readMailFromFile("openpgp-inline-charset-encrypted.mbox")); |
133 | printTree(parser.d->mTree,QString()); | 143 | printTree(parser.d->mTree,QString()); |
134 | auto contentPart = parser.collectContentPart(); | 144 | auto contentPartList = parser.collectContentParts(); |
145 | QCOMPARE(contentPartList.size(), 1); | ||
146 | auto contentPart = contentPartList[0]; | ||
135 | QVERIFY((bool)contentPart); | 147 | QVERIFY((bool)contentPart); |
136 | QCOMPARE(contentPart->availableContents(), ContentPart::PlainText); | 148 | QCOMPARE(contentPart->availableContents(), "plaintext"); |
137 | auto contentList = contentPart->content(ContentPart::PlainText); | 149 | auto contentList = contentPart->content("plaintext"); |
138 | QCOMPARE(contentList.size(), 1); | 150 | QCOMPARE(contentList.size(), 1); |
139 | QCOMPARE(contentList[0]->content(), QStringLiteral("asdasd asd asd asdf sadf sdaf sadf äöü").toLocal8Bit()); | 151 | QCOMPARE(contentList[0]->content(), QStringLiteral("asdasd asd asd asdf sadf sdaf sadf äöü").toLocal8Bit()); |
140 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); | 152 | QCOMPARE(contentList[0]->charset(), QStringLiteral("utf-8").toLocal8Bit()); |