Add skeletal EventStringifier
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 28 Sep 2010 16:44:20 +0000 (18:44 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 13 Oct 2010 23:06:32 +0000 (01:06 +0200)
This class is supposed to generate the user-visible messages from IrcEvents,
i.e. it generates MessageEvents. For now, this lives in the CoreSession, which consumes
and converts the MessageEvents into the usual Messages that are then sent to the client.

In the future, this whole class should move into the client, in order to move string generation
out of the core. There's no need to store plaintext strings in the database if we can as well
simply store the IrcEvents, plus this will allow per-client translations.

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

index eb48554..e79337a 100644 (file)
@@ -14,6 +14,7 @@ set(SOURCES
     cliparser.cpp
     event.cpp
     eventmanager.cpp
     cliparser.cpp
     event.cpp
     eventmanager.cpp
+    eventstringifier.cpp
     identity.cpp
     ignorelistmanager.cpp
     ircchannel.cpp
     identity.cpp
     ignorelistmanager.cpp
     ircchannel.cpp
@@ -41,6 +42,7 @@ set(MOC_HDRS
     bufferviewmanager.h
     coreinfo.h
     eventmanager.h
     bufferviewmanager.h
     coreinfo.h
     eventmanager.h
+    eventstringifier.h
     identity.h
     ignorelistmanager.h
     ircchannel.h
     identity.h
     ignorelistmanager.h
     ircchannel.h
diff --git a/src/common/eventstringifier.cpp b/src/common/eventstringifier.cpp
new file mode 100644 (file)
index 0000000..62ae9fd
--- /dev/null
@@ -0,0 +1,25 @@
+/***************************************************************************
+ *   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 "eventstringifier.h"
+
+EventStringifier::EventStringifier(QObject *parent) : QObject(parent) {
+
+}
diff --git a/src/common/eventstringifier.h b/src/common/eventstringifier.h
new file mode 100644 (file)
index 0000000..e87ce65
--- /dev/null
@@ -0,0 +1,41 @@
+/***************************************************************************
+ *   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 EVENTSTRINGIFIER_H
+#define EVENTSTRINGIFIER_H
+
+#include <QObject>
+
+#include "ircevent.h"
+
+//! Generates user-visible MessageEvents from incoming IrcEvents
+
+/* replaces the string-generating parts of the old IrcServerHandler */
+class EventStringifier : public QObject {
+  Q_OBJECT
+
+public:
+  EventStringifier(QObject *parent = 0);
+
+private:
+
+};
+
+#endif
index 52cab60..a33b942 100644 (file)
@@ -35,6 +35,7 @@
 #include "coresessioneventprocessor.h"
 #include "coreusersettings.h"
 #include "eventmanager.h"
 #include "coresessioneventprocessor.h"
 #include "coreusersettings.h"
 #include "eventmanager.h"
+#include "eventstringifier.h"
 #include "ircchannel.h"
 #include "ircparser.h"
 #include "ircuser.h"
 #include "ircchannel.h"
 #include "ircparser.h"
 #include "ircuser.h"
@@ -61,6 +62,7 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
     _networkConfig(new CoreNetworkConfig("GlobalNetworkConfig", this)),
     _coreInfo(this),
     _eventManager(new EventManager(this)),
     _networkConfig(new CoreNetworkConfig("GlobalNetworkConfig", this)),
     _coreInfo(this),
     _eventManager(new EventManager(this)),
+    _eventStringifier(new EventStringifier(this)),
     _eventProcessor(new CoreSessionEventProcessor(this)),
     _ircParser(new IrcParser(this)),
     scriptEngine(new QScriptEngine(this)),
     _eventProcessor(new CoreSessionEventProcessor(this)),
     _ircParser(new IrcParser(this)),
     scriptEngine(new QScriptEngine(this)),
@@ -93,9 +95,10 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
   loadSettings();
   initScriptEngine();
 
   loadSettings();
   initScriptEngine();
 
-  eventManager()->registerObject(ircParser(), EventManager::NormalPriority, "process");
-  eventManager()->registerObject(eventProcessor(), EventManager::HighPriority, "process");
-  eventManager()->registerObject(this, EventManager::LowPriority, "process"); // for sending MessageEvents to the client
+  eventManager()->registerObject(ircParser(), EventManager::NormalPriority);
+  eventManager()->registerObject(eventProcessor(), EventManager::HighPriority);
+  eventManager()->registerObject(eventStringifier(), EventManager::NormalPriority);
+  eventManager()->registerObject(this, EventManager::LowPriority); // for sending MessageEvents to the client
 
   // 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 20a2374..0a52cf1 100644 (file)
@@ -39,6 +39,7 @@ class CoreNetwork;
 class CoreNetworkConfig;
 class CoreSessionEventProcessor;
 class EventManager;
 class CoreNetworkConfig;
 class CoreSessionEventProcessor;
 class EventManager;
+class EventStringifier;
 class IrcParser;
 class MessageEvent;
 class NetworkConnection;
 class IrcParser;
 class MessageEvent;
 class NetworkConnection;
@@ -70,6 +71,7 @@ public:
   AliasManager &aliasManager() { return _aliasManager; }
 
   inline EventManager *eventManager() const { return _eventManager; }
   AliasManager &aliasManager() { return _aliasManager; }
 
   inline EventManager *eventManager() const { return _eventManager; }
+  inline EventStringifier *eventStringifier() const { return _eventStringifier; }
   inline CoreSessionEventProcessor *eventProcessor() const { return _eventProcessor; }
   inline IrcParser *ircParser() const { return _ircParser; }
 
   inline CoreSessionEventProcessor *eventProcessor() const { return _eventProcessor; }
   inline IrcParser *ircParser() const { return _ircParser; }
 
@@ -190,6 +192,7 @@ private:
   CoreCoreInfo _coreInfo;
 
   EventManager *_eventManager;
   CoreCoreInfo _coreInfo;
 
   EventManager *_eventManager;
+  EventStringifier *_eventStringifier; // should eventually move into client
   CoreSessionEventProcessor *_eventProcessor;
   IrcParser *_ircParser;
 
   CoreSessionEventProcessor *_eventProcessor;
   IrcParser *_ircParser;