diff options
author | Ingo Klöcker <[email protected]> | 2021-05-04 16:35:47 +0000 |
---|---|---|
committer | Ingo Klöcker <[email protected]> | 2021-05-05 17:25:48 +0000 |
commit | e391a08c6f96cd2d93c49b888459ee3f42058118 (patch) | |
tree | a3654544466d97ad315e3685f7b97cefa60037d7 /lang/cpp/src | |
parent | core: Extend gpgme_key_sig_t with trust signature members. (diff) | |
download | gpgme-e391a08c6f96cd2d93c49b888459ee3f42058118.tar.gz gpgme-e391a08c6f96cd2d93c49b888459ee3f42058118.zip |
cpp: Add getters for the attributes of a trust signature
* lang/cpp/src/key.h (TrustSignatureTrust): New enum.
* lang/cpp/src/key.h, lang/cpp/src/key.cpp
(UserID::Signature::isTrustSignature): New.
(UserID::Signature::trustValue): New.
(UserID::Signature::trustDepth): New.
(UserID::Signature::trustScope): New.
--
GnuPG-bug-id: 5245, 5420
Diffstat (limited to 'lang/cpp/src')
-rw-r--r-- | lang/cpp/src/key.cpp | 23 | ||||
-rw-r--r-- | lang/cpp/src/key.h | 11 |
2 files changed, 34 insertions, 0 deletions
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index f9cc2b60..b893a7cd 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -1083,6 +1083,29 @@ const char *UserID::Signature::policyURL() const return nullptr; } +bool UserID::Signature::isTrustSignature() const +{ + return sig && sig->trust_depth > 0; +} + +TrustSignatureTrust UserID::Signature::trustValue() const +{ + if (!sig || !isTrustSignature()) { + return TrustSignatureTrust::None; + } + return sig->trust_value >= 120 ? TrustSignatureTrust::Complete : TrustSignatureTrust::Partial; +} + +unsigned int UserID::Signature::trustDepth() const +{ + return sig ? sig->trust_depth : 0; +} + +const char *UserID::Signature::trustScope() const +{ + return sig ? sig->trust_scope : nullptr; +} + std::string UserID::addrSpecFromString(const char *userid) { if (!userid) { diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h index 515bf185..0e6380db 100644 --- a/lang/cpp/src/key.h +++ b/lang/cpp/src/key.h @@ -47,6 +47,12 @@ class TofuInfo; typedef std::shared_ptr< std::remove_pointer<gpgme_key_t>::type > shared_gpgme_key_t; +enum class TrustSignatureTrust : char { + None = 0, + Partial, + Complete, +}; + // // class Key // @@ -514,6 +520,11 @@ public: GpgME::Notation notation(unsigned int idx) const; std::vector<GpgME::Notation> notations() const; + bool isTrustSignature() const; + TrustSignatureTrust trustValue() const; + unsigned int trustDepth() const; + const char *trustScope() const; + private: shared_gpgme_key_t key; gpgme_user_id_t uid; |