Merge lp:~jonas-drange/ubuntu-system-settings/tech-switch into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Merged
Approved by: Ken VanDine
Approved revision: 1269
Merged at revision: 1313
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/tech-switch
Merge into: lp:ubuntu-system-settings
Prerequisite: lp:~jonas-drange/ubuntu-system-settings/libqofono-0.70-ready
Diff against target: 582 lines (+305/-43)
11 files modified
debian/control (+1/-1)
plugins/cellular/CMakeLists.txt (+2/-0)
plugins/cellular/Components/DataMultiSim.qml (+10/-2)
plugins/cellular/Components/MultiSim.qml (+47/-23)
plugins/cellular/Components/RadioSingleSim.qml (+44/-12)
plugins/cellular/Components/Sim.qml (+26/-3)
plugins/cellular/Components/SingleSim.qml (+4/-0)
plugins/cellular/PageComponent.qml (+76/-2)
plugins/cellular/connectivity.cpp (+49/-0)
plugins/cellular/connectivity.h (+35/-0)
plugins/cellular/plugin.cpp (+11/-0)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/tech-switch
Reviewer Review Type Date Requested Status
Ken VanDine Approve
PS Jenkins bot continuous-integration Needs Fixing
Olivier Tilloy (community) code Needs Fixing
Review via email: mp+246503@code.launchpad.net

Commit message

[cellular] allow user to change 3g modem

Description of the change

* Added connectivity C++ binding used for SIM unlock
* Added a sleepy opacity transition for when modems go away/come back.
* Changed invalidation of the ConnectionManager libqofono binding to invalidate MtkSettings libqofono binding. Most libqofono bindings will not require invalidating anymore, except for the Mtk Settings libqofono binding. See [1].

[1] https://bugs.launchpad.net/ubuntu/+source/libqofono/+bug/1410785

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
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
Ken VanDine (ken-vandine) wrote :

Tested this on krillin, it works. There is a brief time after the UI returns and it shows data is off, after 10 seconds or so it comes back on. That might be confusing, any ideas how to handle that case?

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

wait even though there's multiple modems present

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

cache what modem was online before the tech switch

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)
1265. By Jonas G. Drange

moving repeated functions to sims.js

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Note: I haven’t tested the functionality (I’ll leave that to someone who understands the problem and its context). This is only a code review (from someone who doesn’t know the code base at all).

469 + #define UNLOCKALL_METHOD_NAME "UnlockAllModems"

Why is this one a #define and not a const QString like the others?

