diff --git a/debian/changelog b/debian/changelog index 8e9374f0..648a91cb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +kylin-nm (3.14.0.0+0512-0k10) yangtz; urgency=medium + + * close-cd #131075 【网络】普通用户在详情界面修改网络IP信息时会弹出授权框,如果不进行授权详情界面也会显示修改成功,但是实际未修改 + + -- zhaoshixu Thu, 18 Aug 2022 17:09:12 +0800 + kylin-nm (3.14.0.0+0512-0k9) yangtz; urgency=medium * close-cd #131247 登录界面连接wifi后,登录桌面任务栏网络工具显示未连接,wifi依旧关闭状态 diff --git a/src/backend/dbus-interface/kylinconnectresource.cpp b/src/backend/dbus-interface/kylinconnectresource.cpp index 00d0570a..deebf692 100644 --- a/src/backend/dbus-interface/kylinconnectresource.cpp +++ b/src/backend/dbus-interface/kylinconnectresource.cpp @@ -106,7 +106,7 @@ bool KyConnectResourse::isActiveDevice(QString conUuid, QString devName) return false; } -KyConnectItem * KyConnectResourse::getConnectionItemByUuid(QString connectUuid) +KyConnectItem * KyConnectResourse::getConnectionItemByUuid(QString connectUuid, bool checkActive) { NetworkManager::Connection::Ptr connectPtr = m_networkResourceInstance->getConnect(connectUuid); @@ -116,7 +116,7 @@ KyConnectItem * KyConnectResourse::getConnectionItemByUuid(QString connectUuid) return nullptr; } - if (m_networkResourceInstance->isActiveConnection(connectPtr->uuid())) { + if (checkActive && m_networkResourceInstance->isActiveConnection(connectPtr->uuid())) { qDebug()<<"[KyConnectResourse]"<name()<<"is active connection"; return nullptr; } diff --git a/src/backend/dbus-interface/kylinconnectresource.h b/src/backend/dbus-interface/kylinconnectresource.h index f79024ae..d0db17b3 100644 --- a/src/backend/dbus-interface/kylinconnectresource.h +++ b/src/backend/dbus-interface/kylinconnectresource.h @@ -18,7 +18,7 @@ public: ~KyConnectResourse(); public: - KyConnectItem *getConnectionItemByUuid(QString connectUuid); + KyConnectItem *getConnectionItemByUuid(QString connectUuid, bool checkActive = true); KyConnectItem *getConnectionItemByUuid(QString connectUuid, QString deviceName); void getConnectionList(QString deviceName, NetworkManager::ConnectionSettings::ConnectionType connectionType, diff --git a/src/frontend/netdetails/ipv4page.h b/src/frontend/netdetails/ipv4page.h index 25ef07aa..ab06ce7f 100644 --- a/src/frontend/netdetails/ipv4page.h +++ b/src/frontend/netdetails/ipv4page.h @@ -27,6 +27,8 @@ public: void setIpv4SecDns(const QString &ipv4SecDns); void setGateWay(const QString &gateWay); + QString getNetMaskText(QString text); + bool checkIsChanged(const ConInfo info, KyConnectSetting &setting); private: QComboBox *ipv4ConfigCombox; @@ -52,7 +54,7 @@ private: void configSave(); bool getTextEditState(QString text); bool netMaskIsValide(QString text); - QString getNetMaskText(QString text); + bool checkConnectBtnIsEnabled(); diff --git a/src/frontend/netdetails/netdetail.cpp b/src/frontend/netdetails/netdetail.cpp index 6752904d..3a83be4a 100644 --- a/src/frontend/netdetails/netdetail.cpp +++ b/src/frontend/netdetails/netdetail.cpp @@ -521,22 +521,29 @@ void NetDetail::getStaticIpInfo(ConInfo &conInfo, bool bActived) kyConnectResourse->getConnectionSetting(m_uuid,connetSetting); connetSetting.dumpInfo(); - conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType; +// conInfo.ipv4ConfigType = connetSetting.m_ipv4ConfigIpType; conInfo.ipv6ConfigType = connetSetting.m_ipv6ConfigIpType; conInfo.isAutoConnect = connetSetting.m_isAutoConnect; - if (connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) { - if (connetSetting.m_ipv4Address.size() > 0) { - conInfo.strIPV4Address = connetSetting.m_ipv4Address.at(0).ip().toString(); - conInfo.strIPV4NetMask = connetSetting.m_ipv4Address.at(0).netmask().toString(); - conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString(); - } - if (connetSetting.m_ipv4Dns.size() == 1) { - conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString(); - } else if (connetSetting.m_ipv4Dns.size() > 1) { - conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString(); - conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString(); - } +// if (connetSetting.m_ipv4ConfigIpType == CONFIG_IP_MANUAL) { +// if (connetSetting.m_ipv4Address.size() > 0) { +// conInfo.strIPV4Address = connetSetting.m_ipv4Address.at(0).ip().toString(); +// conInfo.strIPV4NetMask = connetSetting.m_ipv4Address.at(0).netmask().toString(); +// conInfo.strIPV4GateWay = connetSetting.m_ipv4Address.at(0).gateway().toString(); +// } +// if (connetSetting.m_ipv4Dns.size() == 1) { +// conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString(); +// } else if (connetSetting.m_ipv4Dns.size() > 1) { +// conInfo.strIPV4FirDns = connetSetting.m_ipv4Dns.at(0).toString(); +// conInfo.strIPV4SecDns = connetSetting.m_ipv4Dns.at(1).toString(); +// } +// } + //openkylin从第三方库读取有问题 改为ipv4信息直接通过dbus获取 + KyConnectItem* item = kyConnectResourse->getConnectionItemByUuid(m_uuid, false); + if (item == nullptr) { + conInfo.ipv4ConfigType = CONFIG_IP_DHCP; + } else { + getIpv4Info(item->m_connectPath, conInfo); } if (connetSetting.m_ipv6ConfigIpType == CONFIG_IP_MANUAL) { @@ -956,3 +963,94 @@ bool NetDetail::eventFilter(QObject *w, QEvent *event) } return QWidget::eventFilter(w, event); } + +void NetDetail::getIpv4Info(QString objPath, ConInfo &conInfo) +{ + QDBusInterface m_interface("org.freedesktop.NetworkManager", + objPath, + "org.freedesktop.NetworkManager.Settings.Connection", + QDBusConnection::systemBus()); + QDBusMessage result = m_interface.call("GetSettings"); + + if (result.arguments().isEmpty()) { return; } + const QDBusArgument &dbusArg1st = result.arguments().at( 0 ).value(); + QMap> map; + dbusArg1st >> map; + + for (QString key : map.keys() ) { + QMap innerMap = map.value(key); + if (key == "ipv4") { + for (QString inner_key : innerMap.keys()) { + if (inner_key == "address-data") { + //ipv4地址 ipv4子网掩码 + const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value(); + QVector> addressVector; + + dbusArg2nd.beginArray(); + + while (!dbusArg2nd.atEnd()) { + QMap tempMap; + dbusArg2nd >> tempMap; + addressVector.append(tempMap); + } + dbusArg2nd.endArray(); + if (addressVector.size() >= 1) { + conInfo.strIPV4Address = addressVector.at(0).value("address").toString(); + conInfo.strIPV4NetMask = ipv4Page->getNetMaskText(addressVector.at(0).value("prefix").toString()); + } + } else if (inner_key == "method") { + //ipv4 method + if (innerMap.value(inner_key).toString() == "auto") + conInfo.ipv4ConfigType = CONFIG_IP_DHCP; + else { + conInfo.ipv4ConfigType = CONFIG_IP_MANUAL; + } + } else if (inner_key == "dns") { + //dns + const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value(); + QList addressVector; + + dbusArg2nd.beginArray(); + while (!dbusArg2nd.atEnd()) { + uint tempMap; + dbusArg2nd >> tempMap; + addressVector.append(tempMap); + } + dbusArg2nd.endArray(); + if (addressVector.size() == 1) { + QString dns(inet_ntoa(*(struct in_addr *)&addressVector.at(0))); + conInfo.strIPV4FirDns = dns; + } else if (addressVector.size() > 1) { + QString dns1(inet_ntoa(*(struct in_addr *)&addressVector.at(0))); + QString dns2(inet_ntoa(*(struct in_addr *)&addressVector.at(1))); + conInfo.strIPV4FirDns = dns1; + conInfo.strIPV4SecDns = dns2; + } + + } else if (inner_key == "gateway") { + //gateway + conInfo.strIPV4GateWay = innerMap.value(inner_key).toString(); + } + } + } + // if (key == "ipv6") { + // for (QString inner_key : innerMap.keys()) { + // if (inner_key == "address-data"){ + // const QDBusArgument &dbusArg2nd = innerMap.value(inner_key).value(); + // QMap m_map; + + // dbusArg2nd.beginArray(); + // while (!dbusArg2nd.atEnd()) { + // dbusArg2nd >> m_map;// append map to a vector here if you want to keep it + // } + // dbusArg2nd.endArray(); + + // dbusWifiIpv6 = m_map.value("address").toString(); + // } else if (inner_key == "method") { + // dbusWifiIpv6Method = innerMap.value(inner_key).toString(); + // } + // } + // } + } + +} diff --git a/src/frontend/netdetails/netdetail.h b/src/frontend/netdetails/netdetail.h index 5e99a72a..c3262c88 100644 --- a/src/frontend/netdetails/netdetail.h +++ b/src/frontend/netdetails/netdetail.h @@ -30,6 +30,7 @@ #include "kwidget.h" #include "ktabbar.h" +#include using namespace kdk; class NetDetail : public QWidget @@ -81,6 +82,8 @@ private: void showDesktopNotify(const QString &message, QString soundName); void setNetdetailSomeEnable(bool on); + + void getIpv4Info(QString objPath, ConInfo &conInfo); private: KyNetworkDeviceResourse *m_netDeviceResource = nullptr; KyConnectOperation* m_connectOperation = nullptr;