Make bluetooth work if enabled after kdeconnectd is started
Previously, if kdeconnectd was started with bluetooth disabled/unplugged it would continue to not work until kdeconnectd is restarted.
This commit is contained in:
parent
5fa83ca15f
commit
251ea971c5
3 changed files with 18 additions and 11 deletions
|
@ -30,6 +30,12 @@ BluetoothLinkProvider::BluetoothLinkProvider()
|
|||
}
|
||||
|
||||
void BluetoothLinkProvider::onStart()
|
||||
{
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStart executed";
|
||||
tryToInitialise();
|
||||
}
|
||||
|
||||
void BluetoothLinkProvider::tryToInitialise()
|
||||
{
|
||||
QBluetoothLocalDevice localDevice;
|
||||
if (!localDevice.isValid()) {
|
||||
|
@ -37,18 +43,16 @@ void BluetoothLinkProvider::onStart()
|
|||
return;
|
||||
}
|
||||
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStart executed";
|
||||
if (!mBluetoothServer) {
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onNetworkChange re-setting up mBluetoothServer";
|
||||
|
||||
mBluetoothServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
|
||||
mBluetoothServer->setSecurityFlags(QBluetooth::Security::Encryption | QBluetooth::Security::Secure);
|
||||
connect(mBluetoothServer, &QBluetoothServer::newConnection, this, &BluetoothLinkProvider::serverNewConnection);
|
||||
mBluetoothServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
|
||||
mBluetoothServer->setSecurityFlags(QBluetooth::Security::Encryption | QBluetooth::Security::Secure);
|
||||
connect(mBluetoothServer, &QBluetoothServer::newConnection, this, &BluetoothLinkProvider::serverNewConnection);
|
||||
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::About to start server listen";
|
||||
mKdeconnectService = mBluetoothServer->listen(mServiceUuid, QStringLiteral("KDE Connect"));
|
||||
|
||||
// Disabled for the moment as once the server is listening, the client will not be able to connect anyway
|
||||
// mServiceDiscoveryAgent->start();
|
||||
// connectTimer->start();
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onNetworkChange About to start server listen";
|
||||
mKdeconnectService = mBluetoothServer->listen(mServiceUuid, QStringLiteral("KDE Connect"));
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothLinkProvider::onStop()
|
||||
|
@ -65,9 +69,10 @@ void BluetoothLinkProvider::onStop()
|
|||
mBluetoothServer->deleteLater();
|
||||
}
|
||||
|
||||
// I'm in a new network, let's be polite and introduce myself
|
||||
void BluetoothLinkProvider::onNetworkChange()
|
||||
{
|
||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onNetworkChange executed";
|
||||
tryToInitialise();
|
||||
}
|
||||
|
||||
void BluetoothLinkProvider::connectError()
|
||||
|
|
|
@ -62,6 +62,7 @@ private Q_SLOTS:
|
|||
private:
|
||||
void addLink(BluetoothDeviceLink *deviceLink, const QString &deviceId);
|
||||
QList<QBluetoothAddress> getPairedDevices();
|
||||
void tryToInitialise();
|
||||
|
||||
QBluetoothUuid mServiceUuid;
|
||||
QPointer<QBluetoothServer> mBluetoothServer;
|
||||
|
|
|
@ -127,6 +127,7 @@ void Daemon::forceOnNetworkChange()
|
|||
{
|
||||
qCDebug(KDECONNECT_CORE) << "Sending onNetworkChange to" << d->m_linkProviders.size() << "LinkProviders";
|
||||
for (LinkProvider *a : std::as_const(d->m_linkProviders)) {
|
||||
qCDebug(KDECONNECT_CORE) << "Sending onNetworkChange to: " << a->name();
|
||||
a->onNetworkChange();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue