Add IrcParser to handle data between the ircd and Quassel
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 12 Sep 2010 14:01:16 +0000 (16:01 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 13 Oct 2010 23:06:31 +0000 (01:06 +0200)
This class processes data from the ircd(via NetworkDataEvent)  and is supposed to
generate appropriate specialized events once this skeleton actually has an implementation.
IrcParser will be IrcServerHandler's successor in many respects.

src/core/CMakeLists.txt
src/core/corenetwork.cpp
src/core/coresession.cpp
src/core/coresession.h
src/core/ircparser.cpp [new file with mode: 0644]
src/core/ircparser.h [new file with mode: 0644]

index 4a19828..f1f7e50 100644 (file)
@@ -30,6 +30,7 @@ set(SOURCES
     coreuserinputhandler.cpp
     coreusersettings.cpp
     ctcphandler.cpp
+    ircparser.cpp
     ircserverhandler.cpp
     netsplit.cpp
     postgresqlstorage.cpp
@@ -59,6 +60,7 @@ set(MOC_HDRS
     coresessioneventprocessor.h
     coreuserinputhandler.h
     ctcphandler.h
+    ircparser.h
     ircserverhandler.h
     netsplit.h
     postgresqlstorage.h
index b7ec55d..05da413 100644 (file)
 
 #include "corenetwork.h"
 
+#include "ctcphandler.h"
 #include "core.h"
-#include "coresession.h"
 #include "coreidentity.h"
 #include "corenetworkconfig.h"
-
-#include "ircserverhandler.h"
+#include "coresession.h"
 #include "coreuserinputhandler.h"
-#include "ctcphandler.h"
+#include "ircserverhandler.h"
+#include "networkevent.h"
 
 INIT_SYNCABLE_OBJECT(CoreNetwork)
 CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session)
@@ -327,7 +327,9 @@ void CoreNetwork::setMyNick(const QString &mynick) {
 void CoreNetwork::socketHasData() {
   while(socket.canReadLine()) {
     QByteArray s = socket.readLine().trimmed();
-    ircServerHandler()->handleServerMsg(s);
+    ircServerHandler()->handleServerMsg(s); // FIXME remove with events
+
+    coreSession()->eventManager()->sendEvent(new NetworkDataEvent(EventManager::NetworkIncoming, this, s));
   }
 }
 
index bb7b8c0..2e138bb 100644 (file)
@@ -36,6 +36,7 @@
 #include "coreusersettings.h"
 #include "eventmanager.h"
 #include "ircchannel.h"
+#include "ircparser.h"
 #include "ircuser.h"
 #include "logger.h"
 #include "signalproxy.h"
@@ -60,6 +61,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
     _coreInfo(this),
     _eventManager(new EventManager(this)),
     _eventProcessor(new CoreSessionEventProcessor(this)),
+    _ircParser(new IrcParser(this)),
     scriptEngine(new QScriptEngine(this)),
     _processMessages(false),
     _ignoreListManager(this)
@@ -90,7 +92,8 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
   loadSettings();
   initScriptEngine();
 
-  eventManager()->registerObject(eventProcessor(), EventManager::Prepend, "process");
+  eventManager()->registerObject(ircParser(), EventManager::NormalPriority, "process");
+  eventManager()->registerObject(eventProcessor(), EventManager::HighPriority, "process");
 
   // periodically save our session state
   connect(&(Core::instance()->syncTimer()), SIGNAL(timeout()), this, SLOT(saveSessionState()));
index 892cd23..3f36497 100644 (file)
@@ -39,6 +39,7 @@ class CoreNetwork;
 class CoreNetworkConfig;
 class CoreSessionEventProcessor;
 class EventManager;
+class IrcParser;
 class NetworkConnection;
 class SignalProxy;
 
@@ -69,6 +70,7 @@ public:
 
   inline EventManager *eventManager() const { return _eventManager; }
   inline CoreSessionEventProcessor *eventProcessor() const { return _eventProcessor; }
+  inline IrcParser *ircParser() const { return _ircParser; }
 
   inline CoreIrcListHelper *ircListHelper() const { return _ircListHelper; }
 
@@ -185,6 +187,7 @@ private:
 
   EventManager *_eventManager;
   CoreSessionEventProcessor *_eventProcessor;
+  IrcParser *_ircParser;
 
   QScriptEngine *scriptEngine;
 
diff --git a/src/core/ircparser.cpp b/src/core/ircparser.cpp
new file mode 100644 (file)
index 0000000..10a5c8d
--- /dev/null
@@ -0,0 +1,37 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2010 by the Quassel Project                        *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "ircparser.h"
+
+#include "coresession.h"
+#include "networkevent.h"
+
+IrcParser::IrcParser(CoreSession *session) :
+  QObject(session),
+  _coreSession(session)
+{
+
+}
+
+void IrcParser::processNetworkIncoming(Event *event) {
+  NetworkDataEvent *e = static_cast<NetworkDataEvent *>(event);
+
+  qDebug() << "received" << e->data();
+}
diff --git a/src/core/ircparser.h b/src/core/ircparser.h
new file mode 100644 (file)
index 0000000..c1400f1
--- /dev/null
@@ -0,0 +1,44 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2010 by the Quassel Project                        *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef IRCPARSER_H
+#define IRCPARSER_H
+
+#include <QObject>
+
+class CoreSession;
+class Event;
+
+class IrcParser : public QObject {
+  Q_OBJECT
+
+public:
+  IrcParser(CoreSession *session);
+
+  inline CoreSession *coreSession() const { return _coreSession; }
+
+protected:
+  Q_INVOKABLE void processNetworkIncoming(Event *e);
+
+private:
+  CoreSession *_coreSession;
+};
+
+#endif