mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-26 13:44:23 +08:00
tools/obexctl: Add list command
Add support for list command which can be used to list available sessions
This commit is contained in:
parent
a55d1411b5
commit
ec9b36affc
@ -260,6 +260,42 @@ static void cmd_disconnect(int argc, char *argv[])
|
|||||||
g_dbus_proxy_get_path(proxy));
|
g_dbus_proxy_get_path(proxy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *proxy_description(GDBusProxy *proxy, const char *title,
|
||||||
|
const char *description)
|
||||||
|
{
|
||||||
|
const char *path;
|
||||||
|
|
||||||
|
path = g_dbus_proxy_get_path(proxy);
|
||||||
|
|
||||||
|
return g_strdup_printf("%s%s%s%s %s ",
|
||||||
|
description ? "[" : "",
|
||||||
|
description ? : "",
|
||||||
|
description ? "] " : "",
|
||||||
|
title, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_proxy(GDBusProxy *proxy, const char *title,
|
||||||
|
const char *description)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
str = proxy_description(proxy, title, description);
|
||||||
|
|
||||||
|
rl_printf("%s%s\n", str, default_session == proxy ? "[default]" : "");
|
||||||
|
|
||||||
|
g_free(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cmd_list(int argc, char *arg[])
|
||||||
|
{
|
||||||
|
GSList *l;
|
||||||
|
|
||||||
|
for (l = sessions; l; l = g_slist_next(l)) {
|
||||||
|
GDBusProxy *proxy = l->data;
|
||||||
|
print_proxy(proxy, "Session", NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *cmd;
|
const char *cmd;
|
||||||
const char *arg;
|
const char *arg;
|
||||||
@ -268,6 +304,7 @@ static const struct {
|
|||||||
} cmd_table[] = {
|
} cmd_table[] = {
|
||||||
{ "connect", "<dev> [uuid]", cmd_connect, "Connect session" },
|
{ "connect", "<dev> [uuid]", cmd_connect, "Connect session" },
|
||||||
{ "disconnect", "[session]", cmd_disconnect, "Disconnect session" },
|
{ "disconnect", "[session]", cmd_disconnect, "Disconnect session" },
|
||||||
|
{ "list", NULL, cmd_list, "List available sessions" },
|
||||||
{ "quit", NULL, cmd_quit, "Quit program" },
|
{ "quit", NULL, cmd_quit, "Quit program" },
|
||||||
{ "exit", NULL, cmd_quit },
|
{ "exit", NULL, cmd_quit },
|
||||||
{ "help" },
|
{ "help" },
|
||||||
@ -481,32 +518,6 @@ static guint setup_standard_input(void)
|
|||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *proxy_description(GDBusProxy *proxy, const char *title,
|
|
||||||
const char *description)
|
|
||||||
{
|
|
||||||
const char *path;
|
|
||||||
|
|
||||||
path = g_dbus_proxy_get_path(proxy);
|
|
||||||
|
|
||||||
return g_strdup_printf("%s%s%s%s %s ",
|
|
||||||
description ? "[" : "",
|
|
||||||
description ? : "",
|
|
||||||
description ? "] " : "",
|
|
||||||
title, path);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void print_proxy(GDBusProxy *proxy, const char *title,
|
|
||||||
const char *description)
|
|
||||||
{
|
|
||||||
char *str;
|
|
||||||
|
|
||||||
str = proxy_description(proxy, title, description);
|
|
||||||
|
|
||||||
rl_printf("%s%s\n", str, default_session == proxy ? "[default]" : "");
|
|
||||||
|
|
||||||
g_free(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void client_added(GDBusProxy *proxy)
|
static void client_added(GDBusProxy *proxy)
|
||||||
{
|
{
|
||||||
if (client == NULL)
|
if (client == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user