on xenial help sign in
Move upstart launching to wrapper script
commit37dc525f11909b60398c35d2bf091b7f89f4f3a5 authorMichael Terry <michael.terry@canonical.com> dateWed 19 Mar 2014, 15:04 (13 years ago) parent7ada6f1
7 files changed+82−92
data/unity8-greeter-wrapper+11−2 plugins/LightDM/CMakeLists.txt+1−1 plugins/LightDM/URLDispatcher.cpp+61 plugins/LightDM/Upstart.h → plugins/LightDM/URLDispatcher.h+4−4 plugins/LightDM/Upstart.cpp−80 plugins/LightDM/plugin.cpp+4−4 qml/GreeterShell.qml+1−1
data/unity8-greeter-wrapper+11−2
@@ -28,8 +28,17 @@ cleanup()
2828 exit 0
2929}
3030
31−rm -f $XDG_RUNTIME_DIR/mir_socket # clear socket in case we were hard shut down
32−exec $@ &
31+SUB_SOCKET=$XDG_RUNTIME_DIR/mir_socket
32+rm -f $SUB_SOCKET # clear socket in case we were hard shut down
33+
34+# Normal unity8 sessions are entirely driven by Upstart. But greeters
35+# are special. They need access to the file descriptors that lightdm
36+# creates for them and don't want to start all the services that a normal
37+# session would. So it's inconvenient to live within an upstart session.
38+# But... we still want to use Upstart for some services. So launch here.
39+MIR_SOCKET=$SUB_SOCKET /sbin/init --user --startup-event=unity8-greeter-started &
40+
41+exec $@ --file=$SUB_SOCKET &
3342CMD_PID=$!
3443wait $CMD_PID
3544CMD_PID=
plugins/LightDM/CMakeLists.txt+1−1
@@ -19,7 +19,7 @@ set(QMLPLUGIN_SRC
1919 DBusGreeterList.cpp
2020 Greeter.cpp
2121 plugin.cpp
22− Upstart.cpp
22+ URLDispatcher.cpp
2323 UsersModel.cpp
2424 )
2525
plugins/LightDM/URLDispatcher.cppnew file+61
@@ -0,0 +1,61 @@
1+/*
2+ * Copyright (C) 2013 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 "URLDispatcher.h"
18+
19+#include <QDBusConnection>
20+#include <QProcess>
21+#include <unistd.h>
22+
23+class URLDispatcherInterface : public QObject
24+{
25+ Q_OBJECT
26+ Q_CLASSINFO("D-Bus Interface", "com.canonical.URLDispatcher")
27+
28+public:
29+ explicit URLDispatcherInterface(URLDispatcher *parent);
30+
31+ Q_SCRIPTABLE void DispatchURL(const QString &url);
32+
33+private:
34+ URLDispatcher *m_parent;
35+};
36+
37+URLDispatcherInterface::URLDispatcherInterface(URLDispatcher *parent)
38+ : QObject(parent),
39+ m_parent(parent)
40+{
41+}
42+
43+void URLDispatcherInterface::DispatchURL(const QString &url)
44+{
45+ Q_EMIT m_parent->dispatchURL(url);
46+}
47+
48+URLDispatcher::URLDispatcher(QObject *parent)
49+ : QObject(parent)
50+{
51+ // This class also manages our url-dispatcher interception. We intercept
52+ // url-dispatcher because rather than spawning the handler for the URL in
53+ // our own session, we want to do notify the user session to do it for us
54+ // (and start an unlock in the process).
55+ QDBusConnection connection = QDBusConnection::sessionBus();
56+ URLDispatcherInterface *dispatcher = new URLDispatcherInterface(this);
57+ connection.registerObject("/com/canonical/URLDispatcher", dispatcher, QDBusConnection::ExportScriptableContents);
58+ connection.registerService("com.canonical.URLDispatcher");
59+}
60+
61+#include "URLDispatcher.moc"
plugins/LightDM/Upstart.h → plugins/LightDM/URLDispatcher.hrenamed+4−4
@@ -14,18 +14,18 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−#ifndef UNITY_UPSTART_H
18−#define UNITY_UPSTART_H
17+#ifndef UNITY_URLDISPATCHER_H
18+#define UNITY_URLDISPATCHER_H
1919
2020#include <QObject>
2121#include <QString>
2222
23−class Upstart : public QObject
23+class URLDispatcher : public QObject
2424{
2525 Q_OBJECT
2626
2727public:
28− explicit Upstart(QObject *parent=0);
28+ explicit URLDispatcher(QObject *parent=0);
2929
3030Q_SIGNALS:
3131 void dispatchURL(const QString &url);
plugins/LightDM/Upstart.cppdeleted−80
@@ -1,80 +0,0 @@
1−/*
2− * Copyright (C) 2013 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 "Upstart.h"
18−
19−#include <QDBusConnection>
20−#include <QProcess>
21−#include <unistd.h>
22−
23−class URLDispatcher : public QObject
24−{
25− Q_OBJECT
26− Q_CLASSINFO("D-Bus Interface", "com.canonical.URLDispatcher")
27−
28−public:
29− explicit URLDispatcher(Upstart *parent);
30−
31− Q_SCRIPTABLE void DispatchURL(const QString &url);
32−
33−private:
34− Upstart *m_parent;
35−};
36−
37−URLDispatcher::URLDispatcher(Upstart *parent)
38− : QObject(parent),
39− m_parent(parent)
40−{
41−}
42−
43−void URLDispatcher::DispatchURL(const QString &url)
44−{
45− Q_EMIT m_parent->dispatchURL(url);
46−}
47−
48−// Normal unity8 sessions are entirely driven by Upstart. But greeters
49−// are special. They need access to the file descriptors that lightdm
50−// creates for them and don't want to start all the services that a normal
51−// session would. So it's inconvenient to live within an upstart session.
52−// But... we still want to use Upstart for some services. So rather than being
53−// spawned *by* Upstart like unity8 is, we spawn *it* instead.
54−Upstart::Upstart(QObject *parent)
55− : QObject(parent)
56−{
57− // This class also manages our url-dispatcher interception, as it's sort of
58− // a service provided by Upstart normally. We intercept url-dispatcher
59− // because rather than spawning the handler for the URL in our own session,
60− // we want to do notify the user session to do it for us (and start an
61− // unlock in the process).
62− QDBusConnection connection = QDBusConnection::sessionBus();
63− URLDispatcher *dispatcher = new URLDispatcher(this);
64− connection.registerObject("/com/canonical/URLDispatcher", dispatcher, QDBusConnection::ExportScriptableContents);
65− connection.registerService("com.canonical.URLDispatcher");
66−
67− // Start upstart (unless it's already running, like if the user is testing
68− // locally on their desktop)
69− if (QString(qgetenv("UPSTART_SESSION")).isEmpty())
70− {
71− QProcess *upstart = new QProcess(this);
72− QString command = "/sbin/init --user --startup-event=unity8-greeter-started";
73− // in main.cpp, we convert client to server. Convert back here.
74− if (qgetenv("QT_QPA_PLATFORM") == "ubuntumirserver")
75− command.prepend("/usr/bin/env QT_QPA_PLATFORM=ubuntumirclient ");
76− upstart->start(command);
77− }
78−}
79−
80−#include "Upstart.moc"
plugins/LightDM/plugin.cpp+4−4
@@ -20,7 +20,7 @@
2020#include "plugin.h"
2121#include "DBusGreeterList.h"
2222#include "Greeter.h"
23−#include "Upstart.h"
23+#include "URLDispatcher.h"
2424#include "UsersModel.h"
2525#include <libusermetricsoutput/ColorTheme.h>
2626#include <libusermetricsoutput/UserMetrics.h>
@@ -47,11 +47,11 @@ static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
4747 return greeter;
4848}
4949
50−static QObject *upstart_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
50+static QObject *dispatcher_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
5151{
5252 Q_UNUSED(engine)
5353 Q_UNUSED(scriptEngine)
54− return new Upstart();
54+ return new URLDispatcher();
5555}
5656
5757static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
@@ -75,7 +75,7 @@ void LightDMPlugin::registerTypes(const char *uri)
7575
7676 Q_ASSERT(uri == QLatin1String("LightDM"));
7777 qmlRegisterSingletonType<Greeter>(uri, 0, 1, "Greeter", greeter_provider);
78− qmlRegisterSingletonType<Upstart>(uri, 0, 1, "Upstart", upstart_provider);
78+ qmlRegisterSingletonType<URLDispatcher>(uri, 0, 1, "URLDispatcher", dispatcher_provider);
7979 qmlRegisterSingletonType<UsersModel>(uri, 0, 1, "Users", users_provider);
8080 qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable");
8181 qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider);
qml/GreeterShell.qml+1−1
@@ -255,7 +255,7 @@ BasicShell {
255255 }
256256
257257 Connections {
258− target: LightDM.Upstart
258+ target: LightDM.URLDispatcher
259259 onDispatchURL: shell.activateApplication(url)
260260 }
261261