summaryrefslogtreecommitdiff
path: root/dbus-manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-02-05 00:38:41 +0100
committerLennart Poettering <lennart@poettering.net>2010-02-05 00:38:41 +0100
commitc1e1601e8c6cace85b19a0eebe50076e5d119688 (patch)
tree26fe0f48cbcdbfeb21abfef75c1de3ee37e9598e /dbus-manager.c
parentab8ea24411df95861c53aeee1dd91e765331f717 (diff)
dbus: send out signals when units/jobs come, go and change
Diffstat (limited to 'dbus-manager.c')
-rw-r--r--dbus-manager.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/dbus-manager.c b/dbus-manager.c
index bdc82df070..732e586e92 100644
--- a/dbus-manager.c
+++ b/dbus-manager.c
@@ -47,6 +47,24 @@
" <method name=\"ListJobs\">" \
" <arg name=\"jobs\" type=\"a(usssoo)\" direction=\"out\"/>" \
" </method>" \
+ " <method name=\"Subscribe\"/>" \
+ " <method name=\"Unsubscribe\"/>" \
+ " <signal name=\"UnitNew\">" \
+ " <arg name=\"id\" type=\"s\"/>" \
+ " <arg name=\"unit\" type=\"o\"/>" \
+ " </signal>" \
+ " <signal name=\"UnitRemoved\">" \
+ " <arg name=\"id\" type=\"s\"/>" \
+ " <arg name=\"unit\" type=\"o\"/>" \
+ " </signal>" \
+ " <signal name=\"JobNew\">" \
+ " <arg name=\"id\" type=\"u\"/>" \
+ " <arg name=\"job\" type=\"o\"/>" \
+ " </signal>" \
+ " <signal name=\"JobRemoved\">" \
+ " <arg name=\"id\" type=\"u\"/>" \
+ " <arg name=\"job\" type=\"o\"/>" \
+ " </signal>" \
" </interface>" \
BUS_PROPERTIES_INTERFACE \
BUS_INTROSPECTABLE_INTERFACE
@@ -287,6 +305,31 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
if (!dbus_message_iter_close_container(&iter, &sub))
goto oom;
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "Subscribe")) {
+ char *client;
+
+ if (!(client = strdup(dbus_message_get_sender(message))))
+ goto oom;
+
+ r = set_put(m->subscribed, client);
+
+ if (r < 0)
+ return bus_send_error_reply(m, message, NULL, r);
+
+ if (!(reply = dbus_message_new_method_return(message)))
+ goto oom;
+
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "Unsubscribe")) {
+ char *client;
+
+ if (!(client = set_remove(m->subscribed, (char*) dbus_message_get_sender(message))))
+ return bus_send_error_reply(m, message, NULL, -ENOENT);
+
+ free(client);
+
+ if (!(reply = dbus_message_new_method_return(message)))
+ goto oom;
+
} else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
char *introspection = NULL;
FILE *f;