diff options
| -rw-r--r-- | hcid/adapter.c | 13 | ||||
| -rw-r--r-- | hcid/device.c | 15 | 
2 files changed, 27 insertions, 1 deletions
| diff --git a/hcid/adapter.c b/hcid/adapter.c index 850d9f2e..e2e22548 100644 --- a/hcid/adapter.c +++ b/hcid/adapter.c @@ -3420,21 +3420,32 @@ static DBusHandlerResult create_device(DBusConnection *conn,  static DBusHandlerResult remove_device(DBusConnection *conn,  						DBusMessage *msg, void *data)  { +	struct adapter *adapter = data;  	DBusMessage *reply;  	const char *path; +	GSList *l;  	if (!hcid_dbus_use_experimental())  		return error_unknown_method(conn, msg); -	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &path, +	if (dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,  						DBUS_TYPE_INVALID) == FALSE)  		return error_invalid_arguments(conn, msg, NULL); +	l = g_slist_find_custom(adapter->devices, path, (GCompareFunc) strcmp); +	if (!l) +		return error_device_does_not_exist(conn, msg); +  	reply = dbus_message_new_method_return(msg);  	if (!reply)  		return DBUS_HANDLER_RESULT_NEED_MEMORY; +	/* FIXME: Remove from filesystem */ +	/* FIXME: Remove linkkeys */ +  	device_remove(path); +	g_free(l->data); +	adapter->devices = g_slist_remove(adapter->devices, l->data);  	return send_message_and_unref(conn, reply);  } diff --git a/hcid/device.c b/hcid/device.c index 49b3ab84..3f4e5ba4 100644 --- a/hcid/device.c +++ b/hcid/device.c @@ -934,6 +934,21 @@ const gchar *device_create(struct adapter *adapter,  	return device->path;  } +static gint device_path_cmp(const struct device *device, const char *path) +{ +	return strcmp(device->path, path); +} +  void device_remove(const gchar *path)  { +	GSList *l; + + 	l = g_slist_find_custom(device_list, path, + 				(GCompareFunc) device_path_cmp); + 	if (!l) + 		return; +  + 	dbus_connection_destroy_object_path(connection, path); +  + 	device_list = g_slist_remove(device_list, l->data);  } | 
