Skip to contentSkip to conversation

Show all the possibly known devices

PATCH In review Bastien Nocera 2 participants 2 messages Mar 6, 2008 – Mar 7, 2008 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Show all the possibly known devices

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

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

client.c +25 -18
diff -u -p -u -p -r1.42 client.c
@@ -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

-------------------------------------------------------------------------
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 6 lines

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.

it did some modification to the patch to honor the 80 characters width requirement :)

Other than that, the patch has been applied.

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