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 ***************************************************************************/
25 #include "common-export.h"
27 #include "networkevent.h"
30 class COMMON_EXPORT IrcEvent : public NetworkEvent
33 explicit IrcEvent(EventManager::EventType type, Network *network, QString prefix, QStringList params = QStringList())
34 : NetworkEvent(type, network),
35 _prefix(std::move(prefix)),
36 _params(std::move(params))
39 inline QString prefix() const { return _prefix; }
40 inline void setPrefix(const QString &prefix) { _prefix = prefix; }
42 inline QString nick() const { return nickFromMask(prefix()); }
44 inline QStringList params() const { return _params; }
45 inline void setParams(const QStringList ¶ms) { _params = params; }
47 static Event *create(EventManager::EventType type, QVariantMap &map, Network *network);
50 explicit IrcEvent(EventManager::EventType type, QVariantMap &map, Network *network);
51 void toVariantMap(QVariantMap &map) const override;
53 inline QString className() const override { return "IrcEvent"; }
54 inline void debugInfo(QDebug &dbg) const override
56 NetworkEvent::debugInfo(dbg);
57 dbg << ", prefix = " << qPrintable(prefix())
58 << ", params = " << params();
68 class COMMON_EXPORT IrcEventNumeric : public IrcEvent
71 explicit IrcEventNumeric(uint number, Network *network, const QString &prefix, QString target, const QStringList ¶ms = QStringList())
72 : IrcEvent(EventManager::IrcEventNumeric, network, prefix, params),
74 _target(std::move(target))
77 inline uint number() const { return _number; }
79 inline QString target() const { return _target; }
80 inline void setTarget(const QString &target) { _target = target; }
83 explicit IrcEventNumeric(EventManager::EventType type, QVariantMap &map, Network *network);
84 void toVariantMap(QVariantMap &map) const override;
86 inline QString className() const override { return "IrcEventNumeric"; }
87 inline void debugInfo(QDebug &dbg) const override
89 dbg << ", num = " << number();
90 NetworkEvent::debugInfo(dbg);
91 dbg << ", target = " << qPrintable(target())
92 << ", prefix = " << qPrintable(prefix())
93 << ", params = " << params();
101 friend class IrcEvent;
105 class COMMON_EXPORT IrcEventRawMessage : public IrcEvent
108 explicit inline IrcEventRawMessage(EventManager::EventType type, Network *network,
109 QByteArray rawMessage, const QString &prefix, const QString &target,
110 const QDateTime ×tamp = QDateTime())
111 : IrcEvent(type, network, prefix, QStringList() << target),
112 _rawMessage(std::move(rawMessage))
114 setTimestamp(timestamp);
118 inline QString target() const { return params().at(0); }
119 inline void setTarget(const QString &target) { setParams(QStringList() << target); }
121 inline QByteArray rawMessage() const { return _rawMessage; }
122 inline void setRawMessage(const QByteArray &rawMessage) { _rawMessage = rawMessage; }
125 explicit IrcEventRawMessage(EventManager::EventType type, QVariantMap &map, Network *network);
126 void toVariantMap(QVariantMap &map) const override;
128 inline QString className() const override { return "IrcEventRawMessage"; }
129 inline void debugInfo(QDebug &dbg) const override
131 NetworkEvent::debugInfo(dbg);
132 dbg << ", target = " << qPrintable(target())
133 << ", prefix = " << qPrintable(prefix())
134 << ", msg = " << rawMessage();
139 QByteArray _rawMessage;
141 friend class IrcEvent;