cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / common / protocols / legacy / legacypeer.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2020 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 LEGACYPEER_H
22 #define LEGACYPEER_H
23
24 #include "../../remotepeer.h"
25
26 class LegacyPeer : public RemotePeer
27 {
28     Q_OBJECT
29
30 public:
31     enum RequestType
32     {
33         Sync = 1,
34         RpcCall,
35         InitRequest,
36         InitData,
37         HeartBeat,
38         HeartBeatReply
39     };
40
41     LegacyPeer(AuthHandler* authHandler, QTcpSocket* socket, Compressor::CompressionLevel level, QObject* parent = nullptr);
42
43     Protocol::Type protocol() const override { return Protocol::LegacyProtocol; }
44     QString protocolName() const override { return "the legacy protocol"; }
45
46     void setSignalProxy(SignalProxy* proxy) override;
47
48     void dispatch(const Protocol::RegisterClient& msg) override;
49     void dispatch(const Protocol::ClientDenied& msg) override;
50     void dispatch(const Protocol::ClientRegistered& msg) override;
51     void dispatch(const Protocol::SetupData& msg) override;
52     void dispatch(const Protocol::SetupFailed& msg) override;
53     void dispatch(const Protocol::SetupDone& msg) override;
54     void dispatch(const Protocol::Login& msg) override;
55     void dispatch(const Protocol::LoginFailed& msg) override;
56     void dispatch(const Protocol::LoginSuccess& msg) override;
57     void dispatch(const Protocol::SessionState& msg) override;
58
59     void dispatch(const Protocol::SyncMessage& msg) override;
60     void dispatch(const Protocol::RpcCall& msg) override;
61     void dispatch(const Protocol::InitRequest& msg) override;
62     void dispatch(const Protocol::InitData& msg) override;
63
64     void dispatch(const Protocol::HeartBeat& msg) override;
65     void dispatch(const Protocol::HeartBeatReply& msg) override;
66
67 signals:
68     void protocolError(const QString& errorString);
69
70 private:
71     using RemotePeer::writeMessage;
72     void writeMessage(const QVariant& item);
73     void processMessage(const QByteArray& msg) override;
74
75     void handleHandshakeMessage(const QVariant& msg);
76     void handlePackedFunc(const QVariant& packedFunc);
77     void dispatchPackedFunc(const QVariantList& packedFunc);
78
79     void toLegacyIrcUsersAndChannels(QVariantMap& initData);
80     void fromLegacyIrcUsersAndChannels(QVariantMap& initData);
81
82     bool _useCompression;
83 };
84
85 #endif