[git] GPGME - branch, master, updated. gpgme-1.6.0-379-ga8ff34f

by Andre Heinecke cvs at cvs.gnupg.org
Fri Sep 16 17:00:17 CEST 2016


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  a8ff34fc3025af4079cede7f8f9fdf40189b8638 (commit)
       via  77aecfb5c97cea1a99f1ff627748cf71767bac5c (commit)
       via  4d384d7bfef044094695271576ca233625bb520a (commit)
       via  32baac8cdec6fee51bdfc3c55cb2ee141e086df4 (commit)
      from  bd24db313d860ae46d37776dcf1067455d1b9880 (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 a8ff34fc3025af4079cede7f8f9fdf40189b8638
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Sep 16 16:58:00 2016 +0200

    qt: Add test for setting tofu policy
    
    * lang/qt/tests/t-tofuinfo.cpp (testTofuPolicy): New.

diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index 2e1f1f8..f40bf21 100644
--- a/lang/qt/tests/t-tofuinfo.cpp
+++ b/lang/qt/tests/t-tofuinfo.cpp
@@ -33,6 +33,7 @@
 #include <QTemporaryDir>
 #include "protocol.h"
 #include "tofuinfo.h"
+#include "tofupolicyjob.h"
 #include "verifyopaquejob.h"
 #include "verificationresult.h"
 #include "signingresult.h"
@@ -285,6 +286,41 @@ private Q_SLOTS:
         Q_ASSERT(info.signCount());
     }
 
