chiark / gitweb /
core: expose a "Slice" property on Unit objects on the bus
authorLennart Poettering <lennart@poettering.net>
Mon, 17 Jun 2013 23:00:13 +0000 (01:00 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 17 Jun 2013 23:00:13 +0000 (01:00 +0200)
src/core/dbus-unit.c
src/core/dbus-unit.h

index 575f8eb36ad2edd16af848e4a1c8ab85bdad3295..b7391b5506d2945eed08e3ae1315d63311e15271 100644 (file)
@@ -81,6 +81,25 @@ static int bus_unit_append_following(DBusMessageIter *i, const char *property, v
         return 0;
 }
 
+static int bus_unit_append_slice(DBusMessageIter *i, const char *property, void *data) {
+        Unit *u = data;
+        const char *d;
+
+        assert(i);
+        assert(property);
+        assert(u);
+
+        if (UNIT_DEREF(u->slice))
+                d = UNIT_DEREF(u->slice)->id;
+        else
+                d = "";
+
+        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &d))
+                return -ENOMEM;
+
+        return 0;
+}
+
 static int bus_unit_append_dependencies(DBusMessageIter *i, const char *property, void *data) {
         Unit *u;
         Iterator j;
@@ -1255,6 +1274,7 @@ const BusProperty bus_unit_properties[] = {
         { "Id",                   bus_property_append_string,         "s", offsetof(Unit, id),                                         true },
         { "Names",                bus_unit_append_names,             "as", 0 },
         { "Following",            bus_unit_append_following,          "s", 0 },
+        { "Slice",                bus_unit_append_slice,              "s", 0 },
         { "Requires",             bus_unit_append_dependencies,      "as", offsetof(Unit, dependencies[UNIT_REQUIRES]),                true },
         { "RequiresOverridable",  bus_unit_append_dependencies,      "as", offsetof(Unit, dependencies[UNIT_REQUIRES_OVERRIDABLE]),    true },
         { "Requisite",            bus_unit_append_dependencies,      "as", offsetof(Unit, dependencies[UNIT_REQUISITE]),               true },
index acd1ddbe78db78b4fb9ee59532ce084ee7cff9d6..83932c5a6c14b0c3a0e2d31371dfa0869ed35ce8 100644 (file)
@@ -64,6 +64,7 @@
         "  <property name=\"Id\" type=\"s\" access=\"read\"/>\n"        \
         "  <property name=\"Names\" type=\"as\" access=\"read\"/>\n"    \
         "  <property name=\"Following\" type=\"s\" access=\"read\"/>\n" \
+        "  <property name=\"Slice\" type=\"s\" access=\"read\"/>\n"     \
         "  <property name=\"Requires\" type=\"as\" access=\"read\"/>\n" \
         "  <property name=\"RequiresOverridable\" type=\"as\" access=\"read\"/>\n" \
         "  <property name=\"Requisite\" type=\"as\" access=\"read\"/>\n" \