Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F33432243
D618.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
10 KB
Subscribers
None
D618.diff
View Options
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -42,6 +42,7 @@
decryptverifyarchivejob.cpp
decryptverifyjob.cpp
defaultkeygenerationjob.cpp
+ deletejob.cpp
dn.cpp
encryptarchivejob.cpp
encryptjob.cpp
@@ -110,6 +111,7 @@
cleaner.h
decryptverifyarchivejob_p.h
decryptverifyjob_p.h
+ deletejob_p.h
encryptarchivejob_p.h
encryptjob_p.h
importjob_p.h
diff --git a/src/deletejob.h b/src/deletejob.h
--- a/src/deletejob.h
+++ b/src/deletejob.h
@@ -37,6 +37,7 @@
#include "qgpgme_export.h"
#include "job.h"
+#include <gpgme++/global.h>
namespace GpgME
{
@@ -46,6 +47,7 @@
namespace QGpgME
{
+class DeleteJobPrivate;
/**
@short An abstract base class for asynchronous deleters
@@ -65,6 +67,7 @@
Q_OBJECT
protected:
explicit DeleteJob(QObject *parent);
+ DeleteJob(std::unique_ptr<DeleteJobPrivate>, QObject *parent);
public:
~DeleteJob();
@@ -74,9 +77,13 @@
be deleted if the secret key part is available, too.
*/
virtual GpgME::Error start(const GpgME::Key &key, bool allowSecretKeyDeletion = false) = 0;
+ GpgME::Error start(const GpgME::Key &key, GpgME::DeletionFlags flags);
Q_SIGNALS:
void result(const GpgME::Error &result, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error());
+
+private:
+ Q_DECLARE_PRIVATE(DeleteJob);
};
}
diff --git a/src/deletejob.cpp b/src/deletejob.cpp
new file mode 100644
--- /dev/null
+++ b/src/deletejob.cpp
@@ -0,0 +1,50 @@
+/*
+ deletejob.cpp
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2025 g10 Code 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.
+*/
+
+#include "deletejob.h"
+#include "deletejob_p.h"
+
+#include <gpgme++/key.h>
+
+using namespace QGpgME;
+using namespace GpgME;
+
+DeleteJob::DeleteJob(std::unique_ptr<DeleteJobPrivate> dd, QObject *parent)
+ : Job{std::move(dd), parent}
+{
+}
+
+GpgME::Error DeleteJob::start(const Key &key, GpgME::DeletionFlags flags)
+{
+ Q_D(DeleteJob);
+ return d->start(key, flags);
+}
diff --git a/src/deletejob_p.h b/src/deletejob_p.h
new file mode 100644
--- /dev/null
+++ b/src/deletejob_p.h
@@ -0,0 +1,52 @@
+/*
+ deletejob_p.h
+
+ This file is part of qgpgme, the Qt API binding for gpgme
+ Copyright (c) 2025 g10 Code 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_DELETEJOB_P_H__
+#define __QGPGME_DELETEJOB_P_H__
+
+#include "job_p.h"
+
+#include <gpgme++/key.h>
+#include "deletejob.h"
+
+namespace QGpgME
+{
+
+class DeleteJobPrivate : public JobPrivate
+{
+public:
+ virtual GpgME::Error start(const GpgME::Key &key, GpgME::DeletionFlags flags) = 0;
+};
+
+}
+
+#endif // __QGPGME_DELETEJOB_P_H__
diff --git a/src/multideletejob.h b/src/multideletejob.h
--- a/src/multideletejob.h
+++ b/src/multideletejob.h
@@ -52,8 +52,10 @@
namespace QGpgME
{
class DeleteJob;
+class MultiDeleteJobPrivate;
}
+
namespace QGpgME
{
@@ -82,6 +84,7 @@
be deleted if the secret key part is available, too.
*/
GpgME::Error start(const std::vector<GpgME::Key> &keys, bool allowSecretKeyDeletion = false);
+ GpgME::Error start(const std::vector<GpgME::Key> &keys, GpgME::DeletionFlags flags);
/* from Job */
void slotCancel() override;
@@ -101,6 +104,7 @@
std::vector<GpgME::Key> mKeys;
std::vector<GpgME::Key>::const_iterator mIt;
bool mAllowSecretKeyDeletion;
+ Q_DECLARE_PRIVATE(MultiDeleteJob)
};
}
diff --git a/src/multideletejob.cpp b/src/multideletejob.cpp
--- a/src/multideletejob.cpp
+++ b/src/multideletejob.cpp
@@ -37,6 +37,7 @@
#include "multideletejob.h"
#include "protocol.h"
#include "deletejob.h"
+#include "job_p.h"
#include <gpgme++/key.h>
#include <gpgme++/context.h>
@@ -46,8 +47,18 @@
#include <assert.h>
+class QGpgME::MultiDeleteJobPrivate : public QGpgME::JobPrivate
+{
+public:
+ GpgME::DeletionFlags flags;
+ GpgME::Error startIt() override {
+ return GpgME::Error();
+ }
+ void startNow() override {}
+};
+
QGpgME::MultiDeleteJob::MultiDeleteJob(const Protocol *protocol)
- : Job(nullptr),
+ : Job(std::make_unique<MultiDeleteJobPrivate>(), nullptr),
mProtocol(protocol),
mJob(nullptr)
{
@@ -61,8 +72,14 @@
GpgME::Error QGpgME::MultiDeleteJob::start(const std::vector<GpgME::Key> &keys, bool allowSecretKeyDeletion)
{
+ return start(keys, allowSecretKeyDeletion ? GpgME::DeletionFlags::AllowSecret : GpgME::DeletionFlags::UseDefaults);
+}
+
+GpgME::Error QGpgME::MultiDeleteJob::start(const std::vector<GpgME::Key> &keys, GpgME::DeletionFlags flags)
+{
+ Q_D(MultiDeleteJob);
+ d->flags = flags;
mKeys = keys;
- mAllowSecretKeyDeletion = allowSecretKeyDeletion;
mIt = mKeys.begin();
const GpgME::Error err = startAJob();
@@ -108,6 +125,7 @@
GpgME::Error QGpgME::MultiDeleteJob::startAJob()
{
+ Q_D(MultiDeleteJob);
if (mIt == mKeys.end()) {
return GpgME::Error(0);
}
@@ -117,7 +135,7 @@
connect(mJob.data(), &DeleteJob::result, this, &MultiDeleteJob::slotResult);
- return mJob->start(*mIt, mAllowSecretKeyDeletion);
+ return mJob->start(*mIt, d->flags);
}
#include "moc_multideletejob.cpp"
diff --git a/src/qgpgmedeletejob.h b/src/qgpgmedeletejob.h
--- a/src/qgpgmedeletejob.h
+++ b/src/qgpgmedeletejob.h
@@ -44,14 +44,16 @@
class Key;
}
+
namespace QGpgME
{
+class QGpgMEDeleteJobPrivate;
class QGpgMEDeleteJob
#ifdef Q_MOC_RUN
: public DeleteJob
#else
- : public _detail::ThreadedJobMixin<DeleteJob>
+ : public _detail::ThreadedJobMixin<DeleteJob, QGpgME::QGpgMEDeleteJobPrivate>
#endif
{
Q_OBJECT
@@ -65,6 +67,9 @@
/* from DeleteJob */
GpgME::Error start(const GpgME::Key &key, bool allowSecretKeyDeletion) override;
+
+private:
+ Q_DECLARE_PRIVATE(QGpgMEDeleteJob)
};
}
diff --git a/src/qgpgmedeletejob.cpp b/src/qgpgmedeletejob.cpp
--- a/src/qgpgmedeletejob.cpp
+++ b/src/qgpgmedeletejob.cpp
@@ -37,6 +37,7 @@
#endif
#include "qgpgmedeletejob.h"
+#include "deletejob_p.h"
#include <gpgme++/context.h>
#include <gpgme++/key.h>
@@ -46,6 +47,30 @@
using namespace QGpgME;
using namespace GpgME;
+class QGpgME::QGpgMEDeleteJobPrivate : public DeleteJobPrivate
+{
+public:
+ Q_DECLARE_PUBLIC(QGpgMEDeleteJob)
+ Error start(const Key &key, DeletionFlags flags) override;
+ QGpgMEDeleteJobPrivate() = default;
+
+private:
+ void startNow() override;
+ Error startIt() override;
+};
+
+void QGpgME::QGpgMEDeleteJobPrivate::startNow()
+{
+ Q_Q(QGpgMEDeleteJob);
+ q->run();
+}
+
+Error QGpgME::QGpgMEDeleteJobPrivate::startIt()
+{
+ return Error();
+}
+
+
QGpgMEDeleteJob::QGpgMEDeleteJob(Context *context)
: mixin_type(context)
{
@@ -54,17 +79,25 @@
QGpgMEDeleteJob::~QGpgMEDeleteJob() {}
-static QGpgMEDeleteJob::result_type delete_key(Context *ctx, const Key &key, bool allowSecretKeyDeletion)
+static QGpgMEDeleteJob::result_type delete_key(Context *ctx, const Key &key, DeletionFlags flags)
{
- const Error err = ctx->deleteKey(key, allowSecretKeyDeletion);
+ const Error err = ctx->deleteKey(key, flags);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return std::make_tuple(err, log, ae);
}
-Error QGpgMEDeleteJob::start(const Key &key, bool allowSecretKeyDeletion)
+Error QGpgMEDeleteJobPrivate::start(const Key &key, DeletionFlags flags)
{
- run(std::bind(&delete_key, std::placeholders::_1, key, allowSecretKeyDeletion));
+ Q_Q(QGpgMEDeleteJob);
+ q->run(std::bind(&delete_key, std::placeholders::_1, key, flags));
return Error();
}
+
+Error QGpgMEDeleteJob::start(const Key &key, bool allowSecretKeyDeletion)
+{
+ Q_D(QGpgMEDeleteJob);
+ return d->start(key, allowSecretKeyDeletion ? DeletionFlags::AllowSecret : DeletionFlags::UseDefaults);
+}
+
#include "moc_qgpgmedeletejob.cpp"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 21, 1:29 PM (13 h, 1 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e8/33/b2630ff7d3b9d8db2b71db9b703d
Attached To
D618: Allow passing flags to DeleteJob
Event Timeline
Log In to Comment