From 86837eac3346857733f3488acccca9dc2c45605e Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Sun, 12 Sep 2010 16:01:16 +0200 Subject: [PATCH 1/1] Add IrcParser to handle data between the ircd and Quassel 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 | 2 ++ src/core/corenetwork.cpp | 12 ++++++----- src/core/coresession.cpp | 5 ++++- src/core/coresession.h | 3 +++ src/core/ircparser.cpp | 37 +++++++++++++++++++++++++++++++++ src/core/ircparser.h | 44 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 src/core/ircparser.cpp create mode 100644 src/core/ircparser.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 4a19828f..f1f7e50d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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 diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index b7ec55d2..05da4135 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -20,14 +20,14 @@ #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)); } } diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index bb7b8c0f..2e138bbe 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -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())); diff --git a/src/core/coresession.h b/src/core/coresession.h index 892cd23e..3f36497b 100644 --- a/src/core/coresession.h +++ b/src/core/coresession.h @@ -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 index 00000000..10a5c8d3 --- /dev/null +++ b/src/core/ircparser.cpp @@ -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(event); + + qDebug() << "received" << e->data(); +} diff --git a/src/core/ircparser.h b/src/core/ircparser.h new file mode 100644 index 00000000..c1400f11 --- /dev/null +++ b/src/core/ircparser.h @@ -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 + +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 -- 2.20.1