diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2011-07-06 18:23:00 -0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2011-07-14 17:38:13 +0300 |
commit | f61a6cad34af9fcc03839128c4a8a30f97a9a2d0 (patch) | |
tree | fe832d1950cfd54326749bb31be3622199a6e5b9 | |
parent | 55f9fbf82233173cfe890c7827211c535ef35afa (diff) |
Add a function to remove ATT connection callback
-rw-r--r-- | src/attio.h | 2 | ||||
-rw-r--r-- | src/device.c | 27 |
2 files changed, 29 insertions, 0 deletions
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; +} |