1 | /*************************************************************************** |
2 | * Copyright (C) 2005-2014 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 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
19 | ***************************************************************************/ |
20 | |
21 | #ifndef CTCPEVENT_H |
22 | #define CTCPEVENT_H |
23 | |
24 | #include "ircevent.h" |
25 | |
26 | #include <QUuid> |
27 | |
28 | class CtcpEvent : public IrcEvent |
29 | { |
30 | public: |
31 | enum CtcpType { |
32 | Query, |
33 | Reply |
34 | }; |
35 | |
36 | explicit CtcpEvent(EventManager::EventType type, Network *network, const QString &prefix, const QString &target, |
37 | CtcpType ctcpType, const QString &ctcpCmd, const QString ¶m, |
38 | const QDateTime ×tamp = QDateTime(), const QUuid &uuid = QUuid()) |
39 | : IrcEvent(type, network, prefix), |
40 | _ctcpType(ctcpType), |
41 | _ctcpCmd(ctcpCmd), |
42 | _target(target), |
43 | _param(param), |
44 | _uuid(uuid) |
45 | { |
46 | setTimestamp(timestamp); |
47 | } |
48 | |
49 | |
50 | inline CtcpType ctcpType() const { return _ctcpType; } |
51 | inline void setCtcpType(CtcpType type) { _ctcpType = type; } |
52 | |
53 | inline QString ctcpCmd() const { return _ctcpCmd; } |
54 | inline void setCtcpCmd(const QString &ctcpCmd) { _ctcpCmd = ctcpCmd; } |
55 | |
56 | inline QString target() const { return _target; } |
57 | inline void setTarget(const QString &target) { _target = target; } |
58 | |
59 | inline QString param() const { return _param; } |
60 | inline void setParam(const QString ¶m) { _param = param; } |
61 | |
62 | inline QString reply() const { return _reply; } |
63 | inline void setReply(const QString &reply) { _reply = reply; } |
64 | |
65 | inline QUuid uuid() const { return _uuid; } |
66 | inline void setUuid(const QUuid &uuid) { _uuid = uuid; } |
67 | |
68 | static Event *create(EventManager::EventType type, QVariantMap &map, Network *network); |
69 | |
70 | protected: |
71 | explicit CtcpEvent(EventManager::EventType type, QVariantMap &map, Network *network); |
72 | void toVariantMap(QVariantMap &map) const; |
73 | |
74 | virtual inline QString className() const { return "CtcpEvent" ; } |
75 | virtual inline void debugInfo(QDebug &dbg) const |
76 | { |
77 | NetworkEvent::debugInfo(dbg); |
78 | dbg << ", prefix = " << qPrintable(prefix()) |
79 | << ", target = " << qPrintable(target()) |
80 | << ", ctcptype = " << (ctcpType() == Query ? "query" : "reply" ) |
81 | << ", cmd = " << qPrintable(ctcpCmd()) |
82 | << ", param = " << qPrintable(param()) |
83 | << ", reply = " << qPrintable(reply()); |
84 | } |
85 | |
86 | |
87 | private: |
88 | CtcpType _ctcpType; |
89 | QString _ctcpCmd; |
90 | QString _target, _param, _reply; |
91 | QUuid _uuid; |
92 | }; |
93 | |
94 | |
95 | #endif |
96 | |