[Pkg-gnupg-commit] [gpgme] 323/412: cpp: Add convenience update function to a key
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu Sep 22 21:27:12 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gpgme.
commit 79439e76cc5b302222874a1f9e93665cb12801ac
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Mon Sep 5 12:53:02 2016 +0200
cpp: Add convenience update function to a key
* lang/cpp/src/key.cpp (Key::update): New.
* lang/cpp/src/key.h: Update accordingly.
--
This function helps if you have an incomplete key or want
to make sure all info in a key is complete (e.g. validity / tofuinfo)
---
lang/cpp/src/key.cpp | 22 ++++++++++++++++++++++
lang/cpp/src/key.h | 6 ++++++
2 files changed, 28 insertions(+)
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 204eeca..cfa1ba3 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -24,6 +24,7 @@
#include "util.h"
#include "tofuinfo.h"
+#include "context.h"
#include <gpgme.h>
@@ -322,6 +323,27 @@ const Key &Key::mergeWith(const Key &other)
return *this;
}
+void Key::update()
+{
+ auto ctx = Context::createForProtocol(protocol());
+ if (!ctx) {
+ return;
+ }
+ ctx->setKeyListMode(KeyListMode::Local |
+ KeyListMode::Signatures |
+ KeyListMode::SignatureNotations |
+ KeyListMode::Validate |
+ KeyListMode::WithTofu);
+ Error err;
+ auto newKey = ctx->key(primaryFingerprint(), err, hasSecret());
+ delete ctx;
+ if (err) {
+ return;
+ }
+ swap(newKey);
+ return;
+}
+
//
//
// class Subkey
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index 85b16df..f193093 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -146,6 +146,12 @@ public:
unsigned int keyListMode() const;
+ /*! Update information about this key.
+ * Starts a keylisting for this key with validity
+ * and tofu information gathering. Blocks for
+ * how long the keylisting takes.*/
+ void update();
+
private:
gpgme_key_t impl() const
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git
More information about the Pkg-gnupg-commit
mailing list