cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / common / ctcpevent.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2022 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 #pragma once
22
23 #include "common-export.h"
24
25 #include <utility>
26
27 #include <QUuid>
28
29 #include "ircevent.h"
30
31 class COMMON_EXPORT CtcpEvent : public IrcEvent
32 {
33 public:
34     enum CtcpType
35     {
36         Query,
37         Reply
38     };
39
40     explicit CtcpEvent(EventManager::EventType type,
41                        Network* network,
42                        QHash<IrcTagKey, QString> tags,
43                        QString prefix,
44                        QString target,
45                        CtcpType ctcpType,
46                        QString ctcpCmd,
47                        QString param,
48                        const QDateTime& timestamp = QDateTime(),
49                        const QUuid& uuid = QUuid())
50         : IrcEvent(type, network, std::move(tags), std::move(prefix))
51         , _ctcpType(ctcpType)
52         , _ctcpCmd(std::move(ctcpCmd))
53         , _target(std::move(target))
54         , _param(std::move(param))
55         , _uuid(uuid)
56     {
57         setTimestamp(timestamp);
58     }
59
60     inline CtcpType ctcpType() const { return _ctcpType; }
61     inline void setCtcpType(CtcpType type) { _ctcpType = type; }
62
63     inline QString ctcpCmd() const { return _ctcpCmd; }
64     inline void setCtcpCmd(const QString& ctcpCmd) { _ctcpCmd = ctcpCmd; }
65
66     inline QString target() const { return _target; }
67     inline void setTarget(const QString& target) { _target = target; }
68
69     inline QString param() const { return _param; }
70     inline void setParam(const QString& param) { _param = param; }
71
72     inline QString reply() const { return _reply; }
73     inline void setReply(const QString& reply) { _reply = reply; }
74
75     inline QUuid uuid() const { return _uuid; }
76     inline void setUuid(const QUuid& uuid) { _uuid = uuid; }
77
78     static Event* create(EventManager::EventType type, QVariantMap& map, Network* network);
79
80 protected:
81     explicit CtcpEvent(EventManager::EventType type, QVariantMap& map, Network* network);
82     void toVariantMap(QVariantMap& map) const override;
83
84     inline QString className() const override { return "CtcpEvent"; }
85     inline void debugInfo(QDebug& dbg) const override
86     {
87         NetworkEvent::debugInfo(dbg);
88         dbg << ", prefix = " << qPrintable(prefix())
89             << ", target = " << qPrintable(target())
90             << ", ctcptype = " << (ctcpType() == Query ? "query" : "reply")
91             << ", cmd = " << qPrintable(ctcpCmd())
92             << ", param = " << qPrintable(param())
93             << ", reply = " << qPrintable(reply());
94     }
95
96 private:
97     CtcpType _ctcpType;
98     QString _ctcpCmd;
99     QString _target, _param, _reply;
100     QUuid _uuid;
101 };