From 899709300734acc2bac01b1d57a1fd8fe2a6d923 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Thu, 17 May 2018 21:37:46 +0200 Subject: [PATCH] core: Avoid confusing log message when legacy client connects Older clients don't report the features they support, which resulted in a log message listing all features as missing if such a client connected. Handle this special case by checking if any client feature is enabled, and if not, providing a different log message to avoid user confusion. --- src/common/quassel.cpp | 8 ++++++++ src/core/coreauthhandler.cpp | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/quassel.cpp b/src/common/quassel.cpp index 583dd13f..c75836a3 100644 --- a/src/common/quassel.cpp +++ b/src/common/quassel.cpp @@ -20,7 +20,9 @@ #include "quassel.h" +#include #include + #include #if !defined Q_OS_WIN && !defined Q_OS_MAC # include @@ -720,7 +722,13 @@ bool Quassel::Features::isEnabled(Feature feature) const QStringList Quassel::Features::toStringList(bool enabled) const { + // Check if any feature is enabled + if (!enabled && std::all_of(_features.cbegin(), _features.cend(), [](bool feature) { return !feature; })) { + return QStringList{} << "NoFeatures"; + } + QStringList result; + // TODO Qt5: Use QMetaEnum::fromType() auto featureEnum = Quassel::staticMetaObject.enumerator(Quassel::staticMetaObject.indexOfEnumerator("Feature")); for (quint32 i = 0; i < _features.size(); ++i) { diff --git a/src/core/coreauthhandler.cpp b/src/core/coreauthhandler.cpp index 913968bc..6cccaf87 100644 --- a/src/core/coreauthhandler.cpp +++ b/src/core/coreauthhandler.cpp @@ -246,8 +246,12 @@ void CoreAuthHandler::handle(const Login &msg) const auto &clientFeatures = _peer->features(); auto unsupported = clientFeatures.toStringList(false); if (!unsupported.isEmpty()) { - quInfo() << qPrintable(tr("Client does not support the following features: %1").arg(unsupported.join(", "))); + if (unsupported.contains("NoFeatures")) + quInfo() << qPrintable(tr("Client does not support extended features.")); + else + quInfo() << qPrintable(tr("Client does not support the following features: %1").arg(unsupported.join(", "))); } + if (!clientFeatures.unknownFeatures().isEmpty()) { quInfo() << qPrintable(tr("Client supports unknown features: %1").arg(clientFeatures.unknownFeatures().join(", "))); } -- 2.20.1