diff options
author | marcus <marcus@FreeBSD.org> | 2008-04-02 02:20:25 +0800 |
---|---|---|
committer | marcus <marcus@FreeBSD.org> | 2008-04-02 02:20:25 +0800 |
commit | 1d274d13bca51290e107694b40f89eafda2e586f (patch) | |
tree | ab1a44acf0b6e5640bf50675974f133d97d945a0 /sysutils/hal | |
parent | ffa413f6e79ec3e4b36ca2c5b3920859fc78a7da (diff) | |
download | freebsd-ports-gnome-1d274d13bca51290e107694b40f89eafda2e586f.tar.gz freebsd-ports-gnome-1d274d13bca51290e107694b40f89eafda2e586f.tar.zst freebsd-ports-gnome-1d274d13bca51290e107694b40f89eafda2e586f.zip |
* Add an addon to poll mouse device files to see if moused or Xorg owns them.
This allows hal to properly reflect the correct access device, and prevents
X from opening the same device twice
* Use the less expensive clock_gettime() instead of gettimeofday() in hal's
pollers [1]
* Add support for locking storage devices
* Fix the path to the installed documentation
Submitted by: jkim [1]
Tested by: jkim, cokane, and a host of others
Diffstat (limited to 'sysutils/hal')
-rw-r--r-- | sysutils/hal/Makefile | 9 | ||||
-rw-r--r-- | sysutils/hal/files/10-mouse-sysmouse.fdi | 8 | ||||
-rw-r--r-- | sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi | 18 | ||||
-rw-r--r-- | sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in | 92 | ||||
-rw-r--r-- | sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c | 219 | ||||
-rw-r--r-- | sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c | 207 | ||||
-rw-r--r-- | sysutils/hal/files/patch-hald_freebsd_clock | 108 | ||||
-rw-r--r-- | sysutils/hal/pkg-plist | 2 |
8 files changed, 633 insertions, 30 deletions
diff --git a/sysutils/hal/Makefile b/sysutils/hal/Makefile index a0f48e7e1459..be5b10ef7096 100644 --- a/sysutils/hal/Makefile +++ b/sysutils/hal/Makefile @@ -8,7 +8,7 @@ PORTNAME= hal DISTVERSION= 0.5.11rc2 -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= sysutils MASTER_SITES= http://hal.freedesktop.org/releases/ @@ -52,8 +52,8 @@ CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \ USE_RC_SUBR= hald USE_GNOME_SUBR= yes -DOCSDIR= ${PREFIX}/share/doc/${PORTNAME}-${HALVERSION} -PLIST_SUB= VERSION=${HALVERSION} +DOCSDIR= ${PREFIX}/share/doc/${PORTNAME}-${DISTVERSION} +PLIST_SUB= VERSION=${DISTVERSION} RC_FILES= hal.conf:${PREFIX}/etc/dbus-1/system.d PLIST_FILES= ${PRIV_FILES:S|^|%%DATADIR%%/dist/|} @@ -102,6 +102,9 @@ post-patch: post-install: ${MKDIR} ${DATADIR}/dist ${INSTALL_DATA} ${WRKSRC}/hal.conf ${DATADIR}/dist + ${MKDIR} ${PREFIX}/share/hal/fdi/policy/10osvendor + ${INSTALL_DATA} ${FILESDIR}/10-mouse-sysmouse.fdi \ + ${PREFIX}/share/hal/fdi/policy/10osvendor @${SETENV} PKG_PREFIX=${PREFIX} PACKAGE_BUILDING=${PACKAGE_BUILDING} \ ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL .if !defined(PACKAGE_BUILDING) && defined(NEEDS_MEDIA) diff --git a/sysutils/hal/files/10-mouse-sysmouse.fdi b/sysutils/hal/files/10-mouse-sysmouse.fdi new file mode 100644 index 000000000000..cffd4f624e18 --- /dev/null +++ b/sysutils/hal/files/10-mouse-sysmouse.fdi @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<deviceinfo version="0.2"> + <device> + <match key="info.capabilities" contains="input.mouse"> + <append key="info.addons" type="strlist">hald-addon-mouse-sysmouse</append> + </match> + </device> +</deviceinfo> diff --git a/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi b/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi new file mode 100644 index 000000000000..f7af321c0943 --- /dev/null +++ b/sysutils/hal/files/patch-fdi_policy_10osvendor_10-x11-input.fdi @@ -0,0 +1,18 @@ +--- fdi/policy/10osvendor/10-x11-input.fdi.orig 2008-03-27 13:42:31.000000000 -0400 ++++ fdi/policy/10osvendor/10-x11-input.fdi 2008-03-27 13:48:06.000000000 -0400 +@@ -1,15 +1,6 @@ + <?xml version="1.0" encoding="ISO-8859-1"?> + <deviceinfo version="0.2"> + <device> +- <!-- FIXME: Support tablets too. --> +- <match key="info.capabilities" contains="input.mouse"> +- <merge key="input.x11_driver" type="string">mouse</merge> +- <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" +- string="Linux"> +- <merge key="input.x11_driver" type="string">evdev</merge> +- </match> +- </match> +- + <match key="info.capabilities" contains="input.keys"> + <!-- If we're using Linux, we use evdev by default (falling back to + keyboard otherwise). --> diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in b/sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in new file mode 100644 index 000000000000..beb677fa943a --- /dev/null +++ b/sysutils/hal/files/patch-hald_freebsd_addons_Makefile.in @@ -0,0 +1,92 @@ +--- hald/freebsd/addons/Makefile.in.orig 2008-03-27 00:45:50.000000000 -0400 ++++ hald/freebsd/addons/Makefile.in 2008-03-27 00:48:15.000000000 -0400 +@@ -33,7 +33,8 @@ POST_UNINSTALL = : + build_triplet = @build@ + host_triplet = @host@ + @HALD_COMPILE_FREEBSD_TRUE@libexec_PROGRAMS = \ +-@HALD_COMPILE_FREEBSD_TRUE@ hald-addon-storage$(EXEEXT) ++@HALD_COMPILE_FREEBSD_TRUE@ hald-addon-storage$(EXEEXT) \ ++@HALD_COMPILE_FREEBSD_TRUE@ hald-addon-mouse-sysmouse$(EXEEXT) + subdir = hald/freebsd/addons + DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +@@ -47,6 +48,15 @@ CONFIG_CLEAN_FILES = + am__installdirs = "$(DESTDIR)$(libexecdir)" + libexecPROGRAMS_INSTALL = $(INSTALL_PROGRAM) + PROGRAMS = $(libexec_PROGRAMS) ++am_hald_addon_mouse_sysmouse_OBJECTS = \ ++ hald_addon_mouse_sysmouse-addon-mouse.$(OBJEXT) ++hald_addon_mouse_sysmouse_OBJECTS = \ ++ $(am_hald_addon_mouse_sysmouse_OBJECTS) ++hald_addon_mouse_sysmouse_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la ++hald_addon_mouse_sysmouse_LINK = $(LIBTOOL) --tag=CC \ ++ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ ++ $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ ++ $(LDFLAGS) -o $@ + am_hald_addon_storage_OBJECTS = addon-storage.$(OBJEXT) + hald_addon_storage_OBJECTS = $(am_hald_addon_storage_OBJECTS) + hald_addon_storage_DEPENDENCIES = $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la +@@ -62,8 +72,10 @@ CCLD = $(CC) + LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +-SOURCES = $(hald_addon_storage_SOURCES) +-DIST_SOURCES = $(hald_addon_storage_SOURCES) ++SOURCES = $(hald_addon_mouse_sysmouse_SOURCES) \ ++ $(hald_addon_storage_SOURCES) ++DIST_SOURCES = $(hald_addon_mouse_sysmouse_SOURCES) \ ++ $(hald_addon_storage_SOURCES) + ETAGS = etags + CTAGS = ctags + DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +@@ -227,6 +239,11 @@ hald_addon_storage_SOURCES = addon-stora + hald_addon_storage_LDADD = \ + $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la + ++hald_addon_mouse_sysmouse_SOURCES = addon-mouse.c ++hald_addon_mouse_sysmouse_CFLAGS = $(AM_CPPFLAGS) @GLIB_CFLAGS@ ++hald_addon_mouse_sysmouse_LDADD = @GLIB_LIBS@ \ ++ $(top_builddir)/hald/freebsd/libprobe/libhald_freebsd_probe.la ++ + all: all-am + + .SUFFIXES: +@@ -288,6 +305,9 @@ clean-libexecPROGRAMS: + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done ++hald-addon-mouse-sysmouse$(EXEEXT): $(hald_addon_mouse_sysmouse_OBJECTS) $(hald_addon_mouse_sysmouse_DEPENDENCIES) ++ @rm -f hald-addon-mouse-sysmouse$(EXEEXT) ++ $(hald_addon_mouse_sysmouse_LINK) $(hald_addon_mouse_sysmouse_OBJECTS) $(hald_addon_mouse_sysmouse_LDADD) $(LIBS) + hald-addon-storage$(EXEEXT): $(hald_addon_storage_OBJECTS) $(hald_addon_storage_DEPENDENCIES) + @rm -f hald-addon-storage$(EXEEXT) + $(LINK) $(hald_addon_storage_OBJECTS) $(hald_addon_storage_LDADD) $(LIBS) +@@ -299,6 +319,7 @@ distclean-compile: + -rm -f *.tab.c + + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/addon-storage.Po@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Po@am__quote@ + + .c.o: + @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@@ -321,6 +342,20 @@ distclean-compile: + @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + ++hald_addon_mouse_sysmouse-addon-mouse.o: addon-mouse.c ++@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -MT hald_addon_mouse_sysmouse-addon-mouse.o -MD -MP -MF $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo -c -o hald_addon_mouse_sysmouse-addon-mouse.o `test -f 'addon-mouse.c' || echo '$(srcdir)/'`addon-mouse.c ++@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Po ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='addon-mouse.c' object='hald_addon_mouse_sysmouse-addon-mouse.o' libtool=no @AMDEPBACKSLASH@ ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ ++@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -c -o hald_addon_mouse_sysmouse-addon-mouse.o `test -f 'addon-mouse.c' || echo '$(srcdir)/'`addon-mouse.c ++ ++hald_addon_mouse_sysmouse-addon-mouse.obj: addon-mouse.c ++@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -MT hald_addon_mouse_sysmouse-addon-mouse.obj -MD -MP -MF $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo -c -o hald_addon_mouse_sysmouse-addon-mouse.obj `if test -f 'addon-mouse.c'; then $(CYGPATH_W) 'addon-mouse.c'; else $(CYGPATH_W) '$(srcdir)/addon-mouse.c'; fi` ++@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Tpo $(DEPDIR)/hald_addon_mouse_sysmouse-addon-mouse.Po ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='addon-mouse.c' object='hald_addon_mouse_sysmouse-addon-mouse.obj' libtool=no @AMDEPBACKSLASH@ ++@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ ++@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(hald_addon_mouse_sysmouse_CFLAGS) $(CFLAGS) -c -o hald_addon_mouse_sysmouse-addon-mouse.obj `if test -f 'addon-mouse.c'; then $(CYGPATH_W) 'addon-mouse.c'; else $(CYGPATH_W) '$(srcdir)/addon-mouse.c'; fi` ++ + mostlyclean-libtool: + -rm -f *.lo + diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c b/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c new file mode 100644 index 000000000000..21e413123908 --- /dev/null +++ b/sysutils/hal/files/patch-hald_freebsd_addons_addon-mouse.c @@ -0,0 +1,219 @@ +--- hald/freebsd/addons/addon-mouse.c.orig 2008-03-31 04:53:42.000000000 -0400 ++++ hald/freebsd/addons/addon-mouse.c 2008-03-31 05:07:19.000000000 -0400 +@@ -0,0 +1,216 @@ ++/*************************************************************************** ++ * CVSID: $Id$ ++ * ++ * addon-mouse.c : poll mice to disable moused(8) owned devices ++ * ++ * Copyright (C) 2008 Joe Marcus Clarke ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ++ * ++ **************************************************************************/ ++ ++#ifdef HAVE_CONFIG_H ++# include <config.h> ++#endif ++ ++#include <string.h> ++#include <stdlib.h> ++#include <assert.h> ++#include <unistd.h> ++#include <glib.h> ++ ++#include "libhal/libhal.h" ++ ++#include "../libprobe/hfp.h" ++ ++#define CMD "/usr/bin/fstat %s" ++ ++#define MOUSE_DRIVER "mouse" ++#define MOUSED_DEVICE "/dev/sysmouse" ++#define MOUSED_PROC_NAME "moused" ++#define XORG_PROC_NAME "Xorg" ++ ++static struct ++{ ++ const struct timespec update_interval; ++ char *device_file; ++ struct timespec next_update; ++} addon = { { 2, 0 } }; ++ ++static gboolean ++device_opened_by_proc (const char *device, const char *proc) ++{ ++ char **lines; ++ char *output = NULL; ++ char *cmd; ++ int i; ++ gboolean found = FALSE; ++ ++ cmd = g_strdup_printf(CMD, device); ++ ++ if (! g_spawn_command_line_sync (cmd, &output, NULL, NULL, NULL)) ++ { ++ g_free(cmd); ++ goto done; ++ } ++ g_free(cmd); ++ ++ if (! output || strlen(output) == 0) ++ goto done; ++ ++ lines = g_strsplit(output, "\n", 0); ++ if (g_strv_length(lines) < 2) ++ { ++ g_strfreev(lines); ++ goto done; ++ } ++ ++ for (i = 1; lines[i]; i++) ++ { ++ char **fields; ++ guint len; ++ guint j; ++ ++ fields = g_strsplit_set(lines[i], " ", 0); ++ len = g_strv_length(fields); ++ if (len < 2) ++ { ++ g_strfreev(fields); ++ continue; ++ } ++ for (j = 1; j < len && fields[j] && *fields[j] == '\0'; j++) ++ ; ++ if (j < len && fields[j] && ! strcmp(fields[j], proc)) ++ { ++ found = TRUE; ++ g_strfreev(fields); ++ break; ++ } ++ g_strfreev(fields); ++ } ++ ++ g_strfreev(lines); ++ ++done: ++ g_free(output); ++ ++ return found; ++} ++ ++static const char * ++get_mouse_device (const char *device) ++{ ++ if (device_opened_by_proc(device, MOUSED_PROC_NAME)) ++ return MOUSED_DEVICE; ++ ++ return device; ++} ++ ++static void ++poll_for_moused (void) ++{ ++ char *driver; ++ char *old_device; ++ const char *device; ++ gboolean found; ++ ++ old_device = libhal_device_get_property_string(hfp_ctx, hfp_udi, "input.device", &hfp_error); ++ dbus_error_free(&hfp_error); ++ ++ device = get_mouse_device(addon.device_file); ++ if (strcmp(old_device, device)) ++ { ++ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.device", device, &hfp_error); ++ dbus_error_free(&hfp_error); ++ } ++ g_free(old_device); ++ ++ driver = libhal_device_get_property_string(hfp_ctx, hfp_udi, "input.x11_driver", &hfp_error); ++ dbus_error_free(&hfp_error); ++ ++ found = (strcmp(device, MOUSED_DEVICE) == 0); ++ if (! found) ++ found = device_opened_by_proc(device, XORG_PROC_NAME); ++ ++ if (found && driver) ++ { ++ libhal_device_remove_property(hfp_ctx, hfp_udi, "input.x11_driver", &hfp_error); ++ dbus_error_free(&hfp_error); ++ } ++ else if (! (found || driver)) ++ { ++ libhal_device_set_property_string(hfp_ctx, hfp_udi, "input.x11_driver", MOUSE_DRIVER, &hfp_error); ++ dbus_error_free(&hfp_error); ++ } ++ ++ g_free(driver); ++} ++ ++int ++main (int argc, char **argv) ++{ ++ DBusConnection *connection; ++ ++ if (! hfp_init(argc, argv)) ++ goto end; ++ ++ addon.device_file = getenv("HAL_PROP_FREEBSD_DEVICE_FILE"); ++ if (! addon.device_file) ++ goto end; ++ ++ setproctitle("%s", addon.device_file); ++ ++ if (! libhal_device_addon_is_ready(hfp_ctx, hfp_udi, &hfp_error)) ++ goto end; ++ dbus_error_free(&hfp_error); ++ ++ connection = libhal_ctx_get_dbus_connection(hfp_ctx); ++ assert(connection != NULL); ++ ++ while (TRUE) ++ { ++ /* process dbus traffic until update interval has elapsed */ ++ while (TRUE) ++ { ++ struct timespec now; ++ ++ hfp_clock_gettime(&now); ++ if (hfp_timespeccmp(&now, &addon.next_update, <)) ++ { ++ struct timespec timeout; ++ ++ timeout = addon.next_update; ++ hfp_timespecsub(&timeout, &now); ++ ++ if (timeout.tv_sec < 0) /* current time went backwards */ ++ timeout = addon.update_interval; ++ ++ dbus_connection_read_write_dispatch(connection, timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000); ++ if (! dbus_connection_get_is_connected(connection)) ++ goto end; ++ } ++ else ++ break; ++ } ++ ++ poll_for_moused(); ++ ++ hfp_clock_gettime(&addon.next_update); ++ hfp_timespecadd(&addon.next_update, &addon.update_interval); ++ } ++ ++ end: ++ return 0; ++} diff --git a/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c b/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c index ebeeb072c7af..717fc03e48c3 100644 --- a/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c +++ b/sysutils/hal/files/patch-hald_freebsd_addons_addon-storage.c @@ -1,15 +1,81 @@ --- hald/freebsd/addons/addon-storage.c.orig 2008-03-17 17:25:16.000000000 -0400 -+++ hald/freebsd/addons/addon-storage.c 2008-03-22 03:25:19.000000000 -0400 -@@ -150,6 +150,34 @@ hf_addon_storage_update (void) ++++ hald/freebsd/addons/addon-storage.c 2008-03-31 04:41:55.000000000 -0400 +@@ -36,17 +36,23 @@ + #include "../libprobe/hfp.h" + #include "../libprobe/hfp-cdrom.h" + ++static boolean is_locked_by_hal = FALSE; ++static boolean check_lock_state = TRUE; ++static boolean polling_disabled = FALSE; ++ + static struct + { +- const struct timeval update_interval; ++ const struct timespec update_interval; + char *device_file; + char *parent; + boolean is_cdrom; + boolean is_scsi_removable; + boolean had_media; +- struct timeval next_update; ++ struct timespec next_update; + } addon = { { 2, 0 } }; + ++static void update_proc_title (const char *device); ++ + /* see MMC-3 Working Draft Revision 10 */ + static boolean + hf_addon_storage_cdrom_eject_pressed (HFPCDROM *cdrom) +@@ -144,19 +150,114 @@ hf_addon_storage_update (void) + } + } + +- hfp_gettimeofday(&addon.next_update); +- hfp_timevaladd(&addon.next_update, &addon.update_interval); +- return has_media; } +static boolean -+poll_for_media (void) ++poll_for_media (boolean check_only, boolean force) +{ + boolean has_media; + ++ if (check_lock_state) ++ { ++ boolean should_poll; ++ ++ check_lock_state = FALSE; ++ ++ hfp_info("Checking whether device %s is locked by HAL", addon.device_file); ++ if (libhal_device_is_locked_by_others(hfp_ctx, hfp_udi, "org.freedesktop.Hal.Device.Storage", &hfp_error)) ++ { ++ hfp_info("... device %s is locked by HAL", addon.device_file); ++ dbus_error_free(&hfp_error); ++ is_locked_by_hal = TRUE; ++ update_proc_title(addon.device_file); ++ goto skip_check; ++ } ++ else ++ { ++ hfp_info("... device %s is not locked by HAL", addon.device_file); ++ is_locked_by_hal = FALSE; ++ } ++ dbus_error_free(&hfp_error); ++ ++ should_poll = libhal_device_get_property_bool(hfp_ctx, hfp_udi, "storage.media_check_enabled", &hfp_error); ++ dbus_error_free(&hfp_error); ++ polling_disabled = ! should_poll; ++ update_proc_title(addon.device_file); ++ } ++ ++ if (! force && polling_disabled) ++ goto skip_check; ++ + has_media = hf_addon_storage_update(); ++ if (check_only) ++ return has_media; ++ + if (has_media != addon.had_media) + { + /* @@ -29,18 +95,37 @@ + + return TRUE; + } ++ ++skip_check: ++ + return FALSE; +} + static void - update_proc_title (const char *device, boolean polling_enabled) +-update_proc_title (const char *device, boolean polling_enabled) ++update_proc_title (const char *device) { -@@ -159,6 +187,29 @@ update_proc_title (const char *device, b +- if (polling_enabled) +- setproctitle("%s", device); +- else ++ if (polling_disabled) setproctitle("no polling on %s because it is explicitly disabled", device); - } - ++ else if (is_locked_by_hal) ++ setproctitle("no polling on %s because it is locked by HAL", device); ++ else ++ setproctitle("%s", device); ++} ++ +static DBusHandlerResult -+filter_function (DBusConnection *connection, DBusMessage *message, void *user_data) ++dbus_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data) ++{ ++ check_lock_state = TRUE; ++ ++ return DBUS_HANDLER_RESULT_HANDLED; ++} ++ ++static DBusHandlerResult ++direct_filter_function (DBusConnection *connection, DBusMessage *message, void *user_data) +{ + if (dbus_message_is_method_call(message, + "org.freedesktop.Hal.Device.Storage.Removable", @@ -51,7 +136,7 @@ + + hfp_info("Forcing poll for media becusse CheckForMedia() was called"); + -+ had_effect = poll_for_media(); ++ had_effect = poll_for_media(FALSE, TRUE); + + reply = dbus_message_new_method_return (message); + dbus_message_append_args(reply, DBUS_TYPE_BOOLEAN, &had_effect, DBUS_TYPE_INVALID); @@ -60,23 +145,60 @@ + } + + return DBUS_HANDLER_RESULT_HANDLED; -+} -+ + } + int - main (int argc, char **argv) - { -@@ -202,13 +253,30 @@ main (int argc, char **argv) - ! strcmp(driver, "cd")))) && ! strcmp(removable, "true"); - addon.had_media = hf_addon_storage_update(); +@@ -166,8 +267,9 @@ main (int argc, char **argv) + char *removable; + char *bus; + char *driver; +- boolean should_poll; ++ char *filter_str; + DBusConnection *connection; ++ DBusConnection *syscon; + if (! hfp_init(argc, argv)) + goto end; +@@ -200,69 +302,86 @@ main (int argc, char **argv) + addon.is_scsi_removable = (! strcmp(bus, "scsi") || + (! strcmp(bus, "usb") && (! strcmp(driver, "da") || ! strcmp(driver, "sa") || + ! strcmp(driver, "cd")))) && ! strcmp(removable, "true"); +- addon.had_media = hf_addon_storage_update(); ++ addon.had_media = poll_for_media(TRUE, FALSE); ++ + if (! libhal_device_addon_is_ready(hfp_ctx, hfp_udi, &hfp_error)) + goto end; + dbus_error_free(&hfp_error); + ++ syscon = dbus_bus_get(DBUS_BUS_SYSTEM, &hfp_error); ++ dbus_error_free(&hfp_error); ++ assert(syscon != NULL); ++ dbus_connection_set_exit_on_disconnect(syscon, 0); ++ ++ dbus_bus_add_match(syscon, ++ "type='signal'" ++ ",interface='org.freedesktop.Hal.Manager'" ++ ",sender='org.freedesktop.Hal'", ++ NULL); ++ dbus_bus_add_match(syscon, ++ "type='signal'" ++ ",interface='org.freedesktop.Hal.Manager'" ++ ",sender='org.freedesktop.Hal'", ++ NULL); ++ filter_str = hfp_strdup_printf("type='signal'" ++ ",interface='org.freedesktop.Hal.Device'" ++ ",sender='org.freedesktop.Hal'" ++ ",path='%s'", ++ hfp_udi); ++ dbus_bus_add_match(syscon, filter_str, NULL); ++ hfp_free(filter_str); ++ ++ dbus_connection_add_filter(syscon, dbus_filter_function, NULL, NULL); + connection = libhal_ctx_get_dbus_connection(hfp_ctx); assert(connection != NULL); + dbus_connection_set_exit_on_disconnect(connection, 0); -+ dbus_connection_add_filter(connection, filter_function, NULL, NULL); ++ dbus_connection_add_filter(connection, direct_filter_function, NULL, NULL); - while (TRUE) + if (! libhal_device_claim_interface(hfp_ctx, @@ -98,19 +220,42 @@ /* process dbus traffic until update interval has elapsed */ while (TRUE) { -@@ -225,7 +293,7 @@ main (int argc, char **argv) +- struct timeval now; ++ struct timespec now; + +- hfp_gettimeofday(&now); +- if (hfp_timevalcmp(&now, &addon.next_update, <)) ++ hfp_clock_gettime(&now); ++ if (hfp_timespeccmp(&now, &addon.next_update, <)) + { +- struct timeval timeout; ++ struct timespec timeout; + + timeout = addon.next_update; +- hfp_timevalsub(&timeout, &now); ++ hfp_timespecsub(&timeout, &now); + if (timeout.tv_sec < 0) /* current time went backwards */ timeout = addon.update_interval; - dbus_connection_read_write(connection, timeout.tv_sec * 1000 + timeout.tv_usec / 1000); -+ dbus_connection_read_write_dispatch(connection, timeout.tv_sec * 1000 + timeout.tv_usec / 1000); - if (! dbus_connection_get_is_connected(connection)) +- if (! dbus_connection_get_is_connected(connection)) ++ dbus_connection_read_write_dispatch(connection, (int) ((timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000) / 2)); ++ dbus_connection_read_write_dispatch(syscon, (int) ((timeout.tv_sec * 1000 + timeout.tv_nsec / 1000000) / 2)); ++ if (! dbus_connection_get_is_connected(connection) || ++ ! dbus_connection_get_is_connected(syscon)) goto end; } -@@ -239,24 +307,7 @@ main (int argc, char **argv) + else + break; + } - if (should_poll) - { +- should_poll = libhal_device_get_property_bool(hfp_ctx, hfp_udi, "storage.media_check_enabled", &hfp_error); +- dbus_error_free(&hfp_error); +- update_proc_title(addon.device_file, should_poll); +- +- if (should_poll) +- { - has_media = hf_addon_storage_update(); - if (has_media != addon.had_media) - { @@ -129,7 +274,15 @@ - dbus_error_free(&hfp_error); - addon.had_media = has_media; - } -+ poll_for_media(); - } - else - { +- } +- else +- { +- hfp_gettimeofday(&addon.next_update); +- hfp_timevaladd(&addon.next_update, &addon.update_interval); +- } ++ poll_for_media(FALSE, FALSE); ++ hfp_clock_gettime(&addon.next_update); ++ hfp_timespecadd(&addon.next_update, &addon.update_interval); + } + + end: diff --git a/sysutils/hal/files/patch-hald_freebsd_clock b/sysutils/hal/files/patch-hald_freebsd_clock new file mode 100644 index 000000000000..5ce33fde67e2 --- /dev/null +++ b/sysutils/hal/files/patch-hald_freebsd_clock @@ -0,0 +1,108 @@ +--- hald/freebsd/libprobe/hfp.c.orig 2008-03-17 17:25:17.000000000 -0400 ++++ hald/freebsd/libprobe/hfp.c 2008-03-26 12:07:32.000000000 -0400 +@@ -216,55 +216,59 @@ hfp_getenv_bool (const char *variable) + } + + void +-hfp_gettimeofday (struct timeval *t) ++hfp_clock_gettime (struct timespec *t) + { + int status; + + assert(t != NULL); + +- status = gettimeofday(t, NULL); ++#ifdef CLOCK_MONOTONIC_FAST ++ status = clock_gettime(CLOCK_MONOTONIC_FAST, t); ++#else ++ status = clock_gettime(CLOCK_MONOTONIC, t); ++#endif + assert(status == 0); + } + +-/* timeval functions from sys/kern/kern_time.c */ ++/* timespec functions from sys/kern/kern_time.c */ + + static void +-hfp_timevalfix (struct timeval *t) ++hfp_timespecfix (struct timespec *t) + { + assert(t != NULL); + +- if (t->tv_usec < 0) ++ if (t->tv_nsec < 0) + { + t->tv_sec--; +- t->tv_usec += 1000000; ++ t->tv_nsec += 1000000000; + } +- if (t->tv_usec >= 1000000) ++ if (t->tv_nsec >= 1000000000) + { + t->tv_sec++; +- t->tv_usec -= 1000000; ++ t->tv_nsec -= 1000000000; + } + } + + void +-hfp_timevaladd (struct timeval *t1, const struct timeval *t2) ++hfp_timespecadd (struct timespec *t1, const struct timespec *t2) + { + assert(t1 != NULL); + assert(t2 != NULL); + + t1->tv_sec += t2->tv_sec; +- t1->tv_usec += t2->tv_usec; ++ t1->tv_nsec += t2->tv_nsec; + +- hfp_timevalfix(t1); ++ hfp_timespecfix(t1); + } + + void +-hfp_timevalsub (struct timeval *t1, const struct timeval *t2) ++hfp_timespecsub (struct timespec *t1, const struct timespec *t2) + { + assert(t1 != NULL); + assert(t2 != NULL); + + t1->tv_sec -= t2->tv_sec; +- t1->tv_usec -= t2->tv_usec; ++ t1->tv_nsec -= t2->tv_nsec; + +- hfp_timevalfix(t1); ++ hfp_timespecfix(t1); + } +--- hald/freebsd/libprobe/hfp.h.orig 2008-03-17 17:25:17.000000000 -0400 ++++ hald/freebsd/libprobe/hfp.h 2008-03-26 12:05:36.000000000 -0400 +@@ -29,8 +29,8 @@ + #endif + + #include <stdarg.h> ++#include <time.h> + #include <sys/types.h> +-#include <sys/time.h> + + #include "libhal/libhal.h" + +@@ -84,14 +84,14 @@ void volume_id_log (const char *format, + + boolean hfp_getenv_bool (const char *variable); + +-void hfp_gettimeofday (struct timeval *t); +-void hfp_timevaladd (struct timeval *t1, const struct timeval *t2); +-void hfp_timevalsub (struct timeval *t1, const struct timeval *t2); ++void hfp_clock_gettime (struct timespec *t); ++void hfp_timespecadd (struct timespec *t1, const struct timespec *t2); ++void hfp_timespecsub (struct timespec *t1, const struct timespec *t2); + + /* from sys/time.h (_KERNEL) */ +-#define hfp_timevalcmp(t1, t2, cmp) \ ++#define hfp_timespeccmp(t1, t2, cmp) \ + (((t1)->tv_sec == (t2)->tv_sec \ +- ? ((t1)->tv_usec cmp (t2)->tv_usec) \ ++ ? ((t1)->tv_nsec cmp (t2)->tv_nsec) \ + : ((t1)->tv_sec cmp (t2)->tv_sec))) + + #endif /* _HFP_H */ diff --git a/sysutils/hal/pkg-plist b/sysutils/hal/pkg-plist index 92c5a73c86ff..1c75cccbe755 100644 --- a/sysutils/hal/pkg-plist +++ b/sysutils/hal/pkg-plist @@ -61,6 +61,7 @@ libexec/hal/scripts/hal-system-power-suspend-hybrid libexec/hal/scripts/hal-system-wol-enable libexec/hal/scripts/hal-system-wol-enabled libexec/hal/scripts/hal-system-wol-supported +libexec/hald-addon-mouse-sysmouse libexec/hald-addon-storage libexec/hald-generate-fdi-cache libexec/hald-probe-hiddev @@ -78,6 +79,7 @@ sbin/hald %%DATADIR%%/fdi/policy/10osvendor/10-dockstation.fdi %%DATADIR%%/fdi/policy/10osvendor/10-input-policy.fdi %%DATADIR%%/fdi/policy/10osvendor/10-laptop-panel-mgmt-policy.fdi +%%DATADIR%%/fdi/policy/10osvendor/10-mouse-sysmouse.fdi %%DATADIR%%/fdi/policy/10osvendor/10-power-mgmt-policy.fdi %%DATADIR%%/fdi/policy/10osvendor/10-rfkill-switch.fdi %%DATADIR%%/fdi/policy/10osvendor/10-tabletPCs.fdi |