Merge lp:~jonas-drange/ubuntu-system-settings/show-ip-and-mac into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Merged
Approved by: Ken VanDine
Approved revision: 954
Merged at revision: 991
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/show-ip-and-mac
Merge into: lp:ubuntu-system-settings
Diff against target: 549 lines (+393/-8)
10 files modified
plugins/about/CMakeLists.txt (+11/-2)
plugins/about/PageComponent.qml (+19/-0)
plugins/about/networkabout.cpp (+95/-0)
plugins/about/networkabout.h (+57/-0)
plugins/about/plugin.cpp (+3/-1)
plugins/wifi/AccessPoint.qml (+12/-0)
plugins/wifi/CMakeLists.txt (+1/-0)
plugins/wifi/NetworkDetailsBrief.qml (+79/-0)
plugins/wifi/wifidbushelper.cpp (+104/-4)
plugins/wifi/wifidbushelper.h (+12/-1)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/show-ip-and-mac
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Approve
Ken VanDine Approve
Review via email: mp+232487@code.launchpad.net

Commit message

[about/wifi] adding mac addresses for bt and wifi, and ip for wifi

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, I didn't do a real review but the listitem need to have their text set as translatable (e.g using i18.tr() for the strings)

review: Needs Fixing
Revision history for this message
Sebastien Bacher (seb128) wrote :

could you also link to the corresponding bug so it gets closed on upload?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

The title on the NetworkDetailsBrief page should be the wireless network name according to the design.

review: Needs Fixing
954. By Jonas G. Drange

