[gnome-bluetooth] settings: Verify pincodes passed to DisplayPinCode
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] settings: Verify pincodes passed to DisplayPinCode
- Date: Wed, 11 Dec 2013 13:21:32 +0000 (UTC)
commit 581eadf5f93b362ab7fe9348ac1dae642c1e417f
Author: Bastien Nocera <hadess hadess net>
Date: Wed Dec 11 13:58:20 2013 +0100
settings: Verify pincodes passed to DisplayPinCode
So that we can avoid showing a PIN that will not need to be entered.
lib/bluetooth-settings-widget.c | 39 ++++++++++++++++++++++++++++++++++++---
1 files changed, 36 insertions(+), 3 deletions(-)
---
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index eb2392e..b022d7e 100644
--- a/lib/bluetooth-settings-widget.c
+++ b/lib/bluetooth-settings-widget.c
@@ -500,12 +500,14 @@ display_pincode_callback (GDBusMethodInvocation *invocation,
{
BluetoothSettingsWidget *self = user_data;
BluetoothSettingsWidgetPrivate *priv = BLUETOOTH_SETTINGS_WIDGET_GET_PRIVATE (user_data);
- char *display_pin;
- char *name;
+ BluetoothType type;
+ char *display_pin = NULL;
+ char *name, *bdaddr;
+ char *db_pin;
g_debug ("display_pincode_callback (%s, %s)", g_dbus_proxy_get_object_path (device), pincode);
- if (!get_properties_for_device (self, device, &name, NULL, NULL)) {
+ if (!get_properties_for_device (self, device, &name, &bdaddr, &type)) {
char *msg;
msg = g_strdup_printf ("Missing information for %s", g_dbus_proxy_get_object_path (device));
@@ -514,6 +516,34 @@ display_pincode_callback (GDBusMethodInvocation *invocation,
return;
}
+ /* Verify PIN code validity */
+ db_pin = get_pincode_for_device (type,
+ bdaddr,
+ name,
+ NULL,
+ NULL);
+ if (g_strcmp0 (db_pin, "KEYBOARD") == 0) {
+ /* Should work, follow through */
+ } else if (g_strcmp0 (db_pin, "ICADE") == 0) {
+ char *msg;
+
+ msg = g_strdup_printf ("Generated pincode for %s when it shouldn't have", name);
+ g_dbus_method_invocation_return_dbus_error (invocation, "org.bluez.Error.Rejected", msg);
+ g_free (msg);
+ goto bail;
+ } else if (g_strcmp0 (db_pin, "0000") == 0) {
+ g_debug ("Ignoring generated keyboard PIN '%s', should get 0000 soon", pincode);
+ g_dbus_method_invocation_return_value (invocation, NULL);
+ goto bail;
+ } else if (g_strcmp0 (db_pin, "NULL") == 0) {
+ char *msg;
+
+ msg = g_strdup_printf ("Attempting pairing for %s that doesn't support pairing", name);
+ g_dbus_method_invocation_return_dbus_error (invocation, "org.bluez.Error.Rejected", msg);
+ g_free (msg);
+ goto bail;
+ }
+
setup_pairing_dialog (BLUETOOTH_SETTINGS_WIDGET (user_data));
display_pin = g_strdup_printf ("%s⏎", pincode);
@@ -525,7 +555,10 @@ display_pincode_callback (GDBusMethodInvocation *invocation,
g_dbus_method_invocation_return_value (invocation, NULL);
+bail:
+ g_free (db_pin);
g_free (display_pin);
+ g_free (bdaddr);
g_free (name);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]