Fix bug wifi need connect twice wihthout compare bssid

This commit is contained in:
chenlelin 2021-04-07 20:22:52 +08:00
parent 51ef115902
commit 15d2f30f66
4 changed files with 28 additions and 6 deletions

View File

@ -3630,6 +3630,11 @@ void MainWindow::connWifiDone(int connFlag)
is_stop_check_net_state = 0;
}
void MainWindow::onRequestRefreshWifiList()
{
this->ksnm->execGetWifiList(this->wcardname);
}
//重新绘制背景色
void MainWindow::paintEvent(QPaintEvent *event)
{

View File

@ -225,6 +225,7 @@ public slots:
void on_wifi_changed();
void connWifiDone(int connFlag);
void onRequestRefreshWifiList();
//flag =0或1为普通点击、2为收到打开信息、3为收到关闭信息、4为无线网卡插入、5为无线网卡拔出
void onBtnWifiClicked(int flag = 0);

View File

@ -189,6 +189,8 @@ OneConnForm::OneConnForm(QWidget *parent, MainWindow *mainWindow, ConfForm *conf
lbNameLyt->addWidget(lbFreq);
lbNameLyt->addStretch();
ui->lbName->setLayout(lbNameLyt);
connect(this, SIGNAL(requestRefreshWifiList()), mw, SLOT(onRequestRefreshWifiList()));
}
OneConnForm::~OneConnForm()
@ -908,13 +910,26 @@ void OneConnForm::slotConnWifiResult(int connFlag)
if (connFlag == 0) {
if (mw->isHuaWeiPC) {
//network-manager可能回连接到其他bssid对应的网络改成我们想要连接的那个网络
QFuture < void > future1 = QtConcurrent::run([=]() {
//network-manager可能会连接到其他bssid对应的网络改成我们想要连接的那个网络
QtConcurrent::run([=]() {
QString currConnWifiBssid;
KylinDBus myKylinDbus;
QStringList wifiListInfo;
QList<QString> wifiSsidAndUuid = myKylinDbus.getAtiveWifiBSsidUuid(wifiListInfo);
if (wifiSsidAndUuid.size() > 1 && wifiSsidAndUuid.at(1).length() == 17) {
qDebug() << "想要连接的wifi的bssid是 " << wifiSsidAndUuid.at(1);
currConnWifiBssid = wifiSsidAndUuid.at(1);
}
qDebug() << "实际连接的wifi的bssid是 " << wifiBSsid;
QString modityCmd = "nmcli connection modify \""+ wifiName + "\" " + "802-11-wireless.bssid " + wifiBSsid;
system(modityCmd.toUtf8().data());
QString reconnectWifiCmd = "nmcli connection up \"" + wifiName + "\"";
system(reconnectWifiCmd.toUtf8().data());
if (currConnWifiBssid != wifiBSsid && !currConnWifiBssid.isEmpty()) {
QString modityCmd = "nmcli connection modify \""+ wifiName + "\" " + "802-11-wireless.bssid " + wifiBSsid;
system(modityCmd.toUtf8().data());
QString reconnectWifiCmd = "nmcli connection up \"" + wifiName + "\"";
system(reconnectWifiCmd.toUtf8().data());
} else {
emit requestRefreshWifiList();
}
});
}

View File

@ -150,6 +150,7 @@ signals:
void selectedOneWifiForm(QString wifiName, int extendLength);
void connDone(int connFlag);
void disconnActiveWifi();
void requestRefreshWifiList();
void sigConnWifi(QString);
void sigConnWifiPWD(QString, QString, QString);