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>,
	Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
	Manish Mandlik <mmandlik@chromium.org>,
	Howard Chung <howardchung@google.com>,
	Miao-chen Chou <mcchou@chromium.org>
Subject: [BlueZ PATCH v4 6/8] adv_monitor: Handle D-Bus client ready events
Date: Thu, 10 Sep 2020 16:15:52 -0700	[thread overview]
Message-ID: <20200910161528.BlueZ.v4.6.Id5b1ced1530cb21559bc1dcf29d8764b0c7df825@changeid> (raw)
In-Reply-To: <20200910161528.BlueZ.v4.1.Iaa9dc2a66de5fbfa97627e1dbeb800116d3aa91e@changeid>

This adds a handler of client ready events. The handler replies to the
RegisterMonitor() method call.

The following tests were performed.
- Call RegisterMonitor() and expect to receive a return.

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

(no changes since v1)

 src/adv_monitor.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/src/adv_monitor.c b/src/adv_monitor.c
index c6c538cf1..8ef13512a 100644
--- a/src/adv_monitor.c
+++ b/src/adv_monitor.c
@@ -123,9 +123,22 @@ static void app_disconnect_cb(DBusConnection *conn, void *user_data)
 		app_destroy(app);
 }
 
+/* Handles the ready signal of Adv Monitor app */
+static void app_ready_cb(GDBusClient *client, void *user_data)
+{
+	struct adv_monitor_app *app = user_data;
+	uint16_t adapter_id = app->manager->adapter_id;
+
+	btd_info(adapter_id, "Path %s reserved for Adv Monitor app %s",
+			app->path, app->owner);
+
+	app_reply_msg(app, dbus_message_new_method_return(app->reg));
+}
+
 /* Creates an app object, initiates it and sets D-Bus event handlers */
 static struct adv_monitor_app *app_create(DBusConnection *conn,
-					const char *sender, const char *path,
+					DBusMessage *msg, const char *sender,
+					const char *path,
 					struct btd_adv_monitor_manager *manager)
 {
 	struct adv_monitor_app *app;
@@ -150,7 +163,9 @@ static struct adv_monitor_app *app_create(DBusConnection *conn,
 
 	g_dbus_client_set_disconnect_watch(app->client, app_disconnect_cb, app);
 	g_dbus_client_set_proxy_handlers(app->client, NULL, NULL, NULL, NULL);
-	g_dbus_client_set_ready_watch(app->client, NULL, NULL);
+	g_dbus_client_set_ready_watch(app->client, app_ready_cb, app);
+
+	app->reg = dbus_message_ref(msg);
 
 	return app;
 }
@@ -195,7 +210,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg,
 	if (queue_find(manager->apps, app_match, &match))
 		return btd_error_already_exists(msg);
 
-	app = app_create(conn, match.owner, match.path, manager);
+	app = app_create(conn, msg, match.owner, match.path, manager);
 	if (!app) {
 		btd_error(manager->adapter_id,
 				"Failed to reserve %s for Adv Monitor app %s",
@@ -206,10 +221,7 @@ static DBusMessage *register_monitor(DBusConnection *conn, DBusMessage *msg,
 
 	queue_push_tail(manager->apps, app);
 
-	btd_info(manager->adapter_id, "Path %s reserved for Adv Monitor app %s",
-			match.path, match.owner);
-
-	return dbus_message_new_method_return(msg);
+	return NULL;
 }
 
 /* Handles UnregisterMonitor D-Bus call */
-- 
2.26.2


  parent reply	other threads:[~2020-09-10 23:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10 23:15 [BlueZ PATCH v4 1/8] adapter: Remove indirect dependency of headers Miao-chen Chou
2020-09-10 23:15 ` [BlueZ PATCH v4 2/8] adv_monitor: Introduce org.bluez.AdvertisementMonitorManager1 interface Miao-chen Chou
2020-09-10 23:27   ` [BlueZ,v4,2/8] " bluez.test.bot
2020-09-10 23:40     ` Miao-chen Chou
2020-09-10 23:55       ` Luiz Augusto von Dentz
2020-09-10 23:15 ` [BlueZ PATCH v4 3/8] adv_monitor: Implement Get functions of Adv monitor manager properties Miao-chen Chou
2020-09-10 23:15 ` [BlueZ PATCH v4 4/8] adv_monitor: Implement RegisterMonitor() Miao-chen Chou
2020-09-10 23:15 ` [BlueZ PATCH v4 5/8] adv_monitor: Implement UnregisterMonitor() Miao-chen Chou
2020-09-10 23:15 ` Miao-chen Chou [this message]
2020-09-10 23:15 ` [BlueZ PATCH v4 7/8] adv_monitor: Handle D-Bus proxy event of an ADV monitor Miao-chen Chou
2020-09-10 23:15 ` [BlueZ PATCH v4 8/8] doc: Update Advertisement Monitor API description Miao-chen Chou
2020-09-10 23:30 ` [BlueZ,v4,1/8] adapter: Remove indirect dependency of headers bluez.test.bot

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=20200910161528.BlueZ.v4.6.Id5b1ced1530cb21559bc1dcf29d8764b0c7df825@changeid \
    --to=mcchou@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.