[gnome-bluetooth] Bug 579293 – Simplify BluetoothClient



commit c18145baf8b77a5492c5d09e0098f0f2ede59388
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Apr 27 11:23:05 2009 +0100

    Bug 579293 â?? Simplify BluetoothClient
    
    Remove work-arounds for bluetoothd bugs, and use the adapter's
    Devices property instead of calling ListDevices by hand.
    (Closes: #579293)
---
 README                      |    2 +-
 common/bluetooth-client.c   |   66 ++++++-------------------------------------
 common/bluetooth-client.xml |    4 --
 3 files changed, 10 insertions(+), 62 deletions(-)

diff --git a/README b/README
index 696b363..a1fe094 100644
--- a/README
+++ b/README
@@ -21,7 +21,7 @@ Requirements
 
 - GLib (with GIO), GTK+, GConf, dbus-glib, libhal
 - libunique and libnotify
-- BlueZ 4.34 is absolutely required
+- BlueZ 4.36 is absolutely required
 - obexd or obex-data-server is required for bluetooth-sendto to work
 
 Copyright
diff --git a/common/bluetooth-client.c b/common/bluetooth-client.c
index 2f79213..f8ab9dd 100644
--- a/common/bluetooth-client.c
+++ b/common/bluetooth-client.c
@@ -681,58 +681,7 @@ static void adapter_changed(DBusGProxy *adapter, const char *property,
 	if (get_iter_from_proxy(priv->store, &iter, adapter) == FALSE)
 		return;
 
-	if (g_str_equal (property, "Powered") == TRUE) {
-		GHashTable *hash;
-		const gchar *address, *name;
-		gboolean discovering, powered;
-		GPtrArray *array;
-
-		/* Need to update those properties! */
-		adapter_get_properties(adapter, &hash, NULL);
-		if (hash != NULL) {
-			gboolean is_default;
-
-			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;
-
-			value = g_hash_table_lookup(hash, "Powered");
-			powered = 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,
-					   BLUETOOTH_COLUMN_POWERED, powered,
-					   -1);
-			notify = TRUE;
-
-			/* Update the power setting */
-			gtk_tree_model_get(GTK_TREE_MODEL (priv->store), &iter,
-					   BLUETOOTH_COLUMN_DEFAULT, &is_default,
-					   -1);
-			if (is_default) {
-				priv->default_adapter_powered = powered;
-				g_object_notify (G_OBJECT (client), "default-adapter-powered");
-			}
-
-			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) {
+	if (g_str_equal(property, "Name") == TRUE) {
 		const gchar *name = g_value_get_string(value);
 
 		gtk_tree_store_set(priv->store, &iter,
@@ -762,7 +711,7 @@ static void adapter_added(DBusGProxy *manager,
 	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
 	GtkTreeIter iter;
 	DBusGProxy *adapter;
-	GPtrArray *array = NULL;
+	GPtrArray *devices;
 	GHashTable *hash = NULL;
 	GValue *value;
 	const gchar *address, *name;
@@ -786,11 +735,15 @@ static void adapter_added(DBusGProxy *manager,
 
 		value = g_hash_table_lookup(hash, "Powered");
 		powered = value ? g_value_get_boolean(value) : FALSE;
+
+		value = g_hash_table_lookup(hash, "Devices");
+		devices = value ? g_value_get_boxed (value) : NULL;
 	} else {
 		address = NULL;
 		name = NULL;
 		discovering = FALSE;
 		powered = FALSE;
+		devices = NULL;
 	}
 
 	gtk_tree_store_insert_with_values(priv->store, &iter, NULL, -1,
@@ -821,12 +774,11 @@ static void adapter_added(DBusGProxy *manager,
 	dbus_g_proxy_connect_signal(adapter, "DeviceFound",
 				G_CALLBACK(device_found), client, NULL);
 
-	adapter_list_devices(adapter, &array, NULL);
-	if (array != NULL) {
+	if (devices != NULL) {
 		int i;
 
-		for (i = 0; i < array->len; i++) {
-			gchar *path = g_ptr_array_index(array, i);
+		for (i = 0; i < devices->len; i++) {
+			gchar *path = g_ptr_array_index(devices, i);
 			device_created(adapter, path, client);
 			g_free(path);
 		}
diff --git a/common/bluetooth-client.xml b/common/bluetooth-client.xml
index 0ba30b9..2326277 100644
--- a/common/bluetooth-client.xml
+++ b/common/bluetooth-client.xml
@@ -21,10 +21,6 @@
       <arg type="a{sv}" direction="out"/>
     </method>
 
-    <method name="ListDevices">
-      <arg type="ao" direction="out"/>
-    </method>
-
     <method name="StartDiscovery">
     </method>
 



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