These all need to be near-idempotent
This commit is contained in:
parent
732bf0636f
commit
9800664360
2 changed files with 31 additions and 10 deletions
|
@ -75,18 +75,22 @@ void BluetoothLinkProvider::onStop()
|
|||
|
||||
void BluetoothLinkProvider::enable()
|
||||
{
|
||||
if (enabled == false) {
|
||||
enabled = true;
|
||||
tryToInitialise();
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothLinkProvider::disable()
|
||||
{
|
||||
if (enabled == true) {
|
||||
enabled = false;
|
||||
this->onStop();
|
||||
|
||||
mBluetoothServer = nullptr;
|
||||
mServiceDiscoveryAgent = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothLinkProvider::onNetworkChange()
|
||||
{
|
||||
|
|
|
@ -86,17 +86,25 @@ LanLinkProvider::~LanLinkProvider()
|
|||
|
||||
void LanLinkProvider::enable()
|
||||
{
|
||||
if (disabled == true) {
|
||||
disabled = false;
|
||||
this->onStart();
|
||||
}
|
||||
}
|
||||
void LanLinkProvider::disable()
|
||||
{
|
||||
if (disabled == false) {
|
||||
this->onStop();
|
||||
disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void LanLinkProvider::onStart()
|
||||
{
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QHostAddress bindAddress = m_testMode ? QHostAddress::LocalHost : QHostAddress::Any;
|
||||
|
||||
bool success = m_udpSocket.bind(bindAddress, UDP_PORT, QUdpSocket::ShareAddress);
|
||||
|
@ -129,6 +137,9 @@ void LanLinkProvider::onStart()
|
|||
|
||||
void LanLinkProvider::onStop()
|
||||
{
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
#ifdef KDECONNECT_MDNS
|
||||
m_mdnsDiscovery.onStop();
|
||||
#endif
|
||||
|
@ -139,6 +150,9 @@ void LanLinkProvider::onStop()
|
|||
|
||||
void LanLinkProvider::onNetworkChange()
|
||||
{
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
if (m_combineNetworkChangeTimer.isActive()) {
|
||||
qCDebug(KDECONNECT_CORE) << "Device discovery triggered too fast, ignoring";
|
||||
return;
|
||||
|
@ -149,6 +163,9 @@ void LanLinkProvider::onNetworkChange()
|
|||
// I'm in a new network, let's be polite and introduce myself
|
||||
void LanLinkProvider::combinedOnNetworkChange()
|
||||
{
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
if (!m_server->isListening()) {
|
||||
qWarning() << "TCP server not listening, not broadcasting";
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue