]> err.no Git - systemd/commitdiff
dbus: greatly extend dbus coverage
authorLennart Poettering <lennart@poettering.net>
Sun, 18 Apr 2010 01:08:16 +0000 (03:08 +0200)
committerLennart Poettering <lennart@poettering.net>
Sun, 18 Apr 2010 01:08:16 +0000 (03:08 +0200)
36 files changed:
Makefile.am
automount.c
dbus-automount.c [new file with mode: 0644]
dbus-automount.h [new file with mode: 0644]
dbus-device.c [new file with mode: 0644]
dbus-device.h [new file with mode: 0644]
dbus-execute.c [new file with mode: 0644]
dbus-execute.h [new file with mode: 0644]
dbus-job.c
dbus-job.h [new file with mode: 0644]
dbus-manager.c
dbus-manager.h [new file with mode: 0644]
dbus-mount.c [new file with mode: 0644]
dbus-mount.h [new file with mode: 0644]
dbus-service.c [new file with mode: 0644]
dbus-service.h [new file with mode: 0644]
dbus-snapshot.c [new file with mode: 0644]
dbus-snapshot.h [new file with mode: 0644]
dbus-socket.c [new file with mode: 0644]
dbus-socket.h [new file with mode: 0644]
dbus-target.c [new file with mode: 0644]
dbus-target.h [new file with mode: 0644]
dbus-unit.c
dbus-unit.h [new file with mode: 0644]
dbus.c
dbus.h
device.c
job.c
manager.c
mount.c
service.c
socket.c
systemd-interfaces.vala
target.c
unit.c
unit.h

index 8cad1420e0f239ef17b328c808d11b558aafc70f..8720e7898fae37f85bd078b2f59666e61c6180aa 100644 (file)
@@ -128,6 +128,22 @@ COMMON_SOURCES= \
         dbus-unit.h \
         dbus-job.c \
         dbus-job.h \
+       dbus-service.c \
+       dbus-service.h \
+       dbus-socket.c \
+       dbus-socket.h \
+       dbus-target.c \
+       dbus-target.h \
+       dbus-mount.c \
+       dbus-mount.h \
+       dbus-automount.c \
+       dbus-autpmount.h \
+       dbus-snapshot.c \
+       dbus-snapshot.h \
+       dbus-device.c \
+       dbus-device.h \
+       dbus-execute.c \
+       dbus-execute.h \
        cgroup.c \
        cgroup.h \
        mount-setup.c \
index 5d79131afcbcd814ee4eb0951c59e6dca0272640..fa5fd52552afc9af95ee63a1301bfa9f024ce70f 100644 (file)
@@ -34,6 +34,7 @@
 #include "load-fragment.h"
 #include "load-dropin.h"
 #include "unit-name.h"
