|  |  | @ -7,44 +7,6 @@ | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "selfdrive/common/params.h" |  |  |  | #include "selfdrive/common/params.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | #include "selfdrive/common/swaglog.h" |  |  |  | #include "selfdrive/common/swaglog.h" | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | /**
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |  * We are using a NetworkManager DBUS API : https://developer.gnome.org/NetworkManager/1.26/spec.html
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |  * */ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | // https://developer.gnome.org/NetworkManager/1.26/nm-dbus-types.html#NM80211ApFlags
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int NM_802_11_AP_FLAGS_NONE = 0x00000000; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int NM_802_11_AP_FLAGS_PRIVACY = 0x00000001; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int NM_802_11_AP_FLAGS_WPS = 0x00000002; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | // https://developer.gnome.org/NetworkManager/1.26/nm-dbus-types.html#NM80211ApSecurityFlags
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int NM_802_11_AP_SEC_PAIR_WEP40      = 0x00000001; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int NM_802_11_AP_SEC_PAIR_WEP104     = 0x00000002; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int NM_802_11_AP_SEC_GROUP_WEP40     = 0x00000010; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int NM_802_11_AP_SEC_GROUP_WEP104    = 0x00000020; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int NM_802_11_AP_SEC_KEY_MGMT_PSK    = 0x00000100; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString nm_path                = "/org/freedesktop/NetworkManager"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString nm_settings_path       = "/org/freedesktop/NetworkManager/Settings"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString nm_iface               = "org.freedesktop.NetworkManager"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString props_iface            = "org.freedesktop.DBus.Properties"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString nm_settings_iface      = "org.freedesktop.NetworkManager.Settings"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString nm_settings_conn_iface = "org.freedesktop.NetworkManager.Settings.Connection"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString device_iface           = "org.freedesktop.NetworkManager.Device"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString wireless_device_iface  = "org.freedesktop.NetworkManager.Device.Wireless"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString ap_iface               = "org.freedesktop.NetworkManager.AccessPoint"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString connection_iface       = "org.freedesktop.NetworkManager.Connection.Active"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString ipv4config_iface       = "org.freedesktop.NetworkManager.IP4Config"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const QString nm_service             = "org.freedesktop.NetworkManager"; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int state_connected = 100; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int state_need_auth = 60; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int device_type_wifi = 2; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int reason_wrong_password = 8; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | const int dbus_timeout = 100; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | template <typename T> |  |  |  | template <typename T> | 
			
		
	
		
		
			
				
					
					|  |  |  | T get_response(QDBusMessage response) { |  |  |  | T get_response(QDBusMessage response) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QVariant first =  response.arguments().at(0); |  |  |  |   QVariant first =  response.arguments().at(0); | 
			
		
	
	
		
		
			
				
					|  |  | @ -82,7 +44,7 @@ WifiManager::WifiManager(QWidget* parent) : QWidget(parent) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (!adapter.isEmpty()) { |  |  |  |   if (!adapter.isEmpty()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     setup(); |  |  |  |     setup(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } else { |  |  |  |   } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |     bus.connect(nm_service, nm_path, nm_iface, "DeviceAdded", this, SLOT(deviceAdded(QDBusObjectPath))); |  |  |  |     bus.connect(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "DeviceAdded", this, SLOT(deviceAdded(QDBusObjectPath))); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   QTimer* timer = new QTimer(this); |  |  |  |   QTimer* timer = new QTimer(this); | 
			
		
	
	
		
		
			
				
					|  |  | @ -95,16 +57,16 @@ WifiManager::WifiManager(QWidget* parent) : QWidget(parent) { | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void WifiManager::setup() { |  |  |  | void WifiManager::setup() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface nm(nm_service, adapter, device_iface, bus); |  |  |  |   QDBusInterface nm(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_DEVICE, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   bus.connect(nm_service, adapter, device_iface, "StateChanged", this, SLOT(stateChange(unsigned int, unsigned int, unsigned int))); |  |  |  |   bus.connect(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_DEVICE, "StateChanged", this, SLOT(stateChange(unsigned int, unsigned int, unsigned int))); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   bus.connect(nm_service, adapter, props_iface, "PropertiesChanged", this, SLOT(propertyChange(QString, QVariantMap, QStringList))); |  |  |  |   bus.connect(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_PROPERTIES, "PropertiesChanged", this, SLOT(propertyChange(QString, QVariantMap, QStringList))); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   bus.connect(nm_service, nm_settings_path, nm_settings_iface, "ConnectionRemoved", this, SLOT(connectionRemoved(QDBusObjectPath))); |  |  |  |   bus.connect(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, "ConnectionRemoved", this, SLOT(connectionRemoved(QDBusObjectPath))); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   bus.connect(nm_service, nm_settings_path, nm_settings_iface, "NewConnection", this, SLOT(newConnection(QDBusObjectPath))); |  |  |  |   bus.connect(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, "NewConnection", this, SLOT(newConnection(QDBusObjectPath))); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface device_props(nm_service, adapter, props_iface, bus); |  |  |  |   QDBusInterface device_props(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_PROPERTIES, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   device_props.setTimeout(dbus_timeout); |  |  |  |   device_props.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusMessage response = device_props.call("Get", device_iface, "State"); |  |  |  |   QDBusMessage response = device_props.call("Get", NM_DBUS_INTERFACE_DEVICE, "State"); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   raw_adapter_state = get_response<uint>(response); |  |  |  |   raw_adapter_state = get_response<uint>(response); | 
			
		
	
		
		
			
				
					
					|  |  |  |   requestScan(); |  |  |  |   requestScan(); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | @ -123,25 +85,25 @@ void WifiManager::refreshNetworks() { | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | QString WifiManager::get_ipv4_address() { |  |  |  | QString WifiManager::get_ipv4_address() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (raw_adapter_state != state_connected) { |  |  |  |   if (raw_adapter_state != NM_DEVICE_STATE_ACTIVATED) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     return ""; |  |  |  |     return ""; | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  |   QVector<QDBusObjectPath> conns = get_active_connections(); |  |  |  |   QVector<QDBusObjectPath> conns = get_active_connections(); | 
			
		
	
		
		
			
				
					
					|  |  |  |   for (auto &p : conns) { |  |  |  |   for (auto &p : conns) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     QString active_connection = p.path(); |  |  |  |     QString active_connection = p.path(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     QDBusInterface nm(nm_service, active_connection, props_iface, bus); |  |  |  |     QDBusInterface nm(NM_DBUS_SERVICE, active_connection, NM_DBUS_INTERFACE_PROPERTIES, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     nm.setTimeout(dbus_timeout); |  |  |  |     nm.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     QDBusObjectPath pth = get_response<QDBusObjectPath>(nm.call("Get", connection_iface, "Ip4Config")); |  |  |  |     QDBusObjectPath pth = get_response<QDBusObjectPath>(nm.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Ip4Config")); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     QString ip4config = pth.path(); |  |  |  |     QString ip4config = pth.path(); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     QString type = get_response<QString>(nm.call("Get", connection_iface, "Type")); |  |  |  |     QString type = get_response<QString>(nm.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "Type")); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (type == "802-11-wireless") { |  |  |  |     if (type == "802-11-wireless") { | 
			
		
	
		
		
			
				
					
					|  |  |  |       QDBusInterface nm2(nm_service, ip4config, props_iface, bus); |  |  |  |       QDBusInterface nm2(NM_DBUS_SERVICE, ip4config, NM_DBUS_INTERFACE_PROPERTIES, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |       nm2.setTimeout(dbus_timeout); |  |  |  |       nm2.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |       const QDBusArgument &arr = get_response<QDBusArgument>(nm2.call("Get", ipv4config_iface, "AddressData")); |  |  |  |       const QDBusArgument &arr = get_response<QDBusArgument>(nm2.call("Get", NM_DBUS_INTERFACE_IP4_CONFIG, "AddressData")); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       QMap<QString, QVariant> pth2; |  |  |  |       QMap<QString, QVariant> pth2; | 
			
		
	
		
		
			
				
					
					|  |  |  |       arr.beginArray(); |  |  |  |       arr.beginArray(); | 
			
		
	
		
		
			
				
					
					|  |  |  |       while (!arr.atEnd()) { |  |  |  |       while (!arr.atEnd()) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -158,8 +120,8 @@ QString WifiManager::get_ipv4_address() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | QList<Network> WifiManager::get_networks() { |  |  |  | QList<Network> WifiManager::get_networks() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QList<Network> r; |  |  |  |   QList<Network> r; | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface nm(nm_service, adapter, wireless_device_iface, bus); |  |  |  |   QDBusInterface nm(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_DEVICE_WIRELESS, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   nm.setTimeout(dbus_timeout); |  |  |  |   nm.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusMessage response = nm.call("GetAllAccessPoints"); |  |  |  |   QDBusMessage response = nm.call("GetAllAccessPoints"); | 
			
		
	
		
		
			
				
					
					|  |  |  |   QVariant first =  response.arguments().at(0); |  |  |  |   QVariant first =  response.arguments().at(0); | 
			
		
	
	
		
		
			
				
					|  |  | @ -249,8 +211,8 @@ void WifiManager::connect(const QByteArray &ssid, const QString &username, const | 
			
		
	
		
		
			
				
					
					|  |  |  |   connection["ipv4"]["method"] = "auto"; |  |  |  |   connection["ipv4"]["method"] = "auto"; | 
			
		
	
		
		
			
				
					
					|  |  |  |   connection["ipv6"]["method"] = "ignore"; |  |  |  |   connection["ipv6"]["method"] = "ignore"; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface nm_settings(nm_service, nm_settings_path, nm_settings_iface, bus); |  |  |  |   QDBusInterface nm_settings(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   nm_settings.setTimeout(dbus_timeout); |  |  |  |   nm_settings.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   nm_settings.call("AddConnection", QVariant::fromValue(connection)); |  |  |  |   nm_settings.call("AddConnection", QVariant::fromValue(connection)); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | @ -258,15 +220,15 @@ void WifiManager::connect(const QByteArray &ssid, const QString &username, const | 
			
		
	
		
		
			
				
					
					|  |  |  | void WifiManager::deactivateConnection(const QString &ssid) { |  |  |  | void WifiManager::deactivateConnection(const QString &ssid) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   for (QDBusObjectPath active_connection_raw : get_active_connections()) { |  |  |  |   for (QDBusObjectPath active_connection_raw : get_active_connections()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     QString active_connection = active_connection_raw.path(); |  |  |  |     QString active_connection = active_connection_raw.path(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     QDBusInterface nm(nm_service, active_connection, props_iface, bus); |  |  |  |     QDBusInterface nm(NM_DBUS_SERVICE, active_connection, NM_DBUS_INTERFACE_PROPERTIES, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     nm.setTimeout(dbus_timeout); |  |  |  |     nm.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     QDBusObjectPath pth = get_response<QDBusObjectPath>(nm.call("Get", connection_iface, "SpecificObject")); |  |  |  |     QDBusObjectPath pth = get_response<QDBusObjectPath>(nm.call("Get", NM_DBUS_INTERFACE_ACTIVE_CONNECTION, "SpecificObject")); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     if (pth.path() != "" && pth.path() != "/") { |  |  |  |     if (pth.path() != "" && pth.path() != "/") { | 
			
		
	
		
		
			
				
					
					|  |  |  |       QString Ssid = get_property(pth.path(), "Ssid"); |  |  |  |       QString Ssid = get_property(pth.path(), "Ssid"); | 
			
		
	
		
		
			
				
					
					|  |  |  |       if (Ssid == ssid) { |  |  |  |       if (Ssid == ssid) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         QDBusInterface nm2(nm_service, nm_path, nm_iface, bus); |  |  |  |         QDBusInterface nm2(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         nm2.setTimeout(dbus_timeout); |  |  |  |         nm2.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         nm2.call("DeactivateConnection", QVariant::fromValue(active_connection_raw)); |  |  |  |         nm2.call("DeactivateConnection", QVariant::fromValue(active_connection_raw)); | 
			
		
	
		
		
			
				
					
					|  |  |  |       } |  |  |  |       } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | @ -274,10 +236,10 @@ void WifiManager::deactivateConnection(const QString &ssid) { | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | QVector<QDBusObjectPath> WifiManager::get_active_connections() { |  |  |  | QVector<QDBusObjectPath> WifiManager::get_active_connections() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface nm(nm_service, nm_path, props_iface, bus); |  |  |  |   QDBusInterface nm(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE_PROPERTIES, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   nm.setTimeout(dbus_timeout); |  |  |  |   nm.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusMessage response = nm.call("Get", nm_iface, "ActiveConnections"); |  |  |  |   QDBusMessage response = nm.call("Get", NM_DBUS_INTERFACE, "ActiveConnections"); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   const QDBusArgument &arr = get_response<QDBusArgument>(response); |  |  |  |   const QDBusArgument &arr = get_response<QDBusArgument>(response); | 
			
		
	
		
		
			
				
					
					|  |  |  |   QVector<QDBusObjectPath> conns; |  |  |  |   QVector<QDBusObjectPath> conns; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -298,61 +260,61 @@ bool WifiManager::isKnownConnection(const QString &ssid) { | 
			
		
	
		
		
			
				
					
					|  |  |  | void WifiManager::forgetConnection(const QString &ssid) { |  |  |  | void WifiManager::forgetConnection(const QString &ssid) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   const QDBusObjectPath &path = getConnectionPath(ssid); |  |  |  |   const QDBusObjectPath &path = getConnectionPath(ssid); | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (!path.path().isEmpty()) { |  |  |  |   if (!path.path().isEmpty()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     QDBusInterface nm2(nm_service, path.path(), nm_settings_conn_iface, bus); |  |  |  |     QDBusInterface nm2(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     nm2.call("Delete"); |  |  |  |     nm2.call("Delete"); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | bool WifiManager::isWirelessAdapter(const QDBusObjectPath &path) { |  |  |  | bool WifiManager::isWirelessAdapter(const QDBusObjectPath &path) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface device_props(nm_service, path.path(), props_iface, bus); |  |  |  |   QDBusInterface device_props(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_PROPERTIES, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   device_props.setTimeout(dbus_timeout); |  |  |  |   device_props.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   const uint deviceType = get_response<uint>(device_props.call("Get", device_iface, "DeviceType")); |  |  |  |   const uint deviceType = get_response<uint>(device_props.call("Get", NM_DBUS_INTERFACE_DEVICE, "DeviceType")); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   return deviceType == device_type_wifi; |  |  |  |   return deviceType == NM_DEVICE_TYPE_WIFI; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void WifiManager::requestScan() { |  |  |  | void WifiManager::requestScan() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface nm(nm_service, adapter, wireless_device_iface, bus); |  |  |  |   QDBusInterface nm(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_DEVICE_WIRELESS, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   nm.setTimeout(dbus_timeout); |  |  |  |   nm.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   nm.call("RequestScan",  QVariantMap()); |  |  |  |   nm.call("RequestScan",  QVariantMap()); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | uint WifiManager::get_wifi_device_state() { |  |  |  | uint WifiManager::get_wifi_device_state() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface device_props(nm_service, adapter, props_iface, bus); |  |  |  |   QDBusInterface device_props(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_PROPERTIES, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   device_props.setTimeout(dbus_timeout); |  |  |  |   device_props.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusMessage response = device_props.call("Get", device_iface, "State"); |  |  |  |   QDBusMessage response = device_props.call("Get", NM_DBUS_INTERFACE_DEVICE, "State"); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   uint resp = get_response<uint>(response); |  |  |  |   uint resp = get_response<uint>(response); | 
			
		
	
		
		
			
				
					
					|  |  |  |   return resp; |  |  |  |   return resp; | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | QString WifiManager::get_active_ap() { |  |  |  | QString WifiManager::get_active_ap() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface device_props(nm_service, adapter, props_iface, bus); |  |  |  |   QDBusInterface device_props(NM_DBUS_SERVICE, adapter, NM_DBUS_INTERFACE_PROPERTIES, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   device_props.setTimeout(dbus_timeout); |  |  |  |   device_props.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusMessage response = device_props.call("Get", wireless_device_iface, "ActiveAccessPoint"); |  |  |  |   QDBusMessage response = device_props.call("Get", NM_DBUS_INTERFACE_DEVICE_WIRELESS, "ActiveAccessPoint"); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   QDBusObjectPath r = get_response<QDBusObjectPath>(response); |  |  |  |   QDBusObjectPath r = get_response<QDBusObjectPath>(response); | 
			
		
	
		
		
			
				
					
					|  |  |  |   return r.path(); |  |  |  |   return r.path(); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | QByteArray WifiManager::get_property(const QString &network_path , const QString &property) { |  |  |  | QByteArray WifiManager::get_property(const QString &network_path , const QString &property) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface device_props(nm_service, network_path, props_iface, bus); |  |  |  |   QDBusInterface device_props(NM_DBUS_SERVICE, network_path, NM_DBUS_INTERFACE_PROPERTIES, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   device_props.setTimeout(dbus_timeout); |  |  |  |   device_props.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusMessage response = device_props.call("Get", ap_iface, property); |  |  |  |   QDBusMessage response = device_props.call("Get", NM_DBUS_INTERFACE_ACCESS_POINT, property); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   return get_response<QByteArray>(response); |  |  |  |   return get_response<QByteArray>(response); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | unsigned int WifiManager::get_ap_strength(const QString &network_path) { |  |  |  | unsigned int WifiManager::get_ap_strength(const QString &network_path) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface device_props(nm_service, network_path, props_iface, bus); |  |  |  |   QDBusInterface device_props(NM_DBUS_SERVICE, network_path, NM_DBUS_INTERFACE_PROPERTIES, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   device_props.setTimeout(dbus_timeout); |  |  |  |   device_props.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusMessage response = device_props.call("Get", ap_iface, "Strength"); |  |  |  |   QDBusMessage response = device_props.call("Get", NM_DBUS_INTERFACE_ACCESS_POINT, "Strength"); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   return get_response<unsigned int>(response); |  |  |  |   return get_response<unsigned int>(response); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | QString WifiManager::getAdapter() { |  |  |  | QString WifiManager::getAdapter() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface nm(nm_service, nm_path, nm_iface, bus); |  |  |  |   QDBusInterface nm(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   nm.setTimeout(dbus_timeout); |  |  |  |   nm.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   const QDBusReply<QList<QDBusObjectPath>> &response = nm.call("GetDevices"); |  |  |  |   const QDBusReply<QList<QDBusObjectPath>> &response = nm.call("GetDevices"); | 
			
		
	
		
		
			
				
					
					|  |  |  |   for (const QDBusObjectPath &path : response.value()) { |  |  |  |   for (const QDBusObjectPath &path : response.value()) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -365,10 +327,10 @@ QString WifiManager::getAdapter() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | void WifiManager::stateChange(unsigned int new_state, unsigned int previous_state, unsigned int change_reason) { |  |  |  | void WifiManager::stateChange(unsigned int new_state, unsigned int previous_state, unsigned int change_reason) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   raw_adapter_state = new_state; |  |  |  |   raw_adapter_state = new_state; | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (new_state == state_need_auth && change_reason == reason_wrong_password) { |  |  |  |   if (new_state == NM_DEVICE_STATE_NEED_AUTH && change_reason == NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     knownConnections.remove(getConnectionPath(connecting_to_network)); |  |  |  |     knownConnections.remove(getConnectionPath(connecting_to_network)); | 
			
		
	
		
		
			
				
					
					|  |  |  |     emit wrongPassword(connecting_to_network); |  |  |  |     emit wrongPassword(connecting_to_network); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } else if (new_state == state_connected) { |  |  |  |   } else if (new_state == NM_DEVICE_STATE_ACTIVATED) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     connecting_to_network = ""; |  |  |  |     connecting_to_network = ""; | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (this->isVisible()) { |  |  |  |     if (this->isVisible()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |       refreshNetworks(); |  |  |  |       refreshNetworks(); | 
			
		
	
	
		
		
			
				
					|  |  | @ -379,7 +341,7 @@ void WifiManager::stateChange(unsigned int new_state, unsigned int previous_stat | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | // https://developer.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.Device.Wireless.html
 |  |  |  | // 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) { |  |  |  | void WifiManager::propertyChange(const QString &interface, const QVariantMap &props, const QStringList &invalidated_props) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (interface == wireless_device_iface && props.contains("LastScan")) { |  |  |  |   if (interface == NM_DBUS_INTERFACE_DEVICE_WIRELESS && props.contains("LastScan")) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     if (knownConnections.isEmpty()) { |  |  |  |     if (knownConnections.isEmpty()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |       knownConnections = listConnections(); |  |  |  |       knownConnections = listConnections(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | @ -423,16 +385,16 @@ QDBusObjectPath WifiManager::getConnectionPath(const QString &ssid) { | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | QString WifiManager::getConnectionSsid(const QDBusObjectPath &path) { |  |  |  | QString WifiManager::getConnectionSsid(const QDBusObjectPath &path) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface nm(nm_service, path.path(), nm_settings_conn_iface, bus); |  |  |  |   QDBusInterface nm(NM_DBUS_SERVICE, path.path(), NM_DBUS_INTERFACE_SETTINGS_CONNECTION, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   nm.setTimeout(dbus_timeout); |  |  |  |   nm.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   const QDBusReply<Connection> result = nm.call("GetSettings"); |  |  |  |   const QDBusReply<Connection> result = nm.call("GetSettings"); | 
			
		
	
		
		
			
				
					
					|  |  |  |   return result.value().value("802-11-wireless").value("ssid").toString(); |  |  |  |   return result.value().value("802-11-wireless").value("ssid").toString(); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | QMap<QDBusObjectPath, QString> WifiManager::listConnections() { |  |  |  | QMap<QDBusObjectPath, QString> WifiManager::listConnections() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   QMap<QDBusObjectPath, QString> connections; |  |  |  |   QMap<QDBusObjectPath, QString> connections; | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface nm(nm_service, nm_settings_path, nm_settings_iface, bus); |  |  |  |   QDBusInterface nm(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   nm.setTimeout(dbus_timeout); |  |  |  |   nm.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   const QDBusReply<QList<QDBusObjectPath>> response = nm.call("ListConnections"); |  |  |  |   const QDBusReply<QList<QDBusObjectPath>> response = nm.call("ListConnections"); | 
			
		
	
		
		
			
				
					
					|  |  |  |   for (const QDBusObjectPath &path : response.value()) { |  |  |  |   for (const QDBusObjectPath &path : response.value()) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -445,8 +407,8 @@ void WifiManager::activateWifiConnection(const QString &ssid) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   const QDBusObjectPath &path = getConnectionPath(ssid); |  |  |  |   const QDBusObjectPath &path = getConnectionPath(ssid); | 
			
		
	
		
		
			
				
					
					|  |  |  |   if (!path.path().isEmpty()) { |  |  |  |   if (!path.path().isEmpty()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     connecting_to_network = ssid; |  |  |  |     connecting_to_network = ssid; | 
			
		
	
		
		
			
				
					
					|  |  |  |     QDBusInterface nm3(nm_service, nm_path, nm_iface, bus); |  |  |  |     QDBusInterface nm3(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     nm3.setTimeout(dbus_timeout); |  |  |  |     nm3.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     nm3.call("ActivateConnection", QVariant::fromValue(path), QVariant::fromValue(QDBusObjectPath(adapter)), QVariant::fromValue(QDBusObjectPath("/"))); |  |  |  |     nm3.call("ActivateConnection", QVariant::fromValue(path), QVariant::fromValue(QDBusObjectPath(adapter)), QVariant::fromValue(QDBusObjectPath("/"))); | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | @ -479,8 +441,8 @@ void WifiManager::addTetheringConnection() { | 
			
		
	
		
		
			
				
					
					|  |  |  |   connection["ipv4"]["route-metric"] = 1100; |  |  |  |   connection["ipv4"]["route-metric"] = 1100; | 
			
		
	
		
		
			
				
					
					|  |  |  |   connection["ipv6"]["method"] = "ignore"; |  |  |  |   connection["ipv6"]["method"] = "ignore"; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   QDBusInterface nm_settings(nm_service, nm_settings_path, nm_settings_iface, bus); |  |  |  |   QDBusInterface nm_settings(NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, NM_DBUS_INTERFACE_SETTINGS, bus); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   nm_settings.setTimeout(dbus_timeout); |  |  |  |   nm_settings.setTimeout(DBUS_TIMEOUT); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   nm_settings.call("AddConnection", QVariant::fromValue(connection)); |  |  |  |   nm_settings.call("AddConnection", QVariant::fromValue(connection)); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |