Comment 35 for bug 284994

Revision history for this message
tz (thomas-mich) wrote : Re: [Bug 284994] Re: bluetooth-wizard unable to pair to fixed pin devices

CC-ed from the relevant bug discussion. This is my first GTK program
(at least the original modal dialog), so it is probably horrid, but
solves the problem. I don't know how to integrate it with the wizard
gtk objects (it would require either a new PIN selection page, or
something in the existing page adding a text entry to the label and
something to pause it until something was clicked). It also needs
checking and verification/validation added. If it was in PyGtk I'd do
better.

diff -Bbur bluez-gnome-1.8/wizard/main.c bluez-gnome-1.8-tz/wizard/main.c
--- bluez-gnome-1.8/wizard/main.c 2008-10-04 14:32:56.000000000 -0500
+++ bluez-gnome-1.8-tz/wizard/main.c 2008-11-11 10:54:13.000000000 -0600
@@ -56,6 +56,34 @@

 static GtkTreeSelection *search_selection = NULL;

+static GtkWidget *pinentry, *pindialog;
+static char usepincode[32];
+void clicked()
+{
+ char *text;
+
+ text = gtk_entry_get_text( GTK_ENTRY(pinentry));
+ strcpy( usepincode, text );
+ gtk_widget_destroy( pindialog );
+}
+
+static void run_pin_dialog()
+{
+ GtkWidget *label, *button;
+
+ pindialog = gtk_dialog_new();
+ label = gtk_label_new ("Passkey for Pairing");
+ pinentry = gtk_entry_new ();
+ gtk_entry_set_text( GTK_ENTRY(pinentry),target_pincode );
+ button = gtk_button_new_with_label("Pair");
+ gtk_signal_connect_object(GTK_OBJECT (button), "clicked", clicked , NULL);
+ gtk_container_add (GTK_CONTAINER
(GTK_DIALOG(pindialog)->action_area), button);
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG(pindialog)->vbox), label);
+ gtk_container_add (GTK_CONTAINER (GTK_DIALOG(pindialog)->vbox), pinentry);
+ gtk_widget_show_all (pindialog);
+ gtk_dialog_run( GTK_DIALOG(pindialog) );
+}
+
 static gboolean pincode_callback(DBusGMethodInvocation *context,
      DBusGProxy *device, gpointer user_data)
 {
@@ -72,12 +100,19 @@
     target_type == BLUETOOTH_TYPE_HEADPHONE)
   pincode = "0000";

+
+ target_pincode = pincode;
+
+ strcpy( usepincode, pincode );
+
+ run_pin_dialog();
+
  text = g_strdup_printf(_("Please enter the following PIN code: %s"),
- pincode);
+ usepincode);
  gtk_label_set_markup(GTK_LABEL(label_passkey), text);
  g_free(text);

- dbus_g_method_return(context, pincode);
+ dbus_g_method_return(context, usepincode);

  return TRUE;
 }

On Tue, Nov 11, 2008 at 9:11 AM, tz <email address hidden> wrote:
> I wrote a followup - a web page for every owner of a bluetooth device
> that needs a special PIN that would submit it as a new bug report is
> possible...
>
> Perhaps Ubuntu can write its own patch - it looks simple enough but I
> would need time to add the panel (I've only done Gtk in Python).
>
> The short answer is it cannot be hardcoded which is why every other
> implementation (e.g. my Nokia tablet, or even my phone) doesn't do so.
> They typicall present something random but editable.
>
> On Tue, Nov 11, 2008 at 8:23 AM, spaetz <email address hidden> wrote:
>> I must say I find the upstream reaction rather less helpful and optimal.
>> (http://bugzilla.gnome.org/show_bug.cgi?id=560315#c5)
>>
>> bluez-gnome seems to intent to special case each non-keyboard device in
>> their source code rather than just allowing people to enter a fixed PIN
>> in the wizard. Hardcoding the stuff is bound to lag behind existing
>> devices and seems a rather bloaty solution to me. Most of the time
>> people would know best whether to use 1234 or 0000 or somesuch.
>> Whatever.
>>
>> As a consequence, I stop caring about upstream and work around this with
>> a custom shell script.
>>
>> --
>> bluetooth-wizard unable to pair to fixed pin devices
>> https://bugs.launchpad.net/bugs/284994
>> You received this bug notification because you are a direct subscriber
>> of the bug.
>>
>