From 9451faa2ee333904cff59f92ab62918e13ab4b87 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Mon, 14 Nov 2016 20:40:29 +0100 Subject: 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. --- lang/qt/src/job.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lang/qt/src/job.cpp') 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 #include @@ -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::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() {} -- cgit v1.2.3