X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=b0be2a3d52895e595cbdcd4fa0348c650cc56a6e;hp=ce734cc5aa09b79a1379734448f9d38c512f76c5;hb=48189e18131e2366eb2790b37f3b6412292f2d6c;hpb=332069a1830ed3a055ac6f2d7661bae1cc83e40c diff --git a/src/client/client.cpp b/src/client/client.cpp index ce734cc5..b0be2a3d 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -28,7 +28,6 @@ #include "bufferviewmanager.h" #include "clientbacklogmanager.h" #include "clientirclisthelper.h" -#include "global.h" #include "identity.h" #include "ircchannel.h" #include "ircuser.h" @@ -52,8 +51,11 @@ Client *Client::instance() { } void Client::destroy() { - //delete instanceptr; - instanceptr->deleteLater(); + if(instanceptr) { + delete instanceptr->mainUi; + instanceptr->deleteLater(); + instanceptr = 0; + } } void Client::init(AbstractUi *ui) { @@ -63,7 +65,6 @@ void Client::init(AbstractUi *ui) { Client::Client(QObject *parent) : QObject(parent), - socket(0), _signalProxy(new SignalProxy(SignalProxy::Client, this)), mainUi(0), _networkModel(0), @@ -114,13 +115,16 @@ void Client::init() { p->attachSlot(SIGNAL(networkCreated(NetworkId)), this, SLOT(coreNetworkCreated(NetworkId))); p->attachSlot(SIGNAL(networkRemoved(NetworkId)), this, SLOT(coreNetworkRemoved(NetworkId))); - connect(p, SIGNAL(disconnected()), this, SLOT(disconnectFromCore())); + connect(p, SIGNAL(disconnected()), this, SLOT(disconnectedFromCore())); //connect(mainUi, SIGNAL(connectToCore(const QVariantMap &)), this, SLOT(connectToCore(const QVariantMap &))); connect(mainUi, SIGNAL(disconnectFromCore()), this, SLOT(disconnectFromCore())); connect(this, SIGNAL(connected()), mainUi, SLOT(connectedToCore())); connect(this, SIGNAL(disconnected()), mainUi, SLOT(disconnectedFromCore())); + // attach backlog manager + p->synchronize(backlogManager()); + connect(backlogManager(), SIGNAL(messagesReceived(BufferId, int)), _messageModel, SLOT(messagesReceived(BufferId, int))); } /*** public static methods ***/ @@ -250,13 +254,20 @@ void Client::userInput(BufferInfo bufferInfo, QString message) { /*** core connection stuff ***/ -void Client::setConnectedToCore(QIODevice *sock, AccountId id) { - socket = sock; +void Client::setConnectedToCore(QIODevice *socket, AccountId id) { + // if the socket is an orphan, the signalProxy adopts it. + // -> we don't need to care about it anymore + socket->setParent(0); signalProxy()->addPeer(socket); _connectedToCore = true; setCurrentCoreAccount(id); } +void Client::setConnectedToInternalCore() { + _connectedToCore = true; + setCurrentCoreAccount(AccountId()); +} + void Client::setSyncedToCore() { // create buffersyncer Q_ASSERT(!_bufferSyncer); @@ -266,9 +277,6 @@ void Client::setSyncedToCore() { connect(bufferSyncer(), SIGNAL(bufferRenamed(BufferId, QString)), this, SLOT(bufferRenamed(BufferId, QString))); signalProxy()->synchronize(bufferSyncer()); - // attach backlog manager - signalProxy()->synchronize(backlogManager()); - // create a new BufferViewManager _bufferViewManager = new BufferViewManager(signalProxy(), this); @@ -284,16 +292,17 @@ void Client::setSecuredConnection() { void Client::disconnectFromCore() { if(!isConnected()) return; - _connectedToCore = false; - if(socket) { - socket->close(); - socket->deleteLater(); - } + signalProxy()->removeAllPeers(); +} + +void Client::disconnectedFromCore() { + _connectedToCore = false; _syncedToCore = false; emit disconnected(); emit coreConnectionStateChanged(false); + backlogManager()->reset(); messageProcessor()->reset(); // Clear internal data. Hopefully nothing relies on it at this point. @@ -333,10 +342,6 @@ void Client::disconnectFromCore() { } -void Client::setCoreConfiguration(const QVariantMap &settings) { - SignalProxy::writeDataToDevice(socket, settings); -} - /*** ***/ void Client::networkDestroyed() {