X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fclient%2Fcoreconnection.cpp;h=4127152c8fb6967b67f87f5426fd9fb684e1c063;hb=dc11e24b95e5b5e3595cc0e98eb2a572006912c7;hp=735fab46d4baf7a5c4574aa50c7cc492eeb6dd0e;hpb=bd2fb9596ddd44d486a3ff4914bcac045210c498;p=quassel.git diff --git a/src/client/coreconnection.cpp b/src/client/coreconnection.cpp index 735fab46..4127152c 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 * @@ -43,8 +43,7 @@ CoreConnection::CoreConnection(QObject *parent) _progressMinimum(0), _progressMaximum(-1), _progressValue(-1), - _resetting(false), - _qNetworkConfigurationManager(0) + _resetting(false) { qRegisterMetaType("CoreConnection::ConnectionState"); } @@ -58,10 +57,6 @@ void CoreConnection::init() _reconnectTimer.setSingleShot(true); connect(&_reconnectTimer, SIGNAL(timeout()), SLOT(reconnectTimeout())); -#ifdef HAVE_KDE4 - connect(Solid::Networking::notifier(), SIGNAL(statusChanged(Solid::Networking::Status)), - SLOT(solidNetworkStatusChanged(Solid::Networking::Status))); -#endif _qNetworkConfigurationManager = new QNetworkConfigurationManager(this); connect(_qNetworkConfigurationManager, SIGNAL(onlineStateChanged(bool)), SLOT(onlineStateChanged(bool))); @@ -130,22 +125,12 @@ void CoreConnection::reconnectTimeout() if (!_peer) { CoreConnectionSettings s; if (_wantReconnect && s.autoReconnect()) { -#ifdef HAVE_KDE4 - // If using Solid, we don't want to reconnect if we're offline - if (s.networkDetectionMode() == CoreConnectionSettings::UseSolid) { - if (Solid::Networking::status() != Solid::Networking::Connected - && Solid::Networking::status() != Solid::Networking::Unknown) { - return; - } - } -#endif /* HAVE_KDE4 */ - // If using QNetworkConfigurationManager, ditto + // If using QNetworkConfigurationManager, we don't want to reconnect if we're offline if (s.networkDetectionMode() == CoreConnectionSettings::UseQNetworkConfigurationManager) { if (!_qNetworkConfigurationManager->isOnline()) { return; } } - reconnectToCore(); } } @@ -178,36 +163,6 @@ void CoreConnection::reconnectIntervalChanged(const QVariant &interval) } -#ifdef HAVE_KDE4 - -void CoreConnection::solidNetworkStatusChanged(Solid::Networking::Status status) -{ - CoreConnectionSettings s; - if (s.networkDetectionMode() != CoreConnectionSettings::UseSolid) - return; - - switch (status) { - case Solid::Networking::Unknown: - case Solid::Networking::Connected: - //qDebug() << "Solid: Network status changed to connected or unknown"; - if (state() == Disconnected) { - if (_wantReconnect && s.autoReconnect()) { - reconnectToCore(); - } - } - break; - case Solid::Networking::Disconnecting: - case Solid::Networking::Unconnected: - if (state() != Disconnected && !isLocalConnection()) - disconnectFromCore(tr("Network is down"), true); - break; - default: - break; - } -} - -#endif - void CoreConnection::onlineStateChanged(bool isOnline) { CoreConnectionSettings s; @@ -228,6 +183,16 @@ 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(); @@ -260,6 +225,8 @@ void CoreConnection::setState(ConnectionState state) if (state != _state) { _state = state; emit stateChanged(state); + if (state == Connected) + _wantReconnect = true; if (state == Disconnected) emit disconnected(); } @@ -414,14 +381,13 @@ void CoreConnection::connectToCurrentAccount() qWarning() << "Cannot connect to internal core in client-only mode!"; return; } - emit startInternalCore(); InternalPeer *peer = new InternalPeer(); _peer = peer; Client::instance()->signalProxy()->addPeer(peer); // sigproxy will take ownership + emit connectionMsg(tr("Initializing...")); emit connectToInternalCore(peer); setState(Connected); - return; } @@ -437,7 +403,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))); @@ -505,9 +471,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); }