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
This commit is contained in:
Ingo Klöcker 2022-02-02 11:07:53 +01:00
parent 3d7810e8d9
commit bbaeeb5b9d
2 changed files with 20 additions and 0 deletions

View File

@ -50,6 +50,7 @@
#include <gpgme.h>
#include <functional>
#include <istream>
#include <numeric>
#ifndef NDEBUG
@ -799,6 +800,22 @@ Error Context::startKeyImport(const std::vector<Key> &kk)
return err;
}
ImportResult Context::importKeys(const std::vector<std::string> &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<std::string> &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) {

View File

@ -31,6 +31,7 @@
#include "verificationresult.h" // for Signature::Notation
#include <memory>
#include <string>
#include <vector>
#include <utility>
#include <iosfwd>
@ -225,8 +226,10 @@ public:
ImportResult importKeys(const Data &data);
ImportResult importKeys(const std::vector<Key> &keys);
ImportResult importKeys(const std::vector<std::string> &keyIds);
GpgME::Error startKeyImport(const Data &data);
GpgME::Error startKeyImport(const std::vector<Key> &keys);
GpgME::Error startKeyImport(const std::vector<std::string> &keyIds);
ImportResult importResult() const;
//