src: Yearly copyright bump
[quassel.git] / src / common / ircevent.h
index a9d7880..c25d899 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2013 by the Quassel Project                        *
+ *   Copyright (C) 2005-2020 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef IRCEVENT_H
-#define IRCEVENT_H
+#pragma once
 
+#include "common-export.h"
+
+#include <utility>
+
+#include "irctag.h"
 #include "networkevent.h"
 #include "util.h"
 
-class IrcEvent : public NetworkEvent
+class COMMON_EXPORT IrcEvent : public NetworkEvent
 {
 public:
-    explicit IrcEvent(EventManager::EventType type, Network *network, const QString &prefix, const QStringList &params = QStringList())
-        : NetworkEvent(type, network),
-        _prefix(prefix),
-        _params(params)
+    explicit IrcEvent(
+        EventManager::EventType type, Network* network, QHash<IrcTagKey, QString> tags, QString prefix, QStringList params = {})
+        : NetworkEvent(type, network)
+        , _tags(std::move(tags))
+        , _prefix(std::move(prefix))
+        , _params(std::move(params))
     {}
 
     inline QString prefix() const { return _prefix; }
-    inline void setPrefix(const QString &prefix) { _prefix = prefix; }
+    inline void setPrefix(const QString& prefix) { _prefix = prefix; }
+
+    inline QHash<IrcTagKey, QString> tags() const { return _tags; }
+    inline void setTags(const QHash<IrcTagKey, QString>& tags) { _tags = tags; }
 
     inline QString nick() const { return nickFromMask(prefix()); }
 
     inline QStringList params() const { return _params; }
-    inline void setParams(const QStringList &params) { _params = params; }
+    inline void setParams(const QStringListparams) { _params = params; }
 
-    static Event *create(EventManager::EventType type, QVariantMap &map, Network *network);
+    static Event* create(EventManager::EventType type, QVariantMap& map, Network* network);
 
 protected:
-    explicit IrcEvent(EventManager::EventType type, QVariantMap &map, Network *network);
-    void toVariantMap(QVariantMap &map) const;
+    explicit IrcEvent(EventManager::EventType type, QVariantMap& map, Network* network);
+    void toVariantMap(QVariantMap& map) const override;
 
-    virtual inline QString className() const { return "IrcEvent"; }
-    virtual inline void debugInfo(QDebug &dbg) const
+    inline QString className() const override { return "IrcEvent"; }
+    inline void debugInfo(QDebug& dbg) const override
     {
         NetworkEvent::debugInfo(dbg);
-        dbg << ", prefix = " << qPrintable(prefix())
-            << ", params = " << params();
+        dbg << ", prefix = " << qPrintable(prefix()) << ", params = " << params();
     }
 
-
 private:
+    QHash<IrcTagKey, QString> _tags;
     QString _prefix;
     QStringList _params;
 };
 
-
-class IrcEventNumeric : public IrcEvent
+class COMMON_EXPORT IrcEventNumeric : public IrcEvent
 {
 public:
-    explicit IrcEventNumeric(uint number, Network *network, const QString &prefix, const QString &target, const QStringList &params = QStringList())
-        : IrcEvent(EventManager::IrcEventNumeric, network, prefix, params),
-        _number(number),
-        _target(target)
+    explicit IrcEventNumeric(uint number,
+                             Network* network,
+                             QHash<IrcTagKey, QString> tags,
+                             QString prefix,
+                             QString target,
+                             QStringList params = {})
+        : IrcEvent(EventManager::IrcEventNumeric, network, std::move(tags), std::move(prefix), std::move(params))
+        , _number(number)
+        , _target(std::move(target))
     {}
 
     inline uint number() const { return _number; }
 
     inline QString target() const { return _target; }
-    inline void setTarget(const QString &target) { _target = target; }
+    inline void setTarget(const QStringtarget) { _target = target; }
 
 protected:
-    explicit IrcEventNumeric(EventManager::EventType type, QVariantMap &map, Network *network);
-    void toVariantMap(QVariantMap &map) const;
+    explicit IrcEventNumeric(EventManager::EventType type, QVariantMap& map, Network* network);
+    void toVariantMap(QVariantMap& map) const override;
 
-    virtual inline QString className() const { return "IrcEventNumeric"; }
-    virtual inline void debugInfo(QDebug &dbg) const
+    inline QString className() const override { return "IrcEventNumeric"; }
+    inline void debugInfo(QDebug& dbg) const override
     {
         dbg << ", num = " << number();
         NetworkEvent::debugInfo(dbg);
@@ -90,7 +102,6 @@ protected:
             << ", params = " << params();
     }
 
-
 private:
     uint _number;
     QString _target;
@@ -98,32 +109,34 @@ private:
     friend class IrcEvent;
 };
 
-
-class IrcEventRawMessage : public IrcEvent
+class COMMON_EXPORT IrcEventRawMessage : public IrcEvent
 {
 public:
-    explicit inline IrcEventRawMessage(EventManager::EventType type, Network *network,
-        const QByteArray &rawMessage, const QString &prefix, const QString &target,
-        const QDateTime &timestamp = QDateTime())
-        : IrcEvent(type, network, prefix, QStringList() << target),
-        _rawMessage(rawMessage)
+    explicit IrcEventRawMessage(EventManager::EventType type,
+                                Network* network,
+                                QHash<IrcTagKey, QString> tags,
+                                QByteArray rawMessage,
+                                QString prefix,
+                                QString target,
+                                const QDateTime& timestamp = QDateTime())
+        : IrcEvent(type, network, std::move(tags), std::move(prefix), QStringList() << target)
+        , _rawMessage(std::move(rawMessage))
     {
         setTimestamp(timestamp);
     }
 
-
     inline QString target() const { return params().at(0); }
-    inline void setTarget(const QString &target) { setParams(QStringList() << target); }
+    inline void setTarget(const QStringtarget) { setParams(QStringList() << target); }
 
     inline QByteArray rawMessage() const { return _rawMessage; }
-    inline void setRawMessage(const QByteArray &rawMessage) { _rawMessage = rawMessage; }
+    inline void setRawMessage(const QByteArrayrawMessage) { _rawMessage = rawMessage; }
 
 protected:
-    explicit IrcEventRawMessage(EventManager::EventType type, QVariantMap &map, Network *network);
-    void toVariantMap(QVariantMap &map) const;
+    explicit IrcEventRawMessage(EventManager::EventType type, QVariantMap& map, Network* network);
+    void toVariantMap(QVariantMap& map) const override;
 
-    virtual inline QString className() const { return "IrcEventRawMessage"; }
-    virtual inline void debugInfo(QDebug &dbg) const
+    inline QString className() const override { return "IrcEventRawMessage"; }
+    inline void debugInfo(QDebug& dbg) const override
     {
         NetworkEvent::debugInfo(dbg);
         dbg << ", target = " << qPrintable(target())
@@ -131,12 +144,8 @@ protected:
             << ", msg = " << rawMessage();
     }
 
-
 private:
     QByteArray _rawMessage;
 
     friend class IrcEvent;
 };
-
-
-#endif