1 /***************************************************************************
2 * Copyright (C) 2005-2012 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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
24 #include "networkevent.h"
27 class IrcEvent : public NetworkEvent {
29 explicit IrcEvent(EventManager::EventType type, Network *network, const QString &prefix, const QStringList ¶ms = QStringList())
30 : NetworkEvent(type, network),
35 inline QString prefix() const { return _prefix; }
36 inline void setPrefix(const QString &prefix) { _prefix = prefix; }
38 inline QString nick() const { return nickFromMask(prefix()); }
40 inline QStringList params() const { return _params; }
41 inline void setParams(const QStringList ¶ms) { _params = params; }
43 static Event *create(EventManager::EventType type, QVariantMap &map, Network *network);
46 explicit IrcEvent(EventManager::EventType type, QVariantMap &map, Network *network);
47 void toVariantMap(QVariantMap &map) const;
49 virtual inline QString className() const { return "IrcEvent"; }
50 virtual inline void debugInfo(QDebug &dbg) const {
51 NetworkEvent::debugInfo(dbg);
52 dbg << ", prefix = " << qPrintable(prefix())
53 << ", params = " << params();
62 class IrcEventNumeric : public IrcEvent {
64 explicit IrcEventNumeric(uint number, Network *network, const QString &prefix, const QString &target, const QStringList ¶ms = QStringList())
65 : IrcEvent(EventManager::IrcEventNumeric, network, prefix, params),
70 inline uint number() const { return _number; }
72 inline QString target() const { return _target; }
73 inline void setTarget(const QString &target) { _target = target; }
76 explicit IrcEventNumeric(EventManager::EventType type, QVariantMap &map, Network *network);
77 void toVariantMap(QVariantMap &map) const;
79 virtual inline QString className() const { return "IrcEventNumeric"; }
80 virtual inline void debugInfo(QDebug &dbg) const {
81 dbg << ", num = " << number();
82 NetworkEvent::debugInfo(dbg);
83 dbg << ", target = " << qPrintable(target())
84 << ", prefix = " << qPrintable(prefix())
85 << ", params = " << params();
92 friend class IrcEvent;
95 class IrcEventRawMessage : public IrcEvent {
97 explicit inline IrcEventRawMessage(EventManager::EventType type, Network *network,
98 const QByteArray &rawMessage, const QString &prefix, const QString &target,
99 const QDateTime ×tamp = QDateTime())
100 : IrcEvent(type, network, prefix, QStringList() << target),
101 _rawMessage(rawMessage)
103 setTimestamp(timestamp);
106 inline QString target() const { return params().at(0); }
107 inline void setTarget(const QString &target) { setParams(QStringList() << target); }
109 inline QByteArray rawMessage() const { return _rawMessage; }
110 inline void setRawMessage(const QByteArray &rawMessage) { _rawMessage = rawMessage; }
113 explicit IrcEventRawMessage(EventManager::EventType type, QVariantMap &map, Network *network);
114 void toVariantMap(QVariantMap &map) const;
116 virtual inline QString className() const { return "IrcEventRawMessage"; }
117 virtual inline void debugInfo(QDebug &dbg) const {
118 NetworkEvent::debugInfo(dbg);
119 dbg << ", target = " << qPrintable(target())
120 << ", prefix = " << qPrintable(prefix())
121 << ", msg = " << rawMessage();
126 QByteArray _rawMessage;
128 friend class IrcEvent;