summaryrefslogtreecommitdiff
path: root/dbus-manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-04-10 17:40:18 +0200
committerLennart Poettering <lennart@poettering.net>2010-04-10 18:00:28 +0200
commit1adf1049dc9def8d8df405bab7f5ae08e1e9573d (patch)
tree82fefcd7def06b90b607e43742fe6645463783a9 /dbus-manager.c
parentb9f49ee478fdc06c45092f208f1dddd23680ab13 (diff)
dbus: add a couple of properties to the dbus manager interface
Diffstat (limited to 'dbus-manager.c')
-rw-r--r--dbus-manager.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/dbus-manager.c b/dbus-manager.c
index 2323260dbb..a8661bace3 100644
--- a/dbus-manager.c
+++ b/dbus-manager.c
@@ -66,6 +66,11 @@
" <arg name=\"id\" type=\"u\"/>" \
" <arg name=\"job\" type=\"o\"/>" \
" </signal>" \
+ " <property name=\"Version\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"RunningAs\" type=\"s\" access=\"read\"/>" \
+ " <property name=\"BootTimestamp\" type=\"t\" access=\"read\"/>" \
+ " <property name=\"LogLevel\" type=\"s\" access=\"readwrite\"/>" \
+ " <property name=\"LogTarget\" type=\"s\" access=\"readwrite\"/>" \
" </interface>" \
BUS_PROPERTIES_INTERFACE \
BUS_INTROSPECTABLE_INTERFACE
@@ -73,9 +78,51 @@
#define INTROSPECTION_END \
"</node>"
+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;
@@ -422,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);