From fd400d67f4af5181a3ffd8ed4e1c3b0fc5c2a3b2 Mon Sep 17 00:00:00 2001
From: Nobody <nop@nop.nop>
Date: Fri, 24 May 2024 10:16:22 +0300
Subject: [PATCH] Revert "Make ModemManagerQt a required dependency"
This reverts commit e74e44310ef0795588d2c5240d04cc92b5d6999f.
Why, oh why are you bloat-o-maniacs there...
---
CMakeLists.txt | 20 +++++++++++++++++++-
README.md | 6 +++++-
kcm/kcm.cpp | 2 ++
kded/CMakeLists.txt | 23 +++++++++++++++++------
kded/bluetoothmonitor.cpp | 5 ++++-
kded/bluetoothmonitor.h | 2 ++
kded/monitor.cpp | 6 ++++++
kded/monitor.h | 7 ++++++-
libs/CMakeLists.txt | 4 +++-
libs/declarative/CMakeLists.txt | 5 ++++-
libs/declarative/connectionicon.cpp | 20 ++++++++++++++++++++
libs/declarative/connectionicon.h | 8 +++++++-
libs/editor/CMakeLists.txt | 19 +++++++++++++------
libs/editor/uiutils.cpp | 4 ++++
libs/editor/uiutils.h | 4 ++++
libs/handler.cpp | 6 ++++++
libs/handler.h | 8 +++++++-
libs/models/creatableconnectionsmodel.cpp | 2 ++
libs/models/networkmodel.cpp | 14 +++++++++++---
libs/models/networkmodel.h | 4 ++++
libs/models/networkmodelitem.cpp | 4 ++++
tests/CMakeLists.txt | 10 ++++++----
22 files changed, 156 insertions(+), 27 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 46230bdb..d75a17b3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,9 +54,12 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED
WidgetsAddons
WindowSystem
KCMUtils
- ModemManagerQt
)
+find_package(KF5ModemManagerQt ${KF5_MIN_VERSION})
+set_package_properties(KF5ModemManagerQt PROPERTIES
+ TYPE OPTIONAL)
+
ecm_find_qmlmodule(org.kde.prison 1.0)
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG)
@@ -84,6 +87,19 @@ pkg_check_modules(NETWORKMANAGER IMPORTED_TARGET libnm>1.4.0 REQUIRED)
pkg_check_modules(MOBILEBROADBANDPROVIDERINFO mobile-broadband-provider-info)
pkg_get_variable(BROADBANDPROVIDER_DATABASE mobile-broadband-provider-info database)
+if (DISABLE_MODEMMANAGER_SUPPORT)
+ message(STATUS "Disabling ModemManager support")
+ set(WITH_MODEMMANAGER_SUPPORT 0)
+else()
+ if (KF5ModemManagerQt_FOUND)
+ message(STATUS "Enabling ModemManager support")
+ set(WITH_MODEMMANAGER_SUPPORT 1)
+ else()
+ message(STATUS "ModemManager or ModemManagerQt not found")
+ set(WITH_MODEMMANAGER_SUPPORT 0)
+ endif()
+endif()
+
add_definitions(
-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00
-DQT_DEPRECATED_WARNINGS_SINCE=0x060000
@@ -96,6 +112,8 @@ add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY)
+add_definitions(-DWITH_MODEMMANAGER_SUPPORT=${WITH_MODEMMANAGER_SUPPORT})
+
add_subdirectory(applet)
add_subdirectory(kded)
add_subdirectory(kcm)
diff --git a/README.md b/README.md
index feca419f..9865b083 100644
--- a/README.md
+++ b/README.md
@@ -6,11 +6,15 @@ Plasma applet written in QML for managing network connections
Dependencies:
-------------
* networkmanager-qt
- * modemmanager-qt
* NetworkManager 0.9.10 and newer
Optional dependencies:
---------------------
+ * modemmanager-qt
+ - requires ModemManager 1.0.0 and newer as runtime dependency
+ - Plasma-nm is compiled with ModemManager support by default when modemmanager-qt is found,
+ when you want to explicitly disable ModemManager support, use `-DDISABLE_MODEMMANAGER_SUPPORT=true` cmake parameter.
+
* openconnect
- if you want to build the OpenConnect VPN plugin
diff --git a/kcm/kcm.cpp b/kcm/kcm.cpp
index 617ec33c..d51036cf 100644
--- a/kcm/kcm.cpp
+++ b/kcm/kcm.cpp
@@ -292,6 +292,7 @@ void KCMNetworkmanagement::onRequestCreateConnection(int connectionType, const Q
}
} else if (type == NetworkManager::ConnectionSettings::Gsm) { // launch the mobile broadband wizard, both gsm/cdma
+#if WITH_MODEMMANAGER_SUPPORT
QPointer<MobileConnectionWizard> wizard = new MobileConnectionWizard(NetworkManager::ConnectionSettings::Unknown, this);
wizard->setAttribute(Qt::WA_DeleteOnClose);
connect(wizard.data(), &MobileConnectionWizard::accepted, [wizard, this]() {
@@ -325,6 +326,7 @@ void KCMNetworkmanagement::onRequestCreateConnection(int connectionType, const Q
});
wizard->setModal(true);
wizard->show();
+#endif
} else {
NetworkManager::ConnectionSettings::Ptr connectionSettings;
connectionSettings = NetworkManager::ConnectionSettings::Ptr(new NetworkManager::ConnectionSettings(type));
diff --git a/kded/CMakeLists.txt b/kded/CMakeLists.txt
index f7dd2176..e58a59d3 100644
--- a/kded/CMakeLists.txt
+++ b/kded/CMakeLists.txt
@@ -17,17 +17,25 @@ target_sources(kded_networkmanagement PRIVATE
passworddialog.h
secretagent.h
service.h
- modemmonitor.cpp
- modemmonitor.h
- pindialog.cpp
- pindialog.h
)
ki18n_wrap_ui(kded_networkmanagement
passworddialog.ui
- pinwidget.ui
)
+if (WITH_MODEMMANAGER_SUPPORT)
+ target_sources(kded_networkmanagement PRIVATE
+ modemmonitor.cpp
+ modemmonitor.h
+ pindialog.cpp
+ pindialog.h
+ )
+
+ ki18n_wrap_ui(kded_networkmanagement
+ pinwidget.ui
+ )
+endif()
+
ecm_qt_declare_logging_category(kded_networkmanagement HEADER plasma_nm_kded.h IDENTIFIER PLASMA_NM_KDED_LOG CATEGORY_NAME org.kde.plasma.nm.kded DESCRIPTION "Plasma NM (kded)" EXPORT PLASMANM)
@@ -45,9 +53,12 @@ target_link_libraries(kded_networkmanagement
KF5::Wallet
KF5::WindowSystem
KF5::KIOGui
- KF5::ModemManagerQt
)
+if (WITH_MODEMMANAGER_SUPPORT)
+ target_link_libraries(kded_networkmanagement KF5::ModemManagerQt)
+endif()
+
install(TARGETS kded_networkmanagement DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf${QT_MAJOR_VERSION}/kded)
install(FILES networkmanagement.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR})
diff --git a/kded/bluetoothmonitor.cpp b/kded/bluetoothmonitor.cpp
index 82b32f6b..1b60527b 100644
--- a/kded/bluetoothmonitor.cpp
+++ b/kded/bluetoothmonitor.cpp
@@ -85,7 +85,9 @@ void BluetoothMonitor::addBluetoothConnection(const QString &bdAddr, const QStri
btSetting->setInitialized(true);
NetworkManager::addConnection(connectionSettings.toMap());
- } else if (service == QLatin1String("dun")) {
+ }
+#if WITH_MODEMMANAGER_SUPPORT
+ else if (service == QLatin1String("dun")) {
QPointer<MobileConnectionWizard> mobileConnectionWizard = new MobileConnectionWizard(NetworkManager::ConnectionSettings::Bluetooth);
mobileConnectionWizard->setAttribute(Qt::WA_DeleteOnClose);
connect(mobileConnectionWizard.data(), &MobileConnectionWizard::accepted, [bdAddr, connectionName, mobileConnectionWizard]() {
@@ -121,4 +123,5 @@ void BluetoothMonitor::addBluetoothConnection(const QString &bdAddr, const QStri
mobileConnectionWizard->setModal(true);
mobileConnectionWizard->show();
}
+#endif
}
diff --git a/kded/bluetoothmonitor.h b/kded/bluetoothmonitor.h
index 64776e8c..93b4ba35 100644
--- a/kded/bluetoothmonitor.h
+++ b/kded/bluetoothmonitor.h
@@ -9,8 +9,10 @@
#ifndef PLASMA_NM_BLUETOOTH_MONITOR_H
#define PLASMA_NM_BLUETOOTH_MONITOR_H
+#if WITH_MODEMMANAGER_SUPPORT
#include "mobileconnectionwizard.h"
#include <ModemManagerQt/Manager>
+#endif
#include <QObject>
diff --git a/kded/monitor.cpp b/kded/monitor.cpp
index a5c06295..3120e625 100644
--- a/kded/monitor.cpp
+++ b/kded/monitor.cpp
@@ -12,7 +12,9 @@ Monitor::Monitor(QObject *parent)
: QObject(parent)
, m_bluetoothMonitor(new BluetoothMonitor(this))
{
+#if WITH_MODEMMANAGER_SUPPORT
m_modemMonitor = new ModemMonitor(this);
+#endif
QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.plasmanetworkmanagement"));
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/plasmanetworkmanagement"), this, QDBusConnection::ExportScriptableContents);
@@ -21,7 +23,9 @@ Monitor::Monitor(QObject *parent)
Monitor::~Monitor()
{
delete m_bluetoothMonitor;
+#if WITH_MODEMMANAGER_SUPPORT
delete m_modemMonitor;
+#endif
}
bool Monitor::bluetoothConnectionExists(const QString &bdAddr, const QString &service)
@@ -34,8 +38,10 @@ void Monitor::addBluetoothConnection(const QString &bdAddr, const QString &servi
m_bluetoothMonitor->addBluetoothConnection(bdAddr, service, connectionName);
}
+#if WITH_MODEMMANAGER_SUPPORT
void Monitor::unlockModem(const QString &modem)
{
qDebug() << "unlocking " << modem;
m_modemMonitor->unlockModem(modem);
}
+#endif
diff --git a/kded/monitor.h b/kded/monitor.h
index 1c9d3eb9..b853683c 100644
--- a/kded/monitor.h
+++ b/kded/monitor.h
@@ -11,7 +11,9 @@
#include <QObject>
#include "bluetoothmonitor.h"
+#if WITH_MODEMMANAGER_SUPPORT
#include "modemmonitor.h"
+#endif
class Q_DECL_EXPORT Monitor : public QObject
{
@@ -24,11 +26,14 @@ public:
public Q_SLOTS:
Q_SCRIPTABLE bool bluetoothConnectionExists(const QString &bdAddr, const QString &service);
Q_SCRIPTABLE void addBluetoothConnection(const QString &bdAddr, const QString &service, const QString &connectionName);
+#if WITH_MODEMMANAGER_SUPPORT
Q_SCRIPTABLE void unlockModem(const QString &modem);
-
+#endif
private:
BluetoothMonitor *const m_bluetoothMonitor;
+#if WITH_MODEMMANAGER_SUPPORT
ModemMonitor *m_modemMonitor = nullptr;
+#endif
};
#endif // PLASMA_NM_MONITOR_H
diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt
index 59d8cedc..bd4ac49b 100644
--- a/libs/CMakeLists.txt
+++ b/libs/CMakeLists.txt
@@ -44,7 +44,9 @@ PRIVATE
KF5::KIOGui
)
-target_link_libraries(plasmanm_internal PUBLIC KF5::ModemManagerQt)
+if (WITH_MODEMMANAGER_SUPPORT)
+ target_link_libraries(plasmanm_internal PUBLIC KF5::ModemManagerQt)
+endif()
install(TARGETS plasmanm_internal ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/libs/declarative/CMakeLists.txt b/libs/declarative/CMakeLists.txt
index 3909e6b7..70581a79 100644
--- a/libs/declarative/CMakeLists.txt
+++ b/libs/declarative/CMakeLists.txt
@@ -20,8 +20,11 @@ target_link_libraries(plasmanm_qmlplugins
plasmanm_editor
Qt::Quick
KF5::I18n
- KF5::ModemManagerQt
)
+if (WITH_MODEMMANAGER_SUPPORT)
+ target_link_libraries(plasmanm_qmlplugins KF5::ModemManagerQt)
+endif()
+
install(TARGETS plasmanm_qmlplugins DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/networkmanagement)
install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/networkmanagement)
diff --git a/libs/declarative/connectionicon.cpp b/libs/declarative/connectionicon.cpp
index 5f97fb5c..779982cd 100644
--- a/libs/declarative/connectionicon.cpp
+++ b/libs/declarative/connectionicon.cpp
@@ -17,12 +17,16 @@
#include <NetworkManagerQt/WirelessDevice>
#include <NetworkManagerQt/WirelessSetting>
+#if WITH_MODEMMANAGER_SUPPORT
#include <ModemManagerQt/Manager>
+#endif
ConnectionIcon::ConnectionIcon(QObject *parent)
: QObject(parent)
, m_wirelessNetwork(nullptr)
+#if WITH_MODEMMANAGER_SUPPORT
, m_modemNetwork(nullptr)
+#endif
{
connect(NetworkManager::notifier(), &NetworkManager::Notifier::primaryConnectionChanged, this, &ConnectionIcon::primaryConnectionChanged);
connect(NetworkManager::notifier(), &NetworkManager::Notifier::activatingConnectionChanged, this, &ConnectionIcon::activatingConnectionChanged);
@@ -173,6 +177,7 @@ void ConnectionIcon::deviceRemoved(const QString &device)
}
}
+#if WITH_MODEMMANAGER_SUPPORT
void ConnectionIcon::modemNetworkRemoved()
{
m_modemNetwork.clear();
@@ -188,6 +193,7 @@ void ConnectionIcon::modemSignalChanged(ModemManager::SignalQualityPair signalQu
setIconForModem();
}
}
+#endif
void ConnectionIcon::networkingEnabledChanged(bool enabled)
{
@@ -272,10 +278,12 @@ void ConnectionIcon::setStates()
void ConnectionIcon::setIcons()
{
m_signal = 0;
+#if WITH_MODEMMANAGER_SUPPORT
if (m_modemNetwork) {
disconnect(m_modemNetwork.data(), nullptr, this, nullptr);
m_modemNetwork.clear();
}
+#endif
if (m_wirelessNetwork) {
disconnect(m_wirelessNetwork.data(), nullptr, this, nullptr);
m_wirelessNetwork.clear();
@@ -348,12 +356,22 @@ void ConnectionIcon::setIcons()
setConnectionIcon(QStringLiteral("network-wired-activated"));
setConnectionTooltipIcon(QStringLiteral("network-wired-activated"));
} else if (type == NetworkManager::Device::Modem) {
+#if WITH_MODEMMANAGER_SUPPORT
setModemIcon(device);
+#else
+ setConnectionIcon("network-mobile-0");
+ setConnectionTooltipIcon("phone");
+#endif
} else if (type == NetworkManager::Device::Bluetooth) {
NetworkManager::BluetoothDevice::Ptr btDevice = device.objectCast<NetworkManager::BluetoothDevice>();
if (btDevice) {
if (btDevice->bluetoothCapabilities().testFlag(NetworkManager::BluetoothDevice::Dun)) {
+#if WITH_MODEMMANAGER_SUPPORT
setModemIcon(device);
+#else
+ setConnectionIcon("network-mobile-0");
+ setConnectionTooltipIcon("phone");
+#endif
} else {
setConnectionIcon(QStringLiteral("network-bluetooth-activated"));
setConnectionTooltipIcon(QStringLiteral("preferences-system-bluetooth"));
@@ -432,6 +450,7 @@ void ConnectionIcon::setDisconnectedIcon()
}
}
+#if WITH_MODEMMANAGER_SUPPORT
void ConnectionIcon::setModemIcon(const NetworkManager::Device::Ptr &device)
{
NetworkManager::ModemDevice::Ptr modemDevice = device.objectCast<NetworkManager::ModemDevice>();
@@ -526,6 +545,7 @@ void ConnectionIcon::setIconForModem()
setConnectionIcon(QString(result).arg(strength));
setConnectionTooltipIcon(QStringLiteral("phone"));
}
+#endif
void ConnectionIcon::setWirelessIcon(const NetworkManager::Device::Ptr &device, const QString &ssid)
{
diff --git a/libs/declarative/connectionicon.h b/libs/declarative/connectionicon.h
index 22eecefd..287c9a0b 100644
--- a/libs/declarative/connectionicon.h
+++ b/libs/declarative/connectionicon.h
@@ -7,11 +7,13 @@
#ifndef PLASMA_NM_CONNECTION_ICON_H
#define PLASMA_NM_CONNECTION_ICON_H
-#include <ModemManagerQt/Modem>
#include <NetworkManagerQt/ActiveConnection>
#include <NetworkManagerQt/Manager>
#include <NetworkManagerQt/VpnConnection>
#include <NetworkManagerQt/WirelessNetwork>
+#if WITH_MODEMMANAGER_SUPPORT
+#include <ModemManagerQt/Modem>
+#endif
class ConnectionIcon : public QObject
{
@@ -45,9 +47,11 @@ private Q_SLOTS:
void deviceRemoved(const QString &device);
void networkingEnabledChanged(bool enabled);
void primaryConnectionChanged(const QString &connection);
+#if WITH_MODEMMANAGER_SUPPORT
void modemNetworkRemoved();
void modemSignalChanged(ModemManager::SignalQualityPair signalQuality);
void setIconForModem();
+#endif
void statusChanged(NetworkManager::Status status);
void setWirelessIconForSignalStrength(int strength);
void vpnConnectionStateChanged(NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason);
@@ -81,8 +85,10 @@ private:
void setIcons();
void setStates();
void setWirelessIcon(const NetworkManager::Device::Ptr &device, const QString &ssid);
+#if WITH_MODEMMANAGER_SUPPORT
ModemManager::Modem::Ptr m_modemNetwork;
void setModemIcon(const NetworkManager::Device::Ptr &device);
+#endif
};
#endif // PLASMA_NM_CONNECTION_ICON_H
diff --git a/libs/editor/CMakeLists.txt b/libs/editor/CMakeLists.txt
index 1e2c3d68..fe983d63 100644
--- a/libs/editor/CMakeLists.txt
+++ b/libs/editor/CMakeLists.txt
@@ -87,14 +87,19 @@ set(plasmanm_editor_SRCS
widgets/settingwidget.h
widgets/ssidcombobox.cpp
widgets/ssidcombobox.h
- widgets/mobileconnectionwizard.cpp
- widgets/mobileconnectionwizard.h
wireguardkeyvalidator.cpp
wireguardkeyvalidator.h
- mobileproviders.cpp
- mobileproviders.h
)
+if (WITH_MODEMMANAGER_SUPPORT)
+ set(plasmanm_editor_SRCS
+ ${plasmanm_editor_SRCS}
+ widgets/mobileconnectionwizard.cpp
+ widgets/mobileconnectionwizard.h
+ mobileproviders.cpp
+ mobileproviders.h)
+endif()
+
ki18n_wrap_ui(plasmanm_editor_SRCS
settings/ui/802-1x.ui
settings/ui/bond.ui
@@ -143,7 +148,6 @@ PUBLIC
KF5::Completion
KF5::NetworkManagerQt
KF5::WidgetsAddons
- KF5::ModemManagerQt
Qt::Widgets
PRIVATE
KF5::I18n
@@ -156,6 +160,9 @@ PRIVATE
qca-qt${QT_MAJOR_VERSION}
)
-target_compile_definitions(plasmanm_editor PRIVATE BROADBANDPROVIDER_DATABASE=\"${BROADBANDPROVIDER_DATABASE}\")
+if (WITH_MODEMMANAGER_SUPPORT)
+ target_link_libraries(plasmanm_editor PUBLIC KF5::ModemManagerQt)
+ target_compile_definitions(plasmanm_editor PRIVATE BROADBANDPROVIDER_DATABASE=\"${BROADBANDPROVIDER_DATABASE}\")
+endif()
install(TARGETS plasmanm_editor ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/libs/editor/uiutils.cpp b/libs/editor/uiutils.cpp
index 95d5decd..305d692b 100644
--- a/libs/editor/uiutils.cpp
+++ b/libs/editor/uiutils.cpp
@@ -21,10 +21,12 @@
#include <NetworkManagerQt/Manager>
#include <NetworkManagerQt/Security8021xSetting>
+#if WITH_MODEMMANAGER_SUPPORT
#include <ModemManagerQt/Manager>
#include <ModemManagerQt/Modem3Gpp>
#include <ModemManagerQt/ModemCdma>
#include <ModemManagerQt/ModemDevice>
+#endif
// Qt
#include <QHostAddress>
@@ -458,6 +460,7 @@ QString UiUtils::wirelessFrequencyToString(uint frequency)
return i18nc("Wireless connection frequency", "%1 GHz", frequency / 1000.0);
}
+#if WITH_MODEMMANAGER_SUPPORT
QString UiUtils::convertAllowedModeToString(ModemManager::Modem::ModemModes modes)
{
if (modes.testFlag(MM_MODEM_MODE_4G)) {
@@ -561,6 +564,7 @@ QString UiUtils::convertLockReasonToString(MMModemLock reason)
return i18nc("possible SIM lock reason", "Lock reason unknown.");
}
}
+#endif
NetworkManager::ModemDevice::Capability UiUtils::modemSubType(NetworkManager::ModemDevice::Capabilities modemCaps)
{
diff --git a/libs/editor/uiutils.h b/libs/editor/uiutils.h
index 7949fb3c..d143c4ee 100644
--- a/libs/editor/uiutils.h
+++ b/libs/editor/uiutils.h
@@ -19,8 +19,10 @@
#include <NetworkManagerQt/WirelessDevice>
#include <NetworkManagerQt/WirelessSetting>
+#if WITH_MODEMMANAGER_SUPPORT
#include <ModemManager/ModemManager.h>
#include <ModemManagerQt/Modem>
+#endif
class Q_DECL_EXPORT UiUtils
{
@@ -134,9 +136,11 @@ public:
*/
static void setConnectionDefaultPermissions(NetworkManager::ConnectionSettings::Ptr &settings);
+#if WITH_MODEMMANAGER_SUPPORT
static QString convertAllowedModeToString(ModemManager::Modem::ModemModes mode);
static QString convertAccessTechnologyToString(ModemManager::Modem::AccessTechnologies tech);
static QString convertLockReasonToString(MMModemLock reason);
+#endif
static NetworkManager::ModemDevice::Capability modemSubType(NetworkManager::ModemDevice::Capabilities modemCaps);
static QString labelFromWirelessSecurity(NetworkManager::WirelessSecurityType type);
diff --git a/libs/handler.cpp b/libs/handler.cpp
index 8b1782dd..d8191c03 100644
--- a/libs/handler.cpp
+++ b/libs/handler.cpp
@@ -23,8 +23,10 @@
#include <libnm/nm-vpn-plugin-info.h>
+#if WITH_MODEMMANAGER_SUPPORT
#include <ModemManagerQt/Manager>
#include <ModemManagerQt/ModemDevice>
+#endif
#include <QDBusError>
#include <QDBusMetaType>
@@ -149,6 +151,7 @@ void Handler::activateConnection(const QString &connection, const QString &devic
}
}
+#if WITH_MODEMMANAGER_SUPPORT
if (con->settings()->connectionType() == NetworkManager::ConnectionSettings::Gsm) {
NetworkManager::ModemDevice::Ptr nmModemDevice = NetworkManager::findNetworkInterface(device).objectCast<NetworkManager::ModemDevice>();
if (nmModemDevice) {
@@ -172,6 +175,7 @@ void Handler::activateConnection(const QString &connection, const QString &devic
}
}
}
+#endif
QDBusPendingReply<QDBusObjectPath> reply = NetworkManager::activateConnection(connection, device, specificObject);
auto watcher = new QDBusPendingCallWatcher(reply, this);
@@ -951,12 +955,14 @@ void Handler::primaryConnectionTypeChanged(NetworkManager::ConnectionSettings::C
Q_EMIT hotspotSupportedChanged(m_hotspotSupported);
}
+#if WITH_MODEMMANAGER_SUPPORT
void Handler::unlockRequiredChanged(MMModemLock modemLock)
{
if (modemLock == MM_MODEM_LOCK_NONE) {
activateConnection(m_tmpConnectionPath, m_tmpDevicePath, m_tmpSpecificPath);
}
}
+#endif
void Handler::slotRequestWifiCode(QDBusPendingCallWatcher *watcher)
{
diff --git a/libs/handler.h b/libs/handler.h
index 1ae77e07..3b34ce3f 100644
--- a/libs/handler.h
+++ b/libs/handler.h
@@ -11,11 +11,13 @@
#include <QPointer>
#include <QTimer>
-#include <ModemManagerQt/GenericTypes>
#include <NetworkManagerQt/Connection>
#include <NetworkManagerQt/ConnectionSettings>
#include <NetworkManagerQt/Settings>
#include <NetworkManagerQt/Utils>
+#if WITH_MODEMMANAGER_SUPPORT
+#include <ModemManagerQt/GenericTypes>
+#endif
class Q_DECL_EXPORT Handler : public QObject
{
@@ -133,7 +135,9 @@ private Q_SLOTS:
void replyFinished(QDBusPendingCallWatcher *watcher);
void hotspotCreated(QDBusPendingCallWatcher *watcher);
void primaryConnectionTypeChanged(NetworkManager::ConnectionSettings::ConnectionType type);
+#if WITH_MODEMMANAGER_SUPPORT
void unlockRequiredChanged(MMModemLock modemLock);
+#endif
void slotRequestWifiCode(QDBusPendingCallWatcher *watcher);
Q_SIGNALS:
@@ -150,7 +154,9 @@ private:
bool m_hotspotSupported;
bool m_tmpWirelessEnabled;
bool m_tmpWwanEnabled;
+#if WITH_MODEMMANAGER_SUPPORT
QString m_tmpConnectionPath;
+#endif
QString m_tmpConnectionUuid;
QString m_tmpDevicePath;
QString m_tmpSpecificPath;
diff --git a/libs/models/creatableconnectionsmodel.cpp b/libs/models/creatableconnectionsmodel.cpp
index 8cdc6517..26e3f347 100644
--- a/libs/models/creatableconnectionsmodel.cpp
+++ b/libs/models/creatableconnectionsmodel.cpp
@@ -146,12 +146,14 @@ void CreatableConnectionsModel::populateModel()
NetworkManager::ConnectionSettings::Infiniband);
m_list << connectionItem;
+#if WITH_MODEMMANAGER_SUPPORT
connectionItem = new CreatableConnectionItem(i18n("Mobile Broadband"),
i18n("Hardware based connections"),
i18n("Some mobile broadband description"),
QStringLiteral("smartphone"),
NetworkManager::ConnectionSettings::Gsm);
m_list << connectionItem;
+#endif
connectionItem = new CreatableConnectionItem(i18n("Wired Ethernet"),
i18n("Hardware based connections"),
diff --git a/libs/models/networkmodel.cpp b/libs/models/networkmodel.cpp
index 59fff801..80b46c91 100644
--- a/libs/models/networkmodel.cpp
+++ b/libs/models/networkmodel.cpp
@@ -12,8 +12,9 @@
#include <QVector>
#include <algorithm>
+#if WITH_MODEMMANAGER_SUPPORT
#include <ModemManagerQt/Manager>
-
+#endif
#include <NetworkManagerQt/GenericDevice>
#include <NetworkManagerQt/Settings>
@@ -297,7 +298,9 @@ void NetworkModel::initializeSignals(const NetworkManager::Device::Ptr &device)
connect(wifiDev.data(), &NetworkManager::WirelessDevice::networkAppeared, this, &NetworkModel::wirelessNetworkAppeared, Qt::UniqueConnection);
connect(wifiDev.data(), &NetworkManager::WirelessDevice::networkDisappeared, this, &NetworkModel::wirelessNetworkDisappeared, Qt::UniqueConnection);
- } else if (device->type() == NetworkManager::Device::Modem) {
+ }
+#if WITH_MODEMMANAGER_SUPPORT
+ else if (device->type() == NetworkManager::Device::Modem) {
ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(device->udi());
if (modem) {
if (modem->hasInterface(ModemManager::ModemDevice::ModemInterface)) {
@@ -322,6 +325,7 @@ void NetworkModel::initializeSignals(const NetworkManager::Device::Ptr &device)
}
}
}
+#endif
}
void NetworkModel::initializeSignals(const NetworkManager::WirelessNetwork::Ptr &network)
@@ -409,6 +413,7 @@ void NetworkModel::addAvailableConnection(const QString &connection, const Netwo
item->setDevicePath(device->uni());
item->setDeviceState(device->state());
qCDebug(PLASMA_NM_LIBS_LOG).nospace() << "Item " << item->name() << ": device changed to " << item->devicePath();
+#if WITH_MODEMMANAGER_SUPPORT
if (device->type() == NetworkManager::Device::Modem) {
ModemManager::ModemDevice::Ptr modemDevice = ModemManager::findModemDevice(device->udi());
if (modemDevice) {
@@ -419,7 +424,7 @@ void NetworkModel::addAvailableConnection(const QString &connection, const Netwo
}
}
}
-
+#endif
if (item->type() == NetworkManager::ConnectionSettings::Wireless && item->mode() == NetworkManager::WirelessSetting::Infrastructure) {
// Find an accesspoint which could be removed, because it will be merged with a connection
for (NetworkModelItem *secondItem : m_list.returnItems(NetworkItemsList::Ssid, item->ssid())) {
@@ -933,6 +938,7 @@ void NetworkModel::deviceStateChanged(NetworkManager::Device::State state,
}
}
+#if WITH_MODEMMANAGER_SUPPORT
void NetworkModel::gsmNetworkAccessTechnologiesChanged(QFlags<MMModemAccessTechnology> accessTechnologies)
{
Q_UNUSED(accessTechnologies);
@@ -1030,6 +1036,8 @@ void NetworkModel::gsmNetworkSignalQualityChanged(const ModemManager::SignalQual
}
}
+#endif
+
void NetworkModel::ipConfigChanged()
{
NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(qobject_cast<NetworkManager::Device *>(sender())->uni());
diff --git a/libs/models/networkmodel.h b/libs/models/networkmodel.h
index c32b8d2d..131ea417 100644
--- a/libs/models/networkmodel.h
+++ b/libs/models/networkmodel.h
@@ -17,7 +17,9 @@
#include <NetworkManagerQt/VpnConnection>
#include <NetworkManagerQt/WirelessDevice>
+#if WITH_MODEMMANAGER_SUPPORT
#include <ModemManagerQt/Modem>
+#endif
class Q_DECL_EXPORT NetworkModel : public QAbstractListModel
{
@@ -95,9 +97,11 @@ private Q_SLOTS:
void deviceAdded(const QString &device);
void deviceRemoved(const QString &device);
void deviceStateChanged(NetworkManager::Device::State state, NetworkManager::Device::State oldState, NetworkManager::Device::StateChangeReason reason);
+#if WITH_MODEMMANAGER_SUPPORT
void gsmNetworkAccessTechnologiesChanged(QFlags<MMModemAccessTechnology> accessTechnologies);
void gsmNetworkCurrentModesChanged();
void gsmNetworkSignalQualityChanged(const ModemManager::SignalQualityPair &signalQuality);
+#endif
void ipConfigChanged();
void ipInterfaceChanged();
void statusChanged(NetworkManager::Status status);
diff --git a/libs/models/networkmodelitem.cpp b/libs/models/networkmodelitem.cpp
index 0de5c865..85ea7bf1 100644
--- a/libs/models/networkmodelitem.cpp
+++ b/libs/models/networkmodelitem.cpp
@@ -26,11 +26,13 @@
#include <KLocalizedString>
+#if WITH_MODEMMANAGER_SUPPORT
#include <ModemManagerQt/Manager>
#include <ModemManagerQt/Modem3Gpp>
#include <ModemManagerQt/Modem>
#include <ModemManagerQt/ModemCdma>
#include <ModemManagerQt/ModemDevice>
+#endif
#include <QStringBuilder>
@@ -660,6 +662,7 @@ void NetworkModelItem::updateDetails() const
m_details << i18n("MAC Address") << wirelessDevice->hardwareAddress();
}
} else if (m_type == NetworkManager::ConnectionSettings::Gsm || m_type == NetworkManager::ConnectionSettings::Cdma) {
+#if WITH_MODEMMANAGER_SUPPORT
NetworkManager::ModemDevice::Ptr modemDevice = device.objectCast<NetworkManager::ModemDevice>();
if (modemDevice) {
ModemManager::ModemDevice::Ptr modem = ModemManager::findModemDevice(modemDevice->udi());
@@ -682,6 +685,7 @@ void NetworkModelItem::updateDetails() const
}
}
}
+#endif
} else if (m_type == NetworkManager::ConnectionSettings::Vpn) {
m_details << i18n("VPN plugin") << m_vpnType;
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 6a880a96..00ca8efb 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -18,7 +18,9 @@ ecm_add_test(
LINK_LIBRARIES Qt::Test plasmanm_editor
)
-ecm_add_test(
- mobileproviderstest.cpp
- LINK_LIBRARIES Qt::Test plasmanm_editor
-)
+if (WITH_MODEMMANAGER_SUPPORT)
+ ecm_add_test(
+ mobileproviderstest.cpp
+ LINK_LIBRARIES Qt::Test plasmanm_editor
+ )
+endif()
--
2.44.0