Danny Kukawka wrote:
On Donnerstag, 24. Januar 2008, Holger Macht wrote:
On Thu 24. Jan - 02:33:43, Michael Biebl wrote:
[...]
Has this been removed lately from HAL? I'm currently using a git snapshot
from 2007-12-12 and

dbus-send --system --print-reply --dest=org.freedesktop.Hal
/org/freedesktop/Hal/devices/computer
org.freedesktop.Hal.Device.IsCallerPrivileged string:hal-power-suspend
string:":1.9044"

It's now org.freedesktop.hal.power-management.hibernate instead of hal-power-suspend. Our hal on 10.3 was ported to use the old names since the change was to late for 10.3.


Could this be changed in trunk then to match the upstream hal names?

While looking at the code, I noticed some oddities, too:
user_binary/powersave.cpp:633ff

if (liblazy_hal_get_property_bool(HAL_UDI_COMPUTER,
"power_management.can_suspend", &supported) && !supported) {
...
if (!liblazy_hal_get_property_bool(HAL_UDI_COMPUTER,
"power_management.can_standby", &supported) && !supported) {
...
if (!liblazy_hal_get_property_bool(HAL_UDI_COMPUTER,
"power_management.can_hibernate", &supported) && !supported) {

1.) It's liblazy..() for suspend and !liblazy..() for standby and hibernate
2.) The can_standby property is a SUSE specific patch.
If I run powersave -m on Debian, the

if (!liblazy_hal_get_property_bool(HAL_UDI_COMPUTER,
"power_management.can_standby", &supported) && !supported)

check succeeds.
LIBLAZY_ERROR_HAL_NO_SUCH_PROPERTY (-11) is returned for liblazy..() and supported is -1. Both negated is != 0. The return values of liblazy_hal_get_property_bool can be -11, 0 (success) and 1.
The values of supported can be -1, 0 and 1 (success).
So I'd suggest to use
if(liblazy_hal_is_caller_privileged() || supported != 1) {

A patch which fixes that and uses the new hal policy names, is attached.


Cheers,
Michael
--
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?

diff --git a/daemon/pm_interface.cpp b/daemon/pm_interface.cpp
index 5622290..4662827 100644
--- a/daemon/pm_interface.cpp
+++ b/daemon/pm_interface.cpp
@@ -476,7 +476,7 @@ bool PM_Interface::suspendToDisk()
 		return false;
 	}
 
-	if (liblazy_hal_is_caller_privileged("hal-power-hibernate") != 1)
+	if (liblazy_hal_is_caller_privileged("org.freedesktop.hal.power-management.hibernate") != 1)
 		return false;
 	else if (sendSleepRequest("Hibernate", DBUS_TYPE_INVALID)) {
 				 pDebug(DBG_ERR, "Could not send suspend to disk request to HAL\n");
@@ -498,7 +498,7 @@ bool PM_Interface::suspendToRam()
 
 	int wake_up = 0;
 
-	if (liblazy_hal_is_caller_privileged("hal-power-suspend") != 1)
+	if (liblazy_hal_is_caller_privileged("org.freedesktop.hal.power-management.suspend") != 1)
 		return false;
 	else if (sendSleepRequest("Suspend",
 				    DBUS_TYPE_INT32,
diff --git a/user_binary/powersave.cpp b/user_binary/powersave.cpp
index 2ce11ae..e1367ff 100644
--- a/user_binary/powersave.cpp
+++ b/user_binary/powersave.cpp
@@ -634,13 +634,13 @@ bool set_brightness(int level)
 		 int supported;
 		 if (liblazy_hal_get_property_bool(HAL_UDI_COMPUTER,
 						   "power_management.can_suspend", &supported)
-			 && !supported) {
+			 || supported != 1) {
 			 printf("Suspend to ram is not supported.\n");
 			 ret = -1;
 		 } else {
 			 int wake_up = 0;
-			 if (liblazy_hal_is_caller_privileged("hal-power-suspend") != 1)
-				 privilege_error("hal-power-suspend");
+			 if (liblazy_hal_is_caller_privileged("org.freedesktop.hal.power-management.suspend") != 1)
+				 privilege_error("org.freedesktop.hal.power-management.suspend");
 			 else if (send_sleep_request("Suspend",
 						     DBUS_TYPE_INT32,
 						     &wake_up,
@@ -653,14 +653,14 @@ bool set_brightness(int level)
 	 }
 	 if (STANDBY) {
 		 int supported;
-		 if (!liblazy_hal_get_property_bool(HAL_UDI_COMPUTER,
+		 if (liblazy_hal_get_property_bool(HAL_UDI_COMPUTER,
 						    "power_management.can_standby", &supported)
-			 && !supported) {
+			 || supported != 1) {
 			 printf("Standby is not supported.\n");
 			 ret = -1;
 		 } else {
-			 if (liblazy_hal_is_caller_privileged("hal-power-standby") != 1)
-				 privilege_error("hal-power-standby");
+			 if (liblazy_hal_is_caller_privileged("org.freedesktop.hal.power-management.standby") != 1)
+				 privilege_error("org.freedesktop.hal.power-management.standby");
 			 else if (send_sleep_request("Standby", DBUS_TYPE_INVALID)) {
 				 fprintf(stderr, "Could not send standby request to HAL\n");
 				 ret = -1;
@@ -670,14 +670,14 @@ bool set_brightness(int level)
 		 }
 	 } else if (SUSPEND_TO_DISK) {
 		 int supported;
-		 if (!liblazy_hal_get_property_bool(HAL_UDI_COMPUTER,
+		 if (liblazy_hal_get_property_bool(HAL_UDI_COMPUTER,
 					       "power_management.can_hibernate", &supported)
-			 && !supported) {
+			 || supported != 1) {
 			 printf("Suspend to disk is not supported.\n");
 			 ret = -1;
 		 } else {
-			 if (liblazy_hal_is_caller_privileged("hal-power-hibernate") != 1)
-				 privilege_error("hal-power-hibernate");
+			 if (liblazy_hal_is_caller_privileged("org.freedesktop.hal.power-management.hibernate") != 1)
+				 privilege_error("org.freedesktop.hal.power-management.hibernate");
 
 			 else if (send_sleep_request("Hibernate", DBUS_TYPE_INVALID)) {
 				 fprintf(stderr, "Could not send suspend to disk request to HAL\n");

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
powersave-devel mailing list
powersave-devel@forge.novell.com
http://forge.novell.com/mailman/listinfo/powersave-devel

Reply via email to