diff options
author | jmcneill <jmcneill@pkgsrc.org> | 2008-11-27 12:24:02 +0000 |
---|---|---|
committer | jmcneill <jmcneill@pkgsrc.org> | 2008-11-27 12:24:02 +0000 |
commit | 696310ab4a5bb3cd17f53f17a889f9d114227a44 (patch) | |
tree | 2065593f637a46ee112ef47ffac161ccebe62c71 | |
parent | 62dad85b36dfe16e20a4a6c7a3a65235b4c0676a (diff) | |
download | pkgsrc-696310ab4a5bb3cd17f53f17a889f9d114227a44.tar.gz |
hald-netbsd: clear is_charging/is_discharging before walking through the
sensor properties, and make sure we don't read an invalid sensor in
the process. Bump PKGREVISION.
-rw-r--r-- | sysutils/hal/Makefile | 4 | ||||
-rw-r--r-- | sysutils/hal/files/hald-netbsd/envsys.c | 32 |
2 files changed, 15 insertions, 21 deletions
diff --git a/sysutils/hal/Makefile b/sysutils/hal/Makefile index 028b5a18586..efe7a49cddc 100644 --- a/sysutils/hal/Makefile +++ b/sysutils/hal/Makefile @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.10 2008/11/27 03:32:19 jmcneill Exp $ +# $NetBSD: Makefile,v 1.11 2008/11/27 12:24:02 jmcneill Exp $ # DISTNAME= hal-0.5.11 -PKGREVISION= 6 +PKGREVISION= 7 CATEGORIES= sysutils MASTER_SITES= http://hal.freedesktop.org/releases/ EXTRACT_SUFX= .tar.bz2 diff --git a/sysutils/hal/files/hald-netbsd/envsys.c b/sysutils/hal/files/hald-netbsd/envsys.c index 98d4b848aec..d5491224060 100644 --- a/sysutils/hal/files/hald-netbsd/envsys.c +++ b/sysutils/hal/files/hald-netbsd/envsys.c @@ -1,4 +1,4 @@ -/* $NetBSD: envsys.c,v 1.1 2008/11/27 01:45:00 jmcneill Exp $ */ +/* $NetBSD: envsys.c,v 1.2 2008/11/27 12:24:02 jmcneill Exp $ */ /*- * Copyright (c) 2008 Jared D. McNeill <jmcneill@invisible.ca> @@ -174,6 +174,8 @@ envsys_battery_handler(HalDevice *d, prop_array_t properties) device_property_atomic_update_begin (); hal_device_property_set_bool (d, "battery.is_rechargeable", TRUE); + hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE); + hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE); iter = prop_array_iterator (properties); while ((prop = (prop_dictionary_t)prop_object_iterator_next (iter)) != NULL) { @@ -181,10 +183,10 @@ envsys_battery_handler(HalDevice *d, prop_array_t properties) const char *valid; int64_t intval; - if (prop_dictionary_get_cstring_nocopy (prop, "description", &descr) == false) - continue; - - if (prop_dictionary_get_int64 (prop, "cur-value", &intval) == false) + if (prop_dictionary_get_cstring_nocopy (prop, "description", &descr) == false || + prop_dictionary_get_int64 (prop, "cur-value", &intval) == false || + prop_dictionary_get_cstring_nocopy (prop, "state", &valid) == false || + strcmp (valid, "valid") != 0) continue; if (strcmp (descr, "present") == 0) @@ -204,21 +206,13 @@ envsys_battery_handler(HalDevice *d, prop_array_t properties) hal_device_property_set_int (d, "battery.charge_level.percentage", 0); } else if (strcmp (descr, "charge rate") == 0) { - if (prop_dictionary_get_cstring_nocopy (prop, "state", &valid) == false) - continue; - if (strcmp (valid, "valid") == 0) { - hal_device_property_set_bool (d, "battery.rechargeable.is_charging", TRUE); - hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE); - hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600); - } + hal_device_property_set_bool (d, "battery.rechargeable.is_charging", TRUE); + hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE); + hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600); } else if (strcmp (descr, "discharge rate") == 0) { - if (prop_dictionary_get_cstring_nocopy (prop, "state", &valid) == false) - continue; - if (strcmp (valid, "valid") == 0) { - hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE); - hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", TRUE); - hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600); - } + hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE); + hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", TRUE); + hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600); } } |