adapter_get_address(device->adapter, &src);
ba2str(&device->bdaddr, addr);
+
device_remove_bonding(device, conn);
delete_entry(&src, "profiles", addr);
delete_entry(&src, "trusts", addr);
+ delete_all_records(&src, &device->bdaddr);
}
void device_remove(struct btd_device *device, DBusConnection *conn,
next = list->next;
for (uuid = driver->uuids; *uuid; uuid++) {
- sdp_record_t *rec;
-
if (!g_slist_find_custom(uuids, *uuid,
(GCompareFunc) strcasecmp))
continue;
driver_data);
g_free(driver_data);
- rec = find_record_in_list(records, *uuid);
- if (!rec)
- break;
+ break;
+ }
+ }
- delete_record(srcaddr, dstaddr, rec->handle);
+ for (list = uuids; list; list = list->next) {
+ sdp_record_t *rec;
- records = sdp_list_remove(records, rec);
- sdp_record_free(rec);
+ device->uuids = g_slist_remove(device->uuids, list->data);
+
+ rec = find_record_in_list(records, list->data);
+ if (!rec)
+ continue;
+
+ delete_record(srcaddr, dstaddr, rec->handle);
+
+ records = sdp_list_remove(records, rec);
+ sdp_record_free(rec);
- break;
- }
}
if (records)
sdp_list_free(records, (sdp_free_func_t) sdp_record_free);
-
- for (list = uuids; list; list = list->next)
- device->uuids = g_slist_remove(device->uuids, list->data);
}
static void services_changed(struct btd_device *device)
update_services(req, recs);
- if (!req->profiles_added && !req->profiles_removed) {
- debug("%s: No service update", device->path);
- goto proceed;
- }
-
if (device->tmp_records && req->records) {
sdp_list_free(device->tmp_records,
(sdp_free_func_t) sdp_record_free);
req->records = NULL;
}
+ if (!req->profiles_added && !req->profiles_removed) {
+ debug("%s: No service update", device->path);
+ goto proceed;
+ }
+
/* Probe matching drivers for services added */
if (req->profiles_added)
device_probe_drivers(device, req->profiles_added);
rec_list->recs = sdp_list_append(rec_list->recs, rec);
}
+void delete_all_records(bdaddr_t *src, bdaddr_t *dst)
+{
+ sdp_list_t *records, *seq;
+ sdp_record_t *rec;
+ char srcaddr[18], dstaddr[18];
+
+ ba2str(src, srcaddr);
+ ba2str(dst, dstaddr);
+
+ records = read_records(src, dst);
+
+ for (seq = records; seq; seq = seq->next) {
+ rec = seq->data;
+ delete_record(srcaddr, dstaddr, rec->handle);
+ }
+
+ if (records)
+ sdp_list_free(records, (sdp_free_func_t) sdp_record_free);
+}
+
sdp_list_t *read_records(bdaddr_t *src, bdaddr_t *dst)
{
char filename[PATH_MAX + 1];
sdp_record_t *record_from_string(const gchar *str);
sdp_record_t *fetch_record(const gchar *src, const gchar *dst, const uint32_t handle);
int delete_record(const gchar *src, const gchar *dst, const uint32_t handle);
+void delete_all_records(bdaddr_t *src, bdaddr_t *dst);
sdp_list_t *read_records(bdaddr_t *src, bdaddr_t *dst);
sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid);
int store_device_id(const gchar *src, const gchar *dst,