From e9e9f28438f4e11995e6b444928da1c0f8487804 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Sun, 5 Sep 2010 20:20:32 +0200 Subject: [PATCH] Boilerplate work for CoreSessionEventProcessor So far just a dummy object that doesn't do anything, this is supposed to handle events that change the session state (the syncable objects) later. We also add an EventManager instance. Oh, and some #include cleanup. --- src/core/CMakeLists.txt | 2 ++ src/core/coresession.cpp | 27 ++++++++++------- src/core/coresession.h | 16 +++++++--- src/core/coresessioneventprocessor.cpp | 30 ++++++++++++++++++ src/core/coresessioneventprocessor.h | 42 ++++++++++++++++++++++++++ 5 files changed, 102 insertions(+), 15 deletions(-) create mode 100644 src/core/coresessioneventprocessor.cpp create mode 100644 src/core/coresessioneventprocessor.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8ac1bddc..4a19828f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -25,6 +25,7 @@ set(SOURCES corenetwork.cpp corenetworkconfig.cpp coresession.cpp + coresessioneventprocessor.cpp coresettings.cpp coreuserinputhandler.cpp coreusersettings.cpp @@ -55,6 +56,7 @@ set(MOC_HDRS corenetwork.h corenetworkconfig.h coresession.h + coresessioneventprocessor.h coreuserinputhandler.h ctcphandler.h ircserverhandler.h diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 1c38a87a..bb7b8c0f 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -18,28 +18,29 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "coresession.h" + #include #include "core.h" -#include "coresession.h" #include "coreuserinputhandler.h" -#include "signalproxy.h" #include "corebuffersyncer.h" #include "corebacklogmanager.h" #include "corebufferviewmanager.h" -#include "coreirclisthelper.h" -#include "corenetworkconfig.h" -#include "storage.h" - #include "coreidentity.h" +#include "coreignorelistmanager.h" +#include "coreirclisthelper.h" #include "corenetwork.h" -#include "ircuser.h" -#include "ircchannel.h" - -#include "util.h" +#include "corenetworkconfig.h" +#include "coresessioneventprocessor.h" #include "coreusersettings.h" +#include "eventmanager.h" +#include "ircchannel.h" +#include "ircuser.h" #include "logger.h" -#include "coreignorelistmanager.h" +#include "signalproxy.h" +#include "storage.h" +#include "util.h" class ProcessMessagesEvent : public QEvent { public: @@ -57,6 +58,8 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) _ircListHelper(new CoreIrcListHelper(this)), _networkConfig(new CoreNetworkConfig("GlobalNetworkConfig", this)), _coreInfo(this), + _eventManager(new EventManager(this)), + _eventProcessor(new CoreSessionEventProcessor(this)), scriptEngine(new QScriptEngine(this)), _processMessages(false), _ignoreListManager(this) @@ -87,6 +90,8 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent) loadSettings(); initScriptEngine(); + eventManager()->registerObject(eventProcessor(), EventManager::Prepend, "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 772e7dc3..892cd23e 100644 --- a/src/core/coresession.h +++ b/src/core/coresession.h @@ -33,15 +33,17 @@ class CoreBacklogManager; class CoreBufferSyncer; class CoreBufferViewManager; +class CoreIdentity; class CoreIrcListHelper; +class CoreNetwork; class CoreNetworkConfig; -class Identity; -class CoreIdentity; +class CoreSessionEventProcessor; +class EventManager; class NetworkConnection; -class CoreNetwork; -struct NetworkInfo; class SignalProxy; +struct NetworkInfo; + class QScriptEngine; class CoreSession : public QObject { @@ -65,6 +67,9 @@ public: const AliasManager &aliasManager() const { return _aliasManager; } AliasManager &aliasManager() { return _aliasManager; } + inline EventManager *eventManager() const { return _eventManager; } + inline CoreSessionEventProcessor *eventProcessor() const { return _eventProcessor; } + inline CoreIrcListHelper *ircListHelper() const { return _ircListHelper; } inline CoreIgnoreListManager *ignoreListManager() { return &_ignoreListManager; } @@ -178,6 +183,9 @@ private: CoreNetworkConfig *_networkConfig; CoreCoreInfo _coreInfo; + EventManager *_eventManager; + CoreSessionEventProcessor *_eventProcessor; + QScriptEngine *scriptEngine; QList _messageQueue; diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp new file mode 100644 index 00000000..b4a90877 --- /dev/null +++ b/src/core/coresessioneventprocessor.cpp @@ -0,0 +1,30 @@ +/*************************************************************************** + * 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 "coresessioneventprocessor.h" + +#include "coresession.h" + +CoreSessionEventProcessor::CoreSessionEventProcessor(CoreSession *session) + : QObject(session), + _coreSession(session) +{ + +} diff --git a/src/core/coresessioneventprocessor.h b/src/core/coresessioneventprocessor.h new file mode 100644 index 00000000..5113f1bc --- /dev/null +++ b/src/core/coresessioneventprocessor.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * 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 CORESESSIONEVENTPROCESSOR_H +#define CORESESSIONEVENTPROCESSOR_H + +#include + +class CoreSession; + +class CoreSessionEventProcessor : public QObject { + Q_OBJECT + +public: + CoreSessionEventProcessor(CoreSession *session); + + inline CoreSession *coreSession() const { return _coreSession; } + +protected: + +private: + CoreSession *_coreSession; +}; + +#endif -- 2.20.1