增加安全类型的数据转换方 法

This commit is contained in:
zhangyuanyuan1 2022-09-15 10:15:37 +08:00
parent cf088d463f
commit 3ae5abacd7
6 changed files with 42 additions and 58 deletions

View File

@ -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<NetworkManager::AccessPoint *>(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<NetworkManager::AccessPoint *>(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<NetworkManager::AccessPoint *>(sender());
emit wifiNetworkSecuChange(p_wirelessNet);
}, Qt::UniqueConnection);
connect(net->referenceAccessPoint().data(), &NetworkManager::AccessPoint::rsnFlagsChanged, this, [&]()
{
NetworkManager::AccessPoint *p_wirelessNet =
qobject_cast<NetworkManager::AccessPoint *>(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<NetworkManager::AccessPoint *>(sender());
emit wifiNetworkSecuChange(p_wirelessNet);
}
void KyNetworkResourceManager::onDeviceAdded(QString const & uni)
{
qDebug()<< "onDeviceAdded"<<uni;

View File

@ -178,6 +178,7 @@ private slots:
//wifi network
void onUpdateWirelessNet();
void onWifiNetworkSecuChang();
//notifier
void onDeviceAdded(QString const & uni);

View File

@ -89,13 +89,14 @@ void KyWirelessNetItem::init(NetworkManager::WirelessNetwork::Ptr net)
NetworkManager::AccessPoint::WpaFlags wpaFlag = net->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;
}
}

View File

@ -55,6 +55,7 @@ public:
uint m_channel;
int getCategory(QString uni);
void setKySecuType(QString strSecuType);
private:
KyNetworkResourceManager *m_networkResourceInstance = nullptr;

View File

@ -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);
}

View File

@ -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;
}