X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fclient.cpp;h=c25f19392db985bb396134412fb09fbbb7c43c86;hb=fdf69d69f0dda76a65a27ce7059b7b86696ff79c;hp=c2a3e1653607ef066780d8e72eb93d1127bfd87c;hpb=6d32c3e6a04a358789c469948d044715d6fb5aed;p=quassel.git diff --git a/src/client/client.cpp b/src/client/client.cpp index c2a3e165..c25f1939 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -27,6 +27,7 @@ #include "buffersettings.h" #include "buffersyncer.h" #include "bufferviewconfig.h" +#include "bufferviewoverlay.h" #include "clientaliasmanager.h" #include "clientbacklogmanager.h" #include "clientbufferviewmanager.h" @@ -38,6 +39,7 @@ #include "message.h" #include "messagemodel.h" #include "network.h" +#include "networkconfig.h" #include "networkmodel.h" #include "quassel.h" #include "signalproxy.h" @@ -51,6 +53,11 @@ AccountId Client::_currentCoreAccount = 0; /*** Initialization/destruction ***/ +bool Client::instanceExists() +{ + return instanceptr; +} + Client *Client::instance() { if(!instanceptr) instanceptr = new Client(); @@ -80,8 +87,10 @@ Client::Client(QObject *parent) _aliasManager(0), _backlogManager(new ClientBacklogManager(this)), _bufferViewManager(0), + _bufferViewOverlay(new BufferViewOverlay(this)), _ircListHelper(new ClientIrcListHelper(this)), _inputHandler(0), + _networkConfig(0), _messageModel(0), _messageProcessor(0), _connectedToCore(false), @@ -308,14 +317,12 @@ void Client::setSyncedToCore() { connect(bufferSyncer(), SIGNAL(bufferRenamed(BufferId, QString)), this, SLOT(bufferRenamed(BufferId, QString))); connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), this, SLOT(buffersPermanentlyMerged(BufferId, BufferId))); connect(bufferSyncer(), SIGNAL(buffersPermanentlyMerged(BufferId, BufferId)), _messageModel, SLOT(buffersPermanentlyMerged(BufferId, BufferId))); - connect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); connect(networkModel(), SIGNAL(setLastSeenMsg(BufferId, MsgId)), bufferSyncer(), SLOT(requestSetLastSeenMsg(BufferId, const MsgId &))); signalProxy()->synchronize(bufferSyncer()); // create a new BufferViewManager Q_ASSERT(!_bufferViewManager); _bufferViewManager = new ClientBufferViewManager(signalProxy(), this); - connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(createDefaultBufferView())); // create AliasManager @@ -324,14 +331,29 @@ void Client::setSyncedToCore() { connect(aliasManager(), SIGNAL(initDone()), SLOT(sendBufferedUserInput())); signalProxy()->synchronize(aliasManager()); + // create NetworkConfig + Q_ASSERT(!_networkConfig); + _networkConfig = new NetworkConfig("GlobalNetworkConfig", this); + signalProxy()->synchronize(networkConfig()); + + // trigger backlog request once all active bufferviews are initialized + connect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); + _syncedToCore = true; emit connected(); emit coreConnectionStateChanged(true); } void Client::requestInitialBacklog() { - if(bufferViewManager()->isInitialized() && bufferSyncer()->isInitialized()) - Client::backlogManager()->requestInitialBacklog(); + // usually it _should_ take longer until the bufferViews are initialized, so that's what + // triggers this slot. But we have to make sure that we know all buffers yet. + // so we check the BufferSyncer and in case it wasn't initialized we wait for that instead + if(!bufferSyncer()->isInitialized()) { + connect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); + connect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); + return; + } + _backlogManager->requestInitialBacklog(); } void Client::createDefaultBufferView() { @@ -402,6 +424,10 @@ void Client::disconnectedFromCore() { } Q_ASSERT(_identities.isEmpty()); + if(_networkConfig) { + _networkConfig->deleteLater(); + _networkConfig = 0; + } } /*** ***/ @@ -496,6 +522,12 @@ void Client::logMessage(QtMsgType type, const char *msg) { Quassel::logFatalMessage(msg); } else { QString msgString = QString("%1\n").arg(msg); + + //Check to see if there is an instance around, else we risk recursions + //when calling instance() and creating new ones. + if (!instanceExists()) + return; + instance()->_debugLog << msgString; emit instance()->logUpdated(msgString); }