src: Mark symbols to be exported where needed
[quassel.git] / src / common / networkevent.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 <QStringList>
24 #include <QVariantList>
25
26 #include "event.h"
27 #include "network.h"
28
29 class COMMON_EXPORT NetworkEvent : public Event
30 {
31 public:
32     explicit NetworkEvent(EventManager::EventType type, Network *network)
33         : Event(type),
34         _network(network)
35     {}
36
37     inline NetworkId networkId() const { return network() ? network()->networkId() : NetworkId(); }
38     inline Network *network() const { return _network; }
39
40     static Event *create(EventManager::EventType type, QVariantMap &map, Network *network);
41
42 protected:
43     explicit NetworkEvent(EventManager::EventType type, QVariantMap &map, Network *network);
44     void toVariantMap(QVariantMap &map) const;
45
46     virtual inline QString className() const { return "NetworkEvent"; }
47     virtual inline void debugInfo(QDebug &dbg) const { dbg.nospace() << ", net = " << qPrintable(_network->networkName()); }
48
49 private:
50     Network *_network;
51 };
52
53
54 /*****************************************************************************/
55
56 class COMMON_EXPORT NetworkConnectionEvent : public NetworkEvent
57 {
58 public:
59     explicit NetworkConnectionEvent(EventManager::EventType type, Network *network, Network::ConnectionState state)
60         : NetworkEvent(type, network),
61         _state(state)
62     {}
63
64     inline Network::ConnectionState connectionState() const { return _state; }
65     inline void setConnectionState(Network::ConnectionState state) { _state = state; }
66
67 protected:
68     explicit NetworkConnectionEvent(EventManager::EventType type, QVariantMap &map, Network *network);
69     void toVariantMap(QVariantMap &map) const;
70
71     virtual inline QString className() const { return "NetworkConnectionEvent"; }
72     virtual inline void debugInfo(QDebug &dbg) const
73     {
74         NetworkEvent::debugInfo(dbg);
75         dbg.nospace() << ", state = " << qPrintable(QString::number(_state));
76     }
77
78
79 private:
80     Network::ConnectionState _state;
81
82     friend class NetworkEvent;
83 };
84
85
86 class COMMON_EXPORT NetworkDataEvent : public NetworkEvent
87 {
88 public:
89     explicit NetworkDataEvent(EventManager::EventType type, Network *network, const QByteArray &data)
90         : NetworkEvent(type, network),
91         _data(data)
92     {}
93
94     inline QByteArray data() const { return _data; }
95     inline void setData(const QByteArray &data) { _data = data; }
96
97 protected:
98     explicit NetworkDataEvent(EventManager::EventType type, QVariantMap &map, Network *network);
99     void toVariantMap(QVariantMap &map) const;
100
101     virtual inline QString className() const { return "NetworkDataEvent"; }
102     virtual inline void debugInfo(QDebug &dbg) const
103     {
104         NetworkEvent::debugInfo(dbg);
105         dbg.nospace() << ", data = " << data();
106     }
107
108
109 private:
110     QByteArray _data;
111
112     friend class NetworkEvent;
113 };
114
115
116 class COMMON_EXPORT NetworkSplitEvent : public NetworkEvent
117 {
118 public:
119     explicit NetworkSplitEvent(EventManager::EventType type,
120         Network *network,
121         const QString &channel,
122         const QStringList &users,
123         const QString &quitMsg)
124         : NetworkEvent(type, network),
125         _channel(channel),
126         _users(users),
127         _quitMsg(quitMsg)
128     {}
129
130     inline QString channel() const { return _channel; }
131     inline QStringList users() const { return _users; }
132     inline QString quitMessage() const { return _quitMsg; }
133
134 protected:
135     explicit NetworkSplitEvent(EventManager::EventType type, QVariantMap &map, Network *network);
136     void toVariantMap(QVariantMap &map) const;
137
138     virtual inline QString className() const { return "NetworkSplitEvent"; }
139     virtual inline void debugInfo(QDebug &dbg) const
140     {
141         NetworkEvent::debugInfo(dbg);
142         dbg.nospace() << ", channel = " << qPrintable(channel())
143                       << ", users = " << users()
144                       << ", quitmsg = " << quitMessage();
145     }
146
147
148 private:
149     QString _channel;
150     QStringList _users;
151     QString _quitMsg;
152
153     friend class NetworkEvent;
154 };