summaryrefslogtreecommitdiff
path: root/src/dbus-timer.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-07-04 04:37:03 +0200
committerLennart Poettering <lennart@poettering.net>2010-07-04 04:37:03 +0200
commit707e5e52804a8f041f0d2f822f0bcf7062ad24ac (patch)
tree41513704c8e77e5116f20e802254b409fe87cd27 /src/dbus-timer.c
parente87d1818cdf26b8d946776a2182e4ef2847bc0aa (diff)
dbus: complete coverage of timer units
Diffstat (limited to 'src/dbus-timer.c')
-rw-r--r--src/dbus-timer.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/dbus-timer.c b/src/dbus-timer.c
index 68bd8a4489..af0ae72f4f 100644
--- a/src/dbus-timer.c
+++ b/src/dbus-timer.c
@@ -27,8 +27,9 @@
#define BUS_TIMER_INTERFACE \
" <interface name=\"org.freedesktop.systemd1.Timer\">\n" \
- " <property name=\"Unit\" type=\"s\" access=\"read\"/>\n" \
- " </interface>\n" \
+ " <property name=\"Unit\" type=\"s\" access=\"read\"/>\n" \
+ " <property name=\"Timers\" type=\"a(stt)\" access=\"read\"/>\n" \
+ " </interface>\n"
#define INTROSPECTION \
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
@@ -41,10 +42,41 @@
const char bus_timer_interface[] = BUS_TIMER_INTERFACE;
+static int bus_timer_append_timers(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+ Timer *p = data;
+ DBusMessageIter sub, sub2;
+ TimerValue *k;
+
+ assert(m);
+ assert(i);
+ assert(property);
+ assert(p);
+
+ if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "(stt)", &sub))
+ return -ENOMEM;
+
+ LIST_FOREACH(value, k, p->values) {
+ const char *t = timer_base_to_string(k->base);
+
+ if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) ||
+ !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &t) ||
+ !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &k->value) ||
+ !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_UINT64, &k->next_elapse) ||
+ !dbus_message_iter_close_container(&sub, &sub2))
+ return -ENOMEM;
+ }
+
+ if (!dbus_message_iter_close_container(i, &sub))
+ return -ENOMEM;
+
+ return 0;
+}
+
DBusHandlerResult bus_timer_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
- { "org.freedesktop.systemd1.Timer", "Unit", bus_property_append_string, "s", &u->timer.unit->meta.id },
+ { "org.freedesktop.systemd1.Timer", "Unit", bus_property_append_string, "s", u->timer.unit->meta.id },
+ { "org.freedesktop.systemd1.Timer", "Timers", bus_timer_append_timers, "a(stt)", u },
{ NULL, NULL, NULL, NULL, NULL }
};