From ef3433a40e23c56a3a9c6158fde06729e7b0cd12 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 28 Feb 2018 12:02:28 +0100 Subject: Add support for adding attachments in test store --- tests/teststore.cpp | 15 ++++++++++++++- views/conversation/main.qml | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/teststore.cpp b/tests/teststore.cpp index 9d56dd33..84e2da20 100644 --- a/tests/teststore.cpp +++ b/tests/teststore.cpp @@ -64,6 +64,19 @@ static void createMail(const QVariantMap &object, const QByteArray &folder = {}) auto ccAddresses = toStringList(object["cc"].toList()); auto bccAddresses = toStringList(object["bcc"].toList()); + QList attachments = {}; + if (object.contains("attachments")) { + auto attachmentSpecs = object["attachments"].toList(); + for (int i = 0; i < attachmentSpecs.size(); ++i) { + auto const &spec = attachmentSpecs.at(i).toMap(); + attachments << Attachment{spec["name"].toString(), + spec["name"].toString(), + spec["mimeType"].toByteArray(), + false, + spec["data"].toByteArray()}; + } + } + KMime::Types::Mailbox mb; mb.fromUnicodeString("identity@example.org"); auto msg = MailTemplates::createMessage({}, @@ -74,7 +87,7 @@ static void createMail(const QVariantMap &object, const QByteArray &folder = {}) object["subject"].toString(), object["body"].toString(), object["bodyIsHtml"].toBool(), - {}, + attachments, {}, {}); if (object.contains("messageId")) { diff --git a/views/conversation/main.qml b/views/conversation/main.qml index 64f7f273..4832d500 100644 --- a/views/conversation/main.qml +++ b/views/conversation/main.qml @@ -127,6 +127,21 @@ ApplicationWindow { to: ["to@example.org"], unread: true }, + { + resource: "resource1", + date: "2017-07-20T17:47:29", + subject: "WithAttachment", + body: "Hi Mélanie,\n\nI'm sorry to start this on such late notice, but we'd like to get Foo and boo to woo next week, because the following weeks are unfortunately not possible for us.\n", + to: ["to@example.org"], + unread: true, + attachments: [ + { + name: "myImage.png", + mimeType: "image/png", + data: "no real data", + } + ], + } ] }], } -- cgit v1.2.3