All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miao-chen Chou <mcchou@chromium.org>
To: Bluetooth Kernel Mailing List <linux-bluetooth@vger.kernel.org>
Cc: Alain Michaud <alainm@chromium.org>,
	Manish Mandlik <mmandlik@chromium.org>,
	Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
	Howard Chung <howardchung@google.com>,
	Miao-chen Chou <mcchou@chromium.org>,
	Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Subject: [BlueZ PATCH v1 4/7] adv_monitor: Implement UnregisterMonitor()
Date: Tue, 18 Aug 2020 15:26:41 -0700	[thread overview]
Message-ID: <20200818152612.BlueZ.v1.4.I335e42ab9a238261c2492c308ce77c959f631483@changeid> (raw)
In-Reply-To: <20200818152612.BlueZ.v1.1.I205718871f4e636958904f3cfb171cfd381c54b1@changeid>

This implements the UnregisterMonitor() method handler of ADV monitor
manager interface.

The following tests were performed.
- Issue a UnregisterMonitor() call with a nonexistent path and expect
org.bluez.Error.DoesNotExist as the return.
- Issue a UnregisterMonitor() call with a invalid path and expect
org.bluez.Error.InvalidArguments as the return.
- Issue RegisterMonitor() with a path, issue UnregisterMonitor() and
expect a successful method call return.

Reviewed-by: Yun-Hao Chung <howardchung@google.com>
Reviewed-by: Manish Mandlik <mmandlik@chromium.org>
Reviewed-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
---

 src/adv_monitor.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/adv_monitor.c b/src/adv_monitor.c
index 3d27ad18b..a9e2e4421 100644
--- a/src/adv_monitor.c
+++ b/src/adv_monitor.c
@@ -216,13 +216,48 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg,
 	return dbus_message_new_method_return(msg);
 }
 
+/* Handles UnregisterMonitor D-Bus call */
+static DBusMessage *unregister_monitor(DBusConnection *conn,
+					DBusMessage *msg, void *user_data)
+{
+	DBusMessageIter args;
+	struct app_match_data match;
+	struct adv_monitor_app *app;
+	struct btd_adv_monitor_manager *manager = user_data;
+
+	if (!dbus_message_iter_init(msg, &args))
+		return btd_error_invalid_args(msg);
+
+	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
+		return btd_error_invalid_args(msg);
+
+	dbus_message_iter_get_basic(&args, &match.path);
+
+	if (!strlen(match.path) || !g_str_has_prefix(match.path, "/"))
+		return btd_error_invalid_args(msg);
+
+	match.owner = dbus_message_get_sender(msg);
+
+	app = queue_find(manager->apps, app_match, &match);
+	if (!app)
+		return btd_error_does_not_exist(msg);
+
+	queue_remove(manager->apps, app);
+	app_destroy(app);
+
+	btd_info(manager->adapter_id, "Path %s removed along with Adv Monitor "
+			"app %s", match.path, match.owner);
+
+	return dbus_message_new_method_return(msg);
+}
+
 static const GDBusMethodTable adv_monitor_methods[] = {
 	{ GDBUS_METHOD("RegisterMonitor",
 					GDBUS_ARGS({ "application", "o" }),
 					NULL, register_monitor) },
 	{ GDBUS_ASYNC_METHOD("UnregisterMonitor",
 					GDBUS_ARGS({ "application", "o" }),
-					NULL, NULL) },
+					NULL, unregister_monitor) },
 	{ }
 };
 
-- 
2.26.2


  parent reply	other threads:[~2020-08-18 22:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18 22:26 [BlueZ PATCH v1 1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Miao-chen Chou
2020-08-18 22:26 ` [BlueZ PATCH v1 2/7] adv_monitor: Implement Get functions of ADV monitor manager properties Miao-chen Chou
2020-08-18 22:26 ` [BlueZ PATCH v1 3/7] adv_monitor: Implement RegisterMonitor() Miao-chen Chou
2020-09-08 17:24   ` Luiz Augusto von Dentz
2020-09-10  4:52     ` Miao-chen Chou
2020-08-18 22:26 ` Miao-chen Chou [this message]
2020-08-18 22:26 ` [BlueZ PATCH v1 5/7] adv_monitor: Handle D-Bus client ready events Miao-chen Chou
2020-08-18 22:26 ` [BlueZ PATCH v1 6/7] adv_monitor: Handle D-Bus proxy event of an ADV monitor Miao-chen Chou
2020-09-08 17:35   ` Luiz Augusto von Dentz
2020-09-10  4:52     ` Miao-chen Chou
2020-08-18 22:26 ` [BlueZ PATCH v1 7/7] doc/advertisement-monitor-api: Update Advertisement Monitor API description Miao-chen Chou
2020-08-18 22:50   ` [BlueZ,v1,7/7] " bluez.test.bot
2020-09-08 17:39   ` [BlueZ PATCH v1 7/7] " Luiz Augusto von Dentz
2020-09-10  4:53     ` Miao-chen Chou
2020-09-10 17:43       ` Luiz Augusto von Dentz
2020-09-10 23:19         ` Miao-chen Chou
2020-08-18 22:50 ` [BlueZ,v1,1/7] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface bluez.test.bot
2020-08-18 22:53 ` bluez.test.bot
2020-09-08 17:19 ` [BlueZ PATCH v1 1/7] " Luiz Augusto von Dentz
2020-09-10  4:52   ` Miao-chen Chou
2020-09-10 17:31     ` Luiz Augusto von Dentz
2020-09-10 23:18       ` Miao-chen Chou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200818152612.BlueZ.v1.4.I335e42ab9a238261c2492c308ce77c959f631483@changeid \
    --to=mcchou@chromium.org \
    --cc=abhishekpandit@chromium.org \
    --cc=alainm@chromium.org \
    --cc=howardchung@google.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.von.dentz@intel.com \
    --cc=mmandlik@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.