on xenial help sign in
Merge from sim-unlock-on-boot
commit9e784f8f92fd8d0055c6635105e9ba86f3d1fc03 authorMichael Terry <michael.terry@canonical.com> dateThu 21 Aug 2014, 10:46 (12 years ago) parent98f62c795fc898
19 files changed+353
plugins/Ubuntu/CMakeLists.txt+1 plugins/Ubuntu/Connectivity/CMakeLists.txt+10 plugins/Ubuntu/Connectivity/Connectivity.cpp+33 plugins/Ubuntu/Connectivity/Connectivity.h+33 plugins/Ubuntu/Connectivity/Connectivity.qmltypes+17 plugins/Ubuntu/Connectivity/plugin.cpp+34 plugins/Ubuntu/Connectivity/plugin.h+31 plugins/Ubuntu/Connectivity/qmldir+3 qml/Notifications/NotificationMenuItemFactory.qml+5 qml/Shell.qml+5 tests/mocks/Ubuntu/CMakeLists.txt+1 tests/mocks/Ubuntu/Connectivity/CMakeLists.txt+10 tests/mocks/Ubuntu/Connectivity/Connectivity.qmltypes+18 tests/mocks/Ubuntu/Connectivity/MockConnectivity.cpp+27 tests/mocks/Ubuntu/Connectivity/MockConnectivity.h+36 tests/mocks/Ubuntu/Connectivity/plugin.cpp+34 tests/mocks/Ubuntu/Connectivity/plugin.h+31 tests/mocks/Ubuntu/Connectivity/qmldir+3 tests/qmltests/tst_Shell.qml+21
plugins/Ubuntu/CMakeLists.txt+1
@@ -1,3 +1,4 @@
1+add_subdirectory(Connectivity)
12add_subdirectory(Gestures)
23add_subdirectory(DownloadDaemonListener)
34add_subdirectory(Payments)
plugins/Ubuntu/Connectivity/CMakeLists.txtnew file+10
@@ -0,0 +1,10 @@
1+set(CONNECTIVITY_SOURCES
2+ plugin.cpp
3+ Connectivity.cpp
4+)
5+
6+add_library(Connectivity MODULE ${CONNECTIVITY_SOURCES})
7+
8+qt5_use_modules(Connectivity Qml DBus Core)
9+
10+add_unity8_plugin(Ubuntu.Connectivity 0.1 Ubuntu/Connectivity TARGETS Connectivity)
plugins/Ubuntu/Connectivity/Connectivity.cppnew file+33
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "Connectivity.h"
18+#include <QDBusConnection>
19+#include <QDBusInterface>
20+#include <QDBusPendingCall>
21+
22+Connectivity::Connectivity(QObject *parent)
23+ : QObject(parent)
24+{
25+}
26+
27+void Connectivity::unlockAllModems()
28+{
29+ QDBusInterface iface("com.ubuntu.connectivity1",
30+ "/com/ubuntu/connectivity1/Private",
31+ "com.ubuntu.connectivity1.Private");
32+ iface.asyncCall("UnlockAllModems");
33+}
plugins/Ubuntu/Connectivity/Connectivity.hnew file+33
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef CONNECTIVITY_H
18+#define CONNECTIVITY_H
19+
20+#include <QObject>
21+
22+class Connectivity : public QObject
23+{
24+ Q_OBJECT
25+ Q_DISABLE_COPY(Connectivity)
26+
27+public:
28+ explicit Connectivity(QObject *parent = 0);
29+
30+ Q_INVOKABLE void unlockAllModems();
31+};
32+
33+#endif // CONNECTIVITY_H
plugins/Ubuntu/Connectivity/Connectivity.qmltypesnew file+17
@@ -0,0 +1,17 @@
1+import QtQuick.tooling 1.1
2+
3+// This file describes the plugin-supplied types contained in the library.
4+// It is used for QML tooling purposes only.
5+//
6+// This file was auto-generated by:
7+// 'qmlplugindump -notrelocatable Ubuntu.Connectivity 0.1 plugins'
8+
9+Module {
10+ Component {
11+ name: "Connectivity"
12+ prototype: "QObject"
13+ exports: ["Ubuntu.Connectivity/Connectivity 0.1"]
14+ exportMetaObjectRevisions: [0]
15+ Method { name: "unlockAllModems" }
16+ }
17+}
plugins/Ubuntu/Connectivity/plugin.cppnew file+34
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "plugin.h"
18+#include "Connectivity.h"
19+
20+#include <QtQml>
21+
22+static QObject *service_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
23+{
24+ Q_UNUSED(engine)
25+ Q_UNUSED(scriptEngine)
26+ return new Connectivity();
27+}
28+
29+void BackendPlugin::registerTypes(const char *uri)
30+{
31+ Q_ASSERT(uri == QLatin1String("Ubuntu.Connectivity"));
32+
33+ qmlRegisterSingletonType<Connectivity>(uri, 0, 1, "Connectivity", service_provider);
34+}
plugins/Ubuntu/Connectivity/plugin.hnew file+31
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef CONNECTIVITY_PLUGIN_H
18+#define CONNECTIVITY_PLUGIN_H
19+
20+#include <QQmlExtensionPlugin>
21+
22+class BackendPlugin : public QQmlExtensionPlugin
23+{
24+ Q_OBJECT
25+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26+
27+public:
28+ void registerTypes(const char *uri);
29+};
30+
31+#endif // CONNECTIVITY_PLUGIN_H
plugins/Ubuntu/Connectivity/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module Ubuntu.Connectivity
2+plugin Connectivity
3+typeinfo Connectivity.qmltypes
qml/Notifications/NotificationMenuItemFactory.qml+5
@@ -127,6 +127,11 @@ Loader {
127127 onCancel: {
128128 menuModel.activate(menuIndex, false);
129129 }
130+
131+ onEmergencyCall: {
132+ shell.activateApplication("dialer-app")
133+ menuModel.activate(menuIndex, false)
134+ }
130135 }
131136 }
132137}
qml/Shell.qml+5
@@ -20,6 +20,7 @@ import GSettings 1.0
2020import Unity.Application 0.1
2121import Ubuntu.Components 0.1
2222import Ubuntu.Components.Popups 1.0
23+import Ubuntu.Connectivity 0.1
2324import Ubuntu.Gestures 0.1
2425import Ubuntu.SystemImage 0.1
2526import Unity.Launcher 0.1
@@ -416,6 +417,10 @@ Item {
416417 }
417418 }
418419
420+ Component.onCompleted: {
421+ Connectivity.unlockAllModems()
422+ }
423+
419424 onUnlocked: greeter.hide()
420425 onSelected: {
421426 // Update launcher items for new user
tests/mocks/Ubuntu/CMakeLists.txt+1
@@ -1,3 +1,4 @@
1+add_subdirectory(Connectivity)
12add_subdirectory(DownloadDaemonListener)
23add_subdirectory(Payments)
34add_subdirectory(SystemImage)
tests/mocks/Ubuntu/Connectivity/CMakeLists.txtnew file+10
@@ -0,0 +1,10 @@
1+set(MOCK_CONNECTIVITY_SOURCES
2+ plugin.cpp
3+ MockConnectivity.cpp
4+)
5+
6+add_library(MockConnectivity MODULE ${MOCK_CONNECTIVITY_SOURCES})
7+
8+qt5_use_modules(MockConnectivity Qml Quick Core)
9+
10+add_unity8_mock(Ubuntu.Connectivity 0.1 Ubuntu/Connectivity TARGETS MockConnectivity)
tests/mocks/Ubuntu/Connectivity/Connectivity.qmltypesnew file+18
@@ -0,0 +1,18 @@
1+import QtQuick.tooling 1.1
2+
3+// This file describes the plugin-supplied types contained in the library.
4+// It is used for QML tooling purposes only.
5+//
6+// This file was auto-generated by:
7+// 'qmlplugindump -notrelocatable Ubuntu.Connectivity 0.1 plugins'
8+
9+Module {
10+ Component {
11+ name: "MockConnectivity"
12+ prototype: "QObject"
13+ exports: ["Ubuntu.Connectivity/Connectivity 0.1"]
14+ exportMetaObjectRevisions: [0]
15+ Signal { name: "unlockingAllModems" }
16+ Method { name: "unlockAllModems" }
17+ }
18+}
tests/mocks/Ubuntu/Connectivity/MockConnectivity.cppnew file+27
@@ -0,0 +1,27 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "MockConnectivity.h"
18+
19+MockConnectivity::MockConnectivity(QObject *parent)
20+ : QObject(parent)
21+{
22+}
23+
24+void MockConnectivity::unlockAllModems()
25+{
26+ Q_EMIT unlockingAllModems();
27+}
tests/mocks/Ubuntu/Connectivity/MockConnectivity.hnew file+36
@@ -0,0 +1,36 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef MOCK_CONNECTIVITY_H
18+#define MOCK_CONNECTIVITY_H
19+
20+#include <QObject>
21+
22+class MockConnectivity : public QObject
23+{
24+ Q_OBJECT
25+ Q_DISABLE_COPY(MockConnectivity)
26+
27+public:
28+ explicit MockConnectivity(QObject *parent = 0);
29+
30+ Q_INVOKABLE void unlockAllModems();
31+
32+Q_SIGNALS:
33+ void unlockingAllModems(); // only for mock
34+};
35+
36+#endif // MOCK_CONNECTIVITY_H
tests/mocks/Ubuntu/Connectivity/plugin.cppnew file+34
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "plugin.h"
18+#include "MockConnectivity.h"
19+
20+#include <QtQml>
21+
22+static QObject *service_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
23+{
24+ Q_UNUSED(engine)
25+ Q_UNUSED(scriptEngine)
26+ return new MockConnectivity();
27+}
28+
29+void BackendPlugin::registerTypes(const char *uri)
30+{
31+ Q_ASSERT(uri == QLatin1String("Ubuntu.Connectivity"));
32+
33+ qmlRegisterSingletonType<MockConnectivity>(uri, 0, 1, "Connectivity", service_provider);
34+}
tests/mocks/Ubuntu/Connectivity/plugin.hnew file+31
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef MOCK_CONNECTIVITY_PLUGIN_H
18+#define MOCK_CONNECTIVITY_PLUGIN_H
19+
20+#include <QQmlExtensionPlugin>
21+
22+class BackendPlugin : public QQmlExtensionPlugin
23+{
24+ Q_OBJECT
25+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26+
27+public:
28+ void registerTypes(const char *uri);
29+};
30+
31+#endif // MOCK_CONNECTIVITY_PLUGIN_H
tests/mocks/Ubuntu/Connectivity/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module Ubuntu.Connectivity
2+plugin MockConnectivity
3+typeinfo Connectivity.qmltypes
tests/qmltests/tst_Shell.qml+21
@@ -21,6 +21,7 @@ import QtQuick 2.0
2121import QtTest 1.0
2222import GSettings 1.0
2323import LightDM 0.1 as LightDM
24+import Ubuntu.Connectivity 0.1
2425import Unity.Application 0.1
2526import Unity.Test 0.1 as UT
2627import Powerd 0.1
@@ -28,6 +29,7 @@ import Powerd 0.1
2829import "../../qml"
2930
3031Item {
32+ id: root
3133 width: shell.width
3234 height: shell.height
3335
@@ -51,6 +53,11 @@ Item {
5153 id: shell
5254 }
5355
56+ Component {
57+ id: shellComponent
58+ Shell {}
59+ }
60+
5461 SignalSpy {
5562 id: sessionSpy
5663 signalName: "sessionStarted"
@@ -61,6 +68,12 @@ Item {
6168 signalName: "setCurrentScopeCalled"
6269 }
6370
71+ SignalSpy {
72+ id: unlockAllModemsSpy
73+ target: Connectivity
74+ signalName: "unlockingAllModems"
75+ }
76+
6477 UT.UnityTestCase {
6578 name: "Shell"
6679 when: windowShown
@@ -442,5 +455,13 @@ Item {
442455 var indicators = findChild(shell, "indicators")
443456 tryCompare(indicators, "available", true)
444457 }
458+
459+ function test_unlockAllModemsOnBoot() {
460+ unlockAllModemsSpy.clear()
461+ // actually create an object so we notice the onCompleted signal
462+ var greeter = shellComponent.createObject(root)
463+ tryCompare(unlockAllModemsSpy, "count", 1)
464+ greeter.destroy()
465+ }
445466 }
446467}