Merge lp:~jonas-drange/ubuntu-system-settings/rtm-forgetful into lp:ubuntu-system-settings/rtm-14.09

Proposed by Jonas G. Drange
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 966
Merged at revision: 969
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/rtm-forgetful
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 201 lines (+55/-23)
6 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)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+30/-10)
tests/autopilot/ubuntu_system_settings/tests/test_wifi.py (+1/-3)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/rtm-forgetful
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Sebastien Bacher (community) Approve
Review via email: mp+247011@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
Sebastien Bacher (seb128) wrote :

Thanks, that looks fine, it seems like the trunk still use "Forget" where it should be "Forget this network" according to the design, could you mp that change as well while at it, so it doesn't get forgotten later on?

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: Needs Fixing (continuous-integration)
967. By Jonas G. Drange

backend has changed, so test also needs changing

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

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-21 14:21:07 +0000
4@@ -39,14 +39,14 @@
5 ListItem.Divider {}
6
7 Button {
8- text : i18n.tr("Disconnect")
9+ text : i18n.tr("Forget network")
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-21 14:21:07 +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-21 14:21:07 +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-21 14:21:07 +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);
114
115=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
116--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-01-12 16:22:55 +0000
117+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-01-21 14:21:07 +0000
118@@ -48,6 +48,8 @@
119 NM_SERVICE = 'org.freedesktop.NetworkManager'
120 NM_PATH = '/org/freedesktop/NetworkManager'
121 NM_IFACE = 'org.freedesktop.NetworkManager'
122+NM_IFACE = 'org.freedesktop.NetworkManager'
123+NM_AC_CON_IFACE = 'org.freedesktop.NetworkManager.Connection.Active'
124 UPOWER_VERSION = str(UPowerGlib.MAJOR_VERSION)
125 UPOWER_VERSION += '.' + str(UPowerGlib.MINOR_VERSION)
126
127@@ -774,18 +776,11 @@
128 self.obj_nm.Reset()
129 device_path = self.obj_nm.AddWiFiDevice('test0', 'Barbaz', 1)
130 self.device_mock = dbus.Interface(self.dbus_con.get_object(
131- 'org.freedesktop.NetworkManager', device_path),
132+ NM_SERVICE, device_path),
133 dbusmock.MOCK_IFACE)
134
135- """A device should not just implement Device.Wireless/Device.Wired
136- interfaces, but also the Device interface. Since we want to test
137- the Disconnect method, we add it."""
138-
139- try:
140- self.device_mock.AddMethod(DEVICE_IFACE, 'Disconnect', '', '', '')
141- except:
142- # it was already added
143- pass
144+ self.add_active_connection(
145+ 'activecon0', self.device_mock, device_path)
146
147 super(WifiBaseTestCase, self).setUp()
148 self.wifi_page = self.main_view.go_to_wifi_page()
149@@ -796,3 +791,28 @@
150 self.obj_nm.AddWiFiConnection(
151 dev_path, network['connection_name'],
152 network['ssid'], network.get('keymng', ''))
153+
154+ def add_active_connection(self, connection_name, device_mock, device_path):
155+ """Add ActiveConnection object to device as well as the
156+ Active.Connection object being referred to. Will add mocked
157+ Connection object, active_connection_mock, to the test case."""
158+
159+ # Add a new Connection object
160+ con_path = self.obj_nm.AddWiFiConnection(
161+ device_path, connection_name, 'fake ssid', '')
162+ self.active_connection_mock = dbus.Interface(self.dbus_con.get_object(
163+ NM_SERVICE, con_path),
164+ dbusmock.MOCK_IFACE)
165+ # Set up the ActiveConnection object, which will have a
166+ # Connection property pointing to the created Connection
167+ ac_path = '/org/freedesktop/NetworkManager/ActiveConnection/%s' % (
168+ connection_name)
169+ self.dbusmock.AddObject(ac_path, NM_AC_CON_IFACE, {}, [])
170+ ac_mock = dbus.Interface(self.dbus_con.get_object(
171+ NM_SERVICE, ac_path),
172+ dbusmock.MOCK_IFACE)
173+ ac_mock.AddProperty(
174+ NM_AC_CON_IFACE, 'Connection', dbus.ObjectPath(con_path))
175+
176+ device_mock.AddProperty(
177+ DEVICE_IFACE, 'ActiveConnection', dbus.ObjectPath(ac_path))
178
179=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_wifi.py'
180--- tests/autopilot/ubuntu_system_settings/tests/test_wifi.py 2015-01-12 16:22:55 +0000
181+++ tests/autopilot/ubuntu_system_settings/tests/test_wifi.py 2015-01-21 14:21:07 +0000
182@@ -117,7 +117,6 @@
183 _('Your authentication details were incorrect'))))
184
185 def test_connect_to_hidden_network_then_cancel(self):
186-
187 dialog = self.wifi_page.connect_to_hidden_network(
188 'foo',
189 scroll_to_and_click=self.main_view
190@@ -128,10 +127,9 @@
191
192 dialog.cancel()
193
194- # check that Disconnect was called once
195 self.assertThat(
196 lambda:
197- len(self.device_mock.GetMethodCalls('Disconnect')),
198+ len(self.active_connection_mock.GetMethodCalls('Delete')),
199 Eventually(Equals(1)))
200
201 """Note: this test does not actually remove previous networks from the UI.

Subscribers

People subscribed via source and target branches