486 + if (reply.type() == 3) {

"3" should be QDBusMessage::ErrorMessage.

552 +++ plugins/cellular/sims.js

It doesn’t look like the strings extraction is run on JS files, so if I run `make pot` the strings in that file get excluded from the translation template.
Also, I don’t know what’s the policy for updating the POT file in the source tree, but it looks quite outdated at the moment, you might want to consider updating it (not necessarily as part of this MR though).

545 + qmlRegisterType<Connectivity>(uri, 1, 0, "Connectivity");

If the Connectivity type is only meant to have static invokable methods, then you probably want to register it as a singleton, using qmlRegisterSingletonType(…).

review: Needs Fixing (code)
1266. By Jonas G. Drange

move sim related functionality into the SIM qml for now, let connectivity be a singleton

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

merge trunk

1268. By Jonas G. Drange

detach event handler after the sim comes back

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
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

I tried testing this on krillin and had some problems. Understandably I can't really switch to 3g because in the US the best I can get is edge. In my testing it ultimate would change the tech pref, but it would take several minutes for the connection to come back. It looked as if it had worked, but had no connection and the indicator didn't show the connection. Watching it with monitor-ofono I could see stuff happening, but it would take several minutes to connect.

review: Needs Fixing
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

@ken, could you attach the monitor ouput to bug 1379850? Thanks

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

@ken, this might be a long shot, but did you at any point hot swap and not reboot? I've seen something similar to what you describe after a hot swap.

1269. By Jonas G. Drange

fix dep

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 :

This looks good now, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-01-30 18:09:06 +0000
3+++ debian/control 2015-02-09 12:52:48 +0000
4@@ -72,7 +72,7 @@
5 qtdeclarative5-folderlistmodel-plugin,
6 qml-module-qtmultimedia | qml-module-qtmultimedia-gles,
7 qtdeclarative5-gsettings1.0 (>=0.1+14.10.20140801.1),
8- qtdeclarative5-ofono0.2 (>=0.70),
9+ qtdeclarative5-ofono0.2 (>=0.70~),
10 qtdeclarative5-systeminfo-plugin,
11 qtdeclarative5-ubuntu-content1,
12 qtdeclarative5-ubuntu-settings-components (>> 0.2),
13
14=== modified file 'plugins/cellular/CMakeLists.txt'
15--- plugins/cellular/CMakeLists.txt 2014-11-10 15:20:57 +0000
16+++ plugins/cellular/CMakeLists.txt 2015-02-09 12:52:48 +0000
17@@ -24,6 +24,8 @@
18 hotspotmanager.h
19 ofonoactivator.cpp
20 ofonoactivator.h
21+ connectivity.cpp
22+ connectivity.h
23 nm_manager_proxy.h
24 nm_settings_proxy.h
25 nm_settings_connection_proxy.h
26
27=== modified file 'plugins/cellular/Components/DataMultiSim.qml'
28--- plugins/cellular/Components/DataMultiSim.qml 2014-11-12 19:26:36 +0000
29+++ plugins/cellular/Components/DataMultiSim.qml 2015-02-09 12:52:48 +0000
30@@ -24,6 +24,8 @@
31
32 Column {
33
34+ property string prevOnlineModem: parent.prevOnlineModem
35+
36 function getNameFromIndex (index) {
37 if (index === 0) {
38 return i18n.tr("Off");
39@@ -52,8 +54,14 @@
40 objectName: "use" + modelData
41 text: getNameFromIndex(index)
42 }
43- selectedIndex: [true, sims[0].connMan.powered, sims[1].connMan.powered]
44- .lastIndexOf(true)
45+ selectedIndex: {
46+ if (prevOnlineModem) {
47+ return model.indexOf(prevOnlineModem);
48+ } else {
49+ return [true, sims[0].connMan.powered, sims[1].connMan.powered]
50+ .lastIndexOf(true);
51+ }
52+ }
53
54 onDelegateClicked: {
55 // power all sims on or off
56
57=== modified file 'plugins/cellular/Components/MultiSim.qml'
58--- plugins/cellular/Components/MultiSim.qml 2014-12-11 21:14:43 +0000
59+++ plugins/cellular/Components/MultiSim.qml 2015-02-09 12:52:48 +0000
60@@ -37,14 +37,17 @@
61 return s;
62 }
63 property var modems
64- // make settings available to all children of root
65 property var settings: phoneSettings
66+ property string prevOnlineModem: ""
67+
68+ /* @sim a Sim.qml component containing libqofono bindings
69+ @prevOnlineModem path to modem that was online before modem reset */
70+ signal umtsModemChanged (var sim, string prevOnlineModem);
71
72 DataMultiSim {
73 anchors { left: parent.left; right: parent.right }
74 }
75
76-
77 ListItem.SingleValue {
78 text : i18n.tr("Hotspot disabled because Wi-Fi is off.")
79 visible: showAllUI && !hotspotItem.visible
80@@ -96,13 +99,7 @@
81
82 ListItem.Divider {}
83
84- function techToString (tech) {
85- return {
86- 'gsm': i18n.tr("2G only (saves battery)"),
87- 'umts': i18n.tr("2G/3G (faster)"),
88- 'lte': i18n.tr("2G/3G/4G (faster)")
89- }[tech]
90- }
91+ SettingsItemTitle { text: i18n.tr("Connection type:") }
92
93 Repeater {
94 model: sims
95@@ -110,27 +107,54 @@
96 ListItem.ItemSelector {
97 id: radio
98 property var sim: modelData
99- property var rSettings: sim.radioSettings
100- property string techPref: rSettings.technologyPreference
101- property var modemTechs: rSettings.modemTechnologies
102+
103 expanded: true
104- text: i18n.tr("Connection type:")
105- model: modemTechs || []
106+ text: sim.title
107+ model: sim.radioSettings.modemTechnologies
108 delegate: OptionSelectorDelegate {
109 objectName: sim.path + "_radio_" + modelData
110- text: techToString(modelData)
111- }
112- enabled: techPref !== ""
113- visible: sim.connMan.powered
114- selectedIndex: techPref !== "" ? model.indexOf(techPref) : -1
115- onDelegateClicked: rSettings.technologyPreference = model[index];
116+ text: sim.techToString(modelData)
117+ }
118+ enabled: sim.radioSettings.technologyPreference !== ""
119+ selectedIndex: sim.radioSettings.technologyPreference !== "" ?
120+ model.indexOf(sim.radioSettings.technologyPreference) : -1
121+
122+ onDelegateClicked: {
123+ if (model[index] === 'umts_enable') {
124+ sim.radioSettings.technologyPreference = 'umts';
125+ umtsModemChanged(sim, poweredSim ? poweredSim.path : "");
126+ sim.mtkSettings.has3G = true;
127+ } else {
128+ sim.radioSettings.technologyPreference = model[index];
129+ }
130+ }
131+
132 Connections {
133- target: rSettings
134- onTechnologyPreferenceChanged: {
135- radio.selectedIndex = modemTechs.indexOf(preference)
136+ target: sim.radioSettings
137+ onTechnologyPreferenceChanged: radio.selectedIndex =
138+ sim.radioSettings.modemTechnologies.indexOf(preference)
139+
140+ onModemTechnologiesChanged: {
141+ if ((technologies.indexOf('umts') === -1)
142+ && (sim.mtkSettings.has3G === false)) {
143+ radio.model = sim.addUmtsEnableToModel(technologies);
144+ } else {
145+ radio.model = technologies;
146+ }
147+ radio.selectedIndex = sim.radioSettings.technologyPreference !== "" ?
148+ model.indexOf(sim.radioSettings.technologyPreference) : -1
149 }
150 ignoreUnknownSignals: true
151 }
152+
153+ Component.onCompleted: {
154+ if ((sim.radioSettings.modemTechnologies.indexOf('umts') === -1)
155+ && (sim.mtkSettings.has3G === false)) {
156+ radio.model = sim.addUmtsEnableToModel(sim.radioSettings.modemTechnologies);
157+ } else {
158+ radio.model = sim.radioSettings.modemTechnologies;
159+ }
160+ }
161 }
162 }
163
164
165=== modified file 'plugins/cellular/Components/RadioSingleSim.qml'
166--- plugins/cellular/Components/RadioSingleSim.qml 2014-12-02 15:09:50 +0000
167+++ plugins/cellular/Components/RadioSingleSim.qml 2015-02-09 12:52:48 +0000
168@@ -23,6 +23,7 @@
169 import Ubuntu.Components.ListItems 0.1 as ListItem
170
171 Column {
172+ id: radioSingleSim
173 height: childrenRect.height
174
175 property bool enabled: sim.radioSettings.technologyPreference !== ""
176@@ -31,29 +32,60 @@
177
178 ListItem.ItemSelector {
179 id: selector
180+
181 showDivider: false
182 expanded: true
183
184 // an empty string is not a valid preference, which means
185 // we disregard the interace and disable the selector
186 enabled: parent.enabled
187- model: sim.radioSettings.modemTechnologies || []
188-
189+ model: sim.radioSettings.modemTechnologies
190 delegate: OptionSelectorDelegate {
191 objectName: sim.path + "_radio_" + modelData
192- text: {
193- return {
194- 'gsm': i18n.tr("2G only (saves battery)"),
195- 'umts': i18n.tr("2G/3G (faster)"),
196- 'lte': i18n.tr("2G/3G/4G (faster)")
197- }[modelData]
198- }
199+ text: sim.techToString(modelData)
200 showDivider: false
201 }
202- selectedIndex: model.length ?
203- model.indexOf(sim.radioSettings.technologyPreference) : -1
204+ selectedIndex:
205+ sim.radioSettings.technologyPreference !== "" ?
206+ model.indexOf(sim.radioSettings.technologyPreference) : -1
207+
208 onDelegateClicked: {
209- sim.radioSettings.technologyPreference = model[index];
210+ if (model[index] === 'umts_enable') {
211+ sim.radioSettings.technologyPreference = 'umts';
212+ radioSingleSim.parent.umtsModemChanged(sim, sim.connMan.powered ? sim.path : "");
213+ sim.mtkSettings.has3G = true;
214+ } else {
215+ sim.radioSettings.technologyPreference = model[index];
216+ }
217+ }
218+
219+ Connections {
220+ target: sim.radioSettings
221+
222+ onTechnologyPreferenceChanged: selector.selectedIndex =
223+ sim.radioSettings.modemTechnologies.indexOf(preference)
224+
225+ onModemTechnologiesChanged: {
226+ if ((technologies.indexOf('umts') === -1)
227+ && (sim.mtkSettings.has3G === false)) {
228+ selector.model = sim.addUmtsEnableToModel(technologies);
229+ } else {
230+ selector.model = technologies;
231+ }
232+ selector.selectedIndex = sim.radioSettings.technologyPreference !== "" ?
233+ selector.model.indexOf(sim.radioSettings.technologyPreference) : -1
234+ }
235+ ignoreUnknownSignals: true
236+ }
237+
238+ Component.onCompleted: {
239+ if ((sim.radioSettings.modemTechnologies.indexOf('umts') === -1)
240+ && (sim.mtkSettings.has3G === false)) {
241+ selector.model = sim.addUmtsEnableToModel(
242+ sim.radioSettings.modemTechnologies);
243+ } else {
244+ selector.model = sim.radioSettings.modemTechnologies;
245+ }
246 }
247 }
248 }
249
250=== modified file 'plugins/cellular/Components/Sim.qml'
251--- plugins/cellular/Components/Sim.qml 2014-10-07 15:41:44 +0000
252+++ plugins/cellular/Components/Sim.qml 2015-02-09 12:52:48 +0000
253@@ -27,6 +27,7 @@
254 property alias radioSettings: radioSettings
255 property alias simMng: simMng
256 property alias connMan: connMan
257+ property alias mtkSettings: mtkSettings
258
259 property alias present: simMng.present
260 property string path
261@@ -36,14 +37,31 @@
262 return name + (number ? " (" + number + ")" : "");
263 }
264
265+ function techToString (tech) {
266+ var strings = {
267+ 'gsm': i18n.tr("2G only (saves battery)"),
268+ 'umts': i18n.tr("2G/3G (faster)"),
269+ 'lte': i18n.tr("2G/3G/4G (faster)")
270+ };
271+ strings['umts_enable'] = strings['umts'];
272+ return strings[tech];
273+ }
274+
275+ // adds umts_enable to an copy of model
276+ function addUmtsEnableToModel (model) {
277+ var newModel = model.slice(0);
278+ newModel.push('umts_enable');
279+ return newModel;
280+ }
281+
282 OfonoModem {
283 id: modem
284 modemPath: path
285 onInterfacesChanged: {
286- if (interfaces.indexOf('org.ofono.ConnectionManager') >= 0) {
287- connMan._valid = true;
288+ if (interfaces.indexOf('org.ofono.MtkSettings') >= 0) {
289+ mtkSettings._valid = true;
290 } else {
291- connMan._valid = false;
292+ mtkSettings._valid = false;
293 }
294 }
295 }
296@@ -65,6 +83,11 @@
297
298 OfonoConnMan {
299 id: connMan
300+ modemPath: path
301+ }
302+
303+ OfonoMtkSettings {
304+ id: mtkSettings
305 property bool _valid: true
306 modemPath: path
307 on_ValidChanged: {
308
309=== modified file 'plugins/cellular/Components/SingleSim.qml'
310--- plugins/cellular/Components/SingleSim.qml 2014-12-05 15:34:38 +0000
311+++ plugins/cellular/Components/SingleSim.qml 2015-02-09 12:52:48 +0000
312@@ -28,6 +28,10 @@
313
314 property var sim
315
316+ /* @sim a Sim.qml component containing libqofono bindings
317+ @prevOnlineModem path to modem that was online before this event */
318+ signal umtsModemChanged (var sim, string prevOnlineModem);
319+
320 ListItem.Standard {
321 id: selector
322 text: i18n.tr("Cellular data:")
323
324=== modified file 'plugins/cellular/PageComponent.qml'
325--- plugins/cellular/PageComponent.qml 2015-01-14 00:00:41 +0000
326+++ plugins/cellular/PageComponent.qml 2015-02-09 12:52:48 +0000
327@@ -20,6 +20,7 @@
328
329 import QtQuick 2.0
330 import SystemSettings 1.0
331+import Ubuntu.SystemSettings.Cellular 1.0
332 import Ubuntu.Components 0.1
333 import Ubuntu.Components.ListItems 0.1 as ListItem
334 import MeeGo.QOfono 0.2
335@@ -35,8 +36,28 @@
336 property var modemsSorted: []
337 property int simsLoaded: 0
338
339+ // waiting during modem reboots or for modems to come online
340+ property bool waiting: true
341+
342+ QtObject {
343+ id: priv
344+ property string prevOnlineModem: ""
345+ }
346+
347 states: [
348 State {
349+ name: "waiting"
350+ when: waiting
351+ PropertyChanges {
352+ target: waitIndicator
353+ opacity: 1
354+ }
355+ PropertyChanges {
356+ target: flick
357+ opacity: 0
358+ }
359+ },
360+ State {
361 name: "noSim"
362 when: (simsLoaded === 0) || (Sims.getPresentCount() === 0)
363 StateChangeScript {
364@@ -47,7 +68,8 @@
365 name: "singleSim"
366 StateChangeScript {
367 script: loader.setSource("Components/SingleSim.qml", {
368- sim: Sims.getFirstPresent()
369+ sim: Sims.getFirstPresent(),
370+ prevOnlineModem: priv.prevOnlineModem
371 })
372 }
373 when: simsLoaded && (Sims.getPresentCount() === 1)
374@@ -57,7 +79,8 @@
375 StateChangeScript {
376 script: loader.setSource("Components/MultiSim.qml", {
377 sims: Sims.getAll(),
378- modems: modemsSorted
379+ modems: modemsSorted,
380+ prevOnlineModem: priv.prevOnlineModem
381 })
382 }
383 when: simsLoaded && (Sims.getPresentCount() > 1)
384@@ -69,6 +92,7 @@
385 onModemsChanged: {
386 root.modemsSorted = modems.slice(0).sort();
387 Sims.createQML();
388+ root.waiting = false;
389 }
390 }
391
392@@ -85,12 +109,30 @@
393 }
394 }
395
396+ Item {
397+ id: waitIndicator
398+ anchors.fill: parent
399+ opacity: 0
400+
401+ ActivityIndicator {
402+ anchors.centerIn: parent
403+ running: true
404+ }
405+
406+ Behavior on opacity {
407+ PropertyAnimation {
408+ duration: UbuntuAnimation.SleepyDuration
409+ }
410+ }
411+ }
412+
413 Flickable {
414 id: flick
415 anchors.fill: parent
416 contentWidth: parent.width
417 contentHeight: contentItem.childrenRect.height
418 boundsBehavior: (contentHeight > root.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds
419+
420 Column {
421 anchors { left: parent.left; right: parent.right }
422 Loader {
423@@ -98,5 +140,37 @@
424 anchors { left: parent.left; right: parent.right }
425 }
426 }
427+
428+ Behavior on opacity {
429+ PropertyAnimation {
430+ duration: UbuntuAnimation.SleepyDuration
431+ }
432+ }
433+
434+ Connections {
435+ target: loader.item
436+
437+ onUmtsModemChanged: {
438+ var path = sim.path;
439+ var e = sim.simMng.presenceChanged;
440+
441+ function presenceHandler (ispresent) {
442+ if (ispresent) {
443+ root.waiting = false;
444+ Connectivity.unlockAllModems();
445+ e.disconnect(presenceHandler);
446+ }
447+ }
448+
449+ priv.prevOnlineModem = prevOnlineModem ?
450+ prevOnlineModem : "";
451+ root.waiting = true;
452+
453+ /* When the SIM comes back online, set waiting to false:
454+ the modem reboot is done.*/
455+ sim.simMng.presenceChanged.connect(presenceHandler);
456+ }
457+ ignoreUnknownSignals: true
458+ }
459 }
460 }
461
462=== added file 'plugins/cellular/connectivity.cpp'
463--- plugins/cellular/connectivity.cpp 1970-01-01 00:00:00 +0000
464+++ plugins/cellular/connectivity.cpp 2015-02-09 12:52:48 +0000
465@@ -0,0 +1,49 @@
466+/*
467+ * Copyright (C) 2014 Canonical, Ltd.
468+ *
469+ * Authors:
470+ * Jonas G. Drange <jonas.drange@canonical.com>
471+ *
472+ * This program is free software: you can redistribute it and/or modify it
473+ * under the terms of the GNU General Public License version 3, as published
474+ * by the Free Software Foundation.
475+ *
476+ * This library is distributed in the hope that it will be useful, but WITHOUT
477+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
478+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
479+ * details.
480+ *
481+ * You should have received a copy of the GNU General Public License
482+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
483+ */
484+
485+#include <QDBusReply>
486+#include <QtDebug>
487+#include <QDBusInterface>
488+#include "connectivity.h"
489+
490+namespace {
491+ const QString conn_service("com.ubuntu.connectivity1");
492+ const QString conn_object("/com/ubuntu/connectivity1/Private");
493+ const QString conn_interface("com.ubuntu.connectivity1.Private");
494+ const QString conn_unlockall_method("UnlockAllModems");
495+}
496+
497+Connectivity::Connectivity(QObject *parent) : QObject(parent)
498+{
499+}
500+
501+void Connectivity::unlockAllModems() {
502+
503+ QDBusInterface connectivityIface (
504+ conn_service,
505+ conn_object,
506+ conn_interface,
507+ QDBusConnection::sessionBus(),
508+ this);
509+
510+ auto reply = connectivityIface.call(conn_unlockall_method);
511+ if (reply.type() == QDBusMessage::ErrorMessage) {
512+ qWarning() << "Failed to unlock modems" << reply.errorMessage();
513+ }
514+}
515
516=== added file 'plugins/cellular/connectivity.h'
517--- plugins/cellular/connectivity.h 1970-01-01 00:00:00 +0000
518+++ plugins/cellular/connectivity.h 2015-02-09 12:52:48 +0000
519@@ -0,0 +1,35 @@
520+/*
521+ * Copyright (C) 2014 Canonical, Ltd.
522+ *
523+ * Authors:
524+ * Jonas G. Drange <jonas.drange@canonical.com>
525+ *
526+ * This program is free software: you can redistribute it and/or modify it
527+ * under the terms of the GNU General Public License version 3, as published
528+ * by the Free Software Foundation.
529+ *
530+ * This library is distributed in the hope that it will be useful, but WITHOUT
531+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
532+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
533+ * details.
534+ *
535+ * You should have received a copy of the GNU General Public License
536+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
537+ */
538+
539+#ifndef CELLULAR_CONNECTIVITY_HELPER
540+#define CELLULAR_CONNECTIVITY_HELPER
541+
542+#include <QObject>
543+
544+class Connectivity : public QObject {
545+ Q_OBJECT
546+
547+public:
548+ explicit Connectivity(QObject *parent = nullptr);
549+ ~Connectivity() {};
550+
551+ Q_INVOKABLE void unlockAllModems();
552+};
553+
554+#endif
555
556=== modified file 'plugins/cellular/plugin.cpp'
557--- plugins/cellular/plugin.cpp 2014-08-29 14:32:28 +0000
558+++ plugins/cellular/plugin.cpp 2015-02-09 12:52:48 +0000
559@@ -19,12 +19,23 @@
560
561 #include <QtQml>
562 #include <QtQml/QQmlContext>
563+#include "connectivity.h"
564 #include "hotspotmanager.h"
565 #include "ofonoactivator.h"
566
567+static QObject *connectivitySingeltonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
568+{
569+ Q_UNUSED(engine)
570+ Q_UNUSED(scriptEngine)
571+
572+ Connectivity *connectivity = new Connectivity();
573+ return connectivity;
574+}
575+
576 void BackendPlugin::registerTypes(const char *uri)
577 {
578 Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.Cellular"));
579+ qmlRegisterSingletonType<Connectivity>(uri, 1, 0, "Connectivity", connectivitySingeltonProvider);
580 qmlRegisterType<HotspotManager>(uri, 1, 0, "HotspotManager");
581 qmlRegisterType<OfonoActivator>(uri, 1, 0, "OfonoActivator");
582 }

Subscribers

People subscribed via source and target branches