diff options
| author | Calvin Lee <cyrus296@gmail.com> | 2017-11-09 12:58:32 -0700 |
|---|---|---|
| committer | Calvin Lee <cyrus296@gmail.com> | 2017-12-29 12:11:51 -0700 |
| commit | 87035380e33c7da10b53c6da713c56f3d89a1577 (patch) | |
| tree | 4b31ad282fe07227f5720928b1ba07715bc7ea48 /include | |
| parent | b9f36716b52d4566609ac64be88b8a1f65602214 (diff) | |
Add `dbus_get_prop_async` utility
This drastically reduces the amount of boilerplate needed to get a
property from a bus object.
Diffstat (limited to 'include')
| -rw-r--r-- | include/swaybar/tray/dbus.h | 17 |
1 files changed, 17 insertions, 0 deletions
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 @@ -12,6 +12,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 */ void dispatch_dbus(); |
