Diff between 55f9fbf82233173cfe890c7827211c535ef35afa and f61a6cad34af9fcc03839128c4a8a30f97a9a2d0

Changed Files

File Additions Deletions Status
src/attio.h +2 -0 modified
src/device.c +27 -0 modified

Full Patch

diff --git a/src/attio.h b/src/attio.h
index fad8516..7935dcd 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 ea9c0cd..ab21b3a 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;
+}