Merge pull request #93 from mammonsama666/0322-dev
Fix:Wifi with spacer in head/tail can not be connected.
This commit is contained in:
commit
ed2554f532
|
@ -96,7 +96,7 @@ IFace* BackThread::execGetIface()
|
||||||
iface->lstate = 3;
|
iface->lstate = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == "wifi") {
|
if (type == "wifi" && iface->wname.isEmpty()) { //仅统计第一个无线网卡,后续无线网卡状态必然等于或差与第一个获取到的无线网卡
|
||||||
// if type is wireless network
|
// if type is wireless network
|
||||||
iface->wname = iname;
|
iface->wname = iname;
|
||||||
|
|
||||||
|
|
|
@ -417,9 +417,16 @@ void ConfForm::saveNetworkConfiguration()
|
||||||
QString name = ui->leName->text().trimmed();
|
QString name = ui->leName->text().trimmed();
|
||||||
//是选择的自动还是手动配置网络
|
//是选择的自动还是手动配置网络
|
||||||
if (!this->isCreateNewNet) {
|
if (!this->isCreateNewNet) {
|
||||||
if (ui->cbType->currentIndex() == 0) {
|
if (ui->cbType->currentIndex() == 0) {
|
||||||
//kylin_network_set_automethod(name.toUtf8().data());
|
//kylin_network_set_automethod(ui->leName->text().toUtf8().data())
|
||||||
kylin_network_set_automethod(netUuid.toUtf8().data());
|
kylin_network_set_automethod(netUuid.toUtf8().data());
|
||||||
|
} else {
|
||||||
|
QString dnss = ui->leDns->text();
|
||||||
|
if (ui->leDns2->text() != "") {
|
||||||
|
dnss.append(",");
|
||||||
|
dnss.append(ui->leDns2->text());
|
||||||
|
}
|
||||||
|
kylin_network_set_manualall(netUuid.toUtf8().data(), ui->leAddr->text().toUtf8().data(), mask.toUtf8().data(), ui->leGateway->text().toUtf8().data(), dnss.toUtf8().data());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QString dnss = ui->leDns->text();
|
QString dnss = ui->leDns->text();
|
||||||
|
|
|
@ -70,7 +70,7 @@ void KSimpleNM::execGetLanList()
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取无线网络列表数据
|
//获取无线网络列表数据
|
||||||
void KSimpleNM::execGetWifiList()
|
void KSimpleNM::execGetWifiList(const QString& wname)
|
||||||
{
|
{
|
||||||
if (isExecutingGetWifiList) {
|
if (isExecutingGetWifiList) {
|
||||||
syslog(LOG_DEBUG, "It is running getting wifi list when getting wifi list");
|
syslog(LOG_DEBUG, "It is running getting wifi list when getting wifi list");
|
||||||
|
@ -85,7 +85,13 @@ void KSimpleNM::execGetWifiList()
|
||||||
isExecutingGetWifiList = true;
|
isExecutingGetWifiList = true;
|
||||||
|
|
||||||
shellOutputWifi = "";
|
shellOutputWifi = "";
|
||||||
runProcessWifi->start("nmcli -f in-use,signal,security,freq,bssid,ssid device wifi");
|
QString cmd;
|
||||||
|
if (wname.isEmpty() || wname == "") {
|
||||||
|
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path device wifi";
|
||||||
|
} else {
|
||||||
|
cmd = "nmcli -f in-use,signal,security,freq,bssid,ssid,dbus-path device wifi list ifname " + wname;
|
||||||
|
}
|
||||||
|
runProcessWifi->start(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取保存的网络列表数据
|
//获取保存的网络列表数据
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
bool isUseOldWifiSlist = false; //是否应该要用上一次获取的有线列表
|
bool isUseOldWifiSlist = false; //是否应该要用上一次获取的有线列表
|
||||||
|
|
||||||
void execGetLanList();
|
void execGetLanList();
|
||||||
void execGetWifiList();
|
void execGetWifiList(const QString& wname);
|
||||||
void execGetConnList();
|
void execGetConnList();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -1188,6 +1188,18 @@ int KylinDBus::getActiveWifiSignal()
|
||||||
return wifistrength;
|
return wifistrength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//根据Dbus路径获取wifi的ssid(排除空格干扰)
|
||||||
|
QString KylinDBus::getWifiSsid(QString accessPointPath)
|
||||||
|
{
|
||||||
|
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
||||||
|
accessPointPath,
|
||||||
|
"org.freedesktop.DBus.Properties",
|
||||||
|
QDBusConnection::systemBus() );
|
||||||
|
QDBusMessage result = interface.call("Get", "org.freedesktop.NetworkManager.AccessPoint", "Ssid");
|
||||||
|
if (result.arguments().isEmpty()) return "";
|
||||||
|
return result.arguments().at(0).value<QDBusVariant>().variant().toString();
|
||||||
|
}
|
||||||
|
|
||||||
//检查wifi连接状态
|
//检查wifi连接状态
|
||||||
int KylinDBus::checkWifiConnectivity()
|
int KylinDBus::checkWifiConnectivity()
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,6 +76,7 @@ public:
|
||||||
int checkWifiConnectivity();
|
int checkWifiConnectivity();
|
||||||
bool checkNetworkConnectivity();
|
bool checkNetworkConnectivity();
|
||||||
int getActiveWifiSignal();
|
int getActiveWifiSignal();
|
||||||
|
QString getWifiSsid(QString accessPointPath);
|
||||||
|
|
||||||
void toGetWifiList();
|
void toGetWifiList();
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
createListAreaUI(); //创建列表区域的控件
|
createListAreaUI(); //创建列表区域的控件
|
||||||
createLeftAreaUI(); //创建左侧区域控件
|
createLeftAreaUI(); //创建左侧区域控件
|
||||||
|
|
||||||
lname = "-1";
|
lcardname = "-1";
|
||||||
wname = "-1";
|
wcardname = "-1";
|
||||||
llname = "-1";
|
llname = "-1";
|
||||||
lwname = "-1";
|
lwname = "-1";
|
||||||
hideWiFiConn = "Connect to Hidden Wi-Fi Network";
|
hideWiFiConn = "Connect to Hidden Wi-Fi Network";
|
||||||
|
@ -453,12 +453,12 @@ void MainWindow::initNetwork()
|
||||||
BackThread *bt = new BackThread();
|
BackThread *bt = new BackThread();
|
||||||
IFace *iface = bt->execGetIface();
|
IFace *iface = bt->execGetIface();
|
||||||
|
|
||||||
wname = iface->wname;
|
wcardname = iface->wname;
|
||||||
lwname = iface->wname;
|
lwname = iface->wname;
|
||||||
lname = iface->lname;
|
lcardname = iface->lname;
|
||||||
llname = iface->lname;
|
llname = iface->lname;
|
||||||
|
|
||||||
mwBandWidth = bt->execChkLanWidth(lname);
|
mwBandWidth = bt->execChkLanWidth(lcardname);
|
||||||
|
|
||||||
// 开关状态
|
// 开关状态
|
||||||
qDebug()<<"===";
|
qDebug()<<"===";
|
||||||
|
@ -1066,9 +1066,9 @@ void MainWindow::getLanBandWidth()
|
||||||
BackThread *bt = new BackThread();
|
BackThread *bt = new BackThread();
|
||||||
IFace *iface = bt->execGetIface();
|
IFace *iface = bt->execGetIface();
|
||||||
|
|
||||||
lname = iface->lname;
|
lcardname = iface->lname;
|
||||||
|
|
||||||
mwBandWidth = bt->execChkLanWidth(lname);
|
mwBandWidth = bt->execChkLanWidth(lcardname);
|
||||||
}
|
}
|
||||||
|
|
||||||
//检测网络设备状态
|
//检测网络设备状态
|
||||||
|
@ -1323,7 +1323,7 @@ void MainWindow::on_btnWifiList_clicked()
|
||||||
|
|
||||||
this->startLoading();
|
this->startLoading();
|
||||||
//this->objKyDBus->toGetWifiList();
|
//this->objKyDBus->toGetWifiList();
|
||||||
this->ksnm->execGetWifiList();
|
this->ksnm->execGetWifiList(this->wcardname);
|
||||||
} else if (iface->wstate == 3) {
|
} else if (iface->wstate == 3) {
|
||||||
qDebug() << "debug: 连接中,正在配置wifi设备";
|
qDebug() << "debug: 连接中,正在配置wifi设备";
|
||||||
|
|
||||||
|
@ -1706,7 +1706,7 @@ void MainWindow::getWifiListDone(QStringList slist)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_update_wifi_list == 0) {
|
if (is_update_wifi_list == 0) {
|
||||||
//qDebug() << "loadwifi的列表";
|
qDebug() << "loadwifi的列表";
|
||||||
loadWifiListDone(slist);
|
loadWifiListDone(slist);
|
||||||
is_init_wifi_list = 0;
|
is_init_wifi_list = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1774,18 +1774,19 @@ void MainWindow::wifiListOptimize(QStringList& slist)
|
||||||
indexBSsid = headLine.indexOf("BSSID");
|
indexBSsid = headLine.indexOf("BSSID");
|
||||||
indexName = indexBSsid + 19;
|
indexName = indexBSsid + 19;
|
||||||
}
|
}
|
||||||
|
int indexPath = headLine.indexOf("DBUS-PATH");
|
||||||
|
|
||||||
QStringList targetList; //slist优化,同名同频AP中只留信号最强
|
QStringList targetList; //slist优化,同名同频AP中只留信号最强
|
||||||
targetList<<slist.at(0); //把第一行加进去
|
targetList<<slist.at(0); //把第一行加进去
|
||||||
for(int it = 1;it < slist.size();it++){
|
for(int it = 1;it < slist.size();it++){
|
||||||
QString i = slist.at(it);
|
QString i = slist.at(it);
|
||||||
bool ifContinue = false;
|
bool ifContinue = false;
|
||||||
QString conName = i.mid(indexName).trimmed();
|
QString conName = i.mid(indexName, indexPath - indexName).trimmed();
|
||||||
int conSignal = i.mid(indexSignal,3).trimmed().toInt();
|
int conSignal = i.mid(indexSignal,3).trimmed().toInt();
|
||||||
int conFreq = i.mid(indexFreq,4).trimmed().toInt();
|
int conFreq = i.mid(indexFreq,4).trimmed().toInt();
|
||||||
for(int i=0;i<slist.size();i++){
|
for(int i=0;i<slist.size();i++){
|
||||||
QString str = slist.at(i);
|
QString str = slist.at(i);
|
||||||
QString name = str.mid(indexName).trimmed();
|
QString name = str.mid(indexName, indexPath - indexName).trimmed();
|
||||||
int signal = str.mid(indexSignal,3).trimmed().toInt();
|
int signal = str.mid(indexSignal,3).trimmed().toInt();
|
||||||
int freq = str.mid(indexFreq,4).trimmed().toInt();
|
int freq = str.mid(indexFreq,4).trimmed().toInt();
|
||||||
if(conName == name){
|
if(conName == name){
|
||||||
|
@ -1923,7 +1924,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
} else {
|
} else {
|
||||||
QProcess * process = new QProcess;
|
QProcess * process = new QProcess;
|
||||||
QString name = actWifiName;
|
QString name = actWifiName;
|
||||||
process->start(QString("nmcli -f 802-11-wireless.ssid connection show '%1'").arg(name));
|
process->start(QString("nmcli -f 802-11-wireless.ssid connection show \"%1\"").arg(name));
|
||||||
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
||||||
process->deleteLater();
|
process->deleteLater();
|
||||||
});
|
});
|
||||||
|
@ -1942,7 +1943,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
|
|
||||||
// 填充可用网络列表
|
// 填充可用网络列表
|
||||||
QString headLine = slist.at(0);
|
QString headLine = slist.at(0);
|
||||||
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName;
|
int indexSignal,indexSecu, indexFreq, indexBSsid, indexName, indexPath;
|
||||||
headLine = headLine.trimmed();
|
headLine = headLine.trimmed();
|
||||||
|
|
||||||
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
|
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
|
||||||
|
@ -1952,12 +1953,14 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
indexFreq = headLine.indexOf("频率") + 4;
|
indexFreq = headLine.indexOf("频率") + 4;
|
||||||
indexBSsid = headLine.indexOf("BSSID") + 6;
|
indexBSsid = headLine.indexOf("BSSID") + 6;
|
||||||
indexName = indexBSsid + 19;
|
indexName = indexBSsid + 19;
|
||||||
|
indexPath = headLine.indexOf("DBUS-PATH");
|
||||||
} else {
|
} else {
|
||||||
indexSignal = headLine.indexOf("SIGNAL");
|
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 = indexBSsid + 19;
|
indexName = indexBSsid + 19;
|
||||||
|
indexPath = headLine.indexOf("DBUS-PATH");
|
||||||
}
|
}
|
||||||
QStringList wnames;
|
QStringList wnames;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -1965,7 +1968,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
for (int i = 1; i < slist.size(); i ++) {
|
for (int i = 1; i < slist.size(); i ++) {
|
||||||
QString line = slist.at(i);
|
QString line = slist.at(i);
|
||||||
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, indexPath - indexName).trimmed();
|
||||||
|
|
||||||
if (actWifiBssidList.contains(wbssid)) {
|
if (actWifiBssidList.contains(wbssid)) {
|
||||||
actWifiName = wname;
|
actWifiName = wname;
|
||||||
|
@ -1979,13 +1982,12 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
actWifiId = actWifiName;
|
actWifiId = actWifiName;
|
||||||
actWifiName = "--";
|
actWifiName = "--";
|
||||||
}
|
}
|
||||||
|
|
||||||
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(indexSignal, 3).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, indexPath - indexName).trimmed();
|
||||||
QString wfreq = line.mid(indexFreq, 4).trimmed();
|
QString wfreq = line.mid(indexFreq, 4).trimmed();
|
||||||
|
|
||||||
if (actWifiName != "--" && actWifiName == wname) {
|
if (actWifiName != "--" && actWifiName == wname) {
|
||||||
|
@ -1993,14 +1995,15 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
continue; //若当前热点ssid名称和已经连接的wifi的ssid名称相同,但bssid不同,则跳过
|
continue; //若当前热点ssid名称和已经连接的wifi的ssid名称相同,但bssid不同,则跳过
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wnames.contains(wname) && wbssid != actWifiBssid) {
|
if ((wnames.contains(wname) && wbssid != actWifiBssid)) {
|
||||||
continue; //过滤相同名称的wifi
|
continue; //过滤相同名称的wifi
|
||||||
}
|
}
|
||||||
|
|
||||||
int max_freq = wfreq.toInt();
|
int max_freq = wfreq.toInt();
|
||||||
int min_freq = wfreq.toInt();
|
int min_freq = wfreq.toInt();
|
||||||
for (int k = i; k < slist.size(); k ++) {
|
for (int k = i; k < slist.size(); k ++) {
|
||||||
if (wname == slist.at(k).mid(indexName).trimmed()) {
|
QString m_name = slist.at(k).mid(indexName, indexPath - indexName).trimmed();
|
||||||
|
if (wname == m_name) {
|
||||||
if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() > max_freq) {
|
if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() > max_freq) {
|
||||||
max_freq = slist.at(k).mid(indexFreq, 4).trimmed().toInt();
|
max_freq = slist.at(k).mid(indexFreq, 4).trimmed().toInt();
|
||||||
} else if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() < min_freq) {
|
} else if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() < min_freq) {
|
||||||
|
@ -2008,6 +2011,7 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int freqState = 0;
|
int freqState = 0;
|
||||||
if (max_freq < 3000) {
|
if (max_freq < 3000) {
|
||||||
//只有2.4GHZ
|
//只有2.4GHZ
|
||||||
|
@ -2022,7 +2026,14 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
//对于已经连接的wifi
|
//对于已经连接的wifi
|
||||||
connect(ccf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int)));
|
connect(ccf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneTopWifiFormSelected(QString,int)));
|
||||||
connect(ccf, SIGNAL(disconnActiveWifi()), this, SLOT(activeWifiDisconn()));
|
connect(ccf, SIGNAL(disconnActiveWifi()), this, SLOT(activeWifiDisconn()));
|
||||||
ccf->setName(wname, wbssid, actWifiUuid);
|
QString path = line.mid(indexPath).trimmed();
|
||||||
|
QString m_name;
|
||||||
|
if (path != "" && !path.isEmpty()) m_name= this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1)));
|
||||||
|
if (m_name.isEmpty() || m_name == "") {
|
||||||
|
ccf->setName(wname, wbssid, actWifiUuid);
|
||||||
|
} else {
|
||||||
|
ccf->setName(m_name, wbssid, actWifiUuid);
|
||||||
|
}
|
||||||
//ccf->setRate(wrate);
|
//ccf->setRate(wrate);
|
||||||
int signal = wsignal.toInt() + 11;
|
int signal = wsignal.toInt() + 11;
|
||||||
ccf->setSignal(QString::number(signal), wsecu);
|
ccf->setSignal(QString::number(signal), wsecu);
|
||||||
|
@ -2045,7 +2056,15 @@ void MainWindow::loadWifiListDone(QStringList slist)
|
||||||
|
|
||||||
OneConnForm *ocf = new OneConnForm(wifiListWidget, this, confForm, ksnm);
|
OneConnForm *ocf = new OneConnForm(wifiListWidget, this, confForm, ksnm);
|
||||||
connect(ocf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneWifiFormSelected(QString,int)));
|
connect(ocf, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneWifiFormSelected(QString,int)));
|
||||||
ocf->setName(wname, wbssid, "--");
|
// ocf->setName(wname, wbssid, "--");
|
||||||
|
QString path = line.mid(indexPath).trimmed();
|
||||||
|
QString m_name;
|
||||||
|
if (path != "" && !path.isEmpty()) m_name= this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1)));
|
||||||
|
if (m_name.isEmpty() || m_name == "") {
|
||||||
|
ocf->setName(wname, wbssid, actWifiUuid);
|
||||||
|
} else {
|
||||||
|
ocf->setName(m_name, wbssid, actWifiUuid);
|
||||||
|
}
|
||||||
//ocf->setRate(wrate);
|
//ocf->setRate(wrate);
|
||||||
ocf->setLine(true);
|
ocf->setLine(true);
|
||||||
ocf->setSignal(wsignal, wsecu);
|
ocf->setSignal(wsignal, wsecu);
|
||||||
|
@ -2124,7 +2143,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
|
||||||
}
|
}
|
||||||
|
|
||||||
QString headLine = slist.at(0);
|
QString headLine = slist.at(0);
|
||||||
int indexSecu, indexFreq, indexBSsid, indexName;
|
int indexSecu, indexFreq, indexBSsid, indexName, indexPath;
|
||||||
headLine = headLine.trimmed();
|
headLine = headLine.trimmed();
|
||||||
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
|
bool isChineseExist = headLine.contains(QRegExp("[\\x4e00-\\x9fa5]+"));
|
||||||
if (isChineseExist) {
|
if (isChineseExist) {
|
||||||
|
@ -2133,21 +2152,23 @@ void MainWindow::updateWifiListDone(QStringList slist)
|
||||||
indexBSsid = headLine.indexOf("BSSID") + 6;
|
indexBSsid = headLine.indexOf("BSSID") + 6;
|
||||||
//indexName = headLine.indexOf("SSID") + 6;
|
//indexName = headLine.indexOf("SSID") + 6;
|
||||||
indexName = indexBSsid + 19;
|
indexName = indexBSsid + 19;
|
||||||
|
indexPath = headLine.indexOf("DBUS-PATH");
|
||||||
} else {
|
} else {
|
||||||
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 = headLine.indexOf("SSID");
|
||||||
indexName = indexBSsid + 19;
|
indexName = indexBSsid + 19;
|
||||||
|
indexPath = headLine.indexOf("DBUS-PATH");
|
||||||
}
|
}
|
||||||
|
|
||||||
//列表中去除已经减少的wifi
|
//列表中去除已经减少的wifi
|
||||||
for (int i=1; i<oldWifiSlist.size(); i++){
|
for (int i=1; i<oldWifiSlist.size(); i++){
|
||||||
QString line = oldWifiSlist.at(i);
|
QString line = oldWifiSlist.at(i);
|
||||||
QString lastWname = line.mid(lastIndexName).trimmed();
|
QString lastWname = line.mid(lastIndexName, indexPath - lastIndexName).trimmed();
|
||||||
for (int j=1; j<slist.size(); j++){
|
for (int j=1; j<slist.size(); j++){
|
||||||
QString line = slist.at(j);
|
QString line = slist.at(j);
|
||||||
QString wname = line.mid(indexName).trimmed();
|
QString wname = line.mid(indexName, indexPath - indexName).trimmed();
|
||||||
|
|
||||||
if (lastWname == wname){break;} //在slist最后之前找到了lastWname,则停止
|
if (lastWname == wname){break;} //在slist最后之前找到了lastWname,则停止
|
||||||
if (j == slist.size()-1) {
|
if (j == slist.size()-1) {
|
||||||
|
@ -2182,7 +2203,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
|
||||||
QString wsignal = line.mid(0, indexSecu).trimmed();
|
QString wsignal = line.mid(0, indexSecu).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, indexPath - indexName).trimmed();
|
||||||
QString wfreq = line.mid(indexFreq, 4).trimmed();
|
QString wfreq = line.mid(indexFreq, 4).trimmed();
|
||||||
|
|
||||||
if(wname == "" || wname == "--"){continue;}
|
if(wname == "" || wname == "--"){continue;}
|
||||||
|
@ -2196,8 +2217,10 @@ void MainWindow::updateWifiListDone(QStringList slist)
|
||||||
|
|
||||||
int max_freq = wfreq.toInt();
|
int max_freq = wfreq.toInt();
|
||||||
int min_freq = wfreq.toInt();
|
int min_freq = wfreq.toInt();
|
||||||
for (int k = i; k < slist.size(); k ++) {
|
for (int k = 0; k < slist.size(); k ++) {
|
||||||
if (wname == slist.at(k).mid(indexName).trimmed()) {
|
QString m_name = slist.at(k).mid(indexName, indexPath - indexName).trimmed();
|
||||||
|
// QString m_name = this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(slist.at(k).mid(slist.at(k).lastIndexOf("/") + 1).trimmed()));
|
||||||
|
if (wname == m_name) {
|
||||||
if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() > max_freq) {
|
if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() > max_freq) {
|
||||||
max_freq = slist.at(k).mid(indexFreq, 4).trimmed().toInt();
|
max_freq = slist.at(k).mid(indexFreq, 4).trimmed().toInt();
|
||||||
} else if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() < min_freq) {
|
} else if (slist.at(k).mid(indexFreq, 4).trimmed().toInt() < min_freq) {
|
||||||
|
@ -2219,8 +2242,7 @@ void MainWindow::updateWifiListDone(QStringList slist)
|
||||||
|
|
||||||
for (int j=1; j < oldWifiSlist.size(); j++) {
|
for (int j=1; j < oldWifiSlist.size(); j++) {
|
||||||
QString line = oldWifiSlist.at(j);
|
QString line = oldWifiSlist.at(j);
|
||||||
QString lastWname = line.mid(lastIndexName).trimmed();
|
QString lastWname = line.mid(lastIndexName, indexPath - lastIndexName).trimmed();
|
||||||
|
|
||||||
if (lastWname == wname){break;} //上一次的wifi列表已经有名为wname的wifi,则停止
|
if (lastWname == wname){break;} //上一次的wifi列表已经有名为wname的wifi,则停止
|
||||||
if (j == oldWifiSlist.size()-1) { //到lastSlist最后一个都没找到,执行下面流程
|
if (j == oldWifiSlist.size()-1) { //到lastSlist最后一个都没找到,执行下面流程
|
||||||
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
|
QList<OneConnForm *> wifiList = wifiListWidget->findChildren<OneConnForm *>();
|
||||||
|
@ -2239,7 +2261,15 @@ void MainWindow::updateWifiListDone(QStringList slist)
|
||||||
wifiListWidget->resize(W_LIST_WIDGET, wifiListWidget->height() + H_NORMAL_ITEM);
|
wifiListWidget->resize(W_LIST_WIDGET, wifiListWidget->height() + H_NORMAL_ITEM);
|
||||||
OneConnForm *addItem = new OneConnForm(wifiListWidget, this, confForm, ksnm);
|
OneConnForm *addItem = new OneConnForm(wifiListWidget, this, confForm, ksnm);
|
||||||
connect(addItem, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneWifiFormSelected(QString,int)));
|
connect(addItem, SIGNAL(selectedOneWifiForm(QString,int)), this, SLOT(oneWifiFormSelected(QString,int)));
|
||||||
addItem->setName(wname, wbssid, "--");
|
// addItem->setName(wname, wbssid, "--");
|
||||||
|
QString path = line.mid(indexPath).trimmed();
|
||||||
|
QString m_name;
|
||||||
|
if (path != "" && !path.isEmpty()) m_name= this->objKyDBus->getWifiSsid(QString("/org/freedesktop/NetworkManager/AccessPoint/%1").arg(path.mid(path.lastIndexOf("/") + 1)));
|
||||||
|
if (m_name.isEmpty() || m_name == "") {
|
||||||
|
addItem->setName(wname, wbssid, actWifiUuid);
|
||||||
|
} else {
|
||||||
|
addItem->setName(m_name, wbssid, actWifiUuid);
|
||||||
|
}
|
||||||
//addItem->setRate(wrate);
|
//addItem->setRate(wrate);
|
||||||
addItem->setLine(false);
|
addItem->setLine(false);
|
||||||
addItem->setSignal(wsignal, wsecu);
|
addItem->setSignal(wsignal, wsecu);
|
||||||
|
@ -2785,14 +2815,14 @@ void MainWindow::activeStartLoading()
|
||||||
void MainWindow::activeGetWifiList()
|
void MainWindow::activeGetWifiList()
|
||||||
{
|
{
|
||||||
emit this->waitWifiStop();
|
emit this->waitWifiStop();
|
||||||
this->ksnm->execGetWifiList();
|
this->ksnm->execGetWifiList(this->wcardname);
|
||||||
}
|
}
|
||||||
|
|
||||||
//网络开关处理,打开与关闭网络
|
//网络开关处理,打开与关闭网络
|
||||||
void MainWindow::enNetDone()
|
void MainWindow::enNetDone()
|
||||||
{
|
{
|
||||||
BackThread *bt = new BackThread();
|
BackThread *bt = new BackThread();
|
||||||
mwBandWidth = bt->execChkLanWidth(lname);
|
mwBandWidth = bt->execChkLanWidth(lcardname);
|
||||||
|
|
||||||
// 打开网络开关时如果Wifi开关是打开的,设置其样式
|
// 打开网络开关时如果Wifi开关是打开的,设置其样式
|
||||||
if (checkWlOn()) {
|
if (checkWlOn()) {
|
||||||
|
@ -2855,7 +2885,7 @@ void MainWindow::enWifiDone()
|
||||||
{
|
{
|
||||||
is_update_wifi_list = 0;
|
is_update_wifi_list = 0;
|
||||||
if (is_btnWifiList_clicked) {
|
if (is_btnWifiList_clicked) {
|
||||||
this->ksnm->execGetWifiList();
|
this->ksnm->execGetWifiList(this->wcardname);
|
||||||
} else {
|
} else {
|
||||||
//on_btnWifiList_clicked();
|
//on_btnWifiList_clicked();
|
||||||
}
|
}
|
||||||
|
@ -3100,7 +3130,7 @@ void MainWindow::on_checkWifiListChanged()
|
||||||
|
|
||||||
if (loop_iface->wstate != 2) {
|
if (loop_iface->wstate != 2) {
|
||||||
is_update_wifi_list = 1;
|
is_update_wifi_list = 1;
|
||||||
this->ksnm->execGetWifiList(); //更新wifi列表
|
this->ksnm->execGetWifiList(this->wcardname); //更新wifi列表
|
||||||
}
|
}
|
||||||
|
|
||||||
delete loop_iface;
|
delete loop_iface;
|
||||||
|
@ -3266,7 +3296,7 @@ void MainWindow::connWifiDone(int connFlag)
|
||||||
WifiAuthThread *wifi_auth_thread=new WifiAuthThread();
|
WifiAuthThread *wifi_auth_thread=new WifiAuthThread();
|
||||||
wifi_auth_thread->start();
|
wifi_auth_thread->start();
|
||||||
syslog(LOG_DEBUG, "Wi-Fi already connected by clicking button");
|
syslog(LOG_DEBUG, "Wi-Fi already connected by clicking button");
|
||||||
this->ksnm->execGetWifiList();
|
this->ksnm->execGetWifiList(this->wcardname);
|
||||||
|
|
||||||
QString txt(tr("Conn Wifi Success"));
|
QString txt(tr("Conn Wifi Success"));
|
||||||
objKyDBus->showDesktopNotify(txt);
|
objKyDBus->showDesktopNotify(txt);
|
||||||
|
|
|
@ -282,7 +282,7 @@ private:
|
||||||
QWidget *widShowWindow = nullptr;
|
QWidget *widShowWindow = nullptr;
|
||||||
QWidget *widAdvConf = nullptr;
|
QWidget *widAdvConf = nullptr;
|
||||||
|
|
||||||
QString lname, wname; // 以太网卡和无线网卡名称
|
QString lcardname, wcardname; // 以太网卡和无线网卡名称
|
||||||
|
|
||||||
QString btnOffQss, btnOnQss, btnBgOffQss, btnBgOnQss, btnBgHoverQss, btnBgLeaveQss; // 主界面按钮底色
|
QString btnOffQss, btnOnQss, btnBgOffQss, btnBgOnQss, btnBgHoverQss, btnBgLeaveQss; // 主界面按钮底色
|
||||||
QString scrollBarQss, leftBtnQss, funcBtnQss;
|
QString scrollBarQss, leftBtnQss, funcBtnQss;
|
||||||
|
|
|
@ -605,7 +605,7 @@ void OneConnForm::toConnectWirelessNetwork()
|
||||||
if (isWifiConfExist(wifiName)) {
|
if (isWifiConfExist(wifiName)) {
|
||||||
//有配置文件,获取密码存储策略
|
//有配置文件,获取密码存储策略
|
||||||
QProcess * process = new QProcess(this);
|
QProcess * process = new QProcess(this);
|
||||||
process->start(QString("nmcli -f 802-11-wireless-security.psk-flags connection show '%1'").arg(wifiName));
|
process->start(QString("nmcli -f 802-11-wireless-security.psk-flags connection show \"%1\"").arg(wifiName));
|
||||||
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
||||||
process->deleteLater();
|
process->deleteLater();
|
||||||
});
|
});
|
||||||
|
@ -845,7 +845,7 @@ void OneConnForm::on_btnInfo_clicked()
|
||||||
if (line.startsWith("method:")) {
|
if (line.startsWith("method:")) {
|
||||||
v4method = line.split(":").at(1);
|
v4method = line.split(":").at(1);
|
||||||
}
|
}
|
||||||
if (line.startsWith("addr:")) {
|
if (line.startsWith("v4addr:")) {
|
||||||
addr = line.split(":").at(1);
|
addr = line.split(":").at(1);
|
||||||
}
|
}
|
||||||
if (line.startsWith("mask:")) {
|
if (line.startsWith("mask:")) {
|
||||||
|
@ -1023,7 +1023,7 @@ void OneConnForm::on_btnCancel_clicked()
|
||||||
int OneConnForm::getPskFlag()
|
int OneConnForm::getPskFlag()
|
||||||
{
|
{
|
||||||
QProcess * process = new QProcess(this);
|
QProcess * process = new QProcess(this);
|
||||||
process->start(QString("nmcli -f 802-11-wireless-security.psk-flags connection show '%1'").arg(wifiName));
|
process->start(QString("nmcli -f 802-11-wireless-security.psk-flags connection show \"%1\"").arg(wifiName));
|
||||||
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
connect(process, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, [ = ]() {
|
||||||
process->deleteLater();
|
process->deleteLater();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue