Add more Event specializations (IrcEvent*, MessageEvent)
[quassel.git] / src / common / ircevent.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2010 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #ifndef IRCEVENT_H
22 #define IRCEVENT_H
23
24 #include "networkevent.h"
25
26 class IrcEvent : public NetworkEvent {
27 public:
28   explicit IrcEvent(EventManager::EventType type, Network *network, const QString &prefix, const QStringList &params = QStringList())
29     : NetworkEvent(type, network),
30       _prefix(prefix),
31       _params(params)
32   {}
33
34   inline QString prefix() const { return _prefix; }
35   inline void setPrefix(const QString &prefix) { _prefix = prefix; }
36
37   inline QStringList params() const { return _params; }
38   inline void setParams(const QStringList &params) { _params = params; }
39
40 private:
41   QString _prefix;
42   QStringList _params;
43
44 };
45
46 class IrcEventNumeric : public IrcEvent {
47 public:
48   explicit IrcEventNumeric(uint number, Network *network, const QString &prefix, const QString &target, const QStringList &params = QStringList())
49     : IrcEvent(EventManager::IrcEventNumeric, network, prefix, params),
50       _number(number),
51       _target(target)
52   {}
53
54   inline uint number() const { return _number; }
55
56   inline QString target() const { return _target; }
57   inline void setTarget(const QString &target) { _target = target; }
58
59 private:
60   uint _number;
61   QString _target;
62
63 };
64
65 class IrcEventRawMessage : public IrcEvent {
66 public:
67   explicit IrcEventRawMessage(EventManager::EventType type, Network *network, const QString &prefix, const QString &target, const QByteArray &rawMessage)
68     : IrcEvent(type, network, prefix, QStringList() << target),
69       _rawMessage(rawMessage)
70   {}
71
72   inline QString target() const { return params().at(0); }
73   inline void setTarget(const QString &target) { setParams(QStringList() << target); }
74
75   inline QByteArray rawMessage() const { return _rawMessage; }
76   inline void setRawMessage(const QByteArray &rawMessage) { _rawMessage = rawMessage; }
77
78 private:
79   QByteArray _rawMessage;
80 };
81
82 #endif