X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fremotepeer.h;h=e577a86c82e5a2682742aa301f79d090ecc98648;hb=0e80eb98d55efe53d280b38984426318317bcb1a;hp=e41a6a3bc3d823a3631f59764860f7221ef6d1e7;hpb=9fc57dc2c000e80fb8bd746a090e2e8210e1278e;p=quassel.git diff --git a/src/common/remotepeer.h b/src/common/remotepeer.h index e41a6a3b..e577a86c 100644 --- a/src/common/remotepeer.h +++ b/src/common/remotepeer.h @@ -22,19 +22,26 @@ #define REMOTEPEER_H #include -#include +#include "peer.h" #include "protocol.h" #include "signalproxy.h" +class QTcpSocket; class QTimer; -class RemotePeer : public SignalProxy::AbstractPeer +class AuthHandler; + +class RemotePeer : public Peer { Q_OBJECT public: - RemotePeer(QTcpSocket *socket, QObject *parent = 0); + // import the virtuals from the baseclass + using Peer::handle; + using Peer::dispatch; + + RemotePeer(AuthHandler *authHandler, QTcpSocket *socket, QObject *parent = 0); virtual ~RemotePeer() {}; void setSignalProxy(SignalProxy *proxy); @@ -52,27 +59,17 @@ public: QTcpSocket *socket() const; - // this is only used for the auth phase and should be replaced by something more generic - virtual void writeSocketData(const QVariant &item) = 0; - public slots: void close(const QString &reason = QString()); signals: - // this is only used for the auth phase and should be replaced by something more generic - void dataReceived(const QVariant &item); - - void disconnected(); - void error(QAbstractSocket::SocketError); - void transferProgress(int current, int max); + void socketStateChanged(QAbstractSocket::SocketState socketState); + void socketError(QAbstractSocket::SocketError error, const QString &errorString); protected: SignalProxy *signalProxy() const; - template - void handle(const T &protoMessage); - // These protocol messages get handled internally and won't reach SignalProxy void handle(const Protocol::HeartBeat &heartBeat); void handle(const Protocol::HeartBeatReply &heartBeatReply); @@ -82,6 +79,7 @@ protected: private slots: void sendHeartBeat(); void changeHeartBeatInterval(int secs); + void onSocketError(QAbstractSocket::SocketError error); private: QTcpSocket *_socket; @@ -91,19 +89,4 @@ private: int _lag; }; -// Template methods we need in the header -template inline -void RemotePeer::handle(const T &protoMessage) -{ - if (!signalProxy()) { - qWarning() << Q_FUNC_INFO << "Cannot handle messages without a SignalProxy!"; - return; - } - - // _heartBeatCount = 0; - - signalProxy()->handle(this, protoMessage); -} - - #endif