From ec9690cf5ce85f43997ac2a3abd3e728012aee4a Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Wed, 19 Feb 2020 11:12:43 +0100 Subject: [PATCH] qt: Change logging category * lang/qt/src/*: Change logging category to macro to QGPGME_LOG. -- The old logging category macro had a typo and this way we are more consistent with other logging rules. For example you could write gpg.* in the logging conf. --- NEWS | 3 +++ lang/qt/src/Makefile.am | 4 ++-- lang/qt/src/gpgme_backend_debug.cpp | 14 ------------- lang/qt/src/gpgme_backend_debug.h | 11 ---------- lang/qt/src/qgpgme_debug.cpp | 14 +++++++++++++ lang/qt/src/qgpgme_debug.h | 11 ++++++++++ lang/qt/src/qgpgmedecryptverifyjob.cpp | 8 ++++---- lang/qt/src/qgpgmegpgcardjob.cpp | 4 ++-- lang/qt/src/qgpgmenewcryptoconfig.cpp | 26 ++++++++++++------------ lang/qt/src/qgpgmerefreshkeysjob.cpp | 16 +++++++-------- lang/qt/src/qgpgmesecretkeyexportjob.cpp | 2 +- 11 files changed, 58 insertions(+), 55 deletions(-) delete mode 100644 lang/qt/src/gpgme_backend_debug.cpp delete mode 100644 lang/qt/src/gpgme_backend_debug.h create mode 100644 lang/qt/src/qgpgme_debug.cpp create mode 100644 lang/qt/src/qgpgme_debug.h diff --git a/NEWS b/NEWS index d87bc4ff..f5dd953d 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,9 @@ Noteworthy changes in version 1.14.0 (unreleased) * qt: Added job API for gpg-card. + * qt: The logging category has been changed to gpg.qgpgme to be more + consistent with other qt logging categories. + * Interface changes relative to the 1.13.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gpgme_user_id_t EXTENDED: New field 'uidhash'. diff --git a/lang/qt/src/Makefile.am b/lang/qt/src/Makefile.am index cbf6a530..16a2094f 100644 --- a/lang/qt/src/Makefile.am +++ b/lang/qt/src/Makefile.am @@ -20,7 +20,7 @@ # 02111-1307, USA lib_LTLIBRARIES = libqgpgme.la EXTRA_DIST = QGpgmeConfig.cmake.in.in QGpgmeConfigVersion.cmake.in \ - gpgme_backend_debug.h qgpgme_version.h.in \ + qgpgme_debug.h qgpgme_version.h.in \ QGpgmeConfig.cmake.in.in qgpgme_sources = \ @@ -35,7 +35,7 @@ qgpgme_sources = \ qgpgmesecretkeyexportjob.cpp qgpgmesignencryptjob.cpp \ qgpgmesignjob.cpp qgpgmesignkeyjob.cpp qgpgmeverifydetachedjob.cpp \ qgpgmeverifyopaquejob.cpp threadedjobmixin.cpp \ - qgpgmekeyformailboxjob.cpp gpgme_backend_debug.cpp \ + qgpgmekeyformailboxjob.cpp qgpgme_debug.cpp \ qgpgmetofupolicyjob.cpp qgpgmequickjob.cpp \ defaultkeygenerationjob.cpp qgpgmewkspublishjob.cpp \ qgpgmegpgcardjob.cpp \ diff --git a/lang/qt/src/gpgme_backend_debug.cpp b/lang/qt/src/gpgme_backend_debug.cpp deleted file mode 100644 index 6efe932e..00000000 --- a/lang/qt/src/gpgme_backend_debug.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// This file is autogenerated by CMake: DO NOT EDIT - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "gpgme_backend_debug.h" - - -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) -Q_LOGGING_CATEGORY(GPGPME_BACKEND_LOG, "log_gpgme_backend", QtWarningMsg) -#else -Q_LOGGING_CATEGORY(GPGPME_BACKEND_LOG, "log_gpgme_backend") -#endif diff --git a/lang/qt/src/gpgme_backend_debug.h b/lang/qt/src/gpgme_backend_debug.h deleted file mode 100644 index 5ac93db2..00000000 --- a/lang/qt/src/gpgme_backend_debug.h +++ /dev/null @@ -1,11 +0,0 @@ -// This file is autogenerated by CMake: DO NOT EDIT - -#ifndef GPGPME_BACKEND_LOG_H -#define GPGPME_BACKEND_LOG_H - -#include - -Q_DECLARE_LOGGING_CATEGORY(GPGPME_BACKEND_LOG) - - -#endif diff --git a/lang/qt/src/qgpgme_debug.cpp b/lang/qt/src/qgpgme_debug.cpp new file mode 100644 index 00000000..4ed859e2 --- /dev/null +++ b/lang/qt/src/qgpgme_debug.cpp @@ -0,0 +1,14 @@ +// This file is autogenerated by CMake: DO NOT EDIT + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include "qgpgme_debug.h" + + +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) +Q_LOGGING_CATEGORY(QGPGME_LOG, "gpg.qgpgme", QtWarningMsg) +#else +Q_LOGGING_CATEGORY(QGPGME_LOG, "gpg.qgpgme") +#endif diff --git a/lang/qt/src/qgpgme_debug.h b/lang/qt/src/qgpgme_debug.h new file mode 100644 index 00000000..38c16ad3 --- /dev/null +++ b/lang/qt/src/qgpgme_debug.h @@ -0,0 +1,11 @@ +// This file is autogenerated by CMake: DO NOT EDIT + +#ifndef QGPGME_LOG_H +#define QGPGME_LOG_H + +#include + +Q_DECLARE_LOGGING_CATEGORY(QGPGME_LOG) + + +#endif diff --git a/lang/qt/src/qgpgmedecryptverifyjob.cpp b/lang/qt/src/qgpgmedecryptverifyjob.cpp index 9b3f73db..5f9a8abe 100644 --- a/lang/qt/src/qgpgmedecryptverifyjob.cpp +++ b/lang/qt/src/qgpgmedecryptverifyjob.cpp @@ -46,7 +46,7 @@ #include "data.h" #include -#include "gpgme_backend_debug.h" +#include "qgpgme_debug.h" #include @@ -68,7 +68,7 @@ static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread const std::weak_ptr &plainText_) { - qCDebug(GPGPME_BACKEND_LOG); + qCDebug(QGPGME_LOG); const std::shared_ptr cipherText = cipherText_.lock(); const std::shared_ptr plainText = plainText_.lock(); @@ -86,7 +86,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(GPGPME_BACKEND_LOG) << "End no plainText. Error: " << ae; + qCDebug(QGPGME_LOG) << "End no plainText. Error: " << ae; return std::make_tuple(res.first, res.second, out.data(), log, ae); } else { QGpgME::QIODeviceDataProvider out(plainText); @@ -95,7 +95,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(GPGPME_BACKEND_LOG) << "End plainText. Error: " << ae; + qCDebug(QGPGME_LOG) << "End plainText. Error: " << ae; return std::make_tuple(res.first, res.second, QByteArray(), log, ae); } diff --git a/lang/qt/src/qgpgmegpgcardjob.cpp b/lang/qt/src/qgpgmegpgcardjob.cpp index cb59a271..ae0bf72c 100644 --- a/lang/qt/src/qgpgmegpgcardjob.cpp +++ b/lang/qt/src/qgpgmegpgcardjob.cpp @@ -41,7 +41,7 @@ #include #include #include "util.h" -#include "gpgme_backend_debug.h" +#include "qgpgme_debug.h" /* We cannot have a timeout because key generation can * take ages. Well maybe 10 minutes. */ @@ -86,7 +86,7 @@ static QGpgMEGpgCardJob::result_type do_work(const QStringList &cmds, const QStr proc.setProgram(path); proc.setArguments(args); - qCDebug(GPGPME_BACKEND_LOG) << "Executing:" << path << args; + qCDebug(QGPGME_LOG) << "Executing:" << path << args; proc.start(); if (!proc.waitForStarted()) { return std::make_tuple (QString(), QString(), 1, QString(), Error()); diff --git a/lang/qt/src/qgpgmenewcryptoconfig.cpp b/lang/qt/src/qgpgmenewcryptoconfig.cpp index 070ab697..fba20fa6 100644 --- a/lang/qt/src/qgpgmenewcryptoconfig.cpp +++ b/lang/qt/src/qgpgmenewcryptoconfig.cpp @@ -39,7 +39,7 @@ #include "qgpgmenewcryptoconfig.h" #include -#include "gpgme_backend_debug.h" +#include "qgpgme_debug.h" #include #include @@ -101,14 +101,14 @@ void QGpgMENewCryptoConfig::reloadConfiguration(bool) << "components:\n"; std::copy(components.begin(), components.end(), std::ostream_iterator(ss, "\n")); - qCDebug(GPGPME_BACKEND_LOG) << ss.str().c_str(); + qCDebug(QGPGME_LOG) << ss.str().c_str(); } #endif #if 0 TODO port? if (error && showErrors) { const QString wmsg = i18n("Failed to execute gpgconf:

%1

", QString::fromLocal8Bit(error.asString())); - qCWarning(GPGPME_BACKEND_LOG) << wmsg; // to see it from test_cryptoconfig.cpp + qCWarning(QGPGME_LOG) << wmsg; // to see it from test_cryptoconfig.cpp KMessageBox::error(0, wmsg); } #endif @@ -183,7 +183,7 @@ void QGpgMENewCryptoConfigComponent::setComponent(const Component &component) group->m_entryNames.push_back(name); group->m_entriesByName[name] = entry; } else { - qCWarning(GPGPME_BACKEND_LOG) << "found no group for entry" << o.name() << "of component" << name(); + qCWarning(QGPGME_LOG) << "found no group for entry" << o.name() << "of component" << name(); } if (group) { m_groupsByName[group->name()] = group; @@ -222,7 +222,7 @@ void QGpgMENewCryptoConfigComponent::sync(bool runtime) { Q_UNUSED(runtime) // runtime is always set by engine_gpgconf if (const Error err = m_component.save()) { - qCWarning(GPGPME_BACKEND_LOG) << ":" + qCWarning(QGPGME_LOG) << ":" << "Error from gpgconf while saving configuration: %1" << QString::fromLocal8Bit(err.asString()); } @@ -279,7 +279,7 @@ static QString urlpart_encode(const QString &str) QString enc(str); enc.replace(QLatin1Char('%'), QStringLiteral("%25")); // first! enc.replace(QLatin1Char(':'), QStringLiteral("%3a")); - //qCDebug(GPGPME_BACKEND_LOG) <<" urlpart_encode:" << str <<" ->" << enc; + //qCDebug(QGPGME_LOG) <<" urlpart_encode:" << str <<" ->" << enc; return enc; } @@ -326,7 +326,7 @@ QVariant QGpgMENewCryptoConfigEntry::stringToValue(const QString &str, bool unes bool ok = true; const QVariant v = str.isEmpty() ? 0U : str.toUInt(&ok); if (!ok) { - qCWarning(GPGPME_BACKEND_LOG) << "list-of-none should have an unsigned int as value:" << str; + qCWarning(QGPGME_LOG) << "list-of-none should have an unsigned int as value:" << str; } return v; } @@ -340,7 +340,7 @@ QVariant QGpgMENewCryptoConfigEntry::stringToValue(const QString &str, bool unes continue; } else if (unescape) { if (val[0] != '"') { // see README.gpgconf - qCWarning(GPGPME_BACKEND_LOG) << "String value should start with '\"' :" << val; + qCWarning(QGPGME_LOG) << "String value should start with '\"' :" << val; } val = val.mid(1); } @@ -355,7 +355,7 @@ QVariant QGpgMENewCryptoConfigEntry::stringToValue(const QString &str, bool unes return QVariant(QString()); // not set [ok with lists too?] } else if (unescape) { if (val[0] != '"') { // see README.gpgconf - qCWarning(GPGPME_BACKEND_LOG) << "String value should start with '\"' :" << val; + qCWarning(QGPGME_LOG) << "String value should start with '\"' :" << val; } val = val.mid(1); } @@ -369,7 +369,7 @@ QGpgMENewCryptoConfigEntry::~QGpgMENewCryptoConfigEntry() { #ifndef NDEBUG if (!s_duringClear && m_option.dirty()) - qCWarning(GPGPME_BACKEND_LOG) << "Deleting a QGpgMENewCryptoConfigEntry that was modified (" << m_option.description() << ")" + qCWarning(QGPGME_LOG) << "Deleting a QGpgMENewCryptoConfigEntry that was modified (" << m_option.description() << ")" << "You forgot to call sync() (to commit) or clear() (to discard)"; #endif } @@ -480,7 +480,7 @@ static QUrl parseURL(int mRealArgType, const QString &str) if (ok) { url.setPort(port); } else if (!it->isEmpty()) { - qCWarning(GPGPME_BACKEND_LOG) << "parseURL: malformed LDAP server port, ignoring: \"" << *it << "\""; + qCWarning(QGPGME_LOG) << "parseURL: malformed LDAP server port, ignoring: \"" << *it << "\""; } const QString userName = urlpart_decode(*it++); @@ -494,7 +494,7 @@ static QUrl parseURL(int mRealArgType, const QString &str) url.setQuery(urlpart_decode(*it)); return url; } else { - qCWarning(GPGPME_BACKEND_LOG) << "parseURL: malformed LDAP server:" << str; + qCWarning(QGPGME_LOG) << "parseURL: malformed LDAP server:" << str; } } // other URLs : assume wellformed URL syntax. @@ -700,7 +700,7 @@ QString QGpgMENewCryptoConfigEntry::toString(bool escape) const } } QString res = lst.join(","); - //qCDebug(GPGPME_BACKEND_LOG) <<"toString:" << res; + //qCDebug(QGPGME_LOG) <<"toString:" << res; return res; } else { // normal string QString res = mValue.toString(); diff --git a/lang/qt/src/qgpgmerefreshkeysjob.cpp b/lang/qt/src/qgpgmerefreshkeysjob.cpp index ae862e04..5f78f2ae 100644 --- a/lang/qt/src/qgpgmerefreshkeysjob.cpp +++ b/lang/qt/src/qgpgmerefreshkeysjob.cpp @@ -41,7 +41,7 @@ #include "qgpgmerefreshkeysjob.h" #include -#include "gpgme_backend_debug.h" +#include "qgpgme_debug.h" #include "context.h" @@ -157,18 +157,18 @@ void QGpgME::QGpgMERefreshKeysJob::slotStatus(QProcess *proc, const QString &typ if (type == QLatin1String("ERROR")) { if (args.size() < 2) { - qCDebug(GPGPME_BACKEND_LOG) << "not recognising ERROR with < 2 args!"; + qCDebug(QGPGME_LOG) << "not recognising ERROR with < 2 args!"; return; } const int source = (*++it).toInt(&ok); if (!ok) { - qCDebug(GPGPME_BACKEND_LOG) << "expected number for first ERROR arg, got something else"; + qCDebug(QGPGME_LOG) << "expected number for first ERROR arg, got something else"; return; } ok = false; const int code = (*++it).toInt(&ok); if (!ok) { - qCDebug(GPGPME_BACKEND_LOG) << "expected number for second ERROR arg, got something else"; + qCDebug(QGPGME_LOG) << "expected number for second ERROR arg, got something else"; return; } mError = GpgME::Error::fromCode(code, source); @@ -176,26 +176,26 @@ void QGpgME::QGpgMERefreshKeysJob::slotStatus(QProcess *proc, const QString &typ } else if (type == QLatin1String("PROGRESS")) { if (args.size() < 4) { - qCDebug(GPGPME_BACKEND_LOG) << "not recognising PROGRESS with < 4 args!"; + qCDebug(QGPGME_LOG) << "not recognising PROGRESS with < 4 args!"; return; } const QString what = *++it; ok = false; (*++it).toInt(&ok); if (!ok) { - qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"type\", got something else"; + qCDebug(QGPGME_LOG) << "expected number for \"type\", got something else"; return; } ok = false; const int cur = (*++it).toInt(&ok); if (!ok) { - qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"cur\", got something else"; + qCDebug(QGPGME_LOG) << "expected number for \"cur\", got something else"; return; } ok = false; const int total = (*++it).toInt(&ok); if (!ok) { - qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"total\", got something else"; + qCDebug(QGPGME_LOG) << "expected number for \"total\", got something else"; return; } // TODO port diff --git a/lang/qt/src/qgpgmesecretkeyexportjob.cpp b/lang/qt/src/qgpgmesecretkeyexportjob.cpp index d77a50ab..d472bc46 100644 --- a/lang/qt/src/qgpgmesecretkeyexportjob.cpp +++ b/lang/qt/src/qgpgmesecretkeyexportjob.cpp @@ -39,7 +39,7 @@ #include "qgpgmesecretkeyexportjob.h" #include -#include "gpgme_backend_debug.h" +#include "qgpgme_debug.h" #include "context.h" #include "data.h"