+#include "dbus-automount.h"
 
 static const UnitActiveState state_translation_table[_AUTOMOUNT_STATE_MAX] = {
         [AUTOMOUNT_DEAD] = UNIT_INACTIVE,
@@ -602,5 +603,7 @@ const UnitVTable automount_vtable = {
 
         .fd_event = automount_fd_event,
 
+        .bus_message_handler = bus_automount_message_handler,
+
         .shutdown = automount_shutdown
 };
diff --git a/dbus-automount.c b/dbus-automount.c
new file mode 100644 (file)
index 0000000..9003b74
--- /dev/null
@@ -0,0 +1,44 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-automount.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.Automount\">"
+        "  <property name=\"Where\" type=\"s\" access=\"read\"/>"
+        " </interface>"
+        BUS_INTROSPECTABLE_INTERFACE
+        "</node>";
+
+DBusHandlerResult bus_automount_message_handler(Unit *u, DBusMessage *message) {
+        const BusProperty properties[] = {
+                BUS_UNIT_PROPERTIES,
+                { "org.freedesktop.systemd1.Automount", "Where", bus_property_append_string, "s", u->automount.where },
+                { NULL, NULL, NULL, NULL, NULL }
+        };
+
+        return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
diff --git a/dbus-automount.h b/dbus-automount.h
new file mode 100644 (file)
index 0000000..947bf0f
--- /dev/null
@@ -0,0 +1,31 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusautomounthfoo
+#define foodbusautomounthfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_automount_message_handler(Unit *u, DBusMessage *message);
+
+#endif
diff --git a/dbus-device.c b/dbus-device.c
new file mode 100644 (file)
index 0000000..8376478
--- /dev/null
@@ -0,0 +1,44 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-device.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.Device\">"
+        "  <property name=\"SysFSPath\" type=\"s\" access=\"read\"/>"
+        " </interface>"
+        BUS_INTROSPECTABLE_INTERFACE
+        "</node>";
+
+DBusHandlerResult bus_device_message_handler(Unit *u, DBusMessage *message) {
+        const BusProperty properties[] = {
+                BUS_UNIT_PROPERTIES,
+                { "org.freedesktop.systemd1.Device", "SysFSPath", bus_property_append_string, "s", u->device.sysfs },
+                { NULL, NULL, NULL, NULL, NULL }
+        };
+
+        return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
diff --git a/dbus-device.h b/dbus-device.h
new file mode 100644 (file)
index 0000000..f2850a6
--- /dev/null
@@ -0,0 +1,31 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusdevicehfoo
+#define foodbusdevicehfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_device_message_handler(Unit *u, DBusMessage *message);
+
+#endif
diff --git a/dbus-execute.c b/dbus-execute.c
new file mode 100644 (file)
index 0000000..8840396
--- /dev/null
@@ -0,0 +1,28 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <errno.h>
+#include <dbus/dbus.h>
+
+#include "dbus-execute.h"
+
+DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_input, exec_input, ExecInput);
+DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_execute_append_output, exec_output, ExecOutput);
diff --git a/dbus-execute.h b/dbus-execute.h
new file mode 100644 (file)
index 0000000..25ecd98
--- /dev/null
@@ -0,0 +1,79 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusexecutehfoo
+#define foodbusexecutehfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "manager.h"
+
+#define BUS_EXEC_CONTEXT_INTERFACE                                      \
+        "  <property name=\"Environment\" type=\"as\" access=\"read\"/>" \
+        "  <property name=\"UMask\" type=\"u\" access=\"read\"/>"       \
+        "  <property name=\"WorkingDirectory\" type=\"s\" access=\"read\"/>" \
+        "  <property name=\"RootDirectory\" type=\"s\" access=\"read\"/>" \
+        "  <property name=\"CPUSchedulingResetOnFork\" type=\"b\" access=\"read\"/>" \
+        "  <property name=\"NonBlocking\" type=\"b\" access=\"read\"/>" \
+        "  <property name=\"StandardInput\" type=\"s\" access=\"read\"/>" \
+        "  <property name=\"StandardOutput\" type=\"s\" access=\"read\"/>" \
+        "  <property name=\"StandardError\" type=\"s\" access=\"read\"/>" \
+        "  <property name=\"TTYPath\" type=\"s\" access=\"read\"/>"     \
+        "  <property name=\"SyslogPriority\" type=\"i\" access=\"read\"/>" \
+        "  <property name=\"SyslogIdentifier\" type=\"s\" access=\"read\"/>" \
+        "  <property name=\"SecureBits\" type=\"i\" access=\"read\"/>"  \
+        "  <property name=\"CapabilityBoundingSetDrop\" type=\"t\" access=\"read\"/>" \
+        "  <property name=\"User\" type=\"s\" access=\"read\"/>"        \
+        "  <property name=\"Group\" type=\"s\" access=\"read\"/>"       \
+        "  <property name=\"SupplementaryGroups\" type=\"as\" access=\"read\"/>"
+
+#define BUS_EXEC_CONTEXT_PROPERTIES(interface, context)                 \
+        { interface, "Environment",                   bus_property_append_strv,   "as",    (context).environment                   }, \
+        { interface, "UMask",                         bus_property_append_mode,   "u",     &(context).umask                        }, \
+            /* RLimits */                                               \
+        { interface, "WorkingDirectory",              bus_property_append_string, "s",     (context).working_directory             }, \
+        { interface, "RootDirectory",                 bus_property_append_string, "s",     (context).root_directory                }, \
+            /* OOM Adjust */                                            \
+            /* Nice */                                                  \
+            /* IOPrio */                                                \
+            /* CPUSchedPolicy */                                        \
+            /* CPUSchedPriority */                                      \
+            /* CPUAffinity */                                           \
+            /* TimerSlackNS */                                          \
+        { interface, "CPUSchedulingResetOnFork",      bus_property_append_bool,   "b",     &(context).cpu_sched_reset_on_fork      }, \
+        { interface, "NonBlocking",                   bus_property_append_bool,   "b",     &(context).non_blocking                 }, \
+        { interface, "StandardInput",                 bus_execute_append_input,   "s",     &(context).std_input                    }, \
+        { interface, "StandardOutput",                bus_execute_append_output,  "s",     &(context).std_output                   }, \
+        { interface, "StandardError",                 bus_execute_append_output,  "s",     &(context).std_error                    }, \
+        { interface, "TTYPath",                       bus_property_append_string, "s",     (context).tty_path                      }, \
+        { interface, "SyslogPriority",                bus_property_append_int,    "i",     &(context).syslog_priority              }, \
+        { interface, "SyslogIdentifier",              bus_property_append_string, "s",     (context).syslog_identifier             }, \
+            /* CAPABILITIES */                                          \
+        { interface, "SecureBits",                    bus_property_append_int,    "i",     &(context).secure_bits                  }, \
+        { interface, "CapabilityBoundingSetDrop",     bus_property_append_uint64, "t",     &(context).capability_bounding_set_drop }, \
+        { interface, "User",                          bus_property_append_string, "s",     (context).user                          }, \
+        { interface, "Group",                         bus_property_append_string, "s",     (context).group                         }, \
+        { interface, "SupplementaryGroups",           bus_property_append_strv,   "as",    (context).supplementary_groups          }
+
+int bus_execute_append_output(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_execute_append_input(Manager *m, DBusMessageIter *i, const char *property, void *data);
+
+#endif
index b0f575b11be921b1c183775624ffdd2a0e06bb24..bec5bca93cac8215f1c9af2f5662c14d2bdc6b2e 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "dbus.h"
 #include "log.h"
+#include "dbus-job.h"
 
 static const char introspection[] =
         DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
@@ -39,8 +40,8 @@ static const char introspection[] =
         BUS_INTROSPECTABLE_INTERFACE
         "</node>";
 
-DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_job_append_state, job_state, JobState);
-DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_job_append_type, job_type, JobType);
+static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_job_append_state, job_state, JobState);
+static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_job_append_type, job_type, JobType);
 
 static int bus_job_append_unit(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         Job *j = data;
diff --git a/dbus-job.h b/dbus-job.h
new file mode 100644 (file)
index 0000000..cf91760
--- /dev/null
@@ -0,0 +1,32 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusjobhfoo
+#define foodbusjobhfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+void bus_job_send_change_signal(Job *j);
+void bus_job_send_removed_signal(Job *j);
+
+extern const DBusObjectPathVTable bus_job_vtable;
+
+#endif
index 8deb451795ca8bf847b8da24c1e8e97f2c3a7da8..734ed7b886abdd601ebad55e0d5bb965e04e6144 100644 (file)
 
 #include "dbus.h"
 #include "log.h"
+#include "dbus-manager.h"
 
 #define INTROSPECTION_BEGIN                                             \
         DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE                       \
         "<node>"                                                        \
-        " <interface name=\"org.freedesktop.systemd1\">"                \
+        " <interface name=\"org.freedesktop.systemd1.Manager\">"        \
         "  <method name=\"GetUnit\">"                                   \
         "   <arg name=\"name\" type=\"s\" direction=\"in\"/>"           \
         "   <arg name=\"unit\" type=\"o\" direction=\"out\"/>"          \
         "  <method name=\"Subscribe\"/>"                                \
         "  <method name=\"Unsubscribe\"/>"                              \
         "  <method name=\"Dump\"/>"                                     \
+        "  <method name=\"CreateSnapshot\">"                            \
+        "   <arg name=\"name\" type=\"s\" direction=\"in\"/>"           \
+        "   <arg nane=\"cleanup\" type=\"b\" direction=\"in\"/>"        \
+        "   <arg name=\"unit\" type=\"o\" direction=\"out\"/>"          \
+        "  </method>"                                                   \
         "  <signal name=\"UnitNew\">"                                   \
         "   <arg name=\"id\" type=\"s\"/>"                              \
         "   <arg name=\"unit\" type=\"o\"/>"                            \
@@ -78,7 +84,7 @@
 #define INTROSPECTION_END                                               \
         "</node>"
 
-DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_manager_append_running_as, manager_running_as, ManagerRunningAs);
+static 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;
@@ -114,11 +120,11 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection
         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               },
+                { "org.freedesktop.systemd1.Manager", "Version",       bus_property_append_string,    "s", PACKAGE_STRING     },
+                { "org.freedesktop.systemd1.Manager", "RunningAs",     bus_manager_append_running_as, "s", &m->running_as     },
+                { "org.freedesktop.systemd1.Manager", "BootTimestamp", bus_property_append_uint64,    "t", &m->boot_timestamp },
+                { "org.freedesktop.systemd1.Manager", "LogLevel",      bus_manager_append_log_level,  "s", NULL               },
+                { "org.freedesktop.systemd1.Manager", "LogTarget",     bus_manager_append_log_target, "s", NULL               },
                 { NULL, NULL, NULL, NULL, NULL }
         };
 
@@ -138,7 +144,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection
                   dbus_message_get_member(message),
                   dbus_message_get_path(message));
 
