Fixing .desktop entry.
[quassel.git] / src / core / coresession.cpp
index c93324b..94cf39e 100644 (file)
@@ -27,6 +27,7 @@
 #include "signalproxy.h"
 #include "buffersyncer.h"
 #include "corebacklogmanager.h"
+#include "corebufferviewmanager.h"
 #include "storage.h"
 
 #include "network.h"
@@ -43,11 +44,13 @@ CoreSession::CoreSession(UserId uid, bool restoreState, QObject *parent)
     _signalProxy(new SignalProxy(SignalProxy::Server, 0, this)),
     _bufferSyncer(new BufferSyncer(this)),
     _backlogManager(new CoreBacklogManager(this)),
+    _bufferViewManager(new CoreBufferViewManager(_signalProxy, this)),
     scriptEngine(new QScriptEngine(this))
 {
 
   SignalProxy *p = signalProxy();
-
+  connect(p, SIGNAL(peerRemoved(QIODevice *)), this, SLOT(removeClient(QIODevice *)));
+  
   //p->attachSlot(SIGNAL(disconnectFromNetwork(NetworkId)), this, SLOT(disconnectFromNetwork(NetworkId))); // FIXME
   p->attachSlot(SIGNAL(sendInput(BufferInfo, QString)), this, SLOT(msgFromClient(BufferInfo, QString)));
   p->attachSignal(this, SIGNAL(displayMsg(Message)));
@@ -222,6 +225,17 @@ void CoreSession::addClient(QObject *dev) { // this is QObject* so we can use it
   }
 }
 
+void CoreSession::removeClient(QIODevice *iodev) {
+  // no checks for validity check - privateslot...
+  QTcpSocket *socket = qobject_cast<QTcpSocket *>(iodev);
+  if(socket)
+    qDebug() << qPrintable(tr("Client %1 disconnected (UserId: %2).").arg(socket->peerAddress().toString()).arg(user().toInt()));
+  else
+    qDebug() << "Local client disconnedted.";
+  disconnect(socket, 0, this, 0);
+  socket->deleteLater();
+}
+
 SignalProxy *CoreSession::signalProxy() const {
   return _signalProxy;
 }
@@ -258,7 +272,7 @@ void CoreSession::msgFromClient(BufferInfo bufinfo, QString msg) {
   if(conn) {
     conn->userInput(bufinfo, msg);
   } else {
-    qWarning() << "Trying to send to unconnected network!";
+    qWarning() << "Trying to send to unconnected network:" << msg;
   }
 }