diff mbox series

[BlueZ,v1,2/2] client/player: Make transport.show print all transports with no argument

Message ID 20240927195416.2527923-2-luiz.dentz@gmail.com (mailing list archive)
State New
Headers show
Series [BlueZ,v1,1/2] client/player: Make endpoint.show print all endpoint with no argument | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint fail WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 1: T1 Title exceeds max length (87>80): "[BlueZ,v1,2/2] client/player: Make transport.show print all transports with no argument" 10: B3 Line contains hard tab characters (\t): " UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)" 11: B3 Line contains hard tab characters (\t): " Codec: 0x02 (2)" 12: B3 Line contains hard tab characters (\t): " Media Codec: MPEG24" 13: B3 Line contains hard tab characters (\t): " Object Types: MPEG-2 AAC LC" 14: B3 Line contains hard tab characters (\t): " Frequencies: 48kHz" 15: B3 Line contains hard tab characters (\t): " Channels: 2" 16: B3 Line contains hard tab characters (\t): " Bitrate: 320000" 17: B3 Line contains hard tab characters (\t): " VBR: Yes" 18: B3 Line contains hard tab characters (\t): " Device: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX" 19: B3 Line contains hard tab characters (\t): " State: active" 20: B3 Line contains hard tab characters (\t): " Delay: 0x06a4 (1700)" 21: B3 Line contains hard tab characters (\t): " Volume: 0x0059 (89)" 22: B3 Line contains hard tab characters (\t): " Endpoint: /org/bluez/hci0/dev_94_XX_XX_XX_XX_XX/sep4"
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Luiz Augusto von Dentz Sept. 27, 2024, 7:54 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This makes transport.show arguments optional and in case none is given
print all configured transports:

[bluetooth]# transport.show
Transport /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/sep4/fd0
	UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
	Codec: 0x02 (2)
	Media Codec: MPEG24
	Object Types: MPEG-2 AAC LC
	Frequencies: 48kHz
	Channels: 2
	Bitrate: 320000
	VBR: Yes
	Device: /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX
	State: active
	Delay: 0x06a4 (1700)
	Volume: 0x0059 (89)
	Endpoint: /org/bluez/hci0/dev_94_XX_XX_XX_XX_XX/sep4
---
 client/player.c | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/client/player.c b/client/player.c
index 39c14a9434cb..df22465169d5 100644
--- a/client/player.c
+++ b/client/player.c
@@ -5048,17 +5048,8 @@  static void print_configuration(GDBusProxy *proxy)
 	print_lc3_meta(data, len);
 }
 
-static void cmd_show_transport(int argc, char *argv[])
+static void print_transport_properties(GDBusProxy *proxy)
 {
-	GDBusProxy *proxy;
-
-	proxy = g_dbus_proxy_lookup(transports, NULL, argv[1],
-					BLUEZ_MEDIA_TRANSPORT_INTERFACE);
-	if (!proxy) {
-		bt_shell_printf("Transport %s not found\n", argv[1]);
-		return bt_shell_noninteractive_quit(EXIT_FAILURE);
-	}
-
 	bt_shell_printf("Transport %s\n", g_dbus_proxy_get_path(proxy));
 
 	print_property(proxy, "UUID");
@@ -5072,6 +5063,31 @@  static void cmd_show_transport(int argc, char *argv[])
 	print_property(proxy, "QoS");
 	print_property(proxy, "Location");
 	print_property(proxy, "Links");
+}
+
+static void print_transports(void *data, void *user_data)
+{
+	print_transport_properties(data);
+}
+
+static void cmd_show_transport(int argc, char *argv[])
+{
+	GDBusProxy *proxy;
+
+	/* Show all transports if no argument is given */
+	if (argc != 2) {
+		g_list_foreach(transports, print_transports, NULL);
+		return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+	}
+
+	proxy = g_dbus_proxy_lookup(transports, NULL, argv[1],
+					BLUEZ_MEDIA_TRANSPORT_INTERFACE);
+	if (!proxy) {
+		bt_shell_printf("Transport %s not found\n", argv[1]);
+		return bt_shell_noninteractive_quit(EXIT_FAILURE);
+	}
+
+	print_transport_properties(proxy);
 
 	return bt_shell_noninteractive_quit(EXIT_SUCCESS);
 }
@@ -5641,7 +5657,7 @@  static const struct bt_shell_menu transport_menu = {
 	.entries = {
 	{ "list",         NULL,    cmd_list_transport,
 						"List available transports" },
-	{ "show",        "<transport>", cmd_show_transport,
+	{ "show",        "[transport]", cmd_show_transport,
 						"Transport information",
 						transport_generator },
 	{ "acquire",     "<transport> [transport1...]", cmd_acquire_transport,