[gnome-bluetooth] lib: Add helper to remove a device from known devices



commit 2fc6f91c4dff4f9f672ffb349cdd4fd0864748dd
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Sep 27 15:45:05 2011 +0100

    lib: Add helper to remove a device from known devices

 lib/bluetooth-client-private.h |    2 ++
 lib/bluetooth-client.c         |   35 +++++++++++++++++++++++++++++++++++
 lib/gnome-bluetooth.symbols    |    1 +
 3 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/lib/bluetooth-client-private.h b/lib/bluetooth-client-private.h
index 7172900..44c2fbc 100644
--- a/lib/bluetooth-client-private.h
+++ b/lib/bluetooth-client-private.h
@@ -48,6 +48,8 @@ typedef void (*BluetoothClientCreateDeviceFunc) (BluetoothClient *client,
 gboolean bluetooth_client_create_device(BluetoothClient *client,
 			const char *address, const char *agent,
 			BluetoothClientCreateDeviceFunc func, gpointer data);
+gboolean bluetooth_client_remove_device (BluetoothClient *client,
+					 const char      *address);
 
 gboolean bluetooth_client_set_trusted(BluetoothClient *client,
 					const char *device, gboolean trusted);
diff --git a/lib/bluetooth-client.c b/lib/bluetooth-client.c
index c7daa83..176a552 100644
--- a/lib/bluetooth-client.c
+++ b/lib/bluetooth-client.c
@@ -1553,6 +1553,41 @@ gboolean bluetooth_client_create_device (BluetoothClient *client,
 	return TRUE;
 }
 
+gboolean bluetooth_client_remove_device (BluetoothClient *client,
+					 const char      *address)
+{
+	BluetoothClientPrivate *priv = BLUETOOTH_CLIENT_GET_PRIVATE(client);
+	GtkTreeIter iter;
+	DBusGProxy *adapter, *device;
+	GError *err = NULL;
+
+	adapter = bluetooth_client_get_default_adapter(client);
+	if (adapter == NULL)
+		return FALSE;
+
+	if (get_iter_from_address(priv->store, &iter, address, adapter) == FALSE)
+		return FALSE;
+
+	gtk_tree_model_get (GTK_TREE_MODEL(priv->store), &iter,
+			    BLUETOOTH_COLUMN_PROXY, &device, -1);
+	if (device == NULL)
+		return FALSE;
+
+	if (dbus_g_proxy_call (adapter, "RemoveDevice", &err,
+			       DBUS_TYPE_G_OBJECT_PATH, dbus_g_proxy_get_path (device),
+			       G_TYPE_INVALID, G_TYPE_INVALID) == FALSE) {
+		g_object_unref (device);
+		g_warning ("Failed to remove device '%s': %s", address,
+			   err->message);
+		g_error_free (err);
+		return FALSE;
+	}
+
+	g_object_unref (device);
+
+	return TRUE;
+}
+
 gboolean bluetooth_client_set_trusted(BluetoothClient *client,
 					const char *device, gboolean trusted)
 {
diff --git a/lib/gnome-bluetooth.symbols b/lib/gnome-bluetooth.symbols
index 50aa5c8..66f2dec 100644
--- a/lib/gnome-bluetooth.symbols
+++ b/lib/gnome-bluetooth.symbols
@@ -26,6 +26,7 @@ bluetooth_client_get_model
 bluetooth_client_get_filter_model
 bluetooth_client_get_adapter_model
 bluetooth_client_get_device_model
+bluetooth_client_remove_device
 bluetooth_class_to_type
 bluetooth_type_to_string
 bluetooth_verify_address



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