diff options
Diffstat (limited to 'lang/qt/src')
-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 |
3 files changed, 32 insertions, 2 deletions
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> |