网络连接状态改变异常情况处理

This commit is contained in:
zhangyuanyuan1 2023-03-06 10:54:49 +08:00
parent bfeb0c2218
commit 56f9c2e4c9
2 changed files with 12 additions and 4 deletions

View File

@ -681,12 +681,19 @@ void KyNetworkResourceManager::wiredActiveStateChange(QString connectPath,
void KyNetworkResourceManager::connectActiveStateChange(NetworkManager::Connection::Ptr connectPtr, void KyNetworkResourceManager::connectActiveStateChange(NetworkManager::Connection::Ptr connectPtr,
QString deviceName, QString deviceName,
KyConnectState state) KyConnectState state, QString activeConnectUuid)
{ {
QString uuid = connectPtr->uuid(); QString uuid = connectPtr->uuid();
NetworkManager::ConnectionSettings::Ptr connectSettingsPtr = connectPtr->settings(); NetworkManager::ConnectionSettings::Ptr connectSettingsPtr = connectPtr->settings();
KyConnectionType connectionType = (KyConnectionType)connectSettingsPtr->connectionType(); if (uuid.isEmpty()) {
//异常情况处理
Q_EMIT wirelessConnectStateChange(deviceName, "", activeConnectUuid, state);
Q_EMIT wirelessApConnectStateChange(deviceName, "", activeConnectUuid, state);
Q_EMIT wiredConnectStateChange(deviceName, activeConnectUuid, state);
return;
}
KyConnectionType connectionType = (KyConnectionType)connectSettingsPtr->connectionType();
if (connectionType == CONNECT_TYPE_WIRELESS) { if (connectionType == CONNECT_TYPE_WIRELESS) {
wirelessActiveStateChange(connectSettingsPtr, deviceName, uuid, state); wirelessActiveStateChange(connectSettingsPtr, deviceName, uuid, state);
NetworkManager::WirelessSetting::Ptr wirelessSetting NetworkManager::WirelessSetting::Ptr wirelessSetting
@ -716,9 +723,10 @@ void KyNetworkResourceManager::onActiveConnectionChanged(
NetworkManager::Device:: Ptr devicePtr = findDeviceByUni(ifaceUni); NetworkManager::Device:: Ptr devicePtr = findDeviceByUni(ifaceUni);
deviceName = devicePtr->interfaceName(); deviceName = devicePtr->interfaceName();
} }
qDebug() << "KyNetworkResourceManager onActiveConnectionChanged" << activeConnect->uuid();
NetworkManager::Connection::Ptr connectPtr = activeConnect->connection(); NetworkManager::Connection::Ptr connectPtr = activeConnect->connection();
connectActiveStateChange(connectPtr, deviceName, (KyConnectState)state); connectActiveStateChange(connectPtr, deviceName, (KyConnectState)state, activeConnect->uuid());
} else { } else {
qWarning() << LOG_FLAG << "onActiveConnectionChanged failed, the connection is invalid."; qWarning() << LOG_FLAG << "onActiveConnectionChanged failed, the connection is invalid.";
} }

View File

@ -122,7 +122,7 @@ private:
void wiredActiveStateChange(QString connectPath, QString deviceName, void wiredActiveStateChange(QString connectPath, QString deviceName,
QString uuid, KyConnectState state); QString uuid, KyConnectState state);
void connectActiveStateChange(NetworkManager::Connection::Ptr connectPtr, void connectActiveStateChange(NetworkManager::Connection::Ptr connectPtr,
QString deviceName, KyConnectState state); QString deviceName, KyConnectState state, QString activeConnectUuid);
private Q_SLOTS: private Q_SLOTS:
void onServiceAppear(QString, QString, QString); void onServiceAppear(QString, QString, QString);