Skip to contentSkip to conversation

Make search button (and discovery) work

PATCH In review Bastien Nocera 2 participants 6 messages Feb 11, 2008 – Feb 12, 2008 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make search button (and discovery) work

Heya,

Seems that some bits of client.c got mistakenly commented. The #endif should be before the call to DiscoverDevices, not after.

So I fixed this up and finished the work to make the search button behave as expected. I guess we should have it by default now.

Cheers

PS: BZ http://bugzilla.gnome.org/show_bug.cgi?id=515784

Index: bluetooth-device-selection.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/bluetooth-device-selection.c,v retrieving revision 1.14

bluetooth-device-selection.c +20 -14
diff -u -p -u -p -r1.14 bluetooth-device-selection.c
@@ -172,7 +172,7 @@ type_to_text (GtkTreeViewColumn *column,
 	guint type;
 
 	gtk_tree_model_get (model, iter, COLUMN_TYPE, &type, -1);
-	if (type == BLUETOOTH_TYPE_ANY)
+	if (type == 0)
 		g_object_set (cell, "text", _("Unknown"), NULL);
 	else
 		g_object_set (cell, "text", bluetooth_type_to_string (type), NULL);
@@ -211,16 +211,24 @@ search_button_clicked (GtkButton *button
 	bluetooth_device_selection_start_discovery (self);
 }
 
-#if 0
 static void
-discoveries_completed (BluetoothClient *client, gpointer user_data)
+discovery_started (BluetoothClient *client, const char *adapter_path, gboolean is_default, gpointer user_data)
 {
 	BluetoothDeviceSelection *self = BLUETOOTH_DEVICE_SELECTION(user_data);
 	BluetoothDeviceSelectionPrivate *priv = BLUETOOTH_DEVICE_SELECTION_GET_PRIVATE(self);
 
-	gtk_widget_set_sensitive (GTK_WIDGET(priv->search_button), TRUE);
+	if (is_default)
+		gtk_widget_set_sensitive (GTK_WIDGET(priv->search_button), FALSE);
+}
+static void
+discovery_completed (BluetoothClient *client, const char *adapter_path, gboolean is_default, gpointer user_data)
+{
+	BluetoothDeviceSelection *self = BLUETOOTH_DEVICE_SELECTION(user_data);
+	BluetoothDeviceSelectionPrivate *priv = BLUETOOTH_DEVICE_SELECTION_GET_PRIVATE(self);
+
+	if (is_default)
+		gtk_widget_set_sensitive (GTK_WIDGET(priv->search_button), TRUE);
 }
-#endif
 
 static void
 select_browse_device_callback (GtkTreeSelection *selection, gpointer user_data)
@@ -245,7 +253,7 @@ filter_type_func (GtkTreeModel *model, G
 		return TRUE;
 
 	gtk_tree_model_get (model, iter, COLUMN_TYPE, &type, -1);
-	return (type == priv->device_type_filter);
+	return (type & priv->device_type_filter);
 }
 
 static gboolean
@@ -285,7 +293,7 @@ filter_type_changed_cb (GtkComboBox *wid
 	BluetoothDeviceSelection *self = BLUETOOTH_DEVICE_SELECTION (data);
 	BluetoothDeviceSelectionPrivate *priv = BLUETOOTH_DEVICE_SELECTION_GET_PRIVATE(self);
 
-	priv->device_type_filter = gtk_combo_box_get_active (GTK_COMBO_BOX(priv->device_type));
+	priv->device_type_filter = 1 << gtk_combo_box_get_active (GTK_COMBO_BOX(priv->device_type));
 	if (priv->filter)
 		gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter));
 	g_object_notify (G_OBJECT(self), "device-type-filter");
