[PATCH] Show all the possibly known devices

Bastien Nocera <[email protected]>
Newsgroups gmane.linux.bluez.devel
Message-ID <[email protected]>
Heya,

This patch makes the default client.c show all the known devices,
including the seen remote devices. Those can be easily filtered using
the drop-downs at the bottom of the dialogue.

It also doesn't query remotely to avoid problems with asking for a name
for a device we don't know about anymore.

Cheers

-------------------------------------------------------------------------
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
bluez-gnome-device-selection-show-all-devices.patch (text/x-patch, 3.3 KB)
Index: client.c
===================================================================
RCS file: /cvsroot/bluez/gnome/common/client.c,v
retrieving revision 1.42
diff -u -p -u -p -r1.42 client.c
--- client.c	6 Mar 2008 10:54:29 -0000	1.42
+++ client.c	6 Mar 2008 15:45:35 -0000
@@ -204,7 +204,8 @@ static guint class_to_type(guint32 class
 
 static void insert_device(DBusGProxy *object, GtkTreeIter *parent,
 			BluetoothClient *client,
-			const char *address, const int rssi, gboolean active)
+			const char *address, const int rssi, gboolean active,
+			gboolean remote_lookup)
 {
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
@@ -223,20 +224,28 @@ static void insert_device(DBusGProxy *ob
 				&hash, G_TYPE_INVALID);
 
 	value = (hash == NULL) ? NULL : g_hash_table_lookup(hash, "name");
-	if (value == NULL)
-		dbus_g_proxy_call(object, "GetRemoteName", NULL,
-				G_TYPE_STRING, address, G_TYPE_INVALID,
-				G_TYPE_STRING, &name, G_TYPE_INVALID);
-	else
+	if (value == NULL) {
+		if (remote_lookup) {
+			dbus_g_proxy_call(object, "GetRemoteName", NULL,
+					  G_TYPE_STRING, address, G_TYPE_INVALID,
+					  G_TYPE_STRING, &name, G_TYPE_INVALID);
+		} else {
+			name = g_strdup(address);
+		}
+	} else {
 		name = g_value_get_string(value);
+	}
 
 	value = (hash == NULL) ? NULL : g_hash_table_lookup(hash, "class");
-	if (value == NULL)
-		dbus_g_proxy_call(object, "GetRemoteClass", NULL,
-				G_TYPE_STRING, address, G_TYPE_INVALID,
-				G_TYPE_UINT, &class, G_TYPE_INVALID);
-	else
+	if (value == NULL) {
+		if (remote_lookup) {
+			dbus_g_proxy_call(object, "GetRemoteClass", NULL,
+					  G_TYPE_STRING, address, G_TYPE_INVALID,
+					  G_TYPE_UINT, &class, G_TYPE_INVALID);
+		}
+	} else {
 		class = g_value_get_uint(value);
+	}
 
 	value = (hash == NULL) ? NULL : g_hash_table_lookup(hash, "bonded");
 	if (value == NULL)
@@ -447,7 +456,7 @@ static void device_found(DBusGProxy *obj
 	if (find_iter_for_object(object, BLUETOOTH_CLIENT(user_data), &iter) == FALSE)
 		return;
 
-	insert_device(object, &iter, BLUETOOTH_CLIENT(user_data), address, rssi, TRUE);
+	insert_device(object, &iter, BLUETOOTH_CLIENT(user_data), address, rssi, TRUE, TRUE);
 }
 
 static void device_disappeared(DBusGProxy *object,
@@ -567,7 +576,7 @@ static void update_adapter(DBusGProxy *o
 
 	if (error == NULL) {
 		while (*array) {
-			insert_device(object, iter, client, *array, 0, FALSE);
+			insert_device(object, iter, client, *array, 0, FALSE, TRUE);
 			array++;
 		}
 	} else {
@@ -580,7 +589,7 @@ static void update_adapter(DBusGProxy *o
 
 	if (error == NULL) {
 		while (*array) {
-			insert_device(object, iter, client, *array, 0, FALSE);
+			insert_device(object, iter, client, *array, 0, FALSE, FALSE);
 			array++;
 		}
 	} else {
@@ -593,7 +602,7 @@ static void update_adapter(DBusGProxy *o
 
 	if (error == NULL) {
 		while (*array) {
-			insert_device(object, iter, client, *array, 0, FALSE);
+			insert_device(object, iter, client, *array, 0, FALSE, FALSE);
 			array++;
 		}
 	} else {
@@ -602,14 +611,12 @@ static void update_adapter(DBusGProxy *o
 		goto failover;
 	}
 
-	return;
-
 failover:
 	adapter_list_remote_devices(object, &array, &error);
 
 	if (error == NULL) {
 		while (*array) {
-			insert_device(object, iter, client, *array, 0, FALSE);
+			insert_device(object, iter, client, *array, 0, FALSE, FALSE);
 			array++;
 		}
 	} else
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.