qt: Allow checking if the sign/encrypt archive jobs are supported
* lang/qt/src/encryptarchivejob.cpp, lang/qt/src/encryptarchivejob.h (isSupported): New. * lang/qt/src/signarchivejob.cpp, lang/qt/src/signarchivejob.h (isSupported): New. * lang/qt/src/signencryptarchivejob.cpp, lang/qt/src/signencryptarchivejob.h (isSupported): New. * lang/qt/tests/run-encryptarchivejob.cpp (main), lang/qt/tests/run-signarchivejob.cpp (main): Check if jobs are supported. -- GnuPG-bug-id: 6342
This commit is contained in:
parent
8478064691
commit
55c948866f
@ -38,6 +38,8 @@
|
|||||||
#include "encryptarchivejob.h"
|
#include "encryptarchivejob.h"
|
||||||
#include "encryptarchivejob_p.h"
|
#include "encryptarchivejob_p.h"
|
||||||
|
|
||||||
|
#include <engineinfo.h>
|
||||||
|
|
||||||
using namespace QGpgME;
|
using namespace QGpgME;
|
||||||
|
|
||||||
EncryptArchiveJob::EncryptArchiveJob(QObject *parent)
|
EncryptArchiveJob::EncryptArchiveJob(QObject *parent)
|
||||||
@ -47,6 +49,13 @@ EncryptArchiveJob::EncryptArchiveJob(QObject *parent)
|
|||||||
|
|
||||||
EncryptArchiveJob::~EncryptArchiveJob() = default;
|
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)
|
void EncryptArchiveJob::setBaseDirectory(const QString &baseDirectory)
|
||||||
{
|
{
|
||||||
auto d = jobPrivate<EncryptArchiveJobPrivate>(this);
|
auto d = jobPrivate<EncryptArchiveJobPrivate>(this);
|
||||||
|
@ -61,6 +61,8 @@ protected:
|
|||||||
public:
|
public:
|
||||||
~EncryptArchiveJob() override;
|
~EncryptArchiveJob() override;
|
||||||
|
|
||||||
|
static bool isSupported();
|
||||||
|
|
||||||
void setBaseDirectory(const QString &baseDirectory);
|
void setBaseDirectory(const QString &baseDirectory);
|
||||||
QString baseDirectory() const;
|
QString baseDirectory() const;
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#include "signarchivejob.h"
|
#include "signarchivejob.h"
|
||||||
#include "signarchivejob_p.h"
|
#include "signarchivejob_p.h"
|
||||||
|
|
||||||
|
#include <engineinfo.h>
|
||||||
|
|
||||||
using namespace QGpgME;
|
using namespace QGpgME;
|
||||||
|
|
||||||
SignArchiveJob::SignArchiveJob(QObject *parent)
|
SignArchiveJob::SignArchiveJob(QObject *parent)
|
||||||
@ -47,6 +49,13 @@ SignArchiveJob::SignArchiveJob(QObject *parent)
|
|||||||
|
|
||||||
SignArchiveJob::~SignArchiveJob() = default;
|
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)
|
void SignArchiveJob::setBaseDirectory(const QString &baseDirectory)
|
||||||
{
|
{
|
||||||
auto d = jobPrivate<SignArchiveJobPrivate>(this);
|
auto d = jobPrivate<SignArchiveJobPrivate>(this);
|
||||||
|
@ -61,6 +61,8 @@ protected:
|
|||||||
public:
|
public:
|
||||||
~SignArchiveJob() override;
|
~SignArchiveJob() override;
|
||||||
|
|
||||||
|
static bool isSupported();
|
||||||
|
|
||||||
void setBaseDirectory(const QString &baseDirectory);
|
void setBaseDirectory(const QString &baseDirectory);
|
||||||
QString baseDirectory() const;
|
QString baseDirectory() const;
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#include "signencryptarchivejob.h"
|
#include "signencryptarchivejob.h"
|
||||||
#include "signencryptarchivejob_p.h"
|
#include "signencryptarchivejob_p.h"
|
||||||
|
|
||||||
|
#include <engineinfo.h>
|
||||||
|
|
||||||
using namespace QGpgME;
|
using namespace QGpgME;
|
||||||
|
|
||||||
SignEncryptArchiveJob::SignEncryptArchiveJob(QObject *parent)
|
SignEncryptArchiveJob::SignEncryptArchiveJob(QObject *parent)
|
||||||
@ -47,6 +49,13 @@ SignEncryptArchiveJob::SignEncryptArchiveJob(QObject *parent)
|
|||||||
|
|
||||||
SignEncryptArchiveJob::~SignEncryptArchiveJob() = default;
|
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)
|
void SignEncryptArchiveJob::setBaseDirectory(const QString &baseDirectory)
|
||||||
{
|
{
|
||||||
auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this);
|
auto d = jobPrivate<SignEncryptArchiveJobPrivate>(this);
|
||||||
|
@ -61,6 +61,8 @@ protected:
|
|||||||
public:
|
public:
|
||||||
~SignEncryptArchiveJob() override;
|
~SignEncryptArchiveJob() override;
|
||||||
|
|
||||||
|
static bool isSupported();
|
||||||
|
|
||||||
void setBaseDirectory(const QString &baseDirectory);
|
void setBaseDirectory(const QString &baseDirectory);
|
||||||
QString baseDirectory() const;
|
QString baseDirectory() const;
|
||||||
|
|
||||||
|
@ -123,6 +123,12 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
const auto options = parseCommandLine(app.arguments());
|
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);
|
auto output = createOutput(options.archiveName);
|
||||||
if (!output) {
|
if (!output) {
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -118,6 +118,11 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
const auto options = parseCommandLine(app.arguments());
|
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);
|
auto output = createOutput(options.archiveName);
|
||||||
if (!output) {
|
if (!output) {
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user