@@ -441,10 +449,10 @@ bluetooth_device_selection_init(Bluetoot
 
 	priv->client = bluetooth_client_new ();
 
-#if 0
-	g_signal_connect (G_OBJECT(priv->client), "discoveries-completed",
-			  G_CALLBACK(discoveries_completed), self);
-#endif
+	g_signal_connect (G_OBJECT(priv->client), "discovery-started",
+			  G_CALLBACK(discovery_started), self);
+	g_signal_connect (G_OBJECT(priv->client), "discovery-completed",
+			  G_CALLBACK(discovery_completed), self);
 
 	tooltips = gtk_tooltips_new ();
 
@@ -567,7 +575,7 @@ bluetooth_device_selection_init(Bluetoot
 	/* The types match the types used in client.h */
 	for (i = 0; i < BLUETOOTH_TYPE_NUM_TYPES; i++) {
 		gtk_combo_box_append_text (GTK_COMBO_BOX(priv->device_type),
-					   _(bluetooth_type_to_string (i)));
+					   _(bluetooth_type_to_string (1 << i)));
 	}
 	g_signal_connect (G_OBJECT (priv->device_type), "changed",
 			  G_CALLBACK(filter_type_changed_cb), self);
@@ -579,8 +587,6 @@ bluetooth_device_selection_init(Bluetoot
 
 	g_signal_connect (priv->client, "notify::default-adapter",
 			  G_CALLBACK (default_adapter_changed), self);
-
-	bluetooth_device_selection_start_discovery (self);
 }
 
 static void

Index: client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.40

client.c +82 -32

180 lines not on this page · raw message

Index: client.h
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.h,v
retrieving revision 1.22

client.h +17 -12
diff -u -p -u -p -r1.22 client.h
@@ -52,7 +52,8 @@ struct _BluetoothClient {
 struct _BluetoothClientClass {
 	GObjectClass parent_class;
 
-	void (*discoveries_completed) (BluetoothClient *self);
+	void (*discovery_started) (BluetoothClient *self, const char *adapter_path, gboolean is_default);
+	void (*discovery_completed) (BluetoothClient *self, const char *adapter_path, gboolean is_default);
 };
 
 GType bluetooth_client_get_type(void);
@@ -71,22 +72,26 @@ enum {
 	COLUMN_BONDED,
 	COLUMN_TRUSTED,
 	COLUMN_CONNECTED,
+	COLUMN_DISCOVERING,
+	NUM_COLS
 };
 
 enum {
-	BLUETOOTH_TYPE_ANY,
-	BLUETOOTH_TYPE_PHONE,
-	BLUETOOTH_TYPE_MODEM,
-	BLUETOOTH_TYPE_COMPUTER,
-	BLUETOOTH_TYPE_NETWORK,
-	BLUETOOTH_TYPE_HEADSET,
-	BLUETOOTH_TYPE_KEYBOARD,
-	BLUETOOTH_TYPE_MOUSE,
-	BLUETOOTH_TYPE_CAMERA,
-	BLUETOOTH_TYPE_PRINTER,
-	BLUETOOTH_TYPE_NUM_TYPES
+	BLUETOOTH_TYPE_ANY        = 1,
+	BLUETOOTH_TYPE_PHONE      = 1 << 1,
+	BLUETOOTH_TYPE_MODEM      = 1 << 2,
+	BLUETOOTH_TYPE_COMPUTER   = 1 << 3,
+	BLUETOOTH_TYPE_NETWORK    = 1 << 4,
+	BLUETOOTH_TYPE_HEADSET    = 1 << 5,
+	BLUETOOTH_TYPE_KEYBOARD   = 1 << 6,
+	BLUETOOTH_TYPE_MOUSE      = 1 << 7,
+	BLUETOOTH_TYPE_CAMERA     = 1 << 8,
+	BLUETOOTH_TYPE_PRINTER    = 1 << 9 
 };
 
+#define BLUETOOTH_TYPE_NUM_TYPES 10
+#define BLUETOOTH_TYPE_INPUT (BLUETOOTH_TYPE_KEYBOARD | BLUETOOTH_TYPE_MOUSE)
+
 const gchar *bluetooth_type_to_string(guint type);
 
 gboolean bluetooth_client_register_passkey_agent(BluetoothClient *self,

Index: marshal.list
===================================================================
RCS file: /cvsroot/bluez/gnome/common/marshal.list,v retrieving revision 1.3

marshal.list +1 -0
diff -u -p -u -p -r1.3 marshal.list
@@ -1,4 +1,5 @@
 VOID:STRING,UINT,INT
 VOID:STRING,STRING
+VOID:STRING,BOOLEAN
 VOID:STRING,STRING,UINT64
 VOID:UINT64

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#1 lore raw

Hi Bastien,

Quoted 5 lines

Seems that some bits of client.c got mistakenly commented. The #endif should be before the call to DiscoverDevices, not after.

So I fixed this up and finished the work to make the search button behave as expected. I guess we should have it by default now.

where do you need the extra marshal entry for?

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw
Quoted 9 lines · Marcel Holtmann

Hi Bastien,

Quoted 5 lines

Seems that some bits of client.c got mistakenly commented. The #endif should be before the call to DiscoverDevices, not after.

So I fixed this up and finished the work to make the search button behave as expected. I guess we should have it by default now.

where do you need the extra marshal entry for?

For the client.c signal changes in bluetooth_client_class_init().

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#3 lore raw

Hi Bastien,

Quoted 9 lines
Quoted 7 lines
Quoted 5 lines

Seems that some bits of client.c got mistakenly commented. The #endif should be before the call to DiscoverDevices, not after.

So I fixed this up and finished the work to make the search button behave as expected. I guess we should have it by default now.

where do you need the extra marshal entry for?

For the client.c signal changes in bluetooth_client_class_init().

patch has been applied, but I removed the two g_message calls.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#4 lore raw
Quoted 5 lines · Marcel Holtmann

Hi Bastien,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Seems that some bits of client.c got mistakenly commented. The #endif should be before the call to DiscoverDevices, not after.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

So I fixed this up and finished the work to make the search button behave as expected. I guess we should have it by default now.

where do you need the extra marshal entry for?

For the client.c signal changes in bluetooth_client_class_init().

patch has been applied, but I removed the two g_message calls.

I forgot to mention those were there for debugging, and that they should be removed before commit. I hope they were at least useful for your testing :)

Thanks

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

maintainer
#5 lore raw

Hi Bastien,

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines

Seems that some bits of client.c got mistakenly commented. The #endif should be before the call to DiscoverDevices, not after.

So I fixed this up and finished the work to make the search button behave as expected. I guess we should have it by default now.

where do you need the extra marshal entry for?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

For the client.c signal changes in bluetooth_client_class_init().

patch has been applied, but I removed the two g_message calls.

I forgot to mention those were there for debugging, and that they should be removed before commit. I hope they were at least useful for your testing :)

just fixed a signal issue with it. Noticed only after the 0.19 release.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel