Cleaning up the closet... or at least the code. Tried to reduce the number of #includ...
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 28 Jun 2007 00:57:31 +0000 (00:57 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 28 Jun 2007 00:57:31 +0000 (00:57 +0000)
inter-file dependencies as far as possible. There is probably some work left especially in qtgui, though.
Also I removed some obsolete files and split up CoreSession and QtGui in their own files.

50 files changed:
Quassel.kdevelop.filelist
src/CMakeLists.txt
src/client/CMakeLists.txt
src/client/buffer.cpp
src/client/buffer.h
src/client/buffertreemodel.cpp
src/client/buffertreemodel.h
src/client/client.cpp
src/client/client.h
src/client/clientproxy.cpp
src/client/clientproxy.h
src/client/treemodel.h
src/common/CMakeLists.txt
src/common/global.cpp
src/common/global.h
src/common/logger.cpp
src/common/logger.h
src/common/main.cpp
src/common/main_gui.cpp [deleted file]
src/common/message.cpp
src/common/message.h
src/common/proxy_common.h
src/common/quasselui.h
src/common/settings.cpp
src/common/settings.h
src/common/util.cpp
src/core/CMakeLists.txt
src/core/backlog.cpp [deleted file]
src/core/backlog.h [deleted file]
src/core/core.cpp
src/core/core.h
src/core/coreproxy.cpp
src/core/coreproxy.h
src/core/coresession.cpp [new file with mode: 0644]
src/core/coresession.h [new file with mode: 0644]
src/core/server.cpp
src/core/server.h
src/core/sqlitestorage.cpp
src/core/sqlitestorage.h
src/core/storage.h
src/qtgui/CMakeLists.txt
src/qtgui/bufferviewwidget.cpp [deleted file]
src/qtgui/bufferwidget.h
src/qtgui/channelwidgetinput.cpp
src/qtgui/channelwidgetinput.h
src/qtgui/mainwin.cpp
src/qtgui/mainwin.h
src/qtgui/qtgui.cpp [moved from src/common/main_core.cpp with 60% similarity]
src/qtgui/qtgui.h [moved from src/qtgui/bufferviewwidget.h with 60% similarity]
src/qtgui/style.h

index 2d5153c..dc08925 100644 (file)
@@ -1,8 +1,4 @@
 # KDevelop Custom Project File List
-dev-notes
-dev-notes/builtin_cmds.obsolete.cpp
-dev-notes/paulk-mainwindow.ui
-Makefile
 src
 src/client
 src/client/buffer.cpp
@@ -18,13 +14,15 @@ src/client/treemodel.cpp
 src/client/treemodel.h
 src/CMakeLists.txt
 src/common
+src/common/build_core.cpp
+src/common/build_mono.cpp
+src/common/build_qtgui.cpp
 src/common/CMakeLists.txt
 src/common/global.cpp
 src/common/global.h
 src/common/logger.cpp
 src/common/logger.h
-src/common/main_core.cpp
-src/common/main_gui.cpp
+src/common/main.cpp
 src/common/message.cpp
 src/common/message.h
 src/common/proxy_common.h
@@ -34,13 +32,13 @@ src/common/settings.h
 src/common/util.cpp
 src/common/util.h
 src/core
-src/core/backlog.cpp
-src/core/backlog.h
 src/core/CMakeLists.txt
 src/core/core.cpp
 src/core/core.h
 src/core/coreproxy.cpp
 src/core/coreproxy.h
+src/core/coresession.cpp
+src/core/coresession.h
 src/core/server.cpp
 src/core/server.h
 src/core/sqlitestorage.cpp
@@ -54,8 +52,6 @@ src/qtgui/bufferview.cpp
 src/qtgui/bufferviewfilter.cpp
 src/qtgui/bufferviewfilter.h
 src/qtgui/bufferview.h
-src/qtgui/bufferviewwidget.cpp
-src/qtgui/bufferviewwidget.h
 src/qtgui/bufferwidget.cpp
 src/qtgui/bufferwidget.h
 src/qtgui/channelwidgetinput.cpp
@@ -71,6 +67,8 @@ src/qtgui/identities.cpp
 src/qtgui/identities.h
 src/qtgui/mainwin.cpp
 src/qtgui/mainwin.h
+src/qtgui/qtgui.cpp
+src/qtgui/qtgui.h
 src/qtgui/serverlist.cpp
 src/qtgui/serverlist.h
 src/qtgui/settingsdlg.cpp
@@ -99,7 +97,3 @@ src/qtgui/ui/nickeditdlg.ui
 src/qtgui/ui/servereditdlg.ui
 src/qtgui/ui/serverlistdlg.ui
 src/qtgui/ui/settingsdlg.ui
-src/common/build_mono.cpp
-src/common/build_qtgui.cpp
-src/common/build_core.cpp
-src/common/main.cpp
index 7e0244f..65a664b 100644 (file)
@@ -24,9 +24,9 @@ IF(NOT BUILD_MONO AND NOT BUILD_CORE AND NOT BUILD_QTGUI)
   MESSAGE(FATAL_ERROR "\nYou have not selected which parts of Quassel I should build. Aborting.\nRun 'cmake <path> -DBUILD=<part>', where <part> contains one or more of 'core', 'gui' or 'monolithic', or 'all' to build everything.\n")
 ENDIF(NOT BUILD_MONO AND NOT BUILD_CORE AND NOT BUILD_QTGUI)
 
-#IF(BUILD_CORE OR BUILD_QTGUI)
-#  MESSAGE(FATAL_ERROR "\nBuilding of standalone core or GUI not supported at this time. Please check back later.\n")
-#ENDIF(BUILD_CORE OR BUILD_QTGUI)
+IF(BUILD_CORE OR BUILD_QTGUI)
+  MESSAGE(FATAL_ERROR "\nBuilding of standalone core or GUI not supported at this time. Please check back later.\n")
+ENDIF(BUILD_CORE OR BUILD_QTGUI)
 
 SET(CMAKE_BUILD_TYPE Debug)
 
index 40a7695..920eb97 100644 (file)
@@ -3,4 +3,4 @@ SET(client_HDRS )
 SET(client_MOCS buffer.h buffertreemodel.h client.h clientproxy.h treemodel.h)
 
 QT4_WRAP_CPP(_MOC ${client_MOCS})
-ADD_LIBRARY(client ${_MOC} ${client_SRCS} ${client_HDRS})
+ADD_LIBRARY(client ${client_SRCS} ${_MOC})
index c8f375d..7f4d885 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+#include "buffer.h"
 
 #include "client.h"
-#include "buffer.h"
 #include "util.h"
 
-/*
-Buffer::Buffer(QString netname, QString bufname) {
-  Buffer(BufferId(0, netname, bufname));
-
-
-}
-*/
 
 Buffer::Buffer(BufferId bufid) {
   id = bufid;
@@ -172,9 +165,3 @@ void Buffer::setOwnNick(QString nick) {
   _ownNick = nick;
   emit ownNickSet(nick);
 }
-
-/****************************************************************************************/
-
-
-/****************************************************************************************/
-
index 2c361d3..8e9bf6c 100644 (file)
 #ifndef _BUFFER_H_
 #define _BUFFER_H_
 
-#include <QtCore>
-
 #include "global.h"
-#include "message.h"
-#include "quasselui.h"
 
+class AbstractUiMsg;
+class Message;
 struct BufferState;
 
 //!\brief Encapsulates the contents of a single channel, query or server status context.
-/** A Buffer maintains a list of existing nicks and their status. New messages can be appended using
- * displayMsg(). A buffer displays its contents by way of a BufferWidget, which can be shown
- * (and created on demand) by calling showWidget().
+/** A Buffer maintains a list of existing nicks and their status.
  */
 class Buffer : public QObject {
   Q_OBJECT
@@ -106,6 +102,6 @@ class Buffer : public QObject {
     QList<AbstractUiMsg *> layoutedMsgs;
 
 };
-Q_DECLARE_OPERATORS_FOR_FLAGS(Buffer::ActivityLevel)    
+Q_DECLARE_OPERATORS_FOR_FLAGS(Buffer::ActivityLevel)
 
 #endif
index 741215f..3f0a2ad 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <QColor>  // FIXME Dependency on QtGui!
 
-#include "global.h"
+#include "clientproxy.h"
 #include "buffertreemodel.h"
 
 /*****************************************
index 9916edd..23471ad 100644 (file)
 
 #include "treemodel.h"
 #include "buffer.h"
-#include "clientproxy.h"
 
 /*****************************************
  *  Fancy Buffer Items
  *****************************************/
-class BufferTreeItem : public TreeItem{
+class BufferTreeItem : public TreeItem {
   Q_OBJECT
   
 public:
index 30eeb51..6be7e07 100644 (file)
  ***************************************************************************/
 
 #include "client.h"
-#include "clientproxy.h"
+
 #include "buffer.h"
 #include "buffertreemodel.h"
+#include "clientproxy.h"
+#include "quasselui.h"
 #include "util.h"
 
 Client * Client::instanceptr = 0;
@@ -33,8 +35,6 @@ QHash<uint, BufferId> Client::bufferIds;
 QHash<QString, QHash<QString, VarMap> > Client::nicks;
 QHash<QString, bool> Client::netConnected;
 QHash<QString, QString> Client::ownNick;
-//QList<BufferId> Client::coreBuffers;
-
 
 Client *Client::instance() {
   if(instanceptr) return instanceptr;
@@ -180,7 +180,6 @@ void Client::syncToCore() {
     BufferId id = vid.value<BufferId>();
     bufferIds[id.uid()] = id;  // make lookups by id faster
     buffer(id);                // create all buffers, so we see them in the network views
-    //emit requestBacklog(id, -1, -1);  // TODO: use custom settings for backlog request
   }
   connectedToCore = true;
   emit connected();
@@ -404,4 +403,3 @@ void Client::setOwnNick(QString net, QString nick) {
   }
 }
 
-
index 9bc4034..452bed0 100644 (file)
 #ifndef _CLIENT_H_
 #define _CLIENT_H_
 
-#include <QtCore>
-#include <QtNetwork>
+#include <QAbstractSocket>
+#include <QTcpSocket>
+#include <QList>
 
-#include "quasselui.h"
 #include "buffer.h"
 #include "message.h"
 #include "proxy_common.h"
 
+class AbstractUi;
 class ClientProxy;
 class BufferTreeModel;
+class QtGui;
+
+class QTimer;
 
 class Client : public QObject {
   Q_OBJECT
@@ -127,7 +131,6 @@ class Client : public QObject {
     static QHash<QString, QHash<QString, VarMap> > nicks;
     static QHash<QString, bool> netConnected;
     static QHash<QString, QString> ownNick;
-    //static QList<BufferId> coreBuffers;
 
     QTimer *layoutTimer;
     QList<Buffer *> layoutQueue;
index c991dba..3614aa2 100644 (file)
@@ -18,8 +18,6 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#include <QtDebug>
-
 #include "clientproxy.h"
 #include "util.h"
 #include "message.h"
index abe7ca4..e66aa65 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef _GUIPROXY_H_
-#define _GUIPROXY_H_
+#ifndef _CLIENTPROXY_H_
+#define _CLIENTPROXY_H_
+
+#include <QStringList>
 
 #include "proxy_common.h"
 #include "message.h"
 #include "global.h"
 
-#include <QObject>
-#include <QVariant>
-#include <QTcpSocket>
-#include <QStringList>
-
 class ClientProxy : public QObject {
   Q_OBJECT
 
@@ -46,9 +43,6 @@ class ClientProxy : public QObject {
 
     inline void gsGeneric(ClientSignal sig, QVariant v1 = QVariant(), QVariant v2 = QVariant(), QVariant v3 = QVariant()) { send(sig, v1, v2, v3); }
 
-    //void connectToCore(QString host, quint16 port);
-    //void disconnectFromCore();
-
   signals:
     void csCoreState(QVariant);
     void csServerState(QString, QVariant);
@@ -71,36 +65,14 @@ class ClientProxy : public QObject {
 
     void csGeneric(CoreSignal, QVariant, QVariant, QVariant);
 
-    //void coreConnected();
-    //void coreDisconnected();
-    //void coreConnectionError(QString errorMsg);
-
-    //void recvPartialItem(quint32 avail, quint32 size);
-
     void send(ClientSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
 
   public slots:
     void recv(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
 
-  private slots:
-    //void updateCoreData(QString);
-
-    //void serverError(QAbstractSocket::SocketError);
-    //void serverHasData();
-
   private:
     ClientProxy();
     static ClientProxy *instanceptr;
-
-    //QTcpSocket socket;
-    //quint32 blockSize;
-
-  //friend class CoreProxy;
-
 };
 
-//extern ClientProxy *guiProxy;
-
-
-
 #endif
index a403984..1941602 100644 (file)
@@ -21,7 +21,9 @@
 #ifndef _TREEMODEL_H_
 #define _TREEMODEL_H_
 
-#include <QtCore>
+#include <QList>
+#include <QVariant>
+#include <QAbstractItemModel>
 
 /*****************************************
  *  general item used in the Tree Model
index 55457d2..e4e49e6 100644 (file)
@@ -1,6 +1,6 @@
-SET(common_SRCS global.cpp logger.cpp util.cpp message.cpp settings.cpp)
-SET(common_HDRS util.h message.h settings.h)
+SET(common_SRCS global.cpp logger.cpp message.cpp settings.cpp util.cpp)
+SET(common_HDRS message.h settings.h util.h)
 SET(common_MOCS global.h logger.h quasselui.h)
 
 QT4_WRAP_CPP(_MOC ${common_MOCS})
-ADD_LIBRARY(common ${_MOC} ${common_SRCS} ${common_HDRS})
+ADD_LIBRARY(common ${common_SRCS} ${_MOC})
index b92f795..eb4ee8f 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+#include <QObject>
+#include <QStringList>
 
 #include "global.h"
 #include "logger.h"
-#include "core.h"
 #include "message.h"
 #include "util.h"
 
-#include <QtCore>
-#include <QDomDocument>
-
 extern void messageHandler(QtMsgType type, const char *msg);
 
 Global *Global::instanceptr = 0;
index 49f9750..2723b66 100644 (file)
 #define _GLOBAL_H_
 
 /** The protocol version we use fo the communication between core and GUI */
-#define GUI_PROTOCOL 2
+#define GUI_PROTOCOL 3
 
 #define BACKLOG_FORMAT 2
 #define BACKLOG_STRING "QuasselIRC Backlog File"
 
 class Global;
 
-#include <QtCore>
-//#include <QMutex>
+#include <QHash>
+#include <QMutex>
+#include <QString>
+#include <QVariant>
 
 /* Some global stuff */
 typedef QMap<QString, QVariant> VarMap;
index 25bb06b..76fa916 100644 (file)
@@ -18,7 +18,6 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#include "global.h"
 #include "logger.h"
 
 #include <iostream>
index ba8eba4..24a8bb1 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef _LOGGER_H_
 #define _LOGGER_H_
 
-#include <QtCore>
+#include <QObject>
 
 class Logger : public QObject {
   Q_OBJECT
index 51de3c4..c53daab 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#include <iostream>
-
-#include "global.h"
 #include "settings.h"
-#include "quasselui.h"
 
 #if defined BUILD_CORE
 #include <QCoreApplication>
 
 #elif defined BUILD_QTGUI
 #include <QApplication>
-#include "style.h"
 #include "client.h"
 #include "clientproxy.h"
-#include "mainwin.h"
+#include "qtgui.h"
+#include "style.h"
 
 #elif defined BUILD_MONO
 #include <QApplication>
-#include "core.h"
-#include "coreproxy.h"
-#include "style.h"
 #include "client.h"
 #include "clientproxy.h"
-#include "mainwin.h"
+#include "core.h"
+#include "coresession.h"
+#include "qtgui.h"
+#include "style.h"
 
 #else
 #error "Something is wrong - you need to #define a build mode!"
@@ -59,8 +55,6 @@ int main(int argc, char **argv) {
   Global::runMode = Global::Monolithic;
   QApplication app(argc, argv);
 #endif
-  //AbstractUi *foo = new AbstractUi();
-  //foo->init();
   QCoreApplication::setOrganizationDomain("quassel-irc.org");
   QCoreApplication::setApplicationName("Quassel IRC");
   QCoreApplication::setOrganizationName("Quassel IRC Development Team");
@@ -77,8 +71,6 @@ int main(int argc, char **argv) {
   QtGui *gui = new QtGui();
   Client::init(gui);
   gui->init();
-//#else
-//  Core::instance(); // create and init the core object
 #endif
 
   int exitCode = app.exec();
@@ -100,8 +92,8 @@ int main(int argc, char **argv) {
 #ifdef BUILD_QTGUI
 QVariant Client::connectToLocalCore(QString, QString) { return QVariant(); }
 void Client::disconnectFromLocalCore() {}
-#elif defined BUILD_MONO
 
+#elif defined BUILD_MONO
 QVariant Client::connectToLocalCore(QString user, QString passwd) {
   // TODO catch exceptions
   QVariant reply = Core::connectLocalClient(user, passwd);
diff --git a/src/common/main_gui.cpp b/src/common/main_gui.cpp
deleted file mode 100644 (file)
index e9bd6c8..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by The Quassel Team                                *
- *   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) any later version.                                   *
- *                                                                         *
- *   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 <iostream>
-
-#include <QtGui>
-#include <QApplication>
-
-#include "style.h"
-#include "global.h"
-#include "guiproxy.h"
-#include "coreconnectdlg.h"
-#include "util.h"
-#include "chatwidget.h"
-
-#include "mainwin.h"
-
-int main(int argc, char **argv) {
-  QApplication app(argc, argv);
-  QApplication::setOrganizationDomain("quassel-irc.org");
-  QApplication::setApplicationName("Quassel IRC");
-  QApplication::setOrganizationName("The Quassel Team");
-
-  Global::runMode = Global::GUIOnly;
-  Global::quasselDir = QDir::homePath() + "/.quassel";
-
-  global = new Global();
-  guiProxy = new GuiProxy();
-
-  Style::init();
-
-  MainWin mainWin;
-  mainWin.init();
-  int exitCode = app.exec();
-  delete guiProxy;
-  delete global;
-  return exitCode;
-}
-
-void MainWin::syncToCore() {
-  Q_ASSERT(!global->getData("CoreReady").toBool());
-  // ok, we are running as standalone GUI
-  coreConnectDlg = new CoreConnectDlg(this);
-  if(coreConnectDlg->exec() != QDialog::Accepted) {
-    //qApp->quit();
-    exit(1);
-  }
-  VarMap state = coreConnectDlg->getCoreState().toMap();
-  delete coreConnectDlg;
-  VarMap data = state["CoreData"].toMap();
-  QString key;
-  foreach(key, data.keys()) {
-    global->updateData(key, data[key]);
-  }
-  if(!global->getData("CoreReady").toBool()) {
-    QMessageBox::critical(this, tr("Fatal Error"), tr("<b>Could not synchronize with Quassel Core!</b><br>Quassel GUI will be aborted."), QMessageBox::Abort);
-    //qApp->quit();
-    exit(1);
-  }
-  /*
-  foreach(QString net, state["CoreBackLog"].toMap().keys()) {
-    QByteArray logbuf = state["CoreBackLog"].toMap()[net].toByteArray();
-    QDataStream in(&logbuf, QIODevice::ReadOnly); in.setVersion(QDataStream::Qt_4_2);
-    while(!in.atEnd()) {
-      Message msg; in >> msg;
-      coreBackLog[net].append(msg);
-    }
-    qDebug() << net << coreBackLog[net].count();
-  }
-  */
-  coreBuffers.clear();
-  foreach(QVariant v, state["CoreBuffers"].toList()) { coreBuffers.append(v.value<BufferId>()); }
-}
-
-/*
-
-GuiProxy::GuiProxy() {
-  if(guiProxy) qFatal("Trying to instantiate more than one CoreProxy object!");
-
-  blockSize = 0;
-
-  connect(&socket, SIGNAL(readyRead()), this, SLOT(serverHasData()));
-  connect(&socket, SIGNAL(connected()), this, SIGNAL(coreConnected()));
-  connect(&socket, SIGNAL(disconnected()), this, SIGNAL(coreDisconnected()));
-  connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(serverError(QAbstractSocket::SocketError)));
-
-  connect(global, SIGNAL(dataPutLocally(QString)), this, SLOT(updateCoreData(QString)));
-  connect(this, SIGNAL(csUpdateGlobalData(QString, QVariant)), global, SLOT(updateData(QString, QVariant)));
-
-}
-
-void GuiProxy::connectToCore(QString host, quint16 port) {
-  socket.connectToHost(host, port);
-}
-
-void GuiProxy::disconnectFromCore() {
-  socket.close();
-}
-
-void GuiProxy::serverError(QAbstractSocket::SocketError) {
-  emit coreConnectionError(socket.errorString());
-  //qFatal(QString("Connection error: %1").arg(socket.errorString()).toAscii());
-}
-
-void GuiProxy::serverHasData() {
-  QVariant item;
-  while(readDataFromDevice(&socket, blockSize, item)) {
-    emit recvPartialItem(1,1);
-    QList<QVariant> sigdata = item.toList();
-    Q_ASSERT(sigdata.size() == 4);
-    recv((CoreSignal)sigdata[0].toInt(), sigdata[1], sigdata[2], sigdata[3]);
-    blockSize = 0;
-  }
-  if(blockSize > 0) {
-    emit recvPartialItem(socket.bytesAvailable(), blockSize);
-  }
-}
-*/
-/*
-void GuiProxy::send(GuiSignal sig, QVariant arg1, QVariant arg2, QVariant arg3) {
-  QList<QVariant> sigdata;
-  sigdata.append(sig); sigdata.append(arg1); sigdata.append(arg2); sigdata.append(arg3);
-  //qDebug() << "Sending signal: " << sigdata;
-  writeDataToDevice(&socket, QVariant(sigdata));
-}
-*/
-
-void GuiProxy::updateCoreData(QString key) {
-  QVariant data = global->getData(key);
-  send(GS_UPDATE_GLOBAL_DATA, key, data);
-}
index e564b84..8b9f158 100644 (file)
 #include "message.h"
 #include <QDataStream>
 
-/*
-Message Message::plain(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Plain, _text, _sender, _flags);
-}
-
-Message Message::notice(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Notice, _text, _sender, _flags);
-}
-
-Message Message::action(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Action, _text, _sender, _flags);
-}
-
-Message Message::kick(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Kick, _text, _sender, _flags);
-}
-
-Message Message::join(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Join, _text, _sender, _flags);
-}
-
-Message Message::part(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Part, _text, _sender, _flags);
-}
-
-Message Message::nick(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Nick, _text, _sender, _flags);
-}
-
-Message Message::mode(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Mode, _text, _sender, _flags);
-}
-
-Message Message::quit(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Quit, _text, _sender, _flags);
-}
-
-Message Message::kill(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Kill, _text, _sender, _flags);
-}
-
-Message Message::server(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Server, _text, _sender, _flags);
-}
-
-Message Message::info(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Info, _text, _sender, _flags);
-}
-
-Message Message::error(QString _target, QString _text, QString _sender, quint8 _flags) {
-  return Message(_target, Error, _text, _sender, _flags);
-}
-*/
-
 QDataStream &operator<<(QDataStream &out, const Message &msg) {
   /*
   out << (quint32)msg.timeStamp.toTime_t() << (quint8)msg.type << (quint8)msg.flags
index 8cfa23a..36950ec 100644 (file)
@@ -21,7 +21,9 @@
 #ifndef _MESSAGE_H_
 #define _MESSAGE_H_
 
-#include <QtCore>
+#include <QString>
+#include <QDateTime>
+
 #include "global.h"
 
 struct Message {
index 2eacb0d..609b593 100644 (file)
@@ -33,5 +33,4 @@ enum CoreSignal { CS_CORE_STATE, CS_SERVER_CONNECTED, CS_SERVER_DISCONNECTED, CS
 
 };
 
-
 #endif
index 2b31170..5cfc5f0 100644 (file)
@@ -41,7 +41,6 @@ class AbstractUi : public QObject {
   Q_OBJECT
 
   public:
-//    virtual ~AbstractUi() {};
     virtual void init() {};  // called after the client is initialized
     virtual AbstractUiMsg *layoutMsg(const Message &) = 0;
 
index 6f2ba0f..77144c7 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#include "settings.h"
+#include <QSettings>
 
+#include "settings.h"
 
 Settings *settings;
 
-
 void Settings::init() {
   curProfile = QObject::tr("Default");
 }
index f2e0d38..4ef2664 100644 (file)
@@ -21,7 +21,8 @@
 #ifndef _SETTINGS_H_
 #define _SETTINGS_H_
 
-#include <QtCore>
+#include <QString>
+#include <QVariant>
 
 class Settings {
 
index b865253..2238cbe 100644 (file)
@@ -20,8 +20,6 @@
 
 #include "util.h"
 
-#include <QtCore>
-
 QString nickFromMask(QString mask) {
   return mask.section('!', 0, 0);
 }
index fa1e53e..db4cda7 100644 (file)
@@ -1,6 +1,6 @@
-SET(core_SRCS core.cpp coreproxy.cpp server.cpp backlog.cpp storage.cpp sqlitestorage.cpp)
+SET(core_SRCS core.cpp coreproxy.cpp coresession.cpp server.cpp sqlitestorage.cpp storage.cpp)
 SET(core_HDRS )
-SET(core_MOCS core.h coreproxy.h server.h backlog.h storage.h sqlitestorage.h)
+SET(core_MOCS core.h coreproxy.h coresession.h server.h sqlitestorage.h storage.h)
 
 QT4_WRAP_CPP(_MOC ${core_MOCS})
-ADD_LIBRARY(core ${_MOC} ${core_SRCS} ${core_HDRS})
+ADD_LIBRARY(core ${core_SRCS} ${_MOC})
diff --git a/src/core/backlog.cpp b/src/core/backlog.cpp
deleted file mode 100644 (file)
index 6a222af..0000000
+++ /dev/null
@@ -1,337 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005-07 by The Quassel Team                             *
- *   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) any later version.                                   *
- *                                                                         *
- *   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 "backlog.h"
-#include "util.h"
-
-#define DBVERSION 1
-
-Backlog::Backlog() {
-
-
-}
-
-
-Backlog::~Backlog() {
-  logDb.close();
-
-  // FIXME Old stuff
-  foreach(QDataStream *s, logStreams) {
-    delete s;
-  }
-  foreach(QFile *f, logFiles) {
-    if(f->isOpen()) f->close();
-    delete f;
-  }
-}
-
-
-void Backlog::init(QString _user) {
-  user = _user;
-  QDir backlogDir = QDir(Global::quasselDir);
-  if(!backlogDir.exists()) {
-    qWarning(QString("Creating backlog directory \"%1\"...").arg(backlogDir.absolutePath()).toAscii());
-    if(!backlogDir.mkpath(backlogDir.absolutePath())) {
-      qWarning(QString("Could not create backlog directory! Disabling logging...").toAscii());
-      backlogEnabled = false;
-      return;
-    }
-  }
-  QString backlogFile = Global::quasselDir + "/quassel-backlog.sqlite";
-  logDb = QSqlDatabase::addDatabase("QSQLITE", user);
-  logDb.setDatabaseName(backlogFile);
-  bool ok = logDb.open();
-  if(!ok) {
-    qWarning(tr("Could not open backlog database: %1").arg(logDb.lastError().text()).toAscii());
-    qWarning(tr("Disabling logging...").toAscii());
-    backlogEnabled = false; return;
-  }
-
-  if(!logDb.transaction()) qWarning(tr("Database driver does not support transactions. This might lead to a corrupt database!").toAscii());
-  QString tname = QString("'Backlog$%1$'").arg(user);
-  QSqlQuery query(logDb);
-  /* DEBUG */
-  //query.exec(QString("DROP TABLE %1").arg(tname)); // DEBUG
-  //query.exec(QString("DROP TABLE 'Senders$%1$'").arg(user));
-  //query.exec(QString("DROP TABLE 'Buffers$%1$'").arg(user));
-  /* END DEBUG */
-  query.exec(QString("CREATE TABLE IF NOT EXISTS %1 ("
-      "MsgId INTEGER PRIMARY KEY AUTOINCREMENT,"
-      "Time INTEGER,"
-      "BufferId INTEGER,"
-      "Type INTEGER,"
-      "Flags INTEGER,"
-      "SenderId INTEGER,"
-      "Text BLOB"
-      ")").arg(tname));
-  query.exec(QString("INSERT OR REPLACE INTO %1 (MsgId, SenderId, Text) VALUES (0, '$VERSION$', %2)").arg(tname).arg(DBVERSION));
-  query.exec(QString("CREATE TABLE IF NOT EXISTS 'Senders$%1$' (SenderId INTEGER PRIMARY KEY AUTOINCREMENT, Sender TEXT)").arg(user));
-  query.exec(QString("CREATE TABLE IF NOT EXISTS 'Buffers$%1$' (BufferId INTEGER PRIMARY KEY AUTOINCREMENT, GroupId INTEGER, Network TEXT, Buffer TEXT)").arg(user));
-  if(query.lastError().isValid()) {
-    qWarning(tr("Could not create backlog table: %1").arg(query.lastError().text()).toAscii());
-    qWarning(tr("Disabling logging...").toAscii());
-    logDb.rollback();
-    backlogEnabled = false; return;
-  }
-  // Find the next free uid numbers
-  query.exec(QString("SELECT MsgId FROM %1 ORDER BY MsgId DESC LIMIT 1").arg(tname));
-  query.first();
-  if(query.value(0).isValid()) nextMsgId = query.value(0).toUInt() + 1;
-  else {
-    qWarning(tr("Something is wrong with the backlog database! %1").arg(query.lastError().text()).toAscii());
-    nextMsgId = 1;
-  }
-  query.exec(QString("SELECT BufferId FROM 'Buffers$%1$' ORDER BY BufferId DESC LIMIT 1").arg(user));
-  if(query.first()) {
-    if(query.value(0).isValid()) nextBufferId = query.value(0).toUInt() + 1;
-    else {
-      qWarning(tr("Something is wrong with the backlog database! %1").arg(query.lastError().text()).toAscii());
-      nextBufferId = 0;
-    }
-  } else nextBufferId = 0;
-  query.exec(QString("SELECT SenderId FROM 'Senders$%1$' ORDER BY SenderId DESC LIMIT 1").arg(user));
-  if(query.first()) {
-    if(query.value(0).isValid()) nextSenderId = query.value(0).toUInt() + 1;
-    else {
-      qWarning(tr("Something is wrong with the backlog database! %1").arg(query.lastError().text()).toAscii());
-      nextSenderId = 0;
-    }
-  } else nextSenderId = 0;
-  logDb.commit();
-  backlogEnabled = true;
-}
-
-uint Backlog::logMessage(Message msg) {
-  if(!backlogEnabled) return 0;
-  bool ok;
-  logDb.transaction();
-  QSqlQuery query(logDb);
-  QString s = msg.sender; s.replace('\'', "''");
-  QString t = msg.text; t.replace('\'', "''");
-  // Let's do some space-saving optimizations...
-  query.exec(QString("SELECT SenderId FROM 'Senders$%1$' WHERE Sender == '%2'").arg(user).arg(s));
-  int suid;
-  if(!query.first()) {
-    query.exec(QString("INSERT INTO 'Senders$%1$' (SenderId, Sender) VALUES (%2, '%3')").arg(user).arg(nextSenderId).arg(s));
-    suid = nextSenderId;
-  } else suid = query.value(0).toInt();
-  query.exec(QString("INSERT INTO 'Backlog$%1$' (MsgId, Time, BufferId, Type, Flags, SenderId, Text) VALUES (%2, %3, %4, %5, %6, %7, X'%8')").arg(user)
-      .arg(nextMsgId).arg(msg.timeStamp.toTime_t()).arg(msg.buffer.uid()).arg(msg.type).arg(msg.flags).arg(suid).arg(t.toUtf8().toHex().constData()));
-
-  if(query.lastError().isValid()) {
-    qWarning(tr("Database error while logging: %1").arg(query.lastError().text()).toAscii());
-    logDb.rollback();
-    return 0;
-  }
-
-  nextMsgId++;
-  if(suid == nextSenderId) nextSenderId++;
-  logDb.commit();
-  return nextMsgId - 1;
-}
-
-// TODO: optimize by keeping free IDs in memory? What about deleted IDs? Nickchanges for queries?
-BufferId Backlog::getBufferId(QString net, QString buf) {
-  if(!backlogEnabled) {
-    return BufferId(0, net, buf);
-  }
-  //QByteArray n = net.toUtf8().toHex();
-  //QByteArray b = buf.toUtf8().toHex();
-  bool flg = false;
-  logDb.transaction();
-  QSqlQuery query(logDb);
-  int uid = -1;
-  query.exec(QString("SELECT BufferId FROM 'Buffers$%1$' WHERE Network == '%2' AND Buffer == '%3'").arg(user).arg(net).arg(buf));
-  if(!query.first()) {
-    // TODO: joined buffers/queries
-    query.exec(QString("INSERT INTO 'Buffers$%1$' (BufferId, GroupId, Network, Buffer) VALUES (%2, %2, '%3', '%4')").arg(user).arg(nextBufferId).arg(net).arg(buf));
-    uid = nextBufferId++;
-    flg = true;
-  } else uid = query.value(0).toInt();
-  logDb.commit();
-  BufferId id(uid, net, buf, uid);  // FIXME (joined buffers)
-  if(flg) emit bufferIdUpdated(id);
-  return id;  // FIXME (joined buffers)
-}
-
-QList<BufferId> Backlog::requestBuffers(QDateTime since) {
-  QList<BufferId> result;
-  QSqlQuery query(logDb);
-  if(!since.isValid()) {
-    query.exec(QString("SELECT BufferId, GroupId, Network, Buffer FROM 'Buffers$%1$'").arg(user));
-  } else {
-    query.exec(QString("SELECT DISTINCT 'Buffers$%1$'.BufferId, GroupId, Network, Buffer FROM 'Buffers$%1$' NATURAL JOIN 'Backlog$%1$' "
-                       "WHERE Time >= %2").arg(user).arg(since.toTime_t()));
-  }
-  while(query.next()) {
-    result.append(BufferId(query.value(0).toUInt(), query.value(2).toString(), query.value(3).toString(), query.value(1).toUInt()));
-  }
-  return result;
-}
-
-QList<Message> Backlog::requestMsgs(BufferId id, int lastlines, int offset) {
-  QList<Message> result;
-  QSqlQuery query(logDb);
-  QString limit;
-  if(lastlines > 0) limit = QString("LIMIT %1").arg(lastlines);
-  query.exec(QString("SELECT MsgId, Time, Type, Flags, Sender, Text FROM 'Senders$%1$' NATURAL JOIN 'Backlog$%1$' "
-                     "WHERE BufferId IN (SELECT BufferId FROM 'Buffers$%1$' WHERE GroupId == %2) ORDER BY MsgId DESC %3").arg(user).arg(id.groupId()).arg(limit));
-  while(query.next()) {
-    if(offset >= 0 && query.value(0).toInt() >= offset) continue;
-    Message msg(QDateTime::fromTime_t(query.value(1).toInt()), id, (Message::Type)query.value(2).toUInt(), QString::fromUtf8(query.value(5).toByteArray()),
-                query.value(4).toString(), query.value(3).toUInt());
-    msg.msgId = query.value(0).toUInt();
-    result.append(msg);
-  }
-  return result;
-}
-
-
-// OBSOLETE
-// This is kept here for importing the old file-based backlog.
-
-void Backlog::importOldBacklog() {
-  qDebug() << "Deleting backlog database...";
-  logDb.exec(QString("DELETE FROM 'Backlog$%1$' WHERE SenderId != '$VERSION$'").arg(user));
-  logDb.exec(QString("DELETE FROM 'Senders$%1$'").arg(user));
-  logDb.exec(QString("DELETE FROM 'Buffers$%1$'").arg(user));
-  nextMsgId = 1; nextBufferId = 1; nextSenderId = 1;
-  qDebug() << "Importing old backlog files...";
-  initBackLogOld();
-  if(!backLogEnabledOld) return;
-  logDb.exec("VACUUM");
-  qDebug() << "Backlog successfully imported, you have to restart Quassel now!";
-  exit(0);
-
-}
-
-// file name scheme: quassel-backlog-2006-29-10.bin
-void Backlog::initBackLogOld() {
-  backLogDir = QDir(Global::quasselDir + "/backlog");
-  if(!backLogDir.exists()) {
-    qWarning(QString("Creating backlog directory \"%1\"...").arg(backLogDir.absolutePath()).toAscii());
-    if(!backLogDir.mkpath(backLogDir.absolutePath())) {
-      qWarning(QString("Could not create backlog directory! Disabling logging...").toAscii());
-      backLogEnabledOld = false;
-      return;
-    }
-  }
-  backLogDir.refresh();
-  //if(!backLogDir.isReadable()) {
-  //  qWarning(QString("Cannot read directory \"%1\". Disabling logging...").arg(backLogDir.absolutePath()).toAscii());
-  //  backLogEnabled = false;
-  //  return;
-  //}
-  QStringList networks = backLogDir.entryList(QDir::Dirs|QDir::NoDotAndDotDot|QDir::Readable, QDir::Name);
-  foreach(QString net, networks) {
-    QDir dir(backLogDir.absolutePath() + "/" + net);
-    if(!dir.exists()) {
-      qWarning(QString("Could not change to directory \"%1\"!").arg(dir.absolutePath()).toAscii());
-      continue;
-    }
-    QStringList logs = dir.entryList(QStringList("quassel-backlog-*.bin"), QDir::Files|QDir::Readable, QDir::Name);
-    foreach(QString name, logs) {
-      QFile f(dir.absolutePath() + "/" + name);
-      if(!f.open(QIODevice::ReadOnly)) {
-        qWarning(QString("Could not open \"%1\" for reading!").arg(f.fileName()).toAscii());
-        continue;
-      }
-      QDataStream in(&f);
-      in.setVersion(QDataStream::Qt_4_2);
-      QByteArray verstring; quint8 vernum; in >> verstring >> vernum;
-      if(verstring != BACKLOG_STRING) {
-        qWarning(QString("\"%1\" is not a Quassel backlog file!").arg(f.fileName()).toAscii());
-        f.close(); continue;
-      }
-      if(vernum != BACKLOG_FORMAT) {
-        qWarning(QString("\"%1\": Version mismatch!").arg(f.fileName()).toAscii());
-        f.close(); continue;
-      }
-      qDebug() << "Reading backlog from" << f.fileName();
-      logFileDates[net] = QDate::fromString(f.fileName(),
-                                            QString("'%1/quassel-backlog-'yyyy-MM-dd'.bin'").arg(dir.absolutePath()));
-      if(!logFileDates[net].isValid()) {
-        qWarning(QString("\"%1\" has an invalid file name!").arg(f.fileName()).toAscii());
-      }
-      while(!in.atEnd()) {
-        quint8 t, f;
-        quint32 ts;
-        QByteArray s, m, targ;
-        in >> ts >> t >> f >> targ >> s >> m;
-        QString target = QString::fromUtf8(targ);
-        QString sender = QString::fromUtf8(s);
-        QString text = QString::fromUtf8(m);
-        BufferId id;
-        if((f & Message::PrivMsg) && !(f & Message::Self)) {
-          id = getBufferId(net, sender);
-        } else {
-          id = getBufferId(net, target);
-        }
-        Message msg(QDateTime::fromTime_t(ts), id, (Message::Type)t, text, sender, f);
-        //backLog[net].append(m);
-        logMessage(msg);
-      }
-      f.close();
-    }
-  }
-  backLogEnabledOld = true;
-}
-
-
-/** Log a core message (emitted via a displayMsg() signal) to the backlog file.
- * If a file for the current day does not exist, one will be created. Otherwise, messages will be appended.
- * The file header is the string defined by BACKLOG_STRING, followed by a quint8 specifying the format
- * version (BACKLOG_FORMAT). The rest is simply serialized Message objects.
- */
-void Backlog::logMessageOld(QString net, Message msg) {
-  backLog[net].append(msg);
-  if(!logFileDirs.contains(net)) {
-    QDir dir(backLogDir.absolutePath() + "/" + net);
-    if(!dir.exists()) {
-      qWarning(QString("Creating backlog directory \"%1\"...").arg(dir.absolutePath()).toAscii());
-      if(!dir.mkpath(dir.absolutePath())) {
-        qWarning(QString("Could not create backlog directory!").toAscii());
-        return;
-      }
-    }
-    logFileDirs[net] = dir;
-    Q_ASSERT(!logFiles.contains(net) && !logStreams.contains(net));
-    if(!logFiles.contains(net)) logFiles[net] = new QFile();
-    if(!logStreams.contains(net)) logStreams[net] = new QDataStream();
-  }
-  if(!logFileDates[net].isValid() || logFileDates[net] < QDate::currentDate()) {
-    if(logFiles[net]->isOpen()) logFiles[net]->close();
-    logFileDates[net] = QDate::currentDate();
-  }
-  if(!logFiles[net]->isOpen()) {
-    logFiles[net]->setFileName(QString("%1/%2").arg(logFileDirs[net].absolutePath())
-        .arg(logFileDates[net].toString("'quassel-backlog-'yyyy-MM-dd'.bin'")));
-    if(!logFiles[net]->open(QIODevice::WriteOnly|QIODevice::Append|QIODevice::Unbuffered)) {
-      qWarning(QString("Could not open \"%1\" for writing: %2")
-          .arg(logFiles[net]->fileName()).arg(logFiles[net]->errorString()).toAscii());
-      return;
-    }
-    logStreams[net]->setDevice(logFiles[net]); logStreams[net]->setVersion(QDataStream::Qt_4_2);
-    if(!logFiles[net]->size()) *logStreams[net] << BACKLOG_STRING << (quint8)BACKLOG_FORMAT;
-  }
-  *logStreams[net] << msg;
-}
-
-
diff --git a/src/core/backlog.h b/src/core/backlog.h
deleted file mode 100644 (file)
index 9dc0dcf..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005-07 by The Quassel Team                             *
- *   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) any later version.                                   *
- *                                                                         *
- *   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 _BACKLOG_H_
-#define _BACKLOG_H_
-
-#include <QtCore>
-#include <QtSql>
-
-#include "global.h"
-#include "message.h"
-
-// TODO: is this threadsafe? should it be?
-class Backlog : public QObject {
-  Q_OBJECT
-
-  public:
-    Backlog();
-    ~Backlog();
-
-    void init(QString user);
-    void setDefaultSettings(int lines = -1, QDateTime time = QDateTime());
-    void setSettings(QString network, QString buffer, int lines = -1, QDateTime time = QDateTime());
-
-    BufferId getBufferId(QString network, QString buffer);
-    uint logMessage(Message msg);
-
-    QList<Message> requestMsgs(BufferId, int lastlines = -1, int offset = -1);
-    QList<Message> requestMsgs(BufferId, QDateTime since, int offset = -1);
-    //QList<Message> requestMsgRange(BufferId, int first, int last);
-
-    QList<BufferId> requestBuffers(QDateTime since = QDateTime());
-
-  public slots:
-    void importOldBacklog();
-
-  signals:
-    void bufferIdUpdated(BufferId); // sent also if a new bufferid is created
-
-  private:
-    QString user;
-    bool backlogEnabled;
-    QSqlDatabase logDb;
-
-    uint nextMsgId, nextBufferId, nextSenderId;
-
-    QTimer cleanupTimer;
-
-    void cleanup();
-
-    // Old stuff, just for importing old file-based data
-    void initBackLogOld();
-    void logMessageOld(QString net, Message);
-
-    bool backLogEnabledOld;
-    QDir backLogDir;
-    QHash<QString, QList<Message> > backLog;
-    //QHash<QString, int> netIdx;
-    QHash<QString, QFile *> logFiles;
-    QHash<QString, QDataStream *> logStreams;
-    QHash<QString, QDate> logFileDates;
-    QHash<QString, QDir> logFileDirs;
-
-};
-
-
-
-#endif
index f9bc84f..e6b8c7f 100644 (file)
  ***************************************************************************/
 
 #include "core.h"
-#include "server.h"
-#include "global.h"
-#include "util.h"
-#include "coreproxy.h"
+#include "coresession.h"
 #include "sqlitestorage.h"
-
-#include <QtSql>
-#include <QSettings>
+#include "util.h"
 
 Core *Core::instanceptr = 0;
 
@@ -254,177 +249,3 @@ void Core::recvProxySignal(CoreSignal sig, QVariant arg1, QVariant arg2, QVarian
     if(validClients[socket] == uid) writeDataToDevice(socket, QVariant(sigdata));
   }
 }
-
-/*
-  // Read global settings from config file
-  QSettings s;
-  s.beginGroup("Global");
-  QString key;
-  foreach(key, s.childKeys()) {
-    global->updateData(key, s.value(key));
-  }
-
-  global->updateData("CoreReady", true);
-  // Now that we are in sync, we can connect signals to automatically store further updates.
-  // I don't think we care if global data changed locally or if it was updated by a client. 
-  connect(global, SIGNAL(dataUpdatedRemotely(QString)), SLOT(globalDataUpdated(QString)));
-  connect(global, SIGNAL(dataPutLocally(QString)), SLOT(globalDataUpdated(QString)));
-
-}
-  */
-
-CoreSession::CoreSession(UserId uid, Storage *_storage) : user(uid), storage(_storage) {
-  coreProxy = new CoreProxy();
-
-  connect(coreProxy, SIGNAL(send(CoreSignal, QVariant, QVariant, QVariant)), this, SIGNAL(proxySignal(CoreSignal, QVariant, QVariant, QVariant)));
-  connect(coreProxy, SIGNAL(requestServerStates()), this, SIGNAL(serverStateRequested()));
-  connect(coreProxy, SIGNAL(gsRequestConnect(QStringList)), this, SLOT(connectToIrc(QStringList)));
-  connect(coreProxy, SIGNAL(gsUserInput(BufferId, QString)), this, SLOT(msgFromGui(BufferId, QString)));
-  connect(coreProxy, SIGNAL(gsImportBacklog()), storage, SLOT(importOldBacklog()));
-  connect(coreProxy, SIGNAL(gsRequestBacklog(BufferId, QVariant, QVariant)), this, SLOT(sendBacklog(BufferId, QVariant, QVariant)));
-  connect(coreProxy, SIGNAL(gsRequestNetworkStates()), this, SLOT(sendServerStates()));
-  connect(this, SIGNAL(displayMsg(Message)), coreProxy, SLOT(csDisplayMsg(Message)));
-  connect(this, SIGNAL(displayStatusMsg(QString, QString)), coreProxy, SLOT(csDisplayStatusMsg(QString, QString)));
-  connect(this, SIGNAL(backlogData(BufferId, QList<QVariant>, bool)), coreProxy, SLOT(csBacklogData(BufferId, QList<QVariant>, bool)));
-  connect(this, SIGNAL(bufferIdUpdated(BufferId)), coreProxy, SLOT(csUpdateBufferId(BufferId)));
-  connect(storage, SIGNAL(bufferIdUpdated(BufferId)), coreProxy, SLOT(csUpdateBufferId(BufferId)));
-  connect(Global::instance(), SIGNAL(dataUpdatedRemotely(UserId, QString)), this, SLOT(globalDataUpdated(UserId, QString)));
-  connect(Global::instance(), SIGNAL(dataPutLocally(UserId, QString)), this, SLOT(globalDataUpdated(UserId, QString)));
-}
-
-CoreSession::~CoreSession() {
-
-}
-
-UserId CoreSession::userId() {
-  return user;
-}
-
-void CoreSession::processSignal(ClientSignal sig, QVariant arg1, QVariant arg2, QVariant arg3) {
-  coreProxy->recv(sig, arg1, arg2, arg3);
-}
-
-void CoreSession::globalDataUpdated(UserId uid, QString key) {
-  Q_ASSERT(uid == userId());
-  QVariant data = Global::data(userId(), key);
-  QSettings s;
-  s.setValue(QString("Global/%1/").arg(userId())+key, data);
-}
-
-void CoreSession::connectToIrc(QStringList networks) {
-  foreach(QString net, networks) {
-    if(servers.contains(net)) {
-
-    } else {
-      Server *server = new Server(userId(), net);
-      connect(this, SIGNAL(serverStateRequested()), server, SLOT(sendState()));
-      connect(this, SIGNAL(connectToIrc(QString)), server, SLOT(connectToIrc(QString)));
-      connect(this, SIGNAL(disconnectFromIrc(QString)), server, SLOT(disconnectFromIrc(QString)));
-      connect(this, SIGNAL(msgFromGui(QString, QString, QString)), server, SLOT(userInput(QString, QString, QString)));
-
-      connect(server, SIGNAL(connected(QString)), this, SLOT(serverConnected(QString)));
-      connect(server, SIGNAL(disconnected(QString)), this, SLOT(serverDisconnected(QString)));
-
-      connect(server, SIGNAL(serverState(QString, VarMap)), coreProxy, SLOT(csServerState(QString, VarMap)));
-      //connect(server, SIGNAL(displayMsg(Message)), this, SLOT(recvMessageFromServer(Message)));
-      connect(server, SIGNAL(displayMsg(Message::Type, QString, QString, QString, quint8)), this, SLOT(recvMessageFromServer(Message::Type, QString, QString, QString, quint8)));
-      connect(server, SIGNAL(displayStatusMsg(QString)), this, SLOT(recvStatusMsgFromServer(QString)));
-      connect(server, SIGNAL(modeSet(QString, QString, QString)), coreProxy, SLOT(csModeSet(QString, QString, QString)));
-      connect(server, SIGNAL(topicSet(QString, QString, QString)), coreProxy, SLOT(csTopicSet(QString, QString, QString)));
-      connect(server, SIGNAL(nickAdded(QString, QString, VarMap)), coreProxy, SLOT(csNickAdded(QString, QString, VarMap)));
-      connect(server, SIGNAL(nickRenamed(QString, QString, QString)), coreProxy, SLOT(csNickRenamed(QString, QString, QString)));
-      connect(server, SIGNAL(nickRemoved(QString, QString)), coreProxy, SLOT(csNickRemoved(QString, QString)));
-      connect(server, SIGNAL(nickUpdated(QString, QString, VarMap)), coreProxy, SLOT(csNickUpdated(QString, QString, VarMap)));
-      connect(server, SIGNAL(ownNickSet(QString, QString)), coreProxy, SLOT(csOwnNickSet(QString, QString)));
-      connect(server, SIGNAL(queryRequested(QString, QString)), coreProxy, SLOT(csQueryRequested(QString, QString)));
-      // TODO add error handling
-      connect(server, SIGNAL(connected(QString)), coreProxy, SLOT(csServerConnected(QString)));
-      connect(server, SIGNAL(disconnected(QString)), coreProxy, SLOT(csServerDisconnected(QString)));
-
-      server->start();
-      servers[net] = server;
-    }
-    emit connectToIrc(net);
-  }
-}
-
-void CoreSession::serverConnected(QString net) {
-  storage->getBufferId(userId(), net); // create status buffer
-}
-
-void CoreSession::serverDisconnected(QString net) {
-  delete servers[net];
-  servers.remove(net);
-  coreProxy->csServerDisconnected(net);
-}
-
-void CoreSession::msgFromGui(BufferId bufid, QString msg) {
-  emit msgFromGui(bufid.network(), bufid.buffer(), msg);
-}
-
-// ALL messages coming pass through these functions before going to the GUI.
-// So this is the perfect place for storing the backlog and log stuff.
-
-void CoreSession::recvMessageFromServer(Message::Type type, QString target, QString text, QString sender, quint8 flags) {
-  Server *s = qobject_cast<Server*>(this->sender());
-  Q_ASSERT(s);
-  BufferId buf;
-  if((flags & Message::PrivMsg) && !(flags & Message::Self)) {
-    buf = storage->getBufferId(user, s->getNetwork(), nickFromMask(sender));
-  } else {
-    buf = storage->getBufferId(user, s->getNetwork(), target);
-  }
-  Message msg(buf, type, text, sender, flags);
-  msg.msgId = storage->logMessage(msg); //qDebug() << msg.msgId;
-  Q_ASSERT(msg.msgId);
-  emit displayMsg(msg);
-}
-
-void CoreSession::recvStatusMsgFromServer(QString msg) {
-  Server *s = qobject_cast<Server*>(sender());
-  Q_ASSERT(s);
-  emit displayStatusMsg(s->getNetwork(), msg);
-}
-
-
-QList<BufferId> CoreSession::buffers() const {
-  return storage->requestBuffers(user);
-}
-
-
-QVariant CoreSession::sessionState() {
-  VarMap v;
-  QList<QVariant> bufs;
-  foreach(BufferId id, storage->requestBuffers(user)) { bufs.append(QVariant::fromValue(id)); }
-  v["Buffers"] = bufs;
-
-  return v;
-}
-
-void CoreSession::sendServerStates() {
-  emit serverStateRequested();
-}
-
-void CoreSession::sendBacklog(BufferId id, QVariant v1, QVariant v2) {
-  QList<QVariant> log;
-  QList<Message> msglist;
-  if(v1.type() == QVariant::DateTime) {
-
-
-  } else {
-    msglist = storage->requestMsgs(id, v1.toInt(), v2.toInt());
-  }
-
-  // Send messages out in smaller packages - we don't want to make the signal data too large!
-  for(int i = 0; i < msglist.count(); i++) {
-    log.append(QVariant::fromValue(msglist[i]));
-    if(log.count() >= 5) {
-      emit backlogData(id, log, i >= msglist.count() - 1);
-      log.clear();
-    }
-  }
-  if(log.count() > 0) emit backlogData(id, log, true);
-}
-
-
-//Core *core = 0;
index aec0469..374d821 100644 (file)
 
 #include <QString>
 #include <QVariant>
-#include <QSqlDatabase>
+#include <QTcpServer>
+#include <QTcpSocket>
 
-#include "server.h"
-#include "storage.h"
-#include "global.h"
 #include "coreproxy.h"
 
 class CoreSession;
+class Storage;
 
 class Core : public QObject {
   Q_OBJECT
@@ -80,99 +79,4 @@ class Core : public QObject {
     QHash<QTcpSocket *, quint32> blockSizes;
 };
 
-class CoreSession : public QObject {
-  Q_OBJECT
-
-  public:
-    CoreSession(UserId, Storage *);
-    ~CoreSession();
-
-    QList<BufferId> buffers() const;
-    inline UserId userId();
-    QVariant sessionState();
-    CoreProxy *proxy();
-
-  public slots:
-    void connectToIrc(QStringList);
-    void processSignal(ClientSignal, QVariant, QVariant, QVariant);
-    void sendBacklog(BufferId, QVariant, QVariant);
-    void msgFromGui(BufferId, QString message);
-    void sendServerStates();
-
-  signals:
-    void proxySignal(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
-
-    void msgFromGui(QString net, QString buf, QString message);
-    void displayMsg(Message message);
-    void displayStatusMsg(QString, QString);
-
-    void connectToIrc(QString net);
-    void disconnectFromIrc(QString net);
-    void serverStateRequested();
-
-    void backlogData(BufferId, QList<QVariant>, bool done);
-
-    void bufferIdUpdated(BufferId);
-
-  private slots:
-    //void recvProxySignal(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
-    void globalDataUpdated(UserId, QString);
-    void recvStatusMsgFromServer(QString msg);
-    void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
-    void serverConnected(QString net);
-    void serverDisconnected(QString net);
-
-  private:
-    CoreProxy *coreProxy;
-    Storage *storage;
-    QHash<QString, Server *> servers;
-    UserId user;
-
-};
-
-/*
-class Core : public QObject {
-  Q_OBJECT
-
-  public:
-
-    Core();
-    ~Core();
-    QList<BufferId> getBuffers();
-
-  public slots:
-    void connectToIrc(QStringList);
-    void sendBacklog(BufferId, QVariant, QVariant);
-    void msgFromGUI(BufferId, QString message);
-
-  signals:
-    void msgFromGUI(QString net, QString buf, QString message);
-    void displayMsg(Message message);
-    void displayStatusMsg(QString, QString);
-
-    void connectToIrc(QString net);
-    void disconnectFromIrc(QString net);
-    void serverStateRequested();
-
-    void backlogData(BufferId, QList<QVariant>, bool done);
-
-    void bufferIdUpdated(BufferId);
-
-  private slots:
-    void globalDataUpdated(QString);
-    void recvStatusMsgFromServer(QString msg);
-    void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
-    void serverDisconnected(QString net);
-
-  private:
-    Storage *storage;
-    QHash<QString, Server *> servers;
-    UserId user;
-
-};
-
-*/
-//extern Core *core;
-
-
 #endif
index 84c427c..f10af41 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#include <QDebug>
-
 #include "coreproxy.h"
-#include "global.h"
-#include "util.h"
-#include "core.h"
 
 CoreProxy::CoreProxy() {
-//  connect(global, SIGNAL(dataPutLocally(QString)), this, SLOT(updateGlobalData(QString)));
-//  connect(&server, SIGNAL(newConnection()), this, SLOT(incomingConnection()));
-}
-
-/*
-void CoreProxy::processClientUpdate(QTcpSocket *socket, QString key, QVariant data) {
-  global->updateData(key, data);
-  QList<QVariant> sigdata;
-  sigdata.append(CS_UPDATE_GLOBAL_DATA); sigdata.append(key); sigdata.append(data); sigdata.append(QVariant());
-  QTcpSocket *s;
-  foreach(s, clients) {
-    if(s != socket) writeDataToDevice(s, QVariant(sigdata));
-  }
-}
 
-void CoreProxy::updateGlobalData(QString key) {
-  QVariant data = global->getData(key);
-  emit csUpdateGlobalData(key, data);
 }
-*/
-
-/*
-void CoreProxy::send(CoreSignal sig, QVariant arg1, QVariant arg2, QVariant arg3) {
-
-  QList<QVariant> sigdata;
-  sigdata.append(sig); sigdata.append(arg1); sigdata.append(arg2); sigdata.append(arg3);
-  //qDebug() << "Sending signal: " << sigdata;
-  QTcpSocket *socket;
-  foreach(socket, clients) {
-    writeDataToDevice(socket, QVariant(sigdata));
-  }
-}
-*/
 
 void CoreProxy::recv(ClientSignal sig, QVariant arg1, QVariant arg2, QVariant arg3) {
   //qDebug() << "[CORE] Received signal" << sig << ":" << arg1<<arg2<<arg3;
@@ -73,6 +37,3 @@ void CoreProxy::recv(ClientSignal sig, QVariant arg1, QVariant arg2, QVariant ar
     default: emit gsGeneric(sig, arg1, arg2, arg3);
   }
 }
-
-
-//CoreProxy *coreProxy;
index 737d061..fbb34b6 100644 (file)
 #include "message.h"
 #include "global.h"
 
-#include <QtCore>
-#include <QTcpSocket>
-#include <QTcpServer>
+//#include <QtCore>
+#include <QStringList>
+//#include <QTcpSocket>
+//#include <QTcpServer>
 
 /** This class is the Core side of the proxy. The Core connects its signals and slots to it,
  *  and the calls are marshalled and sent to (or received and unmarshalled from) the GuiProxy.
@@ -74,20 +75,10 @@ class CoreProxy : public QObject {
     void send(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
 
   public:
-    //void send(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
     void recv(ClientSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
 
-  private:
-    void processClientUpdate(QTcpSocket *, QString key, QVariant data);
 
-
-  private:
-
-  friend class GuiProxy;
 };
 
-//extern CoreProxy *coreProxy;
-
-
 
 #endif
diff --git a/src/core/coresession.cpp b/src/core/coresession.cpp
new file mode 100644 (file)
index 0000000..ae0bdb2
--- /dev/null
@@ -0,0 +1,177 @@
+/***************************************************************************
+ *   Copyright (C) 2005-07 by The Quassel IRC Development Team             *
+ *   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) any later version.                                   *
+ *                                                                         *
+ *   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 "coresession.h"
+#include "server.h"
+#include "storage.h"
+#include "util.h"
+
+CoreSession::CoreSession(UserId uid, Storage *_storage) : user(uid), storage(_storage) {
+  coreProxy = new CoreProxy();
+
+  connect(coreProxy, SIGNAL(send(CoreSignal, QVariant, QVariant, QVariant)), this, SIGNAL(proxySignal(CoreSignal, QVariant, QVariant, QVariant)));
+  connect(coreProxy, SIGNAL(requestServerStates()), this, SIGNAL(serverStateRequested()));
+  connect(coreProxy, SIGNAL(gsRequestConnect(QStringList)), this, SLOT(connectToIrc(QStringList)));
+  connect(coreProxy, SIGNAL(gsUserInput(BufferId, QString)), this, SLOT(msgFromGui(BufferId, QString)));
+  connect(coreProxy, SIGNAL(gsImportBacklog()), storage, SLOT(importOldBacklog()));
+  connect(coreProxy, SIGNAL(gsRequestBacklog(BufferId, QVariant, QVariant)), this, SLOT(sendBacklog(BufferId, QVariant, QVariant)));
+  connect(coreProxy, SIGNAL(gsRequestNetworkStates()), this, SLOT(sendServerStates()));
+  connect(this, SIGNAL(displayMsg(Message)), coreProxy, SLOT(csDisplayMsg(Message)));
+  connect(this, SIGNAL(displayStatusMsg(QString, QString)), coreProxy, SLOT(csDisplayStatusMsg(QString, QString)));
+  connect(this, SIGNAL(backlogData(BufferId, QList<QVariant>, bool)), coreProxy, SLOT(csBacklogData(BufferId, QList<QVariant>, bool)));
+  connect(this, SIGNAL(bufferIdUpdated(BufferId)), coreProxy, SLOT(csUpdateBufferId(BufferId)));
+  connect(storage, SIGNAL(bufferIdUpdated(BufferId)), coreProxy, SLOT(csUpdateBufferId(BufferId)));
+  connect(Global::instance(), SIGNAL(dataUpdatedRemotely(UserId, QString)), this, SLOT(globalDataUpdated(UserId, QString)));
+  connect(Global::instance(), SIGNAL(dataPutLocally(UserId, QString)), this, SLOT(globalDataUpdated(UserId, QString)));
+}
+
+CoreSession::~CoreSession() {
+
+}
+
+UserId CoreSession::userId() const {
+  return user;
+}
+
+void CoreSession::processSignal(ClientSignal sig, QVariant arg1, QVariant arg2, QVariant arg3) {
+  coreProxy->recv(sig, arg1, arg2, arg3);
+}
+
+void CoreSession::globalDataUpdated(UserId uid, QString key) {
+  Q_ASSERT(uid == userId());
+  QVariant data = Global::data(userId(), key);
+  QSettings s;
+  s.setValue(QString("Global/%1/").arg(userId())+key, data);
+}
+
+void CoreSession::connectToIrc(QStringList networks) {
+  foreach(QString net, networks) {
+    if(servers.contains(net)) {
+
+    } else {
+      Server *server = new Server(userId(), net);
+      connect(this, SIGNAL(serverStateRequested()), server, SLOT(sendState()));
+      connect(this, SIGNAL(connectToIrc(QString)), server, SLOT(connectToIrc(QString)));
+      connect(this, SIGNAL(disconnectFromIrc(QString)), server, SLOT(disconnectFromIrc(QString)));
+      connect(this, SIGNAL(msgFromGui(QString, QString, QString)), server, SLOT(userInput(QString, QString, QString)));
+
+      connect(server, SIGNAL(connected(QString)), this, SLOT(serverConnected(QString)));
+      connect(server, SIGNAL(disconnected(QString)), this, SLOT(serverDisconnected(QString)));
+
+      connect(server, SIGNAL(serverState(QString, VarMap)), coreProxy, SLOT(csServerState(QString, VarMap)));
+      //connect(server, SIGNAL(displayMsg(Message)), this, SLOT(recvMessageFromServer(Message)));
+      connect(server, SIGNAL(displayMsg(Message::Type, QString, QString, QString, quint8)), this, SLOT(recvMessageFromServer(Message::Type, QString, QString, QString, quint8)));
+      connect(server, SIGNAL(displayStatusMsg(QString)), this, SLOT(recvStatusMsgFromServer(QString)));
+      connect(server, SIGNAL(modeSet(QString, QString, QString)), coreProxy, SLOT(csModeSet(QString, QString, QString)));
+      connect(server, SIGNAL(topicSet(QString, QString, QString)), coreProxy, SLOT(csTopicSet(QString, QString, QString)));
+      connect(server, SIGNAL(nickAdded(QString, QString, VarMap)), coreProxy, SLOT(csNickAdded(QString, QString, VarMap)));
+      connect(server, SIGNAL(nickRenamed(QString, QString, QString)), coreProxy, SLOT(csNickRenamed(QString, QString, QString)));
+      connect(server, SIGNAL(nickRemoved(QString, QString)), coreProxy, SLOT(csNickRemoved(QString, QString)));
+      connect(server, SIGNAL(nickUpdated(QString, QString, VarMap)), coreProxy, SLOT(csNickUpdated(QString, QString, VarMap)));
+      connect(server, SIGNAL(ownNickSet(QString, QString)), coreProxy, SLOT(csOwnNickSet(QString, QString)));
+      connect(server, SIGNAL(queryRequested(QString, QString)), coreProxy, SLOT(csQueryRequested(QString, QString)));
+      // TODO add error handling
+      connect(server, SIGNAL(connected(QString)), coreProxy, SLOT(csServerConnected(QString)));
+      connect(server, SIGNAL(disconnected(QString)), coreProxy, SLOT(csServerDisconnected(QString)));
+
+      server->start();
+      servers[net] = server;
+    }
+    emit connectToIrc(net);
+  }
+}
+
+void CoreSession::serverConnected(QString net) {
+  storage->getBufferId(userId(), net); // create status buffer
+}
+
+void CoreSession::serverDisconnected(QString net) {
+  delete servers[net];
+  servers.remove(net);
+  coreProxy->csServerDisconnected(net);
+}
+
+void CoreSession::msgFromGui(BufferId bufid, QString msg) {
+  emit msgFromGui(bufid.network(), bufid.buffer(), msg);
+}
+
+// ALL messages coming pass through these functions before going to the GUI.
+// So this is the perfect place for storing the backlog and log stuff.
+
+void CoreSession::recvMessageFromServer(Message::Type type, QString target, QString text, QString sender, quint8 flags) {
+  Server *s = qobject_cast<Server*>(this->sender());
+  Q_ASSERT(s);
+  BufferId buf;
+  if((flags & Message::PrivMsg) && !(flags & Message::Self)) {
+    buf = storage->getBufferId(user, s->getNetwork(), nickFromMask(sender));
+  } else {
+    buf = storage->getBufferId(user, s->getNetwork(), target);
+  }
+  Message msg(buf, type, text, sender, flags);
+  msg.msgId = storage->logMessage(msg); //qDebug() << msg.msgId;
+  Q_ASSERT(msg.msgId);
+  emit displayMsg(msg);
+}
+
+void CoreSession::recvStatusMsgFromServer(QString msg) {
+  Server *s = qobject_cast<Server*>(sender());
+  Q_ASSERT(s);
+  emit displayStatusMsg(s->getNetwork(), msg);
+}
+
+
+QList<BufferId> CoreSession::buffers() const {
+  return storage->requestBuffers(user);
+}
+
+
+QVariant CoreSession::sessionState() {
+  VarMap v;
+  QList<QVariant> bufs;
+  foreach(BufferId id, storage->requestBuffers(user)) { bufs.append(QVariant::fromValue(id)); }
+  v["Buffers"] = bufs;
+
+  return v;
+}
+
+void CoreSession::sendServerStates() {
+  emit serverStateRequested();
+}
+
+void CoreSession::sendBacklog(BufferId id, QVariant v1, QVariant v2) {
+  QList<QVariant> log;
+  QList<Message> msglist;
+  if(v1.type() == QVariant::DateTime) {
+
+
+  } else {
+    msglist = storage->requestMsgs(id, v1.toInt(), v2.toInt());
+  }
+
+  // Send messages out in smaller packages - we don't want to make the signal data too large!
+  for(int i = 0; i < msglist.count(); i++) {
+    log.append(QVariant::fromValue(msglist[i]));
+    if(log.count() >= 5) {
+      emit backlogData(id, log, i >= msglist.count() - 1);
+      log.clear();
+    }
+  }
+  if(log.count() > 0) emit backlogData(id, log, true);
+}
diff --git a/src/core/coresession.h b/src/core/coresession.h
new file mode 100644 (file)
index 0000000..24d3d8d
--- /dev/null
@@ -0,0 +1,83 @@
+/***************************************************************************
+ *   Copyright (C) 2005-07 by The Quassel IRC Development Team             *
+ *   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) any later version.                                   *
+ *                                                                         *
+ *   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 _CORESESSION_H_
+#define _CORESESSION_H_
+
+#include <QObject>
+#include <QString>
+#include <QVariant>
+
+#include "coreproxy.h"
+
+class Server;
+class Storage;
+
+class CoreSession : public QObject {
+  Q_OBJECT
+
+  public:
+    CoreSession(UserId, Storage *);
+    ~CoreSession();
+
+    QList<BufferId> buffers() const;
+    UserId userId() const;
+    QVariant sessionState();
+    CoreProxy *proxy();
+
+  public slots:
+    void connectToIrc(QStringList);
+    void processSignal(ClientSignal, QVariant, QVariant, QVariant);
+    void sendBacklog(BufferId, QVariant, QVariant);
+    void msgFromGui(BufferId, QString message);
+    void sendServerStates();
+
+  signals:
+    void proxySignal(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
+
+    void msgFromGui(QString net, QString buf, QString message);
+    void displayMsg(Message message);
+    void displayStatusMsg(QString, QString);
+
+    void connectToIrc(QString net);
+    void disconnectFromIrc(QString net);
+    void serverStateRequested();
+
+    void backlogData(BufferId, QList<QVariant>, bool done);
+
+    void bufferIdUpdated(BufferId);
+
+  private slots:
+    //void recvProxySignal(CoreSignal, QVariant arg1 = QVariant(), QVariant arg2 = QVariant(), QVariant arg3 = QVariant());
+    void globalDataUpdated(UserId, QString);
+    void recvStatusMsgFromServer(QString msg);
+    void recvMessageFromServer(Message::Type, QString target, QString text, QString sender = "", quint8 flags = Message::None);
+    void serverConnected(QString net);
+    void serverDisconnected(QString net);
+
+  private:
+    CoreProxy *coreProxy;
+    Storage *storage;
+    QHash<QString, Server *> servers;
+    UserId user;
+
+};
+
+#endif
index e5ed4eb..39fcfb3 100644 (file)
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
-
-#include "util.h"
-#include "global.h"
 #include "server.h"
-#include "message.h"
 
 #include <QMetaObject>
+#include <QMetaMethod>
 #include <QDateTime>
 
+#include "util.h"
+
 Server::Server(UserId uid, QString net) : user(uid), network(net) {
   QString MQUOTE = QString('\020');
   ctcpMDequoteHash[MQUOTE + '0'] = QString('\000');
index c17b4d0..34a4514 100644 (file)
 #ifndef _SERVER_H_
 #define _SERVER_H_
 
-#include <QtCore>
+#include <QAbstractSocket>
+#include <QString>
+#include <QStringList>
+#include <QTcpSocket>
+#include <QThread>
 #include <QTimer>
-#include <QtNetwork>
 
-#include "global.h"
 #include "message.h"
 
 #define DEFAULT_PORT 6667
index 00dc4c0..7ee2e56 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "sqlitestorage.h"
 
+#include <QtSql>
 
 SqliteStorage::SqliteStorage() {
   // TODO I don't think that this path is failsafe for windows users :) 
index 9b60aae..393050b 100644 (file)
 #ifndef _SQLITESTORAGE_H_
 #define _SQLITESTORAGE_H_
 
-#include <QtCore>
 #include <QCryptographicHash>
 
 #include "global.h"
 #include "storage.h"
 
+class QSqlQuery;
+
 class SqliteStorage : public Storage {
   Q_OBJECT
 
index e0d24a9..d143443 100644 (file)
@@ -22,9 +22,9 @@
 #define _STORAGE_H_
 
 #include <QtCore>
-#include <QtSql>
+#include <QSqlDatabase>
 
-#include "global.h"
+//#include "global.h"
 #include "message.h"
 
 class Storage : public QObject {
@@ -158,7 +158,7 @@ class Storage : public QObject {
     // Old stuff, just for importing old file-based data
     void initBackLogOld(UserId id);
 
-    QSqlDatabase logDb;
+    QSqlDatabase logDb; // FIXME this does not belong in the base class!
       
     bool backLogEnabledOld;
     QDir backLogDir;
index 82ad6ff..cef85a4 100644 (file)
@@ -1,8 +1,8 @@
-SET(qtgui_SRCS chatwidget.cpp chatline.cpp channelwidgetinput.cpp tabcompleter.cpp mainwin.cpp serverlist.cpp bufferwidget.cpp
-             identities.cpp coreconnectdlg.cpp bufferview.cpp bufferviewwidget.cpp bufferviewfilter.cpp style.cpp settingsdlg.cpp settingspages.cpp)
+SET(qtgui_SRCS bufferview.cpp bufferviewfilter.cpp bufferwidget.cpp channelwidgetinput.cpp chatline.cpp chatwidget.cpp coreconnectdlg.cpp
+             identities.cpp mainwin.cpp qtgui.cpp serverlist.cpp settingsdlg.cpp settingspages.cpp style.cpp tabcompleter.cpp)
 SET(qtgui_HDRS style.h)
-SET(qtgui_MOCS chatwidget.h chatline.h channelwidgetinput.h tabcompleter.h mainwin.h serverlist.h identities.h coreconnectdlg.h
-             bufferview.h bufferwidget.h bufferviewwidget.h bufferviewfilter.h settingsdlg.h settingspages.h)
+SET(qtgui_MOCS bufferview.h bufferviewfilter.h bufferwidget.h channelwidgetinput.h chatline.h chatwidget.h coreconnectdlg.h
+              identities.h mainwin.h qtgui.h serverlist.h settingsdlg.h settingspages.h tabcompleter.h)
 SET(qtgui_UICS identitiesdlg.ui identitieseditdlg.ui networkeditdlg.ui mainwin.ui
              nickeditdlg.ui serverlistdlg.ui servereditdlg.ui coreconnectdlg.ui ircwidget.ui
              bufferviewwidget.ui bufferwidget.ui settingsdlg.ui
@@ -16,10 +16,7 @@ ENDFOREACH(ui)
 QT4_WRAP_UI(_UIC ${qtgui_UICS_UI})
 QT4_WRAP_CPP(_MOC ${qtgui_MOCS})
 
-# We need to work around a dependency bug with out-of-source builds...
-# Seems to be fixed!
-#SET_SOURCE_FILES_PROPERTIES(${gui_SRCS} PROPERTIES OBJECT_DEPENDS "${_UIC}")
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+#INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
 
-ADD_LIBRARY(qtgui ${qtgui_HDRS} ${qtgui_SRCS} ${_MOC} ${_UIC})
+ADD_LIBRARY(qtgui ${qtgui_SRCS} ${_MOC} ${_UIC})
 TARGET_LINK_LIBRARIES(qtgui common)
\ No newline at end of file
diff --git a/src/qtgui/bufferviewwidget.cpp b/src/qtgui/bufferviewwidget.cpp
deleted file mode 100644 (file)
index 23d0df2..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005-07 by The Quassel Team                             *
- *   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) any later version.                                   *
- *                                                                         *
- *   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 "bufferviewwidget.h"
-
-/*****************************************
- * This Widget Contains the BufferView
- *****************************************/
-BufferViewWidget::BufferViewWidget(QWidget *parent) : QWidget(parent) {
-  ui.setupUi(this);
-}
-
-QSize BufferViewWidget::sizeHint() const {
-  return QSize(150,100);
-}
-
-
-/*****************************************
- * Dock and API for the BufferViews
- *****************************************/
-BufferViewDock::BufferViewDock(QAbstractItemModel *model, const QString &viewname, const BufferViewFilter::Modes &mode, const QStringList &nets, QWidget *parent) : QDockWidget(parent) {
-  setObjectName(QString("View-" + viewname)); // should be unique for mainwindow state!
-  setWindowTitle(viewname);
-
-  BufferViewWidget *viewWidget = new BufferViewWidget(this);
-  viewWidget->treeView()->setFilteredModel(model, mode, nets);
-  setWidget(viewWidget);
-}
index b6dd62b..2024588 100644 (file)
@@ -24,8 +24,6 @@
 #include "ui_bufferwidget.h"
 
 #include "global.h"
-#include "message.h"
-#include "chatwidget.h"
 
 class Buffer;
 struct BufferState;
index c4d1a06..5ee0daa 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "channelwidgetinput.h"
 
+#include "tabcompleter.h"
+
 ChannelWidgetInput::ChannelWidgetInput(QWidget *parent) : QLineEdit(parent) {
   idx = 0;
   connect(this, SIGNAL(returnPressed()), this, SLOT(enter()));
index eb9a9de..5efebd8 100644 (file)
@@ -21,9 +21,9 @@
 #ifndef _CHANNELWIDGETINPUT_H_
 #define _CHANNELWIDGETINPUT_H_
 
-#include <QtCore>
 #include <QtGui>
-#include "tabcompleter.h"
+
+class TabCompleter;
 
 class ChannelWidgetInput : public QLineEdit {
   Q_OBJECT
index bb193cf..fedf028 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#include <QtGui>
-#include <QtCore>
-#include <QSqlDatabase>
+#include "mainwin.h"
 
+#include "bufferview.h"
+#include "chatline.h"
 #include "client.h"
-#include "util.h"
-#include "global.h"
-#include "message.h"
 #include "clientproxy.h"
-
-#include "mainwin.h"
-#include "buffer.h"
-#include "chatline.h"
-#include "serverlist.h"
 #include "coreconnectdlg.h"
+#include "serverlist.h"
 #include "settingsdlg.h"
 #include "settingspages.h"
 
-QtGui::QtGui() : AbstractUi() {
-  mainWin = new MainWin(this);
-  connect(mainWin, SIGNAL(connectToCore(const VarMap &)), this, SIGNAL(connectToCore(const VarMap &)));
-  connect(mainWin, SIGNAL(disconnectFromCore()), this, SIGNAL(disconnectFromCore()));
-  
-}
-
-QtGui::~QtGui() {
-  delete mainWin;
-}
-
-void QtGui::init() {
-  mainWin->init();
-}
-
-AbstractUiMsg *QtGui::layoutMsg(const Message &msg) {
-  return mainWin->layoutMsg(msg);
-}
-
-void QtGui::connectedToCore() {
-  mainWin->connectedToCore();
-}
-
-void QtGui::disconnectedFromCore() {
-  mainWin->disconnectedFromCore();
-}
-
 MainWin::MainWin(QtGui *_gui, QWidget *parent) : QMainWindow(parent), gui(_gui) {
   ui.setupUi(this);
   setWindowTitle("Quassel IRC");
@@ -109,18 +75,6 @@ void MainWin::init() {
   QString net = s.value("CurrentNetwork", "").toString();
   QString buf = s.value("CurrentBuffer", "").toString();
   s.endGroup();
-  /*
-  if(!net.isEmpty()) {
-    if(buffers.contains(net)) {
-      if(buffers[net].contains(buf)) {
-        showBuffer(net, buf);
-      } else {
-        showBuffer(net, "");
-      }
-    }
-  }
-  */
-
 }
 
 MainWin::~MainWin() {
index eed60f7..24e6ccb 100644 (file)
 #ifndef _MAINWIN_H_
 #define _MAINWIN_H_
 
-#include <QtGui>
 #include "ui_mainwin.h"
 
-//#include "global.h"
-#include "message.h"
-#include "chatwidget.h"
+#include "qtgui.h"
 #include "bufferviewfilter.h"
-#include "bufferview.h"
 
 class ServerListDlg;
 class CoreConnectDlg;
 class Buffer;
 class SettingsDlg;
-class MainWin;
-
-class QtGui : public AbstractUi {
-  Q_OBJECT
-
-  public:
-    QtGui();
-    ~QtGui();
-    void init();
-    AbstractUiMsg *layoutMsg(const Message &);
-
-  protected slots:
-    void connectedToCore();
-    void disconnectedFromCore();
-
-  private:
-    MainWin *mainWin;
-};
-
+class QtGui;
+class Message;
 
 //!\brief The main window of Quassel's QtGui.
 class MainWin : public QMainWindow {
similarity index 60%
rename from src/common/main_core.cpp
rename to src/qtgui/qtgui.cpp
index 607aada..8b24217 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005/06 by The Quassel Team                             *
+ *   Copyright (C) 2005-07 by The Quassel IRC Development Team             *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
-#include <iostream>
-
-#include <QCoreApplication>
-#include <QtNetwork>
-#include <QtCore>
-#include <QtDebug>
-
-#include "global.h"
-#include "core.h"
-#include "coreproxy.h"
-#include "util.h"
-
-int main(int argc, char **argv) {
-  QCoreApplication app(argc, argv);
-  QCoreApplication::setOrganizationDomain("quassel-irc.org");
-  QCoreApplication::setApplicationName("Quassel IRC");
-  QCoreApplication::setOrganizationName("The Quassel Team");
-
-  Global::runMode = Global::CoreOnly;
-  Global::quasselDir = QDir::homePath() + "/.quassel";
-
-  global = new Global();
-  coreProxy = new CoreProxy();
-
-  //Logger *logger = new Logger();
-  //Quassel::setLogger(logger);
-
-  int exitCode = app.exec();
-  delete core;
-  delete coreProxy;
-  delete global;
-  return exitCode;
+
+#include "qtgui.h"
+
+#include "mainwin.h"
+
+QtGui::QtGui() : AbstractUi() {
+  mainWin = new MainWin(this);
+  connect(mainWin, SIGNAL(connectToCore(const VarMap &)), this, SIGNAL(connectToCore(const VarMap &)));
+  connect(mainWin, SIGNAL(disconnectFromCore()), this, SIGNAL(disconnectFromCore()));
+
+}
+
+QtGui::~QtGui() {
+  delete mainWin;
 }
 
-void CoreProxy::sendToGUI(CoreSignal, QVariant, QVariant, QVariant) {
-  // dummy function, no GUI available!
+void QtGui::init() {
+  mainWin->init();
 }
 
+AbstractUiMsg *QtGui::layoutMsg(const Message &msg) {
+  return mainWin->layoutMsg(msg);
+}
+
+void QtGui::connectedToCore() {
+  mainWin->connectedToCore();
+}
+
+void QtGui::disconnectedFromCore() {
+  mainWin->disconnectedFromCore();
+}
similarity index 60%
rename from src/qtgui/bufferviewwidget.h
rename to src/qtgui/qtgui.h
index 8de2035..429127a 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-07 by The Quassel Team                             *
+ *   Copyright (C) 2005-07 by The Quassel IRC Development Team             *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef _BUFFERVIEWWIDGET_H_
-#define _BUFFERVIEWWIDGET_H_
+#ifndef _QTGUI_H_
+#define _QTGUI_H_
 
-#include <QtGui>
-#include <QtCore>
+#include "quasselui.h"
+class MainWin;
 
-#include "bufferviewfilter.h"
-#include "bufferview.h"
-#include "ui_bufferviewwidget.h"
-
-
-/*****************************************
- * This Widget Contains the BufferView
- *****************************************/
-class BufferViewWidget : public QWidget {
+//! This class encapsulates Quassel's Qt-based GUI.
+/** This is basically a wrapper around MainWin, which is necessary because we cannot derive MainWin
+ *  from both QMainWindow and AbstractUi (because of multiple inheritance of QObject).
+ */
+class QtGui : public AbstractUi {
   Q_OBJECT
 
-public:
-  BufferViewWidget(QWidget *parent = 0);
-  virtual QSize sizeHint () const;
-  BufferView *treeView(){ return ui.treeView; }  
-
-private:
-  Ui::BufferViewWidget ui;
-};
+  public:
+    QtGui();
+    ~QtGui();
+    void init();
+    AbstractUiMsg *layoutMsg(const Message &);
 
+  protected slots:
+    void connectedToCore();
+    void disconnectedFromCore();
 
-/*****************************************
- * Dock and API for the BufferViews
- *****************************************/
-class BufferViewDock : public QDockWidget {
-  Q_OBJECT
-
-public:
-  BufferViewDock(QAbstractItemModel *model, const QString &name, const BufferViewFilter::Modes &mode, const QStringList &nets = QStringList(), QWidget *parent = 0);
+  private:
+    MainWin *mainWin;
 };
 
-
 #endif
index 861d5c5..a10a969 100644 (file)
@@ -22,7 +22,8 @@
 #define _STYLE_H_
 
 #include <QtCore>
-#include <QtGui>
+#include <QTextCharFormat>
+#include <QTextLayout>
 
 class Style {