diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | lang/qt/src/job.cpp | 10 | ||||
-rw-r--r-- | lang/qt/src/job.h | 16 | ||||
-rw-r--r-- | lang/qt/src/threadedjobmixin.h | 8 | ||||
-rw-r--r-- | lang/qt/tests/t-tofuinfo.cpp | 4 |
5 files changed, 39 insertions, 2 deletions
@@ -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 38dbc995..9ae3f314 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 57677296..a0c02858 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 d1b10432..aef2723a 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 2c87e4a9..f89e1c27 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("[email protected]"); + auto result = job->exec(data1, plaintext); delete job; |