Injecting disabled status from the very start
This commit is contained in:
parent
9800664360
commit
fd07c7bea6
5 changed files with 23 additions and 16 deletions
|
@ -13,11 +13,12 @@
|
||||||
|
|
||||||
#include <QBluetoothServiceInfo>
|
#include <QBluetoothServiceInfo>
|
||||||
|
|
||||||
BluetoothLinkProvider::BluetoothLinkProvider()
|
BluetoothLinkProvider::BluetoothLinkProvider(bool isDisabled)
|
||||||
: mServiceUuid(QBluetoothUuid(QStringLiteral("185f3df4-3268-4e3f-9fca-d4d5059915bd")))
|
: mServiceUuid(QBluetoothUuid(QStringLiteral("185f3df4-3268-4e3f-9fca-d4d5059915bd")))
|
||||||
, mServiceDiscoveryAgent(new QBluetoothServiceDiscoveryAgent(this))
|
, mServiceDiscoveryAgent(new QBluetoothServiceDiscoveryAgent(this))
|
||||||
, connectTimer(new QTimer(this))
|
, connectTimer(new QTimer(this))
|
||||||
{
|
{
|
||||||
|
this->disabled = isDisabled;
|
||||||
connectTimer->setInterval(30000);
|
connectTimer->setInterval(30000);
|
||||||
connectTimer->setSingleShot(false);
|
connectTimer->setSingleShot(false);
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ BluetoothLinkProvider::BluetoothLinkProvider()
|
||||||
void BluetoothLinkProvider::onStart()
|
void BluetoothLinkProvider::onStart()
|
||||||
{
|
{
|
||||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStart executed";
|
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStart executed";
|
||||||
if (enabled) {
|
if (!disabled) {
|
||||||
tryToInitialise();
|
tryToInitialise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +60,7 @@ void BluetoothLinkProvider::tryToInitialise()
|
||||||
|
|
||||||
void BluetoothLinkProvider::onStop()
|
void BluetoothLinkProvider::onStop()
|
||||||
{
|
{
|
||||||
if (enabled) {
|
if (!disabled) {
|
||||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStop executed";
|
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onStop executed";
|
||||||
if (!mBluetoothServer) {
|
if (!mBluetoothServer) {
|
||||||
return;
|
return;
|
||||||
|
@ -75,16 +76,16 @@ void BluetoothLinkProvider::onStop()
|
||||||
|
|
||||||
void BluetoothLinkProvider::enable()
|
void BluetoothLinkProvider::enable()
|
||||||
{
|
{
|
||||||
if (enabled == false) {
|
if (disabled) {
|
||||||
enabled = true;
|
disabled = false;
|
||||||
tryToInitialise();
|
tryToInitialise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BluetoothLinkProvider::disable()
|
void BluetoothLinkProvider::disable()
|
||||||
{
|
{
|
||||||
if (enabled == true) {
|
if (!disabled) {
|
||||||
enabled = false;
|
disabled = true;
|
||||||
this->onStop();
|
this->onStop();
|
||||||
|
|
||||||
mBluetoothServer = nullptr;
|
mBluetoothServer = nullptr;
|
||||||
|
@ -95,7 +96,7 @@ void BluetoothLinkProvider::disable()
|
||||||
void BluetoothLinkProvider::onNetworkChange()
|
void BluetoothLinkProvider::onNetworkChange()
|
||||||
{
|
{
|
||||||
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onNetworkChange executed";
|
qCDebug(KDECONNECT_CORE) << "BluetoothLinkProvider::onNetworkChange executed";
|
||||||
if (enabled) {
|
if (!disabled) {
|
||||||
tryToInitialise();
|
tryToInitialise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ class KDECONNECTCORE_EXPORT BluetoothLinkProvider : public LinkProvider
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BluetoothLinkProvider();
|
BluetoothLinkProvider(bool disabled = false);
|
||||||
|
|
||||||
virtual ~BluetoothLinkProvider();
|
virtual ~BluetoothLinkProvider();
|
||||||
|
|
||||||
QString name() override
|
QString name() override
|
||||||
|
@ -73,7 +74,7 @@ private:
|
||||||
QBluetoothServiceInfo mKdeconnectService;
|
QBluetoothServiceInfo mKdeconnectService;
|
||||||
QBluetoothServiceDiscoveryAgent *mServiceDiscoveryAgent;
|
QBluetoothServiceDiscoveryAgent *mServiceDiscoveryAgent;
|
||||||
QTimer *connectTimer;
|
QTimer *connectTimer;
|
||||||
bool enabled;
|
bool disabled;
|
||||||
|
|
||||||
QMap<QString, DeviceLink *> mLinks;
|
QMap<QString, DeviceLink *> mLinks;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ static const int MAX_REMEMBERED_IDENTITY_PACKETS = 42;
|
||||||
|
|
||||||
static const long MILLIS_DELAY_BETWEEN_CONNECTIONS_TO_SAME_DEVICE = 500;
|
static const long MILLIS_DELAY_BETWEEN_CONNECTIONS_TO_SAME_DEVICE = 500;
|
||||||
|
|
||||||
LanLinkProvider::LanLinkProvider(bool testMode)
|
LanLinkProvider::LanLinkProvider(bool testMode, bool isDisabled)
|
||||||
: m_server(new Server(this))
|
: m_server(new Server(this))
|
||||||
, m_udpSocket(this)
|
, m_udpSocket(this)
|
||||||
, m_tcpPort(0)
|
, m_tcpPort(0)
|
||||||
|
@ -52,6 +52,8 @@ LanLinkProvider::LanLinkProvider(bool testMode)
|
||||||
, m_mdnsDiscovery(this)
|
, m_mdnsDiscovery(this)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
this->disabled = isDisabled;
|
||||||
|
|
||||||
m_combineNetworkChangeTimer.setInterval(0); // increase this if waiting a single event-loop iteration is not enough
|
m_combineNetworkChangeTimer.setInterval(0); // increase this if waiting a single event-loop iteration is not enough
|
||||||
m_combineNetworkChangeTimer.setSingleShot(true);
|
m_combineNetworkChangeTimer.setSingleShot(true);
|
||||||
connect(&m_combineNetworkChangeTimer, &QTimer::timeout, this, &LanLinkProvider::combinedOnNetworkChange);
|
connect(&m_combineNetworkChangeTimer, &QTimer::timeout, this, &LanLinkProvider::combinedOnNetworkChange);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @param testMode Some special overrides needed while testing
|
* @param testMode Some special overrides needed while testing
|
||||||
*/
|
*/
|
||||||
LanLinkProvider(bool testMode = false);
|
LanLinkProvider(bool testMode = false, bool disabled = false);
|
||||||
~LanLinkProvider() override;
|
~LanLinkProvider() override;
|
||||||
|
|
||||||
QString name() override
|
QString name() override
|
||||||
|
|
|
@ -72,13 +72,16 @@ void Daemon::init()
|
||||||
|
|
||||||
qCDebug(KDECONNECT_CORE) << "DBus registration complete";
|
qCDebug(KDECONNECT_CORE) << "DBus registration complete";
|
||||||
|
|
||||||
|
auto configInstance = KdeConnectConfig::instance();
|
||||||
|
auto status = configInstance.getLinkProviderStatus();
|
||||||
|
|
||||||
// Load backends
|
// Load backends
|
||||||
if (d->m_testMode)
|
if (d->m_testMode) {
|
||||||
d->m_linkProviders.insert(new LoopbackLinkProvider());
|
d->m_linkProviders.insert(new LoopbackLinkProvider());
|
||||||
else {
|
} else {
|
||||||
d->m_linkProviders.insert(new LanLinkProvider());
|
d->m_linkProviders.insert(new LanLinkProvider(false, status[QStringLiteral("disabled")].contains(QStringLiteral("LanLinkProvider"))));
|
||||||
#ifdef KDECONNECT_BLUETOOTH
|
#ifdef KDECONNECT_BLUETOOTH
|
||||||
d->m_linkProviders.insert(new BluetoothLinkProvider());
|
d->m_linkProviders.insert(new BluetoothLinkProvider(status[QStringLiteral("disabled")].contains(QStringLiteral("BluetoothLinkProvider"))));
|
||||||
#endif
|
#endif
|
||||||
#ifdef KDECONNECT_LOOPBACK
|
#ifdef KDECONNECT_LOOPBACK
|
||||||
d->m_linkProviders.insert(new LoopbackLinkProvider());
|
d->m_linkProviders.insert(new LoopbackLinkProvider());
|
||||||
|
|
Loading…
Reference in a new issue