diff mbox series

[4/5] Implement RemoveServiceRecord method

Message ID 20200401221434.12185-4-sonnysasaka@chromium.org (mailing list archive)
State New, archived
Headers show
Series [1/5] D-Bus API changes for managing SDP records | expand

Commit Message

Sonny Sasaka April 1, 2020, 10:14 p.m. UTC
From: Miao Chou <mcchou@chromium.org>

This implements the RemoveServiceRecord method of org.bluez.Adapter1 interface.
---
 src/adapter.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
diff mbox series

Patch

diff --git a/src/adapter.c b/src/adapter.c
index c02aaf32b..1be3e7984 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3834,6 +3834,29 @@  failed_to_alloc:
 	return btd_error_failed(msg, "Failed to allocate SDP record");
 }
 
+static DBusMessage *remove_service_record(DBusConnection *conn,
+					DBusMessage *msg, void *user_data)
+{
+	struct btd_adapter *adapter = user_data;
+	uint32_t rec_handle = 0xffffffff;
+	sdp_record_t *rec = NULL;
+
+	if (!(adapter->current_settings & MGMT_SETTING_POWERED))
+		return btd_error_not_ready(msg);
+
+	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT32, &rec_handle,
+							DBUS_TYPE_INVALID))
+		return btd_error_invalid_args(msg);
+
+	rec = sdp_record_find(rec_handle);
+	if (!rec)
+		return btd_error_does_not_exist(msg);
+
+	adapter_service_remove(adapter, rec_handle);
+
+	return dbus_message_new_method_return(msg);
+}
+
 static const GDBusMethodTable adapter_methods[] = {
 	{ GDBUS_ASYNC_METHOD("StartDiscovery", NULL, NULL, start_discovery) },
 	{ GDBUS_METHOD("SetDiscoveryFilter",
@@ -3852,6 +3875,8 @@  static const GDBusMethodTable adapter_methods[] = {
 			GDBUS_ARGS({"record", "a{q(yuv)}"}),
 			GDBUS_ARGS({"handle", "u"}),
 			create_service_record)},
+	{ GDBUS_METHOD("RemoveServiceRecord", GDBUS_ARGS({"handle", "u"}), NULL,
+			remove_service_record)},
 	{ }
 };