From 8714282bfc8c058b94923b0d4bd791ee7466ee97 Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Thu, 9 Feb 2023 16:12:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kylinnetworkdeviceresource.cpp | 8 +- .../kylinnetworkresourcemanager.cpp | 83 +++++++++++++------ .../kylinnetworkresourcemanager.h | 4 +- .../dbus-interface/kywirelessnetitem.cpp | 25 ------ .../dbus-interface/kywirelessnetitem.h | 2 - .../dbus-interface/kywirelessnetresource.cpp | 72 +++++++--------- .../dbus-interface/kywirelessnetresource.h | 2 +- src/frontend/list-items/listitem.cpp | 4 +- src/frontend/tab-pages/wlanpage.cpp | 4 - 9 files changed, 98 insertions(+), 106 deletions(-) diff --git a/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp b/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp index 3e78bfbb..fb7f8a62 100644 --- a/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp +++ b/src/backend/dbus-interface/kylinnetworkdeviceresource.cpp @@ -36,14 +36,14 @@ KyNetworkDeviceResourse::KyNetworkDeviceResourse(QObject *parent) : QObject(pare initDeviceMap(); connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceAdd, - this, &KyNetworkDeviceResourse::onDeviceAdd, Qt::ConnectionType::DirectConnection); + this, &KyNetworkDeviceResourse::onDeviceAdd/*, Qt::ConnectionType::DirectConnection*/); connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceRemove, - this, &KyNetworkDeviceResourse::onDeviceRemove, Qt::ConnectionType::DirectConnection); + this, &KyNetworkDeviceResourse::onDeviceRemove/*, Qt::ConnectionType::DirectConnection*/); connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceUpdate, - this, &KyNetworkDeviceResourse::onDeviceUpdate, Qt::ConnectionType::DirectConnection); + this, &KyNetworkDeviceResourse::onDeviceUpdate/*, Qt::ConnectionType::DirectConnection*/); connect(m_networkResourceInstance, &KyNetworkResourceManager::stateChanged, - this, &KyNetworkDeviceResourse::stateChanged, Qt::ConnectionType::DirectConnection); + this, &KyNetworkDeviceResourse::stateChanged/*, Qt::ConnectionType::DirectConnection*/); connect(m_networkResourceInstance, &KyNetworkResourceManager::deviceCarrierChanage, this, &KyNetworkDeviceResourse::carrierChanage); diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp index 0737a0bd..d38ee6d2 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp @@ -26,6 +26,32 @@ #define LOG_FLAG "[KyNetworkResourceManager]" + +QString enumToQstring(NetworkManager::AccessPoint::Capabilities cap, NetworkManager::AccessPoint::WpaFlags wpa_flags,NetworkManager::AccessPoint::WpaFlags rsn_flags) +{ + QString out; + if ( (cap & NM_802_11_AP_FLAGS_PRIVACY) + && (wpa_flags == NM_802_11_AP_SEC_NONE) + && (rsn_flags == NM_802_11_AP_SEC_NONE)) { + out += "WEP "; + } + if (wpa_flags != NM_802_11_AP_SEC_NONE) { + out += "WPA1 "; + } + if ((rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) + || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { + out += "WPA2 "; + } + if (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_SAE) { + out += "WPA3 "; + } + if ( (wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X) + || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { + out += "802.1X "; + } + return out; +} + KyNetworkResourceManager* KyNetworkResourceManager::m_pInstance = nullptr; KyNetworkResourceManager* KyNetworkResourceManager::getInstance() @@ -778,37 +804,46 @@ void KyNetworkResourceManager::onWifiNetworkUpdate(NetworkManager::WirelessNetwo return; } + bool bFlag = false; + QString devIface; + NetworkManager::Device::Ptr dev = findDeviceUni(net->device()); + if(dev.isNull()) { + qDebug()<< LOG_FLAG << "device invalid"; + bFlag = true; + } else { + devIface = dev->interfaceName(); + } + if(bFlag) { + //device invalid + qDebug() << LOG_FLAG << "wifiNetworkDeviceDisappear"; + Q_EMIT wifiNetworkDeviceDisappear(); + return; + } + + auto index = std::find(m_wifiNets.cbegin(), m_wifiNets.cend(), net); if (m_wifiNets.cend() != index) { if (net->accessPoints().isEmpty()) { - //Q_EMIT - bool bFlag = false; - QString devIface; - NetworkManager::Device::Ptr dev = findDeviceUni(net->device()); - if(dev.isNull()) { - qDebug()<< LOG_FLAG << "device invalid"; - bFlag = true; - } else { - devIface = dev->interfaceName(); - } - //remove auto pos = index - m_wifiNets.cbegin(); removeWifiNetwork(pos); - if(bFlag) { - //device invalid - qDebug() << LOG_FLAG << "wifiNetworkDeviceDisappear"; - Q_EMIT wifiNetworkDeviceDisappear(); - } else { - qDebug()<< LOG_FLAG << "wifiNetwork disappear" << net << net->ssid(); - NetworkManager::AccessPoint::Ptr accessPoitPtr = net->referenceAccessPoint(); - QByteArray rawSsid = accessPoitPtr->rawSsid(); - QString wifiSsid = getSsidFromByteArray(rawSsid); - Q_EMIT wifiNetworkRemoved(devIface, wifiSsid); - } + qDebug()<< LOG_FLAG << "wifiNetwork disappear" << net << net->ssid(); + NetworkManager::AccessPoint::Ptr accessPoitPtr = net->referenceAccessPoint(); + QByteArray rawSsid = accessPoitPtr->rawSsid(); + QString wifiSsid = getSsidFromByteArray(rawSsid); + Q_EMIT wifiNetworkRemoved(devIface, wifiSsid); } else { - qDebug()<< LOG_FLAG << "wifiNetworkPropertyChange " << net << net->ssid(); - Q_EMIT wifiNetworkPropertyChange(net); + NetworkManager::AccessPoint::Ptr accessPointPtr = net->referenceAccessPoint(); + if (accessPointPtr.isNull()) { + return; + } + QByteArray rawSsid = accessPointPtr->rawSsid(); + QString wifiSsid = getSsidFromByteArray(rawSsid); + QString bssid = accessPointPtr->hardwareAddress(); + QString secuType = enumToQstring(accessPointPtr->capabilities(), + accessPointPtr->wpaFlags(), + accessPointPtr->rsnFlags()); + Q_EMIT wifiNetworkPropertyChange(devIface, wifiSsid, net->signalStrength(), bssid, secuType); } } diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.h b/src/backend/dbus-interface/kylinnetworkresourcemanager.h index 0de8ce9a..b43b0dcf 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.h +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.h @@ -45,6 +45,8 @@ #include #include +QString enumToQstring(NetworkManager::AccessPoint::Capabilities cap, NetworkManager::AccessPoint::WpaFlags wpa_flags,NetworkManager::AccessPoint::WpaFlags rsn_flags); + class KyNetworkResourceManager : public QObject { Q_OBJECT @@ -122,7 +124,7 @@ Q_SIGNALS: //to KyWirelessNetResource void wifiNetworkRemoved(QString, QString); void wifiNetworkAdded(QString, QString); - void wifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net); + void wifiNetworkPropertyChange(QString, QString, int, QString, QString); void wifiNetworkSecuChange(NetworkManager::AccessPoint *); void wifiNetworkDeviceDisappear(); void wifiEnabledChanged(bool); diff --git a/src/backend/dbus-interface/kywirelessnetitem.cpp b/src/backend/dbus-interface/kywirelessnetitem.cpp index 9d823693..39e6dad2 100644 --- a/src/backend/dbus-interface/kywirelessnetitem.cpp +++ b/src/backend/dbus-interface/kywirelessnetitem.cpp @@ -27,31 +27,6 @@ const QString WPA3 = "WPA3"; #define FREQ_5GHZ 5000 -QString enumToQstring(NetworkManager::AccessPoint::Capabilities cap, NetworkManager::AccessPoint::WpaFlags wpa_flags,NetworkManager::AccessPoint::WpaFlags rsn_flags) -{ - QString out; - if ( (cap & NM_802_11_AP_FLAGS_PRIVACY) - && (wpa_flags == NM_802_11_AP_SEC_NONE) - && (rsn_flags == NM_802_11_AP_SEC_NONE)) { - out += "WEP "; - } - if (wpa_flags != NM_802_11_AP_SEC_NONE) { - out += "WPA1 "; - } - if ((rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) - || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { - out += "WPA2 "; - } - if (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_SAE) { - out += "WPA3 "; - } - if ( (wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X) - || (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { - out += "802.1X "; - } - return out; -} - KyWirelessNetItem::KyWirelessNetItem(NetworkManager::WirelessNetwork::Ptr net) { m_networkResourceInstance = KyNetworkResourceManager::getInstance(); diff --git a/src/backend/dbus-interface/kywirelessnetitem.h b/src/backend/dbus-interface/kywirelessnetitem.h index 4a6716f4..533e6ca6 100644 --- a/src/backend/dbus-interface/kywirelessnetitem.h +++ b/src/backend/dbus-interface/kywirelessnetitem.h @@ -25,8 +25,6 @@ #include "kylinnetworkresourcemanager.h" #include "kywirelessconnectoperation.h" -QString enumToQstring(NetworkManager::AccessPoint::Capabilities, NetworkManager::AccessPoint::WpaFlags, NetworkManager::AccessPoint::WpaFlags); - class KyWirelessNetItem { public: diff --git a/src/backend/dbus-interface/kywirelessnetresource.cpp b/src/backend/dbus-interface/kywirelessnetresource.cpp index e851b539..2ec9bcf0 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.cpp +++ b/src/backend/dbus-interface/kywirelessnetresource.cpp @@ -61,15 +61,15 @@ KyWirelessNetResource::KyWirelessNetResource(QObject *parent) //TODO:connect device signal connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkAdded, - this, &KyWirelessNetResource::onWifiNetworkAdded, Qt::ConnectionType::DirectConnection); + this, &KyWirelessNetResource::onWifiNetworkAdded/*, Qt::ConnectionType::DirectConnection*/); connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkRemoved, - this, &KyWirelessNetResource::onWifiNetworkRemoved, Qt::ConnectionType::DirectConnection); + this, &KyWirelessNetResource::onWifiNetworkRemoved/*, Qt::ConnectionType::DirectConnection*/); connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkPropertyChange, - this, &KyWirelessNetResource::onWifiNetworkPropertyChange, Qt::ConnectionType::DirectConnection); + this, &KyWirelessNetResource::onWifiNetworkPropertyChange/*, Qt::ConnectionType::DirectConnection*/); connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkSecuChange, - this, &KyWirelessNetResource::onWifiNetworkSecuChange, Qt::ConnectionType::DirectConnection); + this, &KyWirelessNetResource::onWifiNetworkSecuChange/*, Qt::ConnectionType::DirectConnection*/); connect(m_networkResourceInstance, &KyNetworkResourceManager::wifiNetworkDeviceDisappear, - this, &KyWirelessNetResource::onWifiNetworkDeviceDisappear, Qt::ConnectionType::DirectConnection); + this, &KyWirelessNetResource::onWifiNetworkDeviceDisappear/*, Qt::ConnectionType::DirectConnection*/); connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionAdd, this, &KyWirelessNetResource::onConnectionAdd); @@ -457,50 +457,36 @@ void KyWirelessNetResource::onWifiNetworkSecuChange(NetworkManager::AccessPoint } -void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net) +void KyWirelessNetResource::onWifiNetworkPropertyChange(QString interface, QString ssid, int signal, QString bssid, QString sec) { - if (nullptr == net) { - return; - } - qDebug() << "onWifiNetworkPropertyChange" << net->ssid(); - NetworkManager::AccessPoint::Ptr accessPointPtr = net->referenceAccessPoint(); - QByteArray rawSsid = accessPointPtr->rawSsid(); - QString wifiSsid = getSsidFromByteArray(rawSsid); + if (m_WifiNetworkList.contains(interface)) { + QList::iterator iter = m_WifiNetworkList[interface].begin(); + while (iter != m_WifiNetworkList[interface].end()) { + qDebug() << iter->m_NetSsid; + if (iter->m_NetSsid == ssid) { + // qDebug()<< LOG_FLAG <<"recive properity changed signal, sender is" << iter->m_NetSsid; + if (iter->m_signalStrength != signal) { + iter->m_signalStrength = signal; + Q_EMIT signalStrengthChange(interface, ssid, iter->m_signalStrength); + } - if (net->device().isEmpty()) { - return; - } + if (iter->m_bssid != bssid) { + qDebug() << "bssid"; + iter->m_bssid = bssid; + Q_EMIT bssidChange(interface, ssid, iter->m_bssid); + } - QString devIface = m_networkResourceInstance->findDeviceUni(net->device())->interfaceName(); - if (m_WifiNetworkList.contains(devIface)) { - QList::iterator iter = m_WifiNetworkList[devIface].begin(); - while (iter != m_WifiNetworkList[devIface].end()) { - if (iter->m_NetSsid == wifiSsid) { -// qDebug()<< LOG_FLAG <<"recive properity changed signal, sender is" << iter->m_NetSsid; - if (iter->m_signalStrength != net->signalStrength()) { - iter->m_signalStrength = net->signalStrength(); - Q_EMIT signalStrengthChange(devIface, wifiSsid, iter->m_signalStrength); - } + if (iter->m_secuType != sec) { + iter->setKySecuType(sec); + Q_EMIT secuTypeChange(interface, ssid, sec); + } - if (iter->m_bssid != accessPointPtr->hardwareAddress()) { - iter->m_bssid = accessPointPtr->hardwareAddress(); - Q_EMIT bssidChange(devIface, wifiSsid, iter->m_bssid); - } + break; + } - QString secuType = enumToQstring(accessPointPtr->capabilities(), - accessPointPtr->wpaFlags(), - accessPointPtr->rsnFlags()); - if (iter->m_secuType != secuType) { - //qDebug() << "!!!!secuTypeChange" << wifiSsid << iter->m_secuType << "change to " << secuType; - iter->setKySecuType(secuType); - Q_EMIT secuTypeChange(devIface, wifiSsid, secuType); - } - - break; - } - iter++; - } + iter++; + } } } diff --git a/src/backend/dbus-interface/kywirelessnetresource.h b/src/backend/dbus-interface/kywirelessnetresource.h index 807746d0..7afe52fe 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.h +++ b/src/backend/dbus-interface/kywirelessnetresource.h @@ -63,7 +63,7 @@ private: public Q_SLOTS: void onWifiNetworkAdded(QString, QString); void onWifiNetworkRemoved(QString, QString); - void onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net); + void onWifiNetworkPropertyChange(QString interface, QString ssid, int signal, QString bssid, QString sec); void onWifiNetworkSecuChange(NetworkManager::AccessPoint *accessPointPtr); void onWifiNetworkDeviceDisappear(); diff --git a/src/frontend/list-items/listitem.cpp b/src/frontend/list-items/listitem.cpp index 5fbb71d4..954c0133 100644 --- a/src/frontend/list-items/listitem.cpp +++ b/src/frontend/list-items/listitem.cpp @@ -276,8 +276,8 @@ void ListItem::initUI() m_lbLoadDown->setFont(font); m_lbLoadUp->setText("0KB/s"); m_lbLoadDown->setText("0KB/s"); - m_lbLoadDownImg->setPixmap(QPixmap(":/res/x/load-down.png")); - m_lbLoadUpImg->setPixmap(QPixmap(":/res/x/load-up.png")); + m_lbLoadDownImg->setPixmap(QPixmap(QLatin1String(":/res/x/load-down.png"))); + m_lbLoadUpImg->setPixmap(QPixmap(QLatin1String(":/res/x/load-up.png"))); m_hItemLayout->addWidget(m_netButton); m_hItemLayout->addWidget(m_nameLabel); diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index be168004..b91789a4 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -387,10 +387,8 @@ void WlanPage::clearWirelessNetItemMap(QMap &wireless wirelessListWidget->removeItemWidget(p_listWidgetItem); delete p_wlanItem; - p_wlanItem = nullptr; delete p_listWidgetItem; - p_listWidgetItem = nullptr; iter = wirelessNetItem.erase(iter); } @@ -418,10 +416,8 @@ void WlanPage::deleteWirelessItemFormMap(QMap &wirele wirelessListWidget->takeItem(wirelessListWidget->row(p_listWidgetItem)); delete p_wlanItem; - p_wlanItem = nullptr; delete p_listWidgetItem; - p_listWidgetItem = nullptr; if (m_inactivatedNetListWidget->count() <= MAX_ITEMS) { m_inactivatedNetListWidget->setFixedWidth(MIN_WIDTH); From b593dac991b80472409339b7d39d439efd936cba Mon Sep 17 00:00:00 2001 From: jzxc95 <907297917@qq.com> Date: Thu, 9 Feb 2023 17:55:43 +0800 Subject: [PATCH 2/2] update changelog --- debian/changelog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/debian/changelog b/debian/changelog index 75424df7..e6de87a8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +kylin-nm (3.20.1.17-0k0.7) v101; urgency=medium + + * BUG号: + - #153983 【整机生态-SP1-2209-第二阶段】【特殊机型】【T323】跑reboot过程中出现任务栏网络图标丢失的情况 + * 需求号:无 + * 其他改动: + * 影响域:无 + + -- zhaoshixu Thu, 09 Feb 2023 17:52:00 +0800 + kylin-nm (3.20.1.17-0k0.6) v101; urgency=medium * BUG号: