qt: Pimpl QGpgMESignKeyJob

* lang/qt/src/qgpgmesignkeyjob.h: Remove unneeded includes. Include
<memory>.
(QGpgMESignKeyJob): Remove all member variables. Add pimpl pointer.
* lang/qt/src/qgpgmesignkeyjob.cpp: Include <QString>. Don't include
<memory>.
(QGpgMESignKeyJob::Private): New.
(QGpgMESignKeyJob::QGpgMESignKeyJob): Remove initialization of removed
members. Initialize d.
(QGpgMESignKeyJob::start, QGpgMESignKeyJob::setUserIDsToSign,
QGpgMESignKeyJob::setCheckLevel, QGpgMESignKeyJob::setExportable,
QGpgMESignKeyJob::setSigningKey, QGpgMESignKeyJob::setNonRevocable,
QGpgMESignKeyJob::setRemark, QGpgMESignKeyJob::setDupeOk): Adapt to move
of member variables to pimpl.
--

GnuPG-bug-id: 5245, 5421
This commit is contained in:
Ingo Klöcker 2021-05-05 18:32:03 +02:00
parent a8d7b9d167
commit dae01f8185
2 changed files with 41 additions and 43 deletions

View File

@ -38,6 +38,8 @@
#include "qgpgmesignkeyjob.h" #include "qgpgmesignkeyjob.h"
#include <QString>
#include "dataprovider.h" #include "dataprovider.h"
#include "context.h" #include "context.h"
@ -45,20 +47,28 @@
#include "gpgsignkeyeditinteractor.h" #include "gpgsignkeyeditinteractor.h"
#include <cassert> #include <cassert>
#include <memory>
using namespace QGpgME; using namespace QGpgME;
using namespace GpgME; using namespace GpgME;
class QGpgMESignKeyJob::Private
{
public:
Private() = default;
std::vector<unsigned int> m_userIDsToSign;
GpgME::Key m_signingKey;
unsigned int m_checkLevel = 0;
bool m_exportable = false;
bool m_nonRevocable = false;
bool m_started = false;
bool m_dupeOk = false;
QString m_remark;
};
QGpgMESignKeyJob::QGpgMESignKeyJob(Context *context) QGpgMESignKeyJob::QGpgMESignKeyJob(Context *context)
: mixin_type(context), : mixin_type(context)
m_userIDsToSign(), , d{std::unique_ptr<Private>(new Private())}
m_signingKey(),
m_checkLevel(0),
m_exportable(false),
m_nonRevocable(false),
m_started(false),
m_dupeOk(false)
{ {
lateInitialization(); lateInitialization();
} }
@ -100,57 +110,57 @@ static QGpgMESignKeyJob::result_type sign_key(Context *ctx, const Key &key, cons
Error QGpgMESignKeyJob::start(const Key &key) Error QGpgMESignKeyJob::start(const Key &key)
{ {
unsigned int opts = 0; unsigned int opts = 0;
if (m_nonRevocable) { if (d->m_nonRevocable) {
opts |= GpgSignKeyEditInteractor::NonRevocable; opts |= GpgSignKeyEditInteractor::NonRevocable;
} }
if (m_exportable) { if (d->m_exportable) {
opts |= GpgSignKeyEditInteractor::Exportable; opts |= GpgSignKeyEditInteractor::Exportable;
} }
run(std::bind(&sign_key, std::placeholders::_1, key, m_userIDsToSign, m_checkLevel, m_signingKey, opts, run(std::bind(&sign_key, std::placeholders::_1, key, d->m_userIDsToSign, d->m_checkLevel, d->m_signingKey,
m_dupeOk, m_remark)); opts, d->m_dupeOk, d->m_remark));
m_started = true; d->m_started = true;
return Error(); return Error();
} }
void QGpgMESignKeyJob::setUserIDsToSign(const std::vector<unsigned int> &idsToSign) void QGpgMESignKeyJob::setUserIDsToSign(const std::vector<unsigned int> &idsToSign)
{ {
assert(!m_started); assert(!d->m_started);
m_userIDsToSign = idsToSign; d->m_userIDsToSign = idsToSign;
} }
void QGpgMESignKeyJob::setCheckLevel(unsigned int checkLevel) void QGpgMESignKeyJob::setCheckLevel(unsigned int checkLevel)
{ {
assert(!m_started); assert(!d->m_started);
m_checkLevel = checkLevel; d->m_checkLevel = checkLevel;
} }
void QGpgMESignKeyJob::setExportable(bool exportable) void QGpgMESignKeyJob::setExportable(bool exportable)
{ {
assert(!m_started); assert(!d->m_started);
m_exportable = exportable; d->m_exportable = exportable;
} }
void QGpgMESignKeyJob::setSigningKey(const Key &key) void QGpgMESignKeyJob::setSigningKey(const Key &key)
{ {
assert(!m_started); assert(!d->m_started);
m_signingKey = key; d->m_signingKey = key;
} }
void QGpgMESignKeyJob::setNonRevocable(bool nonRevocable) void QGpgMESignKeyJob::setNonRevocable(bool nonRevocable)
{ {
assert(!m_started); assert(!d->m_started);
m_nonRevocable = nonRevocable; d->m_nonRevocable = nonRevocable;
} }
void QGpgMESignKeyJob::setRemark(const QString &remark) void QGpgMESignKeyJob::setRemark(const QString &remark)
{ {
assert(!m_started); assert(!d->m_started);
m_remark = remark; d->m_remark = remark;
} }
void QGpgMESignKeyJob::setDupeOk(bool value) void QGpgMESignKeyJob::setDupeOk(bool value)
{ {
assert(!m_started); assert(!d->m_started);
m_dupeOk = value; d->m_dupeOk = value;
} }
#include "qgpgmesignkeyjob.moc" #include "qgpgmesignkeyjob.moc"

View File

@ -39,13 +39,7 @@
#include "threadedjobmixin.h" #include "threadedjobmixin.h"
#include <QString> #include <memory>
#ifdef BUILDING_QGPGME
# include "key.h"
#else
#include <gpgme++/key.h>
#endif
namespace QGpgME namespace QGpgME
{ {
@ -91,14 +85,8 @@ public:
void setDupeOk(bool value) Q_DECL_OVERRIDE; void setDupeOk(bool value) Q_DECL_OVERRIDE;
private: private:
std::vector<unsigned int> m_userIDsToSign; class Private;
GpgME::Key m_signingKey; std::unique_ptr<Private> d;
unsigned int m_checkLevel;
bool m_exportable;
bool m_nonRevocable;
bool m_started;
bool m_dupeOk;
QString m_remark;
}; };
} }