Merge branch 'kylin-nm-wlan-dev' into 'dbus-interface'

通过nm-connect-editor激活一个新的wifi连接的时候,kylin-nm的界面不显示已激活的连接

See merge request kylin-desktop/kylin-nm!357
This commit is contained in:
ren peijia 2021-10-26 06:57:49 +00:00
commit b3e3f3501d
2 changed files with 98 additions and 58 deletions

View File

@ -579,5 +579,6 @@ QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid)
NetworkManager::Device:: Ptr devicePtr = NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni); m_networkResourceInstance->findDeviceUni(ifaceUni);
deviceName = devicePtr->interfaceName(); deviceName = devicePtr->interfaceName();
return deviceName; return deviceName;
} }

View File

@ -1,5 +1,7 @@
#include "kywirelessnetresource.h" #include "kywirelessnetresource.h"
#define LOG_FLAG "[KyWirelessNetResource]"
static bool subWifiListSort(const KyWirelessNetItem info1, const KyWirelessNetItem info2) static bool subWifiListSort(const KyWirelessNetItem info1, const KyWirelessNetItem info2)
{ {
if (info1.m_isConfigured == info2.m_isConfigured) { if (info1.m_isConfigured == info2.m_isConfigured) {
@ -63,8 +65,6 @@ bool KyWirelessNetResource::getAllDeviceWifiNetwork(QMap<QString,QList<KyWireles
bool KyWirelessNetResource::getDeviceWifiNetwork(QString devIfaceName, QList<KyWirelessNetItem> &wirelessNetResource) bool KyWirelessNetResource::getDeviceWifiNetwork(QString devIfaceName, QList<KyWirelessNetItem> &wirelessNetResource)
{ {
// onWifiNetworkDeviceDisappear();
if (!m_WifiNetworkList.contains(devIfaceName)) { if (!m_WifiNetworkList.contains(devIfaceName)) {
return false; return false;
} else { } else {
@ -76,21 +76,21 @@ bool KyWirelessNetResource::getDeviceWifiNetwork(QString devIfaceName, QList<KyW
bool KyWirelessNetResource::getWifiNetwork(const QString &devIfaceName, const QString &ssid, KyWirelessNetItem &wirelessNetResource) bool KyWirelessNetResource::getWifiNetwork(const QString &devIfaceName, const QString &ssid, KyWirelessNetItem &wirelessNetResource)
{ {
// onWifiNetworkDeviceDisappear();
if (!m_WifiNetworkList.contains(devIfaceName)) { if (!m_WifiNetworkList.contains(devIfaceName)) {
qDebug() << "getWifiNetwork fail,not contain " << devIfaceName; qDebug()<< LOG_FLAG << "getWifiNetwork fail, not contain " << devIfaceName;
return false; return false;
} else { } else {
for (int index = 0; index < m_WifiNetworkList[devIfaceName].size(); index++){ for (int index = 0; index < m_WifiNetworkList[devIfaceName].size(); index++){
if (m_WifiNetworkList[devIfaceName].at(index).m_NetSsid == ssid) { if (m_WifiNetworkList[devIfaceName].at(index).m_NetSsid == ssid) {
wirelessNetResource = m_WifiNetworkList[devIfaceName].at(index); wirelessNetResource = m_WifiNetworkList[devIfaceName].at(index);
qDebug() << "getWifiNetwork success"; qDebug()<< LOG_FLAG << "getWifiNetwork success";
return true; return true;
} }
} }
} }
qDebug() << "getWifiNetwork fail,not contain " << ssid;
qDebug()<< LOG_FLAG << "getWifiNetwork fail, not contain " << ssid;
return false; return false;
} }
@ -121,12 +121,13 @@ void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveCo
continue; continue;
} }
qDebug() << "getWirelessActiveConnection " << activeConnectionPtr->uuid(); qDebug()<< LOG_FLAG << "getWirelessActiveConnection " << activeConnectionPtr->uuid();
QString ssid; QString ssid;
QString ifaceName = getDeviceIFace(activeConnectionPtr, ssid); QString ifaceName = getDeviceIFace(activeConnectionPtr, ssid);
if(ifaceName.isEmpty() || ssid.isNull()) { if(ifaceName.isEmpty() || ssid.isNull()) {
continue; continue;
} }
if (map.contains(ifaceName)) { if (map.contains(ifaceName)) {
map[ifaceName].append(activeConnectionPtr->uuid()); map[ifaceName].append(activeConnectionPtr->uuid());
} else { } else {
@ -135,6 +136,7 @@ void KyWirelessNetResource::getWirelessActiveConnection(NetworkManager::ActiveCo
map.insert(ifaceName,list); map.insert(ifaceName,list);
} }
} }
return; return;
} }
@ -150,7 +152,7 @@ QString KyWirelessNetResource::getActiveConnectSsidByDevice(QString deviceName)
} }
NetworkManager::ActiveConnection::Ptr activeConnectionPtr = nullptr; NetworkManager::ActiveConnection::Ptr activeConnectionPtr = nullptr;
for (int index; index < activeConnectionList.size(); index++) { for (int index = 0; index < activeConnectionList.size(); index++) {
activeConnectionPtr = activeConnectionList.at(index); activeConnectionPtr = activeConnectionList.at(index);
if (activeConnectionPtr.isNull()) { if (activeConnectionPtr.isNull()) {
continue; continue;
@ -164,15 +166,20 @@ QString KyWirelessNetResource::getActiveConnectSsidByDevice(QString deviceName)
continue; continue;
} }
NetworkManager::Connection::Ptr connectPtr = activeConnectionPtr->connection(); QStringList interfaces = activeConnectionPtr->devices();
NetworkManager::ConnectionSettings::Ptr settingPtr = connectPtr->settings(); QString ifaceUni = interfaces.at(0);
if (deviceName != settingPtr->interfaceName()) { NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni);
if (deviceName != devicePtr->interfaceName()) {
continue; continue;
} }
NetworkManager::Connection::Ptr connectPtr = activeConnectionPtr->connection();
NetworkManager::ConnectionSettings::Ptr settingPtr = connectPtr->settings();
NetworkManager::WirelessSetting::Ptr wirelessSettingPtr = NetworkManager::WirelessSetting::Ptr wirelessSettingPtr =
settingPtr->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>(); settingPtr->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
ssid = wirelessSettingPtr->ssid(); ssid = wirelessSettingPtr->ssid();
break;
} }
return ssid; return ssid;
@ -193,7 +200,7 @@ bool KyWirelessNetResource::getActiveWirelessNetItem(QString deviceName, KyWirel
for (int index = 0; index < m_WifiNetworkList[deviceName].size(); index ++) { for (int index = 0; index < m_WifiNetworkList[deviceName].size(); index ++) {
if (m_WifiNetworkList[deviceName].at(index).m_NetSsid == ssid) { if (m_WifiNetworkList[deviceName].at(index).m_NetSsid == ssid) {
wirelessNetItem = m_WifiNetworkList[deviceName].at(index); wirelessNetItem = m_WifiNetworkList[deviceName].at(index);
qDebug() << "getWifiNetwork success"; qDebug()<< LOG_FLAG << "getWifiNetwork success";
return true; return true;
} }
} }
@ -222,9 +229,15 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::ActiveConnection::
if (wireless_sett.isNull()) { if (wireless_sett.isNull()) {
return ""; return "";
} }
wirelessNetResourcessid = wireless_sett->ssid(); wirelessNetResourcessid = wireless_sett->ssid();
return sett->interfaceName(); QStringList interfaces = actConn->devices();
QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni);
return devicePtr->interfaceName();
} }
void KyWirelessNetResource::getSsidByUuid(const QString uuid, QString &ssid) void KyWirelessNetResource::getSsidByUuid(const QString uuid, QString &ssid)
@ -238,12 +251,12 @@ void KyWirelessNetResource::getSsidByUuid(const QString uuid, QString &ssid)
NetworkManager::WirelessSetting::Ptr wireless_sett NetworkManager::WirelessSetting::Ptr wireless_sett
= connectPtr->settings()->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>(); = connectPtr->settings()->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
if (wireless_sett.isNull()) { if (wireless_sett.isNull()) {
qDebug() << "don't have WirelessSetting connection"; qDebug()<< LOG_FLAG << "don't have WirelessSetting connection";
return; return;
} }
ssid = wireless_sett->ssid(); ssid = wireless_sett->ssid();
qDebug() << "getSsidByUuid success " << ssid; qDebug()<< LOG_FLAG << "getSsidByUuid success " << ssid;
return; return;
} }
@ -252,6 +265,16 @@ void KyWirelessNetResource::getDeviceByUuid(const QString uuid, QString &deviceN
{ {
deviceName.clear(); deviceName.clear();
NetworkManager::ActiveConnection::Ptr activeConnectionPtr = m_networkResourceInstance->getActiveConnect(uuid);
if (!activeConnectionPtr.isNull()) {
QStringList interfaces = activeConnectionPtr->devices();
QString ifaceUni = interfaces.at(0);
NetworkManager::Device:: Ptr devicePtr =
m_networkResourceInstance->findDeviceUni(ifaceUni);
deviceName = devicePtr->interfaceName();
return;
}
NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(uuid); NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(uuid);
if (connectPtr.isNull()) { if (connectPtr.isNull()) {
return; return;
@ -264,12 +287,13 @@ void KyWirelessNetResource::getDeviceByUuid(const QString uuid, QString &deviceN
void KyWirelessNetResource::kyWirelessNetItemListInit() void KyWirelessNetResource::kyWirelessNetItemListInit()
{ {
qDebug() << m_networkResourceInstance->m_wifiNets.size(); qDebug()<< LOG_FLAG << "wireless net size:" << m_networkResourceInstance->m_wifiNets.size();
for (auto const & net : m_networkResourceInstance->m_wifiNets) { for (auto const & net : m_networkResourceInstance->m_wifiNets) {
QString devIface = getDeviceIFace(net); QString devIface = getDeviceIFace(net);
if (devIface.isEmpty()) { if (devIface.isEmpty()) {
continue; continue;
} }
KyWirelessNetItem item(net); KyWirelessNetItem item(net);
if (!m_WifiNetworkList.contains(devIface)){ if (!m_WifiNetworkList.contains(devIface)){
QList<KyWirelessNetItem> list; QList<KyWirelessNetItem> list;
@ -288,12 +312,14 @@ QString KyWirelessNetResource::getDeviceIFace(NetworkManager::WirelessNetwork::P
if (net.isNull()) { if (net.isNull()) {
return ""; return "";
} }
QString devUni = net->device(); QString devUni = net->device();
NetworkManager::Device::Ptr dev = m_networkResourceInstance->findDeviceUni(devUni); NetworkManager::Device::Ptr dev = m_networkResourceInstance->findDeviceUni(devUni);
if (dev.isNull()) { if (dev.isNull()) {
qDebug() << "KyWirelessNetResource: can't find " << net->ssid() << " find in device list"; qDebug()<< LOG_FLAG << "KyWirelessNetResource: can't find " << net->ssid() << " find in device list";
return ""; return "";
} }
return dev->interfaceName(); return dev->interfaceName();
} }
@ -339,6 +365,7 @@ void KyWirelessNetResource::onWifiNetworkAdded(QString devIfaceName, QString ssi
if (wifi.isNull()) { if (wifi.isNull()) {
return; return;
} }
KyWirelessNetItem item(wifi); KyWirelessNetItem item(wifi);
if (m_WifiNetworkList.contains(devIfaceName)) { if (m_WifiNetworkList.contains(devIfaceName)) {
@ -380,7 +407,7 @@ void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::Wireless
QList<KyWirelessNetItem>::iterator iter = m_WifiNetworkList[devIface].begin(); QList<KyWirelessNetItem>::iterator iter = m_WifiNetworkList[devIface].begin();
while (iter != m_WifiNetworkList[devIface].end()) { while (iter != m_WifiNetworkList[devIface].end()) {
if (iter->m_NetSsid == net->ssid()) { if (iter->m_NetSsid == net->ssid()) {
qDebug()<<"recive properity changed signal, sender is" << iter->m_NetSsid; qDebug()<< LOG_FLAG <<"recive properity changed signal, sender is" << iter->m_NetSsid;
if (iter->m_signalStrength != net->signalStrength()) { if (iter->m_signalStrength != net->signalStrength()) {
iter->m_signalStrength = net->signalStrength(); iter->m_signalStrength = net->signalStrength();
emit signalStrengthChange(devIface, net->ssid(), iter->m_signalStrength); emit signalStrengthChange(devIface, net->ssid(), iter->m_signalStrength);
@ -415,22 +442,23 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn
{ {
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid); NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
if (conn.isNull()) { if (conn.isNull()) {
qDebug() << "modifyEnterPriseInfoTls connection missing"; qDebug()<< LOG_FLAG << "modifyEnterPriseInfoTls connection missing";
return false; return false;
} }
NetworkManager::WirelessSecuritySetting::Ptr security_sett NetworkManager::WirelessSecuritySetting::Ptr security_sett =
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>(); conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
if (security_sett.isNull()) { if (security_sett.isNull()) {
qDebug() << "don't have WirelessSecurity connection"; qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection";
return false; return false;
} }
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) { if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
return false; return false;
} }
NetworkManager::Security8021xSetting::Ptr setting = conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>(); NetworkManager::Security8021xSetting::Ptr setting =
conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
if (setting.isNull()) { if (setting.isNull()) {
qDebug() << "don't have Security8021x connection"; qDebug()<< LOG_FLAG << "don't have Security8021x connection";
return false; return false;
} }
@ -441,14 +469,17 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn
if (info.caCertPath.left(7) == "file://") { if (info.caCertPath.left(7) == "file://") {
info.caCertPath = info.caCertPath.mid(7); info.caCertPath = info.caCertPath.mid(7);
} }
info.clientCertPath = setting->clientCertificate(); info.clientCertPath = setting->clientCertificate();
if (info.clientCertPath.left(7) == "file://") { if (info.clientCertPath.left(7) == "file://") {
info.clientCertPath = info.clientCertPath.mid(7); info.clientCertPath = info.clientCertPath.mid(7);
} }
info.clientPrivateKey = QString(setting->privateKey()); info.clientPrivateKey = QString(setting->privateKey());
if (info.clientPrivateKey.left(7) == "file://") { if (info.clientPrivateKey.left(7) == "file://") {
info.clientPrivateKey = info.clientPrivateKey.mid(7); info.clientPrivateKey = info.clientPrivateKey.mid(7);
} }
info.m_privateKeyPWDFlag = setting->privateKeyPasswordFlags(); info.m_privateKeyPWDFlag = setting->privateKeyPasswordFlags();
if (!info.m_privateKeyPWDFlag) { if (!info.m_privateKeyPWDFlag) {
info.clientPrivateKeyPWD = m_operation->getPrivateKeyPassword(conn->uuid()); info.clientPrivateKeyPWD = m_operation->getPrivateKeyPassword(conn->uuid());
@ -461,22 +492,25 @@ bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeap
{ {
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid); NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
if (conn.isNull()) { if (conn.isNull()) {
qDebug() << "getEnterPriseInfoPeap connection missing"; qDebug()<< LOG_FLAG << "getEnterPriseInfoPeap connection missing";
return false; return false;
} }
NetworkManager::WirelessSecuritySetting::Ptr security_sett NetworkManager::WirelessSecuritySetting::Ptr security_sett
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>(); = conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
if (security_sett.isNull()) { if (security_sett.isNull()) {
qDebug() << "don't have WirelessSecurity connection"; qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection";
return false; return false;
} }
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) { if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
qDebug() << "keyMgmt not WpaEap " << security_sett->keyMgmt(); qDebug()<< LOG_FLAG << "keyMgmt not WpaEap " << security_sett->keyMgmt();
return false; return false;
} }
NetworkManager::Security8021xSetting::Ptr setting = conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
NetworkManager::Security8021xSetting::Ptr setting =
conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap)) { if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodPeap)) {
qDebug() << "don't have Security8021x connection"; qDebug()<< LOG_FLAG << "don't have Security8021x connection";
return false; return false;
} }
@ -494,24 +528,24 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls
{ {
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid); NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
if (conn.isNull()) { if (conn.isNull()) {
qDebug() << "modifyEnterPriseInfoTtls connection missing"; qDebug()<< LOG_FLAG << "modifyEnterPriseInfoTtls connection missing";
return false; return false;
} }
NetworkManager::WirelessSecuritySetting::Ptr security_sett NetworkManager::WirelessSecuritySetting::Ptr security_sett
= conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>(); = conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast<NetworkManager::WirelessSecuritySetting>();
if (security_sett.isNull()) { if (security_sett.isNull()) {
qDebug() << "don't have WirelessSecurity connection"; qDebug()<< LOG_FLAG << "don't have WirelessSecurity connection";
return false; return false;
} }
if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) { if (security_sett->keyMgmt() != NetworkManager::WirelessSecuritySetting::WpaEap) {
qDebug() << "not wpaeap"<<security_sett->keyMgmt(); qDebug()<< LOG_FLAG << "not wpaeap"<<security_sett->keyMgmt();
return false; return false;
} }
NetworkManager::Security8021xSetting::Ptr setting = conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>(); NetworkManager::Security8021xSetting::Ptr setting = conn->settings()->setting(NetworkManager::Setting::Security8021x).dynamicCast<NetworkManager::Security8021xSetting>();
if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls)) { if (setting.isNull() || !setting->eapMethods().contains(NetworkManager::Security8021xSetting::EapMethod::EapMethodTtls)) {
qDebug() << "don't have Security8021x connection"; qDebug()<< LOG_FLAG << "don't have Security8021x connection";
return false; return false;
} }
@ -524,36 +558,40 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls
} else { } else {
info.authType = KyTtlsAuthMethod::AUTH_NO_EAP; info.authType = KyTtlsAuthMethod::AUTH_NO_EAP;
} }
info.userName = setting->identity(); info.userName = setting->identity();
info.m_passwdFlag = setting->passwordFlags(); info.m_passwdFlag = setting->passwordFlags();
if (!info.m_passwdFlag) { if (!info.m_passwdFlag) {
info.userPWD = m_operation->get8021xPassword(conn->uuid()); info.userPWD = m_operation->get8021xPassword(conn->uuid());
} }
return true; return true;
} }
void KyWirelessNetResource::onConnectionAdd(QString uuid) void KyWirelessNetResource::onConnectionAdd(QString uuid)
{ {
qDebug() << "onConnectionAdd " << uuid; qDebug() << LOG_FLAG << "onConnectionAdd " << uuid;
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid); NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
if (conn.isNull()) { if (conn.isNull()) {
qDebug() << "onConnectionAdd can not find connection" << uuid; qDebug()<< LOG_FLAG << "onConnectionAdd can not find connection" << uuid;
return; return;
} }
NetworkManager::ConnectionSettings::Ptr sett = conn->settings(); NetworkManager::ConnectionSettings::Ptr sett = conn->settings();
if (sett->connectionType() != NetworkManager::ConnectionSettings::ConnectionType::Wireless) { if (sett->connectionType() != NetworkManager::ConnectionSettings::ConnectionType::Wireless) {
qDebug()<< LOG_FLAG << uuid << " is not wireless connection";
return; return;
} }
NetworkManager::WirelessSetting::Ptr wireless_sett = sett->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
NetworkManager::WirelessSetting::Ptr wireless_sett =
sett->setting(NetworkManager::Setting::Wireless).dynamicCast<NetworkManager::WirelessSetting>();
QMap<QString, QString> map; QMap<QString, QString> map;
map.clear(); map.clear();
QMap<QString, QList<KyWirelessNetItem> >::iterator iter = m_WifiNetworkList.begin(); QMap<QString, QList<KyWirelessNetItem> >::iterator iter = m_WifiNetworkList.begin();
while (iter != m_WifiNetworkList.end()) { while (iter != m_WifiNetworkList.end()) {
for(int i = 0; i < iter.value().size(); i++) { for(int i = 0; i < iter.value().size(); i++) {
if (iter.value().at(i).m_NetSsid == wireless_sett->ssid() && (sett->interfaceName() == iter.key() || sett->interfaceName().isEmpty())) { if (iter.value().at(i).m_NetSsid == wireless_sett->ssid()
&& (sett->interfaceName() == iter.key() || sett->interfaceName().isEmpty())) {
QString devIfaceName; QString devIfaceName;
QString ssid; QString ssid;
m_WifiNetworkList[iter.key()][i].m_isConfigured = true; m_WifiNetworkList[iter.key()][i].m_isConfigured = true;
@ -562,7 +600,7 @@ void KyWirelessNetResource::onConnectionAdd(QString uuid)
m_WifiNetworkList[iter.key()][i].m_connDbusPath = conn->path(); m_WifiNetworkList[iter.key()][i].m_connDbusPath = conn->path();
m_WifiNetworkList[iter.key()][i].m_channel = wireless_sett->channel(); m_WifiNetworkList[iter.key()][i].m_channel = wireless_sett->channel();
devIfaceName = sett->interfaceName(); devIfaceName = iter.key();
ssid = iter.value().at(i).m_NetSsid; ssid = iter.value().at(i).m_NetSsid;
map.insert(devIfaceName, ssid); map.insert(devIfaceName, ssid);
@ -571,6 +609,7 @@ void KyWirelessNetResource::onConnectionAdd(QString uuid)
} }
iter++; iter++;
} }
if (!map.isEmpty()) { if (!map.isEmpty()) {
for(auto var = map.cbegin(); var != map.cend(); var++) { for(auto var = map.cbegin(); var != map.cend(); var++) {
QString devIfaceName = var.key(); QString devIfaceName = var.key();
@ -582,18 +621,16 @@ void KyWirelessNetResource::onConnectionAdd(QString uuid)
void KyWirelessNetResource::onConnectionRemove(QString path) void KyWirelessNetResource::onConnectionRemove(QString path)
{ {
qDebug() << "onConnectionRemove remove " << path; qDebug()<< LOG_FLAG << "onConnectionRemove remove " << path;
QMap<QString, QString> map; QMap<QString, QString> map;
map.clear(); map.clear();
QMap<QString, QList<KyWirelessNetItem> >::iterator iter = m_WifiNetworkList.begin(); QMap<QString, QList<KyWirelessNetItem> >::iterator iter = m_WifiNetworkList.begin();
while (iter != m_WifiNetworkList.end()) while (iter != m_WifiNetworkList.end()) {
{ qDebug()<< LOG_FLAG <<"wifi network list key:" << iter.key();
qDebug() << iter.key();
for(int i = 0; i < iter.value().size(); i++) { for(int i = 0; i < iter.value().size(); i++) {
qDebug() << iter.value().at(i).m_connDbusPath; qDebug() << LOG_FLAG << "connection path" << iter.value().at(i).m_connDbusPath;
if (iter.value().at(i).m_connDbusPath == path) if (iter.value().at(i).m_connDbusPath == path) {
{
QString devIfaceName; QString devIfaceName;
QString ssid; QString ssid;
m_WifiNetworkList[iter.key()][i].m_isConfigured = false; m_WifiNetworkList[iter.key()][i].m_isConfigured = false;
@ -610,6 +647,7 @@ void KyWirelessNetResource::onConnectionRemove(QString path)
} }
iter++; iter++;
} }
if (!map.isEmpty()) { if (!map.isEmpty()) {
for(auto var = map.cbegin(); var != map.cend(); var++) { for(auto var = map.cbegin(); var != map.cend(); var++) {
QString devIfaceName = var.key(); QString devIfaceName = var.key();
@ -623,10 +661,10 @@ void KyWirelessNetResource::onConnectionRemove(QString path)
void KyWirelessNetResource::onConnectionUpdate(QString uuid) void KyWirelessNetResource::onConnectionUpdate(QString uuid)
{ {
qDebug() << "onConnectionUpdate " << uuid; qDebug()<< LOG_FLAG << "onConnectionUpdate " << uuid;
NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid); NetworkManager::Connection::Ptr conn = m_networkResourceInstance->getConnect(uuid);
if (conn.isNull()) { if (conn.isNull()) {
qDebug() << "onConnectionAdd can not find connection" << uuid; qDebug()<< LOG_FLAG << "onConnectionAdd can not find connection" << uuid;
return; return;
} }
@ -634,6 +672,7 @@ void KyWirelessNetResource::onConnectionUpdate(QString uuid)
if (sett->connectionType() != NetworkManager::ConnectionSettings::ConnectionType::Wireless) { if (sett->connectionType() != NetworkManager::ConnectionSettings::ConnectionType::Wireless) {
return; return;
} }
m_WifiNetworkList.clear(); m_WifiNetworkList.clear();
kyWirelessNetItemListInit(); kyWirelessNetItemListInit();
emit wifiNetworkUpdate(); emit wifiNetworkUpdate();