From cf088d463f4961092db51d924faac60f869c1d03 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Tue, 13 Sep 2022 17:14:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?wifi=E5=AE=89=E5=85=A8=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=94=B9=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kylinnetworkresourcemanager.cpp | 46 ++++++++++++++++ .../kylinnetworkresourcemanager.h | 4 ++ .../dbus-interface/kywirelessnetresource.cpp | 52 ++++++++++++++++++- .../dbus-interface/kywirelessnetresource.h | 3 +- src/frontend/list-items/wlanlistitem.cpp | 23 +++++++- src/frontend/list-items/wlanlistitem.h | 2 + src/frontend/tab-pages/wlanpage.cpp | 17 ++++-- src/frontend/tab-pages/wlanpage.h | 4 +- 8 files changed, 140 insertions(+), 11 deletions(-) diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp index f45cddc0..8cbf34b2 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp @@ -306,7 +306,20 @@ void KyNetworkResourceManager::addWifiNetwork(NetworkManager::WirelessNetwork::P //device signals connect(net.data(), &NetworkManager::WirelessNetwork::signalStrengthChanged, this, &KyNetworkResourceManager::onUpdateWirelessNet); connect(net.data(), &NetworkManager::WirelessNetwork::referenceAccessPointChanged, this, &KyNetworkResourceManager::onUpdateWirelessNet); + connect(net.data(), &NetworkManager::WirelessNetwork::referenceAccessPointChanged, this, &KyNetworkResourceManager::onReferenceAccessPointChanged); connect(net.data(), &NetworkManager::WirelessNetwork::disappeared, this, &KyNetworkResourceManager::onUpdateWirelessNet); + connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::wpaFlagsChanged, this, [&](NetworkManager::AccessPoint::WpaFlags flags) + { + NetworkManager::AccessPoint *p_wirelessNet = + qobject_cast(sender()); + emit wifiNetworkSecuChange(p_wirelessNet); + }, Qt::UniqueConnection); + connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::rsnFlagsChanged, this, [&](NetworkManager::AccessPoint::WpaFlags flags) + { + NetworkManager::AccessPoint *p_wirelessNet = + qobject_cast(sender()); + emit wifiNetworkSecuChange(p_wirelessNet); + }, Qt::UniqueConnection); } void KyNetworkResourceManager::insertWifiNetworks() @@ -838,6 +851,39 @@ void KyNetworkResourceManager::onWifiNetworkDisappeared(QString const & ssid) return; } +void KyNetworkResourceManager::onReferenceAccessPointChanged() +{ + NetworkManager::WirelessNetwork *p_wirelessNet = + qobject_cast(sender()); + if (nullptr != p_wirelessNet) { + onAccessPointUpdate(p_wirelessNet); + } +} + +void KyNetworkResourceManager::onAccessPointUpdate(NetworkManager::WirelessNetwork * net) +{ + if (nullptr == net) { + return; + } + auto index = std::find(m_wifiNets.cbegin(), m_wifiNets.cend(), net); + if (m_wifiNets.cend() != index) { + if (!net->referenceAccessPoint().isNull()) { + connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::wpaFlagsChanged, this, [&]() + { + NetworkManager::AccessPoint *p_wirelessNet = + qobject_cast(sender()); + emit wifiNetworkSecuChange(p_wirelessNet); + }, Qt::UniqueConnection); + connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::rsnFlagsChanged, this, [&]() + { + NetworkManager::AccessPoint *p_wirelessNet = + qobject_cast(sender()); + emit wifiNetworkSecuChange(p_wirelessNet); + }, Qt::UniqueConnection); + } + } +} + void KyNetworkResourceManager::onUpdateWirelessNet() { NetworkManager::WirelessNetwork *p_wirelessNet = diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.h b/src/backend/dbus-interface/kylinnetworkresourcemanager.h index aa89d00d..743f74a1 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.h +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.h @@ -122,6 +122,7 @@ signals: void wifiNetworkRemoved(QString, QString); void wifiNetworkAdded(QString, QString); void wifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net); + void wifiNetworkSecuChange(NetworkManager::AccessPoint *); void wifiNetworkDeviceDisappear(); void wifiEnabledChanged(bool); @@ -193,6 +194,9 @@ private: void onWifiNetworkUpdate(NetworkManager::WirelessNetwork * net); void onWifiNetworkRemove(NetworkManager::Device * dev, QString const & ssid); + void onAccessPointUpdate(NetworkManager::WirelessNetwork * net); + void onReferenceAccessPointChanged(); + private: bool m_initFinished = false; diff --git a/src/backend/dbus-interface/kywirelessnetresource.cpp b/src/backend/dbus-interface/kywirelessnetresource.cpp index ac3e3046..bbab763b 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.cpp +++ b/src/backend/dbus-interface/kywirelessnetresource.cpp @@ -21,6 +21,9 @@ #include "kylinutil.h" #define LOG_FLAG "[KyWirelessNetResource]" +const QString ENTERPRICE_TYPE = "802.1X"; +const QString WPA1_AND_WPA2 = "WPA"; +const QString WPA3 = "WPA3"; static bool subWifiListSort(const KyWirelessNetItem info1, const KyWirelessNetItem info2) { @@ -63,6 +66,8 @@ KyWirelessNetResource::KyWirelessNetResource(QObject *parent) this, &KyWirelessNetResource::onWifiNetworkRemoved, Qt::ConnectionType::DirectConnection); connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkPropertyChange, this, &KyWirelessNetResource::onWifiNetworkPropertyChange, Qt::ConnectionType::DirectConnection); + connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkSecuChange, + this, &KyWirelessNetResource::onWifiNetworkSecuChange, Qt::ConnectionType::DirectConnection); connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkDeviceDisappear, this, &KyWirelessNetResource::onWifiNetworkDeviceDisappear, Qt::ConnectionType::DirectConnection); @@ -426,12 +431,47 @@ void KyWirelessNetResource::onWifiNetworkRemoved(QString devIfaceName, QString s } } +void KyWirelessNetResource::onWifiNetworkSecuChange(NetworkManager::AccessPoint *accessPointPtr) +{ + QString secuType = enumToQstring(accessPointPtr->capabilities(), + accessPointPtr->wpaFlags(), + accessPointPtr->rsnFlags()); + + + QMap >::iterator iter = m_WifiNetworkList.begin(); + while (iter != m_WifiNetworkList.end()) { + QList::iterator itemIter = iter.value().begin(); + while (itemIter != iter.value().end()) { + if (itemIter->m_NetSsid == accessPointPtr->ssid()) { + QString devName = iter.key(); + itemIter->m_secuType = secuType; + if (secuType.indexOf(ENTERPRICE_TYPE) >= 0) { + itemIter->m_kySecuType = WPA_AND_WPA2_ENTERPRISE; + } else if (secuType.indexOf(WPA3) >= 0) { + itemIter->m_kySecuType = WPA3_PERSONAL; + } else if (secuType.indexOf(WPA1_AND_WPA2) >= 0) { + itemIter->m_kySecuType = WPA_AND_WPA2_PERSONAL; + } else { + itemIter->m_kySecuType = NONE; + } + //qDebug() << "!!!!" << itemIter->m_NetSsid << itemIter->m_secuType << itemIter->m_kySecuType; + emit secuTypeChange(devName, accessPointPtr->ssid(), secuType); + break; + } + itemIter++; + } + iter++; + } + +} + void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net) { if (nullptr == net) { return; } + qDebug() << "onWifiNetworkPropertyChange" << net->ssid(); NetworkManager::AccessPoint::Ptr accessPointPtr = net->referenceAccessPoint(); QByteArray rawSsid = accessPointPtr->rawSsid(); QString wifiSsid = getSsidFromByteArray(rawSsid); @@ -460,7 +500,17 @@ void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::Wireless accessPointPtr->wpaFlags(), accessPointPtr->rsnFlags()); if (iter->m_secuType != secuType) { + //qDebug() << "!!!!secuTypeChange" << wifiSsid << iter->m_secuType << "change to " << secuType; iter->m_secuType = secuType; + if (secuType.indexOf(ENTERPRICE_TYPE) >= 0) { + iter->m_kySecuType = WPA_AND_WPA2_ENTERPRISE; + } else if (secuType.indexOf(WPA3) >= 0) { + iter->m_kySecuType = WPA3_PERSONAL; + } else if (secuType.indexOf(WPA1_AND_WPA2) >= 0) { + iter->m_kySecuType = WPA_AND_WPA2_PERSONAL; + } else { + iter->m_kySecuType = NONE; + } emit secuTypeChange(devIface, wifiSsid, secuType); } @@ -693,7 +743,7 @@ void KyWirelessNetResource::onConnectionRemove(QString path) for(auto var = map.cbegin(); var != map.cend(); var++) { QString devIfaceName = var.key(); QString ssid = var.value(); - emit connectionRemove(devIfaceName, ssid); + emit connectionRemove(devIfaceName, ssid, path); } } diff --git a/src/backend/dbus-interface/kywirelessnetresource.h b/src/backend/dbus-interface/kywirelessnetresource.h index 660b565f..8196fc65 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.h +++ b/src/backend/dbus-interface/kywirelessnetresource.h @@ -64,6 +64,7 @@ public slots: void onWifiNetworkAdded(QString, QString); void onWifiNetworkRemoved(QString, QString); void onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net); + void onWifiNetworkSecuChange(NetworkManager::AccessPoint *accessPointPtr); void onWifiNetworkDeviceDisappear(); void onConnectionAdd(QString uuid); @@ -78,7 +79,7 @@ signals: void signalStrengthChange(QString, QString, int); void bssidChange(QString, QString, QString); void secuTypeChange(QString, QString, QString); - void connectionRemove(QString, QString); + void connectionRemove(QString, QString, QString); void connectionAdd(QString, QString); void wifiNetworkUpdate(); void wifiNetworkAdd(QString, KyWirelessNetItem&); diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index 85191a10..9b33f97b 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -28,6 +28,10 @@ #define ENABLE_BUTTON_COLOR qApp->palette().highlight().color() #define UNABLE_BUTTON_COLOR qApp->palette().button().color() +const QString ENTERPRICE_TYPE = "802.1X"; +const QString WPA1_AND_WPA2 = "WPA"; +const QString WPA3 = "WPA3"; + WlanListItem::WlanListItem(KyWirelessNetItem &wirelessNetItem, QString device, bool isApMode, QWidget *parent) : WlanListItem(wirelessNetItem, device, parent) { @@ -84,6 +88,11 @@ QString WlanListItem::getUuid() return m_wirelessNetItem.m_connectUuid; } +QString WlanListItem::getPath() +{ + return m_wirelessNetItem.m_connDbusPath; +} + void WlanListItem::setSignalStrength(const int &signal) { m_wirelessNetItem.m_signalStrength = signal; @@ -467,7 +476,7 @@ void WlanListItem::onNetButtonClicked() } else { qDebug() << "KeyMgmt not support now " << type; } - + //qDebug() << "!!!!" << m_wirelessNetItem.m_kySecuType << kySecuType; //有配置或者无密码的wifi直接连接 if (m_wirelessNetItem.m_isConfigured) { if (m_wirelessNetItem.m_kySecuType == kySecuType) { @@ -512,7 +521,7 @@ void WlanListItem::updateWirelessNetSecurity(QString ssid, QString securityType) } qDebug() << LOG_FLAG << "Security changed! ssid = " << m_wirelessNetItem.m_NetSsid - << "; security = " << m_wirelessNetItem.m_secuType << "." <= 0) { + m_wirelessNetItem.m_kySecuType = WPA_AND_WPA2_ENTERPRISE; + } else if (securityType.indexOf(WPA3) >= 0) { + m_wirelessNetItem.m_kySecuType = WPA3_PERSONAL; + } else if ( securityType.indexOf(WPA1_AND_WPA2) >= 0) { + m_wirelessNetItem.m_kySecuType = WPA_AND_WPA2_PERSONAL; + } else { + m_wirelessNetItem.m_kySecuType = NONE; + } + return; } diff --git a/src/frontend/list-items/wlanlistitem.h b/src/frontend/list-items/wlanlistitem.h index e8acc822..ee501d63 100644 --- a/src/frontend/list-items/wlanlistitem.h +++ b/src/frontend/list-items/wlanlistitem.h @@ -61,6 +61,8 @@ public: QString getSsid(); QString getUuid(); + QString getPath(); + void setSignalStrength(const int &signal); int getSignalStrength(); diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 188111c1..4ad8f11e 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -606,12 +606,12 @@ void WlanPage::onConnectionAdd(QString deviceName, QString ssid) return; } -void WlanPage::onConnectionRemove(QString deviceName, QString ssid) +void WlanPage::onConnectionRemove(QString deviceName, QString ssid, QString path) { qDebug() << LOG_FLAG << "one connection is removed, it's ssid " << ssid << "device name"<< deviceName; if (deviceName == m_currentDevice) { if (m_activateConnectionItemMap.contains(ssid)) { - updateWirelessNetArea(nullptr, ssid, deviceName); + updateWirelessNetArea(nullptr, ssid, deviceName, path); } updateWlanListItem(ssid); } @@ -872,7 +872,7 @@ void WlanPage::updateActivatedArea(QString uuid, QString ssid, QString devName) return; } -void WlanPage::updateWirelessNetArea(QString uuid, QString ssid, QString devName) +void WlanPage::updateWirelessNetArea(QString uuid, QString ssid, QString devName, QString path) { if(m_wirelessNetItemMap.contains(ssid)) { return; @@ -889,7 +889,12 @@ void WlanPage::updateWirelessNetArea(QString uuid, QString ssid, QString devName qWarning() << LOG_FLAG << "p_wlanItem is null"; return; } - if (p_wlanItem->getUuid() == uuid) { + + if (p_wlanItem->getUuid() == uuid || uuid.isEmpty()) { + if (uuid.isEmpty() && p_wlanItem->getPath() != path) { + return; + } + deleteWirelessItemFormMap(m_activateConnectionItemMap, m_activatedNetListWidget, ssid); QListWidgetItem *p_activeListWidgetItem = addEmptyItem(m_activatedNetListWidget); m_activateConnectionItemMap.insert(EMPTY_SSID, p_activeListWidgetItem); @@ -1005,7 +1010,9 @@ void WlanPage::onConnectionStateChanged(QString uuid, if (devName.isEmpty()) { devName = m_currentDevice; } - updateWirelessNetArea(uuid, ssid, devName); + + updateWirelessNetArea(uuid, ssid, devName,""); + if (m_wirelessNetItemMap.contains(ssid)) { QListWidgetItem *p_listWidgetItem = m_wirelessNetItemMap.value(ssid); updateWlanItemState(m_inactivatedNetListWidget, p_listWidgetItem, Deactivated); diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index c4ee3d38..11c47ba8 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -108,7 +108,7 @@ private slots: void onWlanRemoved(QString interface, QString ssid); void onConnectionAdd(QString deviceName, QString ssid); - void onConnectionRemove(QString deviceName, QString ssid); + void onConnectionRemove(QString deviceName, QString ssid, QString path); void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType); void onDeviceRemove(QString deviceName); @@ -167,7 +167,7 @@ private: void constructActivateConnectionArea(); void updateActivatedArea(QString uuid, QString ssid, QString devName); - void updateWirelessNetArea(QString uuid, QString ssid, QString devName); + void updateWirelessNetArea(QString uuid, QString ssid, QString devName, QString path); void addDeviceToCombox(QString deviceName); void deleteDeviceFromCombox(QString deviceName); From 3ae5abacd70f073d528eec513b2c6d0defa4147d Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Thu, 15 Sep 2022 10:15:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E7=9A=84=E6=95=B0=E6=8D=AE=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E6=96=B9=20=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kylinnetworkresourcemanager.cpp | 39 +++++++------------ .../kylinnetworkresourcemanager.h | 1 + .../dbus-interface/kywirelessnetitem.cpp | 28 +++++++++---- .../dbus-interface/kywirelessnetitem.h | 1 + .../dbus-interface/kywirelessnetresource.cpp | 21 ++-------- src/frontend/list-items/wlanlistitem.cpp | 10 +---- 6 files changed, 42 insertions(+), 58 deletions(-) diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp index 8cbf34b2..3e80ea59 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp @@ -308,18 +308,10 @@ void KyNetworkResourceManager::addWifiNetwork(NetworkManager::WirelessNetwork::P connect(net.data(), &NetworkManager::WirelessNetwork::referenceAccessPointChanged, this, &KyNetworkResourceManager::onUpdateWirelessNet); connect(net.data(), &NetworkManager::WirelessNetwork::referenceAccessPointChanged, this, &KyNetworkResourceManager::onReferenceAccessPointChanged); connect(net.data(), &NetworkManager::WirelessNetwork::disappeared, this, &KyNetworkResourceManager::onUpdateWirelessNet); - connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::wpaFlagsChanged, this, [&](NetworkManager::AccessPoint::WpaFlags flags) - { - NetworkManager::AccessPoint *p_wirelessNet = - qobject_cast(sender()); - emit wifiNetworkSecuChange(p_wirelessNet); - }, Qt::UniqueConnection); - connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::rsnFlagsChanged, this, [&](NetworkManager::AccessPoint::WpaFlags flags) - { - NetworkManager::AccessPoint *p_wirelessNet = - qobject_cast(sender()); - emit wifiNetworkSecuChange(p_wirelessNet); - }, Qt::UniqueConnection); + connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::wpaFlagsChanged, this, &KyNetworkResourceManager::onWifiNetworkSecuChang, + Qt::UniqueConnection); + connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::rsnFlagsChanged, this, &KyNetworkResourceManager::onWifiNetworkSecuChang, + Qt::UniqueConnection); } void KyNetworkResourceManager::insertWifiNetworks() @@ -868,18 +860,10 @@ void KyNetworkResourceManager::onAccessPointUpdate(NetworkManager::WirelessNetwo auto index = std::find(m_wifiNets.cbegin(), m_wifiNets.cend(), net); if (m_wifiNets.cend() != index) { if (!net->referenceAccessPoint().isNull()) { - connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::wpaFlagsChanged, this, [&]() - { - NetworkManager::AccessPoint *p_wirelessNet = - qobject_cast(sender()); - emit wifiNetworkSecuChange(p_wirelessNet); - }, Qt::UniqueConnection); - connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::rsnFlagsChanged, this, [&]() - { - NetworkManager::AccessPoint *p_wirelessNet = - qobject_cast(sender()); - emit wifiNetworkSecuChange(p_wirelessNet); - }, Qt::UniqueConnection); + connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::wpaFlagsChanged, this, &KyNetworkResourceManager::onWifiNetworkSecuChang, + Qt::UniqueConnection); + connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::rsnFlagsChanged, this, &KyNetworkResourceManager::onWifiNetworkSecuChang, + Qt::UniqueConnection); } } } @@ -895,6 +879,13 @@ void KyNetworkResourceManager::onUpdateWirelessNet() return; } +void KyNetworkResourceManager::onWifiNetworkSecuChang() +{ + NetworkManager::AccessPoint *p_wirelessNet = + qobject_cast(sender()); + emit wifiNetworkSecuChange(p_wirelessNet); +} + void KyNetworkResourceManager::onDeviceAdded(QString const & uni) { qDebug()<< "onDeviceAdded"<referenceAccessPoint()->wpaFlags(); NetworkManager::AccessPoint::WpaFlags rsnFlag = net->referenceAccessPoint()->rsnFlags(); m_secuType = enumToQstring(cap, wpaFlag, rsnFlag); - if (m_secuType.indexOf(ENTERPRICE_TYPE) >= 0) { - m_kySecuType = WPA_AND_WPA2_ENTERPRISE; - } else if (m_secuType.indexOf(WPA3) >= 0) { - m_kySecuType = WPA3_PERSONAL; - } else if ( m_secuType.indexOf(WPA1_AND_WPA2) >= 0) { - m_kySecuType = WPA_AND_WPA2_PERSONAL; - } +// if (m_secuType.indexOf(ENTERPRICE_TYPE) >= 0) { +// m_kySecuType = WPA_AND_WPA2_ENTERPRISE; +// } else if (m_secuType.indexOf(WPA3) >= 0) { +// m_kySecuType = WPA3_PERSONAL; +// } else if ( m_secuType.indexOf(WPA1_AND_WPA2) >= 0) { +// m_kySecuType = WPA_AND_WPA2_PERSONAL; +// } + setKySecuType(m_secuType); m_bssid = net->referenceAccessPoint()->hardwareAddress(); m_device = net->device(); m_uni = net->referenceAccessPoint()->uni(); @@ -151,3 +152,16 @@ int KyWirelessNetItem::getCategory(QString uni) } } + +void KyWirelessNetItem::setKySecuType(QString strSecuType) +{ + if (strSecuType.indexOf(ENTERPRICE_TYPE) >= 0) { + m_kySecuType = WPA_AND_WPA2_ENTERPRISE; + } else if (strSecuType.indexOf(WPA3) >= 0) { + m_kySecuType = WPA3_PERSONAL; + } else if ( strSecuType.indexOf(WPA1_AND_WPA2) >= 0) { + m_kySecuType = WPA_AND_WPA2_PERSONAL; + } else { + m_kySecuType = NONE; + } +} diff --git a/src/backend/dbus-interface/kywirelessnetitem.h b/src/backend/dbus-interface/kywirelessnetitem.h index 0eb10690..36eecc76 100644 --- a/src/backend/dbus-interface/kywirelessnetitem.h +++ b/src/backend/dbus-interface/kywirelessnetitem.h @@ -55,6 +55,7 @@ public: uint m_channel; int getCategory(QString uni); + void setKySecuType(QString strSecuType); private: KyNetworkResourceManager *m_networkResourceInstance = nullptr; diff --git a/src/backend/dbus-interface/kywirelessnetresource.cpp b/src/backend/dbus-interface/kywirelessnetresource.cpp index bbab763b..7ed1e8a0 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.cpp +++ b/src/backend/dbus-interface/kywirelessnetresource.cpp @@ -445,15 +445,7 @@ void KyWirelessNetResource::onWifiNetworkSecuChange(NetworkManager::AccessPoint if (itemIter->m_NetSsid == accessPointPtr->ssid()) { QString devName = iter.key(); itemIter->m_secuType = secuType; - if (secuType.indexOf(ENTERPRICE_TYPE) >= 0) { - itemIter->m_kySecuType = WPA_AND_WPA2_ENTERPRISE; - } else if (secuType.indexOf(WPA3) >= 0) { - itemIter->m_kySecuType = WPA3_PERSONAL; - } else if (secuType.indexOf(WPA1_AND_WPA2) >= 0) { - itemIter->m_kySecuType = WPA_AND_WPA2_PERSONAL; - } else { - itemIter->m_kySecuType = NONE; - } + itemIter->setKySecuType(secuType); //qDebug() << "!!!!" << itemIter->m_NetSsid << itemIter->m_secuType << itemIter->m_kySecuType; emit secuTypeChange(devName, accessPointPtr->ssid(), secuType); break; @@ -502,15 +494,8 @@ void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::Wireless if (iter->m_secuType != secuType) { //qDebug() << "!!!!secuTypeChange" << wifiSsid << iter->m_secuType << "change to " << secuType; iter->m_secuType = secuType; - if (secuType.indexOf(ENTERPRICE_TYPE) >= 0) { - iter->m_kySecuType = WPA_AND_WPA2_ENTERPRISE; - } else if (secuType.indexOf(WPA3) >= 0) { - iter->m_kySecuType = WPA3_PERSONAL; - } else if (secuType.indexOf(WPA1_AND_WPA2) >= 0) { - iter->m_kySecuType = WPA_AND_WPA2_PERSONAL; - } else { - iter->m_kySecuType = NONE; - } + iter->setKySecuType(secuType); + emit secuTypeChange(devIface, wifiSsid, secuType); } diff --git a/src/frontend/list-items/wlanlistitem.cpp b/src/frontend/list-items/wlanlistitem.cpp index 9b33f97b..56b83382 100644 --- a/src/frontend/list-items/wlanlistitem.cpp +++ b/src/frontend/list-items/wlanlistitem.cpp @@ -530,15 +530,7 @@ void WlanListItem::updateWirelessNetSecurity(QString ssid, QString securityType) refreshIcon(false); } - if (securityType.indexOf(ENTERPRICE_TYPE) >= 0) { - m_wirelessNetItem.m_kySecuType = WPA_AND_WPA2_ENTERPRISE; - } else if (securityType.indexOf(WPA3) >= 0) { - m_wirelessNetItem.m_kySecuType = WPA3_PERSONAL; - } else if ( securityType.indexOf(WPA1_AND_WPA2) >= 0) { - m_wirelessNetItem.m_kySecuType = WPA_AND_WPA2_PERSONAL; - } else { - m_wirelessNetItem.m_kySecuType = NONE; - } + m_wirelessNetItem.setKySecuType(securityType); return; }