From: Manuel Nickschas Date: Thu, 19 Nov 2009 23:10:08 +0000 (+0100) Subject: Handle client state a bit more sanely X-Git-Tag: 0.6-beta1~163 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=4f2cf796763079da1079751bbdac9b905689ec11 Handle client state a bit more sanely Client can only be disconnected or connected. In the latter state, we guarantee that the typical connection-specific (syncable) objects at least exist (but may not be fully synced yet). It doesn't make much sense API-wise to distinguish between "connected" and "synced" state of the Client object, as vital objects are created after being connected. In any case, more detailed information is available via Client::coreConnection(). --- diff --git a/src/client/client.cpp b/src/client/client.cpp index 019c67c9..84d28ec0 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -98,6 +98,7 @@ Client::Client(QObject *parent) _messageProcessor(0), _coreAccountModel(new CoreAccountModel(this)), _coreConnection(new CoreConnection(_coreAccountModel, this)), + _connected(false), _debugLog(&_debugLogBuffer) { _signalProxy->synchronize(_ircListHelper); @@ -159,11 +160,7 @@ AbstractUi *Client::mainUi() { } bool Client::isConnected() { - return coreConnection()->state() >= CoreConnection::Connected; -} - -bool Client::isSynced() { - return coreConnection()->state() == CoreConnection::Synchronized; + return instance()->_connected; } bool Client::internalCore() { @@ -345,6 +342,7 @@ void Client::setSyncedToCore() { // trigger backlog request once all active bufferviews are initialized connect(bufferViewOverlay(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); + _connected = true; emit connected(); emit coreConnectionStateChanged(true); } @@ -378,6 +376,7 @@ void Client::disconnectFromCore() { } void Client::setDisconnectedFromCore() { + _connected = false; emit disconnected(); emit coreConnectionStateChanged(false); diff --git a/src/client/client.h b/src/client/client.h index a516e252..56083a96 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -120,7 +120,6 @@ public: static inline CoreAccount currentCoreAccount() { return coreConnection()->currentAccount(); } static bool isConnected(); - static bool isSynced(); static bool internalCore(); static void userInput(const BufferInfo &bufferInfo, const QString &message); @@ -230,6 +229,8 @@ private: QHash _networks; QHash _identities; + bool _connected; + QString _debugLogBuffer; QTextStream _debugLog; diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index f8fe6b8f..e7386efc 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -78,7 +78,7 @@ void ChatView::init(MessageFilter *filter) { connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(verticalScrollbarChanged(int))); // only connect if client is synched with a core - if(Client::isSynced()) + if(Client::isConnected()) connect(Client::ignoreListManager(), SIGNAL(ignoreListChanged()), this, SLOT(invalidateFilter())); } @@ -91,8 +91,8 @@ bool ChatView::event(QEvent *event) { case Qt::Key_PageUp: case Qt::Key_PageDown: if(!verticalScrollBar()->isVisible()) { - scene()->requestBacklog(); - return true; + scene()->requestBacklog(); + return true; } default: break;