From 3519d6117332f25b601c9c0636878baf4e8cf55b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Wed, 4 May 2022 14:31:03 +0200 Subject: 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 --- lang/cpp/src/context.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lang/cpp/src/context.cpp') diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp index 568e0458..61b3e0e2 100644 --- a/lang/cpp/src/context.cpp +++ b/lang/cpp/src/context.cpp @@ -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); -- cgit v1.2.3