uisupport: Provide helpers for dealing with widget changes
[quassel.git] / src / core / ircparser.cpp
index 871816d..ea18c00 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "ircparser.h"
 
+#include <QDebug>
+
 #include "corenetwork.h"
 #include "eventmanager.h"
 #include "ircevent.h"
@@ -35,7 +37,11 @@ IrcParser::IrcParser(CoreSession *session) :
     QObject(session),
     _coreSession(session)
 {
-    connect(this, SIGNAL(newEvent(Event *)), coreSession()->eventManager(), SLOT(postEvent(Event *)));
+    // Check if raw IRC logging is enabled
+    _debugLogRawIrc = (Quassel::isOptionSet("debug-irc") || Quassel::isOptionSet("debug-irc-id"));
+    _debugLogRawNetId = Quassel::optionValue("debug-irc-id").toInt();
+
+    connect(this, &IrcParser::newEvent, coreSession()->eventManager(), &EventManager::postEvent);
 }
 
 
@@ -76,7 +82,7 @@ QByteArray IrcParser::decrypt(Network *network, const QString &bufferName, const
 /* used to be handleServerMsg()                                  */
 void IrcParser::processNetworkIncoming(NetworkDataEvent *e)
 {
-    CoreNetwork *net = qobject_cast<CoreNetwork *>(e->network());
+    auto *net = qobject_cast<CoreNetwork *>(e->network());
     if (!net) {
         qWarning() << "Received network event without valid network pointer!";
         return;
@@ -91,6 +97,13 @@ void IrcParser::processNetworkIncoming(NetworkDataEvent *e)
         return;
     }
 
+    // Log the message if enabled and network ID matches or allows all
+    if (_debugLogRawIrc
+            && (_debugLogRawNetId == -1 || net->networkId().toInt() == _debugLogRawNetId)) {
+        // Include network ID
+        qDebug() << "IRC net" << net->networkId() << "<<" << msg;
+    }
+
     // Now we split the raw message into its various parts...
     QString prefix;
     QByteArray trailing;
@@ -226,7 +239,7 @@ void IrcParser::processNetworkIncoming(NetworkDataEvent *e)
                 // :ChanServ!ChanServ@services. NOTICE egst :[#apache] Welcome, this is #apache. Please read the in-channel topic message. This channel is being logged by IRSeekBot. If you have any question please see http://blog.freenode.net/?p=68
                 if (!net->isChannelName(target)) {
                     QString decMsg = net->serverDecode(params.at(1));
-                    QRegExp welcomeRegExp("^\\[([^\\]]+)\\] ");
+                    QRegExp welcomeRegExp(R"(^\[([^\]]+)\] )");
                     if (welcomeRegExp.indexIn(decMsg) != -1) {
                         QString channelname = welcomeRegExp.cap(1);
                         decMsg = decMsg.mid(welcomeRegExp.matchedLength());