Minor cleanups
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 21 Dec 2017 12:44:30 +0000 (13:44 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 21 Dec 2017 12:44:30 +0000 (13:44 +0100)
src/common/message.cpp
src/common/peer.h
src/common/protocol.h
src/common/remotepeer.cpp
src/common/signalproxy.cpp
src/common/signalproxy.h

index a0e480a..911c935 100644 (file)
@@ -21,8 +21,8 @@
 #include "message.h"
 
 #include "util.h"
 #include "message.h"
 
 #include "util.h"
-#include "signalproxy.h"
 #include "peer.h"
 #include "peer.h"
+#include "signalproxy.h"
 
 #include <QDataStream>
 
 
 #include <QDataStream>
 
index 34a5661..fbc1791 100644 (file)
@@ -18,8 +18,7 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef PEER_H
-#define PEER_H
+#pragma once
 
 #include <QAbstractSocket>
 #include <QDataStream>
 
 #include <QAbstractSocket>
 #include <QDataStream>
@@ -27,8 +26,8 @@
 
 #include "authhandler.h"
 #include "protocol.h"
 
 #include "authhandler.h"
 #include "protocol.h"
-#include "signalproxy.h"
 #include "quassel.h"
 #include "quassel.h"
+#include "signalproxy.h"
 
 class Peer : public QObject
 {
 
 class Peer : public QObject
 {
@@ -145,5 +144,3 @@ void Peer::handle(const T &protoMessage)
             return;
     }
 }
             return;
     }
 }
-
-#endif
index 4576080..e626686 100644 (file)
@@ -18,8 +18,7 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef PROTOCOL_H_
-#define PROTOCOL_H_
+#pragma once
 
 #include <QByteArray>
 #include <QDateTime>
 
 #include <QByteArray>
 #include <QDateTime>
@@ -57,7 +56,7 @@ struct HandshakeMessage {
 
 struct RegisterClient : public HandshakeMessage
 {
 
 struct RegisterClient : public HandshakeMessage
 {
-    inline RegisterClient(const QString &clientVersion, const QString &buildDate, bool sslSupported = false, int32_t features = 0)
+    inline RegisterClient(const QString &clientVersion, const QString &buildDate, bool sslSupported = false, quint32 features = 0)
     : clientVersion(clientVersion)
     , buildDate(buildDate)
     , sslSupported(sslSupported)
     : clientVersion(clientVersion)
     , buildDate(buildDate)
     , sslSupported(sslSupported)
@@ -68,7 +67,7 @@ struct RegisterClient : public HandshakeMessage
 
     // this is only used by the LegacyProtocol in compat mode
     bool sslSupported;
 
     // this is only used by the LegacyProtocol in compat mode
     bool sslSupported;
-    int32_t clientFeatures;
+    quint32 clientFeatures;
 };
 
 
 };
 
 
@@ -247,5 +246,3 @@ struct HeartBeatReply
 
 
 };
 
 
 };
-
-#endif
index e25cbb3..7c80406 100644 (file)
@@ -214,7 +214,6 @@ void RemotePeer::onReadyRead()
 
         processMessage(msg);
 
 
         processMessage(msg);
 
-
         if (SignalProxy::current())
             SignalProxy::current()->setSourcePeer(nullptr);
     }
         if (SignalProxy::current())
             SignalProxy::current()->setSourcePeer(nullptr);
     }
index bcc639f..bf07f28 100644 (file)
@@ -173,6 +173,9 @@ int SignalProxy::SignalRelay::qt_metacall(QMetaObject::Call _c, int _id, void **
 // ==================================================
 //  SignalProxy
 // ==================================================
 // ==================================================
 //  SignalProxy
 // ==================================================
+
+thread_local SignalProxy *SignalProxy::_current{nullptr};
+
 SignalProxy::SignalProxy(QObject *parent)
     : QObject(parent)
 {
 SignalProxy::SignalProxy(QObject *parent)
     : QObject(parent)
 {
@@ -204,6 +207,8 @@ SignalProxy::~SignalProxy()
     _syncSlave.clear();
 
     removeAllPeers();
     _syncSlave.clear();
 
     removeAllPeers();
+
+    _current = nullptr;
 }
 
 
 }
 
 
@@ -221,9 +226,6 @@ void SignalProxy::setProxyMode(ProxyMode mode)
         initClient();
 }
 
         initClient();
 }
 
-thread_local SignalProxy *SignalProxy::_current;
-
-
 void SignalProxy::init()
 {
     _heartBeatInterval = 0;
 void SignalProxy::init()
 {
     _heartBeatInterval = 0;
@@ -516,15 +518,9 @@ void SignalProxy::stopSynchronize(SyncableObject *obj)
 template<class T>
 void SignalProxy::dispatch(const T &protoMessage)
 {
 template<class T>
 void SignalProxy::dispatch(const T &protoMessage)
 {
-    for (auto peer : _peerMap.values()) {
-        _targetPeer = peer;
-
-        if (peer->isOpen())
-            peer->dispatch(protoMessage);
-        else
-            QCoreApplication::postEvent(this, new ::RemovePeerEvent(peer));
+    for (auto&& peer : _peerMap.values()) {
+        dispatch(peer, protoMessage);
     }
     }
-    _targetPeer = nullptr;
 }
 
 
 }
 
 
index 77ef3a4..ac4b8c6 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef SIGNALPROXY_H
-#define SIGNALPROXY_H
+#pragma once
 
 #include <QEvent>
 #include <QSet>
 
 #include <QEvent>
 #include <QSet>
-#include <QThreadStorage>
 
 #include <functional>
 
 #include <functional>
-#include <memory>
+#include <initializer_list>
 
 #include "protocol.h"
 
 
 #include "protocol.h"
 
@@ -286,5 +284,3 @@ private:
     QHash<QByteArray, int> _methodIds;
     QHash<int, int> _receiveMap; // if slot x is called then hand over the result to slot y
 };
     QHash<QByteArray, int> _methodIds;
     QHash<int, int> _receiveMap; // if slot x is called then hand over the result to slot y
 };
-
-#endif