1 /***************************************************************************
2 * Copyright (C) 2005-2018 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 <QStringList>
24 #include <QVariantList>
29 class COMMON_EXPORT NetworkEvent : public Event
32 explicit NetworkEvent(EventManager::EventType type, Network *network)
37 inline NetworkId networkId() const { return network() ? network()->networkId() : NetworkId(); }
38 inline Network *network() const { return _network; }
40 static Event *create(EventManager::EventType type, QVariantMap &map, Network *network);
43 explicit NetworkEvent(EventManager::EventType type, QVariantMap &map, Network *network);
44 void toVariantMap(QVariantMap &map) const;
46 virtual inline QString className() const { return "NetworkEvent"; }
47 virtual inline void debugInfo(QDebug &dbg) const { dbg.nospace() << ", net = " << qPrintable(_network->networkName()); }
54 /*****************************************************************************/
56 class COMMON_EXPORT NetworkConnectionEvent : public NetworkEvent
59 explicit NetworkConnectionEvent(EventManager::EventType type, Network *network, Network::ConnectionState state)
60 : NetworkEvent(type, network),
64 inline Network::ConnectionState connectionState() const { return _state; }
65 inline void setConnectionState(Network::ConnectionState state) { _state = state; }
68 explicit NetworkConnectionEvent(EventManager::EventType type, QVariantMap &map, Network *network);
69 void toVariantMap(QVariantMap &map) const;
71 virtual inline QString className() const { return "NetworkConnectionEvent"; }
72 virtual inline void debugInfo(QDebug &dbg) const
74 NetworkEvent::debugInfo(dbg);
75 dbg.nospace() << ", state = " << qPrintable(QString::number(_state));
80 Network::ConnectionState _state;
82 friend class NetworkEvent;
86 class COMMON_EXPORT NetworkDataEvent : public NetworkEvent
89 explicit NetworkDataEvent(EventManager::EventType type, Network *network, const QByteArray &data)
90 : NetworkEvent(type, network),
94 inline QByteArray data() const { return _data; }
95 inline void setData(const QByteArray &data) { _data = data; }
98 explicit NetworkDataEvent(EventManager::EventType type, QVariantMap &map, Network *network);
99 void toVariantMap(QVariantMap &map) const;
101 virtual inline QString className() const { return "NetworkDataEvent"; }
102 virtual inline void debugInfo(QDebug &dbg) const
104 NetworkEvent::debugInfo(dbg);
105 dbg.nospace() << ", data = " << data();
112 friend class NetworkEvent;
116 class COMMON_EXPORT NetworkSplitEvent : public NetworkEvent
119 explicit NetworkSplitEvent(EventManager::EventType type,
121 const QString &channel,
122 const QStringList &users,
123 const QString &quitMsg)
124 : NetworkEvent(type, network),
130 inline QString channel() const { return _channel; }
131 inline QStringList users() const { return _users; }
132 inline QString quitMessage() const { return _quitMsg; }
135 explicit NetworkSplitEvent(EventManager::EventType type, QVariantMap &map, Network *network);
136 void toVariantMap(QVariantMap &map) const;
138 virtual inline QString className() const { return "NetworkSplitEvent"; }
139 virtual inline void debugInfo(QDebug &dbg) const
141 NetworkEvent::debugInfo(dbg);
142 dbg.nospace() << ", channel = " << qPrintable(channel())
143 << ", users = " << users()
144 << ", quitmsg = " << quitMessage();
153 friend class NetworkEvent;