diff --git a/src/backend/dbus-interface/kylinactiveconnectresource.cpp b/src/backend/dbus-interface/kylinactiveconnectresource.cpp index b33510d8..cfc5d55d 100644 --- a/src/backend/dbus-interface/kylinactiveconnectresource.cpp +++ b/src/backend/dbus-interface/kylinactiveconnectresource.cpp @@ -511,3 +511,24 @@ void KyActiveConnectResourse::getApActivateConnect(QList &apC return; } + +bool KyActiveConnectResourse::isActiveConnection(QString uuid, QStringList &devName) +{ + if (!m_networkResourceInstance->isActiveConnection(uuid)) { + return false; + } else { + NetworkManager::ActiveConnection::Ptr actPtr = m_networkResourceInstance->getActiveConnect(uuid); + if (actPtr.isNull()) { + return false; + } else { + QStringList interfaces = actPtr->devices(); + for (int index = 0; index < interfaces.size(); ++index) { + QString ifaceUni = interfaces.at(index); + NetworkManager::Device:: Ptr devicePtr = + m_networkResourceInstance->findDeviceUni(ifaceUni); + devName <interfaceName(); + } + return true; + } + } +} diff --git a/src/backend/dbus-interface/kylinactiveconnectresource.h b/src/backend/dbus-interface/kylinactiveconnectresource.h index 388d85e9..b5d02054 100644 --- a/src/backend/dbus-interface/kylinactiveconnectresource.h +++ b/src/backend/dbus-interface/kylinactiveconnectresource.h @@ -34,6 +34,8 @@ public: void getApActivateConnect(QList &apConnectItemList); + bool isActiveConnection(QString uuid, QStringList &devName); + private: void getActiveConnectIp(NetworkManager::ActiveConnection::Ptr activeConnectPtr, QString &ipv4Address, diff --git a/src/backend/dbus-interface/kylinconnectresource.cpp b/src/backend/dbus-interface/kylinconnectresource.cpp index 10165584..ac491f0f 100644 --- a/src/backend/dbus-interface/kylinconnectresource.cpp +++ b/src/backend/dbus-interface/kylinconnectresource.cpp @@ -16,6 +16,7 @@ KyConnectResourse::KyConnectResourse(QObject *parent) : QObject(parent) connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionAdd, this, &KyConnectResourse::connectionAdd); connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionRemove, this, &KyConnectResourse::connectionRemove); connect(m_networkResourceInstance, &KyNetworkResourceManager::connectionUpdate, this, &KyConnectResourse::connectionUpdate); + connect(m_networkResourceInstance, &KyNetworkResourceManager::connectivityChanged, this, &KyConnectResourse::connectivityChanged); } KyConnectResourse::~KyConnectResourse() @@ -278,6 +279,11 @@ void KyConnectResourse::getIpv6ConnectSetting( return; } +void KyConnectResourse::getConnectivity(NetworkManager::Connectivity &connectivity) +{ + m_networkResourceInstance->getConnectivity(connectivity); +} + void KyConnectResourse::getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting) { qDebug() <<"[KyConnectResourse]" << connectUuid <<"get connect setting info, connect uuid"; diff --git a/src/backend/dbus-interface/kylinconnectresource.h b/src/backend/dbus-interface/kylinconnectresource.h index aa8f9c26..39dfa82c 100644 --- a/src/backend/dbus-interface/kylinconnectresource.h +++ b/src/backend/dbus-interface/kylinconnectresource.h @@ -28,6 +28,7 @@ public: void getApConnections(QList &apConnectItemList); void getConnectionSetting(QString connectUuid, KyConnectSetting &connectSetting); bool getInterfaceByUuid(QString &deviceName, NetworkManager::ConnectionSettings::ConnectionType &type, const QString connUuid); + void getConnectivity(NetworkManager::Connectivity &connectivity); private: KyConnectItem *getConnectionItem(NetworkManager::Connection::Ptr connectPtr); @@ -51,6 +52,7 @@ signals: void connectionAdd(QString uuid); void connectionUpdate(QString uuid); void connectionRemove(QString path); + void connectivityChanged(NetworkManager::Connectivity connectivity); private: KyNetworkResourceManager *m_networkResourceInstance = nullptr; diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp index ab6529a0..76d7a71e 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.cpp @@ -51,6 +51,7 @@ KyNetworkResourceManager::KyNetworkResourceManager(QObject *parent) : QObject(pa connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionAdded, this, &KyNetworkResourceManager::onConnectionAdded); connect(NetworkManager::settingsNotifier(), &NetworkManager::SettingsNotifier::connectionRemoved, this, static_cast(&KyNetworkResourceManager::onConnectionRemoved)); + connect(NetworkManager::notifier(), &NetworkManager::Notifier::connectivityChanged, this, &KyNetworkResourceManager::connectivityChanged); //todo wifi开关信号 connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessEnabledChanged, this, &KyNetworkResourceManager::wifinEnabledChanged); connect(NetworkManager::notifier(), &NetworkManager::Notifier::wirelessHardwareEnabledChanged, [=](){ @@ -483,6 +484,11 @@ bool KyNetworkResourceManager::isActivatingConnection(QString uuid) return false; } +void KyNetworkResourceManager::getConnectivity(NetworkManager::Connectivity &connectivity) +{ + connectivity = NetworkManager::connectivity(); +} + void KyNetworkResourceManager::requestScan(NetworkManager::WirelessDevice * dev) { qDebug() <<"[KyNetworkResourceManager]"<< dev->interfaceName()<<"start scan wifi ap"; diff --git a/src/backend/dbus-interface/kylinnetworkresourcemanager.h b/src/backend/dbus-interface/kylinnetworkresourcemanager.h index cb558a57..8503a4b4 100644 --- a/src/backend/dbus-interface/kylinnetworkresourcemanager.h +++ b/src/backend/dbus-interface/kylinnetworkresourcemanager.h @@ -101,6 +101,8 @@ public: bool isActiveConnection(QString uuid); bool isActivatingConnection(QString uuid); + void getConnectivity(NetworkManager::Connectivity &connectivity); + signals: void connectionAdd(QString uuid); void connectionUpdate(QString uuid); @@ -136,6 +138,8 @@ signals: NetworkManager::VpnConnection::State state, NetworkManager::VpnConnection::StateChangeReason reason); + void connectivityChanged(NetworkManager::Connectivity connectivity); + private slots: //connection void onConnectionUpdated(); diff --git a/src/backend/dbus-interface/kywirelessconnectoperation.cpp b/src/backend/dbus-interface/kywirelessconnectoperation.cpp index e9dd5668..cf182d8a 100644 --- a/src/backend/dbus-interface/kywirelessconnectoperation.cpp +++ b/src/backend/dbus-interface/kywirelessconnectoperation.cpp @@ -247,8 +247,8 @@ QString KyWirelessConnectOperation::getPsk(const QString &connectUuid) } QDBusPendingReply reply = connectPtr->secrets(PSK_SETTING_NAME); QMap map(reply.value()); - if (map.contains("802-11-wireless-security") && map.value("802-11-wireless-security").contains("psk")) - { + if (map.contains("802-11-wireless-security") + && map.value("802-11-wireless-security").contains("psk")) { QString psk = map.value("802-11-wireless-security").value("psk").toString(); return psk; } @@ -267,8 +267,8 @@ QString KyWirelessConnectOperation::getPrivateKeyPassword(const QString &connect } QDBusPendingReply reply = connectPtr->secrets(PSK_SETTING_NAME); QMap map(reply.value()); - if (map.contains("802-1x") && map.value("802-1x").contains("private-key-password")) - { + if (map.contains("802-1x") + && map.value("802-1x").contains("private-key-password")) { QString psk = map.value("802-1x").value("private-key-password").toString(); return psk; } @@ -825,8 +825,7 @@ KyKeyMgmt KyWirelessConnectOperation::getConnectKeyMgmt(const QString &uuid) NetworkManager::WirelessSecuritySetting::Ptr security_sett = connectPtr->settings()->setting(NetworkManager::Setting::WirelessSecurity).dynamicCast(); - if(security_sett.isNull()) - { + if(security_sett.isNull()) { return KyKeyMgmt::Unknown; } return (KyKeyMgmt)security_sett->keyMgmt(); @@ -848,7 +847,6 @@ void KyWirelessConnectOperation::updateWirelessSecu(NetworkManager::ConnectionSe } security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type); if (bPwdChange) { - qDebug() << "set psk " << connSettingInfo.m_psk; security_sett->setPsk(connSettingInfo.m_psk); } return; @@ -927,13 +925,13 @@ bool KyWirelessConnectOperation::getEnterpiseEapMethod(const QString &uuid, KyEa NetworkManager::Connection::Ptr connectPtr = NetworkManager::findConnectionByUuid(uuid); if (connectPtr.isNull()) { - qDebug() << "getEnterpiseEapMethod faild.Can't find uuid = " << uuid; + qWarning() << "getEnterpiseEapMethod faild.Can't find uuid = " << uuid; return false; } KyKeyMgmt keyMgmt = getConnectKeyMgmt(uuid); if (keyMgmt != WpaEap) { - qDebug() << "getEnterpiseEapMethod but not WpaEap.it's " << keyMgmt; + qWarning() << "getEnterpiseEapMethod but not WpaEap.it's " << keyMgmt; return false; } diff --git a/src/backend/dbusadaptor.h b/src/backend/dbusadaptor.h index 0b35e6c0..0c290333 100644 --- a/src/backend/dbusadaptor.h +++ b/src/backend/dbusadaptor.h @@ -79,9 +79,15 @@ public Q_SLOTS: // METHODS //获取热点 QStringList getStoredApInfo(); Q_SIGNALS: // SIGNALS - void wirelessActivating(QString devName, QString ssid); - void wiredActivating(QString devName, QString ssid); - void listUpdate(QString devName); +// void wirelessActivating(QString devName, QString ssid); +// void wiredActivating(QString devName, QString ssid); + void lanAdd(QString devName, QStringList info); + void lanRemove(QString dbusPath); + void lanUpdate(QString devName, QStringList info); + void wlanAdd(QString devName, QStringList info); + void wlanRemove(QString devName,QString ssid); + void wlanactiveConnectionStateChanged(QString devName, QString ssid, int status); + void lanActiveConnectionStateChanged(QString devName, QString uuid, int status); //仅失败,若成功直接发listUpdate void activateFailed(QString errorMessage); void deactivateFailed(QString errorMessage); diff --git a/src/frontend/netdetails/creatnetpage.cpp b/src/frontend/netdetails/creatnetpage.cpp index ea672c6a..ff4bd30e 100644 --- a/src/frontend/netdetails/creatnetpage.cpp +++ b/src/frontend/netdetails/creatnetpage.cpp @@ -165,7 +165,9 @@ void CreatNetPage::constructIpv4Info(KyConnectSetting &setting) QString ipv4address =ipv4addressEdit->text(); QString netMask = netMaskEdit->text(); QString gateWay = gateWayEdit->text(); - qDebug() << ipv4address << netMask << gateWay; + qDebug() << "constructIpv4Info: " << "ipv4address " << ipv4address + << " netMask " << netMask + << " gateWay " << gateWay; QStringList dnsList; dnsList.empty(); diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index b2188fcd..d352f838 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -524,11 +524,9 @@ void NetDetail::on_btnForget_clicked() void NetDetail::setConfirmEnable() { - qDebug() << isCreateNet << isWlan; if (isCreateNet && !isWlan) { isConfirmBtnEnable = isCreateOk; } else { - qDebug() << isDetailOk << isIpv4Ok << isIpv6Ok << isSecuOk; if (isDetailOk && isIpv4Ok && isIpv6Ok) { if (isWlan && !isSecuOk) { isConfirmBtnEnable = false; @@ -551,7 +549,7 @@ bool NetDetail::checkIpv4Conflict(QString ipv4Address) if (ipv4Arping->ipv4ConflictCheck() >= 0) { isConflict = ipv4Arping->ipv4IsConflict(); } else { - qDebug() << "checkIpv4Conflict internal error"; + qWarning() << "checkIpv4Conflict internal error"; } delete ipv4Arping; @@ -567,7 +565,7 @@ bool NetDetail::checkIpv6Conflict(QString ipv6address) if (ipv46rping->ipv6ConflictCheck() >= 0) { isConflict = ipv46rping->ipv6IsConflict(); } else { - qDebug() << "checkIpv6Conflict internal error"; + qWarning() << "checkIpv6Conflict internal error"; } delete ipv46rping; @@ -580,7 +578,6 @@ void NetDetail::updateWirelessPersonalConnect() KyWirelessConnectSetting setting; securityPage->updateSecurityChange(setting); bool isPwdChanged = !(m_info.strPassword == setting.m_psk); - qDebug() << setting.m_psk << isPwdChanged; m_wirelessConnOpration->updateWirelessPersonalConnect(m_uuid, setting, isPwdChanged); } diff --git a/src/frontend/netdetails/securitypage.cpp b/src/frontend/netdetails/securitypage.cpp index 6d509a25..f6447b3a 100644 --- a/src/frontend/netdetails/securitypage.cpp +++ b/src/frontend/netdetails/securitypage.cpp @@ -165,112 +165,20 @@ void SecurityPage::initConnect() //EAP方式变化 connect(eapTypeCombox, &QComboBox::currentTextChanged, this, &SecurityPage::onEapTypeComboxIndexChanged); - connect(caNeedBox, &QCheckBox::clicked, this, [&](){ - if (caNeedBox->isChecked()) { - caCertPathCombox->setEnabled(false); - } else { - caCertPathCombox->setEnabled(true); - } - }); + connect(caNeedBox, &QCheckBox::clicked, this, &SecurityPage::onCaNeedBoxClicked); - connect(pwdBox, &QCheckBox::clicked, this, [&]() { - if (pwdEdit->echoMode() == QLineEdit::Password) { - pwdBox->setChecked(true); - pwdEdit->setEchoMode(QLineEdit::Normal); - } else { - pwdBox->setChecked(false); - pwdEdit->setEchoMode(QLineEdit::Password); - } + connect(pwdBox, &QCheckBox::clicked, this, &SecurityPage::onPwdBoxClicked); + connect(userPwdBox, &QCheckBox::clicked, this, &SecurityPage::onUserPwdBox); + connect(privateKeyBox, &QCheckBox::clicked, this, &SecurityPage::onPrivateKeyBoxClicked); - }); + connect(caCertPathCombox, static_cast(&QComboBox::currentIndexChanged), + this, &SecurityPage::onCaCertPathComboxIndexChanged); - connect(userPwdBox, &QCheckBox::clicked, this, [&]() { - if (userPwdEdit->echoMode() == QLineEdit::Password) { - userPwdBox->setChecked(true); - userPwdEdit->setEchoMode(QLineEdit::Normal); - } else { - userPwdBox->setChecked(false); - userPwdEdit->setEchoMode(QLineEdit::Password); - } + connect(clientCertPathCombox, static_cast(&QComboBox::currentIndexChanged), + this, &SecurityPage::onClientCertPathComboxIndexChanged); - }); - - connect(privateKeyBox, &QCheckBox::clicked, this, [&]() { - if (clientPrivateKeyPwdEdit->echoMode() == QLineEdit::Password) { - privateKeyBox->setChecked(true); - clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Normal); - } else { - privateKeyBox->setChecked(false); - clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Password); - } - - }); - - connect(caCertPathCombox, static_cast(&QComboBox::currentIndexChanged), this, [=] (const QString &str) { - if (str.contains("Choose from file...") || str.contains("从文件选择...")) - { - QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///", - tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)")); - if (!fileName.isNull()) { - QStringList nameList = fileName.split("/"); - caCertPathCombox->blockSignals(true); - caCertPathCombox->setItemText(0, fileName); - caCertPathCombox->setCurrentIndex(0); - caCertPathCombox->blockSignals(false); - } else { - caCertPathCombox->blockSignals(true); - caCertPathCombox->setItemText(0, tr("None")); - caCertPathCombox->setCurrentIndex(0); - caCertPathCombox->blockSignals(false); - } - } else { - qWarning() << "Choose file is null or unvalible"; - } - }); - - connect(clientCertPathCombox, static_cast(&QComboBox::currentIndexChanged), this, [=] (const QString &str) { - if (str.contains("Choose from file...") || str.contains("从文件选择...")) - { - QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///", - tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)")); - if (!fileName.isNull()) { -// QStringList nameList = fileName.split("/"); - clientCertPathCombox->blockSignals(true); - clientCertPathCombox->setItemText(0, fileName); - clientCertPathCombox->setCurrentIndex(0); - clientCertPathCombox->blockSignals(false); - } else { - clientCertPathCombox->blockSignals(true); - clientCertPathCombox->setItemText(0, tr("None")); - clientCertPathCombox->setCurrentIndex(0); - clientCertPathCombox->blockSignals(false); - } - } else { - qWarning() << "Choose file is null or unvalible"; - } - }); - - connect(clientPrivateKeyCombox, static_cast(&QComboBox::currentIndexChanged), this, [=] (const QString &str) { - if (str.contains("Choose from file...") || str.contains("从文件选择...")) - { - QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///", - tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)")); - if (!fileName.isNull()) { - QStringList nameList = fileName.split("/"); - clientPrivateKeyCombox->blockSignals(true); - clientPrivateKeyCombox->setItemText(0, fileName); - clientPrivateKeyCombox->setCurrentIndex(0); - clientPrivateKeyCombox->blockSignals(false); - } else { - clientPrivateKeyCombox->blockSignals(true); - clientPrivateKeyCombox->setItemText(0, tr("None")); - clientPrivateKeyCombox->setCurrentIndex(0); - clientPrivateKeyCombox->blockSignals(false); - } - } else { - qWarning() << "Choose file is null or unvalible"; - } - }); + connect(clientPrivateKeyCombox, static_cast(&QComboBox::currentIndexChanged), + this, &SecurityPage::onClientPrivateKeyComboxIndexChanged); connect(secuTypeCombox, SIGNAL(currentIndexChanged(QString)), this, SLOT(setEnableOfSaveBtn())); connect(pwdEdit, &QLineEdit::textChanged, this, &SecurityPage::setEnableOfSaveBtn); @@ -740,3 +648,114 @@ void SecurityPage::onEapTypeComboxIndexChanged() eapMethodCombox->addItem("gtc(eap)", GTC_EAP); } } + +void SecurityPage::onCaNeedBoxClicked() +{ + if (caNeedBox->isChecked()) { + caCertPathCombox->setEnabled(false); + } else { + caCertPathCombox->setEnabled(true); + } +} + +void SecurityPage::onPwdBoxClicked() +{ + if (pwdEdit->echoMode() == QLineEdit::Password) { + pwdBox->setChecked(true); + pwdEdit->setEchoMode(QLineEdit::Normal); + } else { + pwdBox->setChecked(false); + pwdEdit->setEchoMode(QLineEdit::Password); + } +} + +void SecurityPage::onUserPwdBox() +{ + if (userPwdEdit->echoMode() == QLineEdit::Password) { + userPwdBox->setChecked(true); + userPwdEdit->setEchoMode(QLineEdit::Normal); + } else { + userPwdBox->setChecked(false); + userPwdEdit->setEchoMode(QLineEdit::Password); + } + +} + +void SecurityPage::onPrivateKeyBoxClicked() +{ + if (clientPrivateKeyPwdEdit->echoMode() == QLineEdit::Password) { + privateKeyBox->setChecked(true); + clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Normal); + } else { + privateKeyBox->setChecked(false); + clientPrivateKeyPwdEdit->setEchoMode(QLineEdit::Password); + } +} + +void SecurityPage::onCaCertPathComboxIndexChanged(QString str) +{ + if (str.contains("Choose from file...") || str.contains("从文件选择...")) + { + QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///", + tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)")); + if (!fileName.isNull()) { + QStringList nameList = fileName.split("/"); + caCertPathCombox->blockSignals(true); + caCertPathCombox->setItemText(0, fileName); + caCertPathCombox->setCurrentIndex(0); + caCertPathCombox->blockSignals(false); + } else { + caCertPathCombox->blockSignals(true); + caCertPathCombox->setItemText(0, tr("None")); + caCertPathCombox->setCurrentIndex(0); + caCertPathCombox->blockSignals(false); + } + } else { + qWarning() << "Choose file is null or unvalible"; + } +} + +void SecurityPage::onClientCertPathComboxIndexChanged(QString str) +{ + if (str.contains("Choose from file...") || str.contains("从文件选择...")) + { + QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///", + tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)")); + if (!fileName.isNull()) { + clientCertPathCombox->blockSignals(true); + clientCertPathCombox->setItemText(0, fileName); + clientCertPathCombox->setCurrentIndex(0); + clientCertPathCombox->blockSignals(false); + } else { + clientCertPathCombox->blockSignals(true); + clientCertPathCombox->setItemText(0, tr("None")); + clientCertPathCombox->setCurrentIndex(0); + clientCertPathCombox->blockSignals(false); + } + } else { + qWarning() << "Choose file is null or unvalible"; + } +} + +void SecurityPage::onClientPrivateKeyComboxIndexChanged(QString str) +{ + if (str.contains("Choose from file...") || str.contains("从文件选择...")) + { + QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a CA certificate"), "recent:///", + tr("CA Files (*.pem *.der *.p12 *.crt *.cer *.pfx)")); + if (!fileName.isNull()) { + QStringList nameList = fileName.split("/"); + clientPrivateKeyCombox->blockSignals(true); + clientPrivateKeyCombox->setItemText(0, fileName); + clientPrivateKeyCombox->setCurrentIndex(0); + clientPrivateKeyCombox->blockSignals(false); + } else { + clientPrivateKeyCombox->blockSignals(true); + clientPrivateKeyCombox->setItemText(0, tr("None")); + clientPrivateKeyCombox->setCurrentIndex(0); + clientPrivateKeyCombox->blockSignals(false); + } + } else { + qWarning() << "Choose file is null or unvalible"; + } +} diff --git a/src/frontend/netdetails/securitypage.h b/src/frontend/netdetails/securitypage.h index 153c04c2..34669022 100644 --- a/src/frontend/netdetails/securitypage.h +++ b/src/frontend/netdetails/securitypage.h @@ -96,6 +96,15 @@ private slots: void onEapTypeComboxIndexChanged(); void setEnableOfSaveBtn(); + void onCaNeedBoxClicked(); + void onPwdBoxClicked(); + void onUserPwdBox(); + void onPrivateKeyBoxClicked(); + + void onCaCertPathComboxIndexChanged(QString str); + void onClientCertPathComboxIndexChanged(QString str); + void onClientPrivateKeyComboxIndexChanged(QString str); + signals: void setSecuPageState(bool); }; diff --git a/src/frontend/new-mainwindow.cpp b/src/frontend/new-mainwindow.cpp index 1ea1d72e..61178d4e 100644 --- a/src/frontend/new-mainwindow.cpp +++ b/src/frontend/new-mainwindow.cpp @@ -153,12 +153,15 @@ void MainWindow::initDbusConnnect() connect(m_wlanWidget, &WlanPage::activateFailed, this, &MainWindow::activateFailed); connect(m_wlanWidget, &WlanPage::deactivateFailed, this, &MainWindow::deactivateFailed); - connect(m_lanWidget, &LanPage::listUpdate, this, &MainWindow::listUpdate); - connect(m_wlanWidget, &WlanPage::listUpdate, this, &MainWindow::listUpdate); + connect(m_lanWidget, &LanPage::lanAdd, this, &MainWindow::lanAdd); + connect(m_lanWidget, &LanPage::lanRemove, this, &MainWindow::lanRemove); + connect(m_lanWidget, &LanPage::lanUpdate, this, &MainWindow::lanUpdate); + connect(m_lanWidget, &LanPage::lanActiveConnectionStateChanged, this, &MainWindow::lanActiveConnectionStateChanged); - connect(m_lanWidget, &LanPage::wiredActivating, this, &MainWindow::wiredActivating); - connect(m_wlanWidget, &WlanPage::wirelessActivating, this, &MainWindow::wirelessActivating); + connect(m_wlanWidget, &WlanPage::wlanAdd, this, &MainWindow::wlanAdd); + connect(m_wlanWidget, &WlanPage::wlanRemove, this, &MainWindow::wlanRemove); + connect(m_wlanWidget, &WlanPage::wlanActiveConnectionStateChanged, this, &MainWindow::wlanactiveConnectionStateChanged); connect(m_wlanWidget, &WlanPage::hotspotDeactivated, this, &MainWindow::hotspotDeactivated); connect(m_wlanWidget, &WlanPage::hotspotActivated, this, &MainWindow::hotspotActivated); connect(m_wlanWidget, &WlanPage::secuTypeChange, this, &MainWindow::secuTypeChange); @@ -431,7 +434,9 @@ void MainWindow::showPropertyWidget(QString devName, QString ssid) return; } - qDebug() << "showPropertyWidget no such device " << devName; + qWarning() << "showPropertyWidget no such device " << devName; + delete devResourse; + devResourse = nullptr; } void MainWindow::showCreateWiredConnectWidget(const QString devName) diff --git a/src/frontend/new-mainwindow.h b/src/frontend/new-mainwindow.h index fcf35509..49a113ba 100644 --- a/src/frontend/new-mainwindow.h +++ b/src/frontend/new-mainwindow.h @@ -52,11 +52,14 @@ signals: void deviceStatusChanged(); //设备名称变化 void deviceNameChanged(QString oldName, QString newName); - //设备有线无线列表更新(有线增删、无线增加减少) - void listUpdate(QString devName); - //控制面板连接中 - void wiredActivating(QString devName, QString ssid); - void wirelessActivating(QString devName, QString ssid); + //有线无线列表更新(有线增删、无线增加减少) + void lanAdd(QString devName, QStringList info); + void lanRemove(QString dbusPath); + void lanUpdate(QString devName, QStringList info); + void wlanAdd(QString devName, QStringList info); + void wlanRemove(QString devName,QString ssid); + void wlanactiveConnectionStateChanged(QString devName, QString ssid, int status); + void lanActiveConnectionStateChanged(QString devName, QString uuid, int status); void activateFailed(QString errorMessage); void deactivateFailed(QString errorMessage); //热点断开 diff --git a/src/frontend/tab-pages/lanpage.cpp b/src/frontend/tab-pages/lanpage.cpp index e09ed664..363d4b2e 100644 --- a/src/frontend/tab-pages/lanpage.cpp +++ b/src/frontend/tab-pages/lanpage.cpp @@ -38,6 +38,7 @@ LanPage::LanPage(QWidget *parent) : TabPage(parent) connect(m_activeResourse, &KyActiveConnectResourse::stateChangeReason, this, &LanPage::updateLanlist); connect(m_connectResourse, &KyConnectResourse::connectionAdd, this, &LanPage::addConnectionSlot); connect(m_connectResourse, &KyConnectResourse::connectionRemove, this, &LanPage::removeConnectionSlot); + connect(m_connectResourse, &KyConnectResourse::connectionUpdate, this, &LanPage::connectionUpdateSlot); connect(m_device, &KyNetworkDeviceResourse::deviceAdd, this, &LanPage::onDeviceAdd); connect(m_device, &KyNetworkDeviceResourse::deviceRemove, this, &LanPage::onDeviceRemove); connect(m_device, &KyNetworkDeviceResourse::deviceNameUpdate, this, &LanPage::onDeviceNameUpdate); @@ -121,6 +122,10 @@ void LanPage::onLanSwitchClicked() void LanPage::removeConnectionSlot(QString path) //删除时后端会自动断开激活,将其从未激活列表中删除 { + //for dbus + qDebug() << "[LanPage] emit lanRemove because removeConnectionSlot " << path; + emit lanRemove(path); + qDebug()<<"[LanPage] Removing a connection, path:"<m_ifaceName; - emit listUpdate(item->m_ifaceName); break; } } - if (!isLan) { - //removeConnection不是当前设备的,可能是其他有线设备或无线设备,保险起见发送信号更新 - for (int index = 0; index < devList.size(); ++index) { - if (devList.at(index) == m_deviceName) { - continue; - } - emit listUpdate(devList.at(index)); - } - } } void LanPage::addConnectionSlot(QString uuid) //新增一个有线连接,将其加入到激活列表 @@ -167,8 +160,14 @@ void LanPage::addConnectionSlot(QString uuid) //新增一个有线 } //for dbus - qDebug() << "[LanPage] emit listUpdate because addConnection " << devName; - emit listUpdate(devName); + KyConnectItem *item = nullptr; + item = m_connectResourse->getConnectionItemByUuid(uuid, devName); + if (nullptr != item) { + QStringList info; + info << item->m_connectName << uuid << item->m_connectPath; + qDebug() << "[LanPage] emit lanAdd because addConnection " << devName; + emit lanAdd(devName, info); + } KyConnectItem * newItem = m_connectResourse->getConnectionItemByUuid(uuid, m_deviceName); if (newItem != nullptr) { @@ -182,6 +181,41 @@ void LanPage::addConnectionSlot(QString uuid) //新增一个有线 qDebug()<<"[LanPage] GetConnectionItemByUuid is empty when add a new!"; } } +void LanPage::connectionUpdateSlot(QString uuid) +{ + //for dbus + QStringList devNameList; + if (m_activeResourse->isActiveConnection(uuid, devNameList)) { + for (int i = 0; i < devNameList.size(); ++i) { + KyConnectItem *item = nullptr; + item = m_activeResourse->getActiveConnectionByUuid(uuid, devNameList.at(i)); + if (nullptr != item) { + if (item->m_itemType != NetworkManager::ConnectionSettings::ConnectionType::Wired) { + return; + } + QStringList info; + info << item->m_connectName << uuid << item->m_connectPath; + emit lanUpdate(devNameList.at(i), info); + } + } + } else { + QString devName; + NetworkManager::ConnectionSettings::ConnectionType type; + if (!m_connectResourse->getInterfaceByUuid(devName, type, uuid)) { + return; + } + if (type != NetworkManager::ConnectionSettings::ConnectionType::Wired) { + return; + } + KyConnectItem *item = nullptr; + item = m_connectResourse->getConnectionItemByUuid(uuid, devName); + if (nullptr != item) { + QStringList info; + info << item->m_connectName << uuid << item->m_connectPath; + emit lanUpdate(devName, info); + } + } +} void LanPage::initDevice() { @@ -413,16 +447,23 @@ void LanPage::updateLanlist(QString uuid, NetworkManager::ActiveConnection::Stat qDebug() << "[LanPage] updateLanlist but uuid is invalid"; } - if (state == NetworkManager::ActiveConnection::State::Activating) { - qDebug() << "[LanPage] wiredActivating " << devName; - emit wiredActivating(devName,uuid); + QStringList devNameList; + if (m_activeResourse->isActiveConnection(uuid, devNameList)) { + for (int i = 0; i < devNameList.size(); ++i) { + KyConnectItem *item = nullptr; + item = m_activeResourse->getActiveConnectionByUuid(uuid, devNameList.at(i)); + if (nullptr != item) { + QStringList info; + info << item->m_connectName << uuid << item->m_connectPath; + emit lanActiveConnectionStateChanged(devNameList.at(i), uuid, state); + } + } + } else { + qDebug() << "emit lanActiveConnectionStateChanged" << devName << uuid << state; + emit lanActiveConnectionStateChanged(devName, uuid, state); } - if (state == NetworkManager::ActiveConnection::State::Activated || state == NetworkManager::ActiveConnection::State::Deactivated) - { - qDebug() << "[LanPage] because updateLanlist " < > &map) QVector vector; m_activeResourse->getActiveConnectionList(deviceName,NetworkManager::ConnectionSettings::Wired,activedList); if (!activedList.isEmpty()) { - vector.append(QStringList()<m_connectName<m_connectUuid); + vector.append(QStringList() << activedList.at(0)->m_connectName << activedList.at(0)->m_connectUuid << activedList.at(0)->m_connectPath); } else { vector.append(QStringList()<<("--")); } @@ -560,14 +601,13 @@ void LanPage::showDetailPage(QString devName, QString uuid) item = m_activeResourse->getActiveConnectionByUuid(uuid, devName); if (nullptr == item) { item = m_connectResourse->getConnectionItemByUuid(uuid, devName); + if (nullptr == item) { + qWarning()<<"[LanPage] GetConnectionItemByUuid is empty when showDetailPage"; + return; + } isActive= false; } - if (nullptr == item) { - qDebug()<<"[LanPage] GetConnectionItemByUuid is empty when showDetailPage"; - return; - } - NetDetail *netDetail = new NetDetail(devName, item->m_connectName, uuid, isActive, false, false, this); netDetail->show(); delete item; diff --git a/src/frontend/tab-pages/lanpage.h b/src/frontend/tab-pages/lanpage.h index c01fe7f6..a370366c 100644 --- a/src/frontend/tab-pages/lanpage.h +++ b/src/frontend/tab-pages/lanpage.h @@ -29,8 +29,10 @@ public: void showDetailPage(QString devName, QString uuid); void setWiredDeviceEnable(const QString& devName, bool enable); signals: - void wiredActivating(QString devName, QString ssid); - + void lanAdd(QString devName, QStringList info); + void lanRemove(QString dbusPath); + void lanUpdate(QString devName, QStringList info); + void lanActiveConnectionStateChanged(QString interface, QString uuid, int status); private: void initDevice();//初始化默认设备 void initDeviceCombox(); @@ -72,6 +74,7 @@ private slots: void updateLanlist(QString uuid, NetworkManager::ActiveConnection::State state, NetworkManager::ActiveConnection::Reason reason); void addConnectionSlot(QString uuid); void removeConnectionSlot(QString path); + void connectionUpdateSlot(QString uuid); void onSwithGsettingsChanged(const QString &key); void onLanSwitchClicked(); void onDeviceAdd(QString deviceName, NetworkManager::Device::Type deviceType); diff --git a/src/frontend/tab-pages/tabpage.h b/src/frontend/tab-pages/tabpage.h index 1cee2a08..7810a382 100644 --- a/src/frontend/tab-pages/tabpage.h +++ b/src/frontend/tab-pages/tabpage.h @@ -56,7 +56,6 @@ signals: void deviceNameChanged(QString oldName, QString newName); void activateFailed(QString errorMessage); void deactivateFailed(QString errorMessage); - void listUpdate(QString devName); protected: void initUI(); diff --git a/src/frontend/tab-pages/wlanpage.cpp b/src/frontend/tab-pages/wlanpage.cpp index 94c34a20..4a7c1191 100644 --- a/src/frontend/tab-pages/wlanpage.cpp +++ b/src/frontend/tab-pages/wlanpage.cpp @@ -106,8 +106,6 @@ void WlanPage::initConnections() { connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::onWlanAdded); connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::onWlanRemoved); - connect(m_resource, &KyWirelessNetResource::wifiNetworkAdd, this, &WlanPage::listUpdate); - connect(m_resource, &KyWirelessNetResource::wifiNetworkRemove, this, &WlanPage::listUpdate); connect(m_resource, &KyWirelessNetResource::signalStrengthChange, this, &WlanPage::signalStrengthChange); connect(m_resource, &KyWirelessNetResource::secuTypeChange, this, &WlanPage::secuTypeChange); @@ -290,7 +288,12 @@ void WlanPage::getAllWlan() void WlanPage::onWlanAdded(QString interface, KyWirelessNetItem &item) { - emit listUpdate(interface); + //for dbus + QStringList info; + info < apConnectItemList; diff --git a/src/frontend/tab-pages/wlanpage.h b/src/frontend/tab-pages/wlanpage.h index 0b37cead..351c9565 100644 --- a/src/frontend/tab-pages/wlanpage.h +++ b/src/frontend/tab-pages/wlanpage.h @@ -36,7 +36,9 @@ public: void showDetailPage(QString devName, QString uuid); signals: void oneItemExpanded(const QString &ssid); - void wirelessActivating(QString devName, QString ssid); + void wlanAdd(QString devName, QStringList info); + void wlanRemove(QString devName,QString ssid); + void wlanActiveConnectionStateChanged(QString interface, QString ssid, int status); void hotspotDeactivated(QString devName, QString ssid); void hotspotActivated(QString devName, QString ssid); void signalStrengthChange(QString devName, QString ssid, int strength);