Fix bug UI stucked sometimes if use in-use property to refresh wifi list
This commit is contained in:
parent
99daef74a9
commit
c48faca769
|
@ -85,7 +85,7 @@ void KSimpleNM::execGetWifiList()
|
||||||
isExecutingGetWifiList = true;
|
isExecutingGetWifiList = true;
|
||||||
|
|
||||||
shellOutputWifi = "";
|
shellOutputWifi = "";
|
||||||
runProcessWifi->start("nmcli -f signal,security,freq,bssid,ssid device wifi");
|
runProcessWifi->start("nmcli -f in-use,signal,security,freq,bssid,ssid device wifi");
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取保存的网络列表数据
|
//获取保存的网络列表数据
|
||||||
|
|
|
@ -1014,7 +1014,7 @@ bool KylinDBus::checkNetworkConnectivity()
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取已经连接无线网络的ssid和uuid
|
//获取已经连接无线网络的ssid和uuid
|
||||||
QList<QString> KylinDBus::getAtiveWifiBSsidUuid()
|
QList<QString> KylinDBus::getAtiveWifiBSsidUuid(QStringList wifilist)
|
||||||
{
|
{
|
||||||
QList<QString> strBSsidUuid;
|
QList<QString> strBSsidUuid;
|
||||||
|
|
||||||
|
@ -1047,73 +1047,46 @@ QList<QString> KylinDBus::getAtiveWifiBSsidUuid()
|
||||||
"org.freedesktop.DBus.Properties",
|
"org.freedesktop.DBus.Properties",
|
||||||
QDBusConnection::systemBus() );
|
QDBusConnection::systemBus() );
|
||||||
|
|
||||||
//先获取uuid
|
//获取已经连接wifi的uuid
|
||||||
QDBusReply<QVariant> replyUuid = interfaceInfo.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Uuid");
|
QDBusReply<QVariant> replyUuid = interfaceInfo.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Uuid");
|
||||||
//qDebug() << "wifi uuid : "<< replyUuid.value().toString();
|
//qDebug() << "wifi uuid : "<< replyUuid.value().toString();
|
||||||
strBSsidUuid.append(replyUuid.value().toString());
|
strBSsidUuid.append(replyUuid.value().toString());
|
||||||
|
|
||||||
|
|
||||||
//再获取bssid
|
|
||||||
// QDBusMessage resultConnection = interfaceInfo.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Connection");
|
|
||||||
|
|
||||||
// QList<QVariant> outArgsConnection = resultConnection.arguments();
|
|
||||||
// QVariant firstConnection = outArgsConnection.at(0);
|
|
||||||
// QDBusVariant dbvFirstConnection = firstConnection.value<QDBusVariant>();
|
|
||||||
// QVariant vFirstConnection = dbvFirstConnection.variant();
|
|
||||||
// QDBusObjectPath dbusArgsConnection = vFirstConnection.value<QDBusObjectPath>();
|
|
||||||
|
|
||||||
// QDBusInterface interfaceSet("org.freedesktop.NetworkManager",
|
|
||||||
// dbusArgsConnection.path(),
|
|
||||||
// "org.freedesktop.NetworkManager.Settings.Connection",
|
|
||||||
// QDBusConnection::systemBus());
|
|
||||||
// QDBusMessage resultSet = interfaceSet.call("GetSettings");
|
|
||||||
|
|
||||||
// const QDBusArgument &dbusArg1stSet = resultSet.arguments().at( 0 ).value<QDBusArgument>();
|
|
||||||
// QMap<QString,QMap<QString,QVariant>> mapSet;
|
|
||||||
// dbusArg1stSet >> mapSet;
|
|
||||||
|
|
||||||
// for (QString setKey : mapSet.keys() ) {
|
|
||||||
// QMap<QString,QVariant> subSetMap = mapSet.value(setKey);
|
|
||||||
// if (setKey == "802-11-wireless") {
|
|
||||||
// for (QString searchKey : subSetMap.keys()) {
|
|
||||||
// if (searchKey == "seen-bssids") {
|
|
||||||
// //qDebug() << "wifi bssid : "<<subSetMap.value(searchKey).toStringList();
|
|
||||||
// QStringList strBssidList = subSetMap.value(searchKey).toStringList();
|
|
||||||
// foreach (QString strBssid, strBssidList) {
|
|
||||||
// strBSsidUuid.append(strBssid);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbusArgs.endArray();
|
dbusArgs.endArray();
|
||||||
|
|
||||||
QStringList wifiBSsid;
|
//获取已经连接wifi的bssid
|
||||||
QString connWifiBSsid = "--";
|
if (wifilist.size() != 0) {
|
||||||
QProcess * processWifiBSsid = new QProcess;
|
// 填充可用网络列表
|
||||||
processWifiBSsid->start("nmcli -f IN-USE,BSSID device wifi");
|
QString headLine = wifilist.at(0);
|
||||||
connect(processWifiBSsid, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName;
|
||||||
processWifiBSsid->deleteLater();
|
headLine = headLine.trimmed();
|
||||||
});
|
|
||||||
connect(processWifiBSsid, &QProcess::readyReadStandardOutput, this, [ = ]() {
|
|
||||||
QString strOutput = processWifiBSsid->readAllStandardOutput();
|
|
||||||
actWifiListInfo += strOutput;
|
|
||||||
});
|
|
||||||
processWifiBSsid->waitForFinished();
|
|
||||||
|
|
||||||
wifiBSsid = actWifiListInfo.split("\n");
|
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
|
||||||
foreach (QString strActWifiBSsid, wifiBSsid) {
|
if (isChineseExist) {
|
||||||
if (strActWifiBSsid.indexOf("*") != -1) {
|
indexSignal = headLine.indexOf("SIGNAL");
|
||||||
connWifiBSsid = strActWifiBSsid.mid(3).trimmed();
|
indexSecu = headLine.indexOf("安全性");
|
||||||
|
indexFreq = headLine.indexOf("频率") + 4;
|
||||||
|
indexBSsid = headLine.indexOf("BSSID") + 6;
|
||||||
|
indexName = indexBSsid + 19;
|
||||||
|
} else {
|
||||||
|
indexSignal = headLine.indexOf("SIGNAL");
|
||||||
|
indexSecu = headLine.indexOf("SECURITY");
|
||||||
|
indexFreq = headLine.indexOf("FREQ");
|
||||||
|
indexBSsid = headLine.indexOf("BSSID");
|
||||||
|
indexName = indexBSsid + 19;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1, j = 0; i < wifilist.size(); i ++) {
|
||||||
|
QString line = wifilist.at(i);
|
||||||
|
QString winuse = line.mid(0, indexSignal).trimmed();
|
||||||
|
QString wbssid = line.mid(indexBSsid, 17).trimmed();
|
||||||
|
if (winuse == "*") {
|
||||||
|
strBSsidUuid.append(wbssid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connWifiBSsid != "--") {
|
|
||||||
strBSsidUuid.append(connWifiBSsid);
|
|
||||||
}
|
|
||||||
actWifiListInfo = "";
|
|
||||||
return strBSsidUuid;
|
return strBSsidUuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
void showDesktopNotify(QString message);
|
void showDesktopNotify(QString message);
|
||||||
void initConnectionInfo();
|
void initConnectionInfo();
|
||||||
QList<QString> getAtiveLanSsidUuidState();
|
QList<QString> getAtiveLanSsidUuidState();
|
||||||
QList<QString> getAtiveWifiBSsidUuid();
|
QList<QString> getAtiveWifiBSsidUuid(QStringList wifilist);
|
||||||
void reConnectWiredNet(QString netUuid);
|
void reConnectWiredNet(QString netUuid);
|
||||||
bool toConnectWiredNet(QString netUuid, QString netIfName);
|
bool toConnectWiredNet(QString netUuid, QString netIfName);
|
||||||
void getConnectNetIp(QString netUuid);
|
void getConnectNetIp(QString netUuid);
|
||||||
|
@ -118,8 +118,6 @@ private:
|
||||||
Utils *mUtils;
|
Utils *mUtils;
|
||||||
QThread *mUtilsThread;
|
QThread *mUtilsThread;
|
||||||
|
|
||||||
QString actWifiListInfo;
|
|
||||||
|
|
||||||
int a = 0;
|
int a = 0;
|
||||||
bool isRunningFunction = false;
|
bool isRunningFunction = false;
|
||||||
QTimer *time = nullptr;
|
QTimer *time = nullptr;
|
||||||
|
|
|
@ -1705,7 +1705,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
QList<QString> currConnWifiBSsidUuid;
|
QList<QString> currConnWifiBSsidUuid;
|
||||||
bool isLoop = true;
|
bool isLoop = true;
|
||||||
do {
|
do {
|
||||||
currConnWifiBSsidUuid = objKyDBus->getAtiveWifiBSsidUuid();
|
currConnWifiBSsidUuid = objKyDBus->getAtiveWifiBSsidUuid(slist);
|
||||||
if (currConnWifiBSsidUuid.size() == 1 && currConnWifiBSsidUuid.at(0).length() != 17) {
|
if (currConnWifiBSsidUuid.size() == 1 && currConnWifiBSsidUuid.at(0).length() != 17) {
|
||||||
sleep(1); //等于1说明只获取到uuid,1秒后再获取一次
|
sleep(1); //等于1说明只获取到uuid,1秒后再获取一次
|
||||||
} else {
|
} else {
|
||||||
|
@ -1777,21 +1777,21 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
|
|
||||||
// 填充可用网络列表
|
// 填充可用网络列表
|
||||||
QString headLine = slist.at(0);
|
QString headLine = slist.at(0);
|
||||||
int indexSecu, indexFreq, indexBSsid, indexName;
|
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName;
|
||||||
headLine = headLine.trimmed();
|
headLine = headLine.trimmed();
|
||||||
|
|
||||||
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
|
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
|
||||||
if (isChineseExist) {
|
if (isChineseExist) {
|
||||||
|
indexSignal = headLine.indexOf("SIGNAL");
|
||||||
indexSecu = headLine.indexOf("安全性");
|
indexSecu = headLine.indexOf("安全性");
|
||||||
indexFreq = headLine.indexOf("频率") + 4;
|
indexFreq = headLine.indexOf("频率") + 4;
|
||||||
indexBSsid = headLine.indexOf("BSSID") + 6;
|
indexBSsid = headLine.indexOf("BSSID") + 6;
|
||||||
//indexName = headLine.indexOf("SSID") + 6;
|
|
||||||
indexName = indexBSsid + 19;
|
indexName = indexBSsid + 19;
|
||||||
} else {
|
} else {
|
||||||
|
indexSignal = headLine.indexOf("SIGNAL");
|
||||||
indexSecu = headLine.indexOf("SECURITY");
|
indexSecu = headLine.indexOf("SECURITY");
|
||||||
indexFreq = headLine.indexOf("FREQ");
|
indexFreq = headLine.indexOf("FREQ");
|
||||||
indexBSsid = headLine.indexOf("BSSID");
|
indexBSsid = headLine.indexOf("BSSID");
|
||||||
//indexName = headLine.indexOf("SSID");
|
|
||||||
indexName = indexBSsid + 19;
|
indexName = indexBSsid + 19;
|
||||||
}
|
}
|
||||||
QStringList wnames;
|
QStringList wnames;
|
||||||
|
@ -1809,7 +1809,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
|
|
||||||
for (int i = 1, j = 0; i < slist.size(); i ++) {
|
for (int i = 1, j = 0; i < slist.size(); i ++) {
|
||||||
QString line = slist.at(i);
|
QString line = slist.at(i);
|
||||||
QString wsignal = line.mid(0, indexSecu).trimmed();
|
QString wsignal = line.mid(indexSignal, 3).trimmed();
|
||||||
QString wsecu = line.mid(indexSecu, indexFreq - indexSecu).trimmed();
|
QString wsecu = line.mid(indexSecu, indexFreq - indexSecu).trimmed();
|
||||||
QString wbssid = line.mid(indexBSsid, 17).trimmed();
|
QString wbssid = line.mid(indexBSsid, 17).trimmed();
|
||||||
QString wname = line.mid(indexName).trimmed();
|
QString wname = line.mid(indexName).trimmed();
|
||||||
|
|
|
@ -963,8 +963,9 @@ void OneConnForm::on_btnCancel_clicked()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
KylinDBus myKylinDbus;
|
KylinDBus myKylinDbus;
|
||||||
QList<QString> wifiSsidAndUuid = myKylinDbus.getAtiveWifiBSsidUuid();
|
QStringList wifiListInfo;
|
||||||
if (wifiSsidAndUuid.size() >= 1) {
|
QList<QString> wifiSsidAndUuid = myKylinDbus.getAtiveWifiBSsidUuid(wifiListInfo);
|
||||||
|
if (wifiSsidAndUuid.size() >= 1 && wifiSsidAndUuid.at(0).length() != 17) {
|
||||||
QString currentConnectWifiUuid = wifiSsidAndUuid.at(0);
|
QString currentConnectWifiUuid = wifiSsidAndUuid.at(0);
|
||||||
kylin_network_set_con_down(currentConnectWifiUuid.toUtf8().data());
|
kylin_network_set_con_down(currentConnectWifiUuid.toUtf8().data());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue