diff options
author | David Zeuthen <david@fubar.dk> | 2004-01-13 02:01:04 +0000 |
---|---|---|
committer | David Zeuthen <david@fubar.dk> | 2004-01-13 02:01:04 +0000 |
commit | b99d81a069fd2ba3b512912d9700fde35a20983b (patch) | |
tree | 2a68242d1bddee3dbef6fa9fb08786cac68e3cba | |
parent | 744cd4c190f6fcb751a760ee4ae6278872f73d9d (diff) |
Bump version number to 0.2.3HAL_0_2_3
Add support for Condition signal
new function (main): add device_condition to LibHalFunctions variable
Process DeviceCondition
Add device_condition and type LibHalDeviceCondition
Emit NetLinkEvent(bool got_link) condition
emit BlockMount(string device, string mount_point, string fstype) and
BlockUnmount(string device) events
added emit_condition()
new function
-rw-r--r-- | ChangeLog | 27 | ||||
-rw-r--r-- | Doxyfile | 2 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | hald/hald.h | 4 | ||||
-rw-r--r-- | hald/linux/linux_class_block.c | 26 | ||||
-rw-r--r-- | hald/linux/linux_class_net.c | 6 | ||||
-rw-r--r-- | hald/main.c | 44 | ||||
-rw-r--r-- | libhal/libhal.c | 17 | ||||
-rw-r--r-- | libhal/libhal.h | 16 | ||||
-rw-r--r-- | packaging/fedora/hal.spec | 2 | ||||
-rw-r--r-- | tools/device-manager/DeviceManager.py | 72 | ||||
-rw-r--r-- | tools/lshal.c | 21 |
12 files changed, 203 insertions, 38 deletions
@@ -1,3 +1,30 @@ +2004-01-13 David Zeuthen <david@fubar.dk> + + * configure.in: Bump version number to 0.2.3 + + * tools/device-manager/DeviceManager.py + (DeviceManager.device_changed): Add support for Condition signal + + * tools/lshal.c (device_condition): new function + (main): add device_condition to LibHalFunctions variable + + * libhal/libhal.c (filter_func): Process DeviceCondition + + * libhal/libhal.h (LibHalFunctions_s): Add device_condition + and type LibHalDeviceCondition + + * hald/linux/linux_class_net.c (link_detection_process): Emit + NetLinkEvent(bool got_link) condition + + * hald/linux/linux_class_block.c + (etc_mtab_process_all_block_devices): emit BlockMount(string device, + string mount_point, string fstype) and BlockUnmount(string device) + events + + * hald/hald.h: added emit_condition() + + * hald/main.c (emit_condition): new function + 2004-01-13 Matthew Mastracci <matt@aclaro.com> * tools/device-manager/Const.py.in (BUS_NAMES): add i2c_adapter @@ -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.2 +PROJECT_NUMBER = 0.2.3 # 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 cca730c4..3bb22d4c 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.2, david@fubar.dk) -AM_INIT_AUTOMAKE(hal, 0.2.2) +AC_INIT(hal, 0.2.3, david@fubar.dk) +AM_INIT_AUTOMAKE(hal, 0.2.3) AM_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE diff --git a/hald/hald.h b/hald/hald.h index 8cfbede6..58cdecbe 100644 --- a/hald/hald.h +++ b/hald/hald.h @@ -30,6 +30,7 @@ #include <stdint.h> #include <dbus/dbus.h> +#include "device_store.h" /** * @addtogroup HalDaemon @@ -43,6 +44,9 @@ void* xmalloc(unsigned int how_much); void property_atomic_update_begin(); void property_atomic_update_end(); +void emit_condition(HalDevice* device, const char* condition_name, + int first_arg_type, ... ); + /** * @} */ diff --git a/hald/linux/linux_class_block.c b/hald/linux/linux_class_block.c index ea847668..29b5fd50 100644 --- a/hald/linux/linux_class_block.c +++ b/hald/linux/linux_class_block.c @@ -797,6 +797,7 @@ static void etc_mtab_process_all_block_devices(dbus_bool_t force) if( mp->major==major && mp->minor==minor ) { const char* existing_block_device; + dbus_bool_t was_mounted; HAL_INFO(( "%s mounted at %s, major:minor=%d:%d, fstype=%s, udi=%s", @@ -808,6 +809,8 @@ static void etc_mtab_process_all_block_devices(dbus_bool_t force) existing_block_device = ds_property_get_string(d, "block.device"); + was_mounted = ds_property_get_bool(d, "block.is_mounted"); + /* Yay! Found a mount point; set properties accordingly */ ds_property_set_string(d, "block.mount_point",mp->mount_point); ds_property_set_string(d, "block.fstype", mp->fs_type); @@ -823,6 +826,16 @@ static void etc_mtab_process_all_block_devices(dbus_bool_t force) property_atomic_update_end(); + if( !was_mounted ) + { + emit_condition(d, "BlockMountEvent", + DBUS_TYPE_STRING, + ds_property_get_string(d, "block.device"), + DBUS_TYPE_STRING, mp->mount_point, + DBUS_TYPE_STRING, mp->fs_type, + DBUS_TYPE_INVALID); + } + found_mount_point = TRUE; break; } @@ -831,13 +844,26 @@ static void etc_mtab_process_all_block_devices(dbus_bool_t force) /* No mount point found; (possibly) remove all information */ if( !found_mount_point ) { + dbus_bool_t was_mounted; + property_atomic_update_begin(); + was_mounted = ds_property_get_bool(d, "block.is_mounted"); + ds_property_set_bool(d, "block.is_mounted", FALSE); ds_property_set_string(d, "block.mount_point", ""); ds_property_set_string(d, "block.fstype", ""); property_atomic_update_end(); + + if( was_mounted ) + { + emit_condition(d, "BlockUnmountEvent", + DBUS_TYPE_STRING, + ds_property_get_string(d, "block.device"), + DBUS_TYPE_INVALID); + } + } } } diff --git a/hald/linux/linux_class_net.c b/hald/linux/linux_class_net.c index e2e7aca0..ec8209e2 100644 --- a/hald/linux/linux_class_net.c +++ b/hald/linux/linux_class_net.c @@ -300,6 +300,7 @@ static dbus_uint16_t mdio_read(link_detection_if* iface, int location) */ static void link_detection_process(link_detection_if* iface) { + dbus_bool_t got_link = FALSE; dbus_uint16_t status_word; dbus_uint16_t link_word; dbus_uint16_t status_word_new; @@ -338,6 +339,7 @@ static void link_detection_process(link_detection_if* iface) { ds_property_set_bool(iface->device, "net.ethernet.link", TRUE); + got_link = TRUE; } else { @@ -373,6 +375,10 @@ static void link_detection_process(link_detection_if* iface) } property_atomic_update_end(); + + emit_condition(iface->device, "NetLinkEvent", + DBUS_TYPE_BOOLEAN, got_link, + DBUS_TYPE_INVALID); } } diff --git a/hald/main.c b/hald/main.c index a0796a29..6b5179da 100644 --- a/hald/main.c +++ b/hald/main.c @@ -1815,6 +1815,50 @@ void property_atomic_update_end() } } +/** Emits a condition on a device; the device has to be in the GDL for + * this function to have effect. + * + * Is intended for non-continuous events on the device like + * ProcesserOverheating, BlockDeviceGotDevice, e.g. conditions that + * are exceptional and may not be inferred by looking at properties + * (though some may). + * + * This function accepts a number of parameters that are passed along + * in the D-BUS message. The recipient is supposed to extract the parameters + * himself, by looking at the HAL specification. + * + * @param device The device + * @param condition_name Name of condition + * @param first_arg_type Type of the first argument + * @param ... value of first argument, list of additional + * type-value pairs. Must be terminated with + * DBUS_TYPE_INVALID + */ +void emit_condition(HalDevice* device, const char* condition_name, + int first_arg_type, ... ) +{ + DBusMessage* message; + DBusMessageIter iter; + va_list var_args; + + if( !device->in_gdl ) + return; + + message = dbus_message_new_signal(device->udi, + "org.freedesktop.Hal.Device", + "Condition"); + dbus_message_iter_init(message, &iter); + dbus_message_iter_append_string(&iter, condition_name); + + va_start(var_args, first_arg_type); + dbus_message_append_args_valist(message, first_arg_type, var_args); + va_end(var_args); + + if( !dbus_connection_send(dbus_connection,message, NULL) ) + DIE(("error broadcasting message")); + + dbus_message_unref(message); +} /** Function in the HAL daemon that is called whenever a property on a device * is changed. Will broadcast the changes using D-BUS signals. diff --git a/libhal/libhal.c b/libhal/libhal.c index 2c1aab10..ad718f2c 100644 --- a/libhal/libhal.c +++ b/libhal/libhal.c @@ -426,6 +426,22 @@ static DBusHandlerResult filter_func(DBusConnection* connection, } } else if( dbus_message_is_signal(message, "org.freedesktop.Hal.Device", + "Condition") ) + { + if( functions->device_condition!=NULL ) + { + DBusMessageIter iter; + char* condition_name; + + dbus_message_iter_init(message, &iter); + condition_name = dbus_message_iter_get_string(&iter); + + functions->device_condition(object_path, condition_name, message); + + dbus_free(condition_name); + } + } + else if( dbus_message_is_signal(message, "org.freedesktop.Hal.Device", "PropertyModified") ) { if( functions->device_property_modified!=NULL ) @@ -469,6 +485,7 @@ static LibHalFunctions hal_null_functions = { NULL /*device_removed*/, NULL /*device_new_capability*/, NULL /*property_modified*/, + NULL /*device_condition*/ }; /** Initialize the HAL library. diff --git a/libhal/libhal.h b/libhal/libhal.h index 2f0b6d9e..98013920 100644 --- a/libhal/libhal.h +++ b/libhal/libhal.h @@ -76,6 +76,19 @@ typedef void (*LibHalDevicePropertyModified)(const char* udi, dbus_bool_t is_removed, dbus_bool_t is_added); +/** Type for callback when a non-continuos condition occurs on a device + * + * @param udi Unique Device Id + * @param condition_name Name of the condition, e.g. + * ProcessorOverheating. Consult the HAL spec + * for possible conditions + * @param message D-BUS message with variable parameters + * depending on condition + */ +typedef void (*LibHalDeviceCondition)(const char* udi, + const char* condition_name, + DBusMessage* message); + /** Big convenience chunk for all callback function pointers. * @@ -101,6 +114,9 @@ typedef struct LibHalFunctions_s /** A property of a device changed */ LibHalDevicePropertyModified device_property_modified; + /** A non-continous event on the device occured */ + LibHalDeviceCondition device_condition; + } LibHalFunctions; int hal_initialize(const LibHalFunctions* functions, dbus_bool_t use_cache); diff --git a/packaging/fedora/hal.spec b/packaging/fedora/hal.spec index 7120c4be..ec1020ca 100644 --- a/packaging/fedora/hal.spec +++ b/packaging/fedora/hal.spec @@ -4,7 +4,7 @@ Summary: Hardware Abstraction Layer Name: hal -Version: 0.2.2 +Version: 0.2.3 Release: 1 URL: http://www.freedesktop.org/software/hal/ Source0: %{name}-%{version}.tar.gz diff --git a/tools/device-manager/DeviceManager.py b/tools/device-manager/DeviceManager.py index b3ac4c8f..8f8d76db 100644 --- a/tools/device-manager/DeviceManager.py +++ b/tools/device-manager/DeviceManager.py @@ -74,40 +74,46 @@ class DeviceManager(LibGladeApplication): def device_changed(self, dbus_if, dbus_member, dbus_svc, dbus_obj_path, dbus_message): - """This method is called when properties for a HAL device changes""" - args = dbus_message.get_args_list() - num_modifications = args[0] - print "\nPropertyModified, device=%s"%dbus_obj_path - #print "dbus_obj_path", dbus_obj_path - for i in range(0, num_modifications): - property_name = args[1+3*i] - removed = args[2+3*i] - added = args[3+3*i] - - print " key=%s, rem=%d, add=%d"%(property_name, removed, added) - if property_name=="info.parent": - self.update_device_list() - else: - device_udi = dbus_obj_path - device_udi_obj = self.hal_service.get_object(device_udi, - "org.freedesktop.Hal.Device") - device_obj = self.udi_to_device(device_udi) - - if device_udi_obj.PropertyExists(property_name): - device_obj.properties[property_name] = device_udi_obj.GetProperty(property_name) - print " value=%s"%(device_obj.properties[property_name]) + """This method is called when signals on the Device interface is + received""" + if dbus_member=="Condition": + args = dbus_message.get_args_list() + print "\nCondition %s, device=%s"%(args[0], dbus_obj_path) + print " message = ", args + elif dbus_member=="PropertyModified": + args = dbus_message.get_args_list() + num_modifications = args[0] + print "\nPropertyModified, device=%s"%dbus_obj_path + #print "dbus_obj_path", dbus_obj_path + for i in range(0, num_modifications): + property_name = args[1+3*i] + removed = args[2+3*i] + added = args[3+3*i] + + print " key=%s, rem=%d, add=%d"%(property_name, removed, added) + if property_name=="info.parent": + self.update_device_list() else: - if device_obj != None: - try: - del device_obj.properties[property_name] - except: - pass - - device_focus_udi = self.get_current_focus_udi() - if device_focus_udi != None: - device = self.udi_to_device(device_udi) - if device_focus_udi==device_udi: - self.update_device_notebook(device) + device_udi = dbus_obj_path + device_udi_obj = self.hal_service.get_object(device_udi, + "org.freedesktop.Hal.Device") + device_obj = self.udi_to_device(device_udi) + + if device_udi_obj.PropertyExists(property_name): + device_obj.properties[property_name] = device_udi_obj.GetProperty(property_name) + print " value=%s"%(device_obj.properties[property_name]) + else: + if device_obj != None: + try: + del device_obj.properties[property_name] + except: + pass + + device_focus_udi = self.get_current_focus_udi() + if device_focus_udi != None: + device = self.udi_to_device(device_udi) + if device_focus_udi==device_udi: + self.update_device_notebook(device) def gdl_changed(self, dbus_if, dbus_member, dbus_svc, dbus_obj_path, dbus_message): diff --git a/tools/lshal.c b/tools/lshal.c index 1d305298..def66885 100644 --- a/tools/lshal.c +++ b/tools/lshal.c @@ -226,6 +226,24 @@ static void property_modified(const char* udi, const char* key, } +/** Invoked when a property of a device in the Global Device List is + * changed, and we have we have subscribed to changes for that device. + * + * @param udi Univerisal Device Id + * @param condition_name Name of condition + * @param message D-BUS message with parameters + */ +static void device_condition(const char* udi, const char* condition_name, + DBusMessage* message) +{ + fprintf(stderr, "*** lshal: device_condition, udi=%s\n", udi); + fprintf(stderr, " condition_name=%s\n", condition_name); + /** @todo FIXME print out message */ + fprintf(stderr, "\n"); + /*dump_devices();*/ +} + + /** Invoked by libhal for integration with our mainloop. We take the * easy route and use link with glib for painless integrate. * @@ -271,7 +289,8 @@ int main(int argc, char* argv[]) device_added, device_removed, device_new_capability, - property_modified }; + property_modified, + device_condition }; fprintf(stderr, "lshal version " PACKAGE_VERSION "\n"); |