gnome-bluetooth r343 - trunk/common



Author: hadess
Date: Wed Feb 25 14:41:45 2009
New Revision: 343
URL: http://svn.gnome.org/viewvc/gnome-bluetooth?rev=343&view=rev

Log:
Fix empty device selection in some cases

When the adapter is added, we get its details straight away, but
it hasn't been powered up yet, so the address and name are all
wrong. We need to update its data (and get the children devices) when
the Powered property changes to TRUE.

Modified:
   trunk/common/bluetooth-client.c

Modified: trunk/common/bluetooth-client.c
==============================================================================
--- trunk/common/bluetooth-client.c	(original)
+++ trunk/common/bluetooth-client.c	Wed Feb 25 14:41:45 2009
@@ -475,7 +475,41 @@
 	if (get_iter_from_proxy(priv->store, &iter, adapter) == FALSE)
 		return;
 
-	if (g_str_equal(property, "Name") == TRUE) {
+	if (g_str_equal (property, "Powered") == TRUE) {
+		GHashTable *hash;
+		const gchar *address, *name;
+		gboolean discovering;
+		GPtrArray *array;
+
+		/* Need to update those properties! */
+		adapter_get_properties(adapter, &hash, NULL);
+		if (hash != NULL) {
+			value = g_hash_table_lookup(hash, "Address");
+			address = value ? g_value_get_string(value) : NULL;
+
+			value = g_hash_table_lookup(hash, "Name");
+			name = value ? g_value_get_string(value) : NULL;
+
+			value = g_hash_table_lookup(hash, "Discovering");
+			discovering = value ? g_value_get_boolean(value) : FALSE;
+
+			gtk_tree_store_set(priv->store, &iter,
+					   BLUETOOTH_COLUMN_ADDRESS, address,
+					   BLUETOOTH_COLUMN_NAME, name,
+					   BLUETOOTH_COLUMN_DISCOVERING, discovering, -1);
+
+			adapter_list_devices(adapter, &array, NULL);
+			if (array != NULL) {
+				int i;
+
+				for (i = 0; i < array->len; i++) {
+					gchar *path = g_ptr_array_index(array, i);
+					device_created(adapter, path, client);
+					g_free(path);
+				}
+			}
+		}
+	} else if (g_str_equal(property, "Name") == TRUE) {
 		const gchar *name = g_value_get_string(value);
 
 		gtk_tree_store_set(priv->store, &iter,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]