From f6d020e24fb64cfba5e80cef7f80cad15f08cc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Thu, 4 Jul 2024 18:19:56 +0200 Subject: [PATCH] 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 --- lang/qt/src/debug.cpp | 4 +-- lang/qt/src/qgpgmedecryptverifyjob.cpp | 5 +-- lang/qt/src/qgpgmenewcryptoconfig.cpp | 2 +- lang/qt/src/qgpgmewkdlookupjob.cpp | 7 ++-- lang/qt/src/threadedjobmixin.cpp | 7 ++-- lang/qt/src/util.h | 11 +++++++ lang/qt/tests/run-decryptverifyarchivejob.cpp | 3 +- lang/qt/tests/run-decryptverifyjob.cpp | 3 +- lang/qt/tests/run-encryptarchivejob.cpp | 5 +-- lang/qt/tests/run-encryptjob.cpp | 5 +-- lang/qt/tests/run-exportjob.cpp | 3 +- lang/qt/tests/run-importjob.cpp | 2 +- lang/qt/tests/run-receivekeysjob.cpp | 3 +- lang/qt/tests/run-refreshkeysjob.cpp | 11 ++++--- lang/qt/tests/run-signarchivejob.cpp | 3 +- lang/qt/tests/run-signjob.cpp | 3 +- lang/qt/tests/run-verifydetachedjob.cpp | 3 +- lang/qt/tests/run-verifyopaquejob.cpp | 3 +- lang/qt/tests/run-wkdrefreshjob.cpp | 5 +-- lang/qt/tests/t-changeexpiryjob.cpp | 11 ++++--- lang/qt/tests/t-ownertrust.cpp | 3 +- lang/qt/tests/t-remarks.cpp | 3 +- lang/qt/tests/t-tofuinfo.cpp | 3 +- lang/qt/tests/t-trustsignatures.cpp | 33 ++++++++++--------- lang/qt/tests/t-various.cpp | 9 ++--- 25 files changed, 91 insertions(+), 59 deletions(-) diff --git a/lang/qt/src/debug.cpp b/lang/qt/src/debug.cpp index 03244dc6..acde9d42 100644 --- a/lang/qt/src/debug.cpp +++ b/lang/qt/src/debug.cpp @@ -44,9 +44,9 @@ QDebug operator<<(QDebug debug, const GpgME::Error &err) { #ifdef Q_OS_WIN // 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 - const auto errAsString = QString::fromLocal8Bit(err.asString()); + const auto errAsString = QString::fromLocal8Bit(err.asStdString().c_str()); #endif const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << errAsString << " (code: " << err.code() << ", source: " << err.source() << ")"; diff --git a/lang/qt/src/qgpgmedecryptverifyjob.cpp b/lang/qt/src/qgpgmedecryptverifyjob.cpp index 2cd857b6..24930693 100644 --- a/lang/qt/src/qgpgmedecryptverifyjob.cpp +++ b/lang/qt/src/qgpgmedecryptverifyjob.cpp @@ -39,6 +39,7 @@ #include "qgpgmedecryptverifyjob.h" #include "dataprovider.h" +#include "debug.h" #include "decryptverifyjob_p.h" #include "util.h" @@ -118,7 +119,7 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread const std::pair res = ctx->decryptAndVerify(indata, outdata); Error 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); } else { QGpgME::QIODeviceDataProvider out(plainText); @@ -127,7 +128,7 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread const std::pair res = ctx->decryptAndVerify(indata, outdata); Error 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); } } diff --git a/lang/qt/src/qgpgmenewcryptoconfig.cpp b/lang/qt/src/qgpgmenewcryptoconfig.cpp index 0615776b..a4782d2f 100644 --- a/lang/qt/src/qgpgmenewcryptoconfig.cpp +++ b/lang/qt/src/qgpgmenewcryptoconfig.cpp @@ -211,7 +211,7 @@ void QGpgMENewCryptoConfigComponent::sync(bool runtime) if (const Error err = m_component.save()) { qCWarning(QGPGME_LOG) << ":" << "Error from gpgconf while saving configuration: %1" - << QString::fromLocal8Bit(err.asString()); + << err; } } diff --git a/lang/qt/src/qgpgmewkdlookupjob.cpp b/lang/qt/src/qgpgmewkdlookupjob.cpp index 25f0a2bf..76f5b728 100644 --- a/lang/qt/src/qgpgmewkdlookupjob.cpp +++ b/lang/qt/src/qgpgmewkdlookupjob.cpp @@ -37,6 +37,7 @@ #include "qgpgmewkdlookupjob.h" +#include "debug.h" #include "qgpgme_debug.h" #include @@ -62,7 +63,7 @@ static GpgME::Error startDirmngr(Context *assuanCtx) auto spawnCtx = std::unique_ptr{Context::createForEngine(SpawnEngine, &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"); // 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 // support WKD or that the domain doesn't exist (on subsequent requests // using dirmngr's internal cache) - qCDebug(QGPGME_LOG) << "WKD_GET returned" << err.asString() << "; ignoring..."; + qCDebug(QGPGME_LOG) << "WKD_GET returned" << err << "; ignoring..."; err = {}; } if (err) { - qCDebug(QGPGME_LOG) << "WKD_GET failed with" << err.asString(); + qCDebug(QGPGME_LOG) << "WKD_GET failed with" << err; } return err; diff --git a/lang/qt/src/threadedjobmixin.cpp b/lang/qt/src/threadedjobmixin.cpp index c6372c0d..c0485325 100644 --- a/lang/qt/src/threadedjobmixin.cpp +++ b/lang/qt/src/threadedjobmixin.cpp @@ -39,6 +39,7 @@ #include "threadedjobmixin.h" #include "dataprovider.h" +#include "util.h" #include @@ -82,7 +83,7 @@ QString _detail::audit_log_as_html(Context *ctx, GpgME::Error &err) if (ctx->protocol() == OpenPGP) { if ((err = ctx->getAuditLog(data, OpenPGPAuditLogFlags))) { - return QString::fromLocal8Bit(err.asString()); + return errorAsString(err); } const QByteArray ba = dp.data(); return markupDiagnostics(stringFromGpgOutput(ba)); @@ -91,12 +92,12 @@ QString _detail::audit_log_as_html(Context *ctx, GpgME::Error &err) if (ctx->protocol() == CMS) { if ((err = ctx->lastError())) { if ((err = ctx->getAuditLog(data, Context::DiagnosticAuditLog))) { - return QString::fromLocal8Bit(err.asString()); + return errorAsString(err); } const QByteArray ba = dp.data(); return markupDiagnostics(stringFromGpgOutput(ba)); } else if ((err = ctx->getAuditLog(data, CMSAuditLogFlags))) { - return QString::fromLocal8Bit(err.asString()); + return errorAsString(err); } return QString::fromUtf8(dp.data()); } diff --git a/lang/qt/src/util.h b/lang/qt/src/util.h index cdf38981..fcd1187e 100644 --- a/lang/qt/src/util.h +++ b/lang/qt/src/util.h @@ -36,6 +36,8 @@ #include +#include + #include #include @@ -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); } +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 toStrings(const QStringList &l); QStringList toFingerprints(const std::vector &keys); diff --git a/lang/qt/tests/run-decryptverifyarchivejob.cpp b/lang/qt/tests/run-decryptverifyarchivejob.cpp index 38cf6b86..36d023ec 100644 --- a/lang/qt/tests/run-decryptverifyarchivejob.cpp +++ b/lang/qt/tests/run-decryptverifyarchivejob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include @@ -114,7 +115,7 @@ int main(int argc, char **argv) const auto err = job->startIt(); 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; } diff --git a/lang/qt/tests/run-decryptverifyjob.cpp b/lang/qt/tests/run-decryptverifyjob.cpp index 4d2e947c..da8ec9fe 100644 --- a/lang/qt/tests/run-decryptverifyjob.cpp +++ b/lang/qt/tests/run-decryptverifyjob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include @@ -155,7 +156,7 @@ int main(int argc, char **argv) err = job->startIt(); } 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; } diff --git a/lang/qt/tests/run-encryptarchivejob.cpp b/lang/qt/tests/run-encryptarchivejob.cpp index 2d9c09a3..87781fd9 100644 --- a/lang/qt/tests/run-encryptarchivejob.cpp +++ b/lang/qt/tests/run-encryptarchivejob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include #include @@ -176,7 +177,7 @@ int main(int argc, char **argv) err = job->startIt(); } 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; } } else { @@ -207,7 +208,7 @@ int main(int argc, char **argv) err = job->startIt(); } 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; } } diff --git a/lang/qt/tests/run-encryptjob.cpp b/lang/qt/tests/run-encryptjob.cpp index 47e6e248..14c8ea44 100644 --- a/lang/qt/tests/run-encryptjob.cpp +++ b/lang/qt/tests/run-encryptjob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include #include @@ -157,7 +158,7 @@ int main(int argc, char **argv) err = job->startIt(); } 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; } } else { @@ -189,7 +190,7 @@ int main(int argc, char **argv) err = job->startIt(); } 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; } } diff --git a/lang/qt/tests/run-exportjob.cpp b/lang/qt/tests/run-exportjob.cpp index 6cb43c22..ed6f8912 100644 --- a/lang/qt/tests/run-exportjob.cpp +++ b/lang/qt/tests/run-exportjob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include @@ -106,7 +107,7 @@ int main(int argc, char *argv[]) QObject::connect(job, &QGpgME::ExportJob::result, &app, [&app] (const GpgME::Error &err, const QByteArray &keyData, const QString &, const GpgME::Error &) { if (err) { - cerr << "The ChangeExpiryJob failed with" << err.asString() << "."; + cerr << "The ChangeExpiryJob failed with" << err << "."; app.exit(1); return; } diff --git a/lang/qt/tests/run-importjob.cpp b/lang/qt/tests/run-importjob.cpp index a0b9ffc1..67ee73f3 100644 --- a/lang/qt/tests/run-importjob.cpp +++ b/lang/qt/tests/run-importjob.cpp @@ -89,7 +89,7 @@ int main(int argc, char **argv) const auto keyData = f.readAll(); auto job = (protocol == GpgME::CMS ? QGpgME::smime() : QGpgME::openpgp())->importJob(); 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')) { qDebug().noquote() << line; } diff --git a/lang/qt/tests/run-receivekeysjob.cpp b/lang/qt/tests/run-receivekeysjob.cpp index 6bfe047f..44553218 100644 --- a/lang/qt/tests/run-receivekeysjob.cpp +++ b/lang/qt/tests/run-receivekeysjob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include #include @@ -58,7 +59,7 @@ int main(int argc, char **argv) auto job = QGpgME::openpgp()->receiveKeysJob(); 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; return 0; diff --git a/lang/qt/tests/run-refreshkeysjob.cpp b/lang/qt/tests/run-refreshkeysjob.cpp index e2bf7d1f..ad653a54 100644 --- a/lang/qt/tests/run-refreshkeysjob.cpp +++ b/lang/qt/tests/run-refreshkeysjob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include #include @@ -111,10 +112,10 @@ int main(int argc, char **argv) return 1; } 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) { - 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; 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())}); if (err) { - std::cerr << "Error: " << err.asString() << std::endl; + std::cerr << "Error: " << err << std::endl; return 1; } } else { @@ -141,12 +142,12 @@ int main(int argc, char **argv) return 1; } 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(); }); const auto err = job->start({key}); if (err) { - std::cerr << "Error: " << err.asString() << std::endl; + std::cerr << "Error: " << err << std::endl; return 1; } } diff --git a/lang/qt/tests/run-signarchivejob.cpp b/lang/qt/tests/run-signarchivejob.cpp index c832372a..3152507e 100644 --- a/lang/qt/tests/run-signarchivejob.cpp +++ b/lang/qt/tests/run-signarchivejob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include @@ -168,7 +169,7 @@ int main(int argc, char **argv) err = job->startIt(); } 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; } diff --git a/lang/qt/tests/run-signjob.cpp b/lang/qt/tests/run-signjob.cpp index a85c6034..9c2ebcc2 100644 --- a/lang/qt/tests/run-signjob.cpp +++ b/lang/qt/tests/run-signjob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include @@ -159,7 +160,7 @@ int main(int argc, char **argv) err = job->startIt(); } 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; } diff --git a/lang/qt/tests/run-verifydetachedjob.cpp b/lang/qt/tests/run-verifydetachedjob.cpp index 65274383..60ba5470 100644 --- a/lang/qt/tests/run-verifydetachedjob.cpp +++ b/lang/qt/tests/run-verifydetachedjob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include @@ -113,7 +114,7 @@ int main(int argc, char **argv) job->setSignedFile(options.signedFile); err = job->startIt(); 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; } diff --git a/lang/qt/tests/run-verifyopaquejob.cpp b/lang/qt/tests/run-verifyopaquejob.cpp index 080c988c..09578430 100644 --- a/lang/qt/tests/run-verifyopaquejob.cpp +++ b/lang/qt/tests/run-verifyopaquejob.cpp @@ -34,6 +34,7 @@ #include "config.h" #endif +#include #include #include @@ -152,7 +153,7 @@ int main(int argc, char **argv) err = job->startIt(); } 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; } diff --git a/lang/qt/tests/run-wkdrefreshjob.cpp b/lang/qt/tests/run-wkdrefreshjob.cpp index 85110b0d..17bad83d 100644 --- a/lang/qt/tests/run-wkdrefreshjob.cpp +++ b/lang/qt/tests/run-wkdrefreshjob.cpp @@ -35,6 +35,7 @@ #include "config.h" #endif +#include #include #include @@ -121,7 +122,7 @@ int main(int argc, char **argv) return 1; } 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; } 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}); } if (err) { - std::cerr << "Error: " << err.asString() << std::endl; + std::cerr << "Error: " << err << std::endl; return 1; } diff --git a/lang/qt/tests/t-changeexpiryjob.cpp b/lang/qt/tests/t-changeexpiryjob.cpp index 54a54aeb..b64bf798 100644 --- a/lang/qt/tests/t-changeexpiryjob.cpp +++ b/lang/qt/tests/t-changeexpiryjob.cpp @@ -40,6 +40,7 @@ #include #include #include "protocol.h" +#include "util.h" #include #include @@ -84,7 +85,7 @@ private Q_SLOTS: this, [this] (const GpgME::Error &err2, const QString &, const GpgME::Error &) { Q_EMIT asyncDone(); 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 &) { Q_EMIT asyncDone(); 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 &) { Q_EMIT asyncDone(); 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 &) { Q_EMIT asyncDone(); 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 &) { Q_EMIT asyncDone(); if (err2) { - QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(err2.asString()))); + QFAIL(qPrintable(QString("The ChangeExpiryJob failed with '%1'.").arg(errorAsString(err2)))); } }); diff --git a/lang/qt/tests/t-ownertrust.cpp b/lang/qt/tests/t-ownertrust.cpp index bb2df08a..653304e4 100644 --- a/lang/qt/tests/t-ownertrust.cpp +++ b/lang/qt/tests/t-ownertrust.cpp @@ -37,6 +37,7 @@ #include #include #include +#include "debug.h" #include "keylistjob.h" #include "protocol.h" #include @@ -69,7 +70,7 @@ private Q_SLOTS: connect(job2, &ChangeOwnerTrustJob::result, this, [this](Error e) { if (e) { - qDebug() << "Error in result: " << e.asString(); + qDebug() << "Error in result: " << e; } QVERIFY(!e); Q_EMIT asyncDone(); diff --git a/lang/qt/tests/t-remarks.cpp b/lang/qt/tests/t-remarks.cpp index 86a5f6a5..b7de4ac4 100644 --- a/lang/qt/tests/t-remarks.cpp +++ b/lang/qt/tests/t-remarks.cpp @@ -39,6 +39,7 @@ #include #include #include +#include "debug.h" #include "keylistjob.h" #include "protocol.h" #include "signkeyjob.h" @@ -90,7 +91,7 @@ public: const GpgME::Error) { Q_EMIT asyncDone(); if (err2) { - qDebug() << "Error: " << err2.asString(); + qDebug() << "Error: " << err2; } QVERIFY(err2); }); diff --git a/lang/qt/tests/t-tofuinfo.cpp b/lang/qt/tests/t-tofuinfo.cpp index b495ec5c..852142cf 100644 --- a/lang/qt/tests/t-tofuinfo.cpp +++ b/lang/qt/tests/t-tofuinfo.cpp @@ -38,6 +38,7 @@ #include #include +#include "debug.h" #include "protocol.h" #include #include "tofupolicyjob.h" @@ -377,7 +378,7 @@ private Q_SLOTS: if (keys.empty()) { qDebug() << "bravo@example.net not found"; - qDebug() << "Error: " << result.error().asString(); + qDebug() << "Error: " << result.error(); const auto homedir = QString::fromLocal8Bit(qgetenv("GNUPGHOME")); qDebug() << "Homedir is: " << homedir; QFileInfo fi(homedir + "/pubring.gpg"); diff --git a/lang/qt/tests/t-trustsignatures.cpp b/lang/qt/tests/t-trustsignatures.cpp index 356b49b7..6d575dff 100644 --- a/lang/qt/tests/t-trustsignatures.cpp +++ b/lang/qt/tests/t-trustsignatures.cpp @@ -40,6 +40,7 @@ #include #include "protocol.h" #include "signkeyjob.h" +#include "util.h" #include #include @@ -94,9 +95,9 @@ private Q_SLOTS: if (err2) { if (err2.code() == GPG_ERR_GENERAL) { 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 { - 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.code() == GPG_ERR_GENERAL) { 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 { - 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.code() == GPG_ERR_GENERAL) { 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 { - 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.code() == GPG_ERR_GENERAL) { 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 { - 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.code() == GPG_ERR_GENERAL) { 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 { - 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.code() == GPG_ERR_GENERAL) { 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 { - 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.code() == GPG_ERR_GENERAL) { 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 { - 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.code() == GPG_ERR_GENERAL) { 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 { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); + QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); } } }); diff --git a/lang/qt/tests/t-various.cpp b/lang/qt/tests/t-various.cpp index 6759f3b6..282fffc2 100644 --- a/lang/qt/tests/t-various.cpp +++ b/lang/qt/tests/t-various.cpp @@ -40,6 +40,7 @@ #include #include "keylistjob.h" #include "protocol.h" +#include "util.h" #include #include #include @@ -265,9 +266,9 @@ private Q_SLOTS: if (err2) { if (err2.code() == GPG_ERR_GENERAL) { 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 { - 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.code() == GPG_ERR_GENERAL) { 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 { - QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(err2.asString()))); + QFAIL(qPrintable(QString("The SignKeyJob failed with '%1'.").arg(errorAsString(err2)))); } } });