diff --git a/src/backend/dbus-interface/kylinactiveconnectresource.cpp b/src/backend/dbus-interface/kylinactiveconnectresource.cpp index df31ff31..3c94b975 100644 --- a/src/backend/dbus-interface/kylinactiveconnectresource.cpp +++ b/src/backend/dbus-interface/kylinactiveconnectresource.cpp @@ -560,3 +560,23 @@ bool KyActiveConnectResourse::isActiveConnection(QString uuid, QStringList &devN } } } + +QString KyActiveConnectResourse::getDeviceOfActivateConnect(QString conUuid) +{ + QString deviceName = ""; + + NetworkManager::ActiveConnection::Ptr activeConnectPtr = + m_networkResourceInstance->getActiveConnect(conUuid); + + if (nullptr == activeConnectPtr) { + qWarning()<< "[KyActiveConnectResourse]" <<"it can not find connect "<< conUuid; + return deviceName; + } + + QStringList interfaces = activeConnectPtr->devices(); + QString ifaceUni = interfaces.at(0); + NetworkManager::Device:: Ptr devicePtr = + m_networkResourceInstance->findDeviceUni(ifaceUni); + deviceName = devicePtr->interfaceName(); + return deviceName; +} diff --git a/src/backend/dbus-interface/kylinactiveconnectresource.h b/src/backend/dbus-interface/kylinactiveconnectresource.h index 93225d1b..4a291167 100644 --- a/src/backend/dbus-interface/kylinactiveconnectresource.h +++ b/src/backend/dbus-interface/kylinactiveconnectresource.h @@ -37,6 +37,8 @@ public: bool isActiveConnection(QString uuid, QStringList &devName); + QString getDeviceOfActivateConnect(QString conUuid); + private: void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr, QString &ipv4Address, diff --git a/src/backend/dbus-interface/kylinconnectoperation.cpp b/src/backend/dbus-interface/kylinconnectoperation.cpp index 4701df6b..bb05e3fd 100644 --- a/src/backend/dbus-interface/kylinconnectoperation.cpp +++ b/src/backend/dbus-interface/kylinconnectoperation.cpp @@ -208,9 +208,14 @@ void KyConnectOperation::activateConnection(const QString connectUuid, const QSt void KyConnectOperation::deactivateConnection(const QString activeConnectName, const QString &activeConnectUuid) { + NetworkManager::ActiveConnection::Ptr activateConnectPtr = nullptr; qDebug()<<"deactivetate connect name"<getActiveConnect(activeConnectUuid); if (nullptr == activateConnectPtr) { QString errorMessage = tr("it can not find the activate connect") diff --git a/src/backend/dbus-interface/kylinconnectresource.cpp b/src/backend/dbus-interface/kylinconnectresource.cpp index 3b0b95ae..ef266586 100644 --- a/src/backend/dbus-interface/kylinconnectresource.cpp +++ b/src/backend/dbus-interface/kylinconnectresource.cpp @@ -8,6 +8,22 @@ #include #include +static bool subLanListSort(const KyConnectItem* info1, const KyConnectItem* info2) +{ + QString name1 = info1->m_connectName; + QString name2 = info2->m_connectName; + bool result = true; + if (QString::compare(name1, name2, Qt::CaseInsensitive) > 0) { + result = false; + } + return result; +} + +static void lanListSort(QList &list) +{ + qSort(list.begin(), list.end(), subLanListSort); +} + KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent) { m_networkResourceInstance = KyNetworkResourceManager::getInstance(); @@ -152,6 +168,9 @@ void KyConnectResourse::getConnectionList(QString deviceName, connectPtr = nullptr; } + if (connectItemList.size() > 1) { + lanListSort(connectItemList); + } return; } diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index 3a77c360..2537ba36 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -22,6 +22,7 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent) m_activeResourse = new KyActiveConnectResourse(this); m_connectResourse = new KyConnectResourse(this); m_deviceResource = new KyNetworkDeviceResourse(this); + m_wiredConnectOperation = new KyWiredConnectOperation(this); initUI(); initNetSwitch(); @@ -792,11 +793,19 @@ void LanPage::onUpdateLanlist(QString uuid, updateActivatedConnectionArea(uuid); } else if (state == NetworkManager::ActiveConnection::State::Deactivated) { updateConnectionArea(uuid); + } else if (state == NetworkManager::ActiveConnection::State::Activating + || state == NetworkManager::ActiveConnection::State::Deactivating) { + QString devName = m_activeResourse->getDeviceOfActivateConnect(uuid); + if (devName.isEmpty()) { + NetworkManager::ConnectionSettings::ConnectionType type = NetworkManager::ConnectionSettings::Wired; + m_connectResourse->getInterfaceByUuid(devName, type, uuid); + } + emit lanActiveConnectionStateChanged(devName, uuid, state); } - return; } + void LanPage::getWiredList(QMap > &map) { QStringList devlist;