chiark / gitweb /
dbus: follow standardized fdo PropertiesChanged signal spec
authorLennart Poettering <lennart@poettering.net>
Fri, 20 Aug 2010 00:26:05 +0000 (02:26 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 20 Aug 2010 00:31:54 +0000 (02:31 +0200)
38 files changed:
fixme
src/automount.c
src/dbus-automount.c
src/dbus-device.c
src/dbus-device.h
src/dbus-job.c
src/dbus-manager.c
src/dbus-mount.c
src/dbus-mount.h
src/dbus-path.c
src/dbus-service.c
src/dbus-service.h
src/dbus-snapshot.c
src/dbus-socket.c
src/dbus-socket.h
src/dbus-swap.c
src/dbus-swap.h
src/dbus-target.c
src/dbus-timer.c
src/dbus-timer.h
src/dbus-unit.c
src/dbus-unit.h
src/dbus.c
src/dbus.h
src/device.c
src/mount.c
src/path.c
src/service.c
src/snapshot.c
src/socket.c
src/swap.c
src/systemadm.vala
src/systemctl.c
src/systemd-interfaces.vala
src/target.c
src/timer.c
src/unit.h
src/util.h

diff --git a/fixme b/fixme
index 855f9d6c97a1a237eefca79cdbd4af6c6a5b3f1b..b1474f5246d06b74364e27f164f9586a5de8c1ee 100644 (file)
--- a/fixme
+++ b/fixme
@@ -40,8 +40,6 @@
 
 * write utmp record a la upstart for processes
 
-* follow property change dbus spec
-
 * selinux policy loading
 
 * place /etc/inittab with explaining blurb.
 
 * bash completion a la gdbus
 
+* fstab mit tüdelchen
+
+* api mounts gegen fstab mergen und remounten
+
 External:
 
 * procps, psmisc, sysvinit-tools, hostname → util-linux-ng
index d5da497c8e2a0ff832a38857adaf55f867fee901..b32e0027c1f34152ef4f1956a6ad232081151e9c 100644 (file)
@@ -843,6 +843,7 @@ const UnitVTable automount_vtable = {
 
         .reset_maintenance = automount_reset_maintenance,
 
+        .bus_interface = "org.freedesktop.systemd1.Automount",
         .bus_message_handler = bus_automount_message_handler,
 
         .shutdown = automount_shutdown
index b7b31a19195a10c0efdf74593c80365a0915699b..3bccb4e5f735df83e46679a6d03d5276178f7c13 100644 (file)
@@ -34,6 +34,7 @@
         BUS_UNIT_INTERFACE                                           \
         BUS_AUTOMOUNT_INTERFACE                                      \
         BUS_PROPERTIES_INTERFACE                                     \
+        BUS_PEER_INTERFACE                                           \
         BUS_INTROSPECTABLE_INTERFACE                                 \
         "</node>\n"
 
index bb8b40ec6f19ceed0dcdc95aa765da683f29b434..fcb05a441e6cb24837aed7b75ccb87eccce07549 100644 (file)
         BUS_UNIT_INTERFACE                                              \
         BUS_DEVICE_INTERFACE                                            \
         BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
 const char bus_device_interface[] = BUS_DEVICE_INTERFACE;
 
+const char bus_device_invalidating_properties[] =
+        "SysFSPath\0"
+        "\0";
+
 DBusHandlerResult bus_device_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
         const BusProperty properties[] = {
                 BUS_UNIT_PROPERTIES,
index 639255db616acf9dd976b29bd26bb6674fb2d6a2..fba270b4e6fa53a4ab2011ba23ee40685bf27999 100644 (file)
@@ -29,5 +29,6 @@
 DBusHandlerResult bus_device_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
 
 extern const char bus_device_interface[];
+extern const char bus_device_invalidating_properties[];
 
 #endif
index 727e2ac6d5a710afd2e3aaacb90eb860943ec247..0f76c7d8433cb061e3f2e53dfedfc65e55c0cee5 100644 (file)
@@ -28,7 +28,6 @@
 #define BUS_JOB_INTERFACE                                             \
         " <interface name=\"org.freedesktop.systemd1.Job\">\n"        \
         "  <method name=\"Cancel\"/>\n"                               \
-        "  <signal name=\"Changed\"/>\n"                              \
         "  <property name=\"Id\" type=\"u\" access=\"read\"/>\n"      \
         "  <property name=\"Unit\" type=\"(so)\" access=\"read\"/>\n" \
         "  <property name=\"JobType\" type=\"s\" access=\"read\"/>\n" \
         "<node>\n"                                                    \
         BUS_JOB_INTERFACE                                             \
         BUS_PROPERTIES_INTERFACE                                      \
+        BUS_PEER_INTERFACE                                            \
         BUS_INTROSPECTABLE_INTERFACE                                  \
         "</node>\n"
 
 const char bus_job_interface[] = BUS_JOB_INTERFACE;
 
+#define INVALIDATING_PROPERTIES                 \
+        "State\0"                               \
+        "\0"                                    \
+
 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);
 
@@ -187,10 +191,11 @@ void bus_job_send_change_signal(Job *j) {
                 goto oom;
 
         if (j->sent_dbus_new_signal) {
-                /* Send a change signal */
+                /* Send a properties changed signal */
 
-                if (!(m = dbus_message_new_signal(p, "org.freedesktop.systemd1.Job", "Changed")))
+                if (!(m = bus_properties_changed_new(p, "org.freedesktop.systemd1.Job", INVALIDATING_PROPERTIES)))
                         goto oom;
+
         } else {
                 /* Send a new signal */
 
index 1fca8b554c8b47eca77b828a73635b41ceb43476..eb3768455c2c76edcb5e11074ad4339ab02e6faa 100644 (file)
         "<node>\n"                                                      \
         BUS_MANAGER_INTERFACE                                           \
         BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
         BUS_INTROSPECTABLE_INTERFACE
 
 #define INTROSPECTION_END                                               \
index 933e3bb340eef3b013215e1eef2b9373f146a583..92d74cb92ff40873e59b599929d7902cba991912 100644 (file)
         BUS_UNIT_INTERFACE                                              \
         BUS_MOUNT_INTERFACE                                             \
         BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
 const char bus_mount_interface[] = BUS_MOUNT_INTERFACE;
 
+const char bus_mount_invalidating_properties[] =
+        "What\0"
+        "Options\0"
+        "Type\0"
+        "ExecMount\0"
+        "ExecUnmount\0"
+        "ExecRemount\0"
+        "ControlPID\0"
+        "\0";
+
 static int bus_mount_append_what(Manager *n, DBusMessageIter *i, const char *property, void *data) {
         Mount *m = data;
         const char *d;
index c9ab73f4100ed027bdc7b5907f3a59ffc90f43e6..b5613fa7b6980f983bdde3b575b15dd3d16fb838 100644 (file)
@@ -29,5 +29,6 @@
 DBusHandlerResult bus_mount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
 
 extern const char bus_mount_interface[];
+extern const char bus_mount_invalidating_properties[];
 
 #endif
index 45472e58e6af0c32f8e1518262796944a499d229..c8c302ab3737cbbd91539abe7e2312c0cfd78400 100644 (file)
@@ -37,6 +37,7 @@
         BUS_UNIT_INTERFACE                                              \
         BUS_PATH_INTERFACE                                              \
         BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
index 59222066ea54f304efab419e3462f23efed9f904..86c18dddcfd68c01e843079f6f6590487aed97f3 100644 (file)
         BUS_UNIT_INTERFACE                                              \
         BUS_SERVICE_INTERFACE                                           \
         BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
 const char bus_service_interface[] = BUS_SERVICE_INTERFACE;
 
+const char bus_service_invalidating_properties[] =
+        "ExecStartPre\0"
+        "ExecStart\0"
+        "ExecStartPost\0"
+        "ExecReload\0"
+        "ExecStop\0"
+        "ExecStopPost\0"
+        "ExecMain\0"
+        "MainPID\0"
+        "ControlPID\0"
+        "StatusText\0"
+        "\0";
+
 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);
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_notify_access, notify_access, NotifyAccess);
index 4f628edae37161dd1c975f513c0ffd27943e7108..d6eab65c5202bc9a8cfc19e47bee1227b34df6f1 100644 (file)
@@ -29,5 +29,6 @@
 DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
 
 extern const char bus_service_interface[];
+extern const char bus_service_invalidating_properties[];
 
 #endif
index ecb7ec8ea6da86271f1cda3710613b0d1d3e9dd4..efaec7df3dcc613734247fb20b808eb4be83308a 100644 (file)
@@ -34,6 +34,7 @@
         BUS_UNIT_INTERFACE                                              \
         BUS_SNAPSHOT_INTERFACE                                          \
         BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
index 9406bb294305944d5eebd63decef1865a41924e1..5931f006c202f75957b5958c9aea0dfcb4dcb288 100644 (file)
         BUS_UNIT_INTERFACE                                              \
         BUS_SOCKET_INTERFACE                                            \
         BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
 const char bus_socket_interface[] = BUS_SOCKET_INTERFACE;
 
+const char bus_socket_invalidating_properties[] =
+        "ExecStartPre\0"
+        "ExecStartPost\0"
+        "ExecStopPre\0"
+        "ExecStopPost\0"
+        "ControlPID\0"
+        "NAccepted\0"
+        "NConnections\0"
+        "\0";
+
 static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
 
 DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
index 71d5b4fa87caf282d71a6b5617c7d41904b7d3f9..069a2f5df055489c0cdf05fb53f4882cccf95443 100644 (file)
@@ -29,5 +29,6 @@
 DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
 
 extern const char bus_socket_interface[];
+extern const char bus_socket_invalidating_properties[];
 
 #endif
index 1de44279355b36bd70f8a87db7e52c58164390f7..c345d4bc7dae9f6f1625afd0de51c025ba673549 100644 (file)
         BUS_UNIT_INTERFACE                                              \
         BUS_SWAP_INTERFACE                                              \
         BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
 const char bus_swap_interface[] = BUS_SWAP_INTERFACE;
 
+const char bus_swap_invalidating_properties[] =
+        "What\0"
+        "Priority\0"
+        "\0";
+
 static int bus_swap_append_priority(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         Swap *s = data;
         dbus_int32_t j;
index 5eeb02a16091c93ee80734d1cc6bafdd205e112e..15b914726b2a785f7688dcbbcc162efca32b590d 100644 (file)
@@ -30,5 +30,6 @@
 DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
 
 extern const char bus_swap_interface[];
+extern const char bus_swap_invalidating_properties[];
 
 #endif
index 03e8fc8bd0a6b4fab8d3a0b868d9fc18d0f01bc7..69e82120764e7f8365ef102934287a3b7667e2bf 100644 (file)
@@ -34,6 +34,7 @@
         BUS_UNIT_INTERFACE                                              \
         BUS_TARGET_INTERFACE                                            \
         BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
index 6dfadf214906565dd206650ee9f3be37e4ae2c0a..e57e97303ae97fd0fc469ce9cbd6bf18cf93a88e 100644 (file)
         BUS_UNIT_INTERFACE                                              \
         BUS_TIMER_INTERFACE                                             \
         BUS_PROPERTIES_INTERFACE                                        \
+        BUS_PEER_INTERFACE                                              \
         BUS_INTROSPECTABLE_INTERFACE                                    \
         "</node>\n"
 
 const char bus_timer_interface[] = BUS_TIMER_INTERFACE;
 
+const char bus_timer_invalidating_properties[] =
+        "Timers\0"
+        "NextElapseUSec\0"
+        "\0";
+
 static int bus_timer_append_timers(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         Timer *p = data;
         DBusMessageIter sub, sub2;
index 6f35aa7219eb0b98c346bb8f111999594d02cc4c..e692e12fcb591c0c15d2c625a420f8d69a6f05bc 100644 (file)
@@ -29,5 +29,6 @@
 DBusHandlerResult bus_timer_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
 
 extern const char bus_timer_interface[];
+extern const char bus_timer_invalidating_properties[];
 
 #endif
index ca4e5f248e7ead075715a9f32111fae4fffdca79..519aa5c3e8b0a7cee69fd8d65d5641b653e53441 100644 (file)
 
 const char bus_unit_interface[] = BUS_UNIT_INTERFACE;
 
+#define INVALIDATING_PROPERTIES                 \
+        "LoadState\0"                           \
+        "ActiveState\0"                         \
+        "SubState\0"                            \
+        "InactiveExitTimestamp\0"               \
+        "ActiveEnterTimestamp\0"                \
+        "ActiveExitTimestamp\0"                 \
+        "InactiveEnterTimestamp\0"              \
+        "Job\0"                                 \
+        "NeedDaemonReload\0"                    \
+        "\0"
+
 int bus_unit_append_names(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         char *t;
         Iterator j;
@@ -470,10 +482,27 @@ void bus_unit_send_change_signal(Unit *u) {
                 goto oom;
 
         if (u->meta.sent_dbus_new_signal) {
-                /* Send a change signal */
+                /* Send a properties changed signal. First for the
+                 * specific type, then for the generic unit. The
+                 * clients may rely on this order to get atomic
+                 * behaviour if needed. */
+
+                if (UNIT_VTABLE(u)->bus_invalidating_properties) {
+
+                        if (!(m = bus_properties_changed_new(p,
+                                                             UNIT_VTABLE(u)->bus_interface,
+                                                             UNIT_VTABLE(u)->bus_invalidating_properties)))
+                                goto oom;
+
+                        if (bus_broadcast(u->meta.manager, m) < 0)
+                                goto oom;
 
-                if (!(m = dbus_message_new_signal(p, "org.freedesktop.systemd1.Unit", "Changed")))
+                        dbus_message_unref(m);
+                }
+
+                if (!(m = bus_properties_changed_new(p, "org.freedesktop.systemd1.Unit", INVALIDATING_PROPERTIES)))
                         goto oom;
+
         } else {
                 /* Send a new signal */
 
index 8f17bf23998627f87f60fac5dc4c5e4d096b5a3b..cc55ad7cf9d1955b88b649e9678d92ca766a9f95 100644 (file)
@@ -57,7 +57,6 @@
         "   <arg name=\"job\" type=\"o\" direction=\"out\"/>\n"         \
         "  </method>\n"                                                 \
         "  <method name=\"ResetMaintenance\"/>\n"                       \
-        "  <signal name=\"Changed\"/>\n"                                \
         "  <property name=\"Id\" type=\"s\" access=\"read\"/>\n"        \
         "  <property name=\"Names\" type=\"as\" access=\"read\"/>\n"    \
         "  <property name=\"Following\" type=\"s\" access=\"read\"/>\n" \
index e8828d02df4e4c00e8e5fdd6d5ce169ae045383b..952806bb2ac9feab08a5161d4687534abf784c09 100644 (file)
@@ -1247,6 +1247,7 @@ DBusHandlerResult bus_default_message_handler(Manager *m, DBusConnection *c, DBu
                         if (!dbus_message_iter_close_container(&iter, &sub))
                                 goto oom;
                 }
+
         } else if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Properties", "GetAll") && properties) {
                 const char *interface;
                 const BusProperty *p;
@@ -1611,3 +1612,41 @@ bool bus_connection_has_subscriber(Manager *m, DBusConnection *c) {
 
         return !set_isempty(BUS_CONNECTION_SUBSCRIBED(m, c));
 }
+
+DBusMessage* bus_properties_changed_new(const char *path, const char *interface, const char *properties) {
+        DBusMessage *m;
+        DBusMessageIter iter, sub;
+        const char *i;
+
+        assert(interface);
+        assert(properties);
+
+        if (!(m = dbus_message_new_signal(path, "org.freedesktop.DBus.Properties", "PropertiesChanged")))
+                goto oom;
+
+        dbus_message_iter_init_append(m, &iter);
+
+        /* We won't send any property values, since they might be
+         * large and sometimes not cheap to generated */
+
+        if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &interface) ||
+            !dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &sub) ||
+            !dbus_message_iter_close_container(&iter, &sub) ||
+            !dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "s", &sub))
+                goto oom;
+
+        NULSTR_FOREACH(i, properties)
+                if (!dbus_message_iter_append_basic(&sub, DBUS_TYPE_STRING, &i))
+                        goto oom;
+
+        if (!dbus_message_iter_close_container(&iter, &sub))
+                goto oom;
+
+        return m;
+
+oom:
+        if (m)
+                dbus_message_unref(m);
+
+        return NULL;
+}
index f15a3f99f6de42cbff9fa2fd32684c7f27fa9b94..7c0da3320b33714749db9ee17af8fb1b1aa79c5b 100644 (file)
@@ -47,6 +47,11 @@ typedef struct BusProperty {
         "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n"    \
         "   <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \
         "  </method>\n"                                                 \
+        "  <signal name=\"PropertiesChanged\">\n"                       \
+        "   <arg type=\"s\" name=\"interface\"/>\n"                     \
+        "   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n"        \
+        "   <arg type=\"as\" name=\"invalidated_properties\"/>\n"       \
+        "  </signal>\n"                                                 \
         " </interface>\n"
 
 #define BUS_INTROSPECTABLE_INTERFACE                                    \
@@ -56,6 +61,14 @@ typedef struct BusProperty {
         "  </method>\n"                                                 \
         " </interface>\n"
 
+#define BUS_PEER_INTERFACE                                              \
+        "<interface name=\"org.freedesktop.DBus.Peer\">\n"              \
+        " <method name=\"Ping\"/>\n"                                    \
+        " <method name=\"GetMachineId\">\n"                             \
+        "  <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
+        " </method>\n"                                                  \
+        "</interface>\n"
+
 int bus_init(Manager *m);
 void bus_done(Manager *m);
 
@@ -108,6 +121,8 @@ int bus_parse_strv(DBusMessage *m, char ***_l);
 bool bus_has_subscriber(Manager *m);
 bool bus_connection_has_subscriber(Manager *m, DBusConnection *c);
 
+DBusMessage* bus_properties_changed_new(const char *path, const char *interface, const char *properties);
+
 #define BUS_CONNECTION_SUBSCRIBED(m, c) dbus_connection_get_data((c), (m)->subscribed_data_slot)
 #define BUS_PENDING_CALL_NAME(m, p) dbus_pending_call_get_data((p), (m)->name_data_slot)
 
index 7323192a7176ddaa0fa46fd5181725904a79ea6c..8074a3eddc91402bc5926d1f5a5fb39acba819f4 100644 (file)
@@ -537,7 +537,9 @@ const UnitVTable device_vtable = {
         .active_state = device_active_state,
         .sub_state_to_string = device_sub_state_to_string,
 
+        .bus_interface = "org.freedesktop.systemd1.Device",
         .bus_message_handler = bus_device_message_handler,
+        .bus_invalidating_properties =  bus_device_invalidating_properties,
 
         .following = device_following,
 
index 89b18431dae531d98a32711ee627c83276680c8b..e0ca5bb5d0dd16f4a015282503dc7aa6c167592e 100644 (file)
@@ -1005,6 +1005,9 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
         default:
                 assert_not_reached("Uh, control process died at wrong time.");
         }
+
+        /* Notify clients about changed exit status */
+        unit_add_to_dbus_queue(u);
 }
 
 static void mount_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
@@ -1557,7 +1560,9 @@ const UnitVTable mount_vtable = {
 
         .reset_maintenance = mount_reset_maintenance,
 
+        .bus_interface = "org.freedesktop.systemd1.Mount",
         .bus_message_handler = bus_mount_message_handler,
+        .bus_invalidating_properties =  bus_mount_invalidating_properties,
 
         .enumerate = mount_enumerate,
         .shutdown = mount_shutdown
index 9af1cd4c26bcd3ea5e05c8fcc2a7e2b1bb625462..42c64f3eb1aaf5bd06d2d195f0da50a908f68c5b 100644 (file)
@@ -607,5 +607,6 @@ const UnitVTable path_vtable = {
 
         .reset_maintenance = path_reset_maintenance,
 
+        .bus_interface = "org.freedesktop.systemd1.Path",
         .bus_message_handler = bus_path_message_handler
 };
index 66e233a66927f4be6bfd75180facb289b2674049..d2ef1ad9070e11993ec103d1b16e04d42881b4f5 100644 (file)
@@ -2454,6 +2454,9 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                         }
                 }
         }
+
+        /* Notify clients about changed exit status */
+        unit_add_to_dbus_queue(u);
 }
 
 static void service_timer_event(Unit *u, uint64_t elapsed, Watch* w) {
@@ -2610,6 +2613,9 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
                 }
 
         }
