summaryrefslogtreecommitdiff
path: root/src/modules/dbus-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-01-29 16:26:34 +0100
committerLennart Poettering <lennart@poettering.net>2009-01-29 16:26:34 +0100
commit47a9b96b64e9fd949adf4dd1fbd26c5d75a5df30 (patch)
treeb367b49be2c4d09cadbcba209040e11a3a3fbb8c /src/modules/dbus-util.c
parent746dc2ac19950d4eecc083929d6ed86443e3a112 (diff)
add some helpers for dealing with DBusPendingCall based on Mrc-Andre's work in module-bluetooth-discover
Diffstat (limited to 'src/modules/dbus-util.c')
-rw-r--r--src/modules/dbus-util.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/modules/dbus-util.c b/src/modules/dbus-util.c
index 1fc1e86f..f6a986a5 100644
--- a/src/modules/dbus-util.c
+++ b/src/modules/dbus-util.c
@@ -382,3 +382,51 @@ void pa_dbus_remove_matches(DBusConnection *c, ...) {
}
va_end(ap);
}
+
+pa_dbus_pending *pa_dbus_pending_new(DBusMessage *m, DBusPendingCall *pending, void *context_data, void *call_data) {
+ pa_dbus_pending *p;
+
+ pa_assert(pending);
+
+ p = pa_xnew(pa_dbus_pending, 1);
+ p->message = m;
+ p->pending = pending;
+ p->context_data = context_data;
+ p->call_data = call_data;
+
+ PA_LLIST_INIT(pa_dbus_pending, p);
+
+ return p;
+}
+
+void pa_dbus_pending_free(pa_dbus_pending *p) {
+ pa_assert(p);
+
+ if (p->pending) {
+ dbus_pending_call_cancel(p->pending);
+ dbus_pending_call_unref(p->pending);
+ }
+
+ if (p->message)
+ dbus_message_unref(p->message);
+
+ pa_xfree(p);
+}
+
+void pa_dbus_sync_pending_list(pa_dbus_pending **p) {
+ pa_assert(p);
+
+ while (*p)
+ dbus_pending_call_block((*p)->pending);
+}
+
+void pa_dbus_free_pending_list(pa_dbus_pending **p) {
+ pa_dbus_pending *i;
+
+ pa_assert(p);
+
+ while ((i = *p)) {
+ PA_LLIST_REMOVE(pa_dbus_pending, *p, i);
+ pa_dbus_pending_free(i);
+ }
+}