cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / core / coresession.h
index b8da03c..fb103f7 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2018 by the Quassel Project                        *
+ *   Copyright (C) 2005-2022 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -21,6 +21,7 @@
 #pragma once
 
 #include <utility>
+#include <vector>
 
 #include <QHash>
 #include <QSet>
@@ -32,6 +33,7 @@
 #include "coreignorelistmanager.h"
 #include "coreinfo.h"
 #include "message.h"
+#include "metricsserver.h"
 #include "peer.h"
 #include "protocol.h"
 #include "storage.h"
@@ -52,14 +54,11 @@ class EventStringifier;
 class InternalPeer;
 class IrcParser;
 class MessageEvent;
-class NetworkConnection;
 class RemotePeer;
 class SignalProxy;
 
 struct NetworkInfo;
 
-class QScriptEngine;
-
 class CoreSession : public QObject
 {
     Q_OBJECT
@@ -67,7 +66,7 @@ class CoreSession : public QObject
 public:
     CoreSession(UserId, bool restoreState, bool strictIdentEnabled, QObject* parent = nullptr);
 
-    QList<BufferInfo> buffers() const;
+    std::vector<BufferInfo> buffers() const;
     inline UserId user() const { return _user; }
     CoreNetwork* network(NetworkId) const;
     CoreIdentity* identity(IdentityId) const;
@@ -83,7 +82,6 @@ public:
     const QString strictCompliantIdent(const CoreIdentity* identity);
 
     inline CoreNetworkConfig* networkConfig() const { return _networkConfig; }
-    NetworkConnection* networkConnection(NetworkId) const;
 
     Protocol::SessionState sessionState() const;
 
@@ -164,7 +162,7 @@ public slots:
      * @param[in] msg             Away message, or blank to set unaway
      * @param[in] skipFormatting  If true, skip timestamp formatting codes (e.g. if already done)
      */
-    void globalAway(const QString& msg = QString(), const bool skipFormatting = false);
+    void globalAway(const QString& msg = QString(), bool skipFormatting = false);
 
 signals:
     void initialized();
@@ -174,8 +172,6 @@ signals:
     void displayMsg(Message message);
     void displayStatusMsg(QString, QString);
 
-    void scriptResult(QString result);
-
     //! Identity has been created.
     /** This signal is propagated to the clients to tell them that the given identity has been created.
      *  \param identity The new identity.
@@ -203,18 +199,10 @@ private slots:
     void removeClient(Peer* peer);
 
     void recvStatusMsgFromServer(QString msg);
-    void recvMessageFromServer(NetworkId networkId,
-                               Message::Type,
-                               BufferInfo::Type,
-                               const QString& target,
-                               const QString& text,
-                               const QString& sender = "",
-                               Message::Flags flags = Message::None);
+    void recvMessageFromServer(RawMessage msg);
 
     void destroyNetwork(NetworkId);
 
-    void scriptRequest(QString script);
-
     void clientsConnected();
     void clientsDisconnected();
 
@@ -228,7 +216,6 @@ private:
     void processMessages();
 
     void loadSettings();
-    void initScriptEngine();
 
     /// Hook for converting events to the old displayMsg() handlers
     Q_INVOKABLE void processMessageEvent(MessageEvent* event);
@@ -260,8 +247,6 @@ private:
     CtcpParser* _ctcpParser;
     IrcParser* _ircParser;
 
-    QScriptEngine* scriptEngine;
-
     /**
      * This method obtains the prefixes of the message's sender within a channel, by looking up their channelmodes, and
      * processing them to prefixes based on the network's settings.
@@ -287,10 +272,35 @@ private:
     bool _processMessages;
     CoreIgnoreListManager _ignoreListManager;
     CoreHighlightRuleManager _highlightRuleManager;
+    MetricsServer* _metricsServer{nullptr};
+};
+
+struct NetworkInternalMessage
+{
+    Message::Type type;
+    BufferInfo::Type bufferType;
+    QString target;
+    QString text;
+    QString sender;
+    Message::Flags flags;
+    NetworkInternalMessage(Message::Type type,
+                           BufferInfo::Type bufferType,
+                           QString target,
+                           QString text,
+                           QString sender = "",
+                           Message::Flags flags = Message::None)
+        : type(type)
+        , bufferType(bufferType)
+        , target(std::move(target))
+        , text(std::move(text))
+        , sender(std::move(sender))
+        , flags(flags)
+    {}
 };
 
 struct RawMessage
 {
+    QDateTime timestamp;
     NetworkId networkId;
     Message::Type type;
     BufferInfo::Type bufferType;
@@ -298,9 +308,17 @@ struct RawMessage
     QString text;
     QString sender;
     Message::Flags flags;
-    RawMessage(
-        NetworkId networkId, Message::Type type, BufferInfo::Type bufferType, QString target, QString text, QString sender, Message::Flags flags)
-        : networkId(networkId)
+
+    RawMessage(QDateTime timestamp,
+               NetworkId networkId,
+               Message::Type type,
+               BufferInfo::Type bufferType,
+               QString target,
+               QString text,
+               QString sender,
+               Message::Flags flags)
+        : timestamp(std::move(timestamp))
+        , networkId(networkId)
         , type(type)
         , bufferType(bufferType)
         , target(std::move(target))
@@ -308,4 +326,16 @@ struct RawMessage
         , sender(std::move(sender))
         , flags(flags)
     {}
+
+    RawMessage(NetworkId networkId,
+               const NetworkInternalMessage& msg)
+        : timestamp(QDateTime::currentDateTimeUtc())
+        , networkId(networkId)
+        , type(msg.type)
+        , bufferType(msg.bufferType)
+        , target(msg.target)
+        , text(msg.text)
+        , sender(msg.sender)
+        , flags(msg.flags)
+    {}
 };