translatable strings, naming panel network name

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Works fine, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/about/CMakeLists.txt'
--- plugins/about/CMakeLists.txt 2014-07-22 20:21:24 +0000
+++ plugins/about/CMakeLists.txt 2014-08-29 18:12:46 +0000
@@ -18,8 +18,17 @@
18)18)
1919
20add_library(UbuntuStorageAboutPanel MODULE20add_library(UbuntuStorageAboutPanel MODULE
21plugin.cpp storageabout.cpp click.cpp plugin.h storageabout.h click.h21 plugin.cpp
22${QML_SOURCES}) # So they show up in Qt designer.22 storageabout.cpp
23 click.cpp
24 networkabout.cpp
25 plugin.h
26 storageabout.h
27 click.h
28 networkabout.h
29 ${QML_SOURCES} # So they show up in Qt designer.
30)
31
23qt5_use_modules(UbuntuStorageAboutPanel Qml Quick DBus)32qt5_use_modules(UbuntuStorageAboutPanel Qml Quick DBus)
24target_link_libraries(UbuntuStorageAboutPanel33target_link_libraries(UbuntuStorageAboutPanel
25${ANDR_PROP_LDFLAGS} ${GLIB_LDFLAGS} ${GIO_LDFLAGS})34${ANDR_PROP_LDFLAGS} ${GLIB_LDFLAGS} ${GIO_LDFLAGS})
2635
=== modified file 'plugins/about/PageComponent.qml'
--- plugins/about/PageComponent.qml 2014-08-06 13:54:52 +0000
+++ plugins/about/PageComponent.qml 2014-08-29 18:12:46 +0000
@@ -55,6 +55,10 @@
55 modemPath: manager.modems[0]55 modemPath: manager.modems[0]
56 }56 }
5757
58 NetworkAbout {
59 id: network
60 }
61
58 Flickable {62 Flickable {
59 id: scrollWidget63 id: scrollWidget
60 anchors.fill: parent64 anchors.fill: parent
@@ -118,6 +122,21 @@
118 visible: imeiNumber122 visible: imeiNumber
119 }123 }
120124
125 ListItem.SingleValue {
126 text: i18n.tr("Wi-Fi address")
127 value: network.networkMacAddresses[0]
128 visible: network.networkMacAddresses.length > 0
129 showDivider: bthwaddr.visible
130 }
131
132 ListItem.SingleValue {
133 id: bthwaddr
134 text: i18n.tr("Bluetooth address")
135 value: network.bluetoothMacAddress
136 visible: network.bluetoothMacAddress
137 showDivider: false
138 }
139
121 ListItem.Divider {}140 ListItem.Divider {}
122141
123 ListItem.Standard {142 ListItem.Standard {
124143
=== added file 'plugins/about/networkabout.cpp'
--- plugins/about/networkabout.cpp 1970-01-01 00:00:00 +0000
+++ plugins/about/networkabout.cpp 2014-08-29 18:12:46 +0000
@@ -0,0 +1,95 @@
1/*
2 * This file is part of system-settings
3 *
4 * Copyright (C) 2014 Canonical Ltd.
5 *
6 * Contact: Jonas G. Drange <jonas.drange@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <QDebug>
22#include <QDBusReply>
23
24#include "networkabout.h"
25
26NetworkAbout::NetworkAbout(QObject *parent)
27 : QObject(parent),
28 m_systemBusConnection(QDBusConnection::systemBus())
29{
30
31 setupNetworkMacAddresses();
32 setupBluetoothMacAddress();
33}
34
35void NetworkAbout::setupNetworkMacAddresses()
36{
37 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
38 int count = ifaces.count();
39
40 QString str = QString();
41 for(int i=0;i<count;i++)
42 {
43 QNetworkInterface iface = ifaces.at(i);
44 str = iface.hardwareAddress();
45 // add interfaces that are not loopback
46 if (!iface.flags().testFlag(QNetworkInterface::IsLoopBack)) {
47 m_networkMacAddresses << str;
48 }
49 }
50}
51
52void NetworkAbout::setupBluetoothMacAddress()
53{
54 QDBusInterface bluezManagerInterface (
55 "org.bluez",
56 "/",
57 "org.bluez.Manager",
58 m_systemBusConnection,
59 this);
60
61 if (!bluezManagerInterface.isValid()) {
62 return;
63 }
64
65 QDBusReply<QDBusObjectPath> defaultDevice = bluezManagerInterface.call("DefaultAdapter");
66
67 if (!defaultDevice.isValid()) {
68 return;
69 }
70
71 QDBusInterface adapterInterface (
72 "org.bluez",
73 defaultDevice.value().path(),
74 "org.bluez.Adapter",
75 m_systemBusConnection,
76 this);
77
78 QDBusReply<QVariantMap> props = adapterInterface.call("GetProperties");
79
80 if (!props.isValid()) {
81 return;
82 }
83
84 m_bluetoothMacAddress = props.value()["Address"].toString();
85}
86
87QStringList NetworkAbout::networkMacAddresses()
88{
89 return m_networkMacAddresses;
90}
91
92QString NetworkAbout::bluetoothMacAddress()
93{
94 return m_bluetoothMacAddress;
95}
096
=== added file 'plugins/about/networkabout.h'
--- plugins/about/networkabout.h 1970-01-01 00:00:00 +0000
+++ plugins/about/networkabout.h 2014-08-29 18:12:46 +0000
@@ -0,0 +1,57 @@
1/*
2 * This file is part of system-settings
3 *
4 * Copyright (C) 2014 Canonical Ltd.
5 *
6 * Contact: Jonas G. Drange <jonas.drange@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef NETWORKABOUT_H
22#define NETWORKABOUT_H
23
24#include <QObject>
25#include <QStringList>
26#include <QtNetwork>
27#include <QtDBus/QDBusInterface>
28
29
30class NetworkAbout : public QObject
31{
32 Q_OBJECT
33 Q_PROPERTY( QStringList networkMacAddresses
34 READ networkMacAddresses
35 NOTIFY networkMacAddressesChanged )
36 Q_PROPERTY( QString bluetoothMacAddress
37 READ bluetoothMacAddress
38 NOTIFY bluetoothMacAddressChanged )
39
40public:
41 explicit NetworkAbout (QObject *parent = 0);
42 QStringList networkMacAddresses();
43 QString bluetoothMacAddress();
44
45Q_SIGNALS:
46 void networkMacAddressesChanged(QStringList addresses);
47 void bluetoothMacAddressChanged(QString addresses);
48
49private:
50 QStringList m_networkMacAddresses;
51 QString m_bluetoothMacAddress;
52 void setupNetworkMacAddresses();
53 void setupBluetoothMacAddress();
54 QDBusConnection m_systemBusConnection;
55};
56
57#endif // NETWORKABOUT_H
058
=== modified file 'plugins/about/plugin.cpp'
--- plugins/about/plugin.cpp 2014-07-23 13:37:06 +0000
+++ plugins/about/plugin.cpp 2014-08-29 18:12:46 +0000
@@ -23,14 +23,16 @@
23#include <QtQml/QQmlContext>23#include <QtQml/QQmlContext>
24#include "click.h"24#include "click.h"
25#include "storageabout.h"25#include "storageabout.h"
26#include "networkabout.h"
2627
2728
28void BackendPlugin::registerTypes(const char *uri)29void BackendPlugin::registerTypes(const char *uri)
29{30{
30 Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.StorageAbout"));31 Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.StorageAbout"));
31 32
32 qRegisterMetaType<ClickModel::Roles>();33 qRegisterMetaType<ClickModel::Roles>();
33 qmlRegisterType<ClickModel>(uri, 1, 0, "ClickRoles");34 qmlRegisterType<ClickModel>(uri, 1, 0, "ClickRoles");
35 qmlRegisterType<NetworkAbout>(uri, 1, 0, "NetworkAbout");
34 qmlRegisterType<StorageAbout>(uri, 1, 0, "UbuntuStorageAboutPanel");36 qmlRegisterType<StorageAbout>(uri, 1, 0, "UbuntuStorageAboutPanel");
35}37}
3638
3739
=== modified file 'plugins/wifi/AccessPoint.qml'
--- plugins/wifi/AccessPoint.qml 2013-11-28 15:09:15 +0000
+++ plugins/wifi/AccessPoint.qml 2014-08-29 18:12:46 +0000
@@ -34,6 +34,11 @@
34 onCheckedChanged: {34 onCheckedChanged: {
35 // Can't rely on binding. Checked is assigned on click.35 // Can't rely on binding. Checked is assigned on click.
36 checkBoxActive.checked = checked;36 checkBoxActive.checked = checked;
37
38 // if stack has NetworkDetailsBrief, pop it
39 if (pageStack.depth === 3) {
40 pageStack.pop();
41 }
37 }42 }
3843
39 iconName: {44 iconName: {
@@ -65,4 +70,11 @@
65 accessPoint.activate();70 accessPoint.activate();
66 }71 }
67 }72 }
73 progression: checked
74 onClicked: {
75 if (checked) {
76 pageStack.push(Qt.resolvedUrl("NetworkDetailsBrief.qml"),
77 {networkName : text, accessPoint: accessPoint})
78 }
79 }
68}80}
6981
=== modified file 'plugins/wifi/CMakeLists.txt'
--- plugins/wifi/CMakeLists.txt 2014-06-18 14:16:53 +0000
+++ plugins/wifi/CMakeLists.txt 2014-08-29 18:12:46 +0000
@@ -7,6 +7,7 @@
7IndicatorBase.qml7IndicatorBase.qml
8MenuItemFactory.qml8MenuItemFactory.qml
9NetworkDetails.qml9NetworkDetails.qml
10NetworkDetailsBrief.qml
10OtherNetwork.qml11OtherNetwork.qml
11PageComponent.qml12PageComponent.qml
12PreviousNetworks.qml13PreviousNetworks.qml
1314
=== added file 'plugins/wifi/NetworkDetailsBrief.qml'
--- plugins/wifi/NetworkDetailsBrief.qml 1970-01-01 00:00:00 +0000
+++ plugins/wifi/NetworkDetailsBrief.qml 2014-08-29 18:12:46 +0000
@@ -0,0 +1,79 @@
1/*
2 * This file is part of system-settings
3 *
4 * Copyright (C) 2014 Canonical Ltd.
5 *
6 * Contact: Jonas G. Drange <jonas.drange@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21import QtQuick 2.0
22import QtQuick.Layouts 1.1
23import SystemSettings 1.0
24import Ubuntu.Components 0.1
25import Ubuntu.Components.ListItems 0.1 as ListItem
26import Ubuntu.SystemSettings.Wifi 1.0
27
28ItemPage {
29
30 property string networkName
31 property var accessPoint
32
33 title: networkName
34
35 Column {
36
37 anchors.fill: parent
38
39 ListItem.Divider {}
40
41 Button {
42 text : i18n.tr("Disconnect")
43 anchors {
44 left: parent.left
45 right: parent.right
46 margins: units.gu(2)
47 }
48 onClicked: {
49 if (DbusHelper.deactivateConnection()) {
50 accessPoint.checked = false;
51 accessPoint.checkedChanged(false)
52 }
53
54 }
55 }
56
57 ListItem.Standard {
58 text: i18n.tr("IP address")
59 id: addressItem
60 control: TextField {
61 text: DbusHelper.wifiIp4Address
62 readOnly: true
63 horizontalAlignment: TextInput.AlignRight
64 width: addressItem.width/2
65 persistentSelection: true
66 font.pixelSize: units.dp(16)
67 font.weight: Font.Light
68 font.family: "Ubuntu"
69 color: "#AAAAAA"
70 maximumLength: 20
71 focus: true
72 clip: true
73 opacity: 0.9
74 cursorVisible: false
75 hasClearButton: false
76 }
77 }
78 }
79}
080
=== modified file 'plugins/wifi/wifidbushelper.cpp'
--- plugins/wifi/wifidbushelper.cpp 2014-07-23 13:53:48 +0000
+++ plugins/wifi/wifidbushelper.cpp 2014-08-29 18:12:46 +0000
@@ -23,15 +23,20 @@
23#include <QtDebug>23#include <QtDebug>
24#include <QDBusInterface>24#include <QDBusInterface>
25#include <algorithm>25#include <algorithm>
26#include <arpa/inet.h>
2627
27#include "nm_manager_proxy.h"28#include "nm_manager_proxy.h"
28#include "nm_settings_proxy.h"29#include "nm_settings_proxy.h"
29#include "nm_settings_connection_proxy.h"30#include "nm_settings_connection_proxy.h"
3031
32#define NM_SERVICE "org.freedesktop.NetworkManager"
33#define NM_PATH "/org/freedesktop/NetworkManager"
34
31typedef QMap<QString,QVariantMap> ConfigurationData;35typedef QMap<QString,QVariantMap> ConfigurationData;
32Q_DECLARE_METATYPE(ConfigurationData)36Q_DECLARE_METATYPE(ConfigurationData)
3337
34WifiDbusHelper::WifiDbusHelper(QObject *parent) : QObject(parent)38WifiDbusHelper::WifiDbusHelper(QObject *parent) : QObject(parent),
39 m_systemBusConnection(QDBusConnection::systemBus())
35{40{
36 qDBusRegisterMetaType<ConfigurationData>();41 qDBusRegisterMetaType<ConfigurationData>();
37}42}
@@ -43,9 +48,9 @@
43 return;48 return;
44 }49 }
4550
46 OrgFreedesktopNetworkManagerInterface mgr("org.freedesktop.NetworkManager",51 OrgFreedesktopNetworkManagerInterface mgr(NM_SERVICE,
47 "/org/freedesktop/NetworkManager",52 NM_PATH,
48 QDBusConnection::systemBus());53 m_systemBusConnection);
4954
50 QMap<QString, QVariantMap> configuration;55 QMap<QString, QVariantMap> configuration;
5156
@@ -115,6 +120,53 @@
115 tmp);120 tmp);
116}121}
117122
123QString WifiDbusHelper::getWifiIpAddress()
124{
125 OrgFreedesktopNetworkManagerInterface mgr(NM_SERVICE,
126 NM_PATH,
127 m_systemBusConnection);
128
129 // find the first wlan adapter for now
130 auto reply1 = mgr.GetDevices();
131 reply1.waitForFinished();
132 if(!reply1.isValid()) {
133 qWarning() << "Could not get network device: " << reply1.error().message() << "\n";
134 return QString();
135 }
136 auto devices = reply1.value();
137 int ip4addr;
138
139 QDBusObjectPath dev;
140 for (const auto &d : devices) {
141 QDBusInterface iface("org.freedesktop.NetworkManager",
142 d.path(),
143 "org.freedesktop.NetworkManager.Device",
144 m_systemBusConnection);
145
146 auto type_v = iface.property("DeviceType");
147 if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) {
148 ip4addr = iface.property("Ip4Address").toInt();
149 dev = d;
150 break;
151 }
152 }
153
154 if (dev.path().isEmpty()) {
155 // didn't find a wifi device
156 return QString();
157 }
158
159 if (!ip4addr) {
160 // no ip address
161 return QString();
162 }
163
164
165 struct in_addr ip_addr;
166 ip_addr.s_addr = ip4addr;
167 return QString(inet_ntoa(ip_addr));
168}
169
118struct Network : public QObject170struct Network : public QObject
119{171{
120 struct DontCare : public std::exception {};172 struct DontCare : public std::exception {};
@@ -316,3 +368,51 @@
316 qWarning() << "Error forgetting network: " << reply.error().message() << "\n";368 qWarning() << "Error forgetting network: " << reply.error().message() << "\n";
317 }369 }
318}370}
371
372bool WifiDbusHelper::deactivateConnection() {
373 OrgFreedesktopNetworkManagerInterface mgr(NM_SERVICE,
374 NM_PATH,
375 m_systemBusConnection);
376 // find the first wlan adapter for now
377 auto reply1 = mgr.GetDevices();
378 reply1.waitForFinished();
379 if(!reply1.isValid()) {
380 qWarning() << "deactivateConnection: Could not get network device: " << reply1.error().message() << "\n";
381 return false;
382 }
383 auto devices = reply1.value();
384
385 QDBusObjectPath activeConnection;
386 QDBusObjectPath dev;
387 for (const auto &d : devices) {
388 QDBusInterface iface(NM_SERVICE,
389 d.path(),
390 "org.freedesktop.NetworkManager.Device",
391 m_systemBusConnection);
392
393 auto type_v = iface.property("DeviceType");
394 if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) {
395 activeConnection = qvariant_cast<QDBusObjectPath>(iface.property("ActiveConnection"));
396 dev = d;
397 break;
398 }
399 }
400
401 if (dev.path().isEmpty()) {
402 // didn't find a wifi device
403 return false;
404 }
405
406 if (activeConnection.path().isEmpty()) {
407 // no active connection
408 return false;
409 }
410
411 auto reply = mgr.DeactivateConnection(activeConnection);
412 reply.waitForFinished();
413 if(!reply.isValid()) {
414 qWarning() << "Error deactivating connection: " << reply.error().message() << "\n";
415 return false;
416 }
417 return true;
418}
319419
=== modified file 'plugins/wifi/wifidbushelper.h'
--- plugins/wifi/wifidbushelper.h 2014-07-23 13:53:48 +0000
+++ plugins/wifi/wifidbushelper.h 2014-08-29 18:12:46 +0000
@@ -21,6 +21,7 @@
21#define WIFI_DBUS_HELPER21#define WIFI_DBUS_HELPER
2222
23#include <QObject>23#include <QObject>
24#include <QtDBus>
2425
25/**26/**
26 * For sending specific dbus messages from QML.27 * For sending specific dbus messages from QML.
@@ -28,6 +29,9 @@
2829
29class WifiDbusHelper final : public QObject {30class WifiDbusHelper final : public QObject {
30 Q_OBJECT31 Q_OBJECT
32 Q_PROPERTY( QString wifiIp4Address
33 READ getWifiIpAddress
34 NOTIFY wifiIp4AddressChanged)
3135
32public:36public:
33 explicit WifiDbusHelper(QObject *parent = nullptr);37 explicit WifiDbusHelper(QObject *parent = nullptr);
@@ -36,7 +40,14 @@
36 Q_INVOKABLE void connect(QString ssid, int security, QString password);40 Q_INVOKABLE void connect(QString ssid, int security, QString password);
37 Q_INVOKABLE QList<QStringList> getPreviouslyConnectedWifiNetworks();41 Q_INVOKABLE QList<QStringList> getPreviouslyConnectedWifiNetworks();
38 Q_INVOKABLE void forgetConnection(const QString dbus_path);42 Q_INVOKABLE void forgetConnection(const QString dbus_path);
3943 Q_INVOKABLE bool deactivateConnection();
44
45Q_SIGNALS:
46 void wifiIp4AddressChanged(QString wifiIp4Address);
47
48private:
49 QDBusConnection m_systemBusConnection;
50 QString getWifiIpAddress();
40};51};
4152
4253

Subscribers

People subscribed via source and target branches