cpp: Allow retrieving import result of key listing with locate mode

* lang/cpp/src/context_p.h (enum Context::Private::Operation): Add
value KeyListWithImport.
* lang/cpp/src/context.cpp (Context::startKeyListing, Context::nextKey):
Set lastop to KeyListWithImport if keylist mode includes Locate.
--

Adding Import to lastop for keylist operations that perform a locate
allows retrieving the import result with Context::importResult.

GnuPG-bug-id: 5951
This commit is contained in:
Ingo Klöcker 2022-05-04 14:31:03 +02:00
parent f3ca57dfd7
commit 3519d61173
2 changed files with 10 additions and 3 deletions

View File

@ -535,19 +535,25 @@ const char *Context::getSender ()
Error Context::startKeyListing(const char *pattern, bool secretOnly)
{
d->lastop = Private::KeyList;
d->lastop = (((keyListMode() & GpgME::Locate) == GpgME::Locate)
? Private::KeyListWithImport
: Private::KeyList);
return Error(d->lasterr = gpgme_op_keylist_start(d->ctx, pattern, int(secretOnly)));
}
Error Context::startKeyListing(const char *patterns[], bool secretOnly)
{
d->lastop = Private::KeyList;
d->lastop = (((keyListMode() & GpgME::Locate) == GpgME::Locate)
? Private::KeyListWithImport
: Private::KeyList);
return Error(d->lasterr = gpgme_op_keylist_ext_start(d->ctx, patterns, int(secretOnly), 0));
}
Key Context::nextKey(GpgME::Error &e)
{
d->lastop = Private::KeyList;
d->lastop = (((keyListMode() & GpgME::Locate) == GpgME::Locate)
? Private::KeyListWithImport
: Private::KeyList);
gpgme_key_t key = nullptr;
e = Error(d->lasterr = gpgme_op_keylist_next(d->ctx, &key));
return Key(key, false);

View File

@ -53,6 +53,7 @@ public:
KeyGen = 0x080,
KeyList = 0x100,
KeyListWithImport = KeyList | Import, // gpgme_keylist_result_t and gpgme_import_result_t
TrustList = 0x200, // no gpgme_trustlist_result_t, but nevertheless...
Edit = 0x400, // no gpgme_edit_result_t, but nevertheless...