Fix bug show abnormal wired network list after launch compter
This commit is contained in:
parent
fb73b4a4b6
commit
3cea31eb75
|
@ -405,7 +405,9 @@ void MainWindow::getInitLanSlist()
|
|||
|
||||
FILE * p_file = NULL;
|
||||
|
||||
p_file = popen("export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f type,device,name connection show", "r");
|
||||
//p_file = popen("export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f type,device,name connection show", "r");
|
||||
//nmcli -f type,uuid,name connection show
|
||||
p_file = popen("export LANG='en_US.UTF-8';export LANGUAGE='en_US';nmcli -f type,uuid,name connection show", "r");
|
||||
if (!p_file) {
|
||||
syslog(LOG_ERR, "Error occurred when popen cmd 'nmcli connection show'");
|
||||
qDebug()<<"Error occurred when popen cmd 'nmcli connection show";
|
||||
|
@ -421,6 +423,14 @@ void MainWindow::getInitLanSlist()
|
|||
oldLanSlist.append(strSlist);
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << " ";
|
||||
foreach (QString sss, oldLanSlist) {
|
||||
qDebug() << "AAAAA the oldLanSlist is:"<<sss;
|
||||
//syslog(LOG_DEBUG, "AAAAA the oldLanSlist is: %s",sss.toUtf8().data());
|
||||
}
|
||||
qDebug() << " ";
|
||||
|
||||
pclose(p_file);
|
||||
}
|
||||
|
||||
|
@ -1360,17 +1370,29 @@ void MainWindow::on_btnWifiList_clicked()
|
|||
// 获取lan列表回调
|
||||
void MainWindow::getLanListDone(QStringList slist)
|
||||
{
|
||||
qDebug() << " ";
|
||||
qDebug() <<slist;
|
||||
qDebug() << " ";
|
||||
foreach (QString sss, slist) {
|
||||
qDebug() << "AAAAA the slist is:"<<sss;
|
||||
//syslog(LOG_DEBUG, "AAAAA the slist is: %s",sss.toUtf8().data());
|
||||
}
|
||||
qDebug() << " ";
|
||||
|
||||
//要求使用上一次获取到的列表
|
||||
if (this->ksnm->isUseOldLanSlist) {
|
||||
slist = oldLanSlist;
|
||||
this->ksnm->isUseOldLanSlist = false;
|
||||
}
|
||||
syslog(LOG_DEBUG, "AAAAAAAAAAAAAAAAAAAAAAA");
|
||||
|
||||
//若slist为空,则也使用上一次获取到的列表
|
||||
if (slist.size() == 1 && slist.at(0) == "") {
|
||||
if (oldLanSlist.size() == 1 && oldLanSlist.at(0) == "") {
|
||||
syslog(LOG_DEBUG, "AAAAAAAAAAAAAAAAAAAAAAB");
|
||||
return;
|
||||
} else {
|
||||
syslog(LOG_DEBUG, "AAAAAAAAAAAAAAAAAAAAAAC");
|
||||
slist = oldLanSlist;
|
||||
}
|
||||
}
|
||||
|
@ -1391,6 +1413,7 @@ void MainWindow::getLanListDone(QStringList slist)
|
|||
|
||||
// 若当前lan name为"--",设置OneConnForm
|
||||
if (currConnNames.size() == 0) {
|
||||
syslog(LOG_DEBUG, "AAAAAAAAAAAAAAAAAAAAAAD");
|
||||
OneLancForm *ccf = new OneLancForm(topLanListWidget, this, confForm, ksnm);
|
||||
ccf->setName(tr("Not connected"), "--", "--");//"当前未连接任何 以太网"
|
||||
ccf->setIcon(false);
|
||||
|
@ -1408,13 +1431,24 @@ void MainWindow::getLanListDone(QStringList slist)
|
|||
ccf->setLine(false);
|
||||
currTopLanItem = 1;
|
||||
} else {
|
||||
syslog(LOG_DEBUG, "AAAAAAAAAAAAAAAAAAAAAAE");
|
||||
int i = 0;
|
||||
do {
|
||||
syslog(LOG_DEBUG, "AAAAAAAAAAAAAAAAAAAAAAF");
|
||||
actLanSsidName.append(currConnNames.at(i)); //网络名称
|
||||
actLanUuidName.append(currConnNames.at(i+1)); //网络唯一ID
|
||||
i += 2;
|
||||
} while(i<currConnNames.size());
|
||||
currTopLanItem = actLanSsidName.size();
|
||||
|
||||
syslog(LOG_DEBUG, "AAAAAAAAAAAAAAAAAAAAAAG");
|
||||
foreach (QString ssid, actLanSsidName) {
|
||||
syslog(LOG_DEBUG, "AAAAA the ssid is: %s",ssid.toUtf8().data());
|
||||
}
|
||||
|
||||
foreach (QString uuid, actLanUuidName) {
|
||||
syslog(LOG_DEBUG, "AAAAA the uuid is: %s",uuid.toUtf8().data());
|
||||
}
|
||||
}
|
||||
|
||||
// 填充可用网络列表
|
||||
|
@ -1439,7 +1473,7 @@ void MainWindow::getLanListDone(QStringList slist)
|
|||
bool isActiveNet = false; //是否是活动的连接
|
||||
|
||||
//仅仅对有线网络进行添加列表处理
|
||||
if (ltype != "802-11-wireless" && ltype != "wifi" && ltype != "" && ltype != "--") {
|
||||
if (ltype != "802-11-wireless" && ltype != "wifi" && ltype != "bridge" && ltype != "" && ltype != "--") {
|
||||
objKyDBus->getLanIpDNS(nuuid, true); //使用UUID获取有线网的ip和dns信息
|
||||
QString macLan = getMacByUuid(nuuid); //有线网对应的mac地址
|
||||
|
||||
|
@ -1450,8 +1484,8 @@ void MainWindow::getLanListDone(QStringList slist)
|
|||
macInterface = objKyDBus->getLanMAC(objKyDBus->dbusIfName); //有限网卡对应的mac地址
|
||||
|
||||
if (macLan!="" && macLan!="--" && macLan != macInterface) {
|
||||
//continue; //有线网的permenant mac地址与网卡的地址不同,则不在列表中显示
|
||||
macInterface = macLan;
|
||||
continue; //有线网的permenant mac地址与网卡的地址不同,则不在列表中显示
|
||||
//macInterface = macLan;
|
||||
}
|
||||
} else {
|
||||
mIfName = objKyDBus->multiWiredIfName.at(0); //使用默认的网络接口
|
||||
|
@ -1461,7 +1495,11 @@ void MainWindow::getLanListDone(QStringList slist)
|
|||
//**********************创建已经连接的有线网item********************//
|
||||
if (currConnNames.size() != 0) {//证明有已经连接的有线网络
|
||||
for (int kk=0; kk<actLanSsidName.size(); kk++) {
|
||||
syslog(LOG_DEBUG, "AAAAAAAAAAAAAAAAAAAAAAH");
|
||||
syslog(LOG_DEBUG, "AAAAA the name is: %s",nname.toUtf8().data());
|
||||
syslog(LOG_DEBUG, "AAAAA the nuid is: %s",nuuid.toUtf8().data());
|
||||
if (nname == actLanSsidName.at(kk) && nuuid == actLanUuidName.at(kk)) {
|
||||
syslog(LOG_DEBUG, "AAAAAAAAAAAAAAAAAAAAAAI");
|
||||
topLanListWidget->resize(topLanListWidget->width(), topLanListWidget->height() + H_NORMAL_ITEM*kk);
|
||||
isActiveNet = true; //名为nname的网络是已经连接的有线网络
|
||||
ifLanConnected = true;
|
||||
|
|
Loading…
Reference in New Issue