--- properties/input.c~ 2008-02-05 15:55:17.000000000 -0500 +++ properties/input.c 2008-05-16 20:58:21.000000000 -0400 @@ -50,17 +50,13 @@ DBusGProxyCall *call, void *user_data) { GtkWidget *notebook = user_data; - GtkWidget *button; - GtkWidget *label; - DBusGProxy *client; - const char *path, *busname; + GtkWidget *button = NULL; + GtkWidget *label = NULL; + DBusGProxy *client = NULL; + const char *path = NULL, *busname = NULL; const char *adapter = NULL, *address = NULL, *name = NULL; - gchar *text; - - g_object_set_data(G_OBJECT(notebook), "call", NULL); - - dbus_g_proxy_end_call(proxy, call, NULL, - G_TYPE_STRING, &path, G_TYPE_INVALID); + gchar *text = NULL; + GError* error = NULL; button = g_object_get_data(G_OBJECT(notebook), "cancel"); gtk_widget_hide(button); @@ -68,6 +64,25 @@ button = g_object_get_data(G_OBJECT(notebook), "close"); gtk_widget_set_sensitive(button, TRUE); + g_object_set_data(G_OBJECT(notebook), "call", NULL); + + if (!dbus_g_proxy_end_call(proxy, call, &error, + G_TYPE_STRING, &path, G_TYPE_INVALID)) { + g_assert(NULL != error); + + label = g_object_get_data(G_OBJECT(notebook), "label"); + text = g_strdup_printf("Connection failed with message:" + " %s", error->message); + gtk_label_set_markup(GTK_LABEL(label), text); + + g_free(text); + g_error_free(error); + + return; + } + /* else, the connection succeeded */ + g_assert(NULL != path); + busname = dbus_g_proxy_get_bus_name(proxy); client = dbus_g_proxy_new_for_name(connection, busname, @@ -97,8 +112,14 @@ { DBusGProxyCall *call; - call = dbus_g_proxy_begin_call(manager, "CreateSecureDevice", + /* TODO: Dynamically set the timeout to be equal to 1 + the maximum + timout of a bluetooth authentication handshake, so that the returned + error message is always the message that bluetooth authentication + failed, rather than the generic dbus timeout message. */ + call = dbus_g_proxy_begin_call_with_timeout(manager, + "CreateSecureDevice", proxy_callback, user_data, NULL, + 300000, /* 5 minutes */ G_TYPE_STRING, address, G_TYPE_INVALID); g_object_set_data(G_OBJECT(user_data), "call", call);