From: Manuel Nickschas Date: Thu, 17 May 2018 19:37:46 +0000 (+0200) Subject: core: Avoid confusing log message when legacy client connects X-Git-Tag: travis-deploy-test~121 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=899709300734acc2bac01b1d57a1fd8fe2a6d923;hp=fa3449061f17d7e8db1387f0758fd052f22f4c3b 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. --- 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(", "))); }