hal: Branch 'master'

Richard Hughes hughsient at kemper.freedesktop.org
Thu Jul 5 07:50:47 PDT 2007


 hald/linux/device.c |   10 ++++++++++
 1 files changed, 10 insertions(+)

New commits:
diff-tree bed698872323c46fc6b44ffde10b1b2244b7e228 (from 075ca0f6df9893f972b045771ae703e95cf3f6de)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Jul 5 15:46:47 2007 +0100

    add ups and usb power supply types and set battery.type key
    
    Add UPS and USB power supply types as defined in the power supply class
    and also set battery.type key to the battery type value. This fixes g-p-m
    on machine using the power_supply class.

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 73d0072..a0a0b69 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -3167,6 +3167,7 @@ power_supply_add (const gchar *sysfs_pat
 	gboolean is_battery = FALSE;
 	gboolean is_ac_adapter = FALSE;
 	char *type = NULL;
+	const char *battery_type = NULL;
 
 	/* power_supply devices are very odd, they might be batteries or ac-adapters */
 	type = hal_util_get_string_from_file (sysfs_path, "type");
@@ -3176,6 +3177,13 @@ power_supply_add (const gchar *sysfs_pat
 	}
 	if (strcasecmp (type, "battery") == 0) {
 		is_battery = TRUE;
+		battery_type = "primary";
+	} else if (strcasecmp (type, "ups") == 0) {
+		is_battery = TRUE;
+		battery_type = "ups";
+	} else if (strcasecmp (type, "usb") == 0) {
+		is_battery = TRUE;
+		battery_type = "usb";
 	} else if (strcasecmp (type, "mains") == 0) {
 		is_ac_adapter = TRUE;
 	} else {
@@ -3189,6 +3197,8 @@ power_supply_add (const gchar *sysfs_pat
 
 	if (is_battery == TRUE) {
 		hal_device_property_set_string (d, "info.category", "battery");
+		if (battery_type != NULL)
+			hal_device_property_set_string (d, "battery.type", battery_type);
 		refresh_battery_slow (d);
 		hal_device_add_capability (d, "battery");
 	}


More information about the hal-commit mailing list