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)
This commit is contained in:
parent
444d85ace0
commit
79439e76cc
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "tofuinfo.h"
|
#include "tofuinfo.h"
|
||||||
|
#include "context.h"
|
||||||
|
|
||||||
#include <gpgme.h>
|
#include <gpgme.h>
|
||||||
|
|
||||||
@ -322,6 +323,27 @@ const Key &Key::mergeWith(const Key &other)
|
|||||||
return *this;
|
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
|
// class Subkey
|
||||||
|
@ -146,6 +146,12 @@ public:
|
|||||||
|
|
||||||
unsigned int keyListMode() const;
|
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:
|
private:
|
||||||
gpgme_key_t impl() const
|
gpgme_key_t impl() const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user