diff --git a/src/backend/dbus-interface/kywirelessnetresource.cpp b/src/backend/dbus-interface/kywirelessnetresource.cpp index 0a02783d..6ac80b22 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.cpp +++ b/src/backend/dbus-interface/kywirelessnetresource.cpp @@ -27,8 +27,7 @@ KyWirelessNetResource::~KyWirelessNetResource() bool KyWirelessNetResource::getAllDeviceWifiNetwork(QMap > &map) { onWifiNetworkDeviceDisappear(); - if (m_WifiNetworkList.isEmpty()) - { + if (m_WifiNetworkList.isEmpty()) { return false; } else { map = m_WifiNetworkList; @@ -37,34 +36,33 @@ bool KyWirelessNetResource::getAllDeviceWifiNetwork(QMap &list) +bool KyWirelessNetResource::getDeviceWifiNetwork(QString devIfaceName, QList &wirelessNetResource) { onWifiNetworkDeviceDisappear(); - if (!m_WifiNetworkList.contains(devIfaceName)) - { + + if (!m_WifiNetworkList.contains(devIfaceName)) { return false; } else { - list = m_WifiNetworkList[devIfaceName]; + wirelessNetResource = m_WifiNetworkList[devIfaceName]; return true; } } -bool KyWirelessNetResource::getWifiNetwork(QString &devIfaceName,QString &ssid, KyWirelessNetItem &KyWirelessNetResource) +bool KyWirelessNetResource::getWifiNetwork(QString &devIfaceName, QString &ssid, KyWirelessNetItem &wirelessNetResource) { onWifiNetworkDeviceDisappear(); - if (!m_WifiNetworkList.contains(devIfaceName)) - { + + if (!m_WifiNetworkList.contains(devIfaceName)) { return false; } else { - for (int index = 0; m_WifiNetworkList[devIfaceName].size(); index ++) - { - if (m_WifiNetworkList[devIfaceName].at(index).m_NetSsid == ssid) - { - KyWirelessNetResource = m_WifiNetworkList[devIfaceName].at(index); + for (int index = 0; m_WifiNetworkList[devIfaceName].size(); index ++){ + if (m_WifiNetworkList[devIfaceName].at(index).m_NetSsid == ssid) { + wirelessNetResource = m_WifiNetworkList[devIfaceName].at(index); return true; } } } + return false; } @@ -96,8 +94,7 @@ bool KyWirelessNetResource::getWirelessActiveConnection(QMapconnection(); NetworkManager::ConnectionSettings::Ptr sett = conn->settings(); - ssid = sett->id(); + wirelessNetResourcessid = sett->id(); + return sett->interfaceName(); } void KyWirelessNetResource::kyWirelessNetItemListInit() { qDebug() << 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); - if (devIface.isEmpty()) - { + if (devIface.isEmpty()) { continue; } - if (!m_WifiNetworkList.contains(devIface)) - { + + if (!m_WifiNetworkList.contains(devIface)){ QList list; KyWirelessNetItem item(net); list.append(item); @@ -141,6 +138,8 @@ void KyWirelessNetResource::kyWirelessNetItemListInit() m_WifiNetworkList[devIface].append(item); } } + + return; } QString KyWirelessNetResource::getDeviceIFace(NetworkManager::WirelessNetwork::Ptr net) @@ -214,7 +213,8 @@ void KyWirelessNetResource::onWifiNetworkAdded(QString devIfaceName, QString ssi list.append(item); m_WifiNetworkList.insert(devIfaceName,list); } - emit wifiNetworkAdd(devIfaceName,item); + + emit wifiNetworkAdd(devIfaceName, item); } void KyWirelessNetResource::onWifiNetworkRemoved(QString devIfaceName, QString ssid) @@ -240,36 +240,38 @@ void KyWirelessNetResource::onWifiNetworkRemoved(QString devIfaceName, QString s void KyWirelessNetResource::onWifiNetworkPropertyChange(NetworkManager::WirelessNetwork * net) { - if (nullptr == net) - { + if (nullptr == net) { return; } + 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 == net->ssid()) { - qDebug() << iter->m_NetSsid; + qDebug()<<"recive properity changed signal, sender is" << iter->m_NetSsid; if (iter->m_signalStrength != net->signalStrength()) { iter->m_signalStrength = net->signalStrength(); emit signalStrengthChange(devIface, net->ssid(), iter->m_signalStrength); } + if (iter->m_bssid != net->referenceAccessPoint()->hardwareAddress()) { iter->m_bssid = net->referenceAccessPoint()->hardwareAddress(); emit bssidChange(devIface, net->ssid(), iter->m_bssid); } + QString secuType = enumToQstring(net->referenceAccessPoint()->capabilities(), net->referenceAccessPoint()->wpaFlags(), net->referenceAccessPoint()->rsnFlags()); if (iter->m_secuType != secuType) { iter->m_secuType = secuType; emit secuTypeChange(devIface, net->ssid(), secuType); } + break; } iter++; @@ -291,6 +293,7 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn qDebug() << "modifyEnterPriseInfoTls connection missing"; return false; } + NetworkManager::WirelessSecuritySetting::Ptr security_sett = conn->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); if (security_sett.isNull()) diff --git a/src/backend/dbus-interface/kywirelessnetresource.h b/src/backend/dbus-interface/kywirelessnetresource.h index 01f30426..03e9efbd 100644 --- a/src/backend/dbus-interface/kywirelessnetresource.h +++ b/src/backend/dbus-interface/kywirelessnetresource.h @@ -17,9 +17,9 @@ public: ~KyWirelessNetResource(); //ui层调用接口 - bool getWifiNetwork(QString &devIfaceName,QString &ssid, KyWirelessNetItem &KyWirelessNetResource); - bool getAllDeviceWifiNetwork(QMap > &map); - bool getDeviceWifiNetwork(QString devIfaceName, QList &KyWirelessNetResource); + bool getWifiNetwork(QString &devIfaceName, QString &ssid, KyWirelessNetItem &wirelessNetResource); + bool getAllDeviceWifiNetwork(QMap > &map); + bool getDeviceWifiNetwork(QString devIfaceName, QList &wirelessNetResource); bool getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsInfo &info); bool getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeapInfo &info); @@ -31,7 +31,7 @@ public: private: void kyWirelessNetItemListInit(); QString getDeviceIFace(NetworkManager::WirelessNetwork::Ptr net); - QString getDeviceIFace(NetworkManager::ActiveConnection::Ptr actConn, QString &KyWirelessNetResourcessid); + QString getDeviceIFace(NetworkManager::ActiveConnection::Ptr actConn, QString &wirelessNetResourcessid); public slots: void onWifiNetworkAdded(QString, QString); @@ -53,7 +53,7 @@ signals: private: KyNetworkResourceManager *m_networkResourceInstance = nullptr; - QMap > m_WifiNetworkList; + QMap > m_WifiNetworkList; };