From cb7668caeb71429afce1aded9128334182b233e1 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Mon, 4 Nov 2019 13:54:55 +0100 Subject: [PATCH] cpp: Add API to obtain mutliple remarks * lang/cpp/src/key.cpp, lang/cpp/src/key.h (UserID::remarks): New. * NEWS: Mention this. -- This can be useful if we want to show remarks made by others, too. For: GnuPG-Bug-Id: T4734 --- NEWS | 1 + lang/cpp/src/key.cpp | 16 ++++++++++++++++ lang/cpp/src/key.h | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/NEWS b/NEWS index a986f937..b0490bef 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ Noteworthy changes in version 1.14.0 (unreleased) * Interface changes relative to the 1.13.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cpp: UserID::remark NEW. + cpp: UserID::remarks NEW. cpp: GpgSignKeyEditInteractor::setDupeOk NEW. qt: SignKeyJob::setDupeOk NEW. qt: SignKeyJob::setRemark NEW. diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index e2d91a10..5108a6ee 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -777,6 +777,22 @@ const char *UserID::remark(const Key &remarker, Error &err) const return nullptr; } +std::vector UserID::remarks(std::vector keys, Error &err) const +{ + std::vector ret; + + for (const auto &key: keys) { + const char *rem = remark(key, err); + if (err) { + return ret; + } + if (rem) { + ret.push_back(rem); + } + } + return ret; +} + // // // class Signature diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h index cca3c7a6..cf4e9054 100644 --- a/lang/cpp/src/key.h +++ b/lang/cpp/src/key.h @@ -430,6 +430,10 @@ public: const char *remark(const Key &key, Error &error) const; + /*! Get multiple remarks made by potentially multiple keys. */ + std::vector remarks(std::vector remarkers, + Error &error) const; + private: shared_gpgme_key_t key; gpgme_user_id_t uid;