+
+        /* Notify clients about changed status or main pid */
+        unit_add_to_dbus_queue(u);
 }
 
 static int service_enumerate(Manager *m) {
@@ -2944,7 +2950,9 @@ const UnitVTable service_vtable = {
         .bus_name_owner_change = service_bus_name_owner_change,
         .bus_query_pid_done = service_bus_query_pid_done,
 
+        .bus_interface = "org.freedesktop.systemd1.Service",
         .bus_message_handler = bus_service_message_handler,
+        .bus_invalidating_properties =  bus_service_invalidating_properties,
 
         .enumerate = service_enumerate
 };
index 2c46837ca2a03c09d9e8e5358447aa9901598ecc..f58d46e91702aedfa0c04920131576da6580edea 100644 (file)
@@ -292,5 +292,6 @@ const UnitVTable snapshot_vtable = {
         .active_state = snapshot_active_state,
         .sub_state_to_string = snapshot_sub_state_to_string,
 
+        .bus_interface = "org.freedesktop.systemd1.Snapshot",
         .bus_message_handler = bus_snapshot_message_handler
 };
index 3a371917c51ddaf3eb369c16c3fc138f09bbc731..7510a6d6decd7eaedd57b9dc9bb907ffbc535116 100644 (file)
@@ -659,7 +659,6 @@ static int fifo_address_create(
                 const char *path,
                 mode_t directory_mode,
                 mode_t socket_mode,
-                const char *label,
                 int *_fd) {
 
         int fd = -1, r = 0;
@@ -671,7 +670,7 @@ static int fifo_address_create(
 
         mkdir_parents(path, directory_mode);
 
-        if ((r = label_fifofile_set(label, path)) < 0)
+        if ((r = label_fifofile_set(path)) < 0)
                 goto fail;
 
         /* Enforce the right access mode for the fifo */
@@ -1217,6 +1216,9 @@ static void socket_enter_running(Socket *s, int cfd) {
 
                 if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT(service), JOB_REPLACE, true, &error, NULL)) < 0)
                         goto fail;
+
+                /* Notify clients about changed counters */
+                unit_add_to_dbus_queue(UNIT(s));
         }
 
         return;
