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 "common-export.h"
25 #include "networkevent.h"
28 class COMMON_EXPORT IrcEvent : public NetworkEvent
31 explicit IrcEvent(EventManager::EventType type, Network *network, const QString &prefix, const QStringList ¶ms = QStringList())
32 : NetworkEvent(type, network),
37 inline QString prefix() const { return _prefix; }
38 inline void setPrefix(const QString &prefix) { _prefix = prefix; }
40 inline QString nick() const { return nickFromMask(prefix()); }
42 inline QStringList params() const { return _params; }
43 inline void setParams(const QStringList ¶ms) { _params = params; }
45 static Event *create(EventManager::EventType type, QVariantMap &map, Network *network);
48 explicit IrcEvent(EventManager::EventType type, QVariantMap &map, Network *network);
49 void toVariantMap(QVariantMap &map) const override;
51 inline QString className() const override { return "IrcEvent"; }
52 inline void debugInfo(QDebug &dbg) const override
54 NetworkEvent::debugInfo(dbg);
55 dbg << ", prefix = " << qPrintable(prefix())
56 << ", params = " << params();
66 class COMMON_EXPORT IrcEventNumeric : public IrcEvent
69 explicit IrcEventNumeric(uint number, Network *network, const QString &prefix, const QString &target, const QStringList ¶ms = QStringList())
70 : IrcEvent(EventManager::IrcEventNumeric, network, prefix, params),
75 inline uint number() const { return _number; }
77 inline QString target() const { return _target; }
78 inline void setTarget(const QString &target) { _target = target; }
81 explicit IrcEventNumeric(EventManager::EventType type, QVariantMap &map, Network *network);
82 void toVariantMap(QVariantMap &map) const override;
84 inline QString className() const override { return "IrcEventNumeric"; }
85 inline void debugInfo(QDebug &dbg) const override
87 dbg << ", num = " << number();
88 NetworkEvent::debugInfo(dbg);
89 dbg << ", target = " << qPrintable(target())
90 << ", prefix = " << qPrintable(prefix())
91 << ", params = " << params();
99 friend class IrcEvent;
103 class COMMON_EXPORT IrcEventRawMessage : public IrcEvent
106 explicit inline IrcEventRawMessage(EventManager::EventType type, Network *network,
107 const QByteArray &rawMessage, const QString &prefix, const QString &target,
108 const QDateTime ×tamp = QDateTime())
109 : IrcEvent(type, network, prefix, QStringList() << target),
110 _rawMessage(rawMessage)
112 setTimestamp(timestamp);
116 inline QString target() const { return params().at(0); }
117 inline void setTarget(const QString &target) { setParams(QStringList() << target); }
119 inline QByteArray rawMessage() const { return _rawMessage; }
120 inline void setRawMessage(const QByteArray &rawMessage) { _rawMessage = rawMessage; }
123 explicit IrcEventRawMessage(EventManager::EventType type, QVariantMap &map, Network *network);
124 void toVariantMap(QVariantMap &map) const override;
126 inline QString className() const override { return "IrcEventRawMessage"; }
127 inline void debugInfo(QDebug &dbg) const override
129 NetworkEvent::debugInfo(dbg);
130 dbg << ", target = " << qPrintable(target())
131 << ", prefix = " << qPrintable(prefix())
132 << ", msg = " << rawMessage();
137 QByteArray _rawMessage;
139 friend class IrcEvent;