qt: Replace usage of deprecated Error::asString

* lang/qt/src/debug.cpp (operator<<): Use Error::asStdString instead of
Error::asString.
* lang/qt/src/qgpgmedecryptverifyjob.cpp (decrypt_verify),
lang/qt/src/qgpgmenewcryptoconfig.cpp
(QGpgMENewCryptoConfigComponent::sync),
lang/qt/src/qgpgmewkdlookupjob.cpp (startDirmngr): Use QDebug operator
for Error instead of Error::asString.
* lang/qt/src/threadedjobmixin.cpp (_detail::audit_log_as_html): Use
errorAsString instead of Error::asString.
* lang/qt/src/util.h (errorAsString): New.

* lang/qt/tests/run-decryptverifyarchivejob.cpp (main),
lang/qt/tests/run-decryptverifyjob.cpp (main),
lang/qt/tests/run-encryptarchivejob.cpp (main),
lang/qt/tests/run-encryptjob.cpp (main),
lang/qt/tests/run-exportjob.cpp (main),
lang/qt/tests/run-importjob.cpp (main),
lang/qt/tests/run-receivekeysjob.cpp (main),
lang/qt/tests/run-refreshkeysjob.cpp (main),
lang/qt/tests/run-signarchivejob.cpp (main),
lang/qt/tests/run-signjob.cpp (main),
lang/qt/tests/run-verifydetachedjob.cpp (main),
lang/qt/tests/run-verifyopaquejob.cpp (main),
lang/qt/tests/run-wkdrefreshjob.cpp (main),
lang/qt/tests/t-ownertrust.cpp (testChangeOwnerTrust),
lang/qt/tests/t-remarks.cpp (testRemarkOwnKey),
lang/qt/tests/t-tofuinfo.cpp (testTofuPolicy): Use QDebug operator for
Error instead of Error::asString.
* lang/qt/tests/t-changeexpiryjob.cpp (all test functions),
lang/qt/tests/t-trustsignatures.cpp (all test functions),
lang/qt/tests/t-various.cpp (testSignKeyWithoutExpiration,
testSignKeyWithExpiration): Use errorAsString instead of
Error::asString.
--

GnuPG-bug-id: 7188
This commit is contained in:
Ingo Klöcker 2024-07-04 18:19:56 +02:00
parent 28542b14c4
commit f6d020e24f
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9
25 changed files with 91 additions and 59 deletions

View File

@ -44,9 +44,9 @@ QDebug operator<<(QDebug debug, const GpgME::Error &err)
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// On Windows, we tell libgpg-error to return (translated) error messages as UTF-8 // On Windows, we tell libgpg-error to return (translated) error messages as UTF-8
const auto errAsString = QString::fromUtf8(err.asString()); const auto errAsString = QString::fromStdString(err.asStdString());
#else #else
const auto errAsString = QString::fromLocal8Bit(err.asString()); const auto errAsString = QString::fromLocal8Bit(err.asStdString().c_str());
#endif #endif
const bool oldSetting = debug.autoInsertSpaces(); const bool oldSetting = debug.autoInsertSpaces();
debug.nospace() << errAsString << " (code: " << err.code() << ", source: " << err.source() << ")"; debug.nospace() << errAsString << " (code: " << err.code() << ", source: " << err.source() << ")";

View File

@ -39,6 +39,7 @@
#include "qgpgmedecryptverifyjob.h" #include "qgpgmedecryptverifyjob.h"
#include "dataprovider.h" #include "dataprovider.h"
#include "debug.h"
#include "decryptverifyjob_p.h" #include "decryptverifyjob_p.h"
#include "util.h" #include "util.h"
@ -118,7 +119,7 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread
const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata); const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
Error ae; Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae); const QString log = _detail::audit_log_as_html(ctx, ae);
qCDebug(QGPGME_LOG) << __func__ << "- End no plainText. Error:" << ae.asString(); qCDebug(QGPGME_LOG) << __func__ << "- End no plainText. Error:" << ae;
return std::make_tuple(res.first, res.second, out.data(), log, ae); return std::make_tuple(res.first, res.second, out.data(), log, ae);
} else { } else {
QGpgME::QIODeviceDataProvider out(plainText); QGpgME::QIODeviceDataProvider out(plainText);
@ -127,7 +128,7 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread
const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata); const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
Error ae; Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae); const QString log = _detail::audit_log_as_html(ctx, ae);
qCDebug(QGPGME_LOG) << __func__ << "- End plainText. Error:" << ae.asString(); qCDebug(QGPGME_LOG) << __func__ << "- End plainText. Error:" << ae;
return std::make_tuple(res.first, res.second, QByteArray(), log, ae); return std::make_tuple(res.first, res.second, QByteArray(), log, ae);
} }
} }

