From patchwork Tue Oct 22 14:10:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 837870 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C17BA19F110 for ; Tue, 22 Oct 2024 14:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606284; cv=none; b=DAzbxu0HEP0EHY2Wq0F/IQqnHR/sIHaVdl5nkZX2EBMxDBIWFbEeBybIF/+8zIiTh4cRT0jfFKjFFeKVisxjTdmqRA+TgszGf95XY0qvn6ofCxi0SFlon517VAviE5xNL5xOaqWBWRSQNL8OhHw/yFQ9fGEJ7J9UjzFph90wSvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606284; c=relaxed/simple; bh=8TYtxj8RCuYcQ+6mpbMkTfqD/80RbkhK9oPnRW/Hk+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tVO33MCBtF7xL2w/FRayut+kkzI9dM58YdVPXfqQaKZQZKPCD45zdD1c6Yo4VeNNzYSUWNiyY/QGDGbWxLHjEJ5+dBjBSa7kG0a80stGe8ozzkclwyHzZF+rqtGfi67zkoFpg8b1Svr4whiJ2JQxhUjtAC0dbKuju4otwwUk0xo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id EC826240002; Tue, 22 Oct 2024 14:11:18 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v3 1/7] configure.ac: Update requirement to glib 2.34 Date: Tue, 22 Oct 2024 16:10:32 +0200 Message-ID: <20241022141118.150143-2-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022141118.150143-1-hadess@hadess.net> References: <20241022141118.150143-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: hadess@hadess.net Update build requirements from 2011's glib 2.28 all the way up to 2012's glib 2.34. This will allow us to use g_clear_pointer(). --- acinclude.m4 | 4 ++-- configure.ac | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 4b73a5bfc38f..d0bfe6ccb2fa 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -62,8 +62,8 @@ AC_DEFUN([COMPILER_FLAGS], [ with_cflags="$with_cflags -Wswitch-enum" with_cflags="$with_cflags -Wformat -Wformat-security" with_cflags="$with_cflags -DG_DISABLE_DEPRECATED" - with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28" - with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32" + with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_34" + with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_34" fi AC_SUBST([WARNING_CFLAGS], $with_cflags) ]) diff --git a/configure.ac b/configure.ac index 7093e41ff714..14bd15293918 100644 --- a/configure.ac +++ b/configure.ac @@ -81,7 +81,7 @@ AC_CHECK_DECLS([basename], [], ]) -PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28) +PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.34) if (test "${enable_threads}" = "yes"); then AC_DEFINE(NEED_THREADS, 1, [Define if threading support is required]) From patchwork Tue Oct 22 14:10:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 837624 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD13819F133 for ; Tue, 22 Oct 2024 14:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606283; cv=none; b=jQBhNFcYLdIvqIlwEs7kvmZpdP0zteitU6qwqFCoEyNFrcuzv99EczJfjRgIGEMoOj0DGJ6WPDRmbpZRyjYZW+FwaJEvEn40GYLCyA5XPGoLTw48iWaD1r4AdPugVNqC+j0Hi0AAfaXfrHqZKro/O83f1dewKTQZuNAnWla/t0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606283; c=relaxed/simple; bh=stdfC0w+a9QqvorW0UmHP3AKTvUwMz74Z/gkoW1AZao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tjuii2eRJoDKpxJAgWrfwI1s1A36D+AIZ1Tksl1iEStwIZZoHUBbS//s6G4g0dMA3PP/eQRZJwLg4NjjzbyOC3DMYFoOzQY9uWZyGOGw2/vIEkeTIg3yZIfcOhbwP2BksaT/HxSpm2KJdqZOqFGkQudxwXzjdN8VLWinyITvy1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 38A9F240004; Tue, 22 Oct 2024 14:11:19 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v3 2/7] client: Use g_clear_pointer() to clean up menus Date: Tue, 22 Oct 2024 16:10:33 +0200 Message-ID: <20241022141118.150143-3-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022141118.150143-1-hadess@hadess.net> References: <20241022141118.150143-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: hadess@hadess.net This would avoid warnings should the client be NULL. --- client/admin.c | 5 ++--- client/assistant.c | 5 ++--- client/player.c | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/client/admin.c b/client/admin.c index cd9af6f955da..9d48867bc1d7 100644 --- a/client/admin.c +++ b/client/admin.c @@ -191,7 +191,7 @@ static void proxy_removed(GDBusProxy *proxy, void *user_data) admin_policy_status_removed(proxy); } -static GDBusClient *client; +static GDBusClient *client = NULL; static void disconnect_handler(DBusConnection *connection, void *user_data) { @@ -215,6 +215,5 @@ void admin_add_submenu(void) void admin_remove_submenu(void) { - g_dbus_client_unref(client); - client = NULL; + g_clear_pointer(&client, g_dbus_client_unref); } diff --git a/client/assistant.c b/client/assistant.c index 16e94664a5c3..94052e26fd59 100644 --- a/client/assistant.c +++ b/client/assistant.c @@ -390,7 +390,7 @@ static const struct bt_shell_menu assistant_menu = { {} }, }; -static GDBusClient * client; +static GDBusClient * client = NULL; void assistant_add_submenu(void) { @@ -409,7 +409,6 @@ void assistant_add_submenu(void) void assistant_remove_submenu(void) { - g_dbus_client_unref(client); - client = NULL; + g_clear_pointer(&client, g_dbus_client_unref); } diff --git a/client/player.c b/client/player.c index 188378175486..dea5922d56db 100644 --- a/client/player.c +++ b/client/player.c @@ -5694,7 +5694,7 @@ static const struct bt_shell_menu transport_menu = { {} }, }; -static GDBusClient *client; +static GDBusClient *client = NULL; void player_add_submenu(void) { @@ -5715,6 +5715,6 @@ void player_add_submenu(void) void player_remove_submenu(void) { - g_dbus_client_unref(client); + g_clear_pointer(&client, g_dbus_client_unref); queue_destroy(ios, transport_free); } From patchwork Tue Oct 22 14:10:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 837872 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29E8319F423 for ; Tue, 22 Oct 2024 14:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606283; cv=none; b=Gbvy1rG34h4fmm6VXgPjVvQq7rGS0IGt3jiAKfkA7w59IcQ8mhSSyNng/PWjF++VU/gHL+BhNMBsnMcsa6HAw98n9d85dML9H8IkoaJEMmtHof5HQuTcM0j9STPuN2z0KVMWezKC3Q3bQcr+ngAjEagBlHLQy6BQ7gkDvxcHCjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606283; c=relaxed/simple; bh=LyZBJ+/JOYDSY+EdIQETDOgSabMnIXIvuxpdyI8Gh9M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RmXTRAc7sQAF2Pf97NVv/REbAfZkeAD5Q6LZjRbKQPMO9/G/JxE9rtKrlFEgxhuowzxuxx4FCSS2qkWh6OHkG+CUIhJprxOiOwknUvNjAYtGkVnfqZ0cSYX5c10hooQmEaX5D6So8yO9DguQkqmOTo2PhVk4YoRMl9nsl+Xi6Rg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 78C55240003; Tue, 22 Oct 2024 14:11:19 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v3 3/7] client: Split installing submenu and doing I/O Date: Tue, 22 Oct 2024 16:10:34 +0200 Message-ID: <20241022141118.150143-4-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022141118.150143-1-hadess@hadess.net> References: <20241022141118.150143-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: hadess@hadess.net Split off installing the command's submenu and contacting the management socket or the bluez daemon. --- client/admin.c | 3 +++ client/admin.h | 1 + client/assistant.c | 3 +++ client/assistant.h | 1 + client/main.c | 4 ++++ client/mgmt.c | 11 +++++++---- client/mgmt.h | 3 ++- client/player.c | 3 +++ client/player.h | 1 + tools/btmgmt.c | 3 ++- 10 files changed, 27 insertions(+), 6 deletions(-) diff --git a/client/admin.c b/client/admin.c index 9d48867bc1d7..15759ba0291a 100644 --- a/client/admin.c +++ b/client/admin.c @@ -202,7 +202,10 @@ static void disconnect_handler(DBusConnection *connection, void *user_data) void admin_add_submenu(void) { bt_shell_add_submenu(&admin_menu); +} +void admin_enable_submenu(void) +{ dbus_conn = bt_shell_get_env("DBUS_CONNECTION"); if (!dbus_conn || client) return; diff --git a/client/admin.h b/client/admin.h index 4da83e4e36ba..68a497971f66 100644 --- a/client/admin.h +++ b/client/admin.h @@ -18,4 +18,5 @@ */ void admin_add_submenu(void); +void admin_enable_submenu(void); void admin_remove_submenu(void); diff --git a/client/assistant.c b/client/assistant.c index 94052e26fd59..ceade046be68 100644 --- a/client/assistant.c +++ b/client/assistant.c @@ -395,7 +395,10 @@ static GDBusClient * client = NULL; void assistant_add_submenu(void) { bt_shell_add_submenu(&assistant_menu); +} +void assistant_enable_submenu(void) +{ dbus_conn = bt_shell_get_env("DBUS_CONNECTION"); if (!dbus_conn || client) return; diff --git a/client/assistant.h b/client/assistant.h index 418b0b84031f..c304abea0515 100644 --- a/client/assistant.h +++ b/client/assistant.h @@ -9,5 +9,6 @@ */ void assistant_add_submenu(void); +void assistant_enable_submenu(void); void assistant_remove_submenu(void); diff --git a/client/main.c b/client/main.c index 3f8143dde4b8..17af62000f6d 100644 --- a/client/main.c +++ b/client/main.c @@ -3204,9 +3204,13 @@ int main(int argc, char *argv[]) (void *)endpoint_option); admin_add_submenu(); + admin_enable_submenu(); player_add_submenu(); + player_enable_submenu(); mgmt_add_submenu(); + mgmt_enable_submenu(); assistant_add_submenu(); + assistant_enable_submenu(); client = g_dbus_client_new(dbus_conn, "org.bluez", "/org/bluez"); diff --git a/client/mgmt.c b/client/mgmt.c index 602b92228ab8..aea3d95597c9 100644 --- a/client/mgmt.c +++ b/client/mgmt.c @@ -6026,7 +6026,13 @@ static void mgmt_debug(const char *str, void *user_data) print("%s%s", prefix, str); } -bool mgmt_add_submenu(void) +void mgmt_add_submenu(void) +{ + bt_shell_add_submenu(&mgmt_menu); + bt_shell_add_submenu(&monitor_menu); +} + +bool mgmt_enable_submenu(void) { mgmt = mgmt_new_default(); if (!mgmt) { @@ -6034,9 +6040,6 @@ bool mgmt_add_submenu(void) return false; } - bt_shell_add_submenu(&mgmt_menu); - bt_shell_add_submenu(&monitor_menu); - if (getenv("MGMT_DEBUG")) mgmt_set_debug(mgmt, mgmt_debug, "mgmt: ", NULL); diff --git a/client/mgmt.h b/client/mgmt.h index 5a2026eab6a2..b0f3cafd0777 100644 --- a/client/mgmt.h +++ b/client/mgmt.h @@ -8,6 +8,7 @@ * */ -bool mgmt_add_submenu(void); +void mgmt_add_submenu(void); +bool mgmt_enable_submenu(void); void mgmt_remove_submenu(void); void mgmt_set_index(const char *arg); diff --git a/client/player.c b/client/player.c index dea5922d56db..3189e0575798 100644 --- a/client/player.c +++ b/client/player.c @@ -5701,7 +5701,10 @@ void player_add_submenu(void) bt_shell_add_submenu(&player_menu); bt_shell_add_submenu(&endpoint_menu); bt_shell_add_submenu(&transport_menu); +} +void player_enable_submenu(void) +{ dbus_conn = bt_shell_get_env("DBUS_CONNECTION"); if (!dbus_conn || client) return; diff --git a/client/player.h b/client/player.h index e7778cb1efd9..c09ffa94cbff 100644 --- a/client/player.h +++ b/client/player.h @@ -9,4 +9,5 @@ */ void player_add_submenu(void); +void player_enable_submenu(void); void player_remove_submenu(void); diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 436c2bb21f10..0f6051d5befe 100644 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -46,7 +46,8 @@ int main(int argc, char *argv[]) bt_shell_init(argc, argv, &opt); - if (!mgmt_add_submenu()) { + mgmt_add_submenu(); + if (!mgmt_enable_submenu()) { fprintf(stderr, "Unable to open mgmt_socket\n"); return EXIT_FAILURE; } From patchwork Tue Oct 22 14:10:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 837873 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 722C919F471 for ; Tue, 22 Oct 2024 14:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606283; cv=none; b=f6h0jO/e4h3qwAjUmFo/7a8VlzImRSe6bS082WJJMI8kvzVgdABlEaMj3teLwv69rIKScns7beDjAs5+B57VRkXH+HN7oAjPuYvqEqEivRL18gnx+bwU6AL1384rXZmdal0KIgx1fY7io6307z7ooMoJjnBlDI0F+SAUugAHGY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606283; c=relaxed/simple; bh=wWA/M+qQ+CdbyhZDTYQSa/woqJEvSmt7Is5V992jisg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i70VFFUaXdcGJIiYstAyGNlNBCJdVFkire4bMn7NKVav3NgQVVI08wh9th9z9i7JOj3x70Rve+ToOBOxfxtZUetJKQurtWVrSWlu9ZqqB3/flV6kF9zL/Yjj0JllvMi26sGliW7pOlihm1KEccmoSuGBFvtkEFQVS1diqMXk/Q4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id C2ED0240008; Tue, 22 Oct 2024 14:11:19 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v3 4/7] client: Install submenus before contacting bluez daemon Date: Tue, 22 Oct 2024 16:10:35 +0200 Message-ID: <20241022141118.150143-5-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022141118.150143-1-hadess@hadess.net> References: <20241022141118.150143-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: hadess@hadess.net So that the submenus are installed even if bluez isn't available. --- client/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/main.c b/client/main.c index 17af62000f6d..f60bef1a6d3a 100644 --- a/client/main.c +++ b/client/main.c @@ -3187,6 +3187,10 @@ int main(int argc, char *argv[]) bt_shell_add_submenu(&advertise_monitor_menu); bt_shell_add_submenu(&scan_menu); bt_shell_add_submenu(&gatt_menu); + admin_add_submenu(); + player_add_submenu(); + mgmt_add_submenu(); + assistant_add_submenu(); bt_shell_set_prompt(PROMPT_OFF, NULL); if (agent_option) @@ -3203,13 +3207,9 @@ int main(int argc, char *argv[]) bt_shell_set_env("AUTO_REGISTER_ENDPOINT", (void *)endpoint_option); - admin_add_submenu(); admin_enable_submenu(); - player_add_submenu(); player_enable_submenu(); - mgmt_add_submenu(); mgmt_enable_submenu(); - assistant_add_submenu(); assistant_enable_submenu(); client = g_dbus_client_new(dbus_conn, "org.bluez", "/org/bluez"); From patchwork Tue Oct 22 14:10:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 837623 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C817519F47E for ; Tue, 22 Oct 2024 14:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606283; cv=none; b=XjGfOW4t/iTc/PB0LpLhyxV55MZ0KBB+1rPHSxJ/qQYIJGCLmGwXYK9OglbkX6cUvBFbg9PBIdUsYbk8Dqptn8RkxUFOiyfInxiEJz+0j5UwfDBFJ6Kc18UqqiaVytdCZxzooI1L9mDwIYVkaghxM4WwtNXZst9avEMs1qD1F7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606283; c=relaxed/simple; bh=ULD+6IBmG1PXoku2Q5jp0LOXbS2Lr7YqhrvFwviTOuU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uk2KpnX103+GXeczxHFbOZS0/r9Tvl58a2meHau+43d3s/z3O29dOJlHFZtLD5KcBoaLUa3sq7mKJtoyyXDjgpAvo4ZxtSjq7eoydlB36NT3kTALKtcRBzVOX4Z+TEUaV8hjZUya6lQI1mYJPSlA16T1OMvlrx2khaULBVrJeiQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 1542D240007; Tue, 22 Oct 2024 14:11:19 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v3 5/7] shell: Document "mode" variable Date: Tue, 22 Oct 2024 16:10:36 +0200 Message-ID: <20241022141118.150143-6-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022141118.150143-1-hadess@hadess.net> References: <20241022141118.150143-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: hadess@hadess.net It's unclear what it does, could probably do with being replaced with an enum to make its possible values and meaning clearer. --- src/shared/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/shell.c b/src/shared/shell.c index a8ad956c7948..2f83717b2d39 100644 --- a/src/shared/shell.c +++ b/src/shared/shell.c @@ -71,7 +71,7 @@ static struct { char history[256]; int argc; char **argv; - bool mode; + bool mode; /* whether non-interactive */ bool zsh; bool monitor; int timeout; From patchwork Tue Oct 22 14:10:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 837871 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F149919F485 for ; Tue, 22 Oct 2024 14:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606283; cv=none; b=hHx5WZ0pBUykdnt259Rt8ES0jdUdu5M92Fd/GYw/djZZUdinmhCd8Rbl0DQDqYuFa1pIZ90pklQHOwa1RXRwNMKamp3tUXPYvhN0+jpWarEXuJQEqodq9996sKhiT1xDDCbrwpgJic4kvEY3msmh59Dj2uL/7bFL4QcWZkSRO+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606283; c=relaxed/simple; bh=iV3Gom7Fgo8VpeTriOg1gLZKtpVVrhzfyJhFC7ltCA4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cQ0PlrFRwjsbZ5M3IDDoxD5qtEijKd4EtPbvNcNgKveU/Obq4YbXonGintLQ15y59X9FPkTuqBvm2OKvl/ojGBjaqHLfeklCwZ6knKU2P6qfaKJdRw2LiPKcQ2bH5DqIDtqbYbm4vck9bmGybWpTxwyFdPm83VZ/okX93+NeW6c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 60B8A240013; Tue, 22 Oct 2024 14:11:20 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v3 6/7] shared/shell: Add function to handle early help calls Date: Tue, 22 Oct 2024 16:10:37 +0200 Message-ID: <20241022141118.150143-7-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022141118.150143-1-hadess@hadess.net> References: <20241022141118.150143-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: hadess@hadess.net Add a function that would allow tools to exit after handling --help, so as to avoid the daemon waiting to communicate with a D-Bus service that might not be running. --- src/shared/shell.c | 10 ++++++++++ src/shared/shell.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/shared/shell.c b/src/shared/shell.c index 2f83717b2d39..88cc7df2d565 100644 --- a/src/shared/shell.c +++ b/src/shared/shell.c @@ -1697,3 +1697,13 @@ int bt_shell_get_timeout(void) { return data.timeout; } + +void bt_shell_handle_non_interactive_help(void) +{ + if (!data.mode) + return; + if (data.argv[0] != cmplt) + return; + print_cmds(); + exit(EXIT_SUCCESS); +} diff --git a/src/shared/shell.h b/src/shared/shell.h index e431db9f5821..eebbc71faffb 100644 --- a/src/shared/shell.h +++ b/src/shared/shell.h @@ -60,6 +60,8 @@ int bt_shell_exec(const char *input); void bt_shell_quit(int status); void bt_shell_noninteractive_quit(int status); +void bt_shell_handle_non_interactive_help(void); + bool bt_shell_set_menu(const struct bt_shell_menu *menu); bool bt_shell_add_submenu(const struct bt_shell_menu *menu); From patchwork Tue Oct 22 14:10:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 837622 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D70819FA64 for ; Tue, 22 Oct 2024 14:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606284; cv=none; b=IDGTgJ/UI+9iyg/tXXpg/bdyY8OYcCAW+CFMWmz1skx/yXOP2Ja61pMtw8mceR0HCAc5Ri0Jo5CiEQ7SbV7UiWSkmsDLPNr8bYHr6xDBfUdct79xn0cZYJVOBGt0CcLj9fqfMvXtK0bEP647yM+QFqEaQmg2Y8FNMsZ1SiCOF5s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729606284; c=relaxed/simple; bh=dLCv3QX/enuoC1+8hQH+oDDeJBEnGRJbnwINEc1PP/k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MFxZzbJNlzzfL+A9YhMD5JLu0HER0jDrgWsbX6L7Lws+a5nIqfpZ36BCd+2JTz4QGCqziUlBuZUsefXuBNYg6mywlyEJ6MhPqm0Mf1k96cYBN8z+cqVJfOtHzwt1XcgdnVEi/TNRkBXnVcvGbC2+l20QBIxHJ/qMWdrmUx5psuo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net; spf=pass smtp.mailfrom=hadess.net; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=hadess.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hadess.net Received: by mail.gandi.net (Postfix) with ESMTPSA id A0BFA240015; Tue, 22 Oct 2024 14:11:20 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v3 7/7] client: Fix --help hanging if bluetoothd is not running Date: Tue, 22 Oct 2024 16:10:38 +0200 Message-ID: <20241022141118.150143-8-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022141118.150143-1-hadess@hadess.net> References: <20241022141118.150143-1-hadess@hadess.net> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: hadess@hadess.net Exit after printing all the main and submenu commands. --- client/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/main.c b/client/main.c index f60bef1a6d3a..f5ed9f9f5297 100644 --- a/client/main.c +++ b/client/main.c @@ -3193,6 +3193,8 @@ int main(int argc, char *argv[]) assistant_add_submenu(); bt_shell_set_prompt(PROMPT_OFF, NULL); + bt_shell_handle_non_interactive_help(); + if (agent_option) auto_register_agent = g_strdup(agent_option); else