From f61a6cad34af9fcc03839128c4a8a30f97a9a2d0 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Wed, 6 Jul 2011 18:23:00 -0300 Subject: Add a function to remove ATT connection callback --- src/attio.h | 2 ++ src/device.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/attio.h b/src/attio.h index fad85166..7935dcdc 100644 --- a/src/attio.h +++ b/src/attio.h @@ -27,3 +27,5 @@ typedef void (*attio_connect_cb) (GAttrib *attrib, gpointer user_data); guint btd_device_add_attio_callback(struct btd_device *device, attio_connect_cb func, gpointer user_data); + +gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id); diff --git a/src/device.c b/src/device.c index ea9c0cdc..ab21b3a8 100644 --- a/src/device.c +++ b/src/device.c @@ -2467,3 +2467,30 @@ guint btd_device_add_attio_callback(struct btd_device *device, return attio->id; } + +static int attio_id_cmp(gconstpointer a, gconstpointer b) +{ + const struct attio_data *attio = a; + guint id = GPOINTER_TO_UINT(b); + + return attio->id - id; +} + +gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id) +{ + struct attio_data *attio; + GSList *l; + + l = g_slist_find_custom(device->attios, GUINT_TO_POINTER(id), + attio_id_cmp); + if (!l) + return FALSE; + + attio = l->data; + + device->attios = g_slist_remove(device->attios, attio); + + g_free(attio); + + return TRUE; +} -- cgit v1.2.3