From fedae105cf5d4089415c55278ad92e2bc2109804 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Fri, 28 Jul 2023 15:14:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(=E6=89=98=E7=9B=98):=20=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E7=83=AD=E7=82=B9=E5=90=8E=20WiFi=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=9C=AA=E7=A7=BB=E9=99=A4=E9=97=AE=E9=A2=98?= =?UTF-8?q?(bug181187)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kylinnetworkresourcemanager.cpp | 4 +- .../dbus-interface/kywirelessnetresource.cpp | 49 ++++++++++++++----- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp index aec3e24a..71c3a9b9 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp @@ -457,8 +457,8 @@ NetworkManager::Connection::Ptr KyNetworkResourceManager::getConnect(const QStri int index = 0; NetworkManager::Connection::Ptr connectPtr = nullptr; - qDebug() <<"[KyNetworkResourceManager]" << "get connect with uuid" << connectUuid; if (connectUuid.isEmpty()) { + qWarning() << "[KyNetworkResourceManager]" << "get connect with uuid is empty"; return nullptr; } @@ -473,7 +473,7 @@ NetworkManager::Connection::Ptr KyNetworkResourceManager::getConnect(const QStri } } - qWarning()<<"[KyNetworkResourceManager]"<<"it can not find connect with uuid"<findDeviceInterface(dev); + if (devicePtr.isNull() || !m_WifiNetworkList.contains(dev)) { + return; + } + + NetworkManager::WirelessNetwork::Ptr netPtr = m_networkResourceInstance->findWifiNetwork(ssid, devicePtr->uni()); + if (netPtr.isNull()) { + return; + } + + QList list = m_WifiNetworkList.value(dev); + for (int i = 0; i < list.count(); ++i) { + if (uuid == list.at(i).m_connectUuid) { + list.removeAt(i); + break; + } + } + list.append(KyWirelessNetItem(netPtr)); + m_WifiNetworkList.insert(dev, list); + Q_EMIT wifiNetworkUpdate(); } From 308553b3365968d00cdfe216feac6175fe2cbc21 Mon Sep 17 00:00:00 2001 From: zhangyuanyuan1 Date: Fri, 28 Jul 2023 16:36:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?perf(network=20mode):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=9D=9E=E5=BF=85=E8=A6=81=E6=88=90=E5=91=98=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E4=B8=BA=E5=B1=80=E9=83=A8=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../networkmode/networkmodeconfig.cpp | 22 ++++++++++--------- src/frontend/networkmode/networkmodeconfig.h | 3 --- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/frontend/networkmode/networkmodeconfig.cpp b/src/frontend/networkmode/networkmodeconfig.cpp index d5ca8a57..f770c26a 100644 --- a/src/frontend/networkmode/networkmodeconfig.cpp +++ b/src/frontend/networkmode/networkmodeconfig.cpp @@ -104,10 +104,7 @@ NetworkMode::NetworkMode(QObject *parent) { qRegisterMetaType("NetworkManager::Device::State"); qRegisterMetaType("NetworkManager::Device::StateChangeReason"); - m_deviceResource = new KyNetworkDeviceResourse(this); m_activatedConnectResource = new KyActiveConnectResourse(this); - m_connectResource = new KyConnectResourse(this); - m_wirelessNetResource = new KyWirelessNetResource(this); connect(m_activatedConnectResource, &KyActiveConnectResourse::stateChangeReason, this, &NetworkMode::onConnectionStateChanged); } @@ -116,7 +113,8 @@ void NetworkMode::initWiredNetworkMode() { qDebug()<< LOG_FLAG << "initWiredNetworkMode"; QStringList wiredDevList; - m_deviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDevList); + KyNetworkDeviceResourse deviceResource; + deviceResource.getNetworkDeviceList(NetworkManager::Device::Type::Ethernet, wiredDevList); if (wiredDevList.isEmpty()) { return; } @@ -148,14 +146,16 @@ void NetworkMode::initWirelessNetworkMode() { qDebug()<< LOG_FLAG << "initWirelessNetworkMode"; QStringList wirelessDevList; - m_deviceResource->getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDevList); + KyNetworkDeviceResourse deviceResource; + deviceResource.getNetworkDeviceList(NetworkManager::Device::Type::Wifi, wirelessDevList); if (wirelessDevList.isEmpty()) { return; } for (auto devName : wirelessDevList) { KyWirelessNetItem wirelessNetItem; - bool ret = m_wirelessNetResource->getActiveWirelessNetItem(devName, wirelessNetItem); + KyWirelessNetResource wirelessNetResource; + bool ret = wirelessNetResource.getActiveWirelessNetItem(devName, wirelessNetItem); if (ret == true) { int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(wirelessNetItem.m_connectUuid); @@ -205,9 +205,10 @@ void NetworkMode::onConnectionStateChanged(QString uuid, QString ssid = ""; int configType = NetworkModeConfig::getInstance()->getNetworkModeConfig(uuid); + KyConnectResourse connectResource; //有线网络连接 - if (m_connectResource->isWiredConnection(uuid)) { + if (connectResource.isWiredConnection(uuid)) { KyConnectItem *p_newItem = nullptr; p_newItem = m_activatedConnectResource->getActiveConnectionByUuid(uuid); if (nullptr == p_newItem) { @@ -229,9 +230,10 @@ void NetworkMode::onConnectionStateChanged(QString uuid, } } //无线网络连接 - if (m_connectResource->isWirelessConnection(uuid)) { - m_wirelessNetResource->getSsidByUuid(uuid, ssid); - m_wirelessNetResource->getDeviceByUuid(uuid, deviceName); + if (connectResource.isWirelessConnection(uuid)) { + KyWirelessNetResource wirelessNetResource; + wirelessNetResource.getSsidByUuid(uuid, ssid); + wirelessNetResource.getDeviceByUuid(uuid, deviceName); if (ssid.isEmpty()) { //忘记此网络 qDebug()<< LOG_FLAG << "forgrt wireless connect:" << uuid <<", call break_networkConnect"; diff --git a/src/frontend/networkmode/networkmodeconfig.h b/src/frontend/networkmode/networkmodeconfig.h index c4af58ee..0404bb7f 100644 --- a/src/frontend/networkmode/networkmodeconfig.h +++ b/src/frontend/networkmode/networkmodeconfig.h @@ -64,10 +64,7 @@ public: void initWirelessNetworkMode(); private: - KyNetworkDeviceResourse *m_deviceResource = nullptr; KyActiveConnectResourse *m_activatedConnectResource = nullptr; - KyConnectResourse * m_connectResource = nullptr; - KyWirelessNetResource *m_wirelessNetResource = nullptr; void setFirstConnectNetworkMode(QString uuid, QString deviceName, QString ssid); private Q_SLOTS: