[git] GPGME - branch, master, updated. gpgme-1.9.0-85-g7d1ac5d

by Andre Heinecke cvs at cvs.gnupg.org
Fri Dec 1 14:35:35 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  7d1ac5d61de3c55bf7ff14997b4b111a0f90c177 (commit)
       via  8e2d6c28a5e923f829b5a26d19d9d897949aa1fe (commit)
      from  651b3d8207cc7d85699f89fc4c21cb1243453aa8 (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 7d1ac5d61de3c55bf7ff14997b4b111a0f90c177
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Dec 1 14:29:04 2017 +0100

    qt: Add job for quick commands
    
    * lang/qt/src/qgpgmequickjob.cpp,
    lang/qt/src/qgpgmequickjob.h,
    lang/qt/src/quickjob.h: New.
    * lang/qt/src/Makefile.am,
    lang/qt/src/protocol.h,
    lang/qt/src/protocol_p.h,
    lang/qt/src/job.cpp: Update accordingly.
    
    --
    Keeping it in line with the Job for everything pattern.
    Although it's reduced to one job for four commands as
    the commands all behave the same.

diff --git a/NEWS b/NEWS
index 83c8f5f..fd26ad2 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,7 @@ Noteworthy changes in version 1.10.0 (unreleased)
  cpp: Context::startCreateKey          NEW.
  cpp: Context::createSubkey            NEW.
  cpp: Context::startCreateSubkey       NEW.
+ qt: QuickJob                          NEW.
  py: DecryptResult           EXTENDED: New boolean field 'is_de_vs'.
  py: Signature               EXTENDED: New boolean field 'is_de_vs'.
  py: GpgError                EXTENDED: Partial results in 'results'.
diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am
index 3b3cffc..3225142 100644
--- a/lang/qt/src/Makefile.am
+++ b/lang/qt/src/Makefile.am
@@ -36,7 +36,7 @@ qgpgme_sources = \
     qgpgmesignjob.cpp qgpgmesignkeyjob.cpp qgpgmeverifydetachedjob.cpp \
     qgpgmeverifyopaquejob.cpp threadedjobmixin.cpp \
     qgpgmekeyformailboxjob.cpp gpgme_backend_debug.cpp \
-    qgpgmetofupolicyjob.cpp \
+    qgpgmetofupolicyjob.cpp qgpgmequickjob.cpp \
     defaultkeygenerationjob.cpp qgpgmewkspublishjob.cpp \
     dn.cpp cryptoconfig.cpp
 
@@ -60,6 +60,7 @@ qgpgme_headers= \
     protocol.h \
     qgpgme_export.h \
     qgpgmenewcryptoconfig.h \
+    quickjob.h \
     specialjob.h \
     signjob.h \
     signkeyjob.h \
@@ -97,6 +98,7 @@ camelcase_headers= \
     MultiDeleteJob \
     Protocol \
     QGpgMENewCryptoConfig \
+    QuickJob \
     SpecialJob \
     SignJob \
     SignKeyJob \
@@ -145,6 +147,7 @@ private_qgpgme_headers = \
     qgpgmekeyformailboxjob.h \
     qgpgmewkspublishjob.h \
     qgpgmetofupolicyjob.h \
+    qgpgmequickjob.h \
     threadedjobmixin.h
 
 qgpgme_moc_sources = \
@@ -202,7 +205,9 @@ qgpgme_moc_sources = \
     keyformailboxjob.moc \
     wkspublishjob.moc \
     qgpgmekeyformailboxjob.moc \
-    defaultkeygenerationjob.moc
+    defaultkeygenerationjob.moc \
+    quickjob.moc \
+    qgpgmequickjob.moc
 
 qgpgmeincludedir = $(includedir)/qgpgme
 qgpgmeinclude_HEADERS = $(qgpgme_headers)
diff --git a/lang/qt/src/job.cpp b/lang/qt/src/job.cpp
index 83c5044..c427020 100644
--- a/lang/qt/src/job.cpp
+++ b/lang/qt/src/job.cpp
@@ -64,6 +64,7 @@
 #include "wkspublishjob.h"
 #include "tofupolicyjob.h"
 #include "threadedjobmixin.h"
+#include "quickjob.h"
 
 #include <QCoreApplication>
 #include <QDebug>
@@ -139,6 +140,7 @@ make_job_subclass(SpecialJob)
 make_job_subclass(KeyForMailboxJob)
 make_job_subclass(WKSPublishJob)
 make_job_subclass(TofuPolicyJob)
+make_job_subclass(QuickJob)
 
 #undef make_job_subclass
 
@@ -170,3 +172,4 @@ make_job_subclass(TofuPolicyJob)
 #include "keyformailboxjob.moc"
 #include "wkspublishjob.moc"
 #include "tofupolicyjob.moc"
+#include "quickjob.moc"
diff --git a/lang/qt/src/protocol.h b/lang/qt/src/protocol.h
index 6794bc2..1a52097 100644
--- a/lang/qt/src/protocol.h
+++ b/lang/qt/src/protocol.h
@@ -66,6 +66,7 @@ class SpecialJob;
 class KeyForMailboxJob;
 class WKSPublishJob;
 class TofuPolicyJob;
+class QuickJob;
 
 /** The main entry point for QGpgME Comes in OpenPGP and SMIME(CMS) flavors.
  *
@@ -157,6 +158,9 @@ public:
 
     /** A Job to set tofu policy */
     virtual TofuPolicyJob *tofuPolicyJob() const = 0;
+
+    /** A Job for the quick commands */
+    virtual QuickJob *quickJob() 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 58a0fa6..b6d1abf 100644
--- a/lang/qt/src/protocol_p.h
+++ b/lang/qt/src/protocol_p.h
@@ -60,6 +60,7 @@
 #include "qgpgmekeyformailboxjob.h"
 #include "qgpgmewkspublishjob.h"
 #include "qgpgmetofupolicyjob.h"
+#include "qgpgmequickjob.h"
 
 namespace
 {
@@ -414,6 +415,18 @@ public:
         }
         return new QGpgME::QGpgMETofuPolicyJob(context);
     }
