Merge branch 'up-dbus' into 'dbus-interface'

Up dbus

See merge request kylin-desktop/kylin-nm!349
This commit is contained in:
ren peijia 2021-10-22 05:46:53 +00:00
commit c26f6ef676
5 changed files with 70 additions and 23 deletions

View File

@ -38,7 +38,7 @@ public:
&& this->clientCertPath == info.clientCertPath
&& this->clientPrivateKey == info.clientPrivateKey
&& this->clientPrivateKeyPWD == info.clientPrivateKeyPWD
/*&& this->m_privateKeyPWDFlag == info.m_privateKeyPWDFlag*/) {
&& this->m_privateKeyPWDFlag == info.m_privateKeyPWDFlag) {
return true;
} else {
return false;
@ -83,7 +83,7 @@ public:
if (this->phase2AuthMethod == info.phase2AuthMethod
&& this->userName == info.userName
&& this->userPWD == info.userPWD
/*&& this->m_passwdFlag == info.m_passwdFlag*/) {
&& this->m_passwdFlag == info.m_passwdFlag) {
return true;
} else {
return false;
@ -116,7 +116,7 @@ public:
if (this->authEapMethod == info.authEapMethod
&& this ->userName == info.userName
&& this->userPWD == info.userPWD
/*&& this->m_passwdFlag == info.m_passwdFlag*/) {
&& this->m_passwdFlag == info.m_passwdFlag) {
return true;
}
} else {
@ -124,7 +124,7 @@ public:
if (this->authNoEapMethod == info.authNoEapMethod
&& this ->userName == info.userName
&& this->userPWD == info.userPWD
/*&& this->m_passwdFlag == info.m_passwdFlag*/) {
&& this->m_passwdFlag == info.m_passwdFlag) {
return true;
}
}

View File

@ -3,6 +3,7 @@
#include <networkmanagerqt/wirelesssecuritysetting.h>
#define PSK_SETTING_NAME "802-11-wireless-security"
#define PRIVATE_PSK_SETTING_NAME "802-1x"
NetworkManager::ConnectionSettings::Ptr assembleWpaXPskSettings(NetworkManager::AccessPoint::Ptr accessPoint, QString &psk, bool isAutoConnect)
{
@ -296,7 +297,7 @@ QString KyWirelessConnectOperation::getPrivateKeyPassword(const QString &connect
qWarning()<<errorMessage;
return "";
}
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PSK_SETTING_NAME);
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PRIVATE_PSK_SETTING_NAME);
QMap<QString,QVariantMap> map(reply.value());
if (map.contains("802-1x")
&& map.value("802-1x").contains("private-key-password")) {
@ -316,7 +317,7 @@ QString KyWirelessConnectOperation::get8021xPassword(const QString &connectUuid)
qWarning()<<errorMessage;
return "";
}
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PSK_SETTING_NAME);
QDBusPendingReply<NMVariantMapMap> reply = connectPtr->secrets(PRIVATE_PSK_SETTING_NAME);
QMap<QString,QVariantMap> map(reply.value());
if (map.contains("802-1x") && map.value("802-1x").contains("password"))
{
@ -909,6 +910,8 @@ void KyWirelessConnectOperation::updateWirelessSecu(NetworkManager::ConnectionSe
security_sett->setKeyMgmt((NetworkManager::WirelessSecuritySetting::KeyMgmt)type);
if (bPwdChange) {
security_sett->setPsk(connSettingInfo.m_psk);
NetworkManager::Setting::SecretFlags flag = NetworkManager::Setting::None;
security_sett->setPskFlags(flag);
}
return;
}

View File

@ -438,9 +438,21 @@ bool KyWirelessNetResource::getEnterPriseInfoTls(QString &uuid, KyEapMethodTlsIn
info.identity = setting->identity();
info.domain = setting->domainSuffixMatch();
info.caCertPath = setting->caPath();
if (info.caCertPath.left(7) == "file://") {
info.caCertPath = info.caCertPath.mid(7);
}
info.clientCertPath = setting->clientCertificate();
if (info.clientCertPath.left(7) == "file://") {
info.clientCertPath = info.clientCertPath.mid(7);
}
info.clientPrivateKey = QString(setting->privateKey());
info.clientPrivateKeyPWD = m_operation->getPrivateKeyPassword(conn->uuid());
if (info.clientPrivateKey.left(7) == "file://") {
info.clientPrivateKey = info.clientPrivateKey.mid(7);
}
info.m_privateKeyPWDFlag = setting->privateKeyPasswordFlags();
if (!info.m_privateKeyPWDFlag) {
info.clientPrivateKeyPWD = m_operation->getPrivateKeyPassword(conn->uuid());
}
return true;
}
@ -470,7 +482,10 @@ bool KyWirelessNetResource::getEnterPriseInfoPeap(QString &uuid, KyEapMethodPeap
info.phase2AuthMethod = (KyNoEapMethodAuth)setting->phase2AuthMethod();
info.userName = setting->identity();
info.userPWD = m_operation->get8021xPassword(conn->uuid());
info.m_passwdFlag = setting->passwordFlags();
if (!info.m_passwdFlag) {
info.userPWD = m_operation->get8021xPassword(conn->uuid());
}
return true;
}
@ -510,7 +525,10 @@ bool KyWirelessNetResource::getEnterPriseInfoTtls(QString &uuid, KyEapMethodTtls
info.authType = KyTtlsAuthMethod::AUTH_NO_EAP;
}
info.userName = setting->identity();
info.userPWD = m_operation->get8021xPassword(conn->uuid());
info.m_passwdFlag = setting->passwordFlags();
if (!info.m_passwdFlag) {
info.userPWD = m_operation->get8021xPassword(conn->uuid());
}
return true;

View File

@ -12,6 +12,13 @@
#define AUTO_CONFIG 0
#define MANUAL_CONFIG 1
enum PeapInnerType
{
MSCHAPV2_PEAP = 0,
MD5_PEAP,
GTC_PEAP,
};
enum TtlsInnerType
{
PAP = 0,

View File

@ -242,10 +242,16 @@ void SecurityPage::setPeapInfo(KyEapMethodPeapInfo &info)
showPeapOrTtls();
eapTypeCombox->setCurrentIndex(PEAP);
onEapTypeComboxIndexChanged();
eapMethodCombox->setCurrentIndex(info.phase2AuthMethod);
if (info.phase2AuthMethod == KyAuthMethodMschapv2) {
eapMethodCombox->setCurrentIndex(MSCHAPV2_PEAP);
} else if (info.phase2AuthMethod == KyAuthMethodMd5){
eapMethodCombox->setCurrentIndex(MD5_PEAP);
} else if (info.phase2AuthMethod == KyAuthMethodGtc) {
eapMethodCombox->setCurrentIndex(GTC_PEAP);
}
userNameEdit->setText(info.userName);
userPwdEdit->setText(info.userPWD);
if (info.m_passwdFlag & NetworkManager::Setting::NotSaved) {
if (info.m_passwdFlag) {
userPwdFlagBox->setChecked(true);
} else {
userPwdFlagBox->setChecked(false);
@ -283,7 +289,7 @@ void SecurityPage::setTtlsInfo(KyEapMethodTtlsInfo &info)
}
userNameEdit->setText(info.userName);
userPwdEdit->setText(info.userPWD);
if (info.m_passwdFlag & NetworkManager::Setting::NotSaved) {
if (info.m_passwdFlag) {
userPwdFlagBox->setChecked(true);
} else {
userPwdFlagBox->setChecked(false);
@ -307,9 +313,9 @@ void SecurityPage::setSecurityVisible(const bool &visible)
void SecurityPage::updateTlsChange(KyEapMethodTlsInfo &info)
{
KyEapMethodTlsInfo tlsInfo = assembleTlsInfo();
// if (tlsInfo.clientPrivateKeyPWD != info.clientPrivateKeyPWD) {
if (tlsInfo.clientPrivateKeyPWD != info.clientPrivateKeyPWD) {
tlsInfo.bChanged = true;
// }
}
tlsInfo.devIfaceName = info.devIfaceName;
info = tlsInfo;
}
@ -317,18 +323,18 @@ void SecurityPage::updateTlsChange(KyEapMethodTlsInfo &info)
void SecurityPage::updatePeapChange(KyEapMethodPeapInfo &info)
{
KyEapMethodPeapInfo peapInfo = assemblePeapInfo();
// if (peapInfo.userPWD != info.userPWD) {
if (peapInfo.userPWD != info.userPWD) {
peapInfo.bChanged = true;
// }
}
info = peapInfo;
}
void SecurityPage::updateTtlsChange(KyEapMethodTtlsInfo &info)
{
KyEapMethodTtlsInfo ttlsInfo = assembleTtlsInfo();
// if (ttlsInfo.userPWD != info.userPWD) {
if (ttlsInfo.userPWD != info.userPWD) {
ttlsInfo.bChanged = true;
// }
}
info = ttlsInfo;
}
@ -529,7 +535,20 @@ KyEapMethodTlsInfo SecurityPage::assembleTlsInfo()
KyEapMethodPeapInfo SecurityPage::assemblePeapInfo()
{
KyEapMethodPeapInfo info;
info.phase2AuthMethod = (KyNoEapMethodAuth)eapMethodCombox->currentData().toInt();
// info.phase2AuthMethod = (KyNoEapMethodAuth)eapMethodCombox->currentData().toInt();
switch (eapMethodCombox->currentIndex()) {
case 0:
info.phase2AuthMethod = KyAuthMethodMschapv2;
break;
case 1:
info.phase2AuthMethod = KyAuthMethodMd5;
break;
case 2:
info.phase2AuthMethod = KyAuthMethodGtc;
break;
default:
break;
}
info.userName = userNameEdit->text();
info.userPWD = userPwdEdit->text();
info.m_passwdFlag = (userPwdFlagBox->isChecked() ? NetworkManager::Setting::NotSaved : NetworkManager::Setting::None);
@ -539,7 +558,7 @@ KyEapMethodPeapInfo SecurityPage::assemblePeapInfo()
KyEapMethodTtlsInfo SecurityPage::assembleTtlsInfo()
{
KyEapMethodTtlsInfo info;
switch (eapMethodCombox->currentData().toInt()) {
switch (eapMethodCombox->currentIndex()) {
case PAP:
info.authType = AUTH_NO_EAP;
info.authNoEapMethod = KyAuthMethodPap;
@ -671,9 +690,9 @@ void SecurityPage::onEapTypeComboxIndexChanged()
} else if (index == PEAP) {
showPeapOrTtls();
eapMethodCombox->clear();
eapMethodCombox->addItem("MSCHAPv2", KyAuthMethodMschapv2);
eapMethodCombox->addItem("MD5", KyAuthMethodMd5);
eapMethodCombox->addItem("GTC", KyAuthMethodGtc);
eapMethodCombox->addItem("MSCHAPv2", MSCHAPV2_PEAP);
eapMethodCombox->addItem("MD5", MD5_PEAP);
eapMethodCombox->addItem("GTC", GTC_PEAP);
emit this->eapTypeChanged(PEAP);
} else if (index == TTLS) {
showPeapOrTtls();