qt: Add job for quick commands
* lang/qt/src/qgpgmequickjob.cpp, lang/qt/src/qgpgmequickjob.h, lang/qt/src/quickjob.h: New. * lang/qt/src/Makefile.am, lang/qt/src/protocol.h, lang/qt/src/protocol_p.h, lang/qt/src/job.cpp: Update accordingly. -- Keeping it in line with the Job for everything pattern. Although it's reduced to one job for four commands as the commands all behave the same.
This commit is contained in:
parent
8e2d6c28a5
commit
7d1ac5d61d
1
NEWS
1
NEWS
@ -19,6 +19,7 @@ Noteworthy changes in version 1.10.0 (unreleased)
|
|||||||
cpp: Context::startCreateKey NEW.
|
cpp: Context::startCreateKey NEW.
|
||||||
cpp: Context::createSubkey NEW.
|
cpp: Context::createSubkey NEW.
|
||||||
cpp: Context::startCreateSubkey NEW.
|
cpp: Context::startCreateSubkey NEW.
|
||||||
|
qt: QuickJob NEW.
|
||||||
py: DecryptResult EXTENDED: New boolean field 'is_de_vs'.
|
py: DecryptResult EXTENDED: New boolean field 'is_de_vs'.
|
||||||
py: Signature EXTENDED: New boolean field 'is_de_vs'.
|
py: Signature EXTENDED: New boolean field 'is_de_vs'.
|
||||||
py: GpgError EXTENDED: Partial results in 'results'.
|
py: GpgError EXTENDED: Partial results in 'results'.
|
||||||
|
@ -36,7 +36,7 @@ qgpgme_sources = \
|
|||||||
qgpgmesignjob.cpp qgpgmesignkeyjob.cpp qgpgmeverifydetachedjob.cpp \
|
qgpgmesignjob.cpp qgpgmesignkeyjob.cpp qgpgmeverifydetachedjob.cpp \
|
||||||
qgpgmeverifyopaquejob.cpp threadedjobmixin.cpp \
|
qgpgmeverifyopaquejob.cpp threadedjobmixin.cpp \
|
||||||
qgpgmekeyformailboxjob.cpp gpgme_backend_debug.cpp \
|
qgpgmekeyformailboxjob.cpp gpgme_backend_debug.cpp \
|
||||||
qgpgmetofupolicyjob.cpp \
|
qgpgmetofupolicyjob.cpp qgpgmequickjob.cpp \
|
||||||
defaultkeygenerationjob.cpp qgpgmewkspublishjob.cpp \
|
defaultkeygenerationjob.cpp qgpgmewkspublishjob.cpp \
|
||||||
dn.cpp cryptoconfig.cpp
|
dn.cpp cryptoconfig.cpp
|
||||||
|
|
||||||
@ -60,6 +60,7 @@ qgpgme_headers= \
|
|||||||
protocol.h \
|
protocol.h \
|
||||||
qgpgme_export.h \
|
qgpgme_export.h \
|
||||||
qgpgmenewcryptoconfig.h \
|
qgpgmenewcryptoconfig.h \
|
||||||
|
quickjob.h \
|
||||||
specialjob.h \
|
specialjob.h \
|
||||||
signjob.h \
|
signjob.h \
|
||||||
signkeyjob.h \
|
signkeyjob.h \
|
||||||
@ -97,6 +98,7 @@ camelcase_headers= \
|
|||||||
MultiDeleteJob \
|
MultiDeleteJob \
|
||||||
Protocol \
|
Protocol \
|
||||||
QGpgMENewCryptoConfig \
|
QGpgMENewCryptoConfig \
|
||||||
|
QuickJob \
|
||||||
SpecialJob \
|
SpecialJob \
|
||||||
SignJob \
|
SignJob \
|
||||||
SignKeyJob \
|
SignKeyJob \
|
||||||
@ -145,6 +147,7 @@ private_qgpgme_headers = \
|
|||||||
qgpgmekeyformailboxjob.h \
|
qgpgmekeyformailboxjob.h \
|
||||||
qgpgmewkspublishjob.h \
|
qgpgmewkspublishjob.h \
|
||||||
qgpgmetofupolicyjob.h \
|
qgpgmetofupolicyjob.h \
|
||||||
|
qgpgmequickjob.h \
|
||||||
threadedjobmixin.h
|
threadedjobmixin.h
|
||||||
|
|
||||||
qgpgme_moc_sources = \
|
qgpgme_moc_sources = \
|
||||||
@ -202,7 +205,9 @@ qgpgme_moc_sources = \
|
|||||||
keyformailboxjob.moc \
|
keyformailboxjob.moc \
|
||||||
wkspublishjob.moc \
|
wkspublishjob.moc \
|
||||||
qgpgmekeyformailboxjob.moc \
|
qgpgmekeyformailboxjob.moc \
|
||||||
defaultkeygenerationjob.moc
|
defaultkeygenerationjob.moc \
|
||||||
|
quickjob.moc \
|
||||||
|
qgpgmequickjob.moc
|
||||||
|
|
||||||
qgpgmeincludedir = $(includedir)/qgpgme
|
qgpgmeincludedir = $(includedir)/qgpgme
|
||||||
qgpgmeinclude_HEADERS = $(qgpgme_headers)
|
qgpgmeinclude_HEADERS = $(qgpgme_headers)
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
#include "wkspublishjob.h"
|
#include "wkspublishjob.h"
|
||||||
#include "tofupolicyjob.h"
|
#include "tofupolicyjob.h"
|
||||||
#include "threadedjobmixin.h"
|
#include "threadedjobmixin.h"
|
||||||
|
#include "quickjob.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -139,6 +140,7 @@ make_job_subclass(SpecialJob)
|
|||||||
make_job_subclass(KeyForMailboxJob)
|
make_job_subclass(KeyForMailboxJob)
|
||||||
make_job_subclass(WKSPublishJob)
|
make_job_subclass(WKSPublishJob)
|
||||||
make_job_subclass(TofuPolicyJob)
|
make_job_subclass(TofuPolicyJob)
|
||||||
|
make_job_subclass(QuickJob)
|
||||||
|
|
||||||
#undef make_job_subclass
|
#undef make_job_subclass
|
||||||
|
|
||||||
@ -170,3 +172,4 @@ make_job_subclass(TofuPolicyJob)
|
|||||||
#include "keyformailboxjob.moc"
|
#include "keyformailboxjob.moc"
|
||||||
#include "wkspublishjob.moc"
|
#include "wkspublishjob.moc"
|
||||||
#include "tofupolicyjob.moc"
|
#include "tofupolicyjob.moc"
|
||||||
|
#include "quickjob.moc"
|
||||||
|
@ -66,6 +66,7 @@ class SpecialJob;
|
|||||||
class KeyForMailboxJob;
|
class KeyForMailboxJob;
|
||||||
class WKSPublishJob;
|
class WKSPublishJob;
|
||||||
class TofuPolicyJob;
|
class TofuPolicyJob;
|
||||||
|
class QuickJob;
|
||||||
|
|
||||||
/** The main entry point for QGpgME Comes in OpenPGP and SMIME(CMS) flavors.
|
/** The main entry point for QGpgME Comes in OpenPGP and SMIME(CMS) flavors.
|
||||||
*
|
*
|
||||||
@ -157,6 +158,9 @@ public:
|
|||||||
|
|
||||||
/** A Job to set tofu policy */
|
/** A Job to set tofu policy */
|
||||||
virtual TofuPolicyJob *tofuPolicyJob() const = 0;
|
virtual TofuPolicyJob *tofuPolicyJob() const = 0;
|
||||||
|
|
||||||
|
/** A Job for the quick commands */
|
||||||
|
virtual QuickJob *quickJob() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Obtain a reference to the OpenPGP Protocol.
|
/** Obtain a reference to the OpenPGP Protocol.
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#include "qgpgmekeyformailboxjob.h"
|
#include "qgpgmekeyformailboxjob.h"
|
||||||
#include "qgpgmewkspublishjob.h"
|
#include "qgpgmewkspublishjob.h"
|
||||||
#include "qgpgmetofupolicyjob.h"
|
#include "qgpgmetofupolicyjob.h"
|
||||||
|
#include "qgpgmequickjob.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -414,6 +415,18 @@ public:
|
|||||||
}
|
}
|
||||||
return new QGpgME::QGpgMETofuPolicyJob(context);
|
return new QGpgME::QGpgMETofuPolicyJob(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QGpgME::QuickJob *quickJob() const Q_DECL_OVERRIDE
|
||||||
|
{
|
||||||
|
if (mProtocol != GpgME::OpenPGP) {
|
||||||
|
return Q_NULLPTR;
|
||||||
|
}
|
||||||
|
GpgME::Context *context = GpgME::Context::createForProtocol(mProtocol);
|
||||||
|
if (!context) {
|
||||||
|
return Q_NULLPTR;
|
||||||
|
}
|
||||||
|
return new QGpgME::QGpgMEQuickJob(context);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
123
lang/qt/src/qgpgmequickjob.cpp
Normal file
123
lang/qt/src/qgpgmequickjob.cpp
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
/* qgpgmequickjob.cpp
|
||||||
|
|
||||||
|
Copyright (c) 2017 Intevation GmbH
|
||||||
|
|
||||||
|
QGpgME is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
QGpgME is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
In addition, as a special exception, the copyright holders give
|
||||||
|
permission to link the code of this program with any edition of
|
||||||
|
the Qt library by Trolltech AS, Norway (or with modified versions
|
||||||
|
of Qt that use the same license as Qt), and distribute linked
|
||||||
|
combinations including the two. You must obey the GNU General
|
||||||
|
Public License in all respects for all of the code used other than
|
||||||
|
Qt. If you modify this file, you may extend this exception to
|
||||||
|
your version of the file, but you are not obligated to do so. If
|
||||||
|
you do not wish to do so, delete this exception statement from
|
||||||
|
your version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "qgpgmequickjob.h"
|
||||||
|
|
||||||
|
#include "context.h"
|
||||||
|
#include "key.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
using namespace QGpgME;
|
||||||
|
using namespace GpgME;
|
||||||
|
|
||||||
|
QGpgMEQuickJob::QGpgMEQuickJob(Context *context)
|
||||||
|
: mixin_type(context)
|
||||||
|
{
|
||||||
|
lateInitialization();
|
||||||
|
}
|
||||||
|
|
||||||
|
QGpgMEQuickJob::~QGpgMEQuickJob() {}
|
||||||
|
|
||||||
|
static QGpgMEQuickJob::result_type createWorker(GpgME::Context *ctx,
|
||||||
|
const QString &uid,
|
||||||
|
const char *algo,
|
||||||
|
const QDateTime &expires,
|
||||||
|
const GpgME::Key &key,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
auto err = ctx->createKey(uid.toUtf8().constData(),
|
||||||
|
algo,
|
||||||
|
0,
|
||||||
|
expires.isValid() ? (unsigned long) expires.toSecsSinceEpoch() : 0,
|
||||||
|
key,
|
||||||
|
flags);
|
||||||
|
return std::make_tuple(err, QString(), Error());
|
||||||
|
}
|
||||||
|
|
||||||
|
static QGpgMEQuickJob::result_type addSubkeyWorker(GpgME::Context *ctx,
|
||||||
|
const GpgME::Key &key,
|
||||||
|
const char *algo,
|
||||||
|
const QDateTime &expires,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
auto err = ctx->createSubkey(key, algo, 0,
|
||||||
|
expires.isValid() ? (unsigned long) expires.toSecsSinceEpoch() : 0,
|
||||||
|
flags);
|
||||||
|
return std::make_tuple(err, QString(), Error());
|
||||||
|
}
|
||||||
|
|
||||||
|
static QGpgMEQuickJob::result_type addUidWorker(GpgME::Context *ctx,
|
||||||
|
const GpgME::Key &key,
|
||||||
|
const QString &uid)
|
||||||
|
{
|
||||||
|
auto err = ctx->addUid(key, uid.toUtf8().constData());
|
||||||
|
return std::make_tuple(err, QString(), Error());
|
||||||
|
}
|
||||||
|
|
||||||
|
static QGpgMEQuickJob::result_type revUidWorker(GpgME::Context *ctx,
|
||||||
|
const GpgME::Key &key,
|
||||||
|
const QString &uid)
|
||||||
|
{
|
||||||
|
auto err = ctx->revUid(key, uid.toUtf8().constData());
|
||||||
|
return std::make_tuple(err, QString(), Error());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QGpgMEQuickJob::startCreate(const QString &uid,
|
||||||
|
const char *algo,
|
||||||
|
const QDateTime &expires,
|
||||||
|
const GpgME::Key &key,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
run(std::bind(&createWorker, std::placeholders::_1, uid, algo,
|
||||||
|
expires, key, flags));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QGpgMEQuickJob::startAddUid(const GpgME::Key &key, const QString &uid)
|
||||||
|
{
|
||||||
|
run(std::bind(&addUidWorker, std::placeholders::_1, key, uid));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QGpgMEQuickJob::startRevUid(const GpgME::Key &key, const QString &uid)
|
||||||
|
{
|
||||||
|
run(std::bind(&revUidWorker, std::placeholders::_1, key, uid));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QGpgMEQuickJob::startAddSubkey(const GpgME::Key &key, const char *algo,
|
||||||
|
const QDateTime &expires,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
run(std::bind(&addSubkeyWorker, std::placeholders::_1, key, algo,
|
||||||
|
expires, flags));
|
||||||
|
}
|
||||||
|
#include "qgpgmequickjob.moc"
|
82
lang/qt/src/qgpgmequickjob.h
Normal file
82
lang/qt/src/qgpgmequickjob.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/* qgpgmequickjob.h
|
||||||
|
|
||||||
|
Copyright (c) 2017 Intevation GmbH
|
||||||
|
|
||||||
|
QGpgME is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
QGpgME is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
In addition, as a special exception, the copyright holders give
|
||||||
|
permission to link the code of this program with any edition of
|
||||||
|
the Qt library by Trolltech AS, Norway (or with modified versions
|
||||||
|
of Qt that use the same license as Qt), and distribute linked
|
||||||
|
combinations including the two. You must obey the GNU General
|
||||||
|
Public License in all respects for all of the code used other than
|
||||||
|
Qt. If you modify this file, you may extend this exception to
|
||||||
|
your version of the file, but you are not obligated to do so. If
|
||||||
|
you do not wish to do so, delete this exception statement from
|
||||||
|
your version.
|
||||||
|
*/
|
||||||
|
#ifndef QGPGME_QGPGMEQUICKJOB_H
|
||||||
|
#define QGPGME_QGPGMEQUICKJOB_H
|
||||||
|
|
||||||
|
#include "quickjob.h"
|
||||||
|
|
||||||
|
#include "threadedjobmixin.h"
|
||||||
|
|
||||||
|
namespace GpgME {
|
||||||
|
class Key;
|
||||||
|
}
|
||||||
|
|
||||||
|
class QDateTime;
|
||||||
|
class QString;
|
||||||
|
|
||||||
|
namespace QGpgME{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to the modern key manipulation functions.
|
||||||
|
*/
|
||||||
|
class QGpgMEQuickJob
|
||||||
|
#ifdef Q_MOC_RUN
|
||||||
|
: public QuickJob
|
||||||
|
#else
|
||||||
|
: public _detail::ThreadedJobMixin<QuickJob, std::tuple<GpgME::Error, QString, GpgME::Error> >
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
#ifdef Q_MOC_RUN
|
||||||
|
public Q_SLOTS:
|
||||||
|
void slotFinished();
|
||||||
|
#endif
|
||||||
|
public:
|
||||||
|
explicit QGpgMEQuickJob(GpgME::Context *context);
|
||||||
|
~QGpgMEQuickJob();
|
||||||
|
|
||||||
|
void startCreate(const QString &uid,
|
||||||
|
const char *algo,
|
||||||
|
const QDateTime &expires = QDateTime(),
|
||||||
|
const GpgME::Key &key = GpgME::Key(),
|
||||||
|
unsigned int flags = 0) Q_DECL_OVERRIDE;
|
||||||
|
void startAddUid(const GpgME::Key &key, const QString &uid) Q_DECL_OVERRIDE;
|
||||||
|
void startRevUid(const GpgME::Key &key, const QString &uid) Q_DECL_OVERRIDE;
|
||||||
|
void startAddSubkey(const GpgME::Key &key, const char *algo,
|
||||||
|
const QDateTime &expires = QDateTime(),
|
||||||
|
unsigned int flags = 0) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void result(const GpgME::Error &error,
|
||||||
|
const QString &auditLogAsHtml, const GpgME::Error &auditLogError);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
83
lang/qt/src/quickjob.h
Normal file
83
lang/qt/src/quickjob.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/* quickjob.h
|
||||||
|
|
||||||
|
Copyright (c) 2017 Intevation GmbH
|
||||||
|
|
||||||
|
QGpgME is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
QGpgME is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
In addition, as a special exception, the copyright holders give
|
||||||
|
permission to link the code of this program with any edition of
|
||||||
|
the Qt library by Trolltech AS, Norway (or with modified versions
|
||||||
|
of Qt that use the same license as Qt), and distribute linked
|
||||||
|
combinations including the two. You must obey the GNU General
|
||||||
|
Public License in all respects for all of the code used other than
|
||||||
|
Qt. If you modify this file, you may extend this exception to
|
||||||
|
your version of the file, but you are not obligated to do so. If
|
||||||
|
you do not wish to do so, delete this exception statement from
|
||||||
|
your version.
|
||||||
|
*/
|
||||||
|
#ifndef QGPGME_QUICKJOB_H
|
||||||
|
#define QGPGME_QUICKJOB_H
|
||||||
|
|
||||||
|
#include "job.h"
|
||||||
|
|
||||||
|
#include "qgpgme_export.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
#ifdef BUILDING_QGPGME
|
||||||
|
# include "key.h"
|
||||||
|
#else
|
||||||
|
# include <gpgme++/key.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class QString;
|
||||||
|
|
||||||
|
namespace QGpgME{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to the modern key manipulation functions.
|
||||||
|
*/
|
||||||
|
class QGPGME_EXPORT QuickJob : public Job
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit QuickJob(QObject *parent = Q_NULLPTR);
|
||||||
|
~QuickJob();
|
||||||
|
|
||||||
|
/** Start --quick-gen-key */
|
||||||
|
virtual void startCreate(const QString &uid,
|
||||||
|
const char *algo,
|
||||||
|
const QDateTime &expires = QDateTime(),
|
||||||
|
const GpgME::Key &key = GpgME::Key(),
|
||||||
|
unsigned int flags = 0) = 0;
|
||||||
|
|
||||||
|
/** Start --quick-adduid */
|
||||||
|
virtual void startAddUid(const GpgME::Key &key, const QString &uid) = 0;
|
||||||
|
|
||||||
|
/** Start --quick-revuid */
|
||||||
|
virtual void startRevUid(const GpgME::Key &key, const QString &uid) = 0;
|
||||||
|
|
||||||
|
/** Start --quick-add-key */
|
||||||
|
virtual void startAddSubkey(const GpgME::Key &key, const char *algo,
|
||||||
|
const QDateTime &expires = QDateTime(),
|
||||||
|
unsigned int flags = 0) = 0;
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void result(const GpgME::Error &error,
|
||||||
|
const QString &auditLogAsHtml, const GpgME::Error &auditLogError);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user