Make BufferInfo qDebug()able as per EgS' request.
[quassel.git] / src / core / server.cpp
index 3af2119..b16b837 100644 (file)
@@ -1,11 +1,11 @@
 /***************************************************************************
- *   Copyright (C) 2005-07 by The Quassel Team                             *
+ *   Copyright (C) 2005-07 by the Quassel IRC 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.                                   *
+ *   (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        *
@@ -28,7 +28,6 @@
 #include "coresession.h"
 
 #include "networkinfo.h"
-#include "synchronizer.h"
 
 #include "ircserverhandler.h"
 #include "userinputhandler.h"
@@ -40,9 +39,10 @@ Server::Server(UserId uid, uint networkId, QString net)
     _ircServerHandler(new IrcServerHandler(this)),
     _userInputHandler(new UserInputHandler(this)),
     _ctcpHandler(new CtcpHandler(this)),
-    _networkInfo(new NetworkInfo(networkId, coreSession()->signalProxy(), this))
+    _networkInfo(new NetworkInfo(networkId, this))
 {
   networkInfo()->setNetworkName(net);
+  networkInfo()->setProxy(coreSession()->signalProxy());
 }
 
 Server::~Server() {
@@ -53,10 +53,11 @@ Server::~Server() {
 
 void Server::run() {
   connect(&socket, SIGNAL(connected()), this, SLOT(socketConnected()));
-  connect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
+  connect(&socket, SIGNAL(disconnected()), this, SLOT(quit()));
   connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)));
   connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
   connect(&socket, SIGNAL(readyRead()), this, SLOT(socketHasData()));
+  connect(this, SIGNAL(finished()), this, SLOT(threadFinished()));
 
   exec();
 }
@@ -94,15 +95,17 @@ void Server::socketError( QAbstractSocket::SocketError err ) {
   //qDebug() << "Socket Error!";
 }
 
-void Server::socketConnected( ) {
+void Server::socketConnected() {
   emit connected(networkId());
   putRawLine(QString("NICK :%1").arg(identity["NickList"].toStringList()[0]));  // FIXME: try more nicks if error occurs
   putRawLine(QString("USER %1 8 * :%2").arg(identity["Ident"].toString()).arg(identity["RealName"].toString()));
 }
 
-void Server::socketDisconnected( ) {
+void Server::threadFinished() {
+  // the Socket::disconnected() is connect to this::quit()
+  // so after the event loop is finished we're beeing called
+  // and propagate the disconnect
   emit disconnected(networkId());
-  // propagate to networkInfo, so we can clear up
 }
 
 void Server::socketStateChanged(QAbstractSocket::SocketState state) {