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 ***************************************************************************/
25 #include <QStringList>
26 #include <QVariantList>
31 class COMMON_EXPORT NetworkEvent : public Event
34 explicit NetworkEvent(EventManager::EventType type, Network* network)
39 inline NetworkId networkId() const { return network() ? network()->networkId() : NetworkId(); }
40 inline Network* network() const { return _network; }
42 static Event* create(EventManager::EventType type, QVariantMap& map, Network* network);
45 explicit NetworkEvent(EventManager::EventType type, QVariantMap& map, Network* network);
46 void toVariantMap(QVariantMap& map) const override;
48 inline QString className() const override { return "NetworkEvent"; }
49 inline void debugInfo(QDebug& dbg) const override { dbg.nospace() << ", net = " << qPrintable(_network->networkName()); }
55 /*****************************************************************************/
57 class COMMON_EXPORT NetworkConnectionEvent : public NetworkEvent
60 explicit NetworkConnectionEvent(EventManager::EventType type, Network* network, Network::ConnectionState state)
61 : NetworkEvent(type, network)
65 inline Network::ConnectionState connectionState() const { return _state; }
66 inline void setConnectionState(Network::ConnectionState state) { _state = state; }
69 explicit NetworkConnectionEvent(EventManager::EventType type, QVariantMap& map, Network* network);
70 void toVariantMap(QVariantMap& map) const override;
72 inline QString className() const override { return "NetworkConnectionEvent"; }
73 inline void debugInfo(QDebug& dbg) const override
75 NetworkEvent::debugInfo(dbg);
76 dbg.nospace() << ", state = " << qPrintable(QString::number(_state));
80 Network::ConnectionState _state;
82 friend class NetworkEvent;
85 class COMMON_EXPORT NetworkDataEvent : public NetworkEvent
88 explicit NetworkDataEvent(EventManager::EventType type, Network* network, QByteArray data)
89 : NetworkEvent(type, network)
90 , _data(std::move(data))
93 inline QByteArray data() const { return _data; }
94 inline void setData(const QByteArray& data) { _data = data; }
97 explicit NetworkDataEvent(EventManager::EventType type, QVariantMap& map, Network* network);
98 void toVariantMap(QVariantMap& map) const override;
100 inline QString className() const override { return "NetworkDataEvent"; }
101 inline void debugInfo(QDebug& dbg) const override
103 NetworkEvent::debugInfo(dbg);
104 dbg.nospace() << ", data = " << data();
110 friend class NetworkEvent;
113 class COMMON_EXPORT NetworkSplitEvent : public NetworkEvent
116 explicit NetworkSplitEvent(EventManager::EventType type, Network* network, QString channel, QStringList users, QString quitMsg)
117 : NetworkEvent(type, network)
118 , _channel(std::move(channel))
119 , _users(std::move(users))
120 , _quitMsg(std::move(quitMsg))
123 inline QString channel() const { return _channel; }
124 inline QStringList users() const { return _users; }
125 inline QString quitMessage() const { return _quitMsg; }
128 explicit NetworkSplitEvent(EventManager::EventType type, QVariantMap& map, Network* network);
129 void toVariantMap(QVariantMap& map) const override;
131 inline QString className() const override { return "NetworkSplitEvent"; }
132 inline void debugInfo(QDebug& dbg) const override
134 NetworkEvent::debugInfo(dbg);
135 dbg.nospace() << ", channel = " << qPrintable(channel()) << ", users = " << users() << ", quitmsg = " << quitMessage();
143 friend class NetworkEvent;