This patch unblocks a device when removing it. Adds boolean argument to function device_unblock to only emit property changed signal and probe drivers when unblocking a device if the device is not unblocked as part of being removed. /Daniel
From 5da37821d8bcf47d0734e7d7aaa27d81c9102380 Mon Sep 17 00:00:00 2001 From: Daniel Orstadius <daniel.orstadius@xxxxxxxxx> Date: Mon, 28 Jun 2010 13:45:37 +0300 Subject: [PATCH] Fix unblock removed device Unblocks a device when removing it. Adds boolean argument to function device_unblock to only emit property changed signal and probe drivers when unblocking a device if the device is not unblocked as part of being removed. --- src/device.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/device.c b/src/device.c index 11b1fd2..6deb4a2 100644 --- a/src/device.c +++ b/src/device.c @@ -513,7 +513,7 @@ static int device_block(DBusConnection *conn, struct btd_device *device) return 0; } -static int device_unblock(DBusConnection *conn, struct btd_device *device) +static int device_unblock(DBusConnection *conn, struct btd_device *device, gboolean silent) { int dev_id, dd, err; bdaddr_t src; @@ -543,10 +543,12 @@ static int device_unblock(DBusConnection *conn, struct btd_device *device) if (err < 0) error("write_blocked(): %s (%d)", strerror(-err), -err); - emit_property_changed(conn, device->path, DEVICE_INTERFACE, "Blocked", - DBUS_TYPE_BOOLEAN, &device->blocked); + if (!silent) { + emit_property_changed(conn, device->path, DEVICE_INTERFACE, "Blocked", + DBUS_TYPE_BOOLEAN, &device->blocked); - device_probe_drivers(device, device->uuids); + device_probe_drivers(device, device->uuids); + } return 0; } @@ -560,7 +562,7 @@ static DBusMessage *set_blocked(DBusConnection *conn, DBusMessage *msg, if (value) err = device_block(conn, device); else - err = device_unblock(conn, device); + err = device_unblock(conn, device, FALSE); switch (-err) { case 0: @@ -1100,6 +1102,7 @@ static void device_remove_stored(struct btd_device *device) { bdaddr_t src; char addr[18]; + DBusConnection *conn = get_dbus_connection(); adapter_get_address(device->adapter, &src); ba2str(&device->bdaddr, addr); @@ -1109,6 +1112,9 @@ static void device_remove_stored(struct btd_device *device) delete_entry(&src, "profiles", addr); delete_entry(&src, "trusts", addr); delete_all_records(&src, &device->bdaddr); + + if (device->blocked) + device_unblock(conn, device, TRUE); } void device_remove(struct btd_device *device, gboolean remove_stored) -- 1.6.0.4