+
+    QGpgME::QuickJob *quickJob() 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::QGpgMEQuickJob(context);
+    }
 };
 
 }
diff --git a/lang/qt/src/qgpgmequickjob.cpp b/lang/qt/src/qgpgmequickjob.cpp
new file mode 100644
index 0000000..13ec0a9
--- /dev/null
+++ b/lang/qt/src/qgpgmequickjob.cpp
@@ -0,0 +1,123 @@
+/* qgpgmequickjob.cpp
+
+    Copyright (c) 2017 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.
+*/
+
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include "qgpgmequickjob.h"
+
+#include "context.h"
+#include "key.h"
+#include "util.h"
+
+using namespace QGpgME;
+using namespace GpgME;
+
+QGpgMEQuickJob::QGpgMEQuickJob(Context *context)
+    : mixin_type(context)
+{
+    lateInitialization();
+}
+
+QGpgMEQuickJob::~QGpgMEQuickJob() {}
+
+static QGpgMEQuickJob::result_type createWorker(GpgME::Context *ctx,
+                                                const QString &uid,
+                                                const char *algo,
+                                                const QDateTime &expires,
+                                                const GpgME::Key &key,
+                                                unsigned int flags)
+{
+    auto err = ctx->createKey(uid.toUtf8().constData(),
+                              algo,
+                              0,
+                              expires.isValid() ? (unsigned long) expires.toSecsSinceEpoch() : 0,
+                              key,
+                              flags);
+    return std::make_tuple(err, QString(), Error());
+}
+
+static QGpgMEQuickJob::result_type addSubkeyWorker(GpgME::Context *ctx,
+                                                    const GpgME::Key &key,
+                                                    const char *algo,
+                                                    const QDateTime &expires,
+                                                    unsigned int flags)
+{
+    auto err = ctx->createSubkey(key, algo,  0,
+                                 expires.isValid() ? (unsigned long) expires.toSecsSinceEpoch() : 0,
+                                 flags);
+    return std::make_tuple(err, QString(), Error());
+}
+
+static QGpgMEQuickJob::result_type addUidWorker(GpgME::Context *ctx,
+                                                const GpgME::Key &key,
+                                                const QString &uid)
+{
+    auto err = ctx->addUid(key, uid.toUtf8().constData());
+    return std::make_tuple(err, QString(), Error());
+}
+
+static QGpgMEQuickJob::result_type revUidWorker(GpgME::Context *ctx,
+                                                const GpgME::Key &key,
+                                                const QString &uid)
+{
+    auto err = ctx->revUid(key, uid.toUtf8().constData());
+    return std::make_tuple(err, QString(), Error());
+}
+
+void QGpgMEQuickJob::startCreate(const QString &uid,
+                 const char *algo,
+                 const QDateTime &expires,
+                 const GpgME::Key &key,
+                 unsigned int flags)
+{
+    run(std::bind(&createWorker, std::placeholders::_1, uid, algo,
+                  expires, key, flags));
+}
+
+void QGpgMEQuickJob::startAddUid(const GpgME::Key &key, const QString &uid)
+{
+    run(std::bind(&addUidWorker, std::placeholders::_1, key, uid));
+}
+
+void QGpgMEQuickJob::startRevUid(const GpgME::Key &key, const QString &uid)
+{
+    run(std::bind(&revUidWorker, std::placeholders::_1, key, uid));
+}
+
+void QGpgMEQuickJob::startAddSubkey(const GpgME::Key &key, const char *algo,
+                                    const QDateTime &expires,
+                                    unsigned int flags)
+{
+    run(std::bind(&addSubkeyWorker, std::placeholders::_1, key, algo,
+                  expires, flags));
+}
+#include "qgpgmequickjob.moc"
diff --git a/lang/qt/src/qgpgmequickjob.h b/lang/qt/src/qgpgmequickjob.h
new file mode 100644
index 0000000..82c7332
--- /dev/null
+++ b/lang/qt/src/qgpgmequickjob.h
@@ -0,0 +1,82 @@
+/*  qgpgmequickjob.h
+
+    Copyright (c) 2017 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_QGPGMEQUICKJOB_H
+#define QGPGME_QGPGMEQUICKJOB_H
+
+#include "quickjob.h"
+
+#include "threadedjobmixin.h"
+
+namespace GpgME {
+class Key;
+}
+
+class QDateTime;
+class QString;
+
+namespace QGpgME{
+
+/**
+ * Interface to the modern key manipulation functions.
+ */
+class QGpgMEQuickJob
+#ifdef Q_MOC_RUN
+    : public QuickJob
+#else
+    : public _detail::ThreadedJobMixin<QuickJob, std::tuple<GpgME::Error, QString, GpgME::Error> >
+#endif
+{
+    Q_OBJECT
+#ifdef Q_MOC_RUN
+public Q_SLOTS:
+    void slotFinished();
+#endif
+public:
+    explicit QGpgMEQuickJob(GpgME::Context *context);
+    ~QGpgMEQuickJob();
+
+    void startCreate(const QString &uid,
+                     const char *algo,
+                     const QDateTime &expires = QDateTime(),
+                     const GpgME::Key &key = GpgME::Key(),
+                     unsigned int flags = 0) Q_DECL_OVERRIDE;
+    void startAddUid(const GpgME::Key &key, const QString &uid) Q_DECL_OVERRIDE;
+    void startRevUid(const GpgME::Key &key, const QString &uid) Q_DECL_OVERRIDE;
+    void startAddSubkey(const GpgME::Key &key, const char *algo,
+                        const QDateTime &expires = QDateTime(),
+                        unsigned int flags = 0) Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+    void result(const GpgME::Error &error,
+                const QString &auditLogAsHtml, const GpgME::Error &auditLogError);
+};
+
+}
+#endif
diff --git a/lang/qt/src/quickjob.h b/lang/qt/src/quickjob.h
new file mode 100644
index 0000000..c0a655b
--- /dev/null
+++ b/lang/qt/src/quickjob.h
@@ -0,0 +1,83 @@
+/*  quickjob.h
+
+    Copyright (c) 2017 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_QUICKJOB_H
+#define QGPGME_QUICKJOB_H
+
+#include "job.h"
+
+#include "qgpgme_export.h"
+
+#include <QDateTime>
+
+#ifdef BUILDING_QGPGME
+# include "key.h"
+#else
+# include <gpgme++/key.h>
+#endif
+
+class QString;
+
+namespace QGpgME{
+
+/**
+ * Interface to the modern key manipulation functions.
+ */
+class QGPGME_EXPORT QuickJob : public Job
+{
+    Q_OBJECT
+public:
+    explicit QuickJob(QObject *parent = Q_NULLPTR);
+    ~QuickJob();
+
+    /** Start --quick-gen-key */
+    virtual void startCreate(const QString &uid,
+                             const char *algo,
+                             const QDateTime &expires = QDateTime(),
+                             const GpgME::Key &key = GpgME::Key(),
+                             unsigned int flags = 0) = 0;
+
+    /** Start --quick-adduid */
+    virtual void startAddUid(const GpgME::Key &key, const QString &uid) = 0;
+
+    /** Start --quick-revuid */
+    virtual void startRevUid(const GpgME::Key &key, const QString &uid) = 0;
+
+    /** Start --quick-add-key */
+    virtual void startAddSubkey(const GpgME::Key &key, const char *algo,
+                                const QDateTime &expires = QDateTime(),
+                                unsigned int flags = 0) = 0;
+
+Q_SIGNALS:
+    void result(const GpgME::Error &error,
+                const QString &auditLogAsHtml, const GpgME::Error &auditLogError);
+};
+
+}
+#endif

