X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fcoreconnection.cpp;h=c6f4c9f5a4814725ffffcb7ec68c768f663fd6c4;hp=0e4b4f94646c48bb8e9191cdbe3ef779f21bee0f;hb=e2188dc438be6f3eb0d9cdf47d28821aefe9835e;hpb=1cb02004ee5973b89368bd84f234d4652794690d diff --git a/src/client/coreconnection.cpp b/src/client/coreconnection.cpp index 0e4b4f94..c6f4c9f5 100644 --- a/src/client/coreconnection.cpp +++ b/src/client/coreconnection.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -36,14 +36,7 @@ CoreConnection::CoreConnection(QObject *parent) : QObject(parent), - _authHandler(0), - _state(Disconnected), - _wantReconnect(false), - _wasReconnect(false), - _progressMinimum(0), - _progressMaximum(-1), - _progressValue(-1), - _resetting(false) + _authHandler(nullptr) { qRegisterMetaType("CoreConnection::ConnectionState"); } @@ -140,7 +133,7 @@ void CoreConnection::reconnectTimeout() void CoreConnection::networkDetectionModeChanged(const QVariant &vmode) { CoreConnectionSettings s; - CoreConnectionSettings::NetworkDetectionMode mode = (CoreConnectionSettings::NetworkDetectionMode)vmode.toInt(); + auto mode = (CoreConnectionSettings::NetworkDetectionMode)vmode.toInt(); if (mode == CoreConnectionSettings::UsePingTimeout) Client::signalProxy()->setMaxHeartBeatCount(s.pingTimeoutInterval() / 30); else { @@ -184,6 +177,15 @@ void CoreConnection::onlineStateChanged(bool isOnline) } +QPointer CoreConnection::peer() const +{ + if (_peer) { + return _peer; + } + return _authHandler ? _authHandler->peer() : nullptr; +} + + bool CoreConnection::isEncrypted() const { return _peer && _peer->isSecure(); @@ -216,6 +218,8 @@ void CoreConnection::setState(ConnectionState state) if (state != _state) { _state = state; emit stateChanged(state); + if (state == Connected) + _wantReconnect = true; if (state == Disconnected) emit disconnected(); } @@ -275,17 +279,17 @@ void CoreConnection::resetConnection(bool wantReconnect) _wantReconnect = wantReconnect; if (_authHandler) { - disconnect(_authHandler, 0, this, 0); + disconnect(_authHandler, nullptr, this, nullptr); _authHandler->close(); _authHandler->deleteLater(); - _authHandler = 0; + _authHandler = nullptr; } if (_peer) { - disconnect(_peer, 0, this, 0); + disconnect(_peer, nullptr, this, nullptr); // peer belongs to the sigproxy and thus gets deleted by it _peer->close(); - _peer = 0; + _peer = nullptr; } _netsToSync.clear(); @@ -370,14 +374,13 @@ void CoreConnection::connectToCurrentAccount() qWarning() << "Cannot connect to internal core in client-only mode!"; return; } - emit startInternalCore(); - InternalPeer *peer = new InternalPeer(); + auto *peer = new InternalPeer(); _peer = peer; Client::instance()->signalProxy()->addPeer(peer); // sigproxy will take ownership + emit connectionMsg(tr("Initializing...")); emit connectToInternalCore(peer); setState(Connected); - return; } @@ -393,7 +396,7 @@ void CoreConnection::connectToCurrentAccount() connect(_authHandler, SIGNAL(errorPopup(QString)), SIGNAL(connectionErrorPopup(QString)), Qt::QueuedConnection); connect(_authHandler, SIGNAL(statusMessage(QString)), SIGNAL(connectionMsg(QString))); connect(_authHandler, SIGNAL(encrypted(bool)), SIGNAL(encrypted(bool))); - connect(_authHandler, SIGNAL(startCoreSetup(QVariantList)), SIGNAL(startCoreSetup(QVariantList))); + connect(_authHandler, SIGNAL(startCoreSetup(QVariantList, QVariantList)), SIGNAL(startCoreSetup(QVariantList, QVariantList))); connect(_authHandler, SIGNAL(coreSetupFailed(QString)), SIGNAL(coreSetupFailed(QString))); connect(_authHandler, SIGNAL(coreSetupSuccessful()), SIGNAL(coreSetupSuccess())); connect(_authHandler, SIGNAL(userAuthenticationRequired(CoreAccount*,bool*,QString)), SIGNAL(userAuthenticationRequired(CoreAccount*,bool*,QString))); @@ -443,9 +446,9 @@ void CoreConnection::onHandshakeComplete(RemotePeer *peer, const Protocol::Sessi { updateProgress(100, 100); - disconnect(_authHandler, 0, this, 0); + disconnect(_authHandler, nullptr, this, nullptr); _authHandler->deleteLater(); - _authHandler = 0; + _authHandler = nullptr; _peer = peer; connect(peer, SIGNAL(disconnected()), SLOT(coreSocketDisconnected())); @@ -461,9 +464,6 @@ void CoreConnection::onHandshakeComplete(RemotePeer *peer, const Protocol::Sessi void CoreConnection::internalSessionStateReceived(const Protocol::SessionState &sessionState) { updateProgress(100, 100); - - Client::setCoreFeatures(Quassel::features()); // mono connection... - setState(Synchronizing); syncToCore(sessionState); } @@ -496,7 +496,7 @@ void CoreConnection::syncToCore(const Protocol::SessionState &sessionState) NetworkId netid = networkid.value(); if (Client::network(netid)) continue; - Network *net = new Network(netid, Client::instance()); + auto *net = new Network(netid, Client::instance()); _netsToSync.insert(net); connect(net, SIGNAL(initDone()), SLOT(networkInitDone())); connect(net, SIGNAL(destroyed()), SLOT(networkInitDone())); @@ -511,7 +511,7 @@ void CoreConnection::networkInitDone() { QObject *net = sender(); Q_ASSERT(net); - disconnect(net, 0, this, 0); + disconnect(net, nullptr, this, nullptr); _netsToSync.remove(net); updateProgress(_numNetsToSync - _netsToSync.count(), _numNetsToSync); checkSyncState();