Introduce AbstractMessageProcessor and its specialization QtUiMessageProcessor.
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 6 Aug 2008 19:43:59 +0000 (21:43 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 6 Aug 2008 19:44:30 +0000 (21:44 +0200)
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
src/client/abstractmessageprocessor.cpp [new file with mode: 0644]
src/client/abstractmessageprocessor.h [new file with mode: 0644]
src/qtui/CMakeLists.txt
src/qtui/qtuimessageprocessor.cpp [new file with mode: 0644]
src/qtui/qtuimessageprocessor.h [new file with mode: 0644]

index d4a2459..ecb34dd 100644 (file)
@@ -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 (file)
index 0000000..5ba8683
--- /dev/null
@@ -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<Message> &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 (file)
index 0000000..b140ac1
--- /dev/null
@@ -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<Message> &msgs);
+
+  signals:
+
+  protected:
+    virtual void processMessage(Message &msg) = 0;
+    virtual void processMessages(QList<Message> &msgs) = 0;
+
+};
+
+#endif
index 2ae71a3..6c2c18d 100644 (file)
@@ -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 (file)
index 0000000..e110d61
--- /dev/null
@@ -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<Message> &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 (file)
index 0000000..91cc577
--- /dev/null
@@ -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<Message> &msgs);
+
+};
+
+#endif