+    void testTofuPolicy()
+    {
+        if (!testSupported()) {
+            return;
+        }
+
+        /* First check that the key has no tofu info. */
+        auto *job = openpgp()->keyListJob(false, false, false);
+        std::vector<GpgME::Key> keys;
+        job->addMode(GpgME::WithTofu);
+        auto result = job->exec(QStringList() << QStringLiteral("bravo at example.net"),
+                                                 false, keys);
+
+        Q_ASSERT(!keys.empty());
+        auto key = keys[0];
+        Q_ASSERT(!key.isNull());
+        Q_ASSERT(key.userID(0).tofuInfo().policy() != TofuInfo::PolicyBad);
+        auto *tofuJob = openpgp()->tofuPolicyJob();
+        auto err = tofuJob->exec(key, TofuInfo::PolicyBad);
+        Q_ASSERT(!err);
+        result = job->exec(QStringList() << QStringLiteral("bravo at example.net"),
+                                            false, keys);
+        Q_ASSERT(!keys.empty());
+        key = keys[0];
+        Q_ASSERT(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyBad);
+        err = tofuJob->exec(key, TofuInfo::PolicyGood);
+
+        result = job->exec(QStringList() << QStringLiteral("bravo at example.net"),
+                                            false, keys);
+        key = keys[0];
+        Q_ASSERT(key.userID(0).tofuInfo().policy() == TofuInfo::PolicyGood);
+        delete tofuJob;
+        delete job;
+    }
+
     void initTestCase()
     {
         QGpgMETest::initTestCase();

commit 77aecfb5c97cea1a99f1ff627748cf71767bac5c
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Sep 16 16:55:25 2016 +0200

    qt: Add job for tofupolicy
    
    * lang/qt/src/job.cpp, lang/qt/src/protocol.h,
    lang/qt/src/protocol_p.h: Register job.
    * lang/qt/src/qgpgmetofupolicyjob.cpp,
    lang/qt/src/qgpgmetofupolicyjob.h,
    lang/qt/src/tofupolicyjob.h: New.
    * lang/qt/src/Makefile.am: Update accordingly.

diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am
index f63b295..c15da18 100644
--- a/lang/qt/src/Makefile.am
+++ b/lang/qt/src/Makefile.am
@@ -34,6 +34,7 @@ qgpgme_sources = \
     qgpgmesignjob.cpp qgpgmesignkeyjob.cpp qgpgmeverifydetachedjob.cpp \
     qgpgmeverifyopaquejob.cpp threadedjobmixin.cpp \
     qgpgmekeyformailboxjob.cpp gpgme_backend_debug.cpp \
+    qgpgmetofupolicyjob.cpp \
     defaultkeygenerationjob.cpp qgpgmewkspublishjob.cpp
 
 # If you add one here make sure that you also add one in camelcase
@@ -69,6 +70,7 @@ qgpgme_headers= \
     listallkeysjob.h \
     verifydetachedjob.h \
     defaultkeygenerationjob.h \
+    tofupolicyjob.h \
     wkspublishjob.h
 
 camelcase_headers= \
@@ -102,7 +104,8 @@ camelcase_headers= \
     VerifyDetachedJob \
     KeyForMailboxJob \
     DefaultKeyGenerationJob \
-    WKSPublishJob
+    WKSPublishJob \
+    TofuPolicyJob
 
 private_qgpgme_headers = \
     qgpgme_export.h \
@@ -133,6 +136,7 @@ private_qgpgme_headers = \
     qgpgmeverifyopaquejob.h \
     qgpgmekeyformailboxjob.h \
     qgpgmewkspublishjob.h \
+    qgpgmetofupolicyjob.h \
     specialjob.h \
     threadedjobmixin.h
 
@@ -179,6 +183,8 @@ qgpgme_moc_sources = \
     qgpgmeverifydetachedjob.moc \
     qgpgmeverifyopaquejob.moc \
     qgpgmewkspublishjob.moc \
+    tofupolicyjob.moc \
+    qgpgmetofupolicyjob.moc \
     refreshkeysjob.moc \
     signencryptjob.moc \
     signjob.moc \
diff --git a/lang/qt/src/job.cpp b/lang/qt/src/job.cpp
index 6b355a0..8936ea5 100644
--- a/lang/qt/src/job.cpp
+++ b/lang/qt/src/job.cpp
@@ -57,6 +57,7 @@
 #include "specialjob.h"
 #include "keyformailboxjob.h"
 #include "wkspublishjob.h"
+#include "tofupolicyjob.h"
 
 #include <QCoreApplication>
 #include <QDebug>
@@ -124,6 +125,7 @@ make_job_subclass(AddUserIDJob)
 make_job_subclass(SpecialJob)
 make_job_subclass(KeyForMailboxJob)
 make_job_subclass(WKSPublishJob)
+make_job_subclass(TofuPolicyJob)
 
 #undef make_job_subclass
 
@@ -154,3 +156,4 @@ make_job_subclass(WKSPublishJob)
 #include "specialjob.moc"
 #include "keyformailboxjob.moc"
 #include "wkspublishjob.moc"
+#include "tofupolicyjob.moc"
diff --git a/lang/qt/src/protocol.h b/lang/qt/src/protocol.h
index b2dee1d..40ddcb5 100644
--- a/lang/qt/src/protocol.h
+++ b/lang/qt/src/protocol.h
@@ -64,6 +64,7 @@ class AddUserIDJob;
 class SpecialJob;
 class KeyForMailboxJob;
 class WKSPublishJob;
+class TofuPolicyJob;
 
 /** The main entry point for QGpgME Comes in OpenPGP and SMIME(CMS) flavors.
  *
@@ -152,6 +153,9 @@ public:
 
     /** A Job for interacting with gnupg's wks tools. */
     virtual WKSPublishJob *wksPublishJob() const = 0;
+
+    /** A Job to set tofu policy */
+    virtual TofuPolicyJob *tofuPolicyJob() const = 0;
 };
 
 /** Obtain a reference to the OpenPGP Protocol.
diff --git a/lang/qt/src/protocol_p.h b/lang/qt/src/protocol_p.h
index 2ce4182..7f66fa4 100644
--- a/lang/qt/src/protocol_p.h
+++ b/lang/qt/src/protocol_p.h
@@ -58,6 +58,7 @@
 #include "qgpgmeadduseridjob.h"
 #include "qgpgmekeyformailboxjob.h"
 #include "qgpgmewkspublishjob.h"
+#include "qgpgmetofupolicyjob.h"
 
 namespace
 {
@@ -400,6 +401,18 @@ public:
         }
         return new QGpgME::QGpgMEWKSPublishJob(context.release());
     }
+
+    QGpgME::TofuPolicyJob *tofuPolicyJob() const Q_DECL_OVERRIDE
+    {
+        if (mProtocol != GpgME::OpenPGP) {
+            return Q_NULLPTR;
+        }
+        GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
+        if (!context) {
+            return Q_NULLPTR;
+        }
+        return new QGpgME::QGpgMETofuPolicyJob(context);
+    }
 };
 
 }
diff --git a/lang/qt/src/qgpgmetofupolicyjob.cpp b/lang/qt/src/qgpgmetofupolicyjob.cpp
new file mode 100644
index 0000000..a24c946
--- /dev/null
+++ b/lang/qt/src/qgpgmetofupolicyjob.cpp
@@ -0,0 +1,65 @@
+/* qgpgmetofupolicyjob.cpp
+
+    Copyright (c) 2016 Intevation GmbH
+
+    QGpgME is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.
+
+    QGpgME is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+    In addition, as a special exception, the copyright holders give
+    permission to link the code of this program with any edition of
+    the Qt library by Trolltech AS, Norway (or with modified versions
+    of Qt that use the same license as Qt), and distribute linked
+    combinations including the two.  You must obey the GNU General
+    Public License in all respects for all of the code used other than
+    Qt.  If you modify this file, you may extend this exception to
+    your version of the file, but you are not obligated to do so.  If
+    you do not wish to do so, delete this exception statement from
+    your version.
+*/
+
+#include "qgpgmetofupolicyjob.h"
+
+#include "context.h"
+#include "key.h"
+#include "tofuinfo.h"
+
+
+using namespace QGpgME;
+using namespace GpgME;
+
+QGpgMETofuPolicyJob::QGpgMETofuPolicyJob(Context *context)
+    : mixin_type(context)
+{
+    lateInitialization();
+}
+
+QGpgMETofuPolicyJob::~QGpgMETofuPolicyJob() {}
+
+static QGpgMETofuPolicyJob::result_type policy_worker(Context *ctx, const Key &key, TofuInfo::Policy policy)
+{
+    return std::make_tuple (ctx->setTofuPolicy(key, policy),
+                            QString(), Error());
+}
+
+void QGpgMETofuPolicyJob::start(const Key &key, TofuInfo::Policy policy)
+{
+    run(std::bind(&policy_worker, std::placeholders::_1, key, policy));
+}
+
+Error QGpgMETofuPolicyJob::exec(const Key &key, TofuInfo::Policy policy)
+{
+    return std::get<0>(policy_worker(context(), key, policy));
+}
+
+#include "qgpgmetofupolicyjob.moc"
diff --git a/lang/qt/src/qgpgmetofupolicyjob.h b/lang/qt/src/qgpgmetofupolicyjob.h
new file mode 100644
index 0000000..e7272e7
--- /dev/null
+++ b/lang/qt/src/qgpgmetofupolicyjob.h
@@ -0,0 +1,65 @@
+/* qgpgmetofupolicyjob.h
+
+    Copyright (c) 2016 Intevation GmbH
+
+    QGpgME is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.
+
+    QGpgME is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+    In addition, as a special exception, the copyright holders give
+    permission to link the code of this program with any edition of
+    the Qt library by Trolltech AS, Norway (or with modified versions
+    of Qt that use the same license as Qt), and distribute linked
+    combinations including the two.  You must obey the GNU General
+    Public License in all respects for all of the code used other than
+    Qt.  If you modify this file, you may extend this exception to
+    your version of the file, but you are not obligated to do so.  If
+    you do not wish to do so, delete this exception statement from
+    your version.
+*/
+#ifndef QGPGME_QGPGMETOFUPOLICYJOB_H
+#define QGPGME_QGPGMETOFUPOLICYJOB_H
+
+#include "tofupolicyjob.h"
+
+#include "threadedjobmixin.h"
+namespace GpgME
+{
+    class Key;
+} // namespace GpgME
+
+namespace QGpgME {
+
+class QGpgMETofuPolicyJob
+#ifdef Q_MOC_RUN
+    : public TofuPolicyJob
+#else
+    : public _detail::ThreadedJobMixin<TofuPolicyJob, std::tuple<GpgME::Error, QString, GpgME::Error> >
+#endif
+{
+    Q_OBJECT
+#ifdef Q_MOC_RUN
+public Q_SLOTS:
+    void slotFinished();
+#endif
+public:
+    explicit QGpgMETofuPolicyJob(GpgME::Context *context);
+    ~QGpgMETofuPolicyJob();
+
+    void start(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) Q_DECL_OVERRIDE;
+    GpgME::Error exec(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) Q_DECL_OVERRIDE;
+};
+
+}
+
+#endif
diff --git a/lang/qt/src/tofupolicyjob.h b/lang/qt/src/tofupolicyjob.h
new file mode 100644
index 0000000..3079f91
--- /dev/null
+++ b/lang/qt/src/tofupolicyjob.h
@@ -0,0 +1,80 @@
+/* tofupolicyjob.h
+
+    Copyright (c) 2016 Intevation GmbH
+
+    QGpgME is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.
+
+    QGpgME is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    General Public License for more details.
+
+    You should have received a copy of the GNU General Public License along
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+    In addition, as a special exception, the copyright holders give
+    permission to link the code of this program with any edition of
+    the Qt library by Trolltech AS, Norway (or with modified versions
+    of Qt that use the same license as Qt), and distribute linked
+    combinations including the two.  You must obey the GNU General
+    Public License in all respects for all of the code used other than
+    Qt.  If you modify this file, you may extend this exception to
+    your version of the file, but you are not obligated to do so.  If
+    you do not wish to do so, delete this exception statement from
+    your version.
+*/
+#ifndef QGPGME_TOFUPOLICYJOB_H
+#define QGPGME_TOFUPOLICYJOB_H
+
+#include "job.h"
+
+#include "qgpgme_export.h"
+
+#ifdef BUILDING_QGPGME
+# include "tofuinfo.h"
+#else
+# include <gpgme++/tofuinfo.h>
+#endif
+
+namespace GpgME
+{
+    class Key;
+} // namespace GpgME
+
+namespace QGpgME {
+
+/**
+ * Set the TOFU Policy for a key
+ */
+class QGPGME_EXPORT TofuPolicyJob: public Job
+{
+    Q_OBJECT
+protected:
+    explicit TofuPolicyJob(QObject *parent);
+public:
+    ~TofuPolicyJob();
+
+
+    /* Set the policy to \a policy see the gpgme manual for
+     * policy explanations. */
+    virtual void start(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) = 0;
+
+    virtual GpgME::Error exec(const GpgME::Key &key, GpgME::TofuInfo::Policy policy) = 0;
+
+Q_SIGNALS:
+    /* Result of the operation
+     *
+     * As usual auditLogAsHtml and auditLogError can be ignored.
+     **/
+    void result(const GpgME::Error &error,
+                const QString &auditLogAsHtml = QString(),
+                const GpgME::Error &auditLogError = GpgME::Error());
+};
+
+}
+
+#endif

