Fix bug wired network still use old DNS after change to a new one
This commit is contained in:
parent
51998cae1c
commit
af634e7633
|
@ -271,7 +271,7 @@ void KylinDBus::getWirelessCardName()
|
|||
}
|
||||
|
||||
//获取没有连接的有线网ip
|
||||
void KylinDBus::getLanIp(QString netName)
|
||||
void KylinDBus::getLanIp(QString netName, bool isActNet)
|
||||
{
|
||||
QDBusInterface m_interface("org.freedesktop.NetworkManager",
|
||||
"/org/freedesktop/NetworkManager/Settings",
|
||||
|
@ -306,6 +306,7 @@ void KylinDBus::getLanIp(QString netName)
|
|||
//qDebug() << "Key: " << key;
|
||||
if (key == "ipv4") {
|
||||
for (QString inner_key : innerMap.keys()) {
|
||||
//获取ipv4
|
||||
if (inner_key == "address-data") {
|
||||
const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value<QDBusArgument>();
|
||||
QMap<QString,QVariant> m_map;
|
||||
|
@ -319,6 +320,17 @@ void KylinDBus::getLanIp(QString netName)
|
|||
//qDebug()<<" " << m_map.value("address").toString();
|
||||
dbusLanIpv4 = m_map.value("address").toString();
|
||||
}
|
||||
|
||||
if (isActNet && inner_key == "dns") {
|
||||
const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value<QDBusArgument>();
|
||||
int strDns;
|
||||
dbusArg2nd.beginArray();
|
||||
while (!dbusArg2nd.atEnd()) {
|
||||
dbusArg2nd >> strDns;// append map to a vector here if you want to keep it
|
||||
}
|
||||
dbusArg2nd.endArray();
|
||||
dbusActLanDNS = strDns;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -740,7 +752,6 @@ void KylinDBus::onWifiPropertyChanged(QVariantMap qvm)
|
|||
//有线网的Ip属性变化时的响应函数
|
||||
void KylinDBus::onIpPropertiesChanged()
|
||||
{
|
||||
qDebug() << "哈哈哈哈哈或或或或或";
|
||||
emit this->updateWiredList(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ public:
|
|||
QString dbusLanMac = "";
|
||||
QString dbusWiFiCardName = "";
|
||||
QString dbusWifiMac = "";
|
||||
int dbusActLanDNS;
|
||||
|
||||
public slots:
|
||||
void onNewConnection(QDBusObjectPath objPath);
|
||||
|
@ -99,7 +100,7 @@ public slots:
|
|||
void getLanHwAddressState();
|
||||
void getWiredCardName();
|
||||
void getWirelessCardName();
|
||||
void getLanIp(QString netName);
|
||||
void getLanIp(QString netName, bool isActNet);
|
||||
void getWifiMac(QString netName);
|
||||
void slot_timeout();
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
getInitLanSlist(); //初始化有线网列表
|
||||
initNetwork(); //初始化网络
|
||||
initTimer(); //初始化定时器
|
||||
initActNetDNS();//初始化已连接网络的DNS
|
||||
getSystemFontFamily();//建立GSetting监听系统字体
|
||||
|
||||
connect(ui->btnNetList, &QPushButton::clicked, this, &MainWindow::onBtnNetListClicked);
|
||||
|
@ -555,6 +556,26 @@ void MainWindow::initTimer()
|
|||
setNetSpeed->start(3000);
|
||||
}
|
||||
|
||||
//初始化已经连接网络的DNS
|
||||
void MainWindow::initActNetDNS()
|
||||
{
|
||||
QString actLanName = "--";
|
||||
activecon *act = kylin_network_get_activecon_info();
|
||||
int index = 0;
|
||||
while (act[index].con_name != NULL) {
|
||||
if (QString(act[index].type) == "ethernet" || QString(act[index].type) == "802-3-ethernet") {
|
||||
actLanName = QString(act[index].con_name);
|
||||
break;
|
||||
}
|
||||
index ++;
|
||||
}
|
||||
|
||||
if (actLanName != "--") {
|
||||
oldActLanName = actLanName;
|
||||
objKyDBus->getLanIp(actLanName, true);
|
||||
oldDbusActLanDNS = objKyDBus->dbusActLanDNS;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 任务栏托盘管理、托盘图标处理
|
||||
|
@ -1426,7 +1447,7 @@ void MainWindow::getLanListDone(QStringList slist)
|
|||
// 当前连接的lan
|
||||
if (nname == actLanName) {
|
||||
objKyDBus->getConnectNetIp();
|
||||
objKyDBus->getLanIp(nname);
|
||||
objKyDBus->getLanIp(nname, true);
|
||||
actLanName = "--";
|
||||
if (mwBandWidth == "Unknown!") { getLanBandWidth(); }
|
||||
|
||||
|
@ -1449,7 +1470,10 @@ void MainWindow::getLanListDone(QStringList slist)
|
|||
|
||||
if (!objKyDBus->dbusLanIpv4.isEmpty()) {
|
||||
if (objKyDBus->dbusActiveLanIpv4 != objKyDBus->dbusLanIpv4) {
|
||||
//在第三方nm-connection-editor进行新的配置后,重新连接网络
|
||||
//在第三方nm-connection-editor进行新的IP配置后,重新连接网络
|
||||
objKyDBus->connectWiredNet(nname);
|
||||
} else if ((oldActLanName == actLanName) && (oldDbusActLanDNS != objKyDBus->dbusActLanDNS)) {
|
||||
//在第三方nm-connection-editor进行新的DNS配置后,重新连接网络
|
||||
objKyDBus->connectWiredNet(nname);
|
||||
}
|
||||
}
|
||||
|
@ -1457,9 +1481,11 @@ void MainWindow::getLanListDone(QStringList slist)
|
|||
currSelNetName = "";
|
||||
objKyDBus->dbusActiveLanIpv4 = "";
|
||||
objKyDBus->dbusActiveLanIpv6 = "";
|
||||
oldActLanName = actLanName;
|
||||
oldDbusActLanDNS = objKyDBus->dbusActLanDNS;
|
||||
syslog(LOG_DEBUG, "already insert an active lannet in the top of lan list");
|
||||
} else {
|
||||
objKyDBus->getLanIp(nname);
|
||||
objKyDBus->getLanIp(nname, false);
|
||||
lanListWidget->resize(W_LIST_WIDGET, lanListWidget->height() + H_NORMAL_ITEM);
|
||||
|
||||
//QString strLanName = TranslateLanName(nname);
|
||||
|
@ -2207,6 +2233,8 @@ void MainWindow::activeLanDisconn()
|
|||
//if (status1 != 0){ syslog(LOG_ERR, "execute 'notify-send' in function 'execConnWifiPWD' failed");}
|
||||
|
||||
currSelNetName = "";
|
||||
oldActLanName = "";
|
||||
oldDbusActLanDNS = 0;
|
||||
//this->startLoading();
|
||||
emit this->waitLanStop();
|
||||
this->ksnm->execGetLanList();
|
||||
|
|
|
@ -134,6 +134,8 @@ public:
|
|||
void initTimer();
|
||||
void checkIsWirelessDeviceOn();
|
||||
|
||||
void initActNetDNS();
|
||||
|
||||
QIcon iconLanOnline, iconLanOffline;
|
||||
QIcon iconWifiFull, iconWifiHigh, iconWifiMedium, iconWifiLow;
|
||||
QIcon iconConnecting;
|
||||
|
@ -249,8 +251,9 @@ private:
|
|||
QString scrollBarQss, leftBtnQss, funcBtnQss;
|
||||
|
||||
QStringList oldLanSlist; //上一次获取Lan列表
|
||||
|
||||
QStringList oldWifiSlist; //上一次获取wifi列表
|
||||
QString oldActLanName = ""; //上一次获取的已连接有线网名称
|
||||
int oldDbusActLanDNS = 0; //上一次获取的已连接有线网的DNS代号
|
||||
|
||||
//循环检测网络连接状态
|
||||
QTimer *iconTimer = nullptr;
|
||||
|
|
Loading…
Reference in New Issue