qtui: Set proper icon for "About Quassel" menu option
[quassel.git] / src / common / internalpeer.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 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 #pragma once
22
23 #include <QPointer>
24 #include <QString>
25
26 #include "peer.h"
27 #include "protocol.h"
28 #include "signalproxy.h"
29
30 class InternalPeer : public Peer
31 {
32     Q_OBJECT
33
34 public:
35     InternalPeer(QObject *parent = nullptr);
36     ~InternalPeer() override;
37
38     Protocol::Type protocol() const override { return Protocol::InternalProtocol; }
39     QString description() const override;
40
41     QString address() const override;
42     quint16 port() const override;
43
44     SignalProxy *signalProxy() const override;
45     void setSignalProxy(SignalProxy *proxy) override;
46
47     InternalPeer *peer() const;
48     void setPeer(InternalPeer *peer);
49
50     bool isOpen() const override;
51     bool isSecure() const override;
52     bool isLocal() const override;
53
54     int lag() const override;
55
56     void dispatch(const Protocol::SyncMessage &msg) override;
57     void dispatch(const Protocol::RpcCall &msg) override;
58     void dispatch(const Protocol::InitRequest &msg) override;
59     void dispatch(const Protocol::InitData &msg) override;
60
61     /* These are not needed for InternalPeer */
62     void dispatch(const Protocol::RegisterClient &) override {}
63     void dispatch(const Protocol::ClientDenied &) override {}
64     void dispatch(const Protocol::ClientRegistered &) override {}
65     void dispatch(const Protocol::SetupData &) override {}
66     void dispatch(const Protocol::SetupFailed &) override {}
67     void dispatch(const Protocol::SetupDone &) override {}
68     void dispatch(const Protocol::Login &) override {}
69     void dispatch(const Protocol::LoginFailed &) override {}
70     void dispatch(const Protocol::LoginSuccess &) override {}
71     void dispatch(const Protocol::SessionState &) override {}
72
73 public slots:
74     void close(const QString &reason = QString()) override;
75
76 signals:
77     void dispatchMessage(const Protocol::SyncMessage &msg);
78     void dispatchMessage(const Protocol::RpcCall &msg);
79     void dispatchMessage(const Protocol::InitRequest &msg);
80     void dispatchMessage(const Protocol::InitData &msg);
81
82 private slots:
83     void peerDisconnected();
84
85     void handleMessage(const Protocol::SyncMessage &msg);
86     void handleMessage(const Protocol::RpcCall &msg);
87     void handleMessage(const Protocol::InitRequest &msg);
88     void handleMessage(const Protocol::InitData &msg);
89
90 private:
91     template<typename T>
92     void handle(const T &msg);
93
94 private:
95     SignalProxy *_proxy{nullptr};
96     bool _isOpen{false};
97 };
98
99 Q_DECLARE_METATYPE(QPointer<InternalPeer>)