Fix bug connected items show abnormal if more than one wired network be connected
This commit is contained in:
parent
55db6aecab
commit
0460060a76
|
@ -213,7 +213,6 @@ void BackThread::execConnLan(QString connName, QString ifname)
|
||||||
//先断开当前网卡对应的已连接有线网
|
//先断开当前网卡对应的已连接有线网
|
||||||
QString uuid = objKyDbus.getConnLanNameByIfname(ifname);
|
QString uuid = objKyDbus.getConnLanNameByIfname(ifname);
|
||||||
if (uuid != "--") {
|
if (uuid != "--") {
|
||||||
//qDebug() << "断开网络:" <<uuid;
|
|
||||||
kylin_network_set_con_down(uuid.toUtf8().data());
|
kylin_network_set_con_down(uuid.toUtf8().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -427,7 +427,7 @@ QString KylinDBus::getLanMAC(QString ifname)
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取已经连接的有线网ip
|
//获取已经连接的有线网ip
|
||||||
void KylinDBus::getConnectNetIp()
|
void KylinDBus::getConnectNetIp(QString netUuid)
|
||||||
{
|
{
|
||||||
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
QDBusInterface interface( "org.freedesktop.NetworkManager",
|
||||||
"/org/freedesktop/NetworkManager",
|
"/org/freedesktop/NetworkManager",
|
||||||
|
@ -452,69 +452,73 @@ void KylinDBus::getConnectNetIp()
|
||||||
"org.freedesktop.DBus.Properties",
|
"org.freedesktop.DBus.Properties",
|
||||||
QDBusConnection::systemBus() );
|
QDBusConnection::systemBus() );
|
||||||
|
|
||||||
QDBusReply<QVariant> reply = interfacePro.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type");
|
QDBusReply<QVariant> replyType = interfacePro.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Type");
|
||||||
if (reply.value().toString() == "ethernet" || reply.value().toString() == "802-3-ethernet") {
|
QDBusReply<QVariant> replyUuid = interfacePro.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Uuid");
|
||||||
//ipv4的路径信息和ip信息
|
if (replyType.value().toString() == "ethernet" || replyType.value().toString() == "802-3-ethernet") {
|
||||||
QDBusInterface interfaceIp4( "org.freedesktop.NetworkManager",
|
if (replyUuid.value().toString() == netUuid) {
|
||||||
objPath.path(),
|
//ipv4的路径信息和ip信息
|
||||||
"org.freedesktop.DBus.Properties",
|
QDBusInterface interfaceIp4( "org.freedesktop.NetworkManager",
|
||||||
QDBusConnection::systemBus() );
|
objPath.path(),
|
||||||
QDBusMessage replyIp4 = interfaceIp4.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Ip4Config");
|
|
||||||
QList<QVariant> outArgsIp4 = replyIp4.arguments();
|
|
||||||
QVariant firstIp4 = outArgsIp4.at(0);
|
|
||||||
QDBusVariant dbvFirstIp4 = firstIp4.value<QDBusVariant>();
|
|
||||||
QVariant vFirstIp4 = dbvFirstIp4.variant();
|
|
||||||
QDBusObjectPath dbusPathIp4 = vFirstIp4.value<QDBusObjectPath>();
|
|
||||||
|
|
||||||
QDBusInterface interfaceIpv4( "org.freedesktop.NetworkManager",
|
|
||||||
dbusPathIp4.path(),
|
|
||||||
"org.freedesktop.DBus.Properties",
|
"org.freedesktop.DBus.Properties",
|
||||||
QDBusConnection::systemBus() );
|
QDBusConnection::systemBus() );
|
||||||
QDBusMessage replyIpv4 = interfaceIpv4.call("Get", "org.freedesktop.NetworkManager.IP4Config", "AddressData");
|
QDBusMessage replyIp4 = interfaceIp4.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Ip4Config");
|
||||||
|
QList<QVariant> outArgsIp4 = replyIp4.arguments();
|
||||||
|
QVariant firstIp4 = outArgsIp4.at(0);
|
||||||
|
QDBusVariant dbvFirstIp4 = firstIp4.value<QDBusVariant>();
|
||||||
|
QVariant vFirstIp4 = dbvFirstIp4.variant();
|
||||||
|
QDBusObjectPath dbusPathIp4 = vFirstIp4.value<QDBusObjectPath>();
|
||||||
|
|
||||||
QList<QVariant> outArgsIpv4 = replyIpv4.arguments();
|
QDBusInterface interfaceIpv4( "org.freedesktop.NetworkManager",
|
||||||
QVariant firstIpv4 = outArgsIpv4.at(0);
|
dbusPathIp4.path(),
|
||||||
QDBusVariant dbvFirstIpv4 = firstIpv4.value<QDBusVariant>();
|
"org.freedesktop.DBus.Properties",
|
||||||
QVariant vFirstIpv4 = dbvFirstIpv4.variant();
|
QDBusConnection::systemBus() );
|
||||||
|
QDBusMessage replyIpv4 = interfaceIpv4.call("Get", "org.freedesktop.NetworkManager.IP4Config", "AddressData");
|
||||||
|
|
||||||
const QDBusArgument &dbusArgIpv4 = vFirstIpv4.value<QDBusArgument>();
|
QList<QVariant> outArgsIpv4 = replyIpv4.arguments();
|
||||||
QList<QVariantMap> mDatasIpv4;
|
QVariant firstIpv4 = outArgsIpv4.at(0);
|
||||||
dbusArgIpv4 >> mDatasIpv4;
|
QDBusVariant dbvFirstIpv4 = firstIpv4.value<QDBusVariant>();
|
||||||
|
QVariant vFirstIpv4 = dbvFirstIpv4.variant();
|
||||||
|
|
||||||
foreach (QVariantMap mDataIpv4, mDatasIpv4) {
|
const QDBusArgument &dbusArgIpv4 = vFirstIpv4.value<QDBusArgument>();
|
||||||
dbusActiveLanIpv4 = mDataIpv4.value("address").toString();
|
QList<QVariantMap> mDatasIpv4;
|
||||||
}
|
dbusArgIpv4 >> mDatasIpv4;
|
||||||
|
|
||||||
//ipv6的路径信息和ip信息
|
foreach (QVariantMap mDataIpv4, mDatasIpv4) {
|
||||||
QDBusInterface interfaceIp6( "org.freedesktop.NetworkManager",
|
dbusActiveLanIpv4 = mDataIpv4.value("address").toString();
|
||||||
objPath.path(),
|
}
|
||||||
"org.freedesktop.DBus.Properties",
|
|
||||||
QDBusConnection::systemBus() );
|
|
||||||
QDBusMessage replyIp6 = interfaceIp6.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Ip6Config");
|
|
||||||
QList<QVariant> outArgsIp6 = replyIp6.arguments();
|
|
||||||
QVariant firstIp6 = outArgsIp6.at(0);
|
|
||||||
QDBusVariant dbvFirstIp6 = firstIp6.value<QDBusVariant>();
|
|
||||||
QVariant vFirstIp6 = dbvFirstIp6.variant();
|
|
||||||
QDBusObjectPath dbusPathIp6 = vFirstIp6.value<QDBusObjectPath>();
|
|
||||||
|
|
||||||
QDBusInterface interfaceIpv6( "org.freedesktop.NetworkManager",
|
//ipv6的路径信息和ip信息
|
||||||
dbusPathIp6.path(),
|
QDBusInterface interfaceIp6( "org.freedesktop.NetworkManager",
|
||||||
|
objPath.path(),
|
||||||
"org.freedesktop.DBus.Properties",
|
"org.freedesktop.DBus.Properties",
|
||||||
QDBusConnection::systemBus() );
|
QDBusConnection::systemBus() );
|
||||||
QDBusMessage replyIpv6 = interfaceIpv6.call("Get", "org.freedesktop.NetworkManager.IP6Config", "AddressData");
|
QDBusMessage replyIp6 = interfaceIp6.call("Get", "org.freedesktop.NetworkManager.Connection.Active", "Ip6Config");
|
||||||
|
QList<QVariant> outArgsIp6 = replyIp6.arguments();
|
||||||
|
QVariant firstIp6 = outArgsIp6.at(0);
|
||||||
|
QDBusVariant dbvFirstIp6 = firstIp6.value<QDBusVariant>();
|
||||||
|
QVariant vFirstIp6 = dbvFirstIp6.variant();
|
||||||
|
QDBusObjectPath dbusPathIp6 = vFirstIp6.value<QDBusObjectPath>();
|
||||||
|
|
||||||
QList<QVariant> outArgsIpv6 = replyIpv6.arguments();
|
QDBusInterface interfaceIpv6( "org.freedesktop.NetworkManager",
|
||||||
QVariant firstIpv6 = outArgsIpv6.at(0);
|
dbusPathIp6.path(),
|
||||||
QDBusVariant dbvFirstIpv6 = firstIpv6.value<QDBusVariant>();
|
"org.freedesktop.DBus.Properties",
|
||||||
QVariant vFirstIpv6 = dbvFirstIpv6.variant();
|
QDBusConnection::systemBus() );
|
||||||
|
QDBusMessage replyIpv6 = interfaceIpv6.call("Get", "org.freedesktop.NetworkManager.IP6Config", "AddressData");
|
||||||
|
|
||||||
const QDBusArgument &dbusArgIpv6 = vFirstIpv6.value<QDBusArgument>();
|
QList<QVariant> outArgsIpv6 = replyIpv6.arguments();
|
||||||
QList<QVariantMap> mDatasIpv6;
|
QVariant firstIpv6 = outArgsIpv6.at(0);
|
||||||
dbusArgIpv6 >> mDatasIpv6;
|
QDBusVariant dbvFirstIpv6 = firstIpv6.value<QDBusVariant>();
|
||||||
|
QVariant vFirstIpv6 = dbvFirstIpv6.variant();
|
||||||
|
|
||||||
foreach (QVariantMap mDataIpv6, mDatasIpv6) {
|
const QDBusArgument &dbusArgIpv6 = vFirstIpv6.value<QDBusArgument>();
|
||||||
dbusActiveLanIpv6 = mDataIpv6.value("address").toString();
|
QList<QVariantMap> mDatasIpv6;
|
||||||
|
dbusArgIpv6 >> mDatasIpv6;
|
||||||
|
|
||||||
|
foreach (QVariantMap mDataIpv6, mDatasIpv6) {
|
||||||
|
dbusActiveLanIpv6 = mDataIpv6.value("address").toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dbusArgs.endArray();
|
dbusArgs.endArray();
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
void initConnectionInfo();
|
void initConnectionInfo();
|
||||||
QList<QString> getConnectNetName();
|
QList<QString> getConnectNetName();
|
||||||
void connectWiredNet(QString netName);
|
void connectWiredNet(QString netName);
|
||||||
void getConnectNetIp();
|
void getConnectNetIp(QString netUuid);
|
||||||
void getLanIpChanged();
|
void getLanIpChanged();
|
||||||
void onWiredSettingNumChanged();
|
void onWiredSettingNumChanged();
|
||||||
|
|
||||||
|
|
|
@ -1446,7 +1446,7 @@ void MainWindow::getLanListDone(QStringList slist)
|
||||||
isActiveNet = true; //名为nname的网络是已经连接的有线网络
|
isActiveNet = true; //名为nname的网络是已经连接的有线网络
|
||||||
ifLanConnected = true;
|
ifLanConnected = true;
|
||||||
|
|
||||||
objKyDBus->getConnectNetIp();
|
objKyDBus->getConnectNetIp(nuuid);
|
||||||
if (mwBandWidth == "Unknown!") { getLanBandWidth(); }
|
if (mwBandWidth == "Unknown!") { getLanBandWidth(); }
|
||||||
//QString strLanName = TranslateLanName(nname); //进行中英文系统环境下有线网络名称的汉化
|
//QString strLanName = TranslateLanName(nname); //进行中英文系统环境下有线网络名称的汉化
|
||||||
|
|
||||||
|
@ -1483,10 +1483,10 @@ void MainWindow::getLanListDone(QStringList slist)
|
||||||
ccfAct->setLine(false); //最后一个item不显示下划线
|
ccfAct->setLine(false); //最后一个item不显示下划线
|
||||||
}
|
}
|
||||||
\
|
\
|
||||||
if (!objKyDBus->dbusLanIpv4.isEmpty() && !objKyDBus->dbusActiveLanIpv4.isEmpty()) {
|
if (!objKyDBus->dbusLanIpv4.isEmpty()) {
|
||||||
if (objKyDBus->dbusActiveLanIpv4 != objKyDBus->dbusLanIpv4) {
|
if (!objKyDBus->dbusActiveLanIpv4.isEmpty() && objKyDBus->dbusActiveLanIpv4 != objKyDBus->dbusLanIpv4) {
|
||||||
//在第三方nm-connection-editor进行新的IP配置后,重新连接网络
|
//在第三方nm-connection-editor进行新的IP配置后,重新连接网络
|
||||||
objKyDBus->connectWiredNet(nname);
|
//objKyDBus->connectWiredNet(nname);
|
||||||
} else if ((oldActLanName == actLanSsidName.at(kk)) && (oldDbusActLanDNS != objKyDBus->dbusActLanDNS)) {
|
} else if ((oldActLanName == actLanSsidName.at(kk)) && (oldDbusActLanDNS != objKyDBus->dbusActLanDNS)) {
|
||||||
//在第三方nm-connection-editor进行新的DNS配置后,重新连接网络
|
//在第三方nm-connection-editor进行新的DNS配置后,重新连接网络
|
||||||
objKyDBus->connectWiredNet(nname);
|
objKyDBus->connectWiredNet(nname);
|
||||||
|
@ -2162,8 +2162,10 @@ void MainWindow::oneLanFormSelected(QString lanName, QString uniqueName)
|
||||||
scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA + H_NORMAL_ITEM*(currTopLanItem-1));
|
scrollAreal->move(W_LEFT_AREA, Y_SCROLL_AREA + H_NORMAL_ITEM*(currTopLanItem-1));
|
||||||
lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2 + H_NORMAL_ITEM*(currTopLanItem-1)/2);
|
lbNoItemTip->move(this->width()/2 - W_NO_ITEM_TIP/2 + W_LEFT_AREA/2, this->height()/2 + H_NORMAL_ITEM*(currTopLanItem-1)/2);
|
||||||
|
|
||||||
foreach (OneLancForm *ocf, topLanList) {
|
for (int i = topLanList.size() - 1;i >= 0; i --) {
|
||||||
|
OneLancForm *ocf = topLanList.at(i);
|
||||||
ocf->setTopItem(false);
|
ocf->setTopItem(false);
|
||||||
|
ocf->move(L_VERTICAL_LINE_TO_ITEM, (topLanList.size() - 1 - i) * H_NORMAL_ITEM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void MainWindow::oneTopLanFormSelected(QString lanName, QString uniqueName)
|
void MainWindow::oneTopLanFormSelected(QString lanName, QString uniqueName)
|
||||||
|
|
Loading…
Reference in New Issue