Have the PeerFactory provide the list of supported protocols
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 23 Jan 2014 21:30:59 +0000 (22:30 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 23 Jan 2014 21:30:59 +0000 (22:30 +0100)
... and make use of that in ClientAuthHandler, instead of hardcoding
the available protocols there.

src/client/clientauthhandler.cpp
src/common/peerfactory.cpp
src/common/peerfactory.h

index 415a7dd..74bb295 100644 (file)
@@ -180,7 +180,14 @@ void ClientAuthHandler::onSocketConnected()
         stream << magic;
 
         // here goes the list of protocols we support, in order of preference
-        stream << ((quint32)Protocol::LegacyProtocol | 0x80000000); // end list
+        PeerFactory::ProtoList protos = PeerFactory::supportedProtocols();
+        for (int i = 0; i < protos.count(); ++i) {
+            quint32 reply = protos[i].first;
+            reply |= protos[i].second<<8;
+            if (i == protos.count() - 1)
+                reply |= 0x80000000; // end list
+            stream << reply;
+        }
 
         socket()->flush(); // make sure the probing data is sent immediately
         return;
index 9d55fcc..32ea16a 100644 (file)
 
 #include "protocols/legacy/legacypeer.h"
 
+
+PeerFactory::ProtoList PeerFactory::supportedProtocols()
+{
+    ProtoList result;
+    result.append(ProtoDescriptor(Protocol::LegacyProtocol, 0));
+    return result;
+}
+
+
 RemotePeer *PeerFactory::createPeer(const ProtoDescriptor &protocol, AuthHandler *authHandler, QTcpSocket *socket, QObject *parent)
 {
     return createPeer(ProtoList() << protocol, authHandler, socket, parent);
index 9673711..79a0c35 100644 (file)
@@ -39,6 +39,8 @@ public:
     typedef QPair<Protocol::Type, quint16> ProtoDescriptor;
     typedef QVector<ProtoDescriptor> ProtoList;
 
+    static ProtoList supportedProtocols();
+
     static RemotePeer *createPeer(const ProtoDescriptor &protocol, AuthHandler *authHandler, QTcpSocket *socket, QObject *parent = 0);
     static RemotePeer *createPeer(const ProtoList &protocols, AuthHandler *authHandler, QTcpSocket *socket, QObject *parent = 0);