From 19a23cef109dda8e1b0aa29fe3675b75e2ca2e6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Date: Wed, 18 Sep 2013 16:16:56 -0500 Subject: [PATCH] bluetooth: Create infrastrucure for bluetooth hooks Create a pa_bluetooth_hook enum type and API to get pa_hooks from the opaque pa_bluetooth_discovery struct. --- src/modules/bluetooth/bluez5-util.c | 12 ++++++++++++ src/modules/bluetooth/bluez5-util.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c index 36f1b264..bfb33594 100644 --- a/src/modules/bluetooth/bluez5-util.c +++ b/src/modules/bluetooth/bluez5-util.c @@ -44,8 +44,16 @@ struct pa_bluetooth_discovery { pa_dbus_connection *connection; bool filter_added; bool matches_added; + pa_hook hooks[PA_BLUETOOTH_HOOK_MAX]; }; +pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook) { + pa_assert(y); + pa_assert(PA_REFCNT_VALUE(y) > 0); + + return &y->hooks[hook]; +} + static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *userdata) { pa_bluetooth_discovery *y; DBusError err; @@ -93,6 +101,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) { pa_bluetooth_discovery *y; DBusError err; DBusConnection *conn; + unsigned i; if ((y = pa_shared_get(c, "bluetooth-discovery"))) return pa_bluetooth_discovery_ref(y); @@ -101,6 +110,9 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) { PA_REFCNT_INIT(y); y->core = c; + for (i = 0; i < PA_BLUETOOTH_HOOK_MAX; i++) + pa_hook_init(&y->hooks[i], y); + pa_shared_set(c, "bluetooth-discovery", y); dbus_error_init(&err); diff --git a/src/modules/bluetooth/bluez5-util.h b/src/modules/bluetooth/bluez5-util.h index 56602bf4..afbd8e9b 100644 --- a/src/modules/bluetooth/bluez5-util.h +++ b/src/modules/bluetooth/bluez5-util.h @@ -26,6 +26,12 @@ typedef struct pa_bluetooth_discovery pa_bluetooth_discovery; +typedef enum pa_bluetooth_hook { + PA_BLUETOOTH_HOOK_MAX +} pa_bluetooth_hook_t; + +pa_hook* pa_bluetooth_discovery_hook(pa_bluetooth_discovery *y, pa_bluetooth_hook_t hook); + pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *core); pa_bluetooth_discovery* pa_bluetooth_discovery_ref(pa_bluetooth_discovery *y); void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y); -- 2.39.2