View File

@ -211,7 +211,7 @@ void QGpgMENewCryptoConfigComponent::sync(bool runtime)
if (const Error err = m_component.save()) { if (const Error err = m_component.save()) {
qCWarning(QGPGME_LOG) << ":" qCWarning(QGPGME_LOG) << ":"
<< "Error from gpgconf while saving configuration: %1" << "Error from gpgconf while saving configuration: %1"
<< QString::fromLocal8Bit(err.asString()); << err;
} }
} }

View File

@ -37,6 +37,7 @@
#include "qgpgmewkdlookupjob.h" #include "qgpgmewkdlookupjob.h"
#include "debug.h"
#include "qgpgme_debug.h" #include "qgpgme_debug.h"
#include <gpgme++/context.h> #include <gpgme++/context.h>
@ -62,7 +63,7 @@ static GpgME::Error startDirmngr(Context *assuanCtx)
auto spawnCtx = std::unique_ptr<Context>{Context::createForEngine(SpawnEngine, &err)}; auto spawnCtx = std::unique_ptr<Context>{Context::createForEngine(SpawnEngine, &err)};
if (err) { if (err) {
qCDebug(QGPGME_LOG) << "Error: Failed to get context for spawn engine (" << err.asString() << ")"; qCDebug(QGPGME_LOG) << "Error: Failed to get context for spawn engine (" << err << ")";
} }
const auto gpgconfProgram = GpgME::dirInfo("gpgconf-name"); const auto gpgconfProgram = GpgME::dirInfo("gpgconf-name");
// replace backslashes with forward slashes in homedir to work around bug T6833 // replace backslashes with forward slashes in homedir to work around bug T6833
@ -132,11 +133,11 @@ static GpgME::Error run_wkd_get(Context *ctx, const std::string &email)
// no key for email is available via WKD or that the domain doesn't // no key for email is available via WKD or that the domain doesn't
// support WKD or that the domain doesn't exist (on subsequent requests // support WKD or that the domain doesn't exist (on subsequent requests
// using dirmngr's internal cache) // using dirmngr's internal cache)
qCDebug(QGPGME_LOG) << "WKD_GET returned" << err.asString() << "; ignoring..."; qCDebug(QGPGME_LOG) << "WKD_GET returned" << err << "; ignoring...";
err = {}; err = {};
} }
if (err) { if (err) {
qCDebug(QGPGME_LOG) << "WKD_GET failed with" << err.asString(); qCDebug(QGPGME_LOG) << "WKD_GET failed with" << err;
} }
return err; return err;

View File