@@ -1594,6 +1596,9 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                         assert_not_reached("Uh, control process died at wrong time.");
                 }
         }
+
+        /* Notify clients about changed exit status */
+        unit_add_to_dbus_queue(u);
 }
 
 static void socket_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
@@ -1774,5 +1779,7 @@ const UnitVTable socket_vtable = {
 
         .reset_maintenance = socket_reset_maintenance,
 
-        .bus_message_handler = bus_socket_message_handler
+        .bus_interface = "org.freedesktop.systemd1.Socket",
+        .bus_message_handler = bus_socket_message_handler,
+        .bus_invalidating_properties =  bus_socket_invalidating_properties
 };
index ffe76881d47c3c0c3254411424af43c174835fa7..c81fd67cc8c22b1fc9fbb081c224dfe5a9604ac4 100644 (file)
@@ -599,7 +599,9 @@ const UnitVTable swap_vtable = {
 
         .check_gc = swap_check_gc,
 
+        .bus_interface = "org.freedesktop.systemd1.Swap",
         .bus_message_handler = bus_swap_message_handler,
+        .bus_invalidating_properties =  bus_swap_invalidating_properties,
 
         .reset_maintenance = swap_reset_maintenance,
 
index 3610e2b8f42a31ff8fa8fb199341a2db0a6c7c3f..4aee1d35e6d238a4a1237f0db2c801be8e7d092e 100644 (file)
@@ -325,13 +325,19 @@ public class MainWindow : Window {
                 foreach (var i in list) {
                         TreeIter iter;
 
+                        Properties p = bus.get_object(
+                                        "org.freedesktop.systemd1",
+                                        i.unit_path,
+                                        "org.freedesktop.DBus.Properties") as Properties;
+
+
+                        p.properties_changed.connect(on_unit_changed);
+
                         Unit u = bus.get_object(
                                         "org.freedesktop.systemd1",
                                         i.unit_path,
                                         "org.freedesktop.systemd1.Unit") as Unit;
 
-                        u.changed.connect(on_unit_changed);
-
                         unit_model.append(out iter);
                         unit_model.set(iter,
                                        0, i.id,
@@ -352,13 +358,18 @@ public class MainWindow : Window {
                 foreach (var i in list) {
                         TreeIter iter;
 
+                        Properties p = bus.get_object(
+                                        "org.freedesktop.systemd1",
+                                        i.job_path,
+                                        "org.freedesktop.DBus.Properties") as Properties;
+
+                        p.properties_changed.connect(on_job_changed);
+
                         Job j = bus.get_object(
                                         "org.freedesktop.systemd1",
                                         i.job_path,
                                         "org.freedesktop.systemd1.Job") as Job;
 
-                        j.changed.connect(on_job_changed);
-
                         job_model.append(out iter);
                         job_model.set(iter,
                                       0, "%u".printf(i.id),
@@ -672,15 +683,21 @@ public class MainWindow : Window {
         }
 
         public void on_unit_new(string id, ObjectPath path) {
-                Unit u = bus.get_object(
+                Properties p = bus.get_object(
                                 "org.freedesktop.systemd1",
                                 path,
-                                "org.freedesktop.systemd1.Unit") as Unit;
+                                "org.freedesktop.DBus.Properties") as Properties;
 
-                u.changed.connect(on_unit_changed);
+                p.properties_changed.connect(on_unit_changed);
 
                 TreeIter iter;
                 unit_model.append(out iter);
+
+                Unit u = bus.get_object(
+                                "org.freedesktop.systemd1",
+                                path,
+                                "org.freedesktop.systemd1.Unit") as Unit;
+
                 update_unit_iter(iter, id, u);
         }
 
@@ -695,15 +712,22 @@ public class MainWindow : Window {
         }
 
         public void on_job_new(uint32 id, ObjectPath path) {
-                Job j = bus.get_object(
+
+                Properties p = bus.get_object(
                                 "org.freedesktop.systemd1",
                                 path,
-                                "org.freedesktop.systemd1.Job") as Job;
+                                "org.freedesktop.DBus.Properties") as Properties;
 
-                j.changed.connect(on_job_changed);
+                p.properties_changed.connect(on_job_changed);
 
                 TreeIter iter;
                 job_model.append(out iter);
+
+                Job j = bus.get_object(
+                                "org.freedesktop.systemd1",
+                                path,
+                                "org.freedesktop.systemd1.Job") as Job;
+
                 update_job_iter(iter, id, j);
         }
 
@@ -750,10 +774,15 @@ public class MainWindow : Window {
                 } while (job_model.iter_next(ref iter));
         }
 
-        public void on_unit_changed(Unit u) {
+        public void on_unit_changed(Properties p, string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties) {
                 TreeIter iter;
                 string id;
 
+                Unit u = bus.get_object(
+                                p.get_bus_name(),
+                                p.get_path(),
+                                "org.freedesktop.systemd1.Unit") as Unit;
+
                 if (!(unit_model.get_iter_first(out iter)))
                         return;
 
@@ -776,10 +805,15 @@ public class MainWindow : Window {
                 } while (unit_model.iter_next(ref iter));
         }
 
-        public void on_job_changed(Job j) {
+        public void on_job_changed(Properties p, string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties) {
                 TreeIter iter;
                 uint32 id;
 
+                Job j = bus.get_object(
+                                p.get_bus_name(),
+                                p.get_path(),
+                                "org.freedesktop.systemd1.Job") as Job;
+
                 if (!(job_model.get_iter_first(out iter)))
                         return;
 
index 5bf5e9f38ff61ba05c39ea0b4471d7828e12322d..30f6b2a1e5ff305fa9842e9e721d33a65f76e09a 100644 (file)
@@ -2390,14 +2390,23 @@ static DBusHandlerResult monitor_filter(DBusConnection *connection, DBusMessage
                         printf("Job %u removed.\n", id);
 
 
-        } else if (dbus_message_is_signal(message, "org.freedesktop.systemd1.Unit", "Changed") ||
-                   dbus_message_is_signal(message, "org.freedesktop.systemd1.Job", "Changed")) {
+        } else if (dbus_message_is_signal(message, "org.freedesktop.DBus.Properties", "PropertiesChanged")) {
 
                 const char *path, *interface, *property = "Id";
                 DBusMessageIter iter, sub;
 
                 path = dbus_message_get_path(message);
-                interface = dbus_message_get_interface(message);
+
+                if (!dbus_message_get_args(message, &error,
+                                          DBUS_TYPE_STRING, &interface,
+                                          DBUS_TYPE_INVALID)) {
+                        log_error("Failed to parse message: %s", error.message);
+                        goto finish;
+                }
+
+                if (!streq(interface, "org.freedesktop.systemd1.Job") &&
+                    !streq(interface, "org.freedesktop.systemd1.Unit"))
+                        goto finish;
 
                 if (!(m = dbus_message_new_method_call(
                               "org.freedesktop.systemd1",
@@ -2497,21 +2506,8 @@ static int monitor(DBusConnection *bus, char **args, unsigned n) {
                 dbus_bus_add_match(bus,
                                    "type='signal',"
                                    "sender='org.freedesktop.systemd1',"
-                                   "interface='org.freedesktop.systemd1.Unit',"
-                                   "member='Changed'",
-                                   &error);
-
-                if (dbus_error_is_set(&error)) {
-                        log_error("Failed to add match: %s", error.message);
-                        r = -EIO;
-                        goto finish;
-                }
-
-                dbus_bus_add_match(bus,
-                                   "type='signal',"
-                                   "sender='org.freedesktop.systemd1',"
-                                   "interface='org.freedesktop.systemd1.Job',"
-                                   "member='Changed'",
+                                   "interface='org.freedesktop.DBus.Properties',"
+                                   "member='PropertiesChanged'",
                                    &error);
 
                 if (dbus_error_is_set(&error)) {
index 612cb13228d08d3b585174f42171f2e406380680..9a8c1dcdf3a04335e115b1a494288c798e96d0fb 100644 (file)
@@ -50,13 +50,19 @@ public interface Manager : DBus.Object {
         public abstract JobInfo[] list_jobs() throws DBus.Error;
 
         public abstract ObjectPath get_unit(string name) throws DBus.Error;
+        public abstract ObjectPath get_unit_by_pid(uint32 pid) throws DBus.Error;
         public abstract ObjectPath load_unit(string name) throws DBus.Error;
         public abstract ObjectPath get_job(uint32 id) throws DBus.Error;
 
-        public abstract ObjectPath start_unit(string name, string mode) throws DBus.Error;
-        public abstract ObjectPath stop_unit(string name, string mode) throws DBus.Error;
-        public abstract ObjectPath reload_unit(string name, string mode) throws DBus.Error;
-        public abstract ObjectPath restart_unit(string name, string mode) throws DBus.Error;
+        public abstract ObjectPath start_unit(string name, string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath stop_unit(string name, string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath reload_unit(string name, string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath restart_unit(string name, string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath try_restart_unit(string name, string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath reload_or_restart_unit(string name, string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath reload_or_try_restart_unit(string name, string mode = "replace") throws DBus.Error;
+
+        public abstract void reset_maintenance_unit(string name = "") throws DBus.Error;
 
         public abstract void clear_jobs() throws DBus.Error;
 
@@ -89,6 +95,7 @@ public interface Unit : DBus.Object {
 
         public abstract string id { owned get; }
         public abstract string[] names { owned get; }
+        public abstract string following { owned get; }
         public abstract string[] requires { owned get; }
         public abstract string[] requires_overridable { owned get; }
         public abstract string[] requisite { owned get; }
@@ -98,8 +105,10 @@ public interface Unit : DBus.Object {
         public abstract string[] required_by_overridable { owned get; }
         public abstract string[] wanted_by { owned get; }
         public abstract string[] conflicts { owned get; }
+        public abstract string[] conflicted_by { owned get; }
         public abstract string[] before { owned get; }
         public abstract string[] after { owned get; }
+        public abstract string[] on_failure { owned get; }
         public abstract string description { owned get; }
         public abstract string load_state { owned get; }
         public abstract string active_state { owned get; }
@@ -110,19 +119,28 @@ public interface Unit : DBus.Object {
         public abstract uint64 active_exit_timestamp { owned get; }
         public abstract uint64 inactive_enter_timestamp { owned get; }
         public abstract bool can_start { owned get; }
+        public abstract bool can_stop { owned get; }
         public abstract bool can_reload { owned get; }
         public abstract JobLink job { owned get; }
         public abstract bool recursive_stop { owned get; }
         public abstract bool stop_when_unneeded { owned get; }
+        public abstract bool refuse_manual_start { owned get; }
+        public abstract bool refuse_manual_stop { owned get; }
+        public abstract bool default_dependencies { owned get; }
         public abstract string default_control_group { owned get; }
         public abstract string[] control_groups { owned get; }
-
-        public abstract ObjectPath start(string mode) throws DBus.Error;
-        public abstract ObjectPath stop(string mode) throws DBus.Error;
-        public abstract ObjectPath restart(string mode) throws DBus.Error;
-        public abstract ObjectPath reload(string mode) throws DBus.Error;
-
-        public abstract signal void changed();
+        public abstract bool need_daemon_reload { owned get; }
+        public abstract uint64 job_timeout_usec { owned get; }
+
+        public abstract ObjectPath start(string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath stop(string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath reload(string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath restart(string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath try_restart(string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath reload_or_restart(string mode = "replace") throws DBus.Error;
+        public abstract ObjectPath reload_or_try_restart(string mode = "replace") throws DBus.Error;
+
+        public abstract void reset_maintenance() throws DBus.Error;
 }
 
 [DBus (name = "org.freedesktop.systemd1.Job")]
@@ -138,6 +156,10 @@ public interface Job : DBus.Object {
         public abstract UnitLink unit { owned get; }
 
         public abstract void cancel() throws DBus.Error;
+}
 
-        public abstract signal void changed();
+[DBus (name = "org.freedesktop.DBus.Properties")]
+public interface Properties : DBus.Object {
+        public abstract Value? get(string iface, string property) throws DBus.Error;
+        public abstract signal void properties_changed(string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties);
 }
index 48137fe313ce33b02f3cc410906c9bc4372e6c08..c7285fa737ccece67a9eee4775c3cd05aaf9963b 100644 (file)
@@ -207,5 +207,6 @@ const UnitVTable target_vtable = {
         .active_state = target_active_state,
         .sub_state_to_string = target_sub_state_to_string,
 
+        .bus_interface = "org.freedesktop.systemd1.Target",
         .bus_message_handler = bus_target_message_handler
 };
index 61bd85c7ef2b5324188c3c3478a6ec5562b13a9d..89deb0194a7c3b6baf3c60ff8396630d947612bd 100644 (file)
@@ -498,5 +498,7 @@ const UnitVTable timer_vtable = {
 
         .reset_maintenance = timer_reset_maintenance,
 
-        .bus_message_handler = bus_timer_message_handler
+        .bus_interface = "org.freedesktop.systemd1.Timer",
+        .bus_message_handler = bus_timer_message_handler,
+        .bus_invalidating_properties =  bus_timer_invalidating_properties
 };
index 993a6cb778910f193c3a2aa357c4f34372b22bcd..0362602fa1d92bb31436f6741445041cdb275727 100644 (file)
@@ -334,6 +334,14 @@ struct UnitVTable {
         /* Type specific cleanups. */
         void (*shutdown)(Manager *m);
 
+        /* When sending out PropertiesChanged signal, which properties
+         * shall be invalidated? This is a NUL seperated list of
+         * strings, to minimize relocations a little. */
+        const char *bus_invalidating_properties;
+
+        /* The interface name */
+        const char *bus_interface;
+
         /* Can units of this type have multiple names? */
         bool no_alias:1;
 
index e8d9b3e74bb496503db44ece59973719047d1d33..7490236fa0915e4abaf678c818dadd1864278c9f 100644 (file)
@@ -339,6 +339,9 @@ char *ellipsize(const char *s, unsigned length, unsigned percent);
 
 int touch(const char *path);
 
+#define NULSTR_FOREACH(i, l) \
+        for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
+
 const char *ioprio_class_to_string(int i);
 int ioprio_class_from_string(const char *s);