[gnome-bluetooth] wizard: Work-around remote-initiated pairing race
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] wizard: Work-around remote-initiated pairing race
- Date: Wed, 27 Nov 2013 14:27:57 +0000 (UTC)
commit fda705e7751d18ca744eccbbd37fbdee67f27efd
Author: Bastien Nocera <hadess hadess net>
Date: Wed Nov 27 14:34:26 2013 +0100
wizard: Work-around remote-initiated pairing race
When the TomTom Remote is trying to pair with us, the management
event with callback pin_code_request_callback() is getting called
before the mgmt event with callback connected_callback()
and the Class of device isn't set the first time we're asked for
a pincode.
Instead, wait for 1/2 second, as with a human user before replying
with the PIN code. This means that we'll get the connected event
processed, the class will be updated, and we can reply with the
actual PIN code we want to use.
wizard/main.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/wizard/main.c b/wizard/main.c
index fc930dc..7647cdd 100644
--- a/wizard/main.c
+++ b/wizard/main.c
@@ -76,6 +76,8 @@ static gboolean legacypairing = FALSE;
static gboolean create_started = FALSE;
static gboolean display_called = FALSE;
+static guint pincode_cb_id = 0;
+
/* NULL means automatic, anything else is a pincode specified by the user */
static gchar *user_pincode = NULL;
@@ -237,10 +239,11 @@ update_user_pincode (void)
}
static gboolean
-pincode_callback (GDBusMethodInvocation *invocation,
- GDBusProxy *device,
- gpointer user_data)
+pincode_callback_timeout_cb (gpointer user_data)
{
+ GDBusMethodInvocation *invocation = user_data;
+ GDBusProxy *device = g_object_get_data (G_OBJECT (invocation), "device");
+
create_started = TRUE;
replace_target_properties_for_device (device);
update_user_pincode ();
@@ -305,6 +308,19 @@ pincode_callback (GDBusMethodInvocation *invocation,
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(s)", user_pincode));
+ pincode_cb_id = 0;
+
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean
+pincode_callback (GDBusMethodInvocation *invocation,
+ GDBusProxy *device,
+ gpointer user_data)
+{
+ g_assert (pincode_cb_id == 0);
+ g_object_set_data_full (G_OBJECT (invocation), "device", g_object_ref (device), g_object_unref);
+ pincode_cb_id = g_timeout_add (500, pincode_callback_timeout_cb, invocation);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]