fix(wifi): Wifi can not be connected which security is changed to be psk from eap.

Description: 修复wifi安全性变更后无法正常连接的bug

Log: 修复wifi安全性变更后无法正常连接的bug
Bug: http://172.17.66.192/biz/bug-view-34664.html
This commit is contained in:
zhangjiaping 2021-02-04 09:02:08 +08:00
parent 7b73f52e2e
commit 13c4a25d15
4 changed files with 41 additions and 1 deletions

View File

@ -559,6 +559,26 @@ void OneConnForm::toConnectWirelessNetwork()
}
}
//有配置文件需要判断一下当前配置文件wifi安全性是不是wpa-eap若是需要把原配置文件删除重新配置
QProcess * process = new QProcess(this);
process->start(QString("nmcli -f 802-11-wireless-security.key-mgmt connection show %1").arg(lbNameText->text()));
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});
connect(process, &QProcess::readyReadStandardOutput, this, [ = ]() {
QString str = process->readAllStandardOutput();
key_mgmt = str.mid(str.lastIndexOf(" ") + 1, str.length() - str.lastIndexOf(" ") - 2);
});
process->waitForFinished();
if (QString::compare(key_mgmt, "wpa-eap") == 0) {
//原配置文件是企业wifi删掉请求输入新的密码
QString cmdStr = "nmcli connection delete " + lbNameText->text();
Utils::m_system(cmdStr.toUtf8().data());
psk_flag = 0;
slotConnWifiResult(2); //现在已无配置文件,申请输入密码
return;
}
if (isWifiConfExist(lbNameText->text())) {
//有配置文件,获取密码存储策略
QProcess * process = new QProcess(this);

View File

@ -141,6 +141,7 @@ private:
QLabel * lbFreq = nullptr;
QLabel * lbNameText = nullptr;
QHBoxLayout * lbNameLyt = nullptr;
QString key_mgmt;
signals:
void selectedOneWifiForm(QString wifiName, int extendLength);

View File

@ -18,7 +18,6 @@
#include "wpawifidialog.h"
#include "ui_wpawifidialog.h"
#include "kylin-network-interface.h"
#include "backthread.h"
#include "utils.h"
#include "mainwindow.h"
#include "wireless-security/kylinheadfile.h"
@ -440,6 +439,24 @@ void WpaWifiDialog::slot_on_connectBtn_clicked() {
QString cmdStr = "nmcli connection modify " + nameEditor->text() + " ipv4.method auto";
int res = Utils::m_system(cmdStr.toUtf8().data());
if (res == 0) {
//有配置文件需要判断一下当前配置文件wifi安全性是不是wpa-eap若不是需要把原配置文件删除重新配置
QProcess * process = new QProcess(this);
process->start(QString("nmcli -f 802-11-wireless-security.key-mgmt connection show %1").arg(nameEditor->text()));
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
process->deleteLater();
});
connect(process, &QProcess::readyReadStandardOutput, this, [ = ]() {
QString str = process->readAllStandardOutput();
key_mgmt = str.mid(str.lastIndexOf(" ") + 1, str.length() - str.lastIndexOf(" ") - 2);
});
process->waitForFinished();
if (QString::compare(key_mgmt, "wpa-eap")) {
//原配置文件不是企业wifi删掉重新创建
QString cmdStr = "nmcli connection delete " + nameEditor->text();
Utils::m_system(cmdStr.toUtf8().data());
goto next;
}
process->waitForFinished();
//有网络配置文件,接下来修改网络配置,然后激活连接
qDebug()<<"qDebug: 有配置文件,修改配置后激活:"<<"\n"<<
"qDebug: nmcli connection modify " + nameEditor->text() + " 802-1x.eap " + eapCombox->currentData().toString() + " 802-1x.phase2-auth "
@ -452,6 +469,7 @@ void WpaWifiDialog::slot_on_connectBtn_clicked() {
//激活连接
activateConnection();
} else {
next:
//无网络配置文件,需要新创建
//获取网卡名称
KylinDBus mkylindbus;

View File

@ -92,6 +92,7 @@ private:
QStringList wifi_info;
bool has_config;
QStringList user_list;
QString key_mgmt = "wpa-eap";
MainWindow *mw;