chiark / gitweb /
event: clear pending-state when re-arming timers
[elogind.git] / src / libsystemd-bus / bus-convenience.c
index 7c9824258be5e2bf503464beaddc4379e44427f5..9bf2e2cbe508d90e9b20db99bbc8dae87d93e925 100644 (file)
@@ -25,7 +25,7 @@
 #include "bus-util.h"
 #include "bus-type.h"
 
-int sd_bus_emit_signal(
+_public_ int sd_bus_emit_signal(
                 sd_bus *bus,
                 const char *path,
                 const char *interface,
@@ -56,7 +56,7 @@ int sd_bus_emit_signal(
         return sd_bus_send(bus, m, NULL);
 }
 
-int sd_bus_call_method(
+_public_ int sd_bus_call_method(
                 sd_bus *bus,
                 const char *destination,
                 const char *path,
@@ -87,10 +87,10 @@ int sd_bus_call_method(
                         return r;
         }
 
-        return sd_bus_send_with_reply_and_block(bus, m, 0, error, reply);
+        return sd_bus_call(bus, m, 0, error, reply);
 }
 
-int sd_bus_reply_method_return(
+_public_ int sd_bus_reply_method_return(
                 sd_bus *bus,
                 sd_bus_message *call,
                 const char *types, ...) {
@@ -125,7 +125,7 @@ int sd_bus_reply_method_return(
         return sd_bus_send(bus, m, NULL);
 }
 
-int sd_bus_reply_method_error(
+_public_ int sd_bus_reply_method_error(
                 sd_bus *bus,
                 sd_bus_message *call,
                 const sd_bus_error *e) {
@@ -151,7 +151,7 @@ int sd_bus_reply_method_error(
         return sd_bus_send(bus, m, NULL);
 }
 
-int sd_bus_reply_method_errorf(
+_public_ int sd_bus_reply_method_errorf(
                 sd_bus *bus,
                 sd_bus_message *call,
                 const char *name,
@@ -182,7 +182,7 @@ int sd_bus_reply_method_errorf(
         return sd_bus_reply_method_error(bus, call, &error);
 }
 
-int sd_bus_reply_method_errno(
+_public_ int sd_bus_reply_method_errno(
                 sd_bus *bus,
                 sd_bus_message *call,
                 int error,
@@ -208,7 +208,7 @@ int sd_bus_reply_method_errno(
         return sd_bus_reply_method_error(bus, call, &berror);
 }
 
-int sd_bus_reply_method_errnof(
+_public_ int sd_bus_reply_method_errnof(
                 sd_bus *bus,
                 sd_bus_message *call,
                 int error,
@@ -235,7 +235,7 @@ int sd_bus_reply_method_errnof(
         return sd_bus_reply_method_error(bus, call, &berror);
 }
 
-int sd_bus_get_property(
+_public_ int sd_bus_get_property(
                 sd_bus *bus,
                 const char *destination,
                 const char *path,
@@ -270,7 +270,7 @@ int sd_bus_get_property(
         return 0;
 }
 
-int sd_bus_get_property_trivial(
+_public_ int sd_bus_get_property_trivial(
                 sd_bus *bus,
                 const char *destination,
                 const char *path,
@@ -305,7 +305,82 @@ int sd_bus_get_property_trivial(
         return 0;
 }
 
-int sd_bus_set_property(
+_public_ int sd_bus_get_property_string(
+                sd_bus *bus,
+                const char *destination,
+                const char *path,
+                const char *interface,
+                const char *member,
+                sd_bus_error *error,
+                char **ret) {
+
+        _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
+        const char *s;
+        char *n;
+        int r;
+
+        assert_return(bus, -EINVAL);
+        assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL);
+        assert_return(member_name_is_valid(member), -EINVAL);
+        assert_return(ret, -EINVAL);
+        assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
+        assert_return(!bus_pid_changed(bus), -ECHILD);
+
+        r = sd_bus_call_method(bus, destination, path, "org.freedesktop.DBus.Properties", "Get", error, &reply, "ss", strempty(interface), member);
+        if (r < 0)
+                return r;
+
+        r = sd_bus_message_enter_container(reply, 'v', "s");
+        if (r < 0)
+                return r;
+
+        r = sd_bus_message_read_basic(reply, 's', &s);
+        if (r < 0)
+                return r;
+
+        n = strdup(s);
+        if (!n)
+                return -ENOMEM;
+
+        *ret = n;
+        return 0;
+}
+
+_public_ int sd_bus_get_property_strv(
+                sd_bus *bus,
+                const char *destination,
+                const char *path,
+                const char *interface,
+                const char *member,
+                sd_bus_error *error,
+                char ***ret) {
+
+        _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
+        int r;
+
+        assert_return(bus, -EINVAL);
+        assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL);
+        assert_return(member_name_is_valid(member), -EINVAL);
+        assert_return(ret, -EINVAL);
+        assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
+        assert_return(!bus_pid_changed(bus), -ECHILD);
+
+        r = sd_bus_call_method(bus, destination, path, "org.freedesktop.DBus.Properties", "Get", error, &reply, "ss", strempty(interface), member);
+        if (r < 0)
+                return r;
+
+        r = sd_bus_message_enter_container(reply, 'v', NULL);
+        if (r < 0)
+                return r;
+
+        r = sd_bus_message_read_strv(reply, ret);
+        if (r < 0)
+                return r;
+
+        return 0;
+}
+
+_public_ int sd_bus_set_property(
                 sd_bus *bus,
                 const char *destination,
                 const char *path,
@@ -347,5 +422,5 @@ int sd_bus_set_property(
         if (r < 0)
                 return r;
 
-        return sd_bus_send_with_reply_and_block(bus, m, 0, error, NULL);
+        return sd_bus_call(bus, m, 0, error, NULL);
 }