From dce922f822583f244d9c0bed0f241a44ee86630a Mon Sep 17 00:00:00 2001 From: chenlelin Date: Mon, 15 Jun 2020 15:54:41 +0800 Subject: [PATCH] Add wired ifname when create a new wired network --- src/confform.cpp | 14 ++- src/kylin-dbus-interface.cpp | 23 +++-- translations/kylin-nm_bo.ts | 180 +++++++++++++++++---------------- translations/kylin-nm_zh_CN.qm | Bin 20736 -> 20855 bytes translations/kylin-nm_zh_CN.ts | 173 ++++++++++++++++--------------- 5 files changed, 206 insertions(+), 184 deletions(-) diff --git a/src/confform.cpp b/src/confform.cpp index 772508bc..c25db559 100644 --- a/src/confform.cpp +++ b/src/confform.cpp @@ -207,7 +207,18 @@ void ConfForm::setProp(QString connName, QString v4method, QString addr, QString //点击了创建新的网络的按钮 void ConfForm::on_btnCreate_clicked() { - QString cmdStr = "nmcli connection add con-name '" + ui->leName->text() + "' type ethernet"; + KylinDBus kylindbus; + kylindbus.getWiredCardName(); + QString mIfname = kylindbus.dbusLanCardName; + + if (mIfname == "") { + QString tip(tr("Can not create new wired network for without wired card")); + kylindbus.showDesktopNotify(tip); + this->hide(); + return; + } + + QString cmdStr = "nmcli connection add con-name '" + ui->leName->text() + "' ifname '" + mIfname + "' type ethernet"; Utils::m_system(cmdStr.toUtf8().data()); //int status = system(cmdStr.toUtf8().data()); //if (status != 0){ syslog(LOG_ERR, "execute 'nmcli connection add con-name' in function 'on_btnCreate_clicked' failed");} @@ -218,7 +229,6 @@ void ConfForm::on_btnCreate_clicked() this->on_btnOk_clicked(); } else { QString txt(tr("New network already created")); - KylinDBus kylindbus; kylindbus.showDesktopNotify(txt); } diff --git a/src/kylin-dbus-interface.cpp b/src/kylin-dbus-interface.cpp index a55a6971..82d3caad 100644 --- a/src/kylin-dbus-interface.cpp +++ b/src/kylin-dbus-interface.cpp @@ -181,16 +181,21 @@ void KylinDBus::getLanHwAddressState() //获取有线网卡名称 void KylinDBus::getWiredCardName() { - QDBusInterface lanInterface( "org.freedesktop.NetworkManager", - wiredPath.path(), - "org.freedesktop.DBus.Properties", - QDBusConnection::systemBus() ); - - QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface"); - if (!lanReply.isValid()) { - qDebug()<<"can not get the attribute 'Interface' in func getWiredCardName()"; + if (wiredPath.path() == "") { + dbusLanCardName = ""; } else { - dbusLanCardName = lanReply.value().toString(); + QDBusInterface lanInterface( "org.freedesktop.NetworkManager", + wiredPath.path(), + "org.freedesktop.DBus.Properties", + QDBusConnection::systemBus() ); + + QDBusReply lanReply = lanInterface.call("Get", "org.freedesktop.NetworkManager.Device", "Interface"); + if (!lanReply.isValid()) { + qDebug()<<"can not get the attribute 'Interface' in func getWiredCardName()"; + dbusLanCardName = ""; + } else { + dbusLanCardName = lanReply.value().toString(); + } } } diff --git a/translations/kylin-nm_bo.ts b/translations/kylin-nm_bo.ts index 32736e94..09e6cbb2 100644 --- a/translations/kylin-nm_bo.ts +++ b/translations/kylin-nm_bo.ts @@ -75,26 +75,31 @@ + Can not create new wired network for without wired card + + + + New network already created - + New network settings already finished - + New settings already effective - + Edit Network - + Add Wired Network @@ -107,37 +112,37 @@ - + Add Hidden Wi-Fi - + Connection - + Wi-Fi name - + Wi-Fi security - + Cancel - + Connect - + C_reate… @@ -1102,52 +1107,52 @@ - + Add Hidden Wi-Fi - + Connection - + Wi-Fi name - + Wi-Fi security - + Password - + Cancel - + Connect - + C_reate… - + None - + WPA & WPA2 Personal @@ -1203,7 +1208,7 @@ KylinDBus - + kylin network applet desktop message @@ -1212,150 +1217,142 @@ MainWindow - + kylin-nm - - + + Advanced - - + + Ethernet - + New LAN - + Hide WiFi - - + + Wifi - + HotSpot - + FlyMode - - - - - + + + + + Not connected - - - - - - - - - + + + + + + + + + Disconnected - + Ethernet Networks - + Wifi Networks - + No usable network in the list - + Show MainWindow - + No Other Wired Network Scheme - + No Other Wireless Network Scheme - + Confirm your Wi-Fi password or usable of wireless card - + please insert the wireless network adapter - - + + NetOn, - + Wired net is disconnected - + Wi-Fi is disconnected - + Conn Ethernet Success - + Conn Ethernet Fail - + Conn Wifi Success - - NotifySend - - - Form - - - OneConnForm @@ -1364,51 +1361,56 @@ - - - - + + + + Connect - + Disconnect - - + + Input Password... - + Connect to Hidden Wi-Fi Network - + + Rate + + + + None - + WiFi Security: - + Sifnal: - + MAC: - + Conn Wifi Failed @@ -1432,28 +1434,28 @@ - - + + No Configuration - + IPv4: - + IPv6: - + MAC: - + BandWidth: diff --git a/translations/kylin-nm_zh_CN.qm b/translations/kylin-nm_zh_CN.qm index a805193839a17b0a712bd22df0be5487ad7eff02..95b8dad6b36d9f4b327a91d1fce582770c2469f4 100644 GIT binary patch delta 2367 zcmX}sdr;I>6bJCL%WvN=-YTrJfFKWfF1sv?yDBR$pJ{52nu@X{MnLNlF3GxTCXrl!O3E&$6KPgRHq-|Z zInPK=jN3>=C6eA`9yq2(n$X$83s6YSMXYwZv}8*@tA~TrVZst=x!+=uSADwCXCt#6TX0!^*(OrIievQF#0h} z3J{XTLSEQg!mPyEM7dI-WZpkSqmKy<`TIFCeo#0I6%MF#!2l;K^1vZ$&|&%(Mt8x) zOVH8>?dPFGA$+)RI;Y~HuqT~U5po5_1jFQfVb80v9D!NTK3zDV*7KR!0F_dx_Y)3? z{SN}Q=m=?o;hW%yi!fOZt(`ElLFj&t-y8d@EI6Kbo--BZ&6nBctRRvulud}Lp zCe~|tT!(DtaZZI{k?cTAGpFK?T>kZ!e8_Lg#Rc!yaqhpDFW<(w(Qk*LWia`M{Mk& z5rsa2u|}9usc<q1s}+OEmN_ z`xpCE)$Mw~^ID*9F$}s2hpv65NRdV8NWG#i=uP9BZa>UzQoAScie(b0D22L87~p{+ zG8payM~sC@3!ya;X3Al<73O-?6?GY0|6^ZNSKZsrA4-CXEl{@u2DHHtI}A^UBPw80 zBec$knFG(W3)I!;d0rxQ*KSThOso3jp)nl#f7Q2Z1+IcljX6zR&lg9Q#&(Q{Ne^fi z9X9iY)S-Fj`U38-Yif2xa~*Gn3MtgdU;sf=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(UDj!&K^!8%3BQc6U2%_Ua{bYDuOyS^bugdHW;!6M)X75 zeds(1(;DG~A(*ca7rRsW{AUk|wfFY%M5mxC5$dv_Pbv&J2Sd7HqzcB{pz|(Fd-^=j zB-UNv?-Gff9h`zFm-y|eY_6U6#oG-6&s(fnj?V|4%amsqN9~GGSf{~yY4!tU%-$gj~ z5e%CJV@0j>1SYOulAFY#T=1382&DdtJfYV=3*>zAdQi1OdjFPkyyQT96obXvut^7g$&hh*(*UbrXwACo<1r~m)} diff --git a/translations/kylin-nm_zh_CN.ts b/translations/kylin-nm_zh_CN.ts index 2cb92f94..40b61650 100644 --- a/translations/kylin-nm_zh_CN.ts +++ b/translations/kylin-nm_zh_CN.ts @@ -82,21 +82,26 @@ + Can not create new wired network for without wired card + 缺少有线网卡 无法新建网络 + + + New network already created 已创建新的有线网络 - + New network settings already finished 新的网络配置已经完成 - + Edit Network 编辑网络设置 - + Add Wired Network 新建有线网络 @@ -109,7 +114,7 @@ 新的设置已经生效 - + New settings already effective 新的设置已经生效 @@ -117,37 +122,37 @@ DlgConnHidWifi - + Add Hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Wi-Fi name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Cancel 取消 - + Connect 连接 - + C_reate… 新建... @@ -1133,52 +1138,52 @@ 连接到隐藏 Wi-Fi 网络 - + Add Hidden Wi-Fi 加入隐藏Wi-Fi - + Connection 连接设置: - + Wi-Fi name 网络名称: - + Wi-Fi security Wi-Fi 安全性: - + Password 密码: - + Cancel 取消 - + Connect 连接 - + C_reate… 新建... - + None - + WPA & WPA2 Personal WPA 及 WPA2 个人 @@ -1250,7 +1255,7 @@ KylinDBus - + kylin network applet desktop message 麒麟网络工具信息提示 @@ -1259,7 +1264,7 @@ MainWindow - + kylin-nm 网络工具 @@ -1268,14 +1273,14 @@ 网络 - - + + Advanced 设置网络 - - + + Ethernet 有线网络 @@ -1284,8 +1289,8 @@ 加入网络 - - + + Wifi 无线网络 @@ -1298,95 +1303,95 @@ 已关闭 - + HotSpot 个人热点 - + FlyMode 飞行模式 - + Show MainWindow 显示网络连接界面 - - - - - + + + + + Not connected 当前未连接任何网络 - - - - - - - - - + + + + + + + + + Disconnected 未连接 - + No Other Wired Network Scheme 列表中无其他有线网络 - + No Other Wireless Network Scheme 未检测到其他无线网络 - + Wired net is disconnected 断开有线网络 - + Wi-Fi is disconnected 断开无线网络 - + Confirm your Wi-Fi password or usable of wireless card 请确认Wi-Fi密码或无线设备 - + Ethernet Networks 可用有线网络列表 - + New LAN 新建网络 - + Hide WiFi 加入网络 - + No usable network in the list 列表暂无可连接网络 - - + + NetOn, 已连接, - + Wifi Networks 可用无线网络列表 @@ -1399,7 +1404,7 @@ 打开无线网开关前保持有线网开关打开 - + please insert the wireless network adapter 请先插入无线网卡 @@ -1416,17 +1421,17 @@ 正在更新 Wi-Fi列表 - + Conn Ethernet Success 连接有线网络成功 - + Conn Ethernet Fail 连接有线网络失败 - + Conn Wifi Success 连接无线网络成功 @@ -1434,9 +1439,8 @@ NotifySend - Form - -- + -- @@ -1455,26 +1459,26 @@ 设置 - - - - + + + + Connect 连接 - + Disconnect 断开 - - + + Input Password... 输入密码... - + Connect to Hidden Wi-Fi Network 连接到隐藏 Wi-Fi 网络 @@ -1487,31 +1491,32 @@ 安全 + Rate - 速率 + 速率 - + None - + WiFi Security: WiFi安全性: - + Sifnal: 信号强度: - + MAC: 物理地址: - + Conn Wifi Failed 连接无线网络失败 @@ -1539,28 +1544,28 @@ 断开 - - + + No Configuration 未配置 - + IPv4: IPv4地址: - + IPv6: IPv6地址: - + BandWidth: 带宽: - + MAC: 物理地址: