aboutsummaryrefslogtreecommitdiffstats
path: root/lang/qt/src
diff options
context:
space:
mode:
authorIngo Klöcker <[email protected]>2024-07-04 16:19:56 +0000
committerIngo Klöcker <[email protected]>2024-07-05 08:05:51 +0000
commitf6d020e24fb64cfba5e80cef7f80cad15f08cc3c (patch)
treef4b268730526013c6175cbe8d3cc0523fedb448c /lang/qt/src
parentcpp: Deprecate Error::asString and update users (diff)
downloadgpgme-f6d020e24fb64cfba5e80cef7f80cad15f08cc3c.tar.gz
gpgme-f6d020e24fb64cfba5e80cef7f80cad15f08cc3c.zip
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
Diffstat (limited to 'lang/qt/src')
-rw-r--r--lang/qt/src/debug.cpp4
-rw-r--r--lang/qt/src/qgpgmedecryptverifyjob.cpp5
-rw-r--r--lang/qt/src/qgpgmenewcryptoconfig.cpp2
-rw-r--r--lang/qt/src/qgpgmewkdlookupjob.cpp7
-rw-r--r--lang/qt/src/threadedjobmixin.cpp7
-rw-r--r--lang/qt/src/util.h11
6 files changed, 25 insertions, 11 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<DecryptionResult, VerificationResult> 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<DecryptionResult, VerificationResult> 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 <gpgme++/context.h>
@@ -62,7 +63,7 @@ static GpgME::Error startDirmngr(Context *assuanCtx)
auto spawnCtx = std::unique_ptr<Context>{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 <gpgme++/data.h>
@@ -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 <QStringList>
+#include <gpgme++/error.h>
+
#include <gpgme.h>
#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);
}
+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);
QStringList toFingerprints(const std::vector<GpgME::Key> &keys);