aboutsummaryrefslogtreecommitdiffstats
path: root/lang/qt/src/qgpgmequickjob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lang/qt/src/qgpgmequickjob.cpp')
-rw-r--r--lang/qt/src/qgpgmequickjob.cpp62
1 files changed, 58 insertions, 4 deletions
diff --git a/lang/qt/src/qgpgmequickjob.cpp b/lang/qt/src/qgpgmequickjob.cpp
index 8da1f9a0..d65afd7d 100644
--- a/lang/qt/src/qgpgmequickjob.cpp
+++ b/lang/qt/src/qgpgmequickjob.cpp
@@ -37,23 +37,58 @@
#include "qgpgmequickjob.h"
+#include "qgpgme_debug.h"
+#include "quickjob_p.h"
+#include "util.h"
+
#include <gpgme++/context.h>
#include <gpgme++/key.h>
-#include "util.h"
using namespace QGpgME;
using namespace GpgME;
+namespace
+{
+
+class QGpgMEQuickJobPrivate : public QuickJobPrivate
+{
+ QGpgMEQuickJob *q = nullptr;
+
+public:
+ QGpgMEQuickJobPrivate(QGpgMEQuickJob *qq)
+ : q{qq}
+ {
+ }
+
+ ~QGpgMEQuickJobPrivate() override = default;
+
+private:
+ GpgME::Error startIt() override
+ {
+ Q_ASSERT(!"Not supported by this Job class.");
+ return Error::fromCode(GPG_ERR_NOT_SUPPORTED);
+ }
+
+ void startNow() override
+ {
+ Q_ASSERT(!"Not supported by this Job class.");
+ q->run();
+ }
+
+ GpgME::Error startSetKeyEnabled(const GpgME::Key &key, bool enable) override;
+};
+
+}
+
QGpgMEQuickJob::QGpgMEQuickJob(Context *context)
: mixin_type(context)
{
+ setJobPrivate(this, std::unique_ptr<QGpgMEQuickJobPrivate>{new QGpgMEQuickJobPrivate{this}});
lateInitialization();
}
-QGpgMEQuickJob::~QGpgMEQuickJob()
-{
-}
+QGpgMEQuickJob::~QGpgMEQuickJob() = default;
static QGpgMEQuickJob::result_type createWorker(GpgME::Context *ctx,
const QString &uid,
@@ -154,4 +189,23 @@ void QGpgMEQuickJob::startAddAdsk(const GpgME::Key &key, const char *adsk)
run(std::bind(&addAdskWorker, std::placeholders::_1, key, adsk));
}
+static QGpgMEQuickJob::result_type set_key_enabled(Context *ctx, const Key &key, bool enabled)
+{
+ const auto err = ctx->setKeyEnabled(key, enabled);
+ return std::make_tuple(err, QString(), Error());
+}
+
+Error QGpgMEQuickJobPrivate::startSetKeyEnabled(const Key &key, bool enabled)
+{
+ if (key.isNull()) {
+ return Error::fromCode(GPG_ERR_INV_VALUE);
+ }
+
+ q->run([=](Context *ctx) {
+ return set_key_enabled(ctx, key, enabled);
+ });
+
+ return {};
+}
+
#include "qgpgmequickjob.moc"