diff --git a/lang/qt/src/encryptarchivejob.cpp b/lang/qt/src/encryptarchivejob.cpp index 5c5533be..a99de13f 100644 --- a/lang/qt/src/encryptarchivejob.cpp +++ b/lang/qt/src/encryptarchivejob.cpp @@ -38,6 +38,8 @@ #include "encryptarchivejob.h" #include "encryptarchivejob_p.h" +#include + using namespace QGpgME; EncryptArchiveJob::EncryptArchiveJob(QObject *parent) @@ -47,6 +49,13 @@ EncryptArchiveJob::EncryptArchiveJob(QObject *parent) EncryptArchiveJob::~EncryptArchiveJob() = default; +// static +bool EncryptArchiveJob::isSupported() +{ + static const auto gpgVersion = GpgME::engineInfo(GpgME::GpgEngine).engineVersion(); + return (gpgVersion >= "2.4.1") || (gpgVersion >= "2.2.42" && gpgVersion < "2.3.0"); +} + void EncryptArchiveJob::setBaseDirectory(const QString &baseDirectory) { auto d = jobPrivate(this); diff --git a/lang/qt/src/encryptarchivejob.h b/lang/qt/src/encryptarchivejob.h index 1221994f..619d3cef 100644 --- a/lang/qt/src/encryptarchivejob.h +++ b/lang/qt/src/encryptarchivejob.h @@ -61,6 +61,8 @@ protected: public: ~EncryptArchiveJob() override; + static bool isSupported(); + void setBaseDirectory(const QString &baseDirectory); QString baseDirectory() const; diff --git a/lang/qt/src/signarchivejob.cpp b/lang/qt/src/signarchivejob.cpp index fcdf241d..d185ae9f 100644 --- a/lang/qt/src/signarchivejob.cpp +++ b/lang/qt/src/signarchivejob.cpp @@ -38,6 +38,8 @@ #include "signarchivejob.h" #include "signarchivejob_p.h" +#include + using namespace QGpgME; SignArchiveJob::SignArchiveJob(QObject *parent) @@ -47,6 +49,13 @@ SignArchiveJob::SignArchiveJob(QObject *parent) SignArchiveJob::~SignArchiveJob() = default; +// static +bool SignArchiveJob::isSupported() +{ + static const auto gpgVersion = GpgME::engineInfo(GpgME::GpgEngine).engineVersion(); + return (gpgVersion >= "2.4.1") || (gpgVersion >= "2.2.42" && gpgVersion < "2.3.0"); +} + void SignArchiveJob::setBaseDirectory(const QString &baseDirectory) { auto d = jobPrivate(this); diff --git a/lang/qt/src/signarchivejob.h b/lang/qt/src/signarchivejob.h index 6b8cd175..f30e3e5e 100644 --- a/lang/qt/src/signarchivejob.h +++ b/lang/qt/src/signarchivejob.h @@ -61,6 +61,8 @@ protected: public: ~SignArchiveJob() override; + static bool isSupported(); + void setBaseDirectory(const QString &baseDirectory); QString baseDirectory() const; diff --git a/lang/qt/src/signencryptarchivejob.cpp b/lang/qt/src/signencryptarchivejob.cpp index 6a9a5abe..b1d5e170 100644 --- a/lang/qt/src/signencryptarchivejob.cpp +++ b/lang/qt/src/signencryptarchivejob.cpp @@ -38,6 +38,8 @@ #include "signencryptarchivejob.h" #include "signencryptarchivejob_p.h" +#include + using namespace QGpgME; SignEncryptArchiveJob::SignEncryptArchiveJob(QObject *parent) @@ -47,6 +49,13 @@ SignEncryptArchiveJob::SignEncryptArchiveJob(QObject *parent) SignEncryptArchiveJob::~SignEncryptArchiveJob() = default; +// static +bool SignEncryptArchiveJob::isSupported() +{ + static const auto gpgVersion = GpgME::engineInfo(GpgME::GpgEngine).engineVersion(); + return (gpgVersion >= "2.4.1") || (gpgVersion >= "2.2.42" && gpgVersion < "2.3.0"); +} + void SignEncryptArchiveJob::setBaseDirectory(const QString &baseDirectory) { auto d = jobPrivate(this); diff --git a/lang/qt/src/signencryptarchivejob.h b/lang/qt/src/signencryptarchivejob.h index 67b2fcbb..2cc28a5e 100644 --- a/lang/qt/src/signencryptarchivejob.h +++ b/lang/qt/src/signencryptarchivejob.h @@ -61,6 +61,8 @@ protected: public: ~SignEncryptArchiveJob() override; + static bool isSupported(); + void setBaseDirectory(const QString &baseDirectory); QString baseDirectory() const; diff --git a/lang/qt/tests/run-encryptarchivejob.cpp b/lang/qt/tests/run-encryptarchivejob.cpp index cdcfa17d..9ce79b6c 100644 --- a/lang/qt/tests/run-encryptarchivejob.cpp +++ b/lang/qt/tests/run-encryptarchivejob.cpp @@ -123,6 +123,12 @@ int main(int argc, char **argv) const auto options = parseCommandLine(app.arguments()); + if ((options.sign && !QGpgME::SignEncryptArchiveJob::isSupported()) + || (!options.sign && !QGpgME::EncryptArchiveJob::isSupported())) { + std::cerr << "Error: Encrypting archives is not supported by your version of gpg." << std::endl; + return 1; + } + auto output = createOutput(options.archiveName); if (!output) { return 1; diff --git a/lang/qt/tests/run-signarchivejob.cpp b/lang/qt/tests/run-signarchivejob.cpp index c426ba93..affd8e4d 100644 --- a/lang/qt/tests/run-signarchivejob.cpp +++ b/lang/qt/tests/run-signarchivejob.cpp @@ -118,6 +118,11 @@ int main(int argc, char **argv) const auto options = parseCommandLine(app.arguments()); + if (!QGpgME::SignArchiveJob::isSupported()) { + std::cerr << "Error: Signing archives is not supported by your version of gpg." << std::endl; + return 1; + } + auto output = createOutput(options.archiveName); if (!output) { return 1;