X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Fcoreconnection.cpp;h=9f876f913d6695572590f26483daa3f20f170c11;hp=4928a8bfbd6e2b4da95455ed9a44b4652ea0338e;hb=7af835c93948efa6a2160f7516b9f3296590a22f;hpb=447501045b6fe14fdeff95823e2ea85416da7a77 diff --git a/src/client/coreconnection.cpp b/src/client/coreconnection.cpp index 4928a8bf..9f876f91 100644 --- a/src/client/coreconnection.cpp +++ b/src/client/coreconnection.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2014 by the Quassel Project * + * Copyright (C) 2005-2015 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -57,10 +57,8 @@ void CoreConnection::init() _reconnectTimer.setSingleShot(true); connect(&_reconnectTimer, SIGNAL(timeout()), SLOT(reconnectTimeout())); -#ifdef HAVE_KDE - 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))); CoreConnectionSettings s; s.initAndNotify("PingTimeoutInterval", this, SLOT(pingTimeoutIntervalChanged(QVariant)), 60); @@ -127,16 +125,12 @@ void CoreConnection::reconnectTimeout() if (!_peer) { CoreConnectionSettings s; if (_wantReconnect && s.autoReconnect()) { -#ifdef HAVE_KDE - // 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) { + // If using QNetworkConfigurationManager, we don't want to reconnect if we're offline + if (s.networkDetectionMode() == CoreConnectionSettings::UseQNetworkConfigurationManager) { + if (!_qNetworkConfigurationManager->isOnline()) { return; - } + } } -#endif /* HAVE_KDE */ - reconnectToCore(); } } @@ -169,35 +163,26 @@ void CoreConnection::reconnectIntervalChanged(const QVariant &interval) } -#ifdef HAVE_KDE - -void CoreConnection::solidNetworkStatusChanged(Solid::Networking::Status status) +void CoreConnection::onlineStateChanged(bool isOnline) { CoreConnectionSettings s; - if (s.networkDetectionMode() != CoreConnectionSettings::UseSolid) + if (s.networkDetectionMode() != CoreConnectionSettings::UseQNetworkConfigurationManager) return; - switch (status) { - case Solid::Networking::Unknown: - case Solid::Networking::Connected: - //qDebug() << "Solid: Network status changed to connected or unknown"; + if(isOnline) { + // qDebug() << "QNetworkConfigurationManager reports Online"; if (state() == Disconnected) { if (_wantReconnect && s.autoReconnect()) { reconnectToCore(); } } - break; - case Solid::Networking::Disconnecting: - case Solid::Networking::Unconnected: + } else { + // qDebug() << "QNetworkConfigurationManager reports Offline"; if (state() != Disconnected && !isLocalConnection()) disconnectFromCore(tr("Network is down"), true); - break; - default: - break; } } -#endif bool CoreConnection::isEncrypted() const { @@ -231,6 +216,8 @@ void CoreConnection::setState(ConnectionState state) if (state != _state) { _state = state; emit stateChanged(state); + if (state == Connected) + _wantReconnect = true; if (state == Disconnected) emit disconnected(); }