git » plasma-nm.git » main » tree

[main] / 0001-Revert-Make-ModemManagerQt-a-required-dependency.patch

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
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