fix:when get netdetail of active wifi show active apinfo not reference apinfo
This commit is contained in:
parent
b9c838b29d
commit
61140448e2
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include "kylinnetworkdeviceresource.h"
|
||||
#include "kywirelessnetitem.h"
|
||||
|
||||
KyNetworkDeviceResourse::KyNetworkDeviceResourse(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
@ -161,6 +162,46 @@ void KyNetworkDeviceResourse::setDeviceRefreshRate(QString deviceName, int ms)
|
|||
return;
|
||||
}
|
||||
|
||||
void KyNetworkDeviceResourse::getDeviceActiveAPInfo(const QString devName, QString &strMac, uint &iHz, uint &iChan, QString &secuType)
|
||||
{
|
||||
strMac.clear();
|
||||
iHz = 0;
|
||||
iChan = 0;
|
||||
secuType.clear();
|
||||
|
||||
NetworkManager::Device::Ptr connectDevice =
|
||||
m_networkResourceInstance->getNetworkDevice(devName);
|
||||
|
||||
if (nullptr == connectDevice || !connectDevice->isValid()) {
|
||||
qWarning()<<"[KyNetworkDeviceResourse]"<<"getDeviceActiveAPInfo failed, the device" << devName << "is not existed";
|
||||
return;
|
||||
}
|
||||
|
||||
switch (connectDevice->type()) {
|
||||
case NetworkManager::Device::Wifi:
|
||||
{
|
||||
NetworkManager::WirelessDevice *wirelessDevicePtr =
|
||||
qobject_cast<NetworkManager::WirelessDevice *>(connectDevice.data());
|
||||
NetworkManager::AccessPoint::Ptr apPtr = wirelessDevicePtr->activeAccessPoint();
|
||||
if (apPtr.isNull()) {
|
||||
break;
|
||||
}
|
||||
strMac = apPtr->hardwareAddress();
|
||||
iHz = apPtr->frequency();
|
||||
iChan = NetworkManager::findChannel(iHz);
|
||||
NetworkManager::AccessPoint::Capabilities cap = apPtr->capabilities();
|
||||
NetworkManager::AccessPoint::WpaFlags wpaFlag = apPtr->wpaFlags();
|
||||
NetworkManager::AccessPoint::WpaFlags rsnFlag = apPtr->rsnFlags();
|
||||
secuType = enumToQstring(cap, wpaFlag, rsnFlag);
|
||||
break;
|
||||
}
|
||||
case NetworkManager::Device::Ethernet:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void KyNetworkDeviceResourse::DeviceSpeed(QString deviceName, KyConnectItem *wiredItem)
|
||||
{
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
void setDeviceRefreshRate(QString deviceName, int ms);
|
||||
// void disconnectDevice();
|
||||
//void setDeviceAutoConnect();
|
||||
void getDeviceActiveAPInfo(const QString devName, QString &strMac, uint &iHz, uint &iChan, QString &secuType);
|
||||
|
||||
private:
|
||||
KyWiredConnectOperation wiredOperation;
|
||||
|
|
|
@ -390,17 +390,28 @@ void NetDetail::getBaseInfo(ConInfo &conInfo)
|
|||
}
|
||||
} else {
|
||||
conInfo.strConType = "802-11-wireless";
|
||||
KyWirelessNetItem item;
|
||||
if (!m_resource->getWifiNetwork(m_deviceName, m_name, item)) {
|
||||
qDebug() << "getWifiNetWork failed device:" << m_deviceName << " name:" << m_name;
|
||||
return;
|
||||
if (!isActive) {
|
||||
KyWirelessNetItem item;
|
||||
if (!m_resource->getWifiNetwork(m_deviceName, m_name, item)) {
|
||||
qDebug() << "getWifiNetWork failed device:" << m_deviceName << " name:" << m_name;
|
||||
return;
|
||||
} else {
|
||||
|
||||
conInfo.strMac = item.m_bssid;
|
||||
conInfo.strHz = QString::number(item.m_frequency);
|
||||
conInfo.strChan = QString::number(item.m_channel);
|
||||
//无线特有
|
||||
conInfo.strSecType = item.m_secuType;
|
||||
}
|
||||
} else {
|
||||
conInfo.strMac = item.m_bssid;
|
||||
uint iHz,iChan;
|
||||
m_netDeviceResource->getDeviceActiveAPInfo(m_deviceName, conInfo.strMac, iHz, iChan, conInfo.strSecType);
|
||||
conInfo.strHz = QString::number(iHz);
|
||||
conInfo.strChan = QString::number(iChan);
|
||||
|
||||
}
|
||||
|
||||
//无线特有
|
||||
conInfo.strSecType = item.m_secuType;
|
||||
qDebug() << conInfo.strSecType;
|
||||
|
||||
|
||||
KyKeyMgmt type = m_wirelessConnOpration->getConnectKeyMgmt(m_uuid);
|
||||
if (type == WpaNone || type == Unknown) {
|
||||
|
@ -414,8 +425,6 @@ void NetDetail::getBaseInfo(ConInfo &conInfo)
|
|||
} else {
|
||||
qDebug() << "KeyMgmt not support now " << type;
|
||||
}
|
||||
conInfo.strHz = QString::number(item.m_frequency);
|
||||
conInfo.strChan = QString::number(item.m_channel);
|
||||
|
||||
initSecuData();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue