[git] GPGME - branch, master, updated. gpgme-1.12.0-24-g05a0e97

by Andre Heinecke cvs at cvs.gnupg.org
Thu Oct 25 14:13:58 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, master has been updated
       via  05a0e97f5c12c06082fbeab0fba6f86ddbfbe6b2 (commit)
      from  04791c896712857feaf9a472a48d7a4c4f287775 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 05a0e97f5c12c06082fbeab0fba6f86ddbfbe6b2
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Oct 25 14:09:37 2018 +0200

    cpp: Add some convenience functions
    
    * lang/cpp/src/context.cpp (Context::create): New.
    * lang/cpp/src/context.h: Update accordingly.
    * lang/cpp/src/key.cpp, lang/cpp/src/key.h:
    (Key::isBad, Subkey::isBad, UserID::isBad)
    (UserID::Signature::isBad): Add shorthand for the isX checks.
    * NEWS: Mention it.
    
    --
    I don't know how often I wrote:
    if (key.isNull() || key.isExpired() || key.isRevoked() ...
    
    And for the context it is good practice to use a unique ptr
    so the API should make it easy.

diff --git a/NEWS b/NEWS
index 09ac43e..69fe066 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,14 @@
 Noteworthy changes in version 1.12.1 (unreleased)
 -------------------------------------------------
 
+ * Interface changes relative to the 1.12.0 release:
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ cpp: Context::create                       NEW.
+ cpp: Key::isBad                            NEW.
+ cpp: Subkey::isBad                         NEW.
+ cpp: UserID::isBad                         NEW.
+ cpp: UserID::Signature::isBad              NEW.
+
 
 Noteworthy changes in version 1.12.0 (2018-10-08)
 -------------------------------------------------
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 2892d8b..ce38db0 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -228,6 +228,11 @@ Context *Context::createForProtocol(Protocol proto)
     return new Context(ctx);
 }
 
+std::unique_ptr<Context> Context::create(Protocol proto)
+{
+  return std::unique_ptr <Context> (createForProtocol(proto));
+}
+
 std::unique_ptr<Context> Context::createForEngine(Engine eng, Error *error)
 {
     gpgme_ctx_t ctx = 0;
diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h
index 6e27daa..d3700e0 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -68,6 +68,8 @@ public:
     //
 
     static Context *createForProtocol(Protocol proto);
+    /** Same as above but returning a unique ptr. */
+    static std::unique_ptr<Context> create(Protocol proto);
     static std::unique_ptr<Context> createForEngine(Engine engine, Error *err = 0);
     virtual ~Context();
 
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 8fc266f..0d27292 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -1033,6 +1033,26 @@ time_t Key::lastUpdate() const
     return static_cast<time_t>(key ? key->last_update : 0);
 }
 
+bool Key::isBad() const
+{
+    return isNull() || isRevoked() || isExpired() || isDisabled() || isInvalid();
+}
+
+bool Subkey::isBad() const
+{
+    return isNull() || isRevoked() || isExpired() || isDisabled() || isInvalid();
+}
+
+bool UserID::isBad() const
+{
+    return isNull() || isRevoked() || isInvalid();
+}
+
+bool UserID::Signature::isBad() const
+{
+    return isNull() || isExpired() || isInvalid();
+}
+
 std::ostream &operator<<(std::ostream &os, const UserID &uid)
 {
     os << "GpgME::UserID(";
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index 76a0d4f..c4edba0 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -98,6 +98,10 @@ public:
     bool isDisabled() const;
     bool isInvalid() const;
 
+    /*! Shorthand for isNull || isRevoked || isExpired ||
+     *                          isDisabled || isInvalid */
+    bool isBad() const;
+
     bool canEncrypt() const;
     /*!
       This function contains a workaround for old gpgme's: all secret
@@ -250,6 +254,10 @@ public:
     bool isInvalid() const;
     bool isDisabled() const;
 
+    /*! Shorthand for isNull || isRevoked || isExpired ||
+     *                          isDisabled || isInvalid */
+    bool isBad() const;
+
     bool canEncrypt() const;
     bool canSign() const;
     bool canCertify() const;
@@ -366,6 +374,9 @@ public:
     bool isRevoked() const;
     bool isInvalid() const;
 
+    /*! Shorthand for isNull || isRevoked || isInvalid */
+    bool isBad() const;
+
     /** TOFU info for this userid.
      * @returns The TOFU stats or a null TofuInfo.
      */
@@ -454,6 +465,9 @@ public:
     bool isExpired() const;
     bool isExportable() const;
 
+    /*! Shorthand for isNull || isExpired || isInvalid */
+    bool isBad() const;
+
     const char *signerUserID() const;
     const char *signerName() const;
     const char *signerEmail() const;

-----------------------------------------------------------------------

Summary of changes:
 NEWS                     |  8 ++++++++
 lang/cpp/src/context.cpp |  5 +++++
 lang/cpp/src/context.h   |  2 ++
 lang/cpp/src/key.cpp     | 20 ++++++++++++++++++++
 lang/cpp/src/key.h       | 14 ++++++++++++++
 5 files changed, 49 insertions(+)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list