diff options
-rw-r--r-- | src/adapter.c | 24 | ||||
-rw-r--r-- | src/adapter.h | 1 | ||||
-rw-r--r-- | src/dbus-hci.c | 2 | ||||
-rw-r--r-- | src/device.c | 3 |
4 files changed, 28 insertions, 2 deletions
diff --git a/src/adapter.c b/src/adapter.c index 78990a60..5e6affda 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -1025,6 +1025,7 @@ void adapter_remove_device(DBusConnection *conn, struct btd_adapter *adapter, ba2str(&dst, dstaddr); delete_entry(&adapter->bdaddr, "profiles", dstaddr); + adapter->devices = g_slist_remove(adapter->devices, device); if (!device_is_temporary(device)) { remove_bonding(conn, NULL, dstaddr, adapter); @@ -1034,6 +1035,8 @@ void adapter_remove_device(DBusConnection *conn, struct btd_adapter *adapter, "DeviceRemoved", DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID); + + adapter_update_devices(adapter); } agent = device_get_agent(device); @@ -1043,8 +1046,6 @@ void adapter_remove_device(DBusConnection *conn, struct btd_adapter *adapter, device_set_agent(device, NULL); } - adapter->devices = g_slist_remove(adapter->devices, device); - device_remove(conn, device); } @@ -3156,3 +3157,22 @@ int btd_cancel_authorization(const bdaddr_t *src, const bdaddr_t *dst) return agent_cancel(agent); } + +void adapter_update_devices(struct btd_adapter *adapter) +{ + char **devices; + int i; + GSList *l; + + /* Devices */ + devices = g_new0(char *, g_slist_length(adapter->devices) + 1); + for (i = 0, l = adapter->devices; l; l = l->next, i++) { + struct btd_device *dev = l->data; + devices[i] = (char *) device_get_path(dev); + } + + dbus_connection_emit_property_changed(connection, adapter->path, + ADAPTER_INTERFACE, "Devices", + DBUS_TYPE_ARRAY, &devices); + g_free(devices); +} diff --git a/src/adapter.h b/src/adapter.h index df9a59de..cf61a655 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -151,6 +151,7 @@ void adapter_add_active_conn(struct btd_adapter *adapter, bdaddr_t *bdaddr, uint16_t handle); void adapter_remove_active_conn(struct btd_adapter *adapter, struct active_conn_info *dev); +void adapter_update_devices(struct btd_adapter *adapter); struct active_conn_info *adapter_search_active_conn_by_bdaddr(struct btd_adapter *adapter, bdaddr_t *bda); struct active_conn_info *adapter_search_active_conn_by_handle(struct btd_adapter *adapter, diff --git a/src/dbus-hci.c b/src/dbus-hci.c index 8d5ad1ce..7f142099 100644 --- a/src/dbus-hci.c +++ b/src/dbus-hci.c @@ -554,6 +554,8 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID); + adapter_update_devices(adapter); + dbus_connection_emit_property_changed(connection, dev_path, DEVICE_INTERFACE, "Paired", DBUS_TYPE_BOOLEAN, &paired); diff --git a/src/device.c b/src/device.c index 7a06cd14..5eec2b4c 100644 --- a/src/device.c +++ b/src/device.c @@ -929,6 +929,9 @@ proceed: DBUS_TYPE_OBJECT_PATH, &device->path, DBUS_TYPE_INVALID); + /* Update device list */ + adapter_update_devices(device->adapter); + /* Reply create device request */ reply = dbus_message_new_method_return(req->msg); if (!reply) |