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
=== modified file 'plugins/wifi/wifidbushelper.cpp'
--- plugins/wifi/wifidbushelper.cpp 2015-06-26 11:34:48 +0000
+++ plugins/wifi/wifidbushelper.cpp 2016-05-10 18:13:53 +0000
@@ -22,6 +22,7 @@
22#include <QDBusReply>22#include <QDBusReply>
23#include <QtDebug>23#include <QtDebug>
24#include <QDBusInterface>24#include <QDBusInterface>
25#include <QNetworkInterface>
25#include <algorithm>26#include <algorithm>
26#include <arpa/inet.h>27#include <arpa/inet.h>
2728
@@ -297,33 +298,18 @@
297 return QString();298 return QString();
298 }299 }
299 auto devices = reply1.value();300 auto devices = reply1.value();
300 int ip4addr;
301301
302 QDBusObjectPath dev;
303 for (const auto &d : devices) {302 for (const auto &d : devices) {
304 QDBusInterface iface(NM_SERVICE, d.path(), NM_DEVICE_IFACE, m_systemBusConnection);303 QDBusInterface iface(NM_SERVICE, d.path(), NM_DEVICE_IFACE, m_systemBusConnection);
305 auto type_v = iface.property("DeviceType");304 auto type_v = iface.property("DeviceType");
306 if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) {305 if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) {
307 ip4addr = iface.property("Ip4Address").toInt();306 auto ip4name = iface.property("IpInterface").toString();
308 dev = d;307 return QNetworkInterface::interfaceFromName(ip4name).addressEntries()[0].ip().toString();
309 break;308 break;
310 }309 }
311 }310 }
312311
313 if (dev.path().isEmpty()) {312 return QString();
314 // didn't find a wifi device
315 return QString();
316 }
317
318 if (!ip4addr) {
319 // no ip address
320 return QString();
321 }
322
323
324 struct in_addr ip_addr;
325 ip_addr.s_addr = ip4addr;
326 return QString(inet_ntoa(ip_addr));
327}313}
328314
329struct Network : public QObject315struct Network : public QObject

Subscribers

People subscribed via source and target branches