[git] GPGME - branch, master, updated. gpgme-1.11.0-5-gd65d632

by Andre Heinecke cvs at cvs.gnupg.org
Thu Apr 19 11:57:31 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  d65d6329319bff8cc555999fc92a20e151762a10 (commit)
      from  0adaf7bafd352f1c3a1e797493780150e3bb0adc (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 d65d6329319bff8cc555999fc92a20e151762a10
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Apr 19 11:56:15 2018 +0200

    cpp: Add origin and last_update to UserID
    
    * NEWS: Mention it.
    * lang/cpp/src/key.cpp, lang/cpp/src/key.h (UserID::lastUpdate),
    (UserID::origin): New.
    (gpgme_origin_to_pp_origin): New helper.

diff --git a/NEWS b/NEWS
index 9d6bd0a..6deb325 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ Noteworthy changes in version 1.11.1 (unreleased)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cpp: Key::origin                     NEW.
  cpp: Key::lastUpdate                 NEW.
+ cpp: UserID::origin                  NEW.
+ cpp: UserID::lastUpdate              NEW.
 
 Noteworthy changes in version 1.11.0 (2018-04-18)
 -------------------------------------------------
diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 838033c..034286f 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -967,6 +967,42 @@ Error UserID::revoke()
     return ret;
 }
 
+static Key::Origin gpgme_origin_to_pp_origin (const unsigned int origin)
+{
+    switch (origin) {
+        case GPGME_KEYORG_KS:
+            return Key::OriginKS;
+        case GPGME_KEYORG_DANE:
+            return Key::OriginDane;
+        case GPGME_KEYORG_WKD:
+            return Key::OriginWKD;
+        case GPGME_KEYORG_URL:
+            return Key::OriginURL;
+        case GPGME_KEYORG_FILE:
+            return Key::OriginFile;
+        case GPGME_KEYORG_SELF:
+            return Key::OriginSelf;
+        case GPGME_KEYORG_OTHER:
+            return Key::OriginOther;
+        case GPGME_KEYORG_UNKNOWN:
+        default:
+            return Key::OriginUnknown;
+    }
+}
+
+Key::Origin UserID::origin() const
+{
+    if (isNull()) {
+        return Key::OriginUnknown;
+    }
+    return gpgme_origin_to_pp_origin(uid->origin);
+}
+
+time_t UserID::lastUpdate() const
+{
+    return static_cast<time_t>(uid ? uid->last_update : 0);
+}
+
 Error Key::addUid(const char *uid)
 {
     if (isNull()) {
@@ -986,25 +1022,7 @@ Key::Origin Key::origin() const
     if (isNull()) {
         return OriginUnknown;
     }
-    switch (key->origin) {
-        case GPGME_KEYORG_KS:
-            return OriginKS;
-        case GPGME_KEYORG_DANE:
-            return OriginDane;
-        case GPGME_KEYORG_WKD:
-            return OriginWKD;
-        case GPGME_KEYORG_URL:
-            return OriginURL;
-        case GPGME_KEYORG_FILE:
-            return OriginFile;
-        case GPGME_KEYORG_SELF:
-            return OriginSelf;
-        case GPGME_KEYORG_OTHER:
-            return OriginOther;
-        case GPGME_KEYORG_UNKNOWN:
-        default:
-            return OriginUnknown;
-    }
+    return gpgme_origin_to_pp_origin(key->origin);
 }
 
 time_t Key::lastUpdate() const
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index 07ddc25..76a0d4f 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -392,6 +392,16 @@ public:
      *
      * @returns an error on error.*/
     Error revoke();
+
+    /*! Get the origin of the key.
+     *
+     * @returns the Origin. */
+    Key::Origin origin() const;
+
+    /*! Get the last update time.
+     *
+     * @returns the last update time. */
+    time_t lastUpdate() const;
 private:
     shared_gpgme_key_t key;
     gpgme_user_id_t uid;

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

Summary of changes:
 NEWS                 |  2 ++
 lang/cpp/src/key.cpp | 56 ++++++++++++++++++++++++++++++++++------------------
 lang/cpp/src/key.h   | 10 ++++++++++
 3 files changed, 49 insertions(+), 19 deletions(-)


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




More information about the Gnupg-commits mailing list