struct btd_device *device;
GSList *match_uuids;
GSList *profiles_added;
- GSList *profiles_removed;
sdp_list_t *records;
int search_uuid;
int reconnect_attempt;
if (req->device)
btd_device_unref(req->device);
g_slist_free_full(req->profiles_added, g_free);
- g_slist_free_full(req->profiles_removed, g_free);
if (req->records)
sdp_list_free(req->records, (sdp_free_func_t) sdp_record_free);
return TRUE;
}
-static void remove_service(gpointer data)
-{
- struct btd_service *service = data;
- struct btd_device *device = btd_service_get_device(service);
-
- device->pending = g_slist_remove(device->pending, service);
- service_remove(service);
-}
-
static gboolean do_disconnect(gpointer user_data)
{
struct btd_device *device = user_data;
service = l->data;
device->services = g_slist_delete_link(device->services, l);
- remove_service(service);
+ device->pending = g_slist_remove(device->pending, service);
+ service_remove(service);
}
void device_probe_profiles(struct btd_device *device, GSList *uuids)
DEVICE_INTERFACE, "UUIDs");
}
-static void device_remove_profiles(struct btd_device *device, GSList *uuids)
-{
- char srcaddr[18], dstaddr[18];
- GSList *l, *next;
-
- ba2str(adapter_get_address(device->adapter), srcaddr);
- ba2str(&device->bdaddr, dstaddr);
-
- DBG("Removing profiles for %s", dstaddr);
-
- g_slist_free_full(device->uuids, g_free);
- device->uuids = NULL;
- store_device_info(device);
-
- for (l = device->services; l != NULL; l = next) {
- struct btd_service *service = l->data;
- struct btd_profile *profile = btd_service_get_profile(service);
-
- next = l->next;
- if (device_match_profile(device, profile, device->uuids))
- continue;
-
- device->services = g_slist_delete_link(device->services, l);
- remove_service(service);
- }
-}
-
static void store_sdp_record(GKeyFile *key_file, sdp_record_t *rec)
{
char handle_str[11];
return 0;
req->profiles_added = g_slist_append(req->profiles_added,
g_strdup(uuid));
- return 0;
}
- l = g_slist_find_custom(req->profiles_removed, uuid, bt_uuid_strcmp);
- if (l == NULL)
- return 0;
-
- g_free(l->data);
- req->profiles_removed = g_slist_delete_link(req->profiles_removed, l);
-
return 0;
}
static void update_gatt_services(struct browse_req *req, GSList *current,
GSList *found)
{
- GSList *l, *lmatch, *left = g_slist_copy(current);
+ GSList *l, *lmatch;
/* Added Profiles */
for (l = found; l; l = g_slist_next(l)) {
/* Entry found ? */
lmatch = g_slist_find_custom(current, prim, primary_cmp);
- if (lmatch) {
- left = g_slist_remove(left, lmatch->data);
+ if (lmatch)
continue;
- }
/* New entry */
req->profiles_added = g_slist_append(req->profiles_added,
DBG("UUID Added: %s", prim->uuid);
}
-
- /* Removed Profiles */
- for (l = left; l; l = g_slist_next(l)) {
- struct gatt_primary *prim = l->data;
- req->profiles_removed = g_slist_append(req->profiles_removed,
- g_strdup(prim->uuid));
-
- DBG("UUID Removed: %s", prim->uuid);
- }
-
- g_slist_free(left);
}
static GSList *device_services_from_record(struct btd_device *device,
device->tmp_records = req->records;
req->records = NULL;
- if (!req->profiles_added && !req->profiles_removed) {
+ if (!req->profiles_added) {
DBG("%s: No service update", addr);
goto send_reply;
}
device_probe_profiles(device, req->profiles_added);
}
- /* Remove profiles for services removed */
- if (req->profiles_removed)
- device_remove_profiles(device, req->profiles_removed);
-
/* Propagate services changes */
g_dbus_emit_property_changed(dbus_conn, req->device->path,
DEVICE_INTERFACE, "UUIDs");
search_cb(recs, err, user_data);
}
-static void init_browse(struct browse_req *req, gboolean reverse)
-{
- GSList *l;
-
- /* If we are doing reverse-SDP don't try to detect removed profiles
- * since some devices hide their service records while they are
- * connected
- */
- if (reverse)
- return;
-
- for (l = req->device->uuids; l; l = l->next)
- req->profiles_removed = g_slist_append(req->profiles_removed,
- g_strdup(l->data));
-}
-
static void store_services(struct btd_device *device)
{
struct btd_adapter *adapter = device->adapter;
device->primaries = NULL;
device_register_primaries(device, g_slist_copy(services), -1);
- if (req->profiles_removed)
- device_remove_profiles(device, req->profiles_removed);
device_probe_profiles(device, req->profiles_added);
req = g_new0(struct browse_req, 1);
req->device = btd_device_ref(device);
sdp_uuid16_create(&uuid, uuid_list[req->search_uuid++]);
- init_browse(req, reverse);
err = bt_search_service(adapter_get_address(adapter), &device->bdaddr,
&uuid, browse_cb, req, NULL);