[git] GPGME - branch, master, updated. gpgme-1.7.1-40-g9451faa

by Andre Heinecke cvs at cvs.gnupg.org
Mon Nov 14 20:48:32 CET 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  9451faa2ee333904cff59f92ab62918e13ab4b87 (commit)
       via  d09a84eaf1e4f8c6c2e462995fa15c1a5690a6ce (commit)
      from  f3790ddf56558fb0a08af95fdbae979cd6589aad (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 9451faa2ee333904cff59f92ab62918e13ab4b87
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Nov 14 20:40:29 2016 +0100

    qt: Add API to get the context for a Job
    
    * lang/qt/src/job.cpp,
    lang/qt/src/job.h (Job::context): New.
    * lang/qt/src/threadedjobmixin.cpp
    (ThreadedJobMixin::~ThreadedJobMixin): New. Unregister context.
    (ThreadedJobMixin::lateInitialization): Register context.
    * NEWS: Update for cpp and qt.
    
    --
    The global map hack is necessary because the job class does
    not know about the context which is held in threadedjobmixin.
    Adding a virtual function in Job would be an ABI break which
    I'd like to avoid at this point. Although QGpgME's API will
    need a big ABI break to make it ABI maintainable. The virtual
    jobs -> implementation classes are nearly unmaintainable ABI wise.
    
    The context is exposed to provide more flexibility to users, e.g.
    to add a passphrase callback or to set the sender in a context.

diff --git a/NEWS b/NEWS
index 1cf401e..4bb0cfb 100644
--- a/NEWS
+++ b/NEWS
@@ -14,9 +14,12 @@ Noteworthy changes in version 1.7.2 (unreleased)
  gpgme_query_swdb_result_t       NEW.
  qt: DN                          NEW.
  qt: DN::Attribute               NEW.
+ qt: Job::context(Job*)          NEW.
  cpp: EngineInfo::Version::Version(const char*) NEW.
  cpp: EngineInfo::Version::Version()            NEW.
  cpp: SwdbResult                                NEW.
+ cpp: Context::setSender(const char*)           NEW.
+ cpp: Context::getSender()                      NEW.
 
 
 Noteworthy changes in version 1.7.1 (2016-10-18)
diff --git a/lang/qt/src/job.cpp b/lang/qt/src/job.cpp
index 38dbc99..9ae3f31 100644
--- a/lang/qt/src/job.cpp
+++ b/lang/qt/src/job.cpp
@@ -62,6 +62,7 @@
 #include "keyformailboxjob.h"
 #include "wkspublishjob.h"
 #include "tofupolicyjob.h"
+#include "threadedjobmixin.h"
 
 #include <QCoreApplication>
 #include <QDebug>
@@ -78,7 +79,6 @@ QGpgME::Job::Job(QObject *parent)
 
 QGpgME::Job::~Job()
 {
-
 }
 
 QString QGpgME::Job::auditLogAsHtml() const
@@ -98,6 +98,14 @@ bool QGpgME::Job::isAuditLogSupported() const
     return auditLogError().code() != GPG_ERR_NOT_IMPLEMENTED;
 }
 
+QMap <QGpgME::Job *, GpgME::Context *> QGpgME::g_context_map;
+
+/* static */
+GpgME::Context *QGpgME::Job::context(QGpgME::Job *job)
+{
+    return QGpgME::g_context_map.value (job, nullptr);
+}
+
 #define make_job_subclass_ext(x,y)                \
     QGpgME::x::x( QObject * parent ) : y( parent ) {} \
     QGpgME::x::~x() {}
diff --git a/lang/qt/src/job.h b/lang/qt/src/job.h
index 5767729..a0c0285 100644
--- a/lang/qt/src/job.h
+++ b/lang/qt/src/job.h
@@ -38,6 +38,7 @@
 
 #include <QObject>
 #include <QString>
+#include <QMap>
 
 #ifdef BUILDING_QGPGME
 # include "error.h"
@@ -79,6 +80,20 @@ public:
     virtual GpgME::Error auditLogError() const;
     bool isAuditLogSupported() const;
 
