From 87035380e33c7da10b53c6da713c56f3d89a1577 Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Thu, 9 Nov 2017 12:58:32 -0700 Subject: Add `dbus_get_prop_async` utility This drastically reduces the amount of boilerplate needed to get a property from a bus object. --- include/swaybar/tray/dbus.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/swaybar/tray') diff --git a/include/swaybar/tray/dbus.h b/include/swaybar/tray/dbus.h index 51754464..125ce96f 100644 --- a/include/swaybar/tray/dbus.h +++ b/include/swaybar/tray/dbus.h @@ -11,6 +11,23 @@ extern DBusConnection *conn; */ bool dbus_message_iter_check_signature(DBusMessageIter *iter, const char *sig); +/** + * Fetches the property and calls `callback` with a message iter pointing it. + * Performs error handling and signature checking. + * + * Returns: true if message is successfully sent (will not necessarily arrive) + * and false otherwise + * + * NOTE: `expected_signature` must remain valid until the message reply is + * received, please only use 'static signatures. + */ +bool dbus_get_prop_async(const char *destination, + const char *path, + const char *iface, + const char *prop, + const char *expected_signature, + void(*callback)(DBusMessageIter *iter, void *data), + void *data); /** * Should be called in main loop to dispatch events */ -- cgit v1.2.3-70-g09d2