mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-19 16:22:08 +08:00
Networking: refresh once in background (#21453)
clean up move to setup() old-commit-hash: 07d393499661cbac94e4d13c6b9258f56cfb436a
This commit is contained in:
@@ -68,6 +68,8 @@ void WifiManager::setup() {
|
||||
device_props.setTimeout(DBUS_TIMEOUT);
|
||||
QDBusMessage response = device_props.call("Get", NM_DBUS_INTERFACE_DEVICE, "State");
|
||||
raw_adapter_state = get_response<uint>(response);
|
||||
|
||||
initConnections();
|
||||
requestScan();
|
||||
}
|
||||
|
||||
@@ -342,12 +344,10 @@ void WifiManager::stateChange(unsigned int new_state, unsigned int previous_stat
|
||||
// https://developer.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.Device.Wireless.html
|
||||
void WifiManager::propertyChange(const QString &interface, const QVariantMap &props, const QStringList &invalidated_props) {
|
||||
if (interface == NM_DBUS_INTERFACE_DEVICE_WIRELESS && props.contains("LastScan")) {
|
||||
if (knownConnections.isEmpty()) {
|
||||
knownConnections = listConnections();
|
||||
}
|
||||
if (this->isVisible()) {
|
||||
if (this->isVisible() || firstScan) {
|
||||
refreshNetworks();
|
||||
emit refreshSignal();
|
||||
firstScan = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -391,16 +391,14 @@ QString WifiManager::getConnectionSsid(const QDBusObjectPath &path) {
|
||||
return result.value().value("802-11-wireless").value("ssid").toString();
|
||||
}
|
||||
|
||||
QMap<QDBusObjectPath, QString> WifiManager::listConnections() {
|
||||
QMap<QDBusObjectPath, QString> connections;
|
||||
void WifiManager::initConnections() {
|
||||
QDBusInterface nm(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, bus);
|
||||
nm.setTimeout(DBUS_TIMEOUT);
|
||||
|
||||
const QDBusReply<QList<QDBusObjectPath>> response = nm.call("ListConnections");
|
||||
for (const QDBusObjectPath &path : response.value()) {
|
||||
connections[path] = getConnectionSsid(path);
|
||||
knownConnections[path] = getConnectionSsid(path);
|
||||
}
|
||||
return connections;
|
||||
}
|
||||
|
||||
void WifiManager::activateWifiConnection(const QString &ssid) {
|
||||
|
||||
@@ -64,6 +64,7 @@ private:
|
||||
QString tethering_ssid;
|
||||
QString tetheringPassword = "swagswagcommma";
|
||||
|
||||
bool firstScan = true;
|
||||
QString getAdapter();
|
||||
bool isWirelessAdapter(const QDBusObjectPath &path);
|
||||
QString get_ipv4_address();
|
||||
@@ -77,7 +78,7 @@ private:
|
||||
unsigned int get_ap_strength(const QString &network_path);
|
||||
SecurityType getSecurityType(const QString &path);
|
||||
QDBusObjectPath getConnectionPath(const QString &ssid);
|
||||
QMap<QDBusObjectPath, QString> listConnections();
|
||||
void initConnections();
|
||||
QString getConnectionSsid(const QDBusObjectPath &path);
|
||||
void setup();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user