@ -39,6 +39,7 @@
#include "threadedjobmixin.h" #include "threadedjobmixin.h"
#include "dataprovider.h" #include "dataprovider.h"
#include "util.h"
#include <gpgme++/data.h> #include <gpgme++/data.h>
@ -82,7 +83,7 @@ QString _detail::audit_log_as_html(Context *ctx, GpgME::Error &err)
if (ctx->protocol() == OpenPGP) { if (ctx->protocol() == OpenPGP) {
if ((err = ctx->getAuditLog(data, OpenPGPAuditLogFlags))) { if ((err = ctx->getAuditLog(data, OpenPGPAuditLogFlags))) {
return QString::fromLocal8Bit(err.asString()); return errorAsString(err);
} }
const QByteArray ba = dp.data(); const QByteArray ba = dp.data();
return markupDiagnostics(stringFromGpgOutput(ba)); return markupDiagnostics(stringFromGpgOutput(ba));
@ -91,12 +92,12 @@ QString _detail::audit_log_as_html(Context *ctx, GpgME::Error &err)
if (ctx->protocol() == CMS) { if (ctx->protocol() == CMS) {
if ((err = ctx->lastError())) { if ((err = ctx->lastError())) {
if ((err = ctx->getAuditLog(data, Context::DiagnosticAuditLog))) { if ((err = ctx->getAuditLog(data, Context::DiagnosticAuditLog))) {
return QString::fromLocal8Bit(err.asString()); return errorAsString(err);
} }
const QByteArray ba = dp.data(); const QByteArray ba = dp.data();
return markupDiagnostics(stringFromGpgOutput(ba)); return markupDiagnostics(stringFromGpgOutput(ba));
} else if ((err = ctx->getAuditLog(data, CMSAuditLogFlags))) { } else if ((err = ctx->getAuditLog(data, CMSAuditLogFlags))) {
return QString::fromLocal8Bit(err.asString()); return errorAsString(err);
} }
return QString::fromUtf8(dp.data()); return QString::fromUtf8(dp.data());
} }

View File

@ -36,6 +36,8 @@
#include <QStringList> #include <QStringList>
#include <gpgme++/error.h>
#include <gpgme.h> #include <gpgme.h>
#include <string> #include <string>
@ -51,6 +53,15 @@ static inline gpgme_error_t make_error(gpgme_err_code_t code)
return gpgme_err_make((gpgme_err_source_t)22, code); return gpgme_err_make((gpgme_err_source_t)22, code);
} }
static inline QString errorAsString(const GpgME::Error &error)
{
#ifdef Q_OS_WIN
return QString::fromStdString(error.asStdString());
#else
return QString::fromLocal8Bit(error.asStdString().c_str());
#endif
}
std::vector<std::string> toStrings(const QStringList &l); std::vector<std::string> toStrings(const QStringList &l);
QStringList toFingerprints(const std::vector<GpgME::Key> &keys); QStringList toFingerprints(const std::vector<GpgME::Key> &keys);

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <decryptverifyarchivejob.h> #include <decryptverifyarchivejob.h>
#include <protocol.h> #include <protocol.h>
@ -114,7 +115,7 @@ int main(int argc, char **argv)
const auto err = job->startIt(); const auto err = job->startIt();
if (err) { if (err) {
std::cerr << "Error: Starting the job failed: " << err.asString() << std::endl; std::cerr << "Error: Starting the job failed: " << err << std::endl;
return 1; return 1;
} }

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <protocol.h> #include <protocol.h>
#include <decryptverifyjob.h> #include <decryptverifyjob.h>
@ -155,7 +156,7 @@ int main(int argc, char **argv)
err = job->startIt(); err = job->startIt();
} }
if (err) { if (err) {
std::cerr << "Error: Starting the job failed: " << err.asString() << std::endl; std::cerr << "Error: Starting the job failed: " << err << std::endl;
return 1; return 1;
} }

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <protocol.h> #include <protocol.h>
#include <encryptarchivejob.h> #include <encryptarchivejob.h>
#include <signencryptarchivejob.h> #include <signencryptarchivejob.h>
@ -176,7 +177,7 @@ int main(int argc, char **argv)
err = job->startIt(); err = job->startIt();
} }
if (err) { if (err) {
std::cerr << "Error: Starting the job failed: " << err.asString() << std::endl; std::cerr << "Error: Starting the job failed: " << err << std::endl;
return 1; return 1;
} }
} else { } else {
@ -207,7 +208,7 @@ int main(int argc, char **argv)
err = job->startIt(); err = job->startIt();
} }
if (err) { if (err) {
std::cerr << "Error: Starting the job failed: " << err.asString() << std::endl; std::cerr << "Error: Starting the job failed: " << err << std::endl;
return 1; return 1;
} }
} }

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <protocol.h> #include <protocol.h>
#include <encryptjob.h> #include <encryptjob.h>
#include <signencryptjob.h> #include <signencryptjob.h>
@ -157,7 +158,7 @@ int main(int argc, char **argv)
err = job->startIt(); err = job->startIt();
} }
if (err) { if (err) {
std::cerr << "Error: Starting the job failed: " << err.asString() << std::endl; std::cerr << "Error: Starting the job failed: " << err << std::endl;
return 1; return 1;
} }
} else { } else {
@ -189,7 +190,7 @@ int main(int argc, char **argv)
err = job->startIt(); err = job->startIt();
} }
if (err) { if (err) {
std::cerr << "Error: Starting the job failed: " << err.asString() << std::endl; std::cerr << "Error: Starting the job failed: " << err << std::endl;
return 1; return 1;
} }
} }

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <exportjob.h> #include <exportjob.h>
#include <protocol.h> #include <protocol.h>
@ -106,7 +107,7 @@ int main(int argc, char *argv[])
QObject::connect(job, &QGpgME::ExportJob::result, QObject::connect(job, &QGpgME::ExportJob::result,
&app, [&app] (const GpgME::Error &err, const QByteArray &keyData, const QString &, const GpgME::Error &) { &app, [&app] (const GpgME::Error &err, const QByteArray &keyData, const QString &, const GpgME::Error &) {
if (err) { if (err) {
cerr << "The ChangeExpiryJob failed with" << err.asString() << "."; cerr << "The ChangeExpiryJob failed with" << err << ".";
app.exit(1); app.exit(1);
return; return;
} }

View File

@ -89,7 +89,7 @@ int main(int argc, char **argv)
const auto keyData = f.readAll(); const auto keyData = f.readAll();
auto job = (protocol == GpgME::CMS ? QGpgME::smime() : QGpgME::openpgp())->importJob(); auto job = (protocol == GpgME::CMS ? QGpgME::smime() : QGpgME::openpgp())->importJob();
const auto result = job->exec(keyData); const auto result = job->exec(keyData);
qDebug() << "Result error:" << result.error().asString(); qDebug() << "Result error:" << result.error();
for (const auto &line : QString::fromStdString(QGpgME::toLogString(result)).split('\n')) { for (const auto &line : QString::fromStdString(QGpgME::toLogString(result)).split('\n')) {
qDebug().noquote() << line; qDebug().noquote() << line;
} }

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <gpgme++/importresult.h> #include <gpgme++/importresult.h>
#include <protocol.h> #include <protocol.h>
#include <receivekeysjob.h> #include <receivekeysjob.h>
@ -58,7 +59,7 @@ int main(int argc, char **argv)
auto job = QGpgME::openpgp()->receiveKeysJob(); auto job = QGpgME::openpgp()->receiveKeysJob();
const auto result = job->exec(keyIds); const auto result = job->exec(keyIds);
std::cout << "Result: " << result.error().asString() << std::endl; std::cout << "Result: " << result.error() << std::endl;
std::cout << "Details:\n" << result << std::endl; std::cout << "Details:\n" << result << std::endl;
return 0; return 0;

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <protocol.h> #include <protocol.h>
#include <refreshkeysjob.h> #include <refreshkeysjob.h>
#include <receivekeysjob.h> #include <receivekeysjob.h>
@ -111,10 +112,10 @@ int main(int argc, char **argv)
return 1; return 1;
} }
if (openPGPKey.error) { if (openPGPKey.error) {
std::cerr << "Warning: Error while getting OpenPGP key: " << openPGPKey.error.asString() << std::endl; std::cerr << "Warning: Error while getting OpenPGP key: " << openPGPKey.error << std::endl;
} }
if (smimeKey.error) { if (smimeKey.error) {
std::cerr << "Warning: Error while getting S/MIME key: " << openPGPKey.error.asString() << std::endl; std::cerr << "Warning: Error while getting S/MIME key: " << openPGPKey.error << std::endl;
} }
auto key = openPGPKey.key.isNull() ? smimeKey.key : openPGPKey.key; auto key = openPGPKey.key.isNull() ? smimeKey.key : openPGPKey.key;
std::cout << "Refreshing " << displayName(key.protocol()) << " key " << key.userID(0).id() << std::endl; std::cout << "Refreshing " << displayName(key.protocol()) << " key " << key.userID(0).id() << std::endl;
@ -131,7 +132,7 @@ int main(int argc, char **argv)
}); });
const auto err = job->start({QString::fromLatin1(key.primaryFingerprint())}); const auto err = job->start({QString::fromLatin1(key.primaryFingerprint())});
if (err) { if (err) {
std::cerr << "Error: " << err.asString() << std::endl; std::cerr << "Error: " << err << std::endl;
return 1; return 1;
} }
} else { } else {
@ -141,12 +142,12 @@ int main(int argc, char **argv)
return 1; return 1;
} }
QObject::connect(job, &QGpgME::RefreshKeysJob::result, &app, [](const GpgME::Error &err) { QObject::connect(job, &QGpgME::RefreshKeysJob::result, &app, [](const GpgME::Error &err) {
std::cout << "Result: " << err.asString() << std::endl; std::cout << "Result: " << err << std::endl;
qApp->quit(); qApp->quit();
}); });
const auto err = job->start({key}); const auto err = job->start({key});
if (err) { if (err) {
std::cerr << "Error: " << err.asString() << std::endl; std::cerr << "Error: " << err << std::endl;
return 1; return 1;
} }
} }

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <protocol.h> #include <protocol.h>
#include <signarchivejob.h> #include <signarchivejob.h>
@ -168,7 +169,7 @@ int main(int argc, char **argv)
err = job->startIt(); err = job->startIt();
} }
if (err) { if (err) {
std::cerr << "Error: Starting the job failed: " << err.asString() << std::endl; std::cerr << "Error: Starting the job failed: " << err << std::endl;
return 1; return 1;
} }

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <protocol.h> #include <protocol.h>
#include <signjob.h> #include <signjob.h>
@ -159,7 +160,7 @@ int main(int argc, char **argv)
err = job->startIt(); err = job->startIt();
} }
if (err) { if (err) {
std::cerr << "Error: Starting the job failed: " << err.asString() << std::endl; std::cerr << "Error: Starting the job failed: " << err << std::endl;
return 1; return 1;
} }

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <protocol.h> #include <protocol.h>
#include <verifydetachedjob.h> #include <verifydetachedjob.h>
@ -113,7 +114,7 @@ int main(int argc, char **argv)
job->setSignedFile(options.signedFile); job->setSignedFile(options.signedFile);
err = job->startIt(); err = job->startIt();
if (err) { if (err) {
std::cerr << "Error: Starting the job failed: " << err.asString() << std::endl; std::cerr << "Error: Starting the job failed: " << err << std::endl;
return 1; return 1;
} }

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <protocol.h> #include <protocol.h>
#include <verifyopaquejob.h> #include <verifyopaquejob.h>
@ -152,7 +153,7 @@ int main(int argc, char **argv)
err = job->startIt(); err = job->startIt();
} }
if (err) { if (err) {
std::cerr << "Error: Starting the job failed: " << err.asString() << std::endl; std::cerr << "Error: Starting the job failed: " << err << std::endl;
return 1; return 1;
} }

