| From 83c36231418f9deff7ba16ceb0ead5d63e177a04 Mon Sep 17 00:00:00 2001 |
| From: Scott James Remnant <scott@netsplit.com> |
| Date: Tue, 24 Jan 2012 10:30:53 -0800 |
| Subject: [PATCH 10/13] plugin: Add bonding callback support for plugins |
| |
| Allow plugins to register a bonding callback on a device, this will be |
| called on completion or cancellation of a bonding attempt on that |
| device and allow retrying of the bonding attempt. |
| |
| These callbacks will only be called once, in the case of retrying the |
| callback must be registered again separately from another callback |
| (e.g. the pincode callback). |
| --- |
| src/device.c | 17 +++++++++++++++++ |
| src/device.h | 8 ++++++++ |
| 2 files changed, 25 insertions(+), 0 deletions(-) |
| |
| diff --git a/src/device.c b/src/device.c |
| index 9d4517f..9a62eef 100644 |
| --- a/src/device.c |
| +++ b/src/device.c |
| @@ -144,6 +144,7 @@ struct btd_device { |
| GSList *primaries; /* List of primary services */ |
| GSList *drivers; /* List of device drivers */ |
| GSList *watches; /* List of disconnect_data */ |
| + GSList *bonding_callbacks; /* List of bonding callbacks */ |
| gboolean temporary; |
| struct agent *agent; |
| guint disconn_timer; |
| @@ -264,6 +265,8 @@ static void device_free(gpointer user_data) |
| g_slist_free_full(device->attios, g_free); |
| g_slist_free_full(device->attios_offline, g_free); |
| |
| + g_slist_free(device->bonding_callbacks); |
| + |
| att_cleanup(device); |
| |
| if (device->tmp_records) |
| @@ -2476,6 +2479,20 @@ static void device_auth_req_free(struct btd_device *device) |
| device->authr = NULL; |
| } |
| |
| +void btd_device_register_bonding_cb(struct btd_device *device, |
| + btd_device_bonding_cb_t cb) |
| +{ |
| + device->bonding_callbacks = g_slist_prepend( |
| + device->bonding_callbacks, cb); |
| +} |
| + |
| +void btd_device_unregister_bonding_cb(struct btd_device *device, |
| + btd_device_bonding_cb_t cb) |
| +{ |
| + device->bonding_callbacks = g_slist_remove( |
| + device->bonding_callbacks, cb); |
| +} |
| + |
| gboolean device_is_retrying(struct btd_device *device) |
| { |
| struct bonding_req *bonding = device->bonding; |
| diff --git a/src/device.h b/src/device.h |
| index b957ad6..ce8675b 100644 |
| --- a/src/device.h |
| +++ b/src/device.h |
| @@ -103,6 +103,14 @@ guint device_add_disconnect_watch(struct btd_device *device, |
| void device_remove_disconnect_watch(struct btd_device *device, guint id); |
| void device_set_class(struct btd_device *device, uint32_t value); |
| |
| +typedef gboolean (*btd_device_bonding_cb_t) (struct btd_device *device, |
| + gboolean complete, uint8_t status); |
| + |
| +void btd_device_register_bonding_cb(struct btd_device *dev, |
| + btd_device_bonding_cb_t cb); |
| +void btd_device_unregister_bonding_cb(struct btd_device *dev, |
| + btd_device_bonding_cb_t cb); |
| + |
| #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } ) |
| |
| struct btd_device_driver { |
| -- |
| 1.7.7.3 |
| |