[git] GPGME - branch, master, updated. gpgme-1.8.0-116-g66c3346

by Andre Heinecke cvs at cvs.gnupg.org
Wed Mar 22 16:44:02 CET 2017


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  66c334650bd64fdb72c4bd5975e25b8659d320ec (commit)
       via  8ddb42ada46f00d8393f6c2df7d6b79a4a5878f0 (commit)
       via  121873b821636052c10d9e0bd885eb9013c52096 (commit)
      from  104635eb503ec764146731888a6975b4329660fd (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 66c334650bd64fdb72c4bd5975e25b8659d320ec
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Mar 22 16:41:04 2017 +0100

    qt: Add test for Data::toKeys
    
    * lang/qt/tests/t-various.cpp (TestVarious::testKeyFromFile): New.

diff --git a/lang/qt/tests/t-various.cpp b/lang/qt/tests/t-various.cpp
index 2b51fe6..35d8da9 100644
--- a/lang/qt/tests/t-various.cpp
+++ b/lang/qt/tests/t-various.cpp
@@ -43,12 +43,28 @@
 #include "context.h"
 #include "engineinfo.h"
 #include "dn.h"
+#include "data.h"
+#include "dataprovider.h"
 
 #include "t-support.h"
 
 using namespace QGpgME;
 using namespace GpgME;
 
+static const char aKey[] = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
+"\n"
+"mDMEWG+w/hYJKwYBBAHaRw8BAQdAiq1oStvDYg8ZfFs5DgisYJo8dJxD+C/AA21O\n"
+"K/aif0O0GXRvZnVfY29uZmxpY3RAZXhhbXBsZS5jb22IlgQTFggAPhYhBHoJBLaV\n"
+"DamYAgoa1L5BwMOl/x88BQJYb7D+AhsDBQkDwmcABQsJCAcCBhUICQoLAgQWAgMB\n"
+"Ah4BAheAAAoJEL5BwMOl/x88GvwA/0SxkbLyAcshGm2PRrPsFQsSVAfwaSYFVmS2\n"
+"cMVIw1PfAQDclRH1Z4MpufK07ju4qI33o4s0UFpVRBuSxt7A4P2ZD7g4BFhvsP4S\n"
+"CisGAQQBl1UBBQEBB0AmVrgaDNJ7K2BSalsRo2EkRJjHGqnp5bBB0tapnF81CQMB\n"
+"CAeIeAQYFggAIBYhBHoJBLaVDamYAgoa1L5BwMOl/x88BQJYb7D+AhsMAAoJEL5B\n"
+"wMOl/x88OR0BAMq4/vmJUORRTmzjHcv/DDrQB030DSq666rlckGIKTShAPoDXM9N\n"
+"0gZK+YzvrinSKZXHmn0aSwmC1/hyPybJPEljBw==\n"
+"=p2Oj\n"
+"-----END PGP PUBLIC KEY BLOCK-----\n";
+
 class TestVarious: public QGpgMETest
 {
     Q_OBJECT
@@ -67,6 +83,20 @@ private Q_SLOTS:
         QVERIFY(dn.prettyDN() == QStringLiteral("DC=North America,DC=Fabrikam,DC=COM,OU=Test,CN=Before\rAfter"));
     }
 
+    void testKeyFromFile()
+    {
+        if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.14") {
+            return;
+        }
+        QGpgME::QByteArrayDataProvider dp(aKey);
+        Data data(&dp);
+        const auto keys = data.toKeys();
+        QVERIFY(keys.size() == 1);
+        const auto key = keys[0];
+        QVERIFY(!key.isNull());
+        QVERIFY(key.primaryFingerprint() == QStringLiteral("7A0904B6950DA998020A1AD4BE41C0C3A5FF1F3C"));
+    }
+
     void testQuickUid()
     {
         if (GpgME::engineInfo(GpgME::GpgEngine).engineVersion() < "2.1.13") {

commit 8ddb42ada46f00d8393f6c2df7d6b79a4a5878f0
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Mar 22 16:38:35 2017 +0100

    cpp: Wrap keylist_from_data
    
    * lang/cpp/data.h, lang/cpp/data.cpp (GpgME::Data::toKeys): New.
    
    --
    Doing this in data instead of Context is a bit more idiomatic. But
    this could also be added to Context.

diff --git a/NEWS b/NEWS
index 367b718..d03fe80 100644
--- a/NEWS
+++ b/NEWS
@@ -26,6 +26,7 @@ Noteworthy changes in version 1.8.1 (unreleased)
  cpp: GpgGenCardKeyInteractor                       NEW.
  cpp: Subkey::keyGrip                               NEW.
  cpp: Subkey::isDeVs                                NEW.
+ cpp: Data::toKeys                                  NEW.
  qt: CryptoConfig::stringValueList()                NEW.
  py: Context.__init__        EXTENDED: New keyword arg home_dir.
  py: Context.home_dir        NEW.
diff --git a/lang/cpp/src/data.cpp b/lang/cpp/src/data.cpp
index 2cb4fa8..32ca561 100644
--- a/lang/cpp/src/data.cpp
+++ b/lang/cpp/src/data.cpp
@@ -25,6 +25,7 @@
 #endif
 
 #include "data_p.h"
+#include "context_p.h"
 #include <error.h>
 #include <interfaces/dataprovider.h>
 
@@ -230,3 +231,26 @@ off_t GpgME::Data::seek(off_t offset, int whence)
 {
     return gpgme_data_seek(d->data, offset, whence);
 }
+
+std::vector<GpgME::Key> GpgME::Data::toKeys(Protocol proto) const
+{
+    std::vector<GpgME::Key> ret;
+    if (isNull()) {
+        return ret;
+    }
+    auto ctx = GpgME::Context::createForProtocol(proto);
+    if (!ctx) {
+        return ret;
+    }
+
+    if (gpgme_op_keylist_from_data_start (ctx->impl()->ctx, d->data, 0)) {
+        return ret;
+    }
+
+    gpgme_key_t key;
+    while (!gpgme_op_keylist_next (ctx->impl()->ctx, &key)) {
+        ret.push_back(GpgME::Key(key, false));
+    }
+    delete ctx;
+    return ret;
+}
diff --git a/lang/cpp/src/data.h b/lang/cpp/src/data.h
index 50bdf62..cc7906f 100644
--- a/lang/cpp/src/data.h
+++ b/lang/cpp/src/data.h
@@ -24,6 +24,7 @@
 #define __GPGMEPP_DATA_H__
 
 #include "global.h"
+#include "key.h"
 
 #include <sys/types.h> // for size_t, off_t
 #include <cstdio> // FILE
@@ -109,6 +110,10 @@ public:
     ssize_t write(const void *buffer, size_t length);
     off_t seek(off_t offset, int whence);
 
+    /** Try to parse the data to a key object using the
+     * Protocol proto. Returns an empty list on error.*/
+    std::vector<Key> toKeys(const Protocol proto = Protocol::OpenPGP) const;
+
     class Private;
     Private *impl()
     {

commit 121873b821636052c10d9e0bd885eb9013c52096
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Mar 22 16:34:29 2017 +0100

    qt: Initialize library first in tests
    
    * lang/qt/tests/t-support.cpp (QGpgMETest::initTestCase): Initialize
    library.

diff --git a/lang/qt/tests/t-support.cpp b/lang/qt/tests/t-support.cpp
index 857d0a3..b3a7a70 100644
--- a/lang/qt/tests/t-support.cpp
+++ b/lang/qt/tests/t-support.cpp
@@ -34,6 +34,7 @@
 #endif
 
 #include "t-support.h"
+#include "context.h"
 
 #include <QTest>
 
@@ -44,6 +45,7 @@
 
 void QGpgMETest::initTestCase()
 {
+    GpgME::initializeLibrary();
     const QString gpgHome = qgetenv("GNUPGHOME");
     QVERIFY2(!gpgHome.isEmpty(), "GNUPGHOME environment variable is not set.");
 }

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

Summary of changes:
 NEWS                        |  1 +
 lang/cpp/src/data.cpp       | 24 ++++++++++++++++++++++++
 lang/cpp/src/data.h         |  5 +++++
 lang/qt/tests/t-support.cpp |  2 ++
 lang/qt/tests/t-various.cpp | 30 ++++++++++++++++++++++++++++++
 5 files changed, 62 insertions(+)


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




More information about the Gnupg-commits mailing list