Boilerplate work for CoreSessionEventProcessor
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 5 Sep 2010 18:20:32 +0000 (20:20 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 13 Oct 2010 23:06:31 +0000 (01:06 +0200)
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
src/core/coresession.cpp
src/core/coresession.h
src/core/coresessioneventprocessor.cpp [new file with mode: 0644]
src/core/coresessioneventprocessor.h [new file with mode: 0644]

index 8ac1bdd..4a19828 100644 (file)
@@ -25,6 +25,7 @@ set(SOURCES
     corenetwork.cpp
     corenetworkconfig.cpp
     coresession.cpp
     corenetwork.cpp
     corenetworkconfig.cpp
     coresession.cpp
+    coresessioneventprocessor.cpp
     coresettings.cpp
     coreuserinputhandler.cpp
     coreusersettings.cpp
     coresettings.cpp
     coreuserinputhandler.cpp
     coreusersettings.cpp
@@ -55,6 +56,7 @@ set(MOC_HDRS
     corenetwork.h
     corenetworkconfig.h
     coresession.h
     corenetwork.h
     corenetworkconfig.h
     coresession.h
+    coresessioneventprocessor.h
     coreuserinputhandler.h
     ctcphandler.h
     ircserverhandler.h
     coreuserinputhandler.h
     ctcphandler.h
     ircserverhandler.h
index 1c38a87..bb7b8c0 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
+#include "coresession.h"
+
 #include <QtScript>
 
 #include "core.h"
 #include <QtScript>
 
 #include "core.h"
-#include "coresession.h"
 #include "coreuserinputhandler.h"
 #include "coreuserinputhandler.h"
-#include "signalproxy.h"
 #include "corebuffersyncer.h"
 #include "corebacklogmanager.h"
 #include "corebufferviewmanager.h"
 #include "corebuffersyncer.h"
 #include "corebacklogmanager.h"
 #include "corebufferviewmanager.h"
-#include "coreirclisthelper.h"
-#include "corenetworkconfig.h"
-#include "storage.h"
-
 #include "coreidentity.h"
 #include "coreidentity.h"
+#include "coreignorelistmanager.h"
+#include "coreirclisthelper.h"
 #include "corenetwork.h"
 #include "corenetwork.h"
-#include "ircuser.h"
-#include "ircchannel.h"
-
-#include "util.h"
+#include "corenetworkconfig.h"
+#include "coresessioneventprocessor.h"
 #include "coreusersettings.h"
 #include "coreusersettings.h"
+#include "eventmanager.h"
+#include "ircchannel.h"
+#include "ircuser.h"
 #include "logger.h"
 #include "logger.h"
-#include "coreignorelistmanager.h"
+#include "signalproxy.h"
+#include "storage.h"
+#include "util.h"
 
 class ProcessMessagesEvent : public QEvent {
 public:
 
 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),
     _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)
     scriptEngine(new QScriptEngine(this)),
     _processMessages(false),
     _ignoreListManager(this)
@@ -87,6 +90,8 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
   loadSettings();
   initScriptEngine();
 
   loadSettings();
   initScriptEngine();
 
+  eventManager()->registerObject(eventProcessor(), EventManager::Prepend, "process");
+
   // periodically save our session state
   connect(&(Core::instance()->syncTimer()), SIGNAL(timeout()), this, SLOT(saveSessionState()));
 
   // periodically save our session state
   connect(&(Core::instance()->syncTimer()), SIGNAL(timeout()), this, SLOT(saveSessionState()));
 
index 772e7dc..892cd23 100644 (file)
 class CoreBacklogManager;
 class CoreBufferSyncer;
 class CoreBufferViewManager;
 class CoreBacklogManager;
 class CoreBufferSyncer;
 class CoreBufferViewManager;
+class CoreIdentity;
 class CoreIrcListHelper;
 class CoreIrcListHelper;
+class CoreNetwork;
 class CoreNetworkConfig;
 class CoreNetworkConfig;
-class Identity;
-class CoreIdentity;
+class CoreSessionEventProcessor;
+class EventManager;
 class NetworkConnection;
 class NetworkConnection;
-class CoreNetwork;
-struct NetworkInfo;
 class SignalProxy;
 
 class SignalProxy;
 
+struct NetworkInfo;
+
 class QScriptEngine;
 
 class CoreSession : public QObject {
 class QScriptEngine;
 
 class CoreSession : public QObject {
@@ -65,6 +67,9 @@ public:
   const AliasManager &aliasManager() const { return _aliasManager; }
   AliasManager &aliasManager() { return _aliasManager; }
 
   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; }
   inline CoreIrcListHelper *ircListHelper() const { return _ircListHelper; }
 
   inline CoreIgnoreListManager *ignoreListManager() { return &_ignoreListManager; }
@@ -178,6 +183,9 @@ private:
   CoreNetworkConfig *_networkConfig;
   CoreCoreInfo _coreInfo;
 
   CoreNetworkConfig *_networkConfig;
   CoreCoreInfo _coreInfo;
 
+  EventManager *_eventManager;
+  CoreSessionEventProcessor *_eventProcessor;
+
   QScriptEngine *scriptEngine;
 
   QList<RawMessage> _messageQueue;
   QScriptEngine *scriptEngine;
 
   QList<RawMessage> _messageQueue;
diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp
new file mode 100644 (file)
index 0000000..b4a9087
--- /dev/null
@@ -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 (file)
index 0000000..5113f1b
--- /dev/null
@@ -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 <QObject>
+
+class CoreSession;
+
+class CoreSessionEventProcessor : public QObject {
+  Q_OBJECT
+
+public:
+  CoreSessionEventProcessor(CoreSession *session);
+
+  inline CoreSession *coreSession() const { return _coreSession; }
+
+protected:
+
+private:
+  CoreSession *_coreSession;
+};
+
+#endif