hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Tue Mar 4 05:40:47 PST 2008


 hald/linux/addons/addon-dell-backlight.cpp |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

New commits:
commit 6e268f98bba411861963a8ef495b2f05443118c8
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Mar 4 14:38:46 2008 +0100

    fix hald-addon-dell-backlight AC detection
    
    Thiss fixes fd.o bug #13669 and hald-addon-dell-backlight which uses a
    hardcoded udi to get AC adapter information. With the switch to sysfs
    power_supply devices for AC adapter the path is no longer valid.
    
    Changed the code to check all devices with ac_adapter capability and
    check then all AC adapter until a device has ac_adapter.present and
    then get the info about the adapter state from there. If there is no
    such info assume we are on AC.

diff --git a/hald/linux/addons/addon-dell-backlight.cpp b/hald/linux/addons/addon-dell-backlight.cpp
index 42c9836..b5aac6a 100644
--- a/hald/linux/addons/addon-dell-backlight.cpp
+++ b/hald/linux/addons/addon-dell-backlight.cpp
@@ -178,17 +178,30 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 	DBusError err;
 	DBusMessage *reply = NULL;
 	dbus_bool_t AC;
+	char **udis;
+	int i, num_devices;
+
 	dbus_error_init (&err);
 
         if (!check_priv (connection, message, dbus_message_get_path (message), "org.freedesktop.hal.power-management.lcd-panel")) {
                 return DBUS_HANDLER_RESULT_HANDLED;
         }
-
+	
+	/* set a default */
+	AC = TRUE; 
 	/* Mechanism to ensure that we always set the AC brightness when we are on AC-power etc. */
-	AC = libhal_device_get_property_bool (halctx, 
-					     "/org/freedesktop/Hal/devices/acpi_AC",
-					     "ac_adapter.present",
-					     &err);
+	if ((udis = libhal_find_device_by_capability(halctx, "ac_adapter", &num_devices, &err)) != NULL) {
+		for (i = 0; udis[i] != NULL; i++) {
+			if (dbus_error_is_set(&err)) 
+				dbus_error_free (&err);
+
+			if (libhal_device_property_exists (halctx, udis[i], "ac_adapter.present", &err)) {
+				AC = libhal_device_get_property_bool (halctx, udis[i], "ac_adapter.present", &err);
+				break; /* we found one AC device, leave the for-loop */
+			}
+		}
+		libhal_free_string_array(udis);
+	}
 
 	if (dbus_message_is_method_call (message, 
 					 "org.freedesktop.Hal.Device.LaptopPanel", 
@@ -197,6 +210,9 @@ filter_function (DBusConnection *connection, DBusMessage *message, void *userdat
 		
 		HAL_DEBUG (("Received SetBrightness DBus call"));
 
+		if (dbus_error_is_set(&err)) 
+			dbus_error_free (&err);
+
 		if (dbus_message_get_args (message, 
 					   &err,
 					   DBUS_TYPE_INT32, &brightness,


More information about the hal-commit mailing list