Merge lp:~ken-vandine/ubuntu-system-settings/nm_1.2_ip_address into lp:ubuntu-system-settings

Proposed by Ken VanDine
Status: Merged
Approved by: Ken VanDine
Approved revision: 1654
Merged at revision: 1653
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/nm_1.2_ip_address
Merge into: lp:ubuntu-system-settings
Diff against target: 48 lines (+4/-18)
1 file modified
plugins/wifi/wifidbushelper.cpp (+4/-18)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/nm_1.2_ip_address
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+294284@code.launchpad.net

Commit message

Don't use Ip4Address from NetworkManager, it was deprecated since 0.9 and since removed. Use QNetworkInterface to get the IP address.

Description of the change

Don't use Ip4Address from NetworkManager, it was deprecated since 0.9 and since removed. Use QNetworkInterface to get the IP address.

To post a comment you must log in.
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Beautiful! Approval of code!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/wifi/wifidbushelper.cpp'
2--- plugins/wifi/wifidbushelper.cpp 2015-06-26 11:34:48 +0000
3+++ plugins/wifi/wifidbushelper.cpp 2016-05-10 18:13:53 +0000
4@@ -22,6 +22,7 @@
5 #include <QDBusReply>
6 #include <QtDebug>
7 #include <QDBusInterface>
8+#include <QNetworkInterface>
9 #include <algorithm>
10 #include <arpa/inet.h>
11
12@@ -297,33 +298,18 @@
13 return QString();
14 }
15 auto devices = reply1.value();
16- int ip4addr;
17
18- QDBusObjectPath dev;
19 for (const auto &d : devices) {
20 QDBusInterface iface(NM_SERVICE, d.path(), NM_DEVICE_IFACE, m_systemBusConnection);
21 auto type_v = iface.property("DeviceType");
22 if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) {
23- ip4addr = iface.property("Ip4Address").toInt();
24- dev = d;
25+ auto ip4name = iface.property("IpInterface").toString();
26+ return QNetworkInterface::interfaceFromName(ip4name).addressEntries()[0].ip().toString();
27 break;
28 }
29 }
30
31- if (dev.path().isEmpty()) {
32- // didn't find a wifi device
33- return QString();
34- }
35-
36- if (!ip4addr) {
37- // no ip address
38- return QString();
39- }
40-
41-
42- struct in_addr ip_addr;
43- ip_addr.s_addr = ip4addr;
44- return QString(inet_ntoa(ip_addr));
45+ return QString();
46 }
47
48 struct Network : public QObject

Subscribers

People subscribed via source and target branches