View File

@ -35,6 +35,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <debug.h>
#include <protocol.h> #include <protocol.h>
#include <wkdrefreshjob.h> #include <wkdrefreshjob.h>
@ -121,7 +122,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
if (err) { if (err) {
std::cerr << "Error while getting OpenPGP key: " << err.asString() << std::endl; std::cerr << "Error while getting OpenPGP key: " << err << std::endl;
return 1; return 1;
} }
std::cout << "Refreshing OpenPGP key " << key.userID(0).id() << std::endl; std::cout << "Refreshing OpenPGP key " << key.userID(0).id() << std::endl;
@ -145,7 +146,7 @@ int main(int argc, char **argv)
err = job->start({key}); err = job->start({key});
} }
if (err) { if (err) {
std::cerr << "Error: " << err.asString() << std::endl; std::cerr << "Error: " << err << std::endl;
return 1; return 1;
} }

View File

@ -40,6 +40,7 @@
#include <gpgme++/context.h> #include <gpgme++/context.h>
#include <gpgme++/engineinfo.h> #include <gpgme++/engineinfo.h>
#include "protocol.h" #include "protocol.h"
#include "util.h"
#include <QSignalSpy> #include <QSignalSpy>
#include <QTemporaryDir> #include <QTemporaryDir>
@ -84,7 +85,7 @@ private Q_SLOTS:
this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) {
Q_EMIT asyncDone(); Q_EMIT asyncDone();
if (err2) { if (err2) {
QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2))));
} }
}); });
@ -147,7 +148,7 @@ private Q_SLOTS:
this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) {
Q_EMIT asyncDone(); Q_EMIT asyncDone();
if (err2) { if (err2) {
QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2))));
} }
}); });
@ -211,7 +212,7 @@ private Q_SLOTS:
this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) {
Q_EMIT asyncDone(); Q_EMIT asyncDone();
if (err2) { if (err2) {
QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2))));
} }
}); });
@ -274,7 +275,7 @@ private Q_SLOTS:
this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) {
Q_EMIT asyncDone(); Q_EMIT asyncDone();
if (err2) { if (err2) {
QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2))));
} }
}); });
@ -342,7 +343,7 @@ private Q_SLOTS:
this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) {
Q_EMIT asyncDone(); Q_EMIT asyncDone();
if (err2) { if (err2) {
QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2))));
} }
}); });

View File

@ -37,6 +37,7 @@
#include <QDebug> #include <QDebug>
#include <QTest> #include <QTest>
#include <QSignalSpy> #include <QSignalSpy>
#include "debug.h"
#include "keylistjob.h" #include "keylistjob.h"
#include "protocol.h" #include "protocol.h"
#include <gpgme++/keylistresult.h> #include <gpgme++/keylistresult.h>
@ -69,7 +70,7 @@ private Q_SLOTS:
connect(job2, &ChangeOwnerTrustJob::result, this, [this](Error e) connect(job2, &ChangeOwnerTrustJob::result, this, [this](Error e)
{ {
if (e) { if (e) {
qDebug() << "Error in result: " << e.asString(); qDebug() << "Error in result: " << e;
} }
QVERIFY(!e); QVERIFY(!e);
Q_EMIT asyncDone(); Q_EMIT asyncDone();

View File

@ -39,6 +39,7 @@
#include <QTest> #include <QTest>
#include <QSignalSpy> #include <QSignalSpy>
#include <QTemporaryDir> #include <QTemporaryDir>
#include "debug.h"
#include "keylistjob.h" #include "keylistjob.h"
#include "protocol.h" #include "protocol.h"
#include "signkeyjob.h" #include "signkeyjob.h"
@ -90,7 +91,7 @@ public:
const GpgME::Error) { const GpgME::Error) {
Q_EMIT asyncDone(); Q_EMIT asyncDone();
if (err2) { if (err2) {
qDebug() << "Error: " << err2.asString(); qDebug() << "Error: " << err2;
} }
QVERIFY(err2); QVERIFY(err2);
}); });

