on xenial help sign in
Upstart signals to control indicator services.
e54fd97Ted Gould
debian/control+3
@@ -10,6 +10,8 @@ Build-Depends: cmake,
10 libgles2-mesa-dev[armhf],
10 libgles2-mesa-dev[armhf],
11 libhud-client2-dev,
11 libhud-client2-dev,
12 libjson-perl,
12 libjson-perl,
13+ libnih-dbus-dev,
14+ libnih-dev,
13 libnm-glib-dev,
15 libnm-glib-dev,
14 libnm-util-dev,
16 libnm-util-dev,
15 libpulse-dev,
17 libpulse-dev,
@@ -19,6 +21,7 @@ Build-Depends: cmake,
19 libunity-core-6.0-dev (<< 7.80),
21 libunity-core-6.0-dev (<< 7.80),
20 libunity-dev (>= 7.0.3),
22 libunity-dev (>= 7.0.3),
21 libunity-scopes-json-def-phone,
23 libunity-scopes-json-def-phone,
24+ libupstart-dev,
22 libusermetricsoutput1-dev,
25 libusermetricsoutput1-dev,
23 libxcb1-dev,
26 libxcb1-dev,
24 pkg-config,
27 pkg-config,
plugins/Unity/Indicators/CMakeLists.txt+4
@@ -4,6 +4,8 @@ include(Plugins)
4project(IndicatorsQml)
4project(IndicatorsQml)
5
5
6pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
6pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
7+pkg_check_modules(LIBUPSTART REQUIRED libupstart libnih libnih-dbus dbus-1)
8+
7find_package(Qt5Core REQUIRED)
9find_package(Qt5Core REQUIRED)
8find_package(Qt5Quick REQUIRED)
10find_package(Qt5Quick REQUIRED)
9
11
@@ -15,6 +17,7 @@ include_directories(
15 ${CMAKE_CURRENT_SOURCE_DIR}
17 ${CMAKE_CURRENT_SOURCE_DIR}
16 ${CMAKE_CURRENT_BINARY_DIR}
18 ${CMAKE_CURRENT_BINARY_DIR}
17 ${QMENUMODEL_INCLUDE_DIRS}
19 ${QMENUMODEL_INCLUDE_DIRS}
20+ ${LIBUPSTART_INCLUDE_DIRS}
18)
21)
19
22
20set(IndicatorsQML_SOURCES
23set(IndicatorsQML_SOURCES
@@ -44,6 +47,7 @@ add_library(IndicatorsQml SHARED
44
47
45target_link_libraries(IndicatorsQml
48target_link_libraries(IndicatorsQml
46 ${QMENUMODEL_LDFLAGS}
49 ${QMENUMODEL_LDFLAGS}
50+ ${LIBUPSTART_LIBRARIES}
47)
51)
48
52
49qt5_use_modules(IndicatorsQml Core Qml Quick)
53qt5_use_modules(IndicatorsQml Core Qml Quick)
plugins/Unity/Indicators/indicatorsmanager.cpp+40−1
@@ -21,6 +21,9 @@
21#include <QSettings>
21#include <QSettings>
22#include <QDebug>
22#include <QDebug>
23
23
24+#include <upstart.h>
25+#include <nih/alloc.h>
26+
24#include "paths.h"
27#include "paths.h"
25
28
26
29
@@ -31,7 +34,8 @@ public:
31 : m_name(name)
34 : m_name(name)
32 , m_fileInfo(fileInfo)
35 , m_fileInfo(fileInfo)
33 , m_verified (true)
36 , m_verified (true)
34− {}
37+ {
38+ }
35
39
36 QString m_name;
40 QString m_name;
37 QFileInfo m_fileInfo;
41 QFileInfo m_fileInfo;
@@ -43,12 +47,34 @@ public:
43IndicatorsManager::IndicatorsManager(QObject* parent)
47IndicatorsManager::IndicatorsManager(QObject* parent)
44 : QObject(parent)
48 : QObject(parent)
45 , m_loaded(false)
49 , m_loaded(false)
50+ , m_upstart(NULL)
46{
51{
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+ }
47}
68}
48
69
49IndicatorsManager::~IndicatorsManager()
70IndicatorsManager::~IndicatorsManager()
50{
71{
51 unload();
72 unload();
73+
74+ if (m_upstart != NULL) {
75+ nih_unref(m_upstart, NULL);
76+ m_upstart = NULL;
77+ }
52}
78}
53
79
54void IndicatorsManager::load()
80void IndicatorsManager::load()
@@ -208,6 +234,19 @@ void IndicatorsManager::setLoaded(bool loaded)
208 {
234 {
209 m_loaded = loaded;
235 m_loaded = loaded;
210 Q_EMIT loadedChanged(m_loaded);
236 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+ }
211 }
250 }
212}
251}
213
252
plugins/Unity/Indicators/indicatorsmanager.h+3
@@ -28,6 +28,8 @@
28#include <QHash>
28#include <QHash>
29#include <QSharedPointer>
29#include <QSharedPointer>
30
30
31+typedef struct nih_dbus_proxy NihDBusProxy;
32+
31class UNITYINDICATORS_EXPORT IndicatorsManager : public QObject
33class UNITYINDICATORS_EXPORT IndicatorsManager : public QObject
32{
34{
33 Q_OBJECT
35 Q_OBJECT
@@ -69,6 +71,7 @@ private:
69 QHash<QString, IndicatorData*> m_indicatorsData;
71 QHash<QString, IndicatorData*> m_indicatorsData;
70 QSharedPointer<QFileSystemWatcher> m_fsWatcher;
72 QSharedPointer<QFileSystemWatcher> m_fsWatcher;
71 bool m_loaded;
73 bool m_loaded;
74+ NihDBusProxy * m_upstart;
72};
75};
73
76
74#endif // INDICATORS_MANAGER_H
77#endif // INDICATORS_MANAGER_H