-        if (dbus_message_is_method_call(message, "org.freedesktop.systemd1", "GetUnit")) {
+        if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "GetUnit")) {
                 const char *name;
                 Unit *u;
 
@@ -164,7 +170,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", "LoadUnit")) {
+        } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "LoadUnit")) {
                 const char *name;
                 Unit *u;
 
@@ -216,14 +222,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.Manager", "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.Manager", "ListUnits")) {
                 DBusMessageIter iter, sub;
                 Iterator i;
                 Unit *u;
@@ -298,7 +304,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.Manager", "ListJobs")) {
                 DBusMessageIter iter, sub;
                 Iterator i;
                 Job *j;
@@ -353,7 +359,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.Manager", "Subscribe")) {
                 char *client;
 
                 if (!(client = strdup(dbus_message_get_sender(message))))
@@ -367,7 +373,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.Manager", "Unsubscribe")) {
                 char *client;
 
                 if (!(client = set_remove(m->subscribed, (char*) dbus_message_get_sender(message))))
@@ -378,7 +384,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", "Dump")) {
+        } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Dump")) {
                 FILE *f;
                 char *dump = NULL;
                 size_t size;
@@ -406,6 +412,36 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection  *connection
                 }
 
                 free(dump);
+        } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "CreateSnapshot")) {
+                const char *name;
+                dbus_bool_t cleanup;
+                Snapshot *s;
+
+                if (!dbus_message_get_args(
+                                    message,
+                                    &error,
+                                    DBUS_TYPE_STRING, &name,
+                                    DBUS_TYPE_BOOLEAN, &cleanup,
+                                    DBUS_TYPE_INVALID))
+                        return bus_send_error_reply(m, message, &error, -EINVAL);
+
+                if (name && name[0] == 0)
+                        name = NULL;
+
+                if ((r = snapshot_create(m, name, cleanup, &s)) < 0)
+                        return bus_send_error_reply(m, message, NULL, r);
+
+                if (!(reply = dbus_message_new_method_return(message)))
+                        goto oom;
+
+                if (!(path = unit_dbus_path(UNIT(s))))
+                        goto oom;
+
+                if (!dbus_message_append_args(
+                                    reply,
+                                    DBUS_TYPE_OBJECT_PATH, &path,
+                                    DBUS_TYPE_INVALID))
+                        goto oom;
 
         } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect")) {
                 char *introspection = NULL;
