From efa00e5a912c34c37bcc6dad7b8bc6e3a6f3e4fb Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Wed, 6 Aug 2008 21:43:59 +0200 Subject: [PATCH] Introduce AbstractMessageProcessor and its specialization QtUiMessageProcessor. Its task is to create ChatLineModelItems from Messages, which currently happens in Client. As this is too slow, we will once again process incoming messages, in particular backlog packages, asynchronously. Externalizing this and abstracting it away from Client will facilite this. Also the specialization in QtUi will allow us to use GUI features, which will be particularly handy for determining if we can do font rendering outside the GUI thread. --- src/client/CMakeLists.txt | 2 ++ src/client/abstractmessageprocessor.cpp | 41 +++++++++++++++++++++++ src/client/abstractmessageprocessor.h | 44 +++++++++++++++++++++++++ src/qtui/CMakeLists.txt | 2 ++ src/qtui/qtuimessageprocessor.cpp | 41 +++++++++++++++++++++++ src/qtui/qtuimessageprocessor.h | 39 ++++++++++++++++++++++ 6 files changed, 169 insertions(+) create mode 100644 src/client/abstractmessageprocessor.cpp create mode 100644 src/client/abstractmessageprocessor.h create mode 100644 src/qtui/qtuimessageprocessor.cpp create mode 100644 src/qtui/qtuimessageprocessor.h diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index d4a24597..ecb34ddb 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -7,6 +7,7 @@ set(QT_USE_QTDBUS 1) include(${QT_USE_FILE}) set(SOURCES + abstractmessageprocessor.cpp buffer.cpp buffermodel.cpp buffersettings.cpp @@ -24,6 +25,7 @@ set(SOURCES treemodel.cpp) set(MOC_HDRS + abstractmessageprocessor.h buffer.h buffermodel.h client.h diff --git a/src/client/abstractmessageprocessor.cpp b/src/client/abstractmessageprocessor.cpp new file mode 100644 index 00000000..5ba8683f --- /dev/null +++ b/src/client/abstractmessageprocessor.cpp @@ -0,0 +1,41 @@ +/*************************************************************************** +* Copyright (C) 2005-08 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 "abstractmessageprocessor.h" + +#include "client.h" + +AbstractMessageProcessor::AbstractMessageProcessor(QObject *parent) : QObject(parent) { + + + +} + +void AbstractMessageProcessor::process(Message &msg) { + processMessage(msg); + Client::buffer(msg.bufferInfo())->updateActivityLevel(msg); +} + +void AbstractMessageProcessor::process(QList &msgs) { + processMessages(msgs); + foreach(Message msg, msgs) { + Client::buffer(msg.bufferInfo())->updateActivityLevel(msg); + } +} diff --git a/src/client/abstractmessageprocessor.h b/src/client/abstractmessageprocessor.h new file mode 100644 index 00000000..b140ac19 --- /dev/null +++ b/src/client/abstractmessageprocessor.h @@ -0,0 +1,44 @@ +/*************************************************************************** +* Copyright (C) 2005-08 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 ABSTRACTMESSAGEPROCESSOR_H_ +#define ABSTRACTMESSAGEPROCESSOR_H_ + +#include "message.h" + +class AbstractMessageProcessor : public QObject { + Q_OBJECT + + public: + AbstractMessageProcessor(QObject *parent); + + public slots: + void process(Message &msg); + void process(QList &msgs); + + signals: + + protected: + virtual void processMessage(Message &msg) = 0; + virtual void processMessages(QList &msgs) = 0; + +}; + +#endif diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 2ae71a35..6c2c18de 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -26,6 +26,7 @@ set(SOURCES mainwin.cpp nicklistwidget.cpp qtui.cpp + qtuimessageprocessor.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp @@ -53,6 +54,7 @@ set(MOC_HDRS mainwin.h nicklistwidget.h qtui.h + qtuimessageprocessor.h settingsdlg.h settingspagedlg.h titlesetter.h diff --git a/src/qtui/qtuimessageprocessor.cpp b/src/qtui/qtuimessageprocessor.cpp new file mode 100644 index 00000000..e110d61e --- /dev/null +++ b/src/qtui/qtuimessageprocessor.cpp @@ -0,0 +1,41 @@ +/*************************************************************************** +* Copyright (C) 2005-08 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 "qtuimessageprocessor.h" + +#include "client.h" +#include "messagemodel.h" + +QtUiMessageProcessor::QtUiMessageProcessor(QObject *parent) : AbstractMessageProcessor(parent) { + + +} + +void QtUiMessageProcessor::processMessage(Message &msg) { + Client::checkForHighlight(msg); + Client::messageModel()->insertMessage(msg); +} + +void QtUiMessageProcessor::processMessages(QList &msgs) { + foreach(Message msg, msgs) { + Client::checkForHighlight(msg); + Client::messageModel()->insertMessage(msg); + } +} diff --git a/src/qtui/qtuimessageprocessor.h b/src/qtui/qtuimessageprocessor.h new file mode 100644 index 00000000..91cc5770 --- /dev/null +++ b/src/qtui/qtuimessageprocessor.h @@ -0,0 +1,39 @@ +/*************************************************************************** +* Copyright (C) 2005-08 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 QTUIMESSAGEPROCESSOR_H_ +#define QTUIMESSAGEPROCESSOR_H_ + +#include "abstractmessageprocessor.h" + +class QtUiMessageProcessor : public AbstractMessageProcessor { + Q_OBJECT + + public: + QtUiMessageProcessor(QObject *parent); + + + protected: + void processMessage(Message &msg); + void processMessages(QList &msgs); + +}; + +#endif -- 2.20.1