X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fremotepeer.h;h=191439ef2b402df9c2352e36cd64b93a79aeab49;hp=e41a6a3bc3d823a3631f59764860f7221ef6d1e7;hb=3d464695bf5b57c969f30e6f3b8b429890f976bf;hpb=4c80eeb2d07b5ca75fd399b51c939961fdff1670 diff --git a/src/common/remotepeer.h b/src/common/remotepeer.h index e41a6a3b..191439ef 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-2014 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -22,24 +22,32 @@ #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); - virtual ~RemotePeer() {}; + // import the virtuals from the baseclass + using Peer::handle; + using Peer::dispatch; + + RemotePeer(AuthHandler *authHandler, QTcpSocket *socket, QObject *parent = 0); void setSignalProxy(SignalProxy *proxy); - QString description() const; + virtual Protocol::Type protocol() const = 0; + virtual QString description() const; + virtual quint16 enabledFeatures() const { return 0; } bool isOpen() const; bool isSecure() const; @@ -52,33 +60,28 @@ 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 socketError(QAbstractSocket::SocketError error, const QString &errorString); + void statusMessage(const QString &msg); 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); virtual void dispatch(const Protocol::HeartBeat &msg) = 0; virtual void dispatch(const Protocol::HeartBeatReply &msg) = 0; +protected slots: + virtual void onSocketDataAvailable() = 0; + virtual void onSocketStateChanged(QAbstractSocket::SocketState state); + virtual void onSocketError(QAbstractSocket::SocketError error); + private slots: void sendHeartBeat(); void changeHeartBeatInterval(int secs); @@ -91,19 +94,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