Merge lp:~ken-vandine/ubuntu-system-settings/rtm-forgetful into lp:ubuntu-system-settings/rtm-14.09

Proposed by Ken VanDine
Status: Merged
Merged at revision: 969
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/rtm-forgetful
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 113 lines (+24/-10)
4 files modified
plugins/wifi/NetworkDetailsBrief.qml (+2/-2)
plugins/wifi/OtherNetwork.qml (+2/-2)
plugins/wifi/wifidbushelper.cpp (+19/-5)
plugins/wifi/wifidbushelper.h (+1/-1)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/rtm-forgetful
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+246644@code.launchpad.net

Commit message

Make currently active connection forgettable.

Description of the change

Make currently active connection forgettable.

To post a comment you must log in.
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: Needs Fixing (continuous-integration)
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

String "Forget" can be safely changed to "Forget network" AFAICS. The .pot in rtm contains latter string.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/wifi/NetworkDetailsBrief.qml'
2--- plugins/wifi/NetworkDetailsBrief.qml 2014-09-16 16:08:56 +0000
3+++ plugins/wifi/NetworkDetailsBrief.qml 2015-01-15 21:07:08 +0000
4@@ -39,14 +39,14 @@
5 ListItem.Divider {}
6
7 Button {
8- text : i18n.tr("Disconnect")
9+ text : i18n.tr("Forget")
10 anchors {
11 left: parent.left
12 right: parent.right
13 margins: units.gu(2)
14 }
15 onClicked: {
16- if (DbusHelper.disconnectDevice()) {
17+ if (DbusHelper.forgetActiveDevice()) {
18 accessPoint.checked = false;
19 accessPoint.checkedChanged(false)
20 }
21
22=== modified file 'plugins/wifi/OtherNetwork.qml'
23--- plugins/wifi/OtherNetwork.qml 2014-09-18 16:48:38 +0000
24+++ plugins/wifi/OtherNetwork.qml 2015-01-15 21:07:08 +0000
25@@ -292,7 +292,7 @@
26 // If this dialog created the connection,
27 // disconnect the device
28 if (otherNetworkDialog.state === "CONNECTING") {
29- DbusHelper.disconnectDevice();
30+ DbusHelper.forgetActiveDevice();
31 }
32 }
33 }
34@@ -355,7 +355,7 @@
35 /* Disconnect the device if it tries to reconnect after a
36 connection failure */
37 if (newState === 40) { // 40 = NM_DEVICE_STATE_PREPARE
38- DbusHelper.disconnectDevice();
39+ DbusHelper.forgetActiveDevice();
40 }
41 }
42
43
44=== modified file 'plugins/wifi/wifidbushelper.cpp'
45--- plugins/wifi/wifidbushelper.cpp 2014-09-18 16:48:38 +0000
46+++ plugins/wifi/wifidbushelper.cpp 2015-01-15 21:07:08 +0000
47@@ -32,6 +32,7 @@
48 #define NM_SERVICE "org.freedesktop.NetworkManager"
49 #define NM_PATH "/org/freedesktop/NetworkManager"
50 #define NM_DEVICE_IFACE "org.freedesktop.NetworkManager.Device"
51+#define NM_ACTIVE_CONNECTION_IFACE "org.freedesktop.NetworkManager.Connection.Active"
52
53 typedef QMap<QString,QVariantMap> ConfigurationData;
54 Q_DECLARE_METATYPE(ConfigurationData)
55@@ -394,7 +395,7 @@
56 }
57 }
58
59-bool WifiDbusHelper::disconnectDevice() {
60+bool WifiDbusHelper::forgetActiveDevice() {
61 OrgFreedesktopNetworkManagerInterface mgr(NM_SERVICE,
62 NM_PATH,
63 m_systemBusConnection);
64@@ -402,7 +403,7 @@
65 auto reply1 = mgr.GetDevices();
66 reply1.waitForFinished();
67 if(!reply1.isValid()) {
68- qWarning() << "disconnectDevice: Could not get network device: " << reply1.error().message() << "\n";
69+ qWarning() << __PRETTY_FUNCTION__ << ": Could not get network device: " << reply1.error().message() << "\n";
70 return false;
71 }
72 auto devices = reply1.value();
73@@ -415,11 +416,24 @@
74 if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) {
75 if (d.path().isEmpty()) {
76 // didn't find a wifi device
77- qWarning() << "disconnectDevice: Could not find wifi device\n";
78+ qWarning() << __PRETTY_FUNCTION__ << ": Could not find wifi device\n";
79 return false;
80 } else {
81- iface.call("Disconnect");
82- return true;
83+ auto ac_path_var = iface.property("ActiveConnection");
84+ if(!ac_path_var.isValid()) {
85+ qWarning() << __PRETTY_FUNCTION__ << ": Could not get active connection property from "
86+ << d.path() << ".\n";
87+ return true;
88+ }
89+ QString ac_path = ac_path_var.value<QDBusObjectPath>().path();
90+ QDBusInterface ac_iface(NM_SERVICE, ac_path, NM_ACTIVE_CONNECTION_IFACE, m_systemBusConnection);
91+ auto conn_path_var = ac_iface.property("Connection");
92+ if(!conn_path_var.isValid()) {
93+ qWarning() << __PRETTY_FUNCTION__ << ": Could not get connection path property from "
94+ << ac_path << ".\n";
95+ return false;
96+ }
97+ forgetConnection(conn_path_var.value<QDBusObjectPath>().path());
98 }
99 break;
100 }
101
102=== modified file 'plugins/wifi/wifidbushelper.h'
103--- plugins/wifi/wifidbushelper.h 2014-09-16 16:08:56 +0000
104+++ plugins/wifi/wifidbushelper.h 2015-01-15 21:07:08 +0000
105@@ -40,7 +40,7 @@
106 Q_INVOKABLE void connect(QString ssid, int security, QString password);
107 Q_INVOKABLE QList<QStringList> getPreviouslyConnectedWifiNetworks();
108 Q_INVOKABLE void forgetConnection(const QString dbus_path);
109- Q_INVOKABLE bool disconnectDevice();
110+ Q_INVOKABLE bool forgetActiveDevice();
111
112 public Q_SLOTS:
113 void nmDeviceStateChanged(uint, uint, uint);

Subscribers

People subscribed via source and target branches