LanLinkProvider: Restore previous network change behavior

This commit is contained in:
Alexander Lohnau 2023-07-20 12:58:50 +03:00
parent 8ea717b363
commit e9063d168d

View file

@ -71,13 +71,17 @@ LanLinkProvider::LanLinkProvider(bool testMode, quint16 udpBroadcastPort, quint1
} }
}); });
#else #else
// Detect when a network interface changes status, so we announce ourselves in the new network const auto checkNetworkChange = [this]() {
QNetworkInformation::instance()->loadBackendByFeatures(QNetworkInformation::Feature::Reachability);
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, this, [this]() {
if (QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online) { if (QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online) {
onNetworkChange(); onNetworkChange();
} }
}); };
// Detect when a network interface changes status, so we announce ourselves in the new network
QNetworkInformation::instance()->loadBackendByFeatures(QNetworkInformation::Feature::Reachability);
// We want to know if our current network reachability has changed, or if we change from one network to another
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged, this, checkNetworkChange);
connect(QNetworkInformation::instance(), &QNetworkInformation::transportMediumChanged, this, checkNetworkChange);
#endif #endif
} }
@ -187,7 +191,6 @@ void LanLinkProvider::broadcastUdpIdentityPacket()
#endif #endif
} }
QList<QHostAddress> LanLinkProvider::getBroadcastAddresses() QList<QHostAddress> LanLinkProvider::getBroadcastAddresses()
{ {
const QStringList customDevices = KdeConnectConfig::instance().customDevices(); const QStringList customDevices = KdeConnectConfig::instance().customDevices();