From bbaeeb5b9d5cca99c332cb88c7ae5f14e8745427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Wed, 2 Feb 2022 11:07:53 +0100 Subject: [PATCH] cpp: Allow import of keys given by key ids * lang/cpp/src/context.h (class Context): Add overloads of member functions importKeys and startKeyImport * lang/cpp/src/context.cpp (class Context): ... and implement them. -- GnuPG-bug-id: 5808 --- lang/cpp/src/context.cpp | 17 +++++++++++++++++ lang/cpp/src/context.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp index e8e57dc8..50726816 100644 --- a/lang/cpp/src/context.cpp +++ b/lang/cpp/src/context.cpp @@ -50,6 +50,7 @@ #include +#include #include #include #ifndef NDEBUG @@ -799,6 +800,22 @@ Error Context::startKeyImport(const std::vector &kk) return err; } +ImportResult Context::importKeys(const std::vector &keyIds) +{ + d->lastop = Private::Import; + const StringsToCStrings keyids{keyIds}; + d->lasterr = gpgme_op_receive_keys(d->ctx, keyids.c_strs()); + return ImportResult(d->ctx, Error(d->lasterr)); +} + +Error Context::startKeyImport(const std::vector &keyIds) +{ + d->lastop = Private::Import; + const StringsToCStrings keyids{keyIds}; + d->lasterr = gpgme_op_receive_keys_start(d->ctx, keyids.c_strs()); + return Error(d->lasterr); +} + ImportResult Context::importResult() const { if (d->lastop & Private::Import) { diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h index bfa6b8d8..9c2b2a5f 100644 --- a/lang/cpp/src/context.h +++ b/lang/cpp/src/context.h @@ -31,6 +31,7 @@ #include "verificationresult.h" // for Signature::Notation #include +#include #include #include #include @@ -225,8 +226,10 @@ public: ImportResult importKeys(const Data &data); ImportResult importKeys(const std::vector &keys); + ImportResult importKeys(const std::vector &keyIds); GpgME::Error startKeyImport(const Data &data); GpgME::Error startKeyImport(const std::vector &keys); + GpgME::Error startKeyImport(const std::vector &keyIds); ImportResult importResult() const; //