@ -277,7 +277,7 @@ bool WifiManager::isWirelessAdapter(const QDBusObjectPath &path) {
void WifiManager : : requestScan ( ) {
QDBusInterface nm ( NM_DBUS_SERVICE , adapter , NM_DBUS_INTERFACE_DEVICE_WIRELESS , bus ) ;
nm . setTimeout ( DBUS_TIMEOUT ) ;
nm . call ( " RequestScan " , QVariantMap ( ) ) ;
nm . call ( " RequestScan " , QVariantMap ( ) ) ;
}
uint WifiManager : : get_wifi_device_state ( ) {
@ -365,7 +365,9 @@ void WifiManager::connectionRemoved(const QDBusObjectPath &path) {
void WifiManager : : newConnection ( const QDBusObjectPath & path ) {
knownConnections [ path ] = getConnectionSsid ( path ) ;
activateWifiConnection ( knownConnections [ path ] ) ;
if ( knownConnections [ path ] ! = tethering_ssid ) {
activateWifiConnection ( knownConnections [ path ] ) ;
}
}
void WifiManager : : disconnect ( ) {
@ -428,7 +430,7 @@ void WifiManager::addTetheringConnection() {
connection [ " 802-11-wireless-security " ] [ " key-mgmt " ] = " wpa-psk " ;
connection [ " 802-11-wireless-security " ] [ " pairwise " ] = QStringList ( " ccmp " ) ;
connection [ " 802-11-wireless-security " ] [ " proto " ] = QStringList ( " rsn " ) ;
connection [ " 802-11-wireless-security " ] [ " psk " ] = tetheringPassword ;
connection [ " 802-11-wireless-security " ] [ " psk " ] = defaul tT etheringPassword;
connection [ " ipv4 " ] [ " method " ] = " shared " ;
QMap < QString , QVariant > address ;
@ -445,7 +447,7 @@ void WifiManager::addTetheringConnection() {
}
void WifiManager : : enableTethering ( ) {
if ( ! isKnownConnection ( tethering_ssid . toUtf8 ( ) ) ) {
if ( ! isKnownConnection ( tethering_ssid ) ) {
addTetheringConnection ( ) ;
}
activateWifiConnection ( tethering_ssid . toUtf8 ( ) ) ;
@ -465,8 +467,29 @@ bool WifiManager::tetheringEnabled() {
return false ;
}
QString WifiManager : : getTetheringPassword ( ) {
if ( ! isKnownConnection ( tethering_ssid ) ) {
addTetheringConnection ( ) ;
}
const QDBusObjectPath & path = getConnectionPath ( tethering_ssid ) ;
if ( ! path . path ( ) . isEmpty ( ) ) {
QDBusInterface nm ( NM_DBUS_INTERFACE , path . path ( ) , NM_DBUS_INTERFACE_SETTINGS_CONNECTION , bus ) ;
nm . setTimeout ( DBUS_TIMEOUT ) ;
const QDBusReply < QMap < QString , QMap < QString , QVariant > > > response = nm . call ( " GetSecrets " , " 802-11-wireless-security " ) ;
return response . value ( ) . value ( " 802-11-wireless-security " ) . value ( " psk " ) . toString ( ) ;
}
return " " ;
}
void WifiManager : : changeTetheringPassword ( const QString & newPassword ) {
tetheringPassword = newPassword ;
forgetConnection ( tethering_ssid . toUtf8 ( ) ) ;
addTetheringConnection ( ) ;
const QDBusObjectPath & path = getConnectionPath ( tethering_ssid ) ;
if ( ! path . path ( ) . isEmpty ( ) ) {
QDBusInterface nm ( NM_DBUS_INTERFACE , path . path ( ) , NM_DBUS_INTERFACE_SETTINGS_CONNECTION , bus ) ;
nm . setTimeout ( DBUS_TIMEOUT ) ;
Connection settings = QDBusReply < Connection > ( nm . call ( " GetSettings " ) ) . value ( ) ;
settings [ " 802-11-wireless-security " ] [ " psk " ] = newPassword ;
nm . call ( " Update " , QVariant : : fromValue ( settings ) ) ;
}
}