commit 8e2d6c28a5e923f829b5a26d19d9d897949aa1fe
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Dec 1 13:21:34 2017 +0100

    cpp: Wrap create_key and create_subkey
    
    * lang/cpp/src/context.cpp,
    lang/cpp/src/context.h (Context::startCreateKey)
    (Context::createKey, Context::createSubkey)
    (Context::startCreateSubkey): New.

diff --git a/NEWS b/NEWS
index aee3f10..83c8f5f 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,10 @@ Noteworthy changes in version 1.10.0 (unreleased)
  cpp: DecryptionResult::isDeVs         NEW.
  cpp: Signature::isDeVs                NEW.
  cpp: EngineInfo::Version::operator>   NEW.
+ cpp: Context::createKey               NEW.
+ cpp: Context::startCreateKey          NEW.
+ cpp: Context::createSubkey            NEW.
+ cpp: Context::startCreateSubkey       NEW.
  py: DecryptResult           EXTENDED: New boolean field 'is_de_vs'.
  py: Signature               EXTENDED: New boolean field 'is_de_vs'.
  py: GpgError                EXTENDED: Partial results in 'results'.
diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 77962d8..135e4d5 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -1404,6 +1404,38 @@ Error Context::setTofuPolicyStart(const Key &k, unsigned int policy)
                  k.impl(), to_tofu_policy_t(policy)));
 }
 
