chiark / gitweb /
sd-bus: also allow setting descriptions on bus slots
authorLennart Poettering <lennart@poettering.net>
Tue, 4 Nov 2014 15:57:38 +0000 (16:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 4 Nov 2014 17:09:19 +0000 (18:09 +0100)
src/libsystemd/libsystemd.sym.m4
src/libsystemd/sd-bus/bus-internal.h
src/libsystemd/sd-bus/bus-slot.c
src/systemd/sd-bus.h

index 04581c5..635caf6 100644 (file)
@@ -223,6 +223,8 @@ global:
         sd_bus_slot_get_bus;
         sd_bus_slot_get_userdata;
         sd_bus_slot_set_userdata;
+        sd_bus_slot_get_description;
+        sd_bus_slot_set_description;
         sd_bus_slot_get_current_message;
         sd_bus_message_new_signal;
         sd_bus_message_new_method_call;
index b1310a8..0738148 100644 (file)
@@ -142,6 +142,7 @@ struct sd_bus_slot {
         void *userdata;
         BusSlotType type:5;
         bool floating:1;
+        char *description;
 
         LIST_FIELDS(sd_bus_slot, slots);
 
index 568a6ed..8060e98 100644 (file)
@@ -208,6 +208,7 @@ _public_ sd_bus_slot* sd_bus_slot_unref(sd_bus_slot *slot) {
         }
 
         bus_slot_disconnect(slot);
+        free(slot->description);
         free(slot);
 
         return NULL;
@@ -265,3 +266,18 @@ _public_ void* sd_bus_slot_get_current_userdata(sd_bus_slot *slot) {
 
         return slot->bus->current_userdata;
 }
+
+_public_ int sd_bus_slot_set_description(sd_bus_slot *slot, const char *description) {
+        assert_return(slot, -EINVAL);
+
+        return free_and_strdup(&slot->description, description);
+}
+
+_public_ int sd_bus_slot_get_description(sd_bus_slot *slot, char **description) {
+        assert_return(slot, -EINVAL);
+        assert_return(description, -EINVAL);
+        assert_return(slot->description, -ENXIO);
+
+        *description = slot->description;
+        return 0;
+}
index e6c9559..40c3a4a 100644 (file)
@@ -175,6 +175,9 @@ sd_bus* sd_bus_slot_get_bus(sd_bus_slot *slot);
 void *sd_bus_slot_get_userdata(sd_bus_slot *slot);
 void *sd_bus_slot_set_userdata(sd_bus_slot *slot, void *userdata);
 
+int sd_bus_slot_set_description(sd_bus_slot *slot, const char *description);
+int sd_bus_slot_get_description(sd_bus_slot *slot, char **description);
+
 sd_bus_message* sd_bus_slot_get_current_message(sd_bus_slot *slot);
 sd_bus_message_handler_t sd_bus_slot_get_current_handler(sd_bus_slot *bus);
 void *sd_bus_slot_get_current_userdata(sd_bus_slot *slot);