View File

@ -38,6 +38,7 @@
#include <QTemporaryDir> #include <QTemporaryDir>
#include <QSignalSpy> #include <QSignalSpy>
#include "debug.h"
#include "protocol.h" #include "protocol.h"
#include <gpgme++/tofuinfo.h> #include <gpgme++/tofuinfo.h>
#include "tofupolicyjob.h" #include "tofupolicyjob.h"
@ -377,7 +378,7 @@ private Q_SLOTS:
if (keys.empty()) { if (keys.empty()) {
qDebug() << "bravo@example.net not found"; qDebug() << "bravo@example.net not found";
qDebug() << "Error: " << result.error().asString(); qDebug() << "Error: " << result.error();
const auto homedir = QString::fromLocal8Bit(qgetenv("GNUPGHOME")); const auto homedir = QString::fromLocal8Bit(qgetenv("GNUPGHOME"));
qDebug() << "Homedir is: " << homedir; qDebug() << "Homedir is: " << homedir;
QFileInfo fi(homedir + "/pubring.gpg"); QFileInfo fi(homedir + "/pubring.gpg");

View File

@ -40,6 +40,7 @@
#include <gpgme++/engineinfo.h> #include <gpgme++/engineinfo.h>
#include "protocol.h" #include "protocol.h"
#include "signkeyjob.h" #include "signkeyjob.h"
#include "util.h"
#include <QRegularExpression> #include <QRegularExpression>
#include <QSignalSpy> #include <QSignalSpy>
@ -94,9 +95,9 @@ private Q_SLOTS:
if (err2) { if (err2) {
if (err2.code() == GPG_ERR_GENERAL) { if (err2.code() == GPG_ERR_GENERAL) {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n"
"Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(err2.asString()))); "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2))));
} else { } else {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2))));
} }
} }
}); });
@ -138,9 +139,9 @@ private Q_SLOTS:
if (err2) { if (err2) {
if (err2.code() == GPG_ERR_GENERAL) { if (err2.code() == GPG_ERR_GENERAL) {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n"
"Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(err2.asString()))); "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2))));
} else { } else {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2))));
} }
} }
}); });
@ -205,9 +206,9 @@ private Q_SLOTS:
if (err2) { if (err2) {
if (err2.code() == GPG_ERR_GENERAL) { if (err2.code() == GPG_ERR_GENERAL) {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n"
"Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(err2.asString()))); "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2))));
} else { } else {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2))));
} }
} }
}); });
@ -249,9 +250,9 @@ private Q_SLOTS:
if (err2) { if (err2) {
if (err2.code() == GPG_ERR_GENERAL) { if (err2.code() == GPG_ERR_GENERAL) {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n"
"Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(err2.asString()))); "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2))));
} else { } else {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2))));
} }
} }
}); });
@ -317,9 +318,9 @@ private Q_SLOTS:
if (err2) { if (err2) {
if (err2.code() == GPG_ERR_GENERAL) { if (err2.code() == GPG_ERR_GENERAL) {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n"
"Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(err2.asString()))); "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2))));
} else { } else {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2))));
} }
} }
}); });
@ -361,9 +362,9 @@ private Q_SLOTS:
if (err2) { if (err2) {
if (err2.code() == GPG_ERR_GENERAL) { if (err2.code() == GPG_ERR_GENERAL) {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n"
"Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(err2.asString()))); "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2))));
} else { } else {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2))));
} }
} }
}); });
@ -428,9 +429,9 @@ private Q_SLOTS:
if (err2) { if (err2) {
if (err2.code() == GPG_ERR_GENERAL) { if (err2.code() == GPG_ERR_GENERAL) {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n"
"Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(err2.asString()))); "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2))));
} else { } else {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2))));
} }
} }
}); });
@ -473,9 +474,9 @@ private Q_SLOTS:
if (err2) { if (err2) {
if (err2.code() == GPG_ERR_GENERAL) { if (err2.code() == GPG_ERR_GENERAL) {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n"
"Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(err2.asString()))); "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2))));
} else { } else {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2))));
} }
} }
}); });

View File

@ -40,6 +40,7 @@
#include <QTemporaryDir> #include <QTemporaryDir>
#include "keylistjob.h" #include "keylistjob.h"
#include "protocol.h" #include "protocol.h"
#include "util.h"
#include <gpgme++/keylistresult.h> #include <gpgme++/keylistresult.h>
#include <gpgme++/context.h> #include <gpgme++/context.h>
#include <gpgme++/engineinfo.h> #include <gpgme++/engineinfo.h>
@ -265,9 +266,9 @@ private Q_SLOTS:
if (err2) { if (err2) {
if (err2.code() == GPG_ERR_GENERAL) { if (err2.code() == GPG_ERR_GENERAL) {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n"
"Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(err2.asString()))); "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2))));
} else { } else {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2))));
} }
} }
}); });
@ -321,9 +322,9 @@ private Q_SLOTS:
if (err2) { if (err2) {
if (err2.code() == GPG_ERR_GENERAL) { if (err2.code() == GPG_ERR_GENERAL) {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n" QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.\n"
"Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(err2.asString()))); "Hint: Run with GPGMEPP_INTERACTOR_DEBUG=stderr to debug the edit interaction.").arg(errorAsString(err2))));
} else { } else {
QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2))));
} }
} }
}); });