+    /** Get the underlying context to set some additional options for a job.
+     *
+     * This is intended to provide more flexibility on configuring jobs before
+     * they are started.
+     * The context is still owned by the thread, do not delete it.
+     *
+     * This is a static method that takes the job as argument.
+     *
+     * This function may not be called for running jobs.
+     *
+     * @returns the context used by the job job or null.
+     */
+    static GpgME::Context *context(Job *job);
+
 public Q_SLOTS:
     virtual void slotCancel() = 0;
 
@@ -87,6 +102,7 @@ Q_SIGNALS:
     void done();
 };
 
+extern QMap <Job *, GpgME::Context *> g_context_map;
 }
 
 #endif // __KLEO_JOB_H__
diff --git a/lang/qt/src/threadedjobmixin.h b/lang/qt/src/threadedjobmixin.h
index d1b1043..aef2723 100644
--- a/lang/qt/src/threadedjobmixin.h
+++ b/lang/qt/src/threadedjobmixin.h
@@ -48,6 +48,7 @@
 # include <gpgme++/interfaces/progressprovider.h>
 #endif
 
+#include "job.h"
 
 #include <cassert>
 
@@ -147,7 +148,6 @@ protected:
     explicit ThreadedJobMixin(GpgME::Context *ctx)
         : T_base(0), m_ctx(ctx), m_thread(), m_auditLog(), m_auditLogError()
     {
-
     }
 
     void lateInitialization()
@@ -155,6 +155,12 @@ protected:
         assert(m_ctx);
         QObject::connect(&m_thread, SIGNAL(finished()), this, SLOT(slotFinished()));
         m_ctx->setProgressProvider(this);
+        QGpgME::g_context_map.insert(this, m_ctx.get());
+    }
+
+    ~ThreadedJobMixin()
+    {
+        QGpgME::g_context_map.remove(this);
     }
 
     template <typename T_binder>
diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp
index 2c87e4a..f89e1c2 100644
--- a/lang/qt/tests/t-tofuinfo.cpp
+++ b/lang/qt/tests/t-tofuinfo.cpp
@@ -152,6 +152,10 @@ private Q_SLOTS:
         const QByteArray data1(testMsg1);
         QByteArray plaintext;
 
+        auto ctx = Job::context(job);
+        Q_ASSERT(ctx);
+        ctx->setSender("alfa at example.net");
+
         auto result = job->exec(data1, plaintext);
         delete job;
 

commit d09a84eaf1e4f8c6c2e462995fa15c1a5690a6ce
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Nov 14 16:13:27 2016 +0100

    cpp: Add get / set Sender API
    
    * cpp/src/context.cpp, cpp/src/context.h (Context::setSender),
    (Context::getSender): Add simple wrappers.

diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp
index 1121104..ada7bea 100644
--- a/lang/cpp/src/context.cpp
+++ b/lang/cpp/src/context.cpp
@@ -466,6 +466,16 @@ Error Context::setEngineHomeDirectory(const char *home_dir)
     return Error(gpgme_ctx_set_engine_info(d->ctx, gpgme_get_protocol(d->ctx), filename, home_dir));
 }
 
+Error Context::setSender (const char *sender)
+{
+    return Error(gpgme_set_sender(d->ctx, sender));
+}
+
+const char *Context::getSender ()
+{
+    return gpgme_get_sender(d->ctx);
+}
+
 //
 //
 // Key Management
diff --git a/lang/cpp/src/context.h b/lang/cpp/src/context.h
index ab15a21..2c205b0 100644
--- a/lang/cpp/src/context.h
+++ b/lang/cpp/src/context.h
@@ -304,6 +304,10 @@ public:
     GpgME::Error startSigning(const Data &plainText, Data &signature, SignatureMode mode);
     SigningResult signingResult() const;
 
+    // wrapper for gpgme_set_sender
+    const char *getSender();
+    GpgME::Error setSender(const char *sender);
+
     //
     // Encryption
     //

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

Summary of changes:
 NEWS                           |  3 +++
 lang/cpp/src/context.cpp       | 10 ++++++++++
 lang/cpp/src/context.h         |  4 ++++
 lang/qt/src/job.cpp            | 10 +++++++++-
 lang/qt/src/job.h              | 16 ++++++++++++++++
 lang/qt/src/threadedjobmixin.h |  8 +++++++-
 lang/qt/tests/t-tofuinfo.cpp   |  4 ++++
 7 files changed, 53 insertions(+), 2 deletions(-)


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




More information about the Gnupg-commits mailing list