Merge pull request #2 from sandsmark/wii
[quassel.git] / src / common / protocols / legacy / legacypeer.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2013 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 <QDataStream>
25
26 #include "../../remotepeer.h"
27
28 class QDataStream;
29
30 class LegacyPeer : public RemotePeer
31 {
32     Q_OBJECT
33
34 public:
35     enum RequestType {
36         Sync = 1,
37         RpcCall,
38         InitRequest,
39         InitData,
40         HeartBeat,
41         HeartBeatReply
42     };
43
44     LegacyPeer(QTcpSocket *socket, QObject *parent = 0);
45     ~LegacyPeer() {}
46
47     void setSignalProxy(SignalProxy *proxy);
48
49     void dispatch(const Protocol::SyncMessage &msg);
50     void dispatch(const Protocol::RpcCall &msg);
51     void dispatch(const Protocol::InitRequest &msg);
52     void dispatch(const Protocol::InitData &msg);
53
54     void dispatch(const Protocol::HeartBeat &msg);
55     void dispatch(const Protocol::HeartBeatReply &msg);
56
57     // FIXME: this is only used for the auth phase and should be replaced by something more generic
58     void writeSocketData(const QVariant &item);
59
60 private slots:
61     void socketDataAvailable();
62
63 private:
64     bool readSocketData(QVariant &item);
65     void handlePackedFunc(const QVariant &packedFunc);
66     void dispatchPackedFunc(const QVariantList &packedFunc);
67
68     QDataStream _stream;
69     qint32 _blockSize;
70     bool _useCompression;
71 };
72
73 #endif