fixing dependencies to core. MonolithicApplication is now a proper QObject
authorMarcus Eggenberger <egs@quassel-irc.org>
Tue, 21 Oct 2008 12:45:48 +0000 (14:45 +0200)
committerMarcus Eggenberger <egs@quassel-irc.org>
Tue, 21 Oct 2008 16:52:52 +0000 (18:52 +0200)
src/CMakeLists.txt
src/client/client.h
src/client/clientsyncer.cpp
src/client/clientsyncer.h
src/qtui/coreconnectdlg.cpp
src/qtui/coreconnectdlg.h
src/qtui/monoapplication.cpp
src/qtui/monoapplication.h
src/qtui/qtuiapplication.cpp

index 33374db..da979d5 100644 (file)
@@ -56,7 +56,8 @@ endif(WANT_QTCLIENT)
 
 if(WANT_MONO)
   setup_qt4_variables(${LINK_DBUS} GUI NETWORK SCRIPT SQL ${LINK_WEBKIT})
-  add_executable(quassel WIN32 common/main.cpp qtui/monoapplication.cpp ${COMMON_DEPS} ${CLIENT_DEPS} ${CORE_DEPS})
+  qt4_wrap_cpp(MOC qtui/monoapplication.h)
+  add_executable(quassel WIN32 common/main.cpp qtui/monoapplication.cpp ${MOC} ${COMMON_DEPS} ${CLIENT_DEPS} ${CORE_DEPS})
   add_dependencies(quassel icons genversion_run)
   set_target_properties(quassel PROPERTIES
                                 COMPILE_FLAGS "-DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_SCRIPT_LIB -DQT_SQL_LIB -DBUILD_MONO"
index 62ad9b0..2d073c5 100644 (file)
@@ -43,6 +43,7 @@ class BufferModel;
 class BufferSyncer;
 class ClientBacklogManager;
 class ClientIrcListHelper;
+class ClientSyncer;
 class BufferViewManager;
 class IrcUser;
 class IrcChannel;
@@ -146,6 +147,8 @@ signals:
   void requestCreateNetwork(const NetworkInfo &info);
   void requestRemoveNetwork(NetworkId);
 
+  void newClientSyncer(ClientSyncer *);
+
 public slots:
   //void selectBuffer(Buffer *);
 
index 655875f..a9d5972 100644 (file)
@@ -170,6 +170,7 @@ void ClientSyncer::coreSocketConnected() {
 }
 
 void ClientSyncer::useInternalCore() {
+  emit startInternalCore();
   emit connectToInternalCore(Client::instance()->signalProxy());
 }
 
index 16c516d..d321451 100644 (file)
@@ -61,6 +61,7 @@ signals:
 
   void encrypted(bool);
 
+  void startInternalCore();
   void connectToInternalCore(SignalProxy *proxy);
 
 public slots:
index 6903d93..d61a021 100644 (file)
 
 #include "coreconnectdlg.h"
 
+#include "client.h"
 #include "clientsettings.h"
 #include "clientsyncer.h"
 #include "coreconfigwizard.h"
 #include "iconloader.h"
-#include "monoapplication.h"
 
 CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent)
   : QDialog(parent)
@@ -44,6 +44,8 @@ CoreConnectDlg::CoreConnectDlg(bool autoconnect, QWidget *parent)
   setWindowFlags(Qt::Sheet);
 
   clientSyncer = new ClientSyncer(this);
+  connect(this, SIGNAL(newClientSyncer(ClientSyncer *)), Client::instance(), SIGNAL(newClientSyncer(ClientSyncer *)));
+  emit newClientSyncer(clientSyncer); // announce the new client syncer via the client.
 
   wizard = 0;
 
