From patchwork Tue Oct 22 11:58:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastien Nocera X-Patchwork-Id: 13845637 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 645E5199246 for ; Tue, 22 Oct 2024 12:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598461; cv=none; b=ZCWyu1CfGb6SvJ7K4nP5mgJMnv8cJSw1/A0ImLcQPyc+GC3iR9ObbqhE0LqkoKd708Rr5pFwboQmI+gMCz8RgYhyPQbhQgAkJKkMamU4ni/OFV8UXDfkgYwGngteAE7snRIhPOxIi/EiVuXXKJDwE2BotxvdNMGgGgC4Vw1nZzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598461; c=relaxed/simple; bh=8TYtxj8RCuYcQ+6mpbMkTfqD/80RbkhK9oPnRW/Hk+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ft1m2UhC37Fnt1Jiu8yaaqWKQaXTGJuQ9TDMQKrbFzHo0gr20+gGkpOBCOMlXw3reMosafrd7U6au72I2/hSSb58GH3cTYR7kLtX+58OqcDVMv7qQvIF6OpaHSc6K1dqb5U8X9Q9I0tPrsoTJO+8q4LfmpR8z9HcF18tROv3y1I= 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.197 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 0DBB11C001F; Tue, 22 Oct 2024 12:00:51 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v2 1/7] configure.ac: Update requirement to glib 2.34 Date: Tue, 22 Oct 2024 13:58:31 +0200 Message-ID: <20241022120051.123888-2-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120051.123888-1-hadess@hadess.net> References: <20241022120051.123888-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 11:58: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: 13845638 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 9EDC9199252 for ; Tue, 22 Oct 2024 12:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598461; cv=none; b=A7Fgco+kastSeZ14jSsFly+/Rm64wMSsk/t4TirDOQWH86uJkKnsDHp3ca84BhV5OseAnBBKv2QdgcpgVA7hFINTrRMvfZMBxFv08L9hik9L/y6+xDEJKrbKDfREF7ilrM38USOak/XvsLHUU0lK+RtR/fvbTBHv6X+GaGkQtAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598461; c=relaxed/simple; bh=stdfC0w+a9QqvorW0UmHP3AKTvUwMz74Z/gkoW1AZao=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pTwV84zdB7oGQ5Qv/KR5hHbt8iaGZeU0khHUB1h+Du+nd1bV2y2VfjiIH32T9PA3ysTeNkoHA7zSDFpR7wwnffxkXMxbOwQHG4dN3f0q8KHpOJ7gaqh6c/L+RSByDy0vnWRGaySI6s6KSMCmxNKexYdGm99SoQFd4vt9JxIBz3I= 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.197 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 525851C0021; Tue, 22 Oct 2024 12:00:52 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v2 2/7] client: Use g_clear_pointer() to clean up menus Date: Tue, 22 Oct 2024 13:58:32 +0200 Message-ID: <20241022120051.123888-3-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120051.123888-1-hadess@hadess.net> References: <20241022120051.123888-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 11:58: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: 13845641 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 43155155352 for ; Tue, 22 Oct 2024 12:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598462; cv=none; b=hRO+q5A7V51lrUZ6aPE9f0cbu6bY7mQ21WvdlANYWDJVrqNJpy1p5o7MZc/j5s6iB++T11TMusD/ZWRNt1S59vGc/fgnYuNs89U38aW0tUbxNyyftUjlj6mZhIZFJh8wBGn/9c4yb4ufRnzSpqj8iGyNLbR2h2eTxoVo4EM9QVI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598462; c=relaxed/simple; bh=ivGxwW/lpgwihxo7ubC3MEhED5seqUJwhIqCvXtGme0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TPv0y/hk1bH6NkVBhMzC61wcF2FcRxDY7V68VYf8xK9s49w3fb793Kll2Fm6Duden7COK1LiTOiCcKCfhgsInBTCltdydEMnIFwynEjfTpguJvI1MQPLoA+8qlFtULvNi/ktCAMkaRv1E/P6aSQ0QpmeBwwWOGaw6MUOq7Fn5Jg= 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.197 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 A20F51C0023; Tue, 22 Oct 2024 12:00:52 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v2 3/7] client: Split installing submenu and doing I/O Date: Tue, 22 Oct 2024 13:58:33 +0200 Message-ID: <20241022120051.123888-4-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120051.123888-1-hadess@hadess.net> References: <20241022120051.123888-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 50aa3e7a6cbe..4ae6f121d424 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 fba409f823ef..ef795f5e86fa 100644 --- a/client/mgmt.c +++ b/client/mgmt.c @@ -6028,7 +6028,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) { @@ -6036,9 +6042,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 11:58: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: 13845642 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 4995419B3C5 for ; Tue, 22 Oct 2024 12:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598462; cv=none; b=eKXDihi7wxhp7atu4+DDMejcHKGlQlndyDstGOX2IcTtkLfZXUUhmHEa8mmGZDB9/LehLgv1odR8V9cBKfCVmalfDw6lpn3aIcR9gVHHPXBu9xxKjggfD3PwpzrHssbj+zhstdlX4bCdgdEHPhPgi6q86Dw60HnpYtOT403yFKI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598462; c=relaxed/simple; bh=ejRH2MiZ1eZIklxRoMOTeEhvvwndTs9rocDCNpLyj4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K5Be5IviwFy+0zv/GrFVAqTI2F8t774VqRSGxmbPY5z1kTDNfaoZ6+fFiQ8LWbIug3KVIeJZvwZRAFvhAdNimd9l6dg3JBArg8UsPTgmZa+kWh1ARjVUUjr0A+um4mbNHVnlnPwWlVwHVThpchOxuLhSbRTroQLOGYEK3Tz0bIE= 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.197 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 EEB2F1C0026; Tue, 22 Oct 2024 12:00:52 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v2 4/7] client: Install submenus before contacting bluez daemon Date: Tue, 22 Oct 2024 13:58:34 +0200 Message-ID: <20241022120051.123888-5-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120051.123888-1-hadess@hadess.net> References: <20241022120051.123888-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 4ae6f121d424..144e17622e95 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); 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 11:58: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: 13845640 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 49902199938 for ; Tue, 22 Oct 2024 12:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598461; cv=none; b=mXbuduVIwU4Bn9L7nKdlarRUYDB1FI6sYdT83rnXih8zi/2CeVLeAsOP5KiEy6WXUHRrqbuPTxXBYDJwnB8QXDtklSzMIzZR4MN9Cxn3syDkJ2U4/tdmx5GJK9TybSzxwo1OUJa1BvHShhK6I61Q+FMwUU3PODEHL3YhGt4DoQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598461; c=relaxed/simple; bh=9Y/CFdXkR3Dh+SAzeb5OqTJ5CDE0EEUzMDxPlk94g00=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OkWoQrOMj5QGQOkI3GHWw8kIQ8Ba2GbZ29/iRjOcD8TsCZslc1smf+zIX2GOoz46CYwPDSei2ulL8BEvnC/30jb3L4w1+slPRmiDci2BlgRUiseO6nHLG1YElipKNGiNWPb8XJ3H5PDldSXbrD0uppqzIEqOueKtlXEHUMQrP6g= 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.197 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 43BB41C0024; Tue, 22 Oct 2024 12:00:53 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v2 5/7] shell: Document "mode" variable Date: Tue, 22 Oct 2024 13:58:35 +0200 Message-ID: <20241022120051.123888-6-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120051.123888-1-hadess@hadess.net> References: <20241022120051.123888-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 2100434f6b15..9ff774fe43a2 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 11:58: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: 13845644 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 620BA19CC33 for ; Tue, 22 Oct 2024 12:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598463; cv=none; b=PntSX7IfXQsvrr057EfDdPpNx8jqy9gh8tUKR8X+RwVlW93IDe+pumZPo/+1fzC9vBZQjLevUSTnlNqdbaQanUnmaLCbtsnDlD0IIVXVKsAX3zt7wvA/YYXgK2or3T6qzwytovQ/LfJ8pk6Ni2Gp3q7CZxFJFeztybmKQOW9PC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598463; c=relaxed/simple; bh=Tw5voPPuH/WUlwtUebJj2x7JUskyqTEq+0bS5xxzoyk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AsYaHQlqniE13WeRYoCmZuu6k/gM+JX05J4gwpJ/FH0v541LDV2W37VrTyAm4DVx37/ZTNPrW5I61tETNgPUDnFxfD4jakHF6z8dGfcvYA30dAf6d4r9b7esKCTVMQf2MxyoZ0DdncCvitBtqauGb+GfR6VqfuhLcyCxgaMQHEs= 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.197 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 9A7E81C0028; Tue, 22 Oct 2024 12:00:53 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v2 6/7] shared/shell: Add function to handle early help calls Date: Tue, 22 Oct 2024 13:58:36 +0200 Message-ID: <20241022120051.123888-7-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120051.123888-1-hadess@hadess.net> References: <20241022120051.123888-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 9ff774fe43a2..7107fb4c7776 100644 --- a/src/shared/shell.c +++ b/src/shared/shell.c @@ -1694,3 +1694,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 b03250cac80f..17277a601d3e 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 11:58: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: 13845643 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (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 38D4D19C553 for ; Tue, 22 Oct 2024 12:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598463; cv=none; b=IsAfzFgZxIBps5rCVztcMrHTW+eEfhfz+OUq7nV/Agr+XC/zBnv2LOV+3te2GwlVCgSUIPjZvHbrqUiNKiMzZYJ2sVEkEiDBCQdPqj7fyG3a9d43I3h46LMnkzjvwUZRez4x6X6fof3hu6jb/UnXiFbh7vWI2TZPYcIXXTXY/VM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729598463; c=relaxed/simple; bh=cVssVKnGPA4PcuDBwv+YjYR1Myp1n+85YewD7ncPBvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dnKxae5bRqjuERtTRqcIlGp0J7SXL+rWYJbtxF5q3AmRcuMwJ5XabBuRJD8gg6zqIwRhWac4XoVEFDWDqI4JZbGxUck2CWawje0TOqUJDkcZ5DtZFMpZ1ckfsFp+8p2FVDYJSr/AqKQpwduF/6HaPckSYB9evUwICevFSxEHfYI= 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.197 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 E6BC71C002A; Tue, 22 Oct 2024 12:00:53 +0000 (UTC) From: Bastien Nocera To: linux-bluetooth@vger.kernel.org Cc: Bastien Nocera Subject: [BlueZ v2 7/7] client: Fix --help hanging if bluetoothd is not running Date: Tue, 22 Oct 2024 13:58:37 +0200 Message-ID: <20241022120051.123888-8-hadess@hadess.net> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241022120051.123888-1-hadess@hadess.net> References: <20241022120051.123888-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 144e17622e95..798472ba2660 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); + bt_shell_handle_non_interactive_help(); + if (agent_option) auto_register_agent = g_strdup(agent_option); else