diff options
author | 2017-11-09 12:58:32 -0700 | |
---|---|---|
committer | 2017-12-29 12:11:51 -0700 | |
commit | 87035380e33c7da10b53c6da713c56f3d89a1577 (patch) | |
tree | 4b31ad282fe07227f5720928b1ba07715bc7ea48 /include/swaybar/tray/dbus.h | |
parent | Plug memory `dbus_message_iter_get_signature` leak (diff) | |
download | sway-87035380e33c7da10b53c6da713c56f3d89a1577.tar.gz sway-87035380e33c7da10b53c6da713c56f3d89a1577.tar.zst sway-87035380e33c7da10b53c6da713c56f3d89a1577.zip |
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/swaybar/tray/dbus.h')
-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; | |||
12 | bool dbus_message_iter_check_signature(DBusMessageIter *iter, const char *sig); | 12 | bool dbus_message_iter_check_signature(DBusMessageIter *iter, const char *sig); |
13 | 13 | ||
14 | /** | 14 | /** |
15 | * Fetches the property and calls `callback` with a message iter pointing it. | ||
16 | * Performs error handling and signature checking. | ||
17 | * | ||
18 | * Returns: true if message is successfully sent (will not necessarily arrive) | ||
19 | * and false otherwise | ||
20 | * | ||
21 | * NOTE: `expected_signature` must remain valid until the message reply is | ||
22 | * received, please only use 'static signatures. | ||
23 | */ | ||
24 | bool dbus_get_prop_async(const char *destination, | ||
25 | const char *path, | ||
26 | const char *iface, | ||
27 | const char *prop, | ||
28 | const char *expected_signature, | ||
29 | void(*callback)(DBusMessageIter *iter, void *data), | ||
30 | void *data); | ||
31 | /** | ||
15 | * Should be called in main loop to dispatch events | 32 | * Should be called in main loop to dispatch events |
16 | */ | 33 | */ |
17 | void dispatch_dbus(); | 34 | void dispatch_dbus(); |