@@ -214,13 +216,13 @@ void CoreConnectDlg::on_accountButtonBox_accepted() {
 }
 
 void CoreConnectDlg::on_useInternalCore_clicked() {
-  // FIXME: this needs to be a qobject_cast - therefore MonolithicApplication needs to be a proper QObject... :/
-  MonolithicApplication *monoApp = static_cast<MonolithicApplication *>(QApplication::instance());
-  if(monoApp) {
-    qDebug() << "starting core...";
-    monoApp->startInternalCore();
-    monoApp->connectClientSyncer(clientSyncer);
-  }
+//   // FIXME: this needs to be a qobject_cast - therefore MonolithicApplication needs to be a proper QObject... :/
+//   MonolithicApplication *monoApp = qobject_cast<MonolithicApplication *>(QApplication::instance());
+//   if(monoApp) {
+//     qDebug() << "starting core...";
+//     monoApp->startInternalCore();
+//     monoApp->connectClientSyncer(clientSyncer);
+//   }
   clientSyncer->useInternalCore();
   startSync();
 }
index ff980d3..ae3d5b7 100644 (file)
@@ -18,8 +18,8 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef _CORECONNECTDLG_H_
-#define _CORECONNECTDLG_H_
+#ifndef CORECONNECTDLG_H
+#define CORECONNECTDLG_H
 
 #include <QAbstractSocket>
 
@@ -38,8 +38,10 @@ public:
   CoreConnectDlg(bool = false, QWidget *parent = 0);
   ~CoreConnectDlg();
 
-private slots:
+signals:
+  void newClientSyncer(ClientSyncer *);
 
+private slots:
   /*** Phase Null: Accounts ***/
   void restartPhaseNull();
 
index 97688f2..7b05c73 100644 (file)
@@ -33,8 +33,9 @@ MonolithicApplication::MonolithicApplication(int &argc, char **argv)
 }
 
 bool MonolithicApplication::init() {
-  if(Quassel::init()) {
-    return QtUiApplication::init();
+  connect(Client::instance(), SIGNAL(newClientSyncer(ClientSyncer *)), this, SLOT(newClientSyncer(ClientSyncer *)));
+  if(QtUiApplication::init()) {
+    return true;
   }
   return false;
 }
@@ -45,12 +46,14 @@ MonolithicApplication::~MonolithicApplication() {
   delete _internal;
 }
 
-bool MonolithicApplication::startInternalCore() {
-  return _internal->init();
+void MonolithicApplication::newClientSyncer(ClientSyncer *syncer) {
+  connect(syncer, SIGNAL(startInternalCore()), this, SLOT(startInternalCore()));
 }
 
-void MonolithicApplication::connectClientSyncer(ClientSyncer *syncer) {
+void MonolithicApplication::startInternalCore() {
+  _internal->init();
   Core *core = Core::instance();
+  ClientSyncer *syncer = static_cast<ClientSyncer *>(sender());
   connect(syncer, SIGNAL(connectToInternalCore(SignalProxy *)), core, SLOT(setupInternalClientSession(SignalProxy *)));
   connect(core, SIGNAL(sessionState(const QVariant &)), syncer, SLOT(internalSessionStateReceived(const QVariant &)));
 }
index 4050342..ff35ddd 100644 (file)
@@ -27,13 +27,16 @@ class ClientSyncer;
 class CoreApplicationInternal;
 
 class MonolithicApplication : public QtUiApplication {
+  Q_OBJECT
 public:
   MonolithicApplication(int &, char **);
   ~MonolithicApplication();
 
   bool init();
-  bool startInternalCore();
-  void connectClientSyncer(ClientSyncer *syncer);
+
+private slots:
+  void newClientSyncer(ClientSyncer *syncer);
+  void startInternalCore();
 
 private:
   CoreApplicationInternal *_internal;
index 6ae09c9..7a6f097 100644 (file)
@@ -45,7 +45,6 @@ bool QtUiApplication::init() {
     // QTimer::singleShot(0, gui, SLOT(init()));
     gui->init();
     resumeSessionIfPossible();
-
     return true;
   }
   return false;