diff options
author | David Zeuthen <david@fubar.dk> | 2004-04-07 18:18:50 +0000 |
---|---|---|
committer | David Zeuthen <david@fubar.dk> | 2004-04-07 18:18:50 +0000 |
commit | d39117f8498fc567ed6aa76e6e084ee3343cba0f (patch) | |
tree | 2936f9efcf2ba4a785b7e13d54ce1ed3b2e68c38 | |
parent | a6437167cda65ff8a005a8194f07bdca26bdc4e9 (diff) |
New file for sending device event
Build and install hal.dev
Add accept method to ClassDeviceHandler
Create /etc/hal/device.d and /etc/hal/capability.d
new function (handle_udev_node_created): removed function
(osspec_filter_function): Handle events from hal.dev so we don't need
to rely on udev having built-in dbus support
Bump version to 0.2.90
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | Doxyfile | 2 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | hald/Makefile.am | 5 | ||||
-rw-r--r-- | hald/linux/block_class_device.c | 1 | ||||
-rw-r--r-- | hald/linux/class_device.c | 25 | ||||
-rw-r--r-- | hald/linux/class_device.h | 22 | ||||
-rw-r--r-- | hald/linux/input_class_device.c | 1 | ||||
-rw-r--r-- | hald/linux/osspec.c | 83 | ||||
-rw-r--r-- | hald/linux/printer_class_device.c | 3 | ||||
-rw-r--r-- | hald/linux/scsi_device_class_device.c | 1 | ||||
-rw-r--r-- | hald/linux/scsi_host_class_device.c | 1 | ||||
-rw-r--r-- | tools/linux/Makefile.am | 9 |
13 files changed, 113 insertions, 62 deletions
@@ -1,3 +1,21 @@ +2004-04-07 David Zeuthen <david@fubar.dk> + + * tools/linux/hal_dev.c: New file for sending device event + + * tools/linux/Makefile.am: Build and install hal.dev + + * hald/linux/class_device.h: Add accept method to ClassDeviceHandler + + * hald/Makefile.am (install-data-local): Create /etc/hal/device.d and + /etc/hal/capability.d + + * hald/linux/osspec.c (handle_device_event): new function + (handle_udev_node_created): removed function + (osspec_filter_function): Handle events from hal.dev so we don't + need to rely on udev having built-in dbus support + + * configure.in: Bump version to 0.2.90 + 2004-04-05 Joe Shaw <joe@ximian.com> * hald/linux/printer_class_device.c: Added. New printer class. @@ -23,7 +23,7 @@ PROJECT_NAME = HAL # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 0.2.6 +PROJECT_NUMBER = 0.2.90 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/configure.in b/configure.in index aea54cc8..9d05e6cc 100644 --- a/configure.in +++ b/configure.in @@ -1,8 +1,8 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.57) -AC_INIT(hal, 0.2.6, david@fubar.dk) -AM_INIT_AUTOMAKE(hal, 0.2.6) +AC_INIT(hal, 0.2.90, david@fubar.dk) +AM_INIT_AUTOMAKE(hal, 0.2.90) AM_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE diff --git a/hald/Makefile.am b/hald/Makefile.am index eaa5e5e5..7364dd73 100644 --- a/hald/Makefile.am +++ b/hald/Makefile.am @@ -89,3 +89,8 @@ hald_marshal.c: hald_marshal.list clean-local: rm -f *~ rm -f hald_marshal.c hald_marshal.h + +install-data-local : + $(mkinstalldirs) $(DESTDIR)$(SYSCONFDIR)/hal/device.d + $(mkinstalldirs) $(DESTDIR)$(SYSCONFDIR)/hal/capability.d + diff --git a/hald/linux/block_class_device.c b/hald/linux/block_class_device.c index 2ef79404..92f9ea0a 100644 --- a/hald/linux/block_class_device.c +++ b/hald/linux/block_class_device.c @@ -1222,6 +1222,7 @@ ClassDeviceHandler block_class_handler = { block_class_detection_done, /**< detection is done */ class_device_shutdown, /**< shutdown function */ block_class_tick, /**< timer function */ + class_device_accept, /**< accept function */ block_class_visit, /**< visitor function */ block_class_removed, /**< class device is removed */ class_device_udev_event, /**< handle udev event */ diff --git a/hald/linux/class_device.c b/hald/linux/class_device.c index 4d051c23..e1697d3f 100644 --- a/hald/linux/class_device.c +++ b/hald/linux/class_device.c @@ -61,6 +61,27 @@ class_device_got_device_file (HalDevice *d, gpointer user_data, gboolean prop_exists); +/** Generic accept function that accepts the device if and only if + * the class name from sysfs equals the class name in the class + * + * @param self Pointer to class members + * @param path Sysfs-path for device + * @param class_device libsysfs object for class device + * @param is_probing Set to TRUE only on initial detection + */ +dbus_bool_t +class_device_accept (ClassDeviceHandler *self, + const char *path, + struct sysfs_class_device *class_device, + dbus_bool_t is_probing) +{ + /* only care about given sysfs class name */ + if (strcmp (class_device->classname, self->sysfs_class_name) == 0) + return TRUE; + + return FALSE; +} + /** Generic visitor method for class devices. * * This function parses the attributes present and merges more information @@ -81,10 +102,6 @@ class_device_visit (ClassDeviceHandler *self, char dev_file[SYSFS_PATH_MAX]; char dev_file_prop_name[SYSFS_PATH_MAX]; - /* only care about given sysfs class name */ - if (strcmp (class_device->classname, self->sysfs_class_name) != 0) - return; - /* don't care if there is no sysdevice */ if (class_device->sysdevice == NULL) { return; diff --git a/hald/linux/class_device.h b/hald/linux/class_device.h index 681c0794..a833e16a 100644 --- a/hald/linux/class_device.h +++ b/hald/linux/class_device.h @@ -58,6 +58,23 @@ struct ClassDeviceHandler_s { */ void (*tick) (ClassDeviceHandler* self); + /** Called when processing a new device instance to determine + * whether this class accepts this kind of device. + * + * @param self Pointer to class members + * @param sysfs_path The path in sysfs (including mount point) of + * the device in sysfs + * @param class_device Libsysfs object representing new class device + * instance + * @param is_probing Set to TRUE only on initial detection + * @return Must return TRUE if this class should + * process this device + */ + dbus_bool_t (*accept) (ClassDeviceHandler *self, + const char *sysfs_path, + struct sysfs_class_device *class_device, + dbus_bool_t is_probing); + /** Called when a new instance of a class device is detected either * through hotplug or through initial detection. * @@ -194,6 +211,11 @@ struct ClassDeviceHandler_s { dbus_bool_t merge_or_add; }; +dbus_bool_t class_device_accept (ClassDeviceHandler *self, + const char *path, + struct sysfs_class_device *class_device, + dbus_bool_t is_probing); + void class_device_visit (ClassDeviceHandler *self, const char *path, struct sysfs_class_device *class_device, diff --git a/hald/linux/input_class_device.c b/hald/linux/input_class_device.c index 239bea43..42eedf23 100644 --- a/hald/linux/input_class_device.c +++ b/hald/linux/input_class_device.c @@ -128,6 +128,7 @@ ClassDeviceHandler input_class_handler = { class_device_detection_done, /**< detection is done */ class_device_shutdown, /**< shutdown function */ class_device_tick, /**< timer function */ + class_device_accept, /**< accept function */ class_device_visit, /**< visitor function */ class_device_removed, /**< class device is removed */ class_device_udev_event, /**< handle udev event */ diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c index 0b7a0f4e..1671e3bc 100644 --- a/hald/linux/osspec.c +++ b/hald/linux/osspec.c @@ -122,7 +122,8 @@ visit_class_device (const char *path, dbus_bool_t visit_children) for (i=0; class_device_handlers[i] != NULL; i++) { ClassDeviceHandler *ch = class_device_handlers[i]; - ch->visit (ch, path, class_device, is_probing); + if (ch->accept (ch, path, class_device, is_probing)) + ch->visit (ch, path, class_device, is_probing); } /* Visit children */ @@ -546,59 +547,46 @@ udev_node_created_cb (HalDeviceStore *store, HalDevice *device, handle_udev_node_created_found_device (device, (void*) filename, NULL); } -/** Handle a org.freedesktop.Hal.HotplugEvent message. This message - * origins from the hal.hotplug program, tools/linux/hal_hotplug.c, - * and is basically just a D-BUS-ification of the hotplug event. + +/** Handle a org.freedesktop.Hal.DeviceEvent message. This message + * origins from the hal.dev program, tools/linux/hal_dev.c, + * and is basically just a D-BUS-ification of the device event from udev. * * @param connection D-BUS connection * @param message Message * @return What to do with the message */ static DBusHandlerResult -handle_udev_node_created (DBusConnection * connection, - DBusMessage * message) +handle_device_event (DBusConnection * connection, + DBusMessage * message) { + dbus_bool_t is_add; char *filename; char *sysfs_path; char sysfs_dev_path[SYSFS_PATH_MAX]; if (dbus_message_get_args (message, NULL, + DBUS_TYPE_BOOLEAN, &is_add, DBUS_TYPE_STRING, &filename, DBUS_TYPE_STRING, &sysfs_path, DBUS_TYPE_INVALID)) { strncpy (sysfs_dev_path, sysfs_mount_path, SYSFS_PATH_MAX); strncat (sysfs_dev_path, sysfs_path, SYSFS_PATH_MAX); - HAL_INFO (("udev NodeCreated: %s %s\n", filename, - sysfs_dev_path)); - - /* Find class device; this happens asynchronously as our it - * might be added later.. - */ -#if 0 - ds_device_async_find_by_key_value_string ( - ".udev.sysfs_path", sysfs_dev_path, FALSE, - /* note: it doesn't need to be in the GDL */ - handle_udev_node_created_found_device, - (void *) filename, NULL, - HAL_LINUX_HOTPLUG_TIMEOUT); -#elif 0 - handle_udev_node_created_found_device ( - hal_device_store_match_key_value_string ( - hald_get_gdl (), ".udev.sysfs_path", - sysfs_dev_path), - filename, NULL); -#else - hal_device_store_match_key_value_string_async ( - hald_get_tdl (), - ".udev.sysfs_path", - sysfs_dev_path, - udev_node_created_cb, filename, - HAL_LINUX_HOTPLUG_TIMEOUT); -#endif - /* NOTE NOTE NOTE: we will free filename in async - * result function - */ + if (is_add ) { + hal_device_store_match_key_value_string_async ( + hald_get_tdl (), + ".udev.sysfs_path", + sysfs_dev_path, + udev_node_created_cb, filename, + HAL_LINUX_HOTPLUG_TIMEOUT); + + /* NOTE NOTE NOTE: we will free filename in async + * result function + */ + } else { + dbus_free (filename); + } dbus_free (sysfs_path); } @@ -655,28 +643,19 @@ osspec_filter_function (DBusConnection * connection, DBusMessage * message, void *user_data) { -/* - HAL_INFO(("obj_path=%s interface=%s method=%s", - dbus_message_get_path(message), - dbus_message_get_interface(message), - dbus_message_get_member(message))); -*/ - if (dbus_message_is_method_call (message, "org.freedesktop.Hal.Linux.Hotplug", "HotplugEvent") && strcmp (dbus_message_get_path (message), "/org/freedesktop/Hal/Linux/Hotplug") == 0) { return handle_hotplug (connection, message); - } else if (dbus_message_is_signal (message, - "org.kernel.udev.NodeMonitor", - "NodeCreated")) { - return handle_udev_node_created (connection, message); - } else if (dbus_message_is_signal (message, - "org.kernel.udev.NodeMonitor", - "NodeDeleted")) { - /* This is left intentionally blank */ - } + } else if (dbus_message_is_method_call (message, + "org.freedesktop.Hal.Linux.Hotplug", + "DeviceEvent") && + strcmp (dbus_message_get_path (message), + "/org/freedesktop/Hal/Linux/Hotplug") == 0) { + return handle_device_event (connection, message); + } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } diff --git a/hald/linux/printer_class_device.c b/hald/linux/printer_class_device.c index e043f39c..fee79639 100644 --- a/hald/linux/printer_class_device.c +++ b/hald/linux/printer_class_device.c @@ -146,13 +146,14 @@ ClassDeviceHandler printer_class_handler = { class_device_detection_done, /**< detection is done */ class_device_shutdown, /**< shutdown function */ class_device_tick, /**< timer function */ + class_device_accept, /**< accept function */ class_device_visit, /**< visitor function */ class_device_removed, /**< class device is removed */ class_device_udev_event, /**< handle udev event */ class_device_get_device_file_target,/**< where to store devfile name */ printer_class_post_process, /**< add more properties */ NULL, /**< No UDI computation */ - "usb", /**< sysfs class name */ + "printer", /**< sysfs class name */ "printer", /**< hal class name */ TRUE, /**< require device file */ TRUE /**< merge onto sysdevice */ diff --git a/hald/linux/scsi_device_class_device.c b/hald/linux/scsi_device_class_device.c index a5c06a09..211654e4 100644 --- a/hald/linux/scsi_device_class_device.c +++ b/hald/linux/scsi_device_class_device.c @@ -106,6 +106,7 @@ ClassDeviceHandler scsi_device_class_handler = { class_device_detection_done, /**< detection is done */ class_device_shutdown, /**< shutdown function */ class_device_tick, /**< timer function */ + class_device_accept, /**< accept function */ class_device_visit, /**< visitor function */ class_device_removed, /**< class device is removed */ class_device_udev_event, /**< handle udev event */ diff --git a/hald/linux/scsi_host_class_device.c b/hald/linux/scsi_host_class_device.c index 248869fb..2d8ca871 100644 --- a/hald/linux/scsi_host_class_device.c +++ b/hald/linux/scsi_host_class_device.c @@ -95,6 +95,7 @@ ClassDeviceHandler scsi_host_class_handler = { class_device_detection_done, /**< detection is done */ class_device_shutdown, /**< shutdown function */ class_device_tick, /**< timer function */ + class_device_accept, /**< accept function */ class_device_visit, /**< visitor function */ class_device_removed, /**< class device is removed */ class_device_udev_event, /**< handle udev event */ diff --git a/tools/linux/Makefile.am b/tools/linux/Makefile.am index 084067a3..5088b082 100644 --- a/tools/linux/Makefile.am +++ b/tools/linux/Makefile.am @@ -6,13 +6,15 @@ INCLUDES = \ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ @DBUS_CFLAGS@ -libexec_PROGRAMS = hal.hotplug +libexec_PROGRAMS = hal.hotplug hal.dev hal_hotplug_SOURCES = hal_hotplug.c hal_hotplug_LDADD = @DBUS_LIBS@ -hal_hotplug_LDFLAGS = -all-static +hal_dev_SOURCES = hal_dev.c + +hal_dev_LDADD = @DBUS_LIBS@ clean-local : rm -f *~ @@ -20,6 +22,9 @@ clean-local : install-data-local : $(mkinstalldirs) $(DESTDIR)$(LINUX_HOTPLUG_DIR)/default - cd $(DESTDIR)$(LINUX_HOTPLUG_DIR)/default && $(LN_S) $(libexecdir)/hal.hotplug hal.hotplug + $(mkinstalldirs) $(DESTDIR)/etc/dev.d/default + - cd $(DESTDIR)/dev.d/default && $(LN_S) $(libexecdir)/hal.dev hal.dev uninstall-local : - rm -f $(DESTDIR)$(LINUX_HOTPLUG_DIR)/default/hal.hotplug + - rm -f $(DESTDIR)/etc/dev.d/default/hal.dev |