mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2025-01-24 13:23:29 +08:00
attrib-server: Add GAttrib in attrib_channel_detach function
This commit is contained in:
parent
54f49e31d5
commit
5d250fdf4f
@ -180,27 +180,6 @@ static struct gatt_server *find_gatt_server(const bdaddr_t *bdaddr)
|
||||
return l->data;
|
||||
}
|
||||
|
||||
static struct gatt_server *get_default_gatt_server(void)
|
||||
{
|
||||
struct btd_adapter *adapter;
|
||||
GSList *l;
|
||||
|
||||
adapter = manager_get_default_adapter();
|
||||
if (adapter == NULL) {
|
||||
error("Can't get default adapter");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
l = g_slist_find_custom(servers, adapter, adapter_cmp);
|
||||
if (l == NULL) {
|
||||
error("Not GATT server initialized on adapter %s",
|
||||
adapter_get_path(adapter));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return l->data;
|
||||
}
|
||||
|
||||
static sdp_record_t *server_record_new(uuid_t *uuid, uint16_t start, uint16_t end)
|
||||
{
|
||||
sdp_list_t *svclass_id, *apseq, *proto[2], *root, *aproto;
|
||||
@ -1080,15 +1059,27 @@ static gint channel_id_cmp(gconstpointer data, gconstpointer user_data)
|
||||
return channel->id - id;
|
||||
}
|
||||
|
||||
gboolean attrib_channel_detach(guint id)
|
||||
gboolean attrib_channel_detach(GAttrib *attrib, guint id)
|
||||
{
|
||||
struct gatt_server *server;
|
||||
struct gatt_channel *channel;
|
||||
GError *gerr = NULL;
|
||||
GIOChannel *io;
|
||||
bdaddr_t src;
|
||||
GSList *l;
|
||||
|
||||
DBG("Deprecated function");
|
||||
io = g_attrib_get_channel(attrib);
|
||||
|
||||
server = get_default_gatt_server();
|
||||
bt_io_get(io, BT_IO_L2CAP, &gerr, BT_IO_OPT_SOURCE_BDADDR, &src,
|
||||
BT_IO_OPT_INVALID);
|
||||
|
||||
if (gerr != NULL) {
|
||||
error("bt_io_get: %s", gerr->message);
|
||||
g_error_free(gerr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
server = find_gatt_server(&src);
|
||||
if (server == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -36,4 +36,4 @@ uint32_t attrib_create_sdp(struct btd_adapter *adapter, uint16_t handle,
|
||||
const char *name);
|
||||
void attrib_free_sdp(uint32_t sdp_handle);
|
||||
guint attrib_channel_attach(GAttrib *attrib, gboolean out);
|
||||
gboolean attrib_channel_detach(guint id);
|
||||
gboolean attrib_channel_detach(GAttrib *attrib, guint id);
|
||||
|
@ -1730,7 +1730,7 @@ static void attrib_disconnected(gpointer user_data)
|
||||
|
||||
g_slist_foreach(device->attios, attio_disconnected, NULL);
|
||||
|
||||
attrib_channel_detach(device->attachid);
|
||||
attrib_channel_detach(device->attrib, device->attachid);
|
||||
g_attrib_unref(device->attrib);
|
||||
device->attrib = NULL;
|
||||
|
||||
@ -1779,7 +1779,7 @@ static void primary_cb(GSList *services, guint8 status, gpointer user_data)
|
||||
device_probe_drivers(device, uuids);
|
||||
|
||||
if (device->attios == NULL && device->attios_offline == NULL) {
|
||||
attrib_channel_detach(device->attachid);
|
||||
attrib_channel_detach(device->attrib, device->attachid);
|
||||
g_attrib_unref(device->attrib);
|
||||
device->attrib = NULL;
|
||||
} else
|
||||
@ -2865,7 +2865,7 @@ gboolean btd_device_remove_attio_callback(struct btd_device *device, guint id)
|
||||
return TRUE;
|
||||
|
||||
if (device->attachid) {
|
||||
attrib_channel_detach(device->attachid);
|
||||
attrib_channel_detach(device->attrib, device->attachid);
|
||||
device->attachid = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user