From ae20f0a057f4740e3eedb1641d99c37601ad0b7f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 26 Apr 2018 16:43:00 +0200 Subject: No more direct GpgMe usage in the interfaces. --- .../src/domain/mime/tests/mailtemplatetest.cpp | 50 +--------------------- 1 file changed, 2 insertions(+), 48 deletions(-) (limited to 'framework/src/domain/mime/tests') diff --git a/framework/src/domain/mime/tests/mailtemplatetest.cpp b/framework/src/domain/mime/tests/mailtemplatetest.cpp index d07b704d..75debd75 100644 --- a/framework/src/domain/mime/tests/mailtemplatetest.cpp +++ b/framework/src/domain/mime/tests/mailtemplatetest.cpp @@ -6,10 +6,6 @@ #include #include -#include -#include -#include -#include #include "mailtemplates.h" #include "mailcrypto.h" @@ -24,45 +20,6 @@ static KMime::Content *getSubpart(KMime::Content *msg, const QByteArray &mimeTyp return nullptr; } -static std::vector< GpgME::Key, std::allocator< GpgME::Key > > getKeys(bool smime = false) -{ - QGpgME::KeyListJob *job = nullptr; - - if (smime) { - const QGpgME::Protocol *const backend = QGpgME::smime(); - Q_ASSERT(backend); - job = backend->keyListJob(/* remote = */ false); - } else { - const QGpgME::Protocol *const backend = QGpgME::openpgp(); - Q_ASSERT(backend); - job = backend->keyListJob(/* remote = */ false); - } - Q_ASSERT(job); - - std::vector< GpgME::Key > keys; - GpgME::KeyListResult res = job->exec(QStringList(), /* secretOnly = */ true, keys); - - if (!smime) { - Q_ASSERT(keys.size() == 3); - } - - Q_ASSERT(!res.error()); - - /* - qDebug() << "got private keys:" << keys.size(); - - for (std::vector< GpgME::Key >::iterator i = keys.begin(); i != keys.end(); ++i) { - qDebug() << "key isnull:" << i->isNull() << "isexpired:" << i->isExpired(); - qDebug() << "key numuserIds:" << i->numUserIDs(); - for (uint k = 0; k < i->numUserIDs(); ++k) { - qDebug() << "userIDs:" << i->userID(k).email(); - } - } - */ - - return keys; -} - static QByteArray readMailFromFile(const QString &mailFile) { Q_ASSERT(!QString::fromLatin1(MAIL_DATA_DIR).isEmpty()); @@ -399,8 +356,7 @@ private slots: QString body = "body"; QList attachments; - std::vector keys = getKeys(); - + auto keys = MailCrypto::findKeys({}, true, false); auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, keys, {}, keys[0]); QVERIFY(result); @@ -442,9 +398,7 @@ private slots: QString body = "body"; QList attachments = {{"name", "filename", "mimetype", true, "inlineAttachment"}, {"name", "filename", "mimetype", false, "nonInlineAttachment"}}; - std::vector keys = getKeys(); - - auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, keys); + auto result = MailTemplates::createMessage({}, to, cc, bcc, from, subject, body, false, attachments, MailCrypto::findKeys({}, true, false)); QVERIFY(result); QCOMPARE(result->subject()->asUnicodeString(), subject); -- cgit v1.2.3