on xenial help sign in
Upstart signals to control indicator services.

Approved by Nick Dedekind, PS Jenkins bot.

commite54fd973382177bf686e4e70dc2ef2151e90e5e8 authorTed Gould <ted@gould.cx> dateWed 14 Aug 2013, 10:14 (13 years ago) parentf69018115d463a
4 files changed+50−1
debian/control+3 plugins/Unity/Indicators/CMakeLists.txt+4 plugins/Unity/Indicators/indicatorsmanager.cpp+40−1 plugins/Unity/Indicators/indicatorsmanager.h+3
debian/control+3
@@ -10,6 +10,8 @@ Build-Depends: cmake,
1010 libgles2-mesa-dev[armhf],
1111 libhud-client2-dev,
1212 libjson-perl,
13+ libnih-dbus-dev,
14+ libnih-dev,
1315 libnm-glib-dev,
1416 libnm-util-dev,
1517 libpulse-dev,
@@ -19,6 +21,7 @@ Build-Depends: cmake,
1921 libunity-core-6.0-dev (<< 7.80),
2022 libunity-dev (>= 7.0.3),
2123 libunity-scopes-json-def-phone,
24+ libupstart-dev,
2225 libusermetricsoutput1-dev,
2326 libxcb1-dev,
2427 pkg-config,
plugins/Unity/Indicators/CMakeLists.txt+4
@@ -4,6 +4,8 @@ include(Plugins)
44project(IndicatorsQml)
55
66pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
7+pkg_check_modules(LIBUPSTART REQUIRED libupstart libnih libnih-dbus dbus-1)
8+
79find_package(Qt5Core REQUIRED)
810find_package(Qt5Quick REQUIRED)
911
@@ -15,6 +17,7 @@ include_directories(
1517 ${CMAKE_CURRENT_SOURCE_DIR}
1618 ${CMAKE_CURRENT_BINARY_DIR}
1719 ${QMENUMODEL_INCLUDE_DIRS}
20+ ${LIBUPSTART_INCLUDE_DIRS}
1821)
1922
2023set(IndicatorsQML_SOURCES
@@ -44,6 +47,7 @@ add_library(IndicatorsQml SHARED
4447
4548target_link_libraries(IndicatorsQml
4649 ${QMENUMODEL_LDFLAGS}
50+ ${LIBUPSTART_LIBRARIES}
4751)
4852
4953qt5_use_modules(IndicatorsQml Core Qml Quick)
plugins/Unity/Indicators/indicatorsmanager.cpp+40−1
@@ -21,6 +21,9 @@
2121#include <QSettings>
2222#include <QDebug>
2323
24+#include <upstart.h>
25+#include <nih/alloc.h>
26+
2427#include "paths.h"
2528
2629
@@ -31,7 +34,8 @@ public:
3134 : m_name(name)
3235 , m_fileInfo(fileInfo)
3336 , m_verified (true)
34− {}
37+ {
38+ }
3539
3640 QString m_name;
3741 QFileInfo m_fileInfo;
@@ -43,12 +47,34 @@ public:
4347IndicatorsManager::IndicatorsManager(QObject* parent)
4448 : QObject(parent)
4549 , m_loaded(false)
50+ , m_upstart(NULL)
4651{
52+ auto upstartsession = qgetenv("UPSTART_SESSION");
53+ if (!upstartsession.isNull()) {
54+ DBusConnection * conn = NULL;
55+ conn = dbus_connection_open(upstartsession.constData(), NULL);
56+ if (conn != NULL) {
57+ m_upstart = nih_dbus_proxy_new(NULL, conn,
58+ NULL,
59+ DBUS_PATH_UPSTART,
60+ NULL, NULL);
61+ dbus_connection_unref(conn);
62+ }
63+ }
64+
65+ if (m_upstart != NULL) {
66+ m_upstart->auto_start = FALSE;
67+ }
4768}
4869
4970IndicatorsManager::~IndicatorsManager()
5071{
5172 unload();
73+
74+ if (m_upstart != NULL) {
75+ nih_unref(m_upstart, NULL);
76+ m_upstart = NULL;
77+ }
5278}
5379
5480void IndicatorsManager::load()
@@ -208,6 +234,19 @@ void IndicatorsManager::setLoaded(bool loaded)
208234 {
209235 m_loaded = loaded;
210236 Q_EMIT loadedChanged(m_loaded);
237+
238+ if (m_upstart != NULL) {
239+ int event_sent = 0;
240+ if (m_loaded) {
241+ event_sent = upstart_emit_event_sync(NULL, m_upstart, "indicator-services-start", NULL, 0);
242+ } else {
243+ event_sent = upstart_emit_event_sync(NULL, m_upstart, "indicator-services-end", NULL, 0);
244+ }
245+
246+ if (event_sent != 0) {
247+ qWarning() << "Unable to send indicator event to Upstart";
248+ }
249+ }
211250 }
212251}
213252
plugins/Unity/Indicators/indicatorsmanager.h+3
@@ -28,6 +28,8 @@
2828#include <QHash>
2929#include <QSharedPointer>
3030
31+typedef struct nih_dbus_proxy NihDBusProxy;
32+
3133class UNITYINDICATORS_EXPORT IndicatorsManager : public QObject
3234{
3335 Q_OBJECT
@@ -69,6 +71,7 @@ private:
6971 QHash<QString, IndicatorData*> m_indicatorsData;
7072 QSharedPointer<QFileSystemWatcher> m_fsWatcher;
7173 bool m_loaded;
74+ NihDBusProxy * m_upstart;
7275};
7376
7477#endif // INDICATORS_MANAGER_H