core: Avoid confusing log message when legacy client connects
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 17 May 2018 19:37:46 +0000 (21:37 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 17 May 2018 19:45:53 +0000 (21:45 +0200)
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
src/core/coreauthhandler.cpp

index 583dd13..c75836a 100644 (file)
@@ -20,7 +20,9 @@
 
 #include "quassel.h"
 
 
 #include "quassel.h"
 
+#include <algorithm>
 #include <iostream>
 #include <iostream>
+
 #include <signal.h>
 #if !defined Q_OS_WIN && !defined Q_OS_MAC
 #  include <sys/types.h>
 #include <signal.h>
 #if !defined Q_OS_WIN && !defined Q_OS_MAC
 #  include <sys/types.h>
@@ -720,7 +722,13 @@ bool Quassel::Features::isEnabled(Feature feature) const
 
 QStringList Quassel::Features::toStringList(bool enabled) 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;
     QStringList result;
+
     // TODO Qt5: Use QMetaEnum::fromType()
     auto featureEnum = Quassel::staticMetaObject.enumerator(Quassel::staticMetaObject.indexOfEnumerator("Feature"));
     for (quint32 i = 0; i < _features.size(); ++i) {
     // TODO Qt5: Use QMetaEnum::fromType()
     auto featureEnum = Quassel::staticMetaObject.enumerator(Quassel::staticMetaObject.indexOfEnumerator("Feature"));
     for (quint32 i = 0; i < _features.size(); ++i) {
index 913968b..6cccaf8 100644 (file)
@@ -246,8 +246,12 @@ void CoreAuthHandler::handle(const Login &msg)
     const auto &clientFeatures = _peer->features();
     auto unsupported = clientFeatures.toStringList(false);
     if (!unsupported.isEmpty()) {
     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(", ")));
     }
     if (!clientFeatures.unknownFeatures().isEmpty()) {
         quInfo() << qPrintable(tr("Client supports unknown features: %1").arg(clientFeatures.unknownFeatures().join(", ")));
     }