1 /***************************************************************************
2 * Copyright (C) 2005-2020 by the Quassel Project *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
23 #include "common-export.h"
30 #include "signalproxy.h"
32 class COMMON_EXPORT InternalPeer : public Peer
37 InternalPeer(QObject* parent = nullptr);
38 ~InternalPeer() override;
40 Protocol::Type protocol() const override { return Protocol::InternalProtocol; }
41 QString description() const override;
43 QString address() const override;
44 quint16 port() const override;
46 SignalProxy* signalProxy() const override;
47 void setSignalProxy(SignalProxy* proxy) override;
49 InternalPeer* peer() const;
50 void setPeer(InternalPeer* peer);
52 bool isOpen() const override;
53 bool isSecure() const override;
54 bool isLocal() const override;
56 int lag() const override;
58 void dispatch(const Protocol::SyncMessage& msg) override;
59 void dispatch(const Protocol::RpcCall& msg) override;
60 void dispatch(const Protocol::InitRequest& msg) override;
61 void dispatch(const Protocol::InitData& msg) override;
63 /* These are not needed for InternalPeer */
64 void dispatch(const Protocol::RegisterClient&) override {}
65 void dispatch(const Protocol::ClientDenied&) override {}
66 void dispatch(const Protocol::ClientRegistered&) override {}
67 void dispatch(const Protocol::SetupData&) override {}
68 void dispatch(const Protocol::SetupFailed&) override {}
69 void dispatch(const Protocol::SetupDone&) override {}
70 void dispatch(const Protocol::Login&) override {}
71 void dispatch(const Protocol::LoginFailed&) override {}
72 void dispatch(const Protocol::LoginSuccess&) override {}
73 void dispatch(const Protocol::SessionState&) override {}
76 void close(const QString& reason = QString()) override;
79 void dispatchMessage(const Protocol::SyncMessage& msg);
80 void dispatchMessage(const Protocol::RpcCall& msg);
81 void dispatchMessage(const Protocol::InitRequest& msg);
82 void dispatchMessage(const Protocol::InitData& msg);
85 void peerDisconnected();
87 void handleMessage(const Protocol::SyncMessage& msg);
88 void handleMessage(const Protocol::RpcCall& msg);
89 void handleMessage(const Protocol::InitRequest& msg);
90 void handleMessage(const Protocol::InitData& msg);
94 void handle(const T& msg);
97 SignalProxy* _proxy{nullptr};
101 Q_DECLARE_METATYPE(QPointer<InternalPeer>)