增加接口检查网卡类型 删除接口deviceIsWired

This commit is contained in:
zhangyuanyuan1 2023-04-23 14:47:14 +08:00
parent db4e0c3d60
commit 31a64fcccb
5 changed files with 17 additions and 7 deletions

View File

@ -660,7 +660,7 @@ bool KyActiveConnectResourse::connectionIsVirtual(QString uuid)
return false; return false;
} }
return !m_networkdevice->deviceIsWired(devicePtr->interfaceName()); return !m_networkdevice->checkDeviceType(devicePtr->interfaceName(), NetworkManager::Device::Type::Ethernet);
} }
bool KyActiveConnectResourse::wiredConnectIsActived() bool KyActiveConnectResourse::wiredConnectIsActived()

View File

@ -385,7 +385,7 @@ bool KyNetworkDeviceResourse::wirelessDeviceIsExist(const QString devName)
return list.contains(devName); return list.contains(devName);
} }
bool KyNetworkDeviceResourse::deviceIsWired(QString deviceName) bool KyNetworkDeviceResourse::checkDeviceType(QString deviceName, NetworkManager::Device::Type deviceType)
{ {
NetworkManager::Device::Ptr devicePtr = NetworkManager::Device::Ptr devicePtr =
m_networkResourceInstance->findDeviceInterface(deviceName); m_networkResourceInstance->findDeviceInterface(deviceName);
@ -395,10 +395,15 @@ bool KyNetworkDeviceResourse::deviceIsWired(QString deviceName)
return false; return false;
} }
if (NetworkManager::Device::Type::Ethernet == devicePtr->type() if (deviceType == devicePtr->type()) {
&& !devicePtr->udi().startsWith(VIRTURAL_DEVICE_PATH)) { if (NetworkManager::Device::Type::Ethernet == deviceType) {
if (!devicePtr->udi().startsWith(VIRTURAL_DEVICE_PATH)) {
return true; return true;
} }
} else {
return true;
}
}
return false; return false;
} }

View File

@ -62,7 +62,7 @@ public:
bool wiredDeviceIsCarriered(QString deviceName); bool wiredDeviceIsCarriered(QString deviceName);
bool wirelessDeviceIsExist(const QString devName); bool wirelessDeviceIsExist(const QString devName);
bool deviceIsWired(QString deviceName); bool checkDeviceType(QString deviceName, NetworkManager::Device::Type deviceType);
void setDeviceRefreshRate(QString deviceName, int ms); void setDeviceRefreshRate(QString deviceName, int ms);

View File

@ -524,7 +524,8 @@ void LanPage::addDeviceForCombox(QString deviceName)
void LanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType) void LanPage::onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType)
{ {
if (!m_deviceResource->deviceIsWired(deviceName)) { Q_UNUSED(deviceType)
if (!m_deviceResource->checkDeviceType(deviceName, NetworkManager::Device::Type::Ethernet)) {
return; return;
} }

View File

@ -870,6 +870,10 @@ void WlanPage::onWlanStateChanged(NetworkManager::Device::State newstate, Networ
void WlanPage::onDeviceManagedChanged(QString deviceName, bool managed) void WlanPage::onDeviceManagedChanged(QString deviceName, bool managed)
{ {
if (!m_netDeviceResource->checkDeviceType(deviceName, NetworkManager::Device::Type::Wifi)) {
return;
}
if (managed && !m_devList.contains(deviceName)) { if (managed && !m_devList.contains(deviceName)) {
//添加新增托管网卡 //添加新增托管网卡
onDeviceAdd(deviceName, NetworkManager::Device::Type::Wifi); onDeviceAdd(deviceName, NetworkManager::Device::Type::Wifi);