1 | /*************************************************************************** |
2 | * Copyright (C) 2005-2014 by the Quassel Project * |
3 | * devel@quassel-irc.org * |
4 | * * |
5 | * This program is free software; you can redistribute it and/or modify * |
6 | * it under the terms of the GNU General Public License as published by * |
7 | * the Free Software Foundation; either version 2 of the License, or * |
8 | * (at your option) version 3. * |
9 | * * |
10 | * This program is distributed in the hope that it will be useful, * |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 | * GNU General Public License for more details. * |
14 | * * |
15 | * You should have received a copy of the GNU General Public License * |
16 | * along with this program; if not, write to the * |
17 | * Free Software Foundation, Inc., * |
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
19 | ***************************************************************************/ |
20 | |
21 | #ifndef DATASTREAMPEER_H |
22 | #define DATASTREAMPEER_H |
23 | |
24 | #include "../../remotepeer.h" |
25 | |
26 | class QDataStream; |
27 | |
28 | class DataStreamPeer : public RemotePeer |
29 | { |
30 | Q_OBJECT |
31 | |
32 | public: |
33 | enum RequestType { |
34 | Sync = 1, |
35 | RpcCall, |
36 | InitRequest, |
37 | InitData, |
38 | HeartBeat, |
39 | HeartBeatReply |
40 | }; |
41 | |
42 | DataStreamPeer(AuthHandler *authHandler, QTcpSocket *socket, quint16 features, Compressor::CompressionLevel level, QObject *parent = 0); |
43 | |
44 | Protocol::Type protocol() const { return Protocol::DataStreamProtocol; } |
45 | QString protocolName() const { return "the DataStream protocol" ; } |
46 | |
47 | static quint16 supportedFeatures(); |
48 | static bool acceptsFeatures(quint16 peerFeatures); |
49 | quint16 enabledFeatures() const; |
50 | |
51 | void dispatch(const Protocol::RegisterClient &msg); |
52 | void dispatch(const Protocol::ClientDenied &msg); |
53 | void dispatch(const Protocol::ClientRegistered &msg); |
54 | void dispatch(const Protocol::SetupData &msg); |
55 | void dispatch(const Protocol::SetupFailed &msg); |
56 | void dispatch(const Protocol::SetupDone &msg); |
57 | void dispatch(const Protocol::Login &msg); |
58 | void dispatch(const Protocol::LoginFailed &msg); |
59 | void dispatch(const Protocol::LoginSuccess &msg); |
60 | void dispatch(const Protocol::SessionState &msg); |
61 | |
62 | void dispatch(const Protocol::SyncMessage &msg); |
63 | void dispatch(const Protocol::RpcCall &msg); |
64 | void dispatch(const Protocol::InitRequest &msg); |
65 | void dispatch(const Protocol::InitData &msg); |
66 | |
67 | void dispatch(const Protocol::HeartBeat &msg); |
68 | void dispatch(const Protocol::HeartBeatReply &msg); |
69 | |
70 | signals: |
71 | void protocolError(const QString &errorString); |
72 | |
73 | private: |
74 | using RemotePeer::writeMessage; |
75 | void writeMessage(const QVariantMap &handshakeMsg); |
76 | void writeMessage(const QVariantList &sigProxyMsg); |
77 | void processMessage(const QByteArray &msg); |
78 | |
79 | void handleHandshakeMessage(const QVariantList &mapData); |
80 | void handlePackedFunc(const QVariantList &packedFunc); |
81 | void dispatchPackedFunc(const QVariantList &packedFunc); |
82 | }; |
83 | |
84 | #endif |
85 | |