[gnome-bluetooth] wizard: fix pairing for devices with a pin in the DB



commit 1972a067d1ab8d30f1024207e6b091def04954f8
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Mar 14 11:35:39 2012 -0400

    wizard: fix pairing for devices with a pin in the DB
    
    As far as I understand the intention of the code here is to set
    automatic_pincode to FALSE if the DB detects it needs a special code
    (e.g. keyboards or joysticks); otherwise if a pincode is specified in
    the DB, that one should be used instead of being discarded.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672077

 wizard/main.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/wizard/main.c b/wizard/main.c
index 93423cd..b54c915 100644
--- a/wizard/main.c
+++ b/wizard/main.c
@@ -714,6 +714,7 @@ select_device_changed (BluetoothChooser *selector,
 {
 	GValue value = { 0, };
 	guint target_type = BLUETOOTH_TYPE_ANY;
+	gboolean is_custom_pin = FALSE;
 	int legacypairing;
 
 	if (gtk_assistant_get_current_page (GTK_ASSISTANT (window_assistant)) != PAGE_SEARCH)
@@ -751,14 +752,25 @@ select_device_changed (BluetoothChooser *selector,
 	user_pincode = get_pincode_for_device (target_type, target_address, target_name, &target_max_digits);
 	if (user_pincode != NULL &&
 	    g_str_equal (user_pincode, "NULL") == FALSE) {
-		if (g_str_equal (user_pincode, "KEYBOARD"))
+		if (g_str_equal (user_pincode, "KEYBOARD")) {
 			target_ui_behaviour = PAIRING_UI_KEYBOARD;
-		else if (g_str_equal (user_pincode, "ICADE"))
+			is_custom_pin = TRUE;
+		} else if (g_str_equal (user_pincode, "ICADE")) {
 			target_ui_behaviour = PAIRING_UI_ICADE;
-		g_free (user_pincode);
-		user_pincode = NULL;
+			is_custom_pin = TRUE;
+		} else {
+			pincode = g_strdup (user_pincode);
+		}
 	}
-	automatic_pincode = user_pincode != NULL;
+
+	if (is_custom_pin)
+		automatic_pincode = FALSE;
+	else
+		automatic_pincode = user_pincode != NULL;
+
+	g_free (user_pincode);
+	user_pincode = NULL;
+
 	gtk_entry_set_max_length (GTK_ENTRY (entry_custom), target_max_digits);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]