fix(wlan): modify onConnectionUpdate method and add signal(bug#190099)

This commit is contained in:
zhangyuanyuan1 2023-09-05 17:56:07 +08:00
parent b3c74a6d1b
commit 5190d5e838
5 changed files with 55 additions and 16 deletions

View File

@ -605,7 +605,6 @@ void WlanConnect::onActiveConnectionChanged(QString deviceName, QString ssid, QS
if (!deviceFrameMap.contains(deviceName)) {
return;
}
for (int i = 0; i < deviceFrameMap[deviceName]->itemMap.size(); ++i) {
if (deviceFrameMap[deviceName]->itemMap.contains(ssid)) {
item = deviceFrameMap[deviceName]->itemMap[ssid];
if (status == ACTIVATED || status == ACTIVATING) {
@ -621,10 +620,21 @@ void WlanConnect::onActiveConnectionChanged(QString deviceName, QString ssid, QS
deviceFrameMap[deviceName]->uuid.clear();
//todo 断开后排序 现在等下次更新列表 自动排序
}
} else {
if (uuid == deviceFrameMap[deviceName]->uuid) {
QMap<QString, WlanItem*>::iterator itemIter;
for (itemIter = deviceFrameMap[deviceName]->itemMap.begin(); itemIter != deviceFrameMap[deviceName]->itemMap.end(); itemIter++) {
if (itemIter.value()->uuid == uuid ) {
item = itemIter.value();
if (status == DEACTIVATED) {
itemIter.value()->uuid.clear();
}
break;
}
}
}
}
}
if (nullptr != item) {
itemActiveConnectionStatusChanged(item, status);

View File

@ -863,25 +863,44 @@ void KyWirelessNetResource::onConnectionUpdate(QString uuid)
getSsidByUuid(uuid, ssid);
getDeviceByUuid(uuid, dev);
if (!dev.isEmpty()) {
NetworkManager::Device::Ptr devicePtr = m_networkResourceInstance->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<KyWirelessNetItem> list = m_WifiNetworkList.value(dev);
for (int i = 0; i < list.count(); ++i) {
if (uuid == list.at(i).m_connectUuid) {
list.removeAt(i);
QMap<QString, QList<KyWirelessNetItem> >::iterator iter;
for (iter = m_WifiNetworkList.begin(); iter != m_WifiNetworkList.end(); ++iter) {
QList<KyWirelessNetItem>::iterator itemIter;
for (itemIter = iter.value().begin(); itemIter != iter.value().end(); ++itemIter) {
//判断是否有其他wifi配置 更新WIFI-bd 的connect相关变量 emit update
if (uuid == itemIter->m_connectUuid) {
if (itemIter->m_NetSsid != ssid ||
(iter.key() != dev && !dev.isEmpty())) {
updatewirelessItemConnectInfo(*itemIter);
Q_EMIT connectionUpdate(iter.key(), itemIter->m_NetSsid);
//判断netptr是否为空 空返回
//否则 更新ssid 的connect相关变量 emit update ssid
NetworkManager::Device::Ptr devicePtr = m_networkResourceInstance->findDeviceInterface(dev);
NetworkManager::WirelessNetwork::Ptr netPtr = m_networkResourceInstance->findWifiNetwork(ssid, devicePtr->uni());
if (netPtr.isNull()) {
qDebug() << LOG_FLAG << ssid << "netPtr is Null";
return;
}
}
}
//更新WIFI 的connect相关变量 emit update to ui
if (ssid == itemIter->m_NetSsid) {
if (iter.key() == dev || dev.isEmpty()) {
updatewirelessItemConnectInfo(*itemIter);
Q_EMIT connectionUpdate(dev, itemIter->m_NetSsid);
}
}
break;
}
}
list.append(KyWirelessNetItem(netPtr));
m_WifiNetworkList.insert(dev, list);
Q_EMIT wifiNetworkUpdate();
}

View File

@ -84,6 +84,7 @@ Q_SIGNALS:
void secuTypeChange(QString, QString, QString);
void connectionRemove(QString, QString, QString);
void connectionAdd(QString, QString);
void connectionUpdate(QString, QString);
void wifiNetworkUpdate();
void wifiNetworkAdd(QString, KyWirelessNetItem&);
void wifiNetworkRemove(QString, QString);

View File

@ -62,6 +62,7 @@ WlanPage::WlanPage(QWidget *parent) : TabPage(parent)
connect(m_wirelessNetResource, &KyWirelessNetResource::connectionAdd, this, &WlanPage::onConnectionAdd);
connect(m_wirelessNetResource, &KyWirelessNetResource::connectionRemove, this, &WlanPage::onConnectionRemove);
connect(m_wirelessNetResource, &KyWirelessNetResource::connectionUpdate, this, &WlanPage::onConnectionUpdate);
connect(m_activatedConnectResource, &KyActiveConnectResourse::stateChangeReason,
this, &WlanPage::onConnectionStateChanged);
@ -687,6 +688,13 @@ void WlanPage::onConnectionRemove(QString deviceName, QString ssid, QString path
return;
}
void WlanPage::onConnectionUpdate(QString deviceName, QString ssid)
{
if (deviceName == m_currentDevice || deviceName.isEmpty()) {
updateWlanListItem(ssid);
}
}
void WlanPage::onSecurityTypeChange(QString devName, QString ssid, QString secuType)
{
QListWidgetItem *p_listWidgetItem = nullptr;

View File

@ -119,6 +119,7 @@ private Q_SLOTS:
void onConnectionAdd(QString deviceName, QString ssid);
void onConnectionRemove(QString deviceName, QString ssid, QString path);
void onConnectionUpdate(QString deviceName, QString ssid);
void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType);
void onDeviceRemove(QString deviceName);