From 13c4a25d15fdcc0aca7057b108443a88b1825c7d Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Thu, 4 Feb 2021 09:02:08 +0800 Subject: [PATCH 1/2] fix(wifi): Wifi can not be connected which security is changed to be psk from eap. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 修复wifi安全性变更后无法正常连接的bug Log: 修复wifi安全性变更后无法正常连接的bug Bug: http://172.17.66.192/biz/bug-view-34664.html --- src/oneconnform.cpp | 20 ++++++++++++++++++++ src/oneconnform.h | 1 + src/wpawifidialog.cpp | 20 +++++++++++++++++++- src/wpawifidialog.h | 1 + 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/oneconnform.cpp b/src/oneconnform.cpp index 1f2f0cd5..ac79faaf 100644 --- a/src/oneconnform.cpp +++ b/src/oneconnform.cpp @@ -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(&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); diff --git a/src/oneconnform.h b/src/oneconnform.h index 07c225d2..08b09060 100644 --- a/src/oneconnform.h +++ b/src/oneconnform.h @@ -141,6 +141,7 @@ private: QLabel * lbFreq = nullptr; QLabel * lbNameText = nullptr; QHBoxLayout * lbNameLyt = nullptr; + QString key_mgmt; signals: void selectedOneWifiForm(QString wifiName, int extendLength); diff --git a/src/wpawifidialog.cpp b/src/wpawifidialog.cpp index dd883119..497414b4 100644 --- a/src/wpawifidialog.cpp +++ b/src/wpawifidialog.cpp @@ -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(&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; diff --git a/src/wpawifidialog.h b/src/wpawifidialog.h index 23b10c6d..0058f34c 100644 --- a/src/wpawifidialog.h +++ b/src/wpawifidialog.h @@ -92,6 +92,7 @@ private: QStringList wifi_info; bool has_config; QStringList user_list; + QString key_mgmt = "wpa-eap"; MainWindow *mw; From af37207205297cd45fbe1d4c88ea0c3bc062595b Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Thu, 4 Feb 2021 20:01:02 +0800 Subject: [PATCH 2/2] fix(lan): Lan will be disconnected when connect vpn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description: 修复连接vpn时有线网断开的bug Log: 修复连接vpn时有线网断开的bug Bug: http://172.17.66.192/biz/bug-view-34639.html --- src/backthread.cpp | 8 ++++---- src/mainwindow.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backthread.cpp b/src/backthread.cpp index 4505d6d8..c0749d13 100644 --- a/src/backthread.cpp +++ b/src/backthread.cpp @@ -213,10 +213,10 @@ void BackThread::execConnLan(QString connName, QString ifname, QString connectTy KylinDBus objKyDbus; //先断开当前网卡对应的已连接有线网 - QString uuid = objKyDbus.getConnLanNameByIfname(ifname); - if (uuid != "--") { - kylin_network_set_con_down(uuid.toUtf8().data()); - } +// QString uuid = objKyDbus.getConnLanNameByIfname(ifname); +// if (uuid != "--") { +// kylin_network_set_con_down(uuid.toUtf8().data()); +// } bool wiredCableState = objKyDbus.getWiredCableStateByIfname(ifname); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 431afd38..7cf6230c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2918,7 +2918,6 @@ void MainWindow::connLanDone(int connFlag) if (connFlag == 1) { syslog(LOG_DEBUG, "without net line connect to computer."); - is_stop_check_net_state = 0; QString txt(tr("Without Lan Cable")); objKyDBus->showDesktopNotify(txt); @@ -2977,6 +2976,7 @@ void MainWindow::connLanDone(int connFlag) } this->stopLoading(); + this->is_stop_check_net_state = 0; } void MainWindow::connWifiDone(int connFlag)