1 /***************************************************************************
2 * Copyright (C) 2005-2019 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"
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& params) { _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()) << ", params = " << params();
65 class COMMON_EXPORT IrcEventNumeric : public IrcEvent
68 explicit IrcEventNumeric(uint number, Network* network, const QString& prefix, QString target, const QStringList& params = QStringList())
69 : IrcEvent(EventManager::IrcEventNumeric, network, prefix, params)
71 , _target(std::move(target))
74 inline uint number() const { return _number; }
76 inline QString target() const { return _target; }
77 inline void setTarget(const QString& target) { _target = target; }
80 explicit IrcEventNumeric(EventManager::EventType type, QVariantMap& map, Network* network);
81 void toVariantMap(QVariantMap& map) const override;
83 inline QString className() const override { return "IrcEventNumeric"; }
84 inline void debugInfo(QDebug& dbg) const override
86 dbg << ", num = " << number();
87 NetworkEvent::debugInfo(dbg);
88 dbg << ", target = " << qPrintable(target()) << ", prefix = " << qPrintable(prefix()) << ", params = " << params();
95 friend class IrcEvent;
98 class COMMON_EXPORT IrcEventRawMessage : public IrcEvent
101 explicit inline IrcEventRawMessage(EventManager::EventType type,
103 QByteArray rawMessage,
104 const QString& prefix,
105 const QString& target,
106 const QDateTime& timestamp = QDateTime())
107 : IrcEvent(type, network, prefix, QStringList() << target)
108 , _rawMessage(std::move(rawMessage))
110 setTimestamp(timestamp);
113 inline QString target() const { return params().at(0); }
114 inline void setTarget(const QString& target) { setParams(QStringList() << target); }
116 inline QByteArray rawMessage() const { return _rawMessage; }
117 inline void setRawMessage(const QByteArray& rawMessage) { _rawMessage = rawMessage; }
120 explicit IrcEventRawMessage(EventManager::EventType type, QVariantMap& map, Network* network);
121 void toVariantMap(QVariantMap& map) const override;
123 inline QString className() const override { return "IrcEventRawMessage"; }
124 inline void debugInfo(QDebug& dbg) const override
126 NetworkEvent::debugInfo(dbg);
127 dbg << ", target = " << qPrintable(target()) << ", prefix = " << qPrintable(prefix()) << ", msg = " << rawMessage();
131 QByteArray _rawMessage;
133 friend class IrcEvent;