Skip to contentSkip to conversation

Draft of xdg-hostname support

PATCH In review Bastien Nocera 2 participants 3 messages Jun 12, 2009 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Draft of xdg-hostname support

Hey,

xdg-hostname[1] is a D-Bus service that offers notification on hostname changes, and provides an additional "Display hostname" (think MacOS X' and Windows' "computer name").

This would allow us to call adapters something like:
Bastien's laptop
rather than:
dhcp-1-124-1

The code is a first pass at the problem, and won't even run, but will compile. I'm thinking about changing that code, and I'm looking for hints on the direction (rather than comments on the dependencies or the coding style).

I'm thinking:
- Make expand_name UTF-8 aware
- Factor the main_opts.hostname setting code, and make it pluggable (hints?)
- Change the device name when the display name or hostname changes (would need to get added to the hciops plugin)

Comments? Ideas?

[1]: See
https://fedoraproject.org/wiki/Desktop/Whiteboards/BetterHostname
http://people.freedesktop.org/~david/xdg-hostname.png
http://cgit.freedesktop.org/~david/xdg-hostname/

Quoted 1 line

From ac801a01e01e50eb182ffb6bc33c09e0438bfae1 Mon Sep 17 00:00:00 2001

From: Bastien Nocera <[email protected]>
Date: Fri, 12 Jun 2009 15:19:17 +0100
Subject: [PATCH] Add draft xdg-hostname plugin

Use xdg-hostname's "display name" as the default name for the adapters.

---
 acinclude.m4        |   12 +++++
 configure.ac        |    1 +
 plugins/Makefile.am |    8 +++
 plugins/hostname.c  |  128 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/plugin.c        |    8 ++--
 5 files changed, 153 insertions(+), 4 deletions(-)
 create mode 100644 plugins/hostname.c
acinclude.m4 +12 -0
index eb7cdeb..34a62ca 100644
@@ -171,6 +171,12 @@ AC_DEFUN([AC_PATH_SNDFILE], [
 	AC_SUBST(SNDFILE_LIBS)
 ])
 
