|
|
|
@ -2,8 +2,7 @@ |
|
|
|
|
#include <set> |
|
|
|
|
|
|
|
|
|
#include "wifiManager.hpp" |
|
|
|
|
#include "wifi.hpp" |
|
|
|
|
typedef QMap<QString, QMap<QString, QVariant> > Connection; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString nm_path = "/org/freedesktop/NetworkManager"; |
|
|
|
|
QString nm_settings_path = "/org/freedesktop/NetworkManager/Settings"; |
|
|
|
@ -91,6 +90,7 @@ SecurityType WifiManager::getSecurityType(QString path){ |
|
|
|
|
int wpaflag = get_property(path, "WpaFlags").toInt(); |
|
|
|
|
int rsnflag = get_property(path, "RsnFlags").toInt(); |
|
|
|
|
int wpa_props = wpaflag | rsnflag; |
|
|
|
|
|
|
|
|
|
if(sflag == 0){ |
|
|
|
|
return SecurityType::OPEN; |
|
|
|
|
} else if((sflag & 0x1) && (wpa_props & (0x333) && !(wpa_props & 0x200))) { |
|
|
|
@ -103,9 +103,11 @@ SecurityType WifiManager::getSecurityType(QString path){ |
|
|
|
|
return SecurityType::UNSUPPORTED; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WifiManager::connect(Network n){ |
|
|
|
|
return connect(n, "", ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WifiManager::connect(Network n, QString password){ |
|
|
|
|
return connect(n, "", password); |
|
|
|
|
} |
|
|
|
@ -119,6 +121,7 @@ void WifiManager::connect(Network n, QString username, QString password){ |
|
|
|
|
qDebug() << "Connecting to"<< n.ssid << "with username, password =" << username << "," <<password; |
|
|
|
|
connect(n.ssid, username, password, n.security_type); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WifiManager::connect(QByteArray ssid, QString username, QString password, SecurityType security_type){ |
|
|
|
|
Connection connection; |
|
|
|
|
connection["connection"]["type"] = "802-11-wireless"; |
|
|
|
@ -145,7 +148,6 @@ void WifiManager::connect(QByteArray ssid, QString username, QString password, S |
|
|
|
|
} else { |
|
|
|
|
qDebug() << result.value().path(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WifiManager::print_active_connections(){ |
|
|
|
@ -164,6 +166,7 @@ void WifiManager::print_active_connections(){ |
|
|
|
|
} |
|
|
|
|
step4.endArray(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WifiManager::clear_connections(QString ssid){ |
|
|
|
|
QDBusInterface nm(nm_service, nm_settings_path, nm_settings_iface, bus); |
|
|
|
|
QDBusMessage response = nm.call("ListConnections"); |
|
|
|
@ -194,6 +197,7 @@ void WifiManager::clear_connections(QString ssid){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void WifiManager::request_scan(){ |
|
|
|
|
if (!has_adapter) return; |
|
|
|
|
|
|
|
|
@ -207,12 +211,14 @@ uint WifiManager::get_wifi_device_state(){ |
|
|
|
|
uint resp = get_response<uint>(response); |
|
|
|
|
return resp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString WifiManager::get_active_ap(){ |
|
|
|
|
QDBusInterface device_props(nm_service, adapter, props_iface, bus); |
|
|
|
|
QDBusMessage response = device_props.call("Get", wireless_device_iface, "ActiveAccessPoint"); |
|
|
|
|
QDBusObjectPath r = get_response<QDBusObjectPath>(response); |
|
|
|
|
return r.path(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QByteArray WifiManager::get_property(QString network_path ,QString property){ |
|
|
|
|
QDBusInterface device_props(nm_service, network_path, props_iface, bus); |
|
|
|
|
QDBusMessage response = device_props.call("Get", ap_iface, property); |
|
|
|
|