Re: [PATCH BlueZ v2] tools/obexctl: Add command line options to support session/system bus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, Nov 11, 2024 at 11:50 PM <quic_dgangire@xxxxxxxxxxx> wrote:
>
> From: Damodar Reddy GangiReddy <quic_dgangire@xxxxxxxxxxx>
>
> Currently obexctl only uses session bus.
> As obexd has been enabled support for both session and system bus.
> Configuring obexctl to use session/system bus during the runtime
> with command line options.
> ./obexctl --bustype=system or --bustype=session.
> By Default session bus will be used.

I think we should probably attempt to detect at runtime if the name is
available over session or system.

> ---
>  tools/obexctl.c | 30 ++++++++++++++++++++++++++++--
>  1 file changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/tools/obexctl.c b/tools/obexctl.c
> index a398b095b..d88ffc9fe 100644
> --- a/tools/obexctl.c
> +++ b/tools/obexctl.c
> @@ -2149,16 +2149,42 @@ static void property_changed(GDBusProxy *proxy, const char *name,
>                 session_property_changed(proxy, name, iter);
>  }
>
> +static const char *help[] = {
> +               "Configures either session or system bus.By Default session bus is used",
> +};
> +
> +static const char *bustype_option;
> +
> +static const char **optargs[] = {
> +               &bustype_option
> +};
> +
> +static const struct option options[] = {
> +               { "bustype", required_argument, 0, 'b' },
> +               { 0, 0, 0, 0 }
> +};
> +
> +static const struct bt_shell_opt opt = {
> +               .options = options,
> +               .optno = sizeof(options) / sizeof(struct option),
> +               .optstr = "b",
> +               .optarg = optargs,
> +               .help = help,
> +};
> +
>  int main(int argc, char *argv[])
>  {
>         GDBusClient *client;
>         int status;
>
> -       bt_shell_init(argc, argv, NULL);
> +       bt_shell_init(argc, argv, &opt);
>         bt_shell_set_menu(&main_menu);
>         bt_shell_set_prompt(PROMPT, NULL);
>
> -       dbus_conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
> +       if (bustype_option && !(strcmp(bustype_option, "system")))
> +               dbus_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
> +       else
> +               dbus_conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
>
>         client = g_dbus_client_new(dbus_conn, "org.bluez.obex",
>                                                         "/org/bluez/obex");
> --
> 2.34.1
>
>


-- 
Luiz Augusto von Dentz





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux