From 97841c86340fb12922d2b8c4b31028289cc19df4 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 7 Oct 2024 19:45:27 +0100 Subject: [PATCH] Rough enable/disable for lanlink --- core/backends/bluetooth/bluetoothlinkprovider.cpp | 15 +++++++++++++++ core/backends/bluetooth/bluetoothlinkprovider.h | 15 ++------------- core/backends/lan/lanlinkprovider.cpp | 11 +++++++++++ core/backends/lan/lanlinkprovider.h | 10 ++++------ 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/core/backends/bluetooth/bluetoothlinkprovider.cpp b/core/backends/bluetooth/bluetoothlinkprovider.cpp index 3248e1c68..6e061f18a 100644 --- a/core/backends/bluetooth/bluetoothlinkprovider.cpp +++ b/core/backends/bluetooth/bluetoothlinkprovider.cpp @@ -73,6 +73,21 @@ void BluetoothLinkProvider::onStop() } } +void BluetoothLinkProvider::enable() +{ + enabled = true; + tryToInitialise(); +} + +void BluetoothLinkProvider::disable() +{ + enabled = false; + this->onStop(); + + mBluetoothServer = nullptr; + mServiceDiscoveryAgent = nullptr; +} + void BluetoothLinkProvider::onNetworkChange() { qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onNetworkChange executed"; diff --git a/core/backends/bluetooth/bluetoothlinkprovider.h b/core/backends/bluetooth/bluetoothlinkprovider.h index 419dcdb55..7245e4f66 100644 --- a/core/backends/bluetooth/bluetoothlinkprovider.h +++ b/core/backends/bluetooth/bluetoothlinkprovider.h @@ -42,20 +42,9 @@ public: return 10; } - void enable() override - { - enabled = true; - tryToInitialise(); - } + void enable() override; - void disable() override - { - enabled = false; - this->onStop(); - - mBluetoothServer = nullptr; - mServiceDiscoveryAgent = nullptr; - } + void disable() override; public Q_SLOTS: virtual void onNetworkChange() override; diff --git a/core/backends/lan/lanlinkprovider.cpp b/core/backends/lan/lanlinkprovider.cpp index 4b3f4e229..ecaad0286 100644 --- a/core/backends/lan/lanlinkprovider.cpp +++ b/core/backends/lan/lanlinkprovider.cpp @@ -84,6 +84,17 @@ LanLinkProvider::~LanLinkProvider() { } +void LanLinkProvider::enable() +{ + disabled = false; + this->onStart(); +} +void LanLinkProvider::disable() +{ + this->onStop(); + disabled = true; +} + void LanLinkProvider::onStart() { const QHostAddress bindAddress = m_testMode ? QHostAddress::LocalHost : QHostAddress::Any; diff --git a/core/backends/lan/lanlinkprovider.h b/core/backends/lan/lanlinkprovider.h index 0ceeed51d..4184d6569 100644 --- a/core/backends/lan/lanlinkprovider.h +++ b/core/backends/lan/lanlinkprovider.h @@ -43,12 +43,8 @@ public: return 20; } - void enable() override - { - } - void disable() override - { - } + void enable() override; + void disable() override; void sendUdpIdentityPacket(const QList &addresses); @@ -99,6 +95,8 @@ private: const bool m_testMode; QTimer m_combineNetworkChangeTimer; + bool disabled; + #ifdef KDECONNECT_MDNS MdnsDiscovery m_mdnsDiscovery; #endif