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

View File

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