Merge lp:~jonas-drange/ubuntu-system-settings/consolidate-connectivity into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Work in progress
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/consolidate-connectivity
Merge into: lp:ubuntu-system-settings
Diff against target: 272 lines (+56/-93)
9 files modified
plugins/cellular/CMakeLists.txt (+2/-2)
plugins/security-privacy/CMakeLists.txt (+1/-2)
plugins/security-privacy/connectivity.cpp (+0/-49)
plugins/security-privacy/connectivity.h (+0/-35)
src/CMakeLists.txt (+4/-0)
src/connectivity.cpp (+16/-0)
src/connectivity.h (+3/-2)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+1/-3)
tests/autopilot/ubuntu_system_settings/tests/test_security.py (+29/-0)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/consolidate-connectivity
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ken VanDine Needs Fixing
Review via email: mp+250347@code.launchpad.net

Commit message

[cellular/security] consolidate connectivity APIs, making it a shared USS library

Description of the change

Both Security and Cellular use the private Connectivity API to unlock one or more SIMs. They both have a C++ binding that does this, since they the two panels landed independently.

This branch moves the Connectivity C++ binding out of the respective plugins and makes it a shared one—usable by all plugins.

Needs manual testing of SIM unlocking in Security panel, as well as unlocking after a tech switch (changing has3g on a modem).

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: Approve (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Please add the test back for this

review: Needs Fixing
1321. By Jonas G. Drange

merge trunk

1322. By Jonas G. Drange

re-add previously broken test

1323. By Jonas G. Drange

testing theory that we can't have two setupclass calls

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1324. By Jonas G. Drange

re-add mixin, move test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1325. By Jonas G. Drange

rewriting test to not include session bus mocking, which in this case seems broken

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1326. By Jonas G. Drange

OLD FASHIONED MOCK

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1327. By Jonas G. Drange

mocking the proper way

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

Unmerged revisions

1327. By Jonas G. Drange

mocking the proper way

1326. By Jonas G. Drange

OLD FASHIONED MOCK

1325. By Jonas G. Drange

rewriting test to not include session bus mocking, which in this case seems broken

1324. By Jonas G. Drange

re-add mixin, move test

1323. By Jonas G. Drange

testing theory that we can't have two setupclass calls

1322. By Jonas G. Drange

re-add previously broken test

1321. By Jonas G. Drange

merge trunk

1320. By Jonas G. Drange

make connectivity a shared uss library

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/cellular/CMakeLists.txt'
2--- plugins/cellular/CMakeLists.txt 2015-01-14 15:57:10 +0000
3+++ plugins/cellular/CMakeLists.txt 2015-02-25 00:19:36 +0000
4@@ -24,8 +24,6 @@
5 hotspotmanager.h
6 ofonoactivator.cpp
7 ofonoactivator.h
8- connectivity.cpp
9- connectivity.h
10 nm_manager_proxy.h
11 nm_settings_proxy.h
12 nm_settings_connection_proxy.h
13@@ -33,6 +31,8 @@
14 )
15 qt5_use_modules(UbuntuCellularPanel Qml Quick DBus)
16
17+target_link_libraries (UbuntuCellularPanel uss-connectivity)
18+
19 set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Cellular)
20 install(TARGETS UbuntuCellularPanel DESTINATION ${PLUG_DIR})
21 install(FILES qmldir DESTINATION ${PLUG_DIR})
22
23=== modified file 'plugins/security-privacy/CMakeLists.txt'
24--- plugins/security-privacy/CMakeLists.txt 2015-01-26 13:35:57 +0000
25+++ plugins/security-privacy/CMakeLists.txt 2015-02-25 00:19:36 +0000
26@@ -33,8 +33,6 @@
27 )
28
29 set(PANEL_SOURCES
30- connectivity.cpp
31- connectivity.h
32 plugin.cpp
33 plugin.h
34 securityprivacy.cpp
35@@ -58,6 +56,7 @@
36 set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/SecurityPrivacy)
37 target_link_libraries (UbuntuSecurityPrivacyPanel
38 uss-accountsservice
39+ uss-connectivity
40 ${ACCOUNTSSERVICE_LDFLAGS}
41 ${GOBJECT_LDFLAGS}
42 ${TRUST_STORE_LDFLAGS}
43
44=== removed file 'plugins/security-privacy/connectivity.cpp'
45--- plugins/security-privacy/connectivity.cpp 2015-01-26 13:35:57 +0000
46+++ plugins/security-privacy/connectivity.cpp 1970-01-01 00:00:00 +0000
47@@ -1,49 +0,0 @@
48-/*
49- * Copyright (C) 2015 Canonical, Ltd.
50- *
51- * Authors:
52- * Jonas G. Drange <jonas.drange@canonical.com>
53- *
54- * This program is free software: you can redistribute it and/or modify it
55- * under the terms of the GNU General Public License version 3, as published
56- * by the Free Software Foundation.
57- *
58- * This library is distributed in the hope that it will be useful, but WITHOUT
59- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
60- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
61- * details.
62- *
63- * You should have received a copy of the GNU General Public License
64- * along with this program. If not, see <http://www.gnu.org/licenses/>.
65- */
66-
67-#include <QDBusReply>
68-#include <QtDebug>
69-#include <QDBusInterface>
70-#include "connectivity.h"
71-
72-namespace {
73- const QString conn_service("com.ubuntu.connectivity1");
74- const QString conn_object("/com/ubuntu/connectivity1/Private");
75- const QString conn_interface("com.ubuntu.connectivity1.Private");
76- const QString conn_unlockmodem_method("UnlockModem");
77-}
78-
79-Connectivity::Connectivity(QObject *parent) : QObject(parent)
80-{
81-}
82-
83-void Connectivity::unlockModem(QString path)
84-{
85- QDBusInterface connectivityIface (
86- conn_service,
87- conn_object,
88- conn_interface,
89- QDBusConnection::sessionBus(),
90- this);
91-
92- auto reply = connectivityIface.call(conn_unlockmodem_method, path);
93- if (reply.type() == QDBusMessage::ErrorMessage) {
94- qWarning() << "Failed to unlock modem" << path << reply.errorMessage();
95- }
96-}
97
98=== removed file 'plugins/security-privacy/connectivity.h'
99--- plugins/security-privacy/connectivity.h 2015-01-26 13:35:57 +0000
100+++ plugins/security-privacy/connectivity.h 1970-01-01 00:00:00 +0000
101@@ -1,35 +0,0 @@
102-/*
103- * Copyright (C) 2015 Canonical, Ltd.
104- *
105- * Authors:
106- * Jonas G. Drange <jonas.drange@canonical.com>
107- *
108- * This program is free software: you can redistribute it and/or modify it
109- * under the terms of the GNU General Public License version 3, as published
110- * by the Free Software Foundation.
111- *
112- * This library is distributed in the hope that it will be useful, but WITHOUT
113- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
114- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
115- * details.
116- *
117- * You should have received a copy of the GNU General Public License
118- * along with this program. If not, see <http://www.gnu.org/licenses/>.
119- */
120-
121-#ifndef CELLULAR_CONNECTIVITY_HELPER
122-#define CELLULAR_CONNECTIVITY_HELPER
123-
124-#include <QObject>
125-
126-class Connectivity : public QObject {
127- Q_OBJECT
128-
129-public:
130- explicit Connectivity(QObject *parent = nullptr);
131- ~Connectivity() {};
132-
133- Q_INVOKABLE void unlockModem(QString path);
134-};
135-
136-#endif
137
138=== modified file 'src/CMakeLists.txt'
139--- src/CMakeLists.txt 2014-10-31 14:53:32 +0000
140+++ src/CMakeLists.txt 2015-02-25 00:19:36 +0000
141@@ -37,9 +37,13 @@
142
143 add_library(uss-accountsservice SHARED accountsservice.h accountsservice.cpp)
144 add_library(uss-sessionservice SHARED sessionservice.h sessionservice.cpp)
145+add_library(uss-connectivity SHARED connectivity.h connectivity.cpp)
146 qt5_use_modules(uss-accountsservice Core Qml DBus)
147 qt5_use_modules(uss-sessionservice Core Qml DBus)
148+qt5_use_modules(uss-connectivity Core Qml DBus)
149 set_target_properties(uss-accountsservice PROPERTIES VERSION 0.0 SOVERSION 0.0)
150 set_target_properties(uss-sessionservice PROPERTIES VERSION 0.0 SOVERSION 0.0)
151+set_target_properties(uss-connectivity PROPERTIES VERSION 0.0 SOVERSION 0.0)
152 install(TARGETS uss-accountsservice LIBRARY DESTINATION ${PLUGIN_MODULE_DIR} NAMELINK_SKIP)
153 install(TARGETS uss-sessionservice LIBRARY DESTINATION ${PLUGIN_MODULE_DIR} NAMELINK_SKIP)
154+install(TARGETS uss-connectivity LIBRARY DESTINATION ${PLUGIN_MODULE_DIR} NAMELINK_SKIP)
155
156=== renamed file 'plugins/cellular/connectivity.cpp' => 'src/connectivity.cpp'
157--- plugins/cellular/connectivity.cpp 2015-01-21 20:44:20 +0000
158+++ src/connectivity.cpp 2015-02-25 00:19:36 +0000
159@@ -27,6 +27,7 @@
160 const QString conn_object("/com/ubuntu/connectivity1/Private");
161 const QString conn_interface("com.ubuntu.connectivity1.Private");
162 const QString conn_unlockall_method("UnlockAllModems");
163+ const QString conn_unlockmodem_method("UnlockModem");
164 }
165
166 Connectivity::Connectivity(QObject *parent) : QObject(parent)
167@@ -47,3 +48,18 @@
168 qWarning() << "Failed to unlock modems" << reply.errorMessage();
169 }
170 }
171+
172+void Connectivity::unlockModem(QString path)
173+{
174+ QDBusInterface connectivityIface (
175+ conn_service,
176+ conn_object,
177+ conn_interface,
178+ QDBusConnection::sessionBus(),
179+ this);
180+
181+ auto reply = connectivityIface.call(conn_unlockmodem_method, path);
182+ if (reply.type() == QDBusMessage::ErrorMessage) {
183+ qWarning() << "Failed to unlock modem" << path << reply.errorMessage();
184+ }
185+}
186
187=== renamed file 'plugins/cellular/connectivity.h' => 'src/connectivity.h'
188--- plugins/cellular/connectivity.h 2015-01-14 15:57:10 +0000
189+++ src/connectivity.h 2015-02-25 00:19:36 +0000
190@@ -17,8 +17,8 @@
191 * along with this program. If not, see <http://www.gnu.org/licenses/>.
192 */
193
194-#ifndef CELLULAR_CONNECTIVITY_HELPER
195-#define CELLULAR_CONNECTIVITY_HELPER
196+#ifndef CONNECTIVITY_HELPER
197+#define CONNECTIVITY_HELPER
198
199 #include <QObject>
200
201@@ -30,6 +30,7 @@
202 ~Connectivity() {};
203
204 Q_INVOKABLE void unlockAllModems();
205+ Q_INVOKABLE void unlockModem(QString path);
206 };
207
208 #endif
209
210=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
211--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-02-19 07:22:16 +0000
212+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-02-25 00:19:36 +0000
213@@ -781,14 +781,12 @@
214 class ConnectivityMixin(dbusmock.DBusTestCase):
215 @classmethod
216 def setUpClass(cls):
217- cls.start_session_bus()
218- cls.connectivity_dbus = cls.get_dbus()
219 cls.connectivity_server = cls.spawn_server(CON_SERVICE,
220 CON_PATH,
221 CON_IFACE,
222 system_bus=False,
223 stdout=subprocess.PIPE)
224-
225+ cls.connectivity_dbus = cls.get_dbus()
226 cls.connectivity_mock = dbus.Interface(
227 cls.connectivity_dbus.get_object(CON_SERVICE,
228 CON_PATH),
229
230=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_security.py'
231--- tests/autopilot/ubuntu_system_settings/tests/test_security.py 2015-02-19 15:18:09 +0000
232+++ tests/autopilot/ubuntu_system_settings/tests/test_security.py 2015-02-25 00:19:36 +0000
233@@ -13,6 +13,7 @@
234
235 from ubuntu_system_settings.tests import (
236 SecurityBaseTestCase,
237+ ConnectivityMixin,
238 SIM_IFACE)
239
240 from ubuntu_system_settings.utils.i18n import ugettext as _
241@@ -409,3 +410,31 @@
242 self.assertFalse(
243 len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
244 )
245+
246+
247+class SecurityConnectivityTestCase(SecurityBaseTestCase, ConnectivityMixin):
248+
249+ def _go_to_sim_lock(self):
250+ selector = self.security_page.select_single(
251+ objectName='simControl'
252+ )
253+ self.main_view.scroll_to_and_click(selector)
254+
255+ def test_sim_unlock(self):
256+ # lock sim
257+ self.modem_0.Set(SIM_IFACE, 'PinRequired', 'pin')
258+ self.modem_0.EmitSignal(
259+ SIM_IFACE, 'PropertyChanged', 'sv', ['PinRequired', 'pin'])
260+
261+ self._go_to_sim_lock()
262+ unlock = self.system_settings.main_view.select_single(
263+ objectName='unlock')
264+ self.system_settings.main_view.pointing_device.click_object(unlock)
265+
266+ self.assertThat(
267+ lambda: len(self.connectivity_mock.GetMethodCalls('UnlockModem')),
268+ Eventually(Equals(1)))
269+
270+ # make sure the argument for the one call is the modem path
271+ for d, args in self.connectivity_mock.GetMethodCalls('UnlockModem'):
272+ self.assertEqual(str(args[0]), '/ril_0')

Subscribers

People subscribed via source and target branches