[PATCH v3] Use local icon for zeroconf shared devices

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

 



On Wed, 2016-08-31 at 18:14 +0200, Sylvain Baubeau wrote:
> systemd-hostnamed provides an icon for the machine it is running on.
> If it is running, module-zeroconf-publish uses this icon for the
> 'icon-name' attribute in the Avahi properties. module-zeroconf-discover
> passes this icon to module-tunnel using the module parameter
> {sink/source}_properties.
> 
> This allows to display a portable, desktop or phone instead of
> the generic sound card icon.
> ---
>  src/Makefile.am                        |  4 +-
>  src/modules/module-zeroconf-discover.c |  9 ++++
>  src/modules/module-zeroconf-publish.c  | 79 +++++++++++++++++++++++++++++++++-
>  3 files changed, 88 insertions(+), 4 deletions(-)
> 
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 7b19497..2d5bdd4 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -1899,8 +1899,8 @@ module_solaris_la_LIBADD = $(MODULE_LIBADD)
>  
>  module_zeroconf_publish_la_SOURCES = modules/module-zeroconf-publish.c
>  module_zeroconf_publish_la_LDFLAGS = $(MODULE_LDFLAGS)
> -module_zeroconf_publish_la_LIBADD = $(MODULE_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libprotocol-native.la
> -module_zeroconf_publish_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
> +module_zeroconf_publish_la_LIBADD = $(MODULE_LIBADD) $(AVAHI_LIBS) $(DBUS_LIBS) libavahi-wrap.la libprotocol-native.la
> +module_zeroconf_publish_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS) $(DBUS_CFLAGS)

Sorry for not realizing this already with the first version, but the D-
Bus functionality needs to be disabled if D-Bus support is not enabled.

> +static char *get_icon_name(pa_module*m) {
> +    const char *interface = HOSTNAME_DBUS_INTERFACE;
> +    const char *property = HOSTNAME_DBUS_ICON_PROPERTY;
> +    char *icon_name;
> +    pa_dbus_connection *bus;
> +    DBusError error;
> +    DBusMessageIter args;
> +    DBusMessage *msg = NULL;
> +    DBusMessage *reply = NULL;
> +    DBusConnection *conn = NULL;
> +    DBusMessageIter sub;
> +
> +    if (!(bus = pa_dbus_bus_get(m->core, DBUS_BUS_SYSTEM, &error))) {
> +        pa_log("Failed to get system bus connection: %s", error.message);
> +        goto out;
> +    }
> +
> +    conn = pa_dbus_connection_get(bus);
> +
> +    msg = dbus_message_new_method_call(HOSTNAME_DBUS_INTERFACE,
> +                                       HOSTNAME_DBUS_PATH,
> +                                       "org.freedesktop.DBus.Properties",
> +                                       "Get");
> +    dbus_message_append_args(msg, DBUS_TYPE_STRING, &interface, DBUS_TYPE_STRING, &property, DBUS_TYPE_INVALID);
> +
> +    dbus_error_init(&error);
> +    if ((reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &error)) == NULL) {
> +        pa_log("Failed to send: %s:%s\n", error.name, error.message);

No need for \n.

> +        dbus_error_free(&error);
> +        goto out;
> +    }
> +
> +    dbus_message_iter_init(reply, &args);
> +    if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_VARIANT) {
> +        pa_log("Incorrect reply type\n");

No need for \n.

> +        goto out;
> +    }
> +
> +    dbus_message_iter_recurse(&args, &sub);
> +
> +    if (dbus_message_iter_get_arg_type(&sub) != DBUS_TYPE_STRING) {
> +        pa_log("Incorrect value type\n");

No need for \n.

-- 
Tanu


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux