chiark / gitweb /
unit: remove union Unit
[elogind.git] / src / dbus-snapshot.c
index 8aeca15..0967034 100644 (file)
@@ -1,4 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
 /***
   This file is part of systemd.
 
 #include "dbus-unit.h"
 #include "dbus-snapshot.h"
-
-static const char introspection[] =
-        DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
-        "<node>"
-        BUS_UNIT_INTERFACE
-        BUS_PROPERTIES_INTERFACE
-        " <interface name=\"org.freedesktop.systemd1.Snapshot\">"
-        "  <method name=\"Remove\"/>"
-        "  <property name=\"Cleanup\" type=\"b\" access=\"read\"/>"
-        " </interface>"
-        BUS_INTROSPECTABLE_INTERFACE
-        "</node>";
-
-DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message) {
+#include "dbus-common.h"
+
+#define BUS_SNAPSHOT_INTERFACE                                          \
+        " <interface name=\"org.freedesktop.systemd1.Snapshot\">\n"     \
+        "  <method name=\"Remove\"/>\n"                                 \
+        "  <property name=\"Cleanup\" type=\"b\" access=\"read\"/>\n"   \
+        " </interface>\n"
+
+#define INTROSPECTION                                                   \
+        DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE                       \
+        "<node>\n"                                                      \
+        BUS_UNIT_INTERFACE                                              \
+        BUS_SNAPSHOT_INTERFACE                                          \
+        BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
+        BUS_INTROSPECTABLE_INTERFACE                                    \
+        "</node>\n"
+
+#define INTERFACES_LIST                              \
+        BUS_UNIT_INTERFACES_LIST                     \
+        "org.freedesktop.systemd1.Snapshot\0"
+
+const char bus_snapshot_interface[] _introspect_("Snapshot") = BUS_SNAPSHOT_INTERFACE;
+
+DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
+        Snapshot *s = SNAPSHOT(u);
         const BusProperty properties[] = {
                 BUS_UNIT_PROPERTIES,
-                { "org.freedesktop.systemd1.Snapshot", "Cleanup", bus_property_append_bool, "b", &u->snapshot.cleanup },
+                { "org.freedesktop.systemd1.Snapshot", "Cleanup", bus_property_append_bool, "b", &s->cleanup },
                 { NULL, NULL, NULL, NULL, NULL }
         };
 
@@ -54,10 +66,10 @@ DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message) {
                         goto oom;
 
         } else
-                return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+                return bus_default_message_handler(c, message, INTROSPECTION, INTERFACES_LIST, properties);
 
         if (reply) {
-                if (!dbus_connection_send(u->meta.manager->api_bus, reply, NULL))
+                if (!dbus_connection_send(c, reply, NULL))
                         goto oom;
 
                 dbus_message_unref(reply);