+Error Context::startCreateKey (const char *userid,
+                               const char *algo,
+                               unsigned long reserved,
+                               unsigned long expires,
+                               const Key &certkey,
+                               unsigned int flags)
+{
+    return Error(d->lasterr = gpgme_op_createkey_start(d->ctx,
+                 userid,
+                 algo,
+                 reserved,
+                 expires,
+                 certkey.impl(),
+                 flags));
+}
+
+Error Context::createKey (const char *userid,
+                          const char *algo,
+                          unsigned long reserved,
+                          unsigned long expires,
+                          const Key &certkey,
+                          unsigned int flags)
+{
+    return Error(d->lasterr = gpgme_op_createkey(d->ctx,
+                 userid,
+                 algo,
+                 reserved,
+                 expires,
+                 certkey.impl(),
+                 flags));
+}
+
 Error Context::addUid(const Key &k, const char *userid)
 {
     return Error(d->lasterr = gpgme_op_adduid(d->ctx,
@@ -1428,6 +1460,24 @@ Error Context::startRevUid(const Key &k, const char *userid)
                  k.impl(), userid, 0));
 }
 
+Error Context::createSubkey(const Key &k, const char *algo,
+                            unsigned long reserved,
+                            unsigned long expires,
+                            unsigned int flags)
+{
+    return Error(d->lasterr = gpgme_op_createsubkey(d->ctx,
+                 k.impl(), algo, reserved, expires, flags));
+}
+
+Error Context::startCreateSubkey(const Key &k, const char *algo,
+                                 unsigned long reserved,
+                                 unsigned long expires,
+                                 unsigned int flags)
+{
+    return Error(d->lasterr = gpgme_op_createsubkey_start(d->ctx,
+                 k.impl(), algo, reserved, expires, flags));
+}
+
 // 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 bec4e39..4cd5b30 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -214,12 +214,38 @@ 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);
 
