@@ -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