From 3eebe11329417e77038d860af3b6f35630f40450 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 28 Sep 2010 18:44:20 +0200 Subject: [PATCH] Add skeletal EventStringifier 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 | 2 ++ src/common/eventstringifier.cpp | 25 ++++++++++++++++++++ src/common/eventstringifier.h | 41 +++++++++++++++++++++++++++++++++ src/core/coresession.cpp | 9 +++++--- src/core/coresession.h | 3 +++ 5 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 src/common/eventstringifier.cpp create mode 100644 src/common/eventstringifier.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index eb485549..e79337aa 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -14,6 +14,7 @@ set(SOURCES cliparser.cpp event.cpp eventmanager.cpp + eventstringifier.cpp identity.cpp ignorelistmanager.cpp ircchannel.cpp @@ -41,6 +42,7 @@ set(MOC_HDRS bufferviewmanager.h coreinfo.h eventmanager.h + eventstringifier.h identity.h ignorelistmanager.h ircchannel.h diff --git a/src/common/eventstringifier.cpp b/src/common/eventstringifier.cpp new file mode 100644 index 00000000..62ae9fd9 --- /dev/null +++ b/src/common/eventstringifier.cpp @@ -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 index 00000000..e87ce658 --- /dev/null +++ b/src/common/eventstringifier.h @@ -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 + +#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 diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp index 52cab60b..a33b942c 100644 --- a/src/core/coresession.cpp +++ b/src/core/coresession.cpp @@ -35,6 +35,7 @@ #include "coresessioneventprocessor.h" #include "coreusersettings.h" #include "eventmanager.h" +#include "eventstringifier.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)), + _eventStringifier(new EventStringifier(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(); - 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())); diff --git a/src/core/coresession.h b/src/core/coresession.h index 20a2374e..0a52cf10 100644 --- a/src/core/coresession.h +++ b/src/core/coresession.h @@ -39,6 +39,7 @@ class CoreNetwork; class CoreNetworkConfig; class CoreSessionEventProcessor; class EventManager; +class EventStringifier; class IrcParser; class MessageEvent; class NetworkConnection; @@ -70,6 +71,7 @@ public: 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; } @@ -190,6 +192,7 @@ private: CoreCoreInfo _coreInfo; EventManager *_eventManager; + EventStringifier *_eventStringifier; // should eventually move into client CoreSessionEventProcessor *_eventProcessor; IrcParser *_ircParser; -- 2.20.1