input/hog: Use .accept and .disconnect instead of attio
This adds .accept and .disconnect callbacks instead of attio which
is deprecated.
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index a934c62..b254379 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -69,24 +69,6 @@
static gboolean suspend_supported = FALSE;
static struct queue *devices = NULL;
-static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
-{
- struct hog_device *dev = user_data;
-
- DBG("HoG connected");
-
- bt_hog_attach(dev->hog, attrib);
-}
-
-static void attio_disconnected_cb(gpointer user_data)
-{
- struct hog_device *dev = user_data;
-
- DBG("HoG disconnected");
-
- bt_hog_detach(dev->hog);
-}
-
static struct hog_device *hog_device_new(struct btd_device *device,
struct gatt_primary *prim)
{
@@ -115,15 +97,6 @@
dev->device = btd_device_ref(device);
- /*
- * TODO: Remove attio callback and use .accept once using
- * bt_gatt_client.
- */
- dev->attioid = btd_device_add_attio_callback(device,
- attio_connected_cb,
- attio_disconnected_cb,
- dev);
-
if (!devices)
devices = queue_new();
@@ -142,7 +115,6 @@
devices = NULL;
}
- btd_device_remove_attio_callback(dev->device, dev->attioid);
btd_device_unref(dev->device);
bt_hog_unref(dev->hog);
free(dev);
@@ -215,11 +187,39 @@
hog_device_free(dev);
}
+static int hog_accept(struct btd_service *service)
+{
+ struct hog_device *dev = btd_service_get_user_data(service);
+ struct btd_device *device = btd_service_get_device(service);
+ GAttrib *attrib = btd_device_get_attrib(device);
+
+ /* TODO: Replace GAttrib with bt_gatt_client */
+ bt_hog_attach(dev->hog, attrib);
+
+ btd_service_connecting_complete(service, 0);
+
+ return 0;
+}
+
+static int hog_disconnect(struct btd_service *service)
+{
+ struct hog_device *dev = btd_service_get_user_data(service);
+
+ bt_hog_detach(dev->hog);
+
+ btd_service_disconnecting_complete(service, 0);
+
+ return 0;
+}
+
static struct btd_profile hog_profile = {
.name = "input-hog",
.remote_uuid = HOG_UUID,
.device_probe = hog_probe,
.device_remove = hog_remove,
+ .accept = hog_accept,
+ .disconnect = hog_disconnect,
+ .auto_connect = true,
};
static int hog_init(void)
diff --git a/src/device.c b/src/device.c
index fcb2378..8a66a3c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5935,6 +5935,14 @@
return device->client;
}
+void *btd_device_get_attrib(struct btd_device *device)
+{
+ if (!device)
+ return NULL;
+
+ return device->attrib;
+}
+
struct bt_gatt_server *btd_device_get_gatt_server(struct btd_device *device)
{
if (!device)
diff --git a/src/device.h b/src/device.h
index db10827..387f598 100644
--- a/src/device.h
+++ b/src/device.h
@@ -70,6 +70,7 @@
struct gatt_db *btd_device_get_gatt_db(struct btd_device *device);
struct bt_gatt_client *btd_device_get_gatt_client(struct btd_device *device);
struct bt_gatt_server *btd_device_get_gatt_server(struct btd_device *device);
+void *btd_device_get_attrib(struct btd_device *device);
void btd_device_gatt_set_service_changed(struct btd_device *device,
uint16_t start, uint16_t end);
bool device_attach_att(struct btd_device *dev, GIOChannel *io);