commit 4d384d7bfef044094695271576ca233625bb520a
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Sep 16 16:54:07 2016 +0200

    cpp: Add support for gpgme_op_tofu_policy
    
    * src/context.cpp, src/context.h (setTofuPolicy, setTofuPolicyStart):
    New.

diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 1e134a0..00f397b 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -41,6 +41,7 @@
 #include "data_p.h"
 #include "context_p.h"
 #include "util.h"
+#include "tofuinfo.h"
 
 #include <gpgme.h>
 
@@ -1329,6 +1330,36 @@ Error Context::setPinentryMode(PinentryMode which)
     return Error(d->lasterr = gpgme_set_pinentry_mode(d->ctx, mode));
 }
 
+static gpgme_tofu_policy_t to_tofu_policy_t(unsigned int policy)
+{
+    switch (policy) {
+        case TofuInfo::PolicyNone:
+            return GPGME_TOFU_POLICY_NONE;
+        case TofuInfo::PolicyAuto:
+            return GPGME_TOFU_POLICY_AUTO;
+        case TofuInfo::PolicyGood:
+            return GPGME_TOFU_POLICY_GOOD;
+        case TofuInfo::PolicyBad:
+            return GPGME_TOFU_POLICY_BAD;
+        case TofuInfo::PolicyAsk:
+            return GPGME_TOFU_POLICY_ASK;
+        case TofuInfo::PolicyUnknown:
+            return GPGME_TOFU_POLICY_UNKNOWN;
+    }
+}
+
+Error Context::setTofuPolicy(const Key &k, unsigned int policy)
+{
+    return Error(d->lasterr = gpgme_op_tofu_policy(d->ctx,
+                 k.impl(), to_tofu_policy_t(policy)));
+}
+
+Error Context::setTofuPolicyStart(const Key &k, unsigned int policy)
+{
+    return Error(d->lasterr = gpgme_op_tofu_policy_start(d->ctx,
+                 k.impl(), to_tofu_policy_t(policy)));
+}
+
 // Engine Spawn stuff
 Error Context::spawn(const char *file, const char *argv[],
                      Data &input, Data &output, Data &err,
diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h
index f5e2b95..b1e4f5f 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -214,6 +214,10 @@ public:
     GpgME::Error edit(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
     GpgME::Error startEditing(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
 
+    // using TofuInfo::Policy
+    Error setTofuPolicy(const Key &k, unsigned int policy);
+    Error setTofuPolicyStart(const Key &k, unsigned int policy);
+
     EditInteractor *lastEditInteractor() const;
     std::unique_ptr<EditInteractor> takeLastEditInteractor();
 

commit 32baac8cdec6fee51bdfc3c55cb2ee141e086df4
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Sep 16 16:52:03 2016 +0200

    cpp: Declare sizes of tofu-info enums
    
    * lang/cpp/src/tofuinfo.h (Policy, Validity): Declare sizes.
    
    --
    This is a quick ABI break before the release so that we can
    easier extend them in the future. All new enums in public API
    should be declared with a size from now on.

diff --git a/lang/cpp/src/tofuinfo.h b/lang/cpp/src/tofuinfo.h
index ec253e9..c09c82a 100644
--- a/lang/cpp/src/tofuinfo.h
+++ b/lang/cpp/src/tofuinfo.h
@@ -56,7 +56,7 @@ public:
 
     /* @enum Validity
      * @brief The TOFU Validity. */
-    enum Validity {
+    enum Validity : unsigned int {
         /*! Unknown (uninitialized).*/
         ValidityUnknown,
         /*! TOFU Conflict.*/
@@ -74,7 +74,7 @@ public:
 
     /* @enum Policy
      * @brief The TOFU Validity. */
-    enum Policy {
+    enum Policy : unsigned int {
         /*! GPGME_TOFU_POLICY_NONE */
         PolicyNone,
         /*! GPGME_TOFU_POLICY_AUTO */

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

Summary of changes:
 lang/cpp/src/context.cpp                           | 31 +++++++++++++
 lang/cpp/src/context.h                             |  4 ++
 lang/cpp/src/tofuinfo.h                            |  4 +-
 lang/qt/src/Makefile.am                            |  8 +++-
 lang/qt/src/job.cpp                                |  3 ++
 lang/qt/src/protocol.h                             |  4 ++
 lang/qt/src/protocol_p.h                           | 13 ++++++
 ...qgpgmedeletejob.cpp => qgpgmetofupolicyjob.cpp} | 34 +++++++-------
 ...qgpgmewkspublishjob.h => qgpgmetofupolicyjob.h} | 27 +++++------
 .../src/{qgpgmewkspublishjob.h => tofupolicyjob.h} | 54 +++++++++++++---------
 lang/qt/tests/t-tofuinfo.cpp                       | 36 +++++++++++++++
 11 files changed, 160 insertions(+), 58 deletions(-)
 copy lang/qt/src/{qgpgmedeletejob.cpp => qgpgmetofupolicyjob.cpp} (66%)
 copy lang/qt/src/{qgpgmewkspublishjob.h => qgpgmetofupolicyjob.h} (70%)
 copy lang/qt/src/{qgpgmewkspublishjob.h => tofupolicyjob.h} (62%)


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




More information about the Gnupg-commits mailing list