X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fcoreconnection.cpp;h=460b3b70ddc81ae6413cba9bd2487abe8c8aa5b0;hp=d20e434d4ae96f0a693309c8d0e4f928798d9010;hb=86bd6b1ffb870e65af6d830a2ea16471c348ed5a;hpb=f9f7524c41eb5668f3172cfddaa4d50badcd7fff diff --git a/src/client/coreconnection.cpp b/src/client/coreconnection.cpp index d20e434d..460b3b70 100644 --- a/src/client/coreconnection.cpp +++ b/src/client/coreconnection.cpp @@ -45,6 +45,12 @@ CoreConnection::CoreConnection(CoreAccountModel *model, QObject *parent) _progressValue(-1) { qRegisterMetaType("CoreConnection::ConnectionState"); +} + +void CoreConnection::init() { + Client::signalProxy()->setHeartBeatInterval(30); + connect(Client::signalProxy(), SIGNAL(disconnected()), SLOT(coreSocketDisconnected())); + connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), SIGNAL(lagUpdated(int))); _reconnectTimer.setSingleShot(true); connect(&_reconnectTimer, SIGNAL(timeout()), SLOT(reconnectTimeout())); @@ -53,11 +59,6 @@ CoreConnection::CoreConnection(CoreAccountModel *model, QObject *parent) connect(Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)), SLOT(solidNetworkStatusChanged(Solid::Networking::Status))); #endif -} - -void CoreConnection::init() { - Client::signalProxy()->setHeartBeatInterval(30); - connect(Client::signalProxy(), SIGNAL(disconnected()), SLOT(coreSocketDisconnected())); CoreConnectionSettings s; s.initAndNotify("PingTimeoutInterval", this, SLOT(pingTimeoutIntervalChanged(QVariant)), 60); @@ -102,35 +103,6 @@ void CoreConnection::updateProgress(int value, int max) { setProgressValue(value); } -void CoreConnection::resetConnection(bool wantReconnect) { - _wantReconnect = wantReconnect; - - if(_socket) { - disconnect(_socket, 0, this, 0); - _socket->deleteLater(); - _socket = 0; - } - _blockSize = 0; - - _coreMsgBuffer.clear(); - - _netsToSync.clear(); - _numNetsToSync = 0; - - setProgressMaximum(-1); // disable - setState(Disconnected); - - emit connectionMsg(tr("Disconnected from core.")); - emit encrypted(false); - - // initiate if a reconnect if appropriate - CoreConnectionSettings s; - if(wantReconnect && s.autoReconnect()) { - _reconnectTimer.start(); - //reconnectToCore(); - } -} - void CoreConnection::reconnectTimeout() { if(!_socket) { CoreConnectionSettings s; @@ -283,7 +255,6 @@ void CoreConnection::coreSocketError(QAbstractSocket::SocketError) { } void CoreConnection::coreSocketDisconnected() { - emit disconnected(); qDebug() << Q_FUNC_INFO; resetConnection(true); // FIXME handle disconnects gracefully @@ -349,6 +320,35 @@ void CoreConnection::disconnectFromCore(const QString &errorString, bool wantRec resetConnection(wantReconnect); } +void CoreConnection::resetConnection(bool wantReconnect) { + _wantReconnect = wantReconnect; + + if(_socket) { + disconnect(_socket, 0, this, 0); + _socket->deleteLater(); + _socket = 0; + } + _blockSize = 0; + + _coreMsgBuffer.clear(); + + _netsToSync.clear(); + _numNetsToSync = 0; + + setProgressMaximum(-1); // disable + setState(Disconnected); + emit lagUpdated(-1); + + emit connectionMsg(tr("Disconnected from core.")); + emit encrypted(false); + + // initiate if a reconnect if appropriate + CoreConnectionSettings s; + if(wantReconnect && s.autoReconnect()) { + _reconnectTimer.start(); + } +} + void CoreConnection::reconnectToCore() { if(currentAccount().isValid()) connectToCore(currentAccount().accountId()); @@ -670,8 +670,9 @@ void CoreConnection::syncToCore(const QVariantMap &sessionState) { checkSyncState(); } +// this is also called for destroyed networks! void CoreConnection::networkInitDone() { - Network *net = qobject_cast(sender()); + QObject *net = sender(); Q_ASSERT(net); disconnect(net, 0, this, 0); _netsToSync.remove(net); @@ -680,7 +681,7 @@ void CoreConnection::networkInitDone() { } void CoreConnection::checkSyncState() { - if(_netsToSync.isEmpty()) { + if(_netsToSync.isEmpty() && state() >= Synchronizing) { setState(Synchronized); setProgressText(tr("Synchronized to %1").arg(currentAccount().accountName())); setProgressMaximum(-1);