From 47f3d92bf340f2a24b3c837a3afa5e1890b413ac Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Fri, 19 Jan 2024 13:44:46 +0100 Subject: [PATCH] qt: Add function for synchronously executing ExportJob * lang/qt/src/exportjob: Add exec function. * lang/qt/src/qgpgmeexportjob.cpp: Implement exec function. * lang/qt/src/qgpgmeexportjob.h: Override exec function. -- GnuPG-Bug-Id: 6893 --- lang/qt/src/exportjob.h | 6 ++++++ lang/qt/src/qgpgmeexportjob.cpp | 14 ++++++++++++++ lang/qt/src/qgpgmeexportjob.h | 1 + 3 files changed, 21 insertions(+) diff --git a/lang/qt/src/exportjob.h b/lang/qt/src/exportjob.h index 4fdb468d..91b5c90e 100644 --- a/lang/qt/src/exportjob.h +++ b/lang/qt/src/exportjob.h @@ -80,6 +80,12 @@ public: virtual void setExportFlags (unsigned int flags); + /** + * Starts the export operation synchronously, otherwise behaves identical to + * ExportJob::start + */ + virtual GpgME::Error exec(const QStringList &patterns, QByteArray &data); + Q_SIGNALS: void result(const GpgME::Error &result, const QByteArray &keyData, const QString &auditLogAsHtml = QString(), const GpgME::Error &auditLogError = GpgME::Error()); }; diff --git a/lang/qt/src/qgpgmeexportjob.cpp b/lang/qt/src/qgpgmeexportjob.cpp index e9bc0a4d..803af7dd 100644 --- a/lang/qt/src/qgpgmeexportjob.cpp +++ b/lang/qt/src/qgpgmeexportjob.cpp @@ -88,6 +88,14 @@ Error QGpgMEExportJob::start(const QStringList &patterns) return Error(); } +Error QGpgMEExportJob::exec(const QStringList &patterns, QByteArray &data) +{ + auto mode = m_exportMode | m_additionalExportModeFlags; + const result_type r = export_qba(context(), patterns, mode); + data = std::get<1>(r); + return std::get<0>(r); +} + void QGpgMEExportJob::setExportFlags(unsigned int flags) { m_additionalExportModeFlags = flags; @@ -97,4 +105,10 @@ void QGpgMEExportJob::setExportFlags(unsigned int flags) void ExportJob::setExportFlags(unsigned int) { } + +/* For ABI compat not pure virtual. */ +GpgME::Error ExportJob::exec(const QStringList &patterns, QByteArray &data) +{ +} + #include "qgpgmeexportjob.moc" diff --git a/lang/qt/src/qgpgmeexportjob.h b/lang/qt/src/qgpgmeexportjob.h index 272fff4d..b60b95f2 100644 --- a/lang/qt/src/qgpgmeexportjob.h +++ b/lang/qt/src/qgpgmeexportjob.h @@ -69,6 +69,7 @@ public: /* from ExportJob */ GpgME::Error start(const QStringList &patterns) override; + GpgME::Error exec(const QStringList &patterns, QByteArray &data) override; private: unsigned int m_exportMode;