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
This commit is contained in:
Tobias Fella 2024-01-19 13:44:46 +01:00
parent 0011412193
commit 47f3d92bf3
No known key found for this signature in database
GPG Key ID: F315CBBEE5E1889B
3 changed files with 21 additions and 0 deletions

View File

@ -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());
};

View File

@ -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"

View File

@ -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;