+AC_DEFUN([AC_PATH_XDG_HOSTNAME], [
+	PKG_CHECK_MODULES(XDG_HOSTNAME, xdg-hostname-gobject-1, xdg_hostname_found=yes, xdg_hostname_found=no)
+	AC_SUBST(XDG_HOSTNAME_CFLAGS)
+	AC_SUBST(XDG_HOSTNAME_LIBS)
+])
+
 AC_DEFUN([AC_ARG_BLUEZ], [
 	debug_enable=no
 	fortify_enable=yes
@@ -181,6 +187,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
 	usb_enable=${usb_found}
 	alsa_enable=${alsa_found}
 	gstreamer_enable=${gstreamer_found}
+	xdg_hostname_enable=${xdg_hostname_found}
 	audio_enable=yes
 	input_enable=yes
 	serial_enable=yes
@@ -233,6 +240,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [
 		gstreamer_enable=${enableval}
 	])
 
+	AC_ARG_ENABLE(xdg-hostname, AC_HELP_STRING([--enable-xdg-hostname], [enable xdg-hostname support]), [
+		xdg_hostname_enable=${enableval}
+	])
+
 	AC_ARG_ENABLE(alsa, AC_HELP_STRING([--enable-alsa], [enable ALSA support]), [
 		alsa_enable=${enableval}
 	])
@@ -339,6 +350,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
 	AM_CONDITIONAL(SBC, test "${alsa_enable}" = "yes" || test "${gstreamer_enable}" = "yes")
 	AM_CONDITIONAL(ALSA, test "${alsa_enable}" = "yes" && test "${alsa_found}" = "yes")
 	AM_CONDITIONAL(GSTREAMER, test "${gstreamer_enable}" = "yes" && test "${gstreamer_found}" = "yes")
+	AM_CONDITIONAL(XDG_HOSTNAME, test "${xdg_hostname_enable}" = "yes" && test "${xdg_hostname_found}" = "yes")
 	AM_CONDITIONAL(AUDIOPLUGIN, test "${audio_enable}" = "yes")
 	AM_CONDITIONAL(INPUTPLUGIN, test "${input_enable}" = "yes")
 	AM_CONDITIONAL(SERIALPLUGIN, test "${serial_enable}" = "yes")
configure.ac +1 -0
index da930e5..7f5faba 100644
@@ -38,6 +38,7 @@ AC_PATH_GSTREAMER
 AC_PATH_USB
 AC_PATH_NETLINK
 AC_PATH_SNDFILE
+AC_PATH_XDG_HOSTNAME
 
 AC_ARG_BLUEZ
 
plugins/Makefile.am +8 -0
index 9d9f970..1279116 100644
@@ -20,6 +20,12 @@ plugin_LTLIBRARIES += netlink.la
 netlink_la_LIBADD = @NETLINK_LIBS@
 endif
 
+if XDG_HOSTNAME
+plugin_LTLIBRARIES += hostname.la
+hostname_la_LIBADD = @XDG_HOSTNAME_LIBS@
+hostname_la_CFLAGS = $(XDG_HOSTNAME_CFLAGS) $(DBUS_CFLAGS)
+endif
+
 builtin_modules += hal
 builtin_sources += hal.c
 
@@ -63,9 +69,11 @@ all-local:
 	@$(LN_S) -f $(top_srcdir)/audio/.libs/audio.so
 	@$(LN_S) -f $(top_srcdir)/serial/.libs/serial.so
 	@$(LN_S) -f $(top_srcdir)/network/.libs/network.so
+	@$(LN_S) -f $(top_srcdir)/plugins/.libs/hostname.so
 
 clean-local:
 	@rm -f network.so
 	@rm -f serial.so
 	@rm -f audio.so
 	@rm -f input.so
+	@rm -f hostname.so
plugins/hostname.c new file +128 -0

128 lines not on this page · raw message

src/plugin.c +4 -4
index a57bf2c..4b752a8 100644
@@ -116,7 +116,7 @@ gboolean plugin_init(GKeyFile *config)
 	gchar **disabled;
 	unsigned int i;
 
-	if (strlen(PLUGINDIR) == 0)
+	if (strlen("../plugins") == 0)
 		return FALSE;
 
 	/* Make a call to BtIO API so its symbols got resolved before the
@@ -140,9 +140,9 @@ gboolean plugin_init(GKeyFile *config)
 		add_plugin(NULL,  __bluetooth_builtin[i]);
 	}
 
-	debug("Loading plugins %s", PLUGINDIR);
+	debug("Loading plugins %s", "../plugins");
 
-	dir = g_dir_open(PLUGINDIR, 0, NULL);
+	dir = g_dir_open("../plugins", 0, NULL);
 	if (!dir) {
 		g_strfreev(disabled);
 		return FALSE;
@@ -161,7 +161,7 @@ gboolean plugin_init(GKeyFile *config)
 		if (disabled && is_disabled(file, disabled))
 			continue;
 
-		filename = g_build_filename(PLUGINDIR, file, NULL);
+		filename = g_build_filename("../plugins", file, NULL);
 
 		if (stat(filename, &st) < 0) {
 			error("Can't find plugin %s: %s", filename,
Signature · 1 line
1.6.2.2
maintainer
#1 lore raw

Hi Bastien,

Quoted 14 lines

xdg-hostname[1] is a D-Bus service that offers notification on hostname changes, and provides an additional "Display hostname" (think MacOS X' and Windows' "computer name").

This would allow us to call adapters something like:
Bastien's laptop
rather than:
dhcp-1-124-1

The code is a first pass at the problem, and won't even run, but will compile. I'm thinking about changing that code, and I'm looking for hints on the direction (rather than comments on the dependencies or the coding style).

Quoted 6 lines

I'm thinking:
- Make expand_name UTF-8 aware
- Factor the main_opts.hostname setting code, and make it pluggable (hints?)
- Change the device name when the display name or hostname changes (would need to get added to the hciops plugin)

personally I never liked the Bluetooth name being derived from the bare hostname and desktop systems. So feel free to do something similar that we do for the class of device.

However keep in mind that systems like the N810 or similar wanna have a specific default name and we have to respect that. So if integration configures a default device name in main.conf then we should respect that.

Problem area as usual are the cases with multiple devices attached to the same system. Having them ending all up with the same name would be kind stupid.

Don't change src/plugin.c since bootstrap-configure will turn PLUGINDIR to the local repository anyway. And also you can have builtin plugins that will solve the testing issue.

Of course when you consider this seriously for inclusion, I expect a pure low-level D-Bus plugin here. Same as how we handle HAL.

Regards

Marcel

#2 lore raw
Quoted 23 lines · Marcel Holtmann

Hi Bastien,

Quoted 14 lines

xdg-hostname[1] is a D-Bus service that offers notification on hostname changes, and provides an additional "Display hostname" (think MacOS X' and Windows' "computer name").

This would allow us to call adapters something like:
Bastien's laptop
rather than:
dhcp-1-124-1

The code is a first pass at the problem, and won't even run, but will compile. I'm thinking about changing that code, and I'm looking for hints on the direction (rather than comments on the dependencies or the coding style).

Quoted 6 lines

I'm thinking:
- Make expand_name UTF-8 aware
- Factor the main_opts.hostname setting code, and make it pluggable (hints?)
- Change the device name when the display name or hostname changes (would need to get added to the hciops plugin)

Quoted 8 lines

personally I never liked the Bluetooth name being derived from the bare hostname and desktop systems. So feel free to do something similar that we do for the class of device.

However keep in mind that systems like the N810 or similar wanna have a specific default name and we have to respect that. So if integration configures a default device name in main.conf then we should respect that.

Sure. We'd adjust the default configuration slightly, and fix expand_name and leave it at that.

Quoted 3 lines

Problem area as usual are the cases with multiple devices attached to the same system. Having them ending all up with the same name would be kind stupid.

Yes. Although there's no real way to work around that.

Quoted 3 lines

Don't change src/plugin.c since bootstrap-configure will turn PLUGINDIR to the local repository anyway. And also you can have builtin plugins that will solve the testing issue.

Missed that bit. And the patch got into the commit by mistake.

Quoted 2 lines

Of course when you consider this seriously for inclusion, I expect a pure low-level D-Bus plugin here. Same as how we handle HAL.

Did you _actually_ read the mail:

Quoted 3 lines
Quoted 3 lines

and I'm looking for
hints on the direction (rather than comments on the dependencies or the coding style).

I'm still wondering how we can handle the hostname changing, and having the hostname overridden by a plugin.