diff --git a/src/adapter.c b/src/adapter.c
index 48d6294..421cd43 100644
--- a/src/adapter.c
+++ b/src/adapter.c
g_slist_foreach(adapter->devices, device_probe_profile, profile);
}
+void adapter_remove_profile(struct btd_adapter *adapter, gpointer p)
+{
+ struct btd_profile *profile = p;
+
+ if (!adapter->initialized)
+ return;
+
+ if (profile->device_remove)
+ g_slist_foreach(adapter->devices, device_remove_profile, p);
+
+ adapter->profiles = g_slist_remove(adapter->profiles, profile);
+
+ if (profile->adapter_remove)
+ profile->adapter_remove(profile, adapter);
+}
+
static void load_connections(struct btd_adapter *adapter)
{
GSList *l, *conns;
diff --git a/src/adapter.h b/src/adapter.h
index 9f840e8..f34763f 100644
--- a/src/adapter.h
+++ b/src/adapter.h
typedef void (*service_auth_cb) (DBusError *derr, void *user_data);
void adapter_add_profile(struct btd_adapter *adapter, gpointer p);
+void adapter_remove_profile(struct btd_adapter *adapter, gpointer p);
int btd_register_adapter_driver(struct btd_adapter_driver *driver);
void btd_unregister_adapter_driver(struct btd_adapter_driver *driver);
int btd_request_authorization(const bdaddr_t *src, const bdaddr_t *dst,
diff --git a/src/device.c b/src/device.c
index cb25606..efa3dbe 100644
--- a/src/device.c
+++ b/src/device.c
g_slist_free(probe_uuids);
}
+void device_remove_profile(gpointer a, gpointer b)
+{
+ struct btd_device *device = a;
+ struct btd_profile *profile = b;
+
+ if (!g_slist_find(device->profiles, profile))
+ return;
+
+ device->profiles = g_slist_remove(device->profiles, profile);
+
+ profile->device_remove(profile, device);
+}
+
void device_probe_profiles(struct btd_device *device, GSList *uuids)
{
struct probe_data d = { device, uuids };
diff --git a/src/device.h b/src/device.h
index 02c1782..eb45244 100644
--- a/src/device.h
+++ b/src/device.h
GSList *profiles);
void btd_device_add_uuid(struct btd_device *device, const char *uuid);
void device_probe_profile(gpointer a, gpointer b);
+void device_remove_profile(gpointer a, gpointer b);
struct btd_adapter *device_get_adapter(struct btd_device *device);
void device_get_address(struct btd_device *device, bdaddr_t *bdaddr,
uint8_t *bdaddr_type);
diff --git a/src/profile.c b/src/profile.c
index ad2ad4a..24f7b28 100644
--- a/src/profile.c
+++ b/src/profile.c
static void remove_ext(struct ext_profile *ext)
{
+ manager_foreach_adapter(adapter_remove_profile, &ext->p);
+
ext_profiles = g_slist_remove(ext_profiles, ext);
DBG("Removed \"%s\"", ext->name);