1 /***************************************************************************
2 * Copyright (C) 2005-2014 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 ***************************************************************************/
24 #include "networkevent.h"
27 class IrcEvent : public NetworkEvent
30 explicit IrcEvent(EventManager::EventType type, Network *network, const QString &prefix, const QStringList ¶ms = QStringList())
31 : NetworkEvent(type, network),
36 inline QString prefix() const { return _prefix; }
37 inline void setPrefix(const QString &prefix) { _prefix = prefix; }
39 inline QString nick() const { return nickFromMask(prefix()); }
41 inline QStringList params() const { return _params; }
42 inline void setParams(const QStringList ¶ms) { _params = params; }
44 static Event *create(EventManager::EventType type, QVariantMap &map, Network *network);
47 explicit IrcEvent(EventManager::EventType type, QVariantMap &map, Network *network);
48 void toVariantMap(QVariantMap &map) const;
50 virtual inline QString className() const { return "IrcEvent"; }
51 virtual inline void debugInfo(QDebug &dbg) const
53 NetworkEvent::debugInfo(dbg);
54 dbg << ", prefix = " << qPrintable(prefix())
55 << ", params = " << params();
65 class IrcEventNumeric : public IrcEvent
68 explicit IrcEventNumeric(uint number, Network *network, const QString &prefix, const QString &target, const QStringList ¶ms = QStringList())
69 : IrcEvent(EventManager::IrcEventNumeric, network, prefix, params),
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;
83 virtual inline QString className() const { return "IrcEventNumeric"; }
84 virtual inline void debugInfo(QDebug &dbg) const
86 dbg << ", num = " << number();
87 NetworkEvent::debugInfo(dbg);
88 dbg << ", target = " << qPrintable(target())
89 << ", prefix = " << qPrintable(prefix())
90 << ", params = " << params();
98 friend class IrcEvent;
102 class IrcEventRawMessage : public IrcEvent
105 explicit inline IrcEventRawMessage(EventManager::EventType type, Network *network,
106 const QByteArray &rawMessage, const QString &prefix, const QString &target,
107 const QDateTime ×tamp = QDateTime())
108 : IrcEvent(type, network, prefix, QStringList() << target),
109 _rawMessage(rawMessage)
111 setTimestamp(timestamp);
115 inline QString target() const { return params().at(0); }
116 inline void setTarget(const QString &target) { setParams(QStringList() << target); }
118 inline QByteArray rawMessage() const { return _rawMessage; }
119 inline void setRawMessage(const QByteArray &rawMessage) { _rawMessage = rawMessage; }
122 explicit IrcEventRawMessage(EventManager::EventType type, QVariantMap &map, Network *network);
123 void toVariantMap(QVariantMap &map) const;
125 virtual inline QString className() const { return "IrcEventRawMessage"; }
126 virtual inline void debugInfo(QDebug &dbg) const
128 NetworkEvent::debugInfo(dbg);
129 dbg << ", target = " << qPrintable(target())
130 << ", prefix = " << qPrintable(prefix())
131 << ", msg = " << rawMessage();
136 QByteArray _rawMessage;
138 friend class IrcEvent;