diff --git a/dbus-manager.h b/dbus-manager.h
new file mode 100644 (file)
index 0000000..0acd2d0
--- /dev/null
@@ -0,0 +1,29 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusmanagerhfoo
+#define foodbusmanagerhfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+extern const DBusObjectPathVTable bus_manager_vtable;
+
+#endif
diff --git a/dbus-mount.c b/dbus-mount.c
new file mode 100644 (file)
index 0000000..cbdb300
--- /dev/null
@@ -0,0 +1,55 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-mount.h"
+#include "dbus-execute.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.Mount\">"
+        "  <property name=\"Where\" type=\"s\" access=\"read\"/>"
+        "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>"
+        BUS_EXEC_CONTEXT_INTERFACE
+        "  <property name=\"KillMode\" type=\"s\" access=\"read\"/>"
+        "  <property name=\"ControlPID\" type=\"u\" access=\"read\"/>"
+        " </interface>"
+        BUS_INTROSPECTABLE_INTERFACE
+        "</node>";
+
+DBusHandlerResult bus_mount_message_handler(Unit *u, DBusMessage *message) {
+        const BusProperty properties[] = {
+                BUS_UNIT_PROPERTIES,
+                { "org.freedesktop.systemd1.Mount", "Where",       bus_property_append_string, "s", u->mount.where         },
+                /* Where, Options, fstype */
+                { "org.freedesktop.systemd1.Mount", "TimeoutUSec", bus_property_append_usec,   "t", &u->mount.timeout_usec },
+                /* ExecCommand */
+                BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Mount", u->mount.exec_context),
+                { "org.freedesktop.systemd1.Mount", "KillMode",    bus_unit_append_kill_mode,  "s", &u->mount.kill_mode    },
+                { "org.freedesktop.systemd1.Mount", "ControlPID",  bus_property_append_pid,    "u", &u->mount.control_pid  },
+                { NULL, NULL, NULL, NULL, NULL }
+        };
+
+        return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
diff --git a/dbus-mount.h b/dbus-mount.h
new file mode 100644 (file)
index 0000000..b92867d
--- /dev/null
@@ -0,0 +1,31 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusmounthfoo
+#define foodbusmounthfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_mount_message_handler(Unit *u, DBusMessage *message);
+
+#endif
diff --git a/dbus-service.c b/dbus-service.c
new file mode 100644 (file)
index 0000000..24dd6c1
--- /dev/null
@@ -0,0 +1,78 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <errno.h>
+
+#include "dbus-unit.h"
+#include "dbus-execute.h"
+#include "dbus-service.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.Service\">"
+        "  <property name=\"Type\" type=\"s\" access=\"read\"/>"
+        "  <property name=\"Restart\" type=\"s\" access=\"read\"/>"
+        "  <property name=\"PIDFile\" type=\"s\" access=\"read\"/>"
+        "  <property name=\"RestartUSec\" type=\"t\" access=\"read\"/>"
+        "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>"
+        BUS_EXEC_CONTEXT_INTERFACE
+        "  <property name=\"PermissionsStartOnly\" type=\"b\" access=\"read\"/>"
+        "  <property name=\"RootDirectoryStartOnly\" type=\"b\" access=\"read\"/>"
+        "  <property name=\"ValidNoProcess\" type=\"b\" access=\"read\"/>"
+        "  <property name=\"KillMode\" type=\"s\" access=\"read\"/>"
+        "  <property name=\"MainPID\" type=\"u\" access=\"read\"/>"
+        "  <property name=\"ControlPID\" type=\"u\" access=\"read\"/>"
+        "  <property name=\"SysVPath\" type=\"s\" access=\"read\"/>"
+        "  <property name=\"BusName\" type=\"s\" access=\"read\"/>"
+        " </interface>"
+        BUS_INTROSPECTABLE_INTERFACE
+        "</node>";
+
+static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_type, service_type, ServiceType);
+static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_restart, service_restart, ServiceRestart);
+
+DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message) {
+        const BusProperty properties[] = {
+                BUS_UNIT_PROPERTIES,
+                { "org.freedesktop.systemd1.Service", "Type",                   bus_service_append_type,    "s", &u->service.type },
+                { "org.freedesktop.systemd1.Service", "Restart",                bus_service_append_restart, "s", &u->service.restart },
+                { "org.freedesktop.systemd1.Service", "PIDFile",                bus_property_append_string, "s", u->service.pid_file },
+                { "org.freedesktop.systemd1.Service", "RestartUSec",            bus_property_append_usec,   "t", &u->service.restart_usec },
+                { "org.freedesktop.systemd1.Service", "TimeoutUSec",            bus_property_append_usec,   "t", &u->service.timeout_usec },
+                /* ExecCommand */
+                BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Service", u->service.exec_context),
+                { "org.freedesktop.systemd1.Service", "PermissionsStartOnly",   bus_property_append_bool,   "b", &u->service.permissions_start_only },
+                { "org.freedesktop.systemd1.Service", "RootDirectoryStartOnly", bus_property_append_bool,   "b", &u->service.root_directory_start_only },
+                { "org.freedesktop.systemd1.Service", "ValidNoProcess",         bus_property_append_bool,   "b", &u->service.valid_no_process },
+                { "org.freedesktop.systemd1.Service", "KillMode",               bus_unit_append_kill_mode,  "s", &u->service.kill_mode },
+                /* MainExecStatus */
+                { "org.freedesktop.systemd1.Service", "MainPID",                bus_property_append_pid,    "u", &u->service.main_pid },
+                { "org.freedesktop.systemd1.Service", "ControlPID",             bus_property_append_pid,    "u", &u->service.control_pid },
+                { "org.freedesktop.systemd1.Service", "SysVPath",               bus_property_append_string, "s", u->service.sysv_path },
+                { "org.freedesktop.systemd1.Service", "BusName",                bus_property_append_string, "s", u->service.bus_name },
+                { NULL, NULL, NULL, NULL, NULL }
+        };
+
+        return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
diff --git a/dbus-service.h b/dbus-service.h
new file mode 100644 (file)
index 0000000..f0a468e
--- /dev/null
@@ -0,0 +1,31 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusservicehfoo
+#define foodbusservicehfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message);
+
+#endif
diff --git a/dbus-snapshot.c b/dbus-snapshot.c
new file mode 100644 (file)
index 0000000..8aeca15
--- /dev/null
@@ -0,0 +1,75 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#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) {
+        const BusProperty properties[] = {
+                BUS_UNIT_PROPERTIES,
+                { "org.freedesktop.systemd1.Snapshot", "Cleanup", bus_property_append_bool, "b", &u->snapshot.cleanup },
+                { NULL, NULL, NULL, NULL, NULL }
+        };
+
+        DBusMessage *reply = NULL;
+        DBusError error;
+
+        dbus_error_init(&error);
+
+        if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Snapshot", "Remove")) {
+
+                snapshot_remove(SNAPSHOT(u));
+
+                if (!(reply = dbus_message_new_method_return(message)))
+                        goto oom;
+
+        } else
+                return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+
+        if (reply) {
+                if (!dbus_connection_send(u->meta.manager->api_bus, reply, NULL))
+                        goto oom;
+
+                dbus_message_unref(reply);
+        }
+
+        return DBUS_HANDLER_RESULT_HANDLED;
+
+oom:
+        if (reply)
+                dbus_message_unref(reply);
+
+        dbus_error_free(&error);
+
+        return DBUS_HANDLER_RESULT_NEED_MEMORY;
+}
diff --git a/dbus-snapshot.h b/dbus-snapshot.h
new file mode 100644 (file)
index 0000000..5f28550
--- /dev/null
@@ -0,0 +1,31 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbussnapshothfoo
+#define foodbussnapshothfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message);
+
+#endif
diff --git a/dbus-socket.c b/dbus-socket.c
new file mode 100644 (file)
index 0000000..2a2349c
--- /dev/null
@@ -0,0 +1,64 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-socket.h"
+#include "dbus-execute.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.Socket\">"
+        "  <property name=\"BindIPv6Only\" type=\"b\" access=\"read\"/>"
+        "  <property name=\"Backlog\" type=\"u\" access=\"read\"/>"
+        "  <property name=\"TimeoutUSec\" type=\"t\" access=\"read\"/>"
+        BUS_EXEC_CONTEXT_INTERFACE
+        "  <property name=\"KillMode\" type=\"s\" access=\"read\"/>"
+        "  <property name=\"ControlPID\" type=\"u\" access=\"read\"/>"
+        "  <property name=\"BindToDevice\" type=\"s\" access=\"read\"/>"
+        "  <property name=\"DirectoryMode\" type=\"u\" access=\"read\"/>"
+        "  <property name=\"SocketMode\" type=\"u\" access=\"read\"/>"
+        "  <property name=\"Accept\" type=\"b\" access=\"read\"/>"
+        " </interface>"
+        BUS_INTROSPECTABLE_INTERFACE
+        "</node>";
+
+DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message) {
+        const BusProperty properties[] = {
+                BUS_UNIT_PROPERTIES,
+                { "org.freedesktop.systemd1.Socket", "BindIPv6Only",  bus_property_append_bool,     "b", &u->socket.bind_ipv6_only },
+                { "org.freedesktop.systemd1.Socket", "Backlog",       bus_property_append_unsigned, "u", &u->socket.backlog },
+                { "org.freedesktop.systemd1.Socket", "TimeoutUSec",   bus_property_append_usec,     "t", &u->socket.timeout_usec },
+                /* ExecCommand */
+                BUS_EXEC_CONTEXT_PROPERTIES("org.freedesktop.systemd1.Socket", u->socket.exec_context),
+                { "org.freedesktop.systemd1.Socket", "KillMode",      bus_unit_append_kill_mode,    "s", &u->socket.kill_mode },
+                { "org.freedesktop.systemd1.Socket", "ControlPID",    bus_property_append_pid,      "u", &u->socket.control_pid },
+                { "org.freedesktop.systemd1.Socket", "BindToDevice",  bus_property_append_string,   "s", u->socket.bind_to_device },
+                { "org.freedesktop.systemd1.Socket", "DirectoryMode", bus_property_append_mode,     "u", &u->socket.directory_mode },
+                { "org.freedesktop.systemd1.Socket", "SocketMode",    bus_property_append_mode,     "u", &u->socket.socket_mode },
+                { "org.freedesktop.systemd1.Socket", "Accept",        bus_property_append_bool,     "b", &u->socket.accept },
+                { NULL, NULL, NULL, NULL, NULL }
+        };
+
+        return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
diff --git a/dbus-socket.h b/dbus-socket.h
new file mode 100644 (file)
index 0000000..6a8f534
--- /dev/null
@@ -0,0 +1,31 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbussockethfoo
+#define foodbussockethfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message);
+
+#endif
diff --git a/dbus-target.c b/dbus-target.c
new file mode 100644 (file)
index 0000000..be984b9
--- /dev/null
@@ -0,0 +1,42 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "dbus-unit.h"
+#include "dbus-target.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.Target\">"
+        " </interface>"
+        BUS_INTROSPECTABLE_INTERFACE
+        "</node>";
+
+DBusHandlerResult bus_target_message_handler(Unit *u, DBusMessage *message) {
+        const BusProperty properties[] = {
+                BUS_UNIT_PROPERTIES,
+                { NULL, NULL, NULL, NULL, NULL }
+        };
+
+        return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+}
diff --git a/dbus-target.h b/dbus-target.h
new file mode 100644 (file)
index 0000000..f6a1ac5
--- /dev/null
@@ -0,0 +1,31 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbustargethfoo
+#define foodbustargethfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "unit.h"
+
+DBusHandlerResult bus_target_message_handler(Unit *u, DBusMessage *message);
+
+#endif
index 6bccec14a71fef7eee247b60cf3e81a388fe099d..cbc2812e315ca71ed0ddbb1583fee3e7de1f0972 100644 (file)
 
 #include "dbus.h"
 #include "log.h"
+#include "dbus-unit.h"
 
-static const char introspection[] =
-        DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE
-        "<node>"
-        " <interface name=\"org.freedesktop.systemd1.Unit\">"
-        "  <method name=\"Start\">"
-        "   <arg name=\"mode\" type=\"s\" direction=\"in\"/>"
-        "   <arg name=\"job\" type=\"o\" direction=\"out\"/>"
-        "  </method>"
-        "  <method name=\"Stop\">"
-        "   <arg name=\"mode\" type=\"s\" direction=\"in\"/>"
-        "   <arg name=\"job\" type=\"o\" direction=\"out\"/>"
-        "  </method>"
-        "  <method name=\"Restart\">"
-        "   <arg name=\"mode\" type=\"s\" direction=\"in\"/>"
-        "   <arg name=\"job\" type=\"o\" direction=\"out\"/>"
-        "  </method>"
-        "  <method name=\"Reload\">"
-        "   <arg name=\"mode\" type=\"s\" direction=\"in\"/>"
-        "   <arg name=\"job\" type=\"o\" direction=\"out\"/>"
-        "  </method>"
-        "  <signal name=\"Changed\"/>"
-        "  <property name=\"Id\" type=\"s\" access=\"read\"/>"
-        "  <property name=\"Description\" type=\"s\" access=\"read\"/>"
-        "  <property name=\"LoadState\" type=\"s\" access=\"read\"/>"
-        "  <property name=\"ActiveState\" type=\"s\" access=\"read\"/>"
-        "  <property name=\"SubState\" type=\"s\" access=\"read\"/>"
-        "  <property name=\"FragmentPath\" type=\"s\" access=\"read\"/>"
-        "  <property name=\"ActiveEnterTimestamp\" type=\"t\" access=\"read\"/>"
-        "  <property name=\"ActiveExitTimestamp\" type=\"t\" access=\"read\"/>"
-        "  <property name=\"CanReload\" type=\"b\" access=\"read\"/>"
-        "  <property name=\"CanStart\" type=\"b\" access=\"read\"/>"
-        "  <property name=\"Job\" type=\"(uo)\" access=\"read\"/>"
-        " </interface>"
-        BUS_PROPERTIES_INTERFACE
-        BUS_INTROSPECTABLE_INTERFACE
-        "</node>";
-
-static int bus_unit_append_description(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_names(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+        char *t;
+        Iterator j;
+        DBusMessageIter sub;
+        Unit *u = data;
+
+        if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
+                return -ENOMEM;
+
+        SET_FOREACH(t, u->meta.names, j)
+                if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &t))
+                        return -ENOMEM;
+
+        if (!dbus_message_iter_close_container(i, &sub))
+                return -ENOMEM;
+
+        return 0;
+}
+
+int bus_unit_append_description(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         Unit *u = data;
         const char *d;
 
@@ -80,7 +63,7 @@ static int bus_unit_append_description(Manager *m, DBusMessageIter *i, const cha
 
 DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_unit_append_load_state, unit_load_state, UnitLoadState);
 
-static int bus_unit_append_active_state(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_active_state(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         Unit *u = data;
         const char *state;
 
@@ -97,7 +80,7 @@ static int bus_unit_append_active_state(Manager *m, DBusMessageIter *i, const ch
         return 0;
 }
 
-static int bus_unit_append_sub_state(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_sub_state(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         Unit *u = data;
         const char *state;
 
@@ -114,7 +97,7 @@ static int bus_unit_append_sub_state(Manager *m, DBusMessageIter *i, const char
         return 0;
 }
 
-static int bus_unit_append_can_reload(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_can_start(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         Unit *u = data;
         dbus_bool_t b;
 
@@ -123,7 +106,7 @@ static int bus_unit_append_can_reload(Manager *m, DBusMessageIter *i, const char
         assert(property);
         assert(u);
 
-        b = unit_can_reload(u);
+        b = unit_can_start(u);
 
         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
                 return -ENOMEM;
@@ -131,7 +114,7 @@ static int bus_unit_append_can_reload(Manager *m, DBusMessageIter *i, const char
         return 0;
 }
 
-static int bus_unit_append_can_start(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_can_reload(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         Unit *u = data;
         dbus_bool_t b;
 
@@ -140,7 +123,7 @@ static int bus_unit_append_can_start(Manager *m, DBusMessageIter *i, const char
         assert(property);
         assert(u);
 
-        b = unit_can_start(u);
+        b = unit_can_reload(u);
 
         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
                 return -ENOMEM;
@@ -148,7 +131,7 @@ static int bus_unit_append_can_start(Manager *m, DBusMessageIter *i, const char
         return 0;
 }
 
-static int bus_unit_append_job(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+int bus_unit_append_job(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         Unit *u = data;
         DBusMessageIter sub;
         char *p;
@@ -196,23 +179,62 @@ static int bus_unit_append_job(Manager *m, DBusMessageIter *i, const char *prope
         return 0;
 }
 
-static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message) {
+int bus_unit_append_default_cgroup(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+        Unit *u = data;
+        char *t;
+        CGroupBonding *cgb;
+        bool success;
 
-        const BusProperty properties[] = {
-                { "org.freedesktop.systemd1.Unit", "Id",                   bus_property_append_string,   "s",    u->meta.id                      },
-                { "org.freedesktop.systemd1.Unit", "Description",          bus_unit_append_description,  "s",    u                               },
-                { "org.freedesktop.systemd1.Unit", "LoadState",            bus_unit_append_load_state,   "s",    &u->meta.load_state             },
-                { "org.freedesktop.systemd1.Unit", "ActiveState",          bus_unit_append_active_state, "s",    u                               },
-                { "org.freedesktop.systemd1.Unit", "SubState",             bus_unit_append_sub_state,    "s",    u                               },
-                { "org.freedesktop.systemd1.Unit", "FragmentPath",         bus_property_append_string,   "s",    u->meta.fragment_path           },
-                { "org.freedesktop.systemd1.Unit", "ActiveEnterTimestamp", bus_property_append_uint64,   "t",    &u->meta.active_enter_timestamp },
-                { "org.freedesktop.systemd1.Unit", "ActiveExitTimestamp",  bus_property_append_uint64,   "t",    &u->meta.active_exit_timestamp  },
-                { "org.freedesktop.systemd1.Unit", "CanReload",            bus_unit_append_can_reload,   "b",    u                               },
-                { "org.freedesktop.systemd1.Unit", "CanStart",             bus_unit_append_can_start,    "b",    u                               },
-                { "org.freedesktop.systemd1.Unit", "Job",                  bus_unit_append_job,          "(uo)", u                               },
-                { NULL, NULL, NULL, NULL, NULL }
-        };
+        assert(m);
+        assert(i);
+        assert(property);
+        assert(u);
+
+        if ((cgb = unit_get_default_cgroup(u))) {
+                if (!(t = cgroup_bonding_to_string(cgb)))
+                        return -ENOMEM;
+        } else
+                t = (char*) "";
 
+        success = dbus_message_iter_append_basic(i, DBUS_TYPE_STRING, &t);
+
+        if (cgb)
+                free(t);
+
+        return success ? 0 : -ENOMEM;
+}
+
+int bus_unit_append_cgroups(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+        Unit *u = data;
+        CGroupBonding *cgb;
+        DBusMessageIter sub;
+
+        if (!dbus_message_iter_open_container(i, DBUS_TYPE_ARRAY, "s", &sub))
+                return -ENOMEM;
+
+        LIST_FOREACH(by_unit, cgb, u->meta.cgroup_bondings) {
+                char *t;
+                bool success;
+
+                if (!(t = cgroup_bonding_to_string(cgb)))
+                        return -ENOMEM;
+
+                success = dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &t);
+                free(t);
+
+                if (!success)
+                        return -ENOMEM;
+        }
+
+        if (!dbus_message_iter_close_container(i, &sub))
+                return -ENOMEM;
+
+        return 0;
+}
+
+DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_unit_append_kill_mode, kill_mode, KillMode);
+
+static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message) {
         DBusMessage *reply = NULL;
         Manager *m = u->meta.manager;
         DBusError error;
@@ -228,8 +250,10 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message
                 job_type = JOB_RELOAD;
         else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Restart"))
                 job_type = JOB_RESTART;
+        else if (UNIT_VTABLE(u)->bus_message_handler)
+                return UNIT_VTABLE(u)->bus_message_handler(u, message);
         else
-                return bus_default_message_handler(u->meta.manager, message, introspection, properties);
+                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
         if (job_type != _JOB_TYPE_INVALID) {
                 const char *smode;
diff --git a/dbus-unit.h b/dbus-unit.h
new file mode 100644 (file)
index 0000000..471f64c
--- /dev/null
@@ -0,0 +1,101 @@
+/*-*- Mode: C; c-basic-offset: 8 -*-*/
+
+#ifndef foodbusunithfoo
+#define foodbusunithfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <dbus/dbus.h>
+
+#include "manager.h"
+
+#define BUS_UNIT_INTERFACE \
+        " <interface name=\"org.freedesktop.systemd1.Unit\">"           \
+        "  <method name=\"Start\">"                                     \
+        "   <arg name=\"mode\" type=\"s\" direction=\"in\"/>"           \
+        "   <arg name=\"job\" type=\"o\" direction=\"out\"/>"           \
+        "  </method>"                                                   \
+        "  <method name=\"Stop\">"                                      \
+        "   <arg name=\"mode\" type=\"s\" direction=\"in\"/>"           \
+        "   <arg name=\"job\" type=\"o\" direction=\"out\"/>"           \
+        "  </method>"                                                   \
+        "  <method name=\"Restart\">"                                   \
+        "   <arg name=\"mode\" type=\"s\" direction=\"in\"/>"           \
+        "   <arg name=\"job\" type=\"o\" direction=\"out\"/>"           \
+        "  </method>"                                                   \
+        "  <method name=\"Reload\">"                                    \
+        "   <arg name=\"mode\" type=\"s\" direction=\"in\"/>"           \
+        "   <arg name=\"job\" type=\"o\" direction=\"out\"/>"           \
+        "  </method>"                                                   \
+        "  <signal name=\"Changed\"/>"                                  \
+        "  <property name=\"Id\" type=\"s\" access=\"read\"/>"          \
+        "  <property name=\"Names\" type=\"as\" access=\"read\"/>"      \
+        "  <property name=\"Description\" type=\"s\" access=\"read\"/>" \
+        "  <property name=\"LoadState\" type=\"s\" access=\"read\"/>"   \
+        "  <property name=\"ActiveState\" type=\"s\" access=\"read\"/>" \
+        "  <property name=\"SubState\" type=\"s\" access=\"read\"/>"    \
+        "  <property name=\"FragmentPath\" type=\"s\" access=\"read\"/>" \
+        "  <property name=\"ActiveEnterTimestamp\" type=\"t\" access=\"read\"/>" \
+        "  <property name=\"ActiveExitTimestamp\" type=\"t\" access=\"read\"/>" \
+        "  <property name=\"CanReload\" type=\"b\" access=\"read\"/>"   \
+        "  <property name=\"CanStart\" type=\"b\" access=\"read\"/>"    \
+        "  <property name=\"Job\" type=\"(uo)\" access=\"read\"/>"      \
+        "  <property name=\"RecursiveStop\" type=\"b\" access=\"read\"/>" \
+        "  <property name=\"StopWhenUneeded\" type=\"b\" access=\"read\"/>" \
+        "  <property name=\"DefaultControlGroup\" type=\"s\" access=\"read\"/>" \
+        "  <property name=\"ControlGroups\" type=\"as\" access=\"read\"/>" \
+        " </interface>"
+
+#define BUS_UNIT_PROPERTIES \
+        { "org.freedesktop.systemd1.Unit", "Id",                   bus_property_append_string,     "s",    u->meta.id                      }, \
+        { "org.freedesktop.systemd1.Unit", "Names",                bus_unit_append_names,          "as",   u                               }, \
+        { "org.freedesktop.systemd1.Unit", "Description",          bus_unit_append_description,    "s",    u                               }, \
+        { "org.freedesktop.systemd1.Unit", "LoadState",            bus_unit_append_load_state,     "s",    &u->meta.load_state             }, \
+        { "org.freedesktop.systemd1.Unit", "ActiveState",          bus_unit_append_active_state,   "s",    u                               }, \
+        { "org.freedesktop.systemd1.Unit", "SubState",             bus_unit_append_sub_state,      "s",    u                               }, \
+        { "org.freedesktop.systemd1.Unit", "FragmentPath",         bus_property_append_string,     "s",    u->meta.fragment_path           }, \
+        { "org.freedesktop.systemd1.Unit", "ActiveEnterTimestamp", bus_property_append_uint64,     "t",    &u->meta.active_enter_timestamp }, \
+        { "org.freedesktop.systemd1.Unit", "ActiveExitTimestamp",  bus_property_append_uint64,     "t",    &u->meta.active_exit_timestamp  }, \
+        { "org.freedesktop.systemd1.Unit", "CanStart",             bus_unit_append_can_start,      "b",    u                               }, \
+        { "org.freedesktop.systemd1.Unit", "CanReload",            bus_unit_append_can_reload,     "b",    u                               }, \
+        { "org.freedesktop.systemd1.Unit", "Job",                  bus_unit_append_job,            "(uo)", u                               }, \
+        { "org.freedesktop.systemd1.Unit", "RecursiveStop",        bus_property_append_bool,       "b",    &u->meta.recursive_stop         }, \
+        { "org.freedesktop.systemd1.Unit", "StopWhenUneeded",      bus_property_append_bool,       "b",    &u->meta.stop_when_unneeded     }, \
+        { "org.freedesktop.systemd1.Unit", "DefaultControlGroup",  bus_unit_append_default_cgroup, "s",    u                               }, \
+        { "org.freedesktop.systemd1.Unit", "ControlGroups",        bus_unit_append_cgroups,        "as",   u                               }
+
+int bus_unit_append_names(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_description(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_load_state(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_active_state(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_sub_state(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_can_start(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_can_reload(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_job(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_default_cgroup(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_cgroups(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_unit_append_kill_mode(Manager *m, DBusMessageIter *i, const char *property, void *data);
+
+void bus_unit_send_change_signal(Unit *u);
+void bus_unit_send_removed_signal(Unit *u);
+
+extern const DBusObjectPathVTable bus_unit_vtable;
+
+#endif
diff --git a/dbus.c b/dbus.c
index a1a3606361eb8654efb67ef2ffed09343b1ab6ad..79b1a7ebc39b529c127be37a76cdf5e893e2695c 100644 (file)
--- a/dbus.c
+++ b/dbus.c
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <dbus/dbus.h>
-
 #include <sys/epoll.h>
 #include <sys/timerfd.h>
 #include <errno.h>
 #include <unistd.h>
+#include <dbus/dbus.h>
 
 #include "dbus.h"
 #include "log.h"
 #include "strv.h"
 #include "cgroup.h"
+#include "dbus-unit.h"
+#include "dbus-job.h"
+#include "dbus-manager.h"
 
 static void api_bus_dispatch_status(DBusConnection *bus, DBusDispatchStatus status, void *data)  {
         Manager *m = data;
@@ -1023,6 +1025,10 @@ int bus_property_append_uint64(Manager *m, DBusMessageIter *i, const char *prope
         assert(property);
         assert(data);
 
+        /* Let's ensure that pid_t is actually 64bit, and hence this
+         * function can be used for usec_t */
+        assert_cc(sizeof(uint64_t) == sizeof(usec_t));
+
         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT64, data))
                 return -ENOMEM;
 
@@ -1035,8 +1041,28 @@ int bus_property_append_uint32(Manager *m, DBusMessageIter *i, const char *prope
         assert(property);
         assert(data);
 
+        /* Let's ensure that pid_t and mode_t is actually 32bit, and
+         * hence this function can be used for pid_t/mode_t */
+        assert_cc(sizeof(uint32_t) == sizeof(pid_t));
+        assert_cc(sizeof(uint32_t) == sizeof(mode_t));
+        assert_cc(sizeof(uint32_t) == sizeof(unsigned));
+
         if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT32, data))
                 return -ENOMEM;
 
         return 0;
 }
+
+int bus_property_append_int32(Manager *m, DBusMessageIter *i, const char *property, void *data) {
+        assert(m);
+        assert(i);
+        assert(property);
+        assert(data);
+
+        assert_cc(sizeof(int32_t) == sizeof(int));
+
+        if (!dbus_message_iter_append_basic(i, DBUS_TYPE_INT32, data))
+                return -ENOMEM;
+
+        return 0;
+}
diff --git a/dbus.h b/dbus.h
index 412c6683197150a79ad27f0a64fbb61c53ff04f4..47a6639b43837f2bc457b1cd1c286b0bb8c4a555 100644 (file)
--- a/dbus.h
+++ b/dbus.h
@@ -66,30 +66,27 @@ unsigned bus_dispatch(Manager *m);
 void bus_watch_event(Manager *m, Watch *w, int events);
 void bus_timeout_event(Manager *m, Watch *w, int events);
 
+int bus_query_pid(Manager *m, const char *name);
+
 DBusHandlerResult bus_default_message_handler(Manager *m, DBusMessage *message, const char* introspection, const BusProperty *properties);
 
 DBusHandlerResult bus_send_error_reply(Manager *m, DBusMessage *message, DBusError *bus_error, int error);
 
-int bus_query_pid(Manager *m, const char *name);
-
 int bus_property_append_string(Manager *m, DBusMessageIter *i, const char *property, void *data);
 int bus_property_append_strv(Manager *m, DBusMessageIter *i, const char *property, void *data);
 int bus_property_append_bool(Manager *m, DBusMessageIter *i, const char *property, void *data);
+int bus_property_append_int32(Manager *m, DBusMessageIter *i, const char *property, void *data);
 int bus_property_append_uint32(Manager *m, DBusMessageIter *i, const char *property, void *data);
 int bus_property_append_uint64(Manager *m, DBusMessageIter *i, const char *property, void *data);
 
-extern const DBusObjectPathVTable bus_manager_vtable;
-extern const DBusObjectPathVTable bus_job_vtable;
-extern const DBusObjectPathVTable bus_unit_vtable;
-
-void bus_unit_send_change_signal(Unit *u);
-void bus_unit_send_removed_signal(Unit *u);
-
-void bus_job_send_change_signal(Job *j);
-void bus_job_send_removed_signal(Job *j);
+#define bus_property_append_int bus_property_append_int32
+#define bus_property_append_pid bus_property_append_uint32
+#define bus_property_append_mode bus_property_append_uint32
+#define bus_property_append_unsigned bus_property_append_uint32
+#define bus_property_append_usec bus_property_append_uint64
 
-#define DEFINE_BUS_PROPERTY_APPEND_ENUM(function,name,type)            \
-        static int function(Manager *m, DBusMessageIter *i, const char *property, void *data) { \
+#define DEFINE_BUS_PROPERTY_APPEND_ENUM(function,name,type)             \
+        int function(Manager *m, DBusMessageIter *i, const char *property, void *data) { \
                 const char *value;                                      \
                 type *field = data;                                     \
                                                                         \
index a9b003c66484c4871b7621c2e06e8f2f047f4472..ddd05b35a08ec090c3768bb2acd60e082fc6d158 100644 (file)
--- a/device.c
+++ b/device.c
@@ -28,6 +28,7 @@
 #include "strv.h"
 #include "log.h"
 #include "unit-name.h"
+#include "dbus-device.h"
 
 static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = {
         [DEVICE_DEAD] = UNIT_INACTIVE,
@@ -463,6 +464,8 @@ const UnitVTable device_vtable = {
         .active_state = device_active_state,
         .sub_state_to_string = device_sub_state_to_string,
 
+        .bus_message_handler = bus_device_message_handler,
+
         .enumerate = device_enumerate,
         .shutdown = device_shutdown
 };
diff --git a/job.c b/job.c
index 0e03fcdc77b4a943f9eec90259f75f3e99ea11c8..c1b00714ec995de43c366abb872dc53654ed9a5e 100644 (file)
--- a/job.c
+++ b/job.c
@@ -29,6 +29,7 @@
 #include "load-fragment.h"
 #include "load-dropin.h"
 #include "log.h"
+#include "dbus-job.h"
 
 Job* job_new(Manager *m, JobType type, Unit *unit) {
         Job *j;
index 6f3ff54d6ceaa64307edb54a1bfcacca1836cd70..0187d3b374650cb34550268f514831c77bb35be4 100644 (file)
--- a/manager.c
+++ b/manager.c
@@ -47,6 +47,8 @@
 #include "mount-setup.h"
 #include "utmp-wtmp.h"
 #include "unit-name.h"
+#include "dbus-unit.h"
+#include "dbus-job.h"
 
 static int enable_special_signals(Manager *m) {
         char fd;
diff --git a/mount.c b/mount.c
index cc94ca6f2365cb078275ee9ad323efefbe345c83..d3e222d4bc83be173eb97582af266b1301fe9ae4 100644 (file)
--- a/mount.c
+++ b/mount.c
@@ -33,6 +33,8 @@
 #include "strv.h"
 #include "mount-setup.h"
 #include "unit-name.h"
+#include "mount.h"
+#include "dbus-mount.h"
 
 static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = {
         [MOUNT_DEAD] = UNIT_INACTIVE,
@@ -1357,6 +1359,8 @@ const UnitVTable mount_vtable = {
         .sigchld_event = mount_sigchld_event,
         .timer_event = mount_timer_event,
 
+        .bus_message_handler = bus_mount_message_handler,
+
         .enumerate = mount_enumerate,
         .shutdown = mount_shutdown
 };
index c85c6f572a62b109c11974ad8d20a307a0fd8dac..f334027a7986b094f8bc38f6f01337fcaa410b7b 100644 (file)
--- a/service.c
+++ b/service.c
@@ -31,6 +31,7 @@
 #include "log.h"
 #include "strv.h"
 #include "unit-name.h"
+#include "dbus-service.h"
 
 #define COMMENTS "#;\n"
 #define NEWLINES "\n\r"
@@ -2239,5 +2240,7 @@ const UnitVTable service_vtable = {
         .bus_name_owner_change = service_bus_name_owner_change,
         .bus_query_pid_done = service_bus_query_pid_done,
 
+        .bus_message_handler = bus_service_message_handler,
+
         .enumerate = service_enumerate
 };
index 88fb2d3869e50231a4cfd4a2b6974c091e352688..22658dcb009c3d273c418f35cfa67dcdf76c7c0c 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -35,6 +35,7 @@
 #include "load-fragment.h"
 #include "strv.h"
 #include "unit-name.h"
+#include "dbus-socket.h"
 
 static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = {
         [SOCKET_DEAD] = UNIT_INACTIVE,
@@ -1098,5 +1099,7 @@ const UnitVTable socket_vtable = {
 
         .fd_event = socket_fd_event,
         .sigchld_event = socket_sigchld_event,
-        .timer_event = socket_timer_event
+        .timer_event = socket_timer_event,
+
+        .bus_message_handler = bus_socket_message_handler
 };
index dae0648c6424ae0e1b8122a03ffe670e154a2be6..3b65d3c90b3f2ecd0e352c7e20f444fccfcf6bff 100644 (file)
@@ -19,7 +19,7 @@
 
 using DBus;
 
-[DBus (name = "org.freedesktop.systemd1")]
+[DBus (name = "org.freedesktop.systemd1.Manager")]
 public interface Manager : DBus.Object {
 
         public struct UnitInfo {
@@ -76,12 +76,16 @@ public interface Unit : DBus.Object {
         public abstract string description { owned get; }
         public abstract string load_state { owned get; }
         public abstract string active_state { owned get; }
+        public abstract string sub_state { owned get; }
         public abstract string fragment_path { owned get; }
         public abstract uint64 active_enter_timestamp { owned get; }
         public abstract uint64 active_exit_timestamp { owned get; }
-        public abstract bool can_reload { owned get; }
         public abstract bool can_start { owned get; }
+        public abstract bool can_reload { owned get; }
         public abstract JobLink job { owned get; /* FIXME: this setter is a temporary fix to make valac not segfault */ set; }
+        public abstract bool recursive_stop { owned get; }
+        public abstract bool stop_when_unneeded { owned get; }
+        public abstract string default_control_group { owned get; }
 
         public abstract ObjectPath start(string mode) throws DBus.Error;
         public abstract ObjectPath stop(string mode) throws DBus.Error;
index 176ab68c42f4d5f7ce2a601c3dffcd867f3d0028..61cbebf654bc900b8340b6e24db4ca4f67b067e8 100644 (file)
--- a/target.c
+++ b/target.c
@@ -26,6 +26,7 @@
 #include "target.h"
 #include "load-fragment.h"
 #include "log.h"
+#include "dbus-target.h"
 
 static const UnitActiveState state_translation_table[_TARGET_STATE_MAX] = {
         [TARGET_DEAD] = UNIT_INACTIVE,
@@ -133,5 +134,7 @@ const UnitVTable target_vtable = {
         .stop = target_stop,
 
         .active_state = target_active_state,
-        .sub_state_to_string = target_sub_state_to_string
+        .sub_state_to_string = target_sub_state_to_string,
+
+        .bus_message_handler = bus_target_message_handler
 };
diff --git a/unit.c b/unit.c
index 900c76ad66a1aa47c468d94aba0d125629b4ff3c..f8589fe60569fc4c06b2d1afc4a2a9b92c970780 100644 (file)
--- a/unit.c
+++ b/unit.c
@@ -37,6 +37,7 @@
 #include "log.h"
 #include "unit-name.h"
 #include "specifier.h"
+#include "dbus-unit.h"
 
 const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX] = {
         [UNIT_SERVICE] = &service_vtable,
diff --git a/unit.h b/unit.h
index 4dc53a1a687ca6ab1425035b9515753a01967d0e..b3c75ce20a7e5451a2e35653f308eee755d00bc2 100644 (file)
--- a/unit.h
+++ b/unit.h
@@ -264,6 +264,9 @@ struct UnitVTable {
         /* Called whenever a bus PID lookup finishes */
         void (*bus_query_pid_done)(Unit *u, const char *name, pid_t pid);
 
+        /* Called for each message received on the bus */
+        DBusHandlerResult (*bus_message_handler)(Unit *u, DBusMessage *message);
+
         /* This is called for each unit type and should be used to
          * enumerate existing devices and load them. However,
          * everything that is loaded here should still stay in