X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dbus-manager.c;h=a8661bace3332def5359bc410182e93afe07aa74;hb=5cc5d790f4593bbf7829faba502e4c00b3718a08;hp=732e586e9292c01dec4be5a61dcad975e149cebd;hpb=c1e1601e8c6cace85b19a0eebe50076e5d119688;p=elogind.git
diff --git a/dbus-manager.c b/dbus-manager.c
index 732e586e9..a8661bace 100644
--- a/dbus-manager.c
+++ b/dbus-manager.c
@@ -38,7 +38,7 @@
" " \
" " \
" " \
- " " \
+ " " \
" " \
" " \
" " \
@@ -49,6 +49,7 @@
" " \
" " \
" " \
+ " " \
" " \
" " \
" " \
@@ -65,6 +66,11 @@
" " \
" " \
" " \
+ " " \
+ " " \
+ " " \
+ " " \
+ " " \
" " \
BUS_PROPERTIES_INTERFACE \
BUS_INTROSPECTABLE_INTERFACE
@@ -72,9 +78,51 @@
#define INTROSPECTION_END \
""
+DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_manager_append_running_as, manager_running_as, ManagerRunningAs);
+
+static int bus_manager_append_log_target(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+ const char *t;
+
+ assert(m);
+ assert(i);
+ assert(property);
+
+ t = log_target_to_string(log_get_target());
+
+ if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t))
+ return -ENOMEM;
+
+ return 0;
+}
+
+static int bus_manager_append_log_level(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+ const char *t;
+
+ assert(m);
+ assert(i);
+ assert(property);
+
+ t = log_level_to_string(log_get_max_level());
+
+ if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t))
+ return -ENOMEM;
+
+ return 0;
+}
+
static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
- int r;
Manager *m = data;
+
+ const BusProperty properties[] = {
+ { "org.freedesktop.systemd1", "Version", bus_property_append_string, "s", PACKAGE_VERSION },
+ { "org.freedesktop.systemd1", "RunningAs", bus_manager_append_running_as, "s", &m->running_as },
+ { "org.freedesktop.systemd1", "BootTimestamp", bus_property_append_uint64, "t", &m->boot_timestamp },
+ { "org.freedesktop.systemd1", "LogLevel", bus_manager_append_log_level, "s", NULL },
+ { "org.freedesktop.systemd1", "LogTarget", bus_manager_append_log_target, "s", NULL },
+ { NULL, NULL, NULL, NULL, NULL }
+ };
+
+ int r;
DBusError error;
DBusMessage *reply = NULL;
char * path = NULL;
@@ -142,7 +190,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
DBUS_TYPE_INVALID))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "GetJob")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "GetJob")) {
uint32_t id;
Job *j;
@@ -168,14 +216,14 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
DBUS_TYPE_INVALID))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "ClearJobs")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "ClearJobs")) {
manager_clear_jobs(m);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "ListUnits")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "ListUnits")) {
DBusMessageIter iter, sub;
Iterator i;
Unit *u;
@@ -249,7 +297,7 @@ 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", "ListJobs")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "ListJobs")) {
DBusMessageIter iter, sub;
Iterator i;
Job *j;
@@ -305,7 +353,7 @@ 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")) {
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "Subscribe")) {
char *client;
if (!(client = strdup(dbus_message_get_sender(message))))
@@ -319,7 +367,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
- } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "Unsubscribe")) {
+ } 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))))
@@ -330,6 +378,35 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
+ } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "Dump")) {
+ FILE *f;
+ char *dump = NULL;
+ size_t size;
+
+ if (!(reply = dbus_message_new_method_return(message)))
+ goto oom;
+
+ if (!(f = open_memstream(&dump, &size)))
+ goto oom;
+
+ manager_dump_units(m, f, NULL);
+ manager_dump_jobs(m, f, NULL);
+
+ if (ferror(f)) {
+ fclose(f);
+ free(dump);
+ goto oom;
+ }
+
+ fclose(f);
+
+ if (!dbus_message_append_args(reply, DBUS_TYPE_STRING, &dump, DBUS_TYPE_INVALID)) {
+ free(dump);
+ goto oom;
+ }
+
+ free(dump);
+
} else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
char *introspection = NULL;
FILE *f;
@@ -392,7 +469,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
free(introspection);
} else
- return bus_default_message_handler(m, message, NULL, NULL);
+ return bus_default_message_handler(m, message, NULL, properties);
free(path);