Remove support for network detection via Solid
authorManuel Nickschas <sputnick@quassel-irc.org>
Fri, 6 Feb 2015 21:22:21 +0000 (22:22 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Fri, 6 Feb 2015 21:22:21 +0000 (22:22 +0100)
Now that we rely on Qt 4.8 and up, we can use QNCM on all platforms.
Solid::Networking didn't do anything else, and is deprecated in
KDE Frameworks in favor of QNCM anyway.

Also improved the core connection settings dialog a bit.

src/client/CMakeLists.txt
src/client/clientsettings.cpp
src/client/clientsettings.h
src/client/coreconnection.cpp
src/client/coreconnection.h
src/qtui/settingspages/coreconnectionsettingspage.cpp
src/qtui/settingspages/coreconnectionsettingspage.ui

index 4f0106c..4eef7d5 100644 (file)
@@ -38,11 +38,6 @@ set(SOURCES
     clientcoreinfo.h
 )
 
-if (KDE4_FOUND)
-    include_directories(${KDE4_INCLUDES})
-    add_definitions(-DHAVE_KDE ${KDE4_DEFINITIONS})
-endif()
-
 if (USE_QT5)
     list(APPEND qt_modules Widgets)
 endif()
@@ -53,7 +48,3 @@ add_library(mod_client STATIC ${SOURCES})
 qt_use_modules(mod_client Network Core Gui ${qt_modules})
 
 target_link_libraries(mod_client mod_common)
-
-if (KDE4_FOUND)
-    target_link_libraries(mod_client ${KDE4_SOLID_LIBS})
-endif()
index 1023efb..dc8e5c1 100644 (file)
@@ -249,12 +249,10 @@ void CoreConnectionSettings::setNetworkDetectionMode(NetworkDetectionMode mode)
 
 CoreConnectionSettings::NetworkDetectionMode CoreConnectionSettings::networkDetectionMode()
 {
-#ifdef HAVE_KDE4
-    NetworkDetectionMode def = UseSolid;
-#else
-    NetworkDetectionMode def = UseQNetworkConfigurationManager;
-#endif
-    return (NetworkDetectionMode)localValue("NetworkDetectionMode", def).toInt();
+    auto mode = localValue("NetworkDetectionMode", UseQNetworkConfigurationManager).toInt();
+    if (mode == 0)
+        mode = UseQNetworkConfigurationManager; // UseSolid is gone, map that to the new default
+    return static_cast<NetworkDetectionMode>(mode);
 }
 
 
index ed02efd..dd413e0 100644 (file)
@@ -124,8 +124,7 @@ class CoreConnectionSettings : public ClientSettings
 {
 public:
     enum NetworkDetectionMode {
-        UseSolid,
-        UseQNetworkConfigurationManager,
+        UseQNetworkConfigurationManager = 1, // UseSolid is gone
         UsePingTimeout,
         NoActiveDetection
     };
index 735fab4..0e4b4f9 100644 (file)
@@ -43,8 +43,7 @@ CoreConnection::CoreConnection(QObject *parent)
     _progressMinimum(0),
     _progressMaximum(-1),
     _progressValue(-1),
-    _resetting(false),
-    _qNetworkConfigurationManager(0)
+    _resetting(false)
 {
     qRegisterMetaType<ConnectionState>("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,7 @@ void CoreConnection::onlineStateChanged(bool isOnline)
     }
 }
 
+
 bool CoreConnection::isEncrypted() const
 {
     return _peer && _peer->isSecure();
index 3c21b79..0019a53 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef CORECONNECTION_H_
-#define CORECONNECTION_H_
+#pragma once
 
-#include "QPointer"
-#include "QTimer"
+#include <QNetworkConfigurationManager>
+#include <QPointer>
+#include <QTimer>
 
 #ifdef HAVE_SSL
 #  include <QSslSocket>
 #  include <QTcpSocket>
 #endif
 
-#ifdef HAVE_KDE4
-#  include <Solid/Networking>
-#endif
-
-#include <QNetworkConfigurationManager>
-
 #include "coreaccount.h"
 #include "remotepeer.h"
 #include "types.h"
@@ -150,9 +144,6 @@ private slots:
     void reconnectIntervalChanged(const QVariant &interval);
     void reconnectTimeout();
 
-#ifdef HAVE_KDE4
-    void solidNetworkStatusChanged(Solid::Networking::Status status);
-#endif
     void onlineStateChanged(bool isOnline);
 
 private:
@@ -191,5 +182,3 @@ inline QString CoreConnection::progressText() const { return _progressText; }
 inline CoreConnection::ConnectionState CoreConnection::state() const { return _state; }
 inline bool CoreConnection::isConnected() const { return state() >= Connected; }
 inline CoreAccount CoreConnection::currentAccount() const { return _account; }
-
-#endif
index aeb732e..d73c010 100644 (file)
@@ -24,13 +24,9 @@ CoreConnectionSettingsPage::CoreConnectionSettingsPage(QWidget *parent)
     : SettingsPage(tr("Remote Cores"), tr("Connection"), parent)
 {
     ui.setupUi(this);
-#ifndef HAVE_KDE4
-    ui.useSolid->hide();
-#endif
 
     initAutoWidgets();
 
-    connect(ui.useSolid, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
     connect(ui.useQNetworkConfigurationManager, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
     connect(ui.usePingTimeout, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
     connect(ui.useNoTimeout, SIGNAL(toggled(bool)), SLOT(widgetHasChanged()));
@@ -50,11 +46,7 @@ void CoreConnectionSettingsPage::widgetHasChanged()
 
 void CoreConnectionSettingsPage::defaults()
 {
-#ifdef HAVE_KDE4
-    setRadioButtons(CoreConnectionSettings::UseSolid);
-#else
     setRadioButtons(CoreConnectionSettings::UseQNetworkConfigurationManager);
-#endif
 
     SettingsPage::defaults();
 }
@@ -81,11 +73,6 @@ void CoreConnectionSettingsPage::save()
 void CoreConnectionSettingsPage::setRadioButtons(CoreConnectionSettings::NetworkDetectionMode mode)
 {
     switch (mode) {
-#ifdef HAVE_KDE4
-    case CoreConnectionSettings::UseSolid:
-        ui.useSolid->setChecked(true);
-        break;
-#endif
     case CoreConnectionSettings::UseQNetworkConfigurationManager:
         ui.useQNetworkConfigurationManager->setChecked(true);
         break;
@@ -100,10 +87,6 @@ void CoreConnectionSettingsPage::setRadioButtons(CoreConnectionSettings::Network
 
 CoreConnectionSettings::NetworkDetectionMode CoreConnectionSettingsPage::modeFromRadioButtons() const
 {
-#ifdef HAVE_KDE4
-    if (ui.useSolid->isChecked())
-        return CoreConnectionSettings::UseSolid;
-#endif
     if (ui.useQNetworkConfigurationManager->isChecked())
         return CoreConnectionSettings::UseQNetworkConfigurationManager;
     if (ui.usePingTimeout->isChecked())
index d641bfa..1589184 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>446</width>
+    <width>476</width>
     <height>465</height>
    </rect>
   </property>
       <string>Network Status Detection</string>
      </property>
      <layout class="QVBoxLayout" name="verticalLayout">
-      <item>
-       <widget class="QRadioButton" name="useSolid">
-        <property name="toolTip">
-         <string>Rely on KDE's hardware layer to detect if we're online. Recommended for most KDE users</string>
-        </property>
-        <property name="text">
-         <string>Use KDE's network status detection (via Solid)</string>
-        </property>
-        <property name="checked">
-         <bool>false</bool>
-        </property>
-       </widget>
-      </item>
       <item>
        <widget class="QRadioButton" name="useQNetworkConfigurationManager">
         <property name="toolTip">
-         <string>Rely on Qt's network configuration manager to detect if we're online.</string>
+         <string>Rely on Qt's network configuration manager to detect if we're online</string>
         </property>
         <property name="text">
-         <string>Use Qt's network status detection (via QNetworkConfigurationManager)</string>
+         <string>Automatic</string>
         </property>
         <property name="checked">
          <bool>false</bool>
      <item>
       <widget class="QSpinBox" name="reconnectInterval">
        <property name="toolTip">
-        <string>Actively ping the remote core and disconnect if we didn't get a reply after a certain time</string>
+        <string>Interval between consecutive connection attempts</string>
        </property>
        <property name="suffix">
         <string> seconds</string>
    </item>
   </layout>
  </widget>
+ <tabstops>
+  <tabstop>useQNetworkConfigurationManager</tabstop>
+  <tabstop>usePingTimeout</tabstop>
+  <tabstop>pingTimeout</tabstop>
+  <tabstop>useNoTimeout</tabstop>
+  <tabstop>autoReconnect</tabstop>
+  <tabstop>reconnectInterval</tabstop>
+ </tabstops>
  <resources/>
  <connections>
   <connection>