diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-11-22 16:47:08 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-11-22 16:47:08 +0100 |
commit | 0bde2f020dd602ca360f394cd56d3973e857b5cc (patch) | |
tree | 8209f64fc13962942bc91e1f940b92e5d9eb12d1 /framework/src/domain/mime/mailcrypto.cpp | |
parent | b87099411a5a23572c5160adfa09e2ef2b882705 (diff) | |
download | kube-0bde2f020dd602ca360f394cd56d3973e857b5cc.tar.gz kube-0bde2f020dd602ca360f394cd56d3973e857b5cc.zip |
Find signing keys
Diffstat (limited to 'framework/src/domain/mime/mailcrypto.cpp')
-rw-r--r-- | framework/src/domain/mime/mailcrypto.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/framework/src/domain/mime/mailcrypto.cpp b/framework/src/domain/mime/mailcrypto.cpp index ad161a63..19e81b4f 100644 --- a/framework/src/domain/mime/mailcrypto.cpp +++ b/framework/src/domain/mime/mailcrypto.cpp | |||
@@ -22,8 +22,10 @@ | |||
22 | #include "mailcrypto.h" | 22 | #include "mailcrypto.h" |
23 | #include <QGpgME/Protocol> | 23 | #include <QGpgME/Protocol> |
24 | #include <QGpgME/SignJob> | 24 | #include <QGpgME/SignJob> |
25 | #include <QGpgME/KeyListJob> | ||
25 | #include <gpgme++/global.h> | 26 | #include <gpgme++/global.h> |
26 | #include <gpgme++/signingresult.h> | 27 | #include <gpgme++/signingresult.h> |
28 | #include <gpgme++/keylistresult.h> | ||
27 | #include <QDebug> | 29 | #include <QDebug> |
28 | 30 | ||
29 | /* | 31 | /* |
@@ -452,3 +454,28 @@ KMime::Content *MailCrypto::sign(KMime::Content *content, const std::vector<GpgM | |||
452 | return nullptr; | 454 | return nullptr; |
453 | } | 455 | } |
454 | 456 | ||
457 | std::vector<GpgME::Key> MailCrypto::findKeys(const QStringList &filter, bool findPrivate, Protocol protocol) | ||
458 | { | ||
459 | const QGpgME::Protocol *const backend = protocol == SMIME ? QGpgME::smime() : QGpgME::openpgp(); | ||
460 | Q_ASSERT(backend); | ||
461 | QGpgME::KeyListJob *job = backend->keyListJob(false); | ||
462 | Q_ASSERT(job); | ||
463 | |||
464 | std::vector<GpgME::Key> keys; | ||
465 | GpgME::KeyListResult res = job->exec(filter, findPrivate, keys); | ||
466 | |||
467 | Q_ASSERT(!res.error()); | ||
468 | |||
469 | qWarning() << "got keys:" << keys.size(); | ||
470 | |||
471 | for (std::vector< GpgME::Key >::iterator i = keys.begin(); i != keys.end(); ++i) { | ||
472 | qWarning() << "key isnull:" << i->isNull() << "isexpired:" << i->isExpired(); | ||
473 | qWarning() << "key numuserIds:" << i->numUserIDs(); | ||
474 | for (uint k = 0; k < i->numUserIDs(); ++k) { | ||
475 | qWarning() << "userIDs:" << i->userID(k).email(); | ||
476 | } | ||
477 | } | ||
478 | |||
479 | return keys; | ||
480 | } | ||
481 | |||