X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcommon%2Fremotepeer.h;h=e9d85f59ed3fe443d0abe0ddefe440bf21a16107;hb=39328183a6a87c6eb10a9dbbffcd5d65bf154a1f;hp=6c3e35f415a820ad15058a26e83c0c26e38da393;hpb=89ae7093aaf405d24f3d7ac0825290f2a065da99;p=quassel.git diff --git a/src/common/remotepeer.h b/src/common/remotepeer.h index 6c3e35f4..e9d85f59 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 * @@ -18,29 +18,40 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef REMOTEPEER_H -#define REMOTEPEER_H +#pragma once + +#include "common-export.h" #include +#include "compressor.h" #include "peer.h" #include "protocol.h" #include "signalproxy.h" -class QTcpSocket; class QTimer; -class RemotePeer : public Peer +class AuthHandler; + +class COMMON_EXPORT RemotePeer : public Peer { Q_OBJECT public: - RemotePeer(QTcpSocket *socket, QObject *parent = 0); - virtual ~RemotePeer() {}; + // import the virtuals from the baseclass + using Peer::handle; + using Peer::dispatch; + + RemotePeer(AuthHandler *authHandler, QTcpSocket *socket, Compressor::CompressionLevel level, QObject *parent = nullptr); 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; @@ -53,23 +64,19 @@ 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 transferProgress(int current, int max); + void socketError(QAbstractSocket::SocketError error, const QString &errorString); + void statusMessage(const QString &msg); protected: SignalProxy *signalProxy() const; - using Peer::handle; - using Peer::dispatch; + 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); @@ -77,16 +84,26 @@ protected: 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); +private: + bool readMessage(QByteArray &msg); + private: QTcpSocket *_socket; + Compressor *_compressor; SignalProxy *_signalProxy; QTimer *_heartBeatTimer; int _heartBeatCount; int _lag; + quint32 _msgSize; }; - -#endif