Hacking in a very rough enable/disable (untested) implementation

This commit is contained in:
Rob Emery 2024-10-06 15:32:21 +01:00 committed by Carl Schwan
parent 21b081ad14
commit bc48c5e9f8
No known key found for this signature in database
GPG key ID: 02325448204E452A
2 changed files with 25 additions and 11 deletions

View file

@ -32,7 +32,9 @@ BluetoothLinkProvider::BluetoothLinkProvider()
void BluetoothLinkProvider::onStart() void BluetoothLinkProvider::onStart()
{ {
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStart executed"; qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStart executed";
tryToInitialise(); if (enabled) {
tryToInitialise();
}
} }
void BluetoothLinkProvider::tryToInitialise() void BluetoothLinkProvider::tryToInitialise()
@ -57,22 +59,26 @@ void BluetoothLinkProvider::tryToInitialise()
void BluetoothLinkProvider::onStop() void BluetoothLinkProvider::onStop()
{ {
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStop executed"; if (enabled) {
if (!mBluetoothServer) { qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStop executed";
return; if (!mBluetoothServer) {
return;
}
connectTimer->stop();
mKdeconnectService.unregisterService();
mBluetoothServer->close();
mBluetoothServer->deleteLater();
} }
connectTimer->stop();
mKdeconnectService.unregisterService();
mBluetoothServer->close();
mBluetoothServer->deleteLater();
} }
void BluetoothLinkProvider::onNetworkChange() void BluetoothLinkProvider::onNetworkChange()
{ {
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onNetworkChange executed"; qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onNetworkChange executed";
tryToInitialise(); if (enabled) {
tryToInitialise();
}
} }
void BluetoothLinkProvider::connectError() void BluetoothLinkProvider::connectError()

View file

@ -44,10 +44,17 @@ public:
void enable() override void enable() override
{ {
enabled = true;
tryToInitialise();
} }
void disable() override void disable() override
{ {
enabled = false;
this->onStop();
mBluetoothServer = nullptr;
mServiceDiscoveryAgent = nullptr;
} }
public Q_SLOTS: public Q_SLOTS:
@ -77,6 +84,7 @@ private:
QBluetoothServiceInfo mKdeconnectService; QBluetoothServiceInfo mKdeconnectService;
QBluetoothServiceDiscoveryAgent *mServiceDiscoveryAgent; QBluetoothServiceDiscoveryAgent *mServiceDiscoveryAgent;
QTimer *connectTimer; QTimer *connectTimer;
bool enabled;
QMap<QString, DeviceLink *> mLinks; QMap<QString, DeviceLink *> mLinks;