+
+    //
+    // Modern Interface actions. Require 2.1.x
+    //
+    Error startCreateKey (const char *userid,
+                          const char *algo,
+                          unsigned long reserved,
+                          unsigned long expires,
+                          const Key &certkey,
+                          unsigned int flags);
+    Error createKey (const char *userid,
+                     const char *algo,
+                     unsigned long reserved,
+                     unsigned long expires,
+                     const Key &certkey,
+                     unsigned int flags);
+
     Error addUid(const Key &key, const char *userid);
     Error startAddUid(const Key &key, const char *userid);
 
     Error revUid(const Key &key, const char *userid);
     Error startRevUid(const Key &key, const char *userid);
 
+    Error createSubkey(const Key &key, const char *algo,
+                       unsigned long reserved = 0,
+                       unsigned long expires = 0,
+                       unsigned int flags = 0);
+    Error startCreateSubkey(const Key &key, const char *algo,
+                            unsigned long reserved = 0,
+                            unsigned long expires = 0,
+                            unsigned int flags = 0);
+
     // using TofuInfo::Policy
     Error setTofuPolicy(const Key &k, unsigned int policy);
     Error setTofuPolicyStart(const Key &k, unsigned int policy);

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

Summary of changes:
 NEWS                                               |   5 +
 lang/cpp/src/context.cpp                           |  50 +++++++++
 lang/cpp/src/context.h                             |  26 +++++
 lang/qt/src/Makefile.am                            |   9 +-
 lang/qt/src/job.cpp                                |   3 +
 lang/qt/src/protocol.h                             |   4 +
 lang/qt/src/protocol_p.h                           |  13 +++
 lang/qt/src/qgpgmequickjob.cpp                     | 123 +++++++++++++++++++++
 ...{defaultkeygenerationjob.h => qgpgmequickjob.h} |  66 +++++------
 .../src/{defaultkeygenerationjob.h => quickjob.h}  |  59 +++++-----
 10 files changed, 298 insertions(+), 60 deletions(-)
 create mode 100644 lang/qt/src/qgpgmequickjob.cpp
 copy lang/qt/src/{defaultkeygenerationjob.h => qgpgmequickjob.h} (55%)
 copy lang/qt/src/{defaultkeygenerationjob.h => quickjob.h} (56%)


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




More information about the Gnupg-commits mailing list