add device name when actvating or deactivating && lan list sort
This commit is contained in:
parent
b1690dc2ec
commit
92efbe52c3
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ public:
|
||||||
|
|
||||||
bool isActiveConnection(QString uuid, QStringList &devName);
|
bool isActiveConnection(QString uuid, QStringList &devName);
|
||||||
|
|
||||||
|
QString getDeviceOfActivateConnect(QString conUuid);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr,
|
||||||
QString &ipv4Address,
|
QString &ipv4Address,
|
||||||
|
|
|
@ -208,9 +208,14 @@ void KyConnectOperation::activateConnection(const QString connectUuid, const QSt
|
||||||
|
|
||||||
void KyConnectOperation::deactivateConnection(const QString activeConnectName, const QString &activeConnectUuid)
|
void KyConnectOperation::deactivateConnection(const QString activeConnectName, const QString &activeConnectUuid)
|
||||||
{
|
{
|
||||||
|
|
||||||
NetworkManager::ActiveConnection::Ptr activateConnectPtr = nullptr;
|
NetworkManager::ActiveConnection::Ptr activateConnectPtr = nullptr;
|
||||||
|
|
||||||
qDebug()<<"deactivetate connect name"<<activeConnectName<<"uuid"<<activeConnectUuid;
|
qDebug()<<"deactivetate connect name"<<activeConnectName<<"uuid"<<activeConnectUuid;
|
||||||
|
|
||||||
|
if (nullptr == m_networkResourceInstance) {
|
||||||
|
qDebug() << "NULL!";
|
||||||
|
}
|
||||||
activateConnectPtr = m_networkResourceInstance->getActiveConnect(activeConnectUuid);
|
activateConnectPtr = m_networkResourceInstance->getActiveConnect(activeConnectUuid);
|
||||||
if (nullptr == activateConnectPtr) {
|
if (nullptr == activateConnectPtr) {
|
||||||
QString errorMessage = tr("it can not find the activate connect")
|
QString errorMessage = tr("it can not find the activate connect")
|
||||||
|
|
|
@ -8,6 +8,22 @@
|
||||||
#include <NetworkManagerQt/VpnPlugin>
|
#include <NetworkManagerQt/VpnPlugin>
|
||||||
#include <NetworkManagerQt/VpnSetting>
|
#include <NetworkManagerQt/VpnSetting>
|
||||||
|
|
||||||
|
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<KyConnectItem *> &list)
|
||||||
|
{
|
||||||
|
qSort(list.begin(), list.end(), subLanListSort);
|
||||||
|
}
|
||||||
|
|
||||||
KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent)
|
KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
m_networkResourceInstance = KyNetworkResourceManager::getInstance();
|
||||||
|
@ -152,6 +168,9 @@ void KyConnectResourse::getConnectionList(QString deviceName,
|
||||||
connectPtr = nullptr;
|
connectPtr = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (connectItemList.size() > 1) {
|
||||||
|
lanListSort(connectItemList);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent)
|
||||||
m_activeResourse = new KyActiveConnectResourse(this);
|
m_activeResourse = new KyActiveConnectResourse(this);
|
||||||
m_connectResourse = new KyConnectResourse(this);
|
m_connectResourse = new KyConnectResourse(this);
|
||||||
m_deviceResource = new KyNetworkDeviceResourse(this);
|
m_deviceResource = new KyNetworkDeviceResourse(this);
|
||||||
|
m_wiredConnectOperation = new KyWiredConnectOperation(this);
|
||||||
|
|
||||||
initUI();
|
initUI();
|
||||||
initNetSwitch();
|
initNetSwitch();
|
||||||
|
@ -792,11 +793,19 @@ void LanPage::onUpdateLanlist(QString uuid,
|
||||||
updateActivatedConnectionArea(uuid);
|
updateActivatedConnectionArea(uuid);
|
||||||
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
} else if (state == NetworkManager::ActiveConnection::State::Deactivated) {
|
||||||
updateConnectionArea(uuid);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map)
|
void LanPage::getWiredList(QMap<QString, QVector<QStringList> > &map)
|
||||||
{
|
{
|
||||||
QStringList devlist;
|
QStringList devlist;
|
||||||
|
|
Loading…
Reference in New Issue