diff options
Diffstat (limited to 'lang/qt/src')
-rw-r--r-- | lang/qt/src/debug.cpp | 4 | ||||
-rw-r--r-- | lang/qt/src/qgpgmedecryptverifyjob.cpp | 5 | ||||
-rw-r--r-- | lang/qt/src/qgpgmenewcryptoconfig.cpp | 2 | ||||
-rw-r--r-- | lang/qt/src/qgpgmewkdlookupjob.cpp | 7 | ||||
-rw-r--r-- | lang/qt/src/threadedjobmixin.cpp | 7 | ||||
-rw-r--r-- | lang/qt/src/util.h | 11 |
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); |