X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fremotepeer.h;h=7bf7944f850707a035d603662e7c67b4981fe477;hb=74226102118400b228618f7373137a4a01e7d85f;hp=e577a86c82e5a2682742aa301f79d090ecc98648;hpb=64cf9f9b8a737dad5f29447805d4004cfd03c454;p=quassel.git diff --git a/src/common/remotepeer.h b/src/common/remotepeer.h index e577a86c..7bf7944f 100644 --- a/src/common/remotepeer.h +++ b/src/common/remotepeer.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -23,11 +23,11 @@ #include +#include "compressor.h" #include "peer.h" #include "protocol.h" #include "signalproxy.h" -class QTcpSocket; class QTimer; class AuthHandler; @@ -41,12 +41,16 @@ public: using Peer::handle; using Peer::dispatch; - RemotePeer(AuthHandler *authHandler, QTcpSocket *socket, QObject *parent = 0); - virtual ~RemotePeer() {}; + RemotePeer(AuthHandler *authHandler, QTcpSocket *socket, Compressor::CompressionLevel level, QObject *parent = 0); void setSignalProxy(SignalProxy *proxy); - QString description() const; + virtual QString protocolName() const = 0; + virtual QString description() const; + virtual quint16 enabledFeatures() const { return 0; } + + virtual QString address() const; + virtual quint16 port() const; bool isOpen() const; bool isSecure() const; @@ -64,29 +68,43 @@ public slots: signals: void transferProgress(int current, int max); - void socketStateChanged(QAbstractSocket::SocketState socketState); void socketError(QAbstractSocket::SocketError error, const QString &errorString); + void statusMessage(const QString &msg); protected: SignalProxy *signalProxy() const; + void writeMessage(const QByteArray &msg); + virtual void processMessage(const QByteArray &msg) = 0; + // These protocol messages get handled internally and won't reach SignalProxy void handle(const Protocol::HeartBeat &heartBeat); void handle(const Protocol::HeartBeatReply &heartBeatReply); virtual void dispatch(const Protocol::HeartBeat &msg) = 0; virtual void dispatch(const Protocol::HeartBeatReply &msg) = 0; +protected slots: + virtual void onSocketStateChanged(QAbstractSocket::SocketState state); + virtual void onSocketError(QAbstractSocket::SocketError error); + private slots: + void onReadyRead(); + void onCompressionError(Compressor::Error error); + void sendHeartBeat(); void changeHeartBeatInterval(int secs); - void onSocketError(QAbstractSocket::SocketError error); + +private: + bool readMessage(QByteArray &msg); private: QTcpSocket *_socket; + Compressor *_compressor; SignalProxy *_signalProxy; QTimer *_heartBeatTimer; int _heartBeatCount; int _lag; + quint32 _msgSize; }; #endif