X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fprotocols%2Fdatastream%2Fdatastreampeer.h;fp=src%2Fcommon%2Fprotocols%2Fdatastream%2Fdatastreampeer.h;h=a0e8f91ba7483e6f14ba1970db62d4a54f4bc97e;hp=0000000000000000000000000000000000000000;hb=db9bba48e1674f169d1ed3cf184e5fa56dbe3a80;hpb=6f82edb27a2ed2c77b36591e492d8aa2671344ef diff --git a/src/common/protocols/datastream/datastreampeer.h b/src/common/protocols/datastream/datastreampeer.h new file mode 100644 index 00000000..a0e8f91b --- /dev/null +++ b/src/common/protocols/datastream/datastreampeer.h @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2005-2014 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef DATASTREAMPEER_H +#define DATASTREAMPEER_H + +#include + +#include "../../remotepeer.h" + +class QDataStream; + +class DataStreamPeer : public RemotePeer +{ + Q_OBJECT + +public: + enum RequestType { + Sync = 1, + RpcCall, + InitRequest, + InitData, + HeartBeat, + HeartBeatReply + }; + + DataStreamPeer(AuthHandler *authHandler, QTcpSocket *socket, quint16 features, QObject *parent = 0); + + Protocol::Type protocol() const { return Protocol::DataStreamProtocol; } + + static quint16 supportedFeatures(); + static bool acceptsFeatures(quint16 peerFeatures); + quint16 enabledFeatures() const; + + void setSignalProxy(SignalProxy *proxy); + + void dispatch(const Protocol::RegisterClient &msg); + void dispatch(const Protocol::ClientDenied &msg); + void dispatch(const Protocol::ClientRegistered &msg); + void dispatch(const Protocol::SetupData &msg); + void dispatch(const Protocol::SetupFailed &msg); + void dispatch(const Protocol::SetupDone &msg); + void dispatch(const Protocol::Login &msg); + void dispatch(const Protocol::LoginFailed &msg); + void dispatch(const Protocol::LoginSuccess &msg); + void dispatch(const Protocol::SessionState &msg); + + void dispatch(const Protocol::SyncMessage &msg); + void dispatch(const Protocol::RpcCall &msg); + void dispatch(const Protocol::InitRequest &msg); + void dispatch(const Protocol::InitData &msg); + + void dispatch(const Protocol::HeartBeat &msg); + void dispatch(const Protocol::HeartBeatReply &msg); + +signals: + void protocolError(const QString &errorString); + + // only used in compat mode + void protocolVersionMismatch(int actual, int expected); + +protected slots: + void onSocketDataAvailable(); + +private: + bool readSocketData(QVariant &item); + void writeSocketData(const QVariant &item); + void handleHandshakeMessage(const QVariant &msg); + void handlePackedFunc(const QVariant &packedFunc); + void dispatchPackedFunc(const QVariantList &packedFunc); + + QDataStream _stream; + quint32 _blockSize; + bool _useCompression; +}; + +#endif