summaryrefslogtreecommitdiffstats
path: root/tdecore
diff options
context:
space:
mode:
Diffstat (limited to 'tdecore')
-rw-r--r--tdecore/tdehw/CMakeLists.txt6
-rw-r--r--tdecore/tdehw/tdecpudevice.cpp39
-rw-r--r--tdecore/tdehw/tderootsystemdevice.cpp142
3 files changed, 147 insertions, 40 deletions
diff --git a/tdecore/tdehw/CMakeLists.txt b/tdecore/tdehw/CMakeLists.txt
index 29c8b1ebe..a31d98146 100644
--- a/tdecore/tdehw/CMakeLists.txt
+++ b/tdecore/tdehw/CMakeLists.txt
@@ -17,7 +17,7 @@ if( NOT DBUS_SYSTEM_BUS )
set( DBUS_SYSTEM_BUS "unix:path=/var/run/dbus/system_bus_socket" CACHE INTERNAL "" FORCE )
endif()
-if( WITH_TDEHWLIB_DAEMONS OR WITH_UPOWER OR WITH_UDISKS OR WITH_UDISKS2 OR
+if( WITH_TDEHWLIB_DAEMONS OR WITH_HAL OR WITH_UPOWER OR WITH_UDISKS OR WITH_UDISKS2 OR
WITH_NETWORK_MANAGER_BACKEND OR WITH_CONSOLEKIT )
list( APPEND TDEHW_CUSTOM_INCLUDE_DIRS ${DBUS_TQT_INCLUDE_DIRS} )
list( APPEND TDEHW_CUSTOM_LIBRARY_DIRS ${DBUS_TQT_LIBRARY_DIRS} )
@@ -28,6 +28,10 @@ if( WITH_TDEHWLIB_DAEMONS )
add_definitions( -DWITH_TDEHWLIB_DAEMONS )
endif( )
+if( WITH_HAL )
+ add_definitions( -DWITH_HAL )
+endif( )
+
if( WITH_UPOWER )
add_definitions( -DWITH_UPOWER )
endif( )
diff --git a/tdecore/tdehw/tdecpudevice.cpp b/tdecore/tdehw/tdecpudevice.cpp
index e1b5cd4ce..d02cf77f1 100644
--- a/tdecore/tdehw/tdecpudevice.cpp
+++ b/tdecore/tdehw/tdecpudevice.cpp
@@ -30,13 +30,13 @@
#include "config.h"
// uPower
-#if defined(WITH_TDEHWLIB_DAEMONS)
+#if defined(WITH_TDEHWLIB_DAEMONS) || defined(WITH_HAL)
#include <tqdbusdata.h>
#include <tqdbusmessage.h>
#include <tqdbusproxy.h>
#include <tqdbusvariant.h>
#include <tqdbusconnection.h>
-#endif // defined(WITH_TDEHWLIB_DAEMONS)
+#endif // defined(WITH_TDEHWLIB_DAEMONS) || defined(WITH_HAL)
TDECPUDevice::TDECPUDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
@@ -151,6 +151,23 @@ bool TDECPUDevice::canSetGovernor() {
}
#endif // WITH_TDEHWLIB_DAEMONS
+#ifdef WITH_HAL
+ {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.Hal",
+ "/org/freedesktop/Hal/devices/computer",
+ "org.freedesktop.Hal.Device.CPUFreq",
+ "GetCPUFreqGovernor");
+ TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return true;
+ }
+ }
+ }
+#endif // WITH_HAL
+
return FALSE;
}
@@ -184,6 +201,24 @@ void TDECPUDevice::setGovernor(TQString gv) {
}
#endif // WITH_TDEHWLIB_DAEMONS
+#ifdef WITH_HAL
+ if ( !setGovernorDone ) {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy cpuFreqControl("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.CPUFreq", dbusConn);
+ if (cpuFreqControl.canSend()) {
+ // set CPU governor
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(gv.lower());
+ TQT_DBusMessage reply = cpuFreqControl.sendWithReply("SetCPUFreqGovernor", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ setGovernorDone = TRUE;
+ }
+ }
+ }
+ }
+#endif // WITH_HAL
+
// Force update of the device information object
if ( setGovernorDone ) {
TDEGlobal::hardwareDevices()->processModifiedCPUs();
diff --git a/tdecore/tdehw/tderootsystemdevice.cpp b/tdecore/tdehw/tderootsystemdevice.cpp
index 69f89df5f..56cfe9f8f 100644
--- a/tdecore/tdehw/tderootsystemdevice.cpp
+++ b/tdecore/tdehw/tderootsystemdevice.cpp
@@ -123,8 +123,9 @@ bool TDERootSystemDevice::canSuspend() {
return FALSE;
}
}
- else {
+
#ifdef WITH_UPOWER
+ {
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
if (dbusConn.isConnected()) {
TQT_DBusProxy upowerProperties("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", dbusConn);
@@ -136,21 +137,38 @@ bool TDERootSystemDevice::canSuspend() {
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
return reply[0].toVariant().value.toBool();
}
- else {
- return FALSE;
- }
}
- else {
- return FALSE;
- }
- }
- else {
- return FALSE;
}
-#else // WITH_UPOWER
- return FALSE;
+ }
#endif// WITH_UPOWER
+
+#ifdef WITH_HAL
+ {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy halProperties("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device", dbusConn);
+ if (halProperties.canSend()) {
+ // can suspend?
+ TQValueList<TQT_DBusData> params;
+ TQT_DBusMessage reply;
+ params.clear();
+ params << TQT_DBusData::fromString("power_management.can_suspend");
+ reply = halProperties.sendWithReply("GetPropertyBoolean", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toBool();
+ }
+ params.clear();
+ params << TQT_DBusData::fromString("power_management.can_suspend_to_ram");
+ reply = halProperties.sendWithReply("GetPropertyBoolean", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toBool();
+ }
+ }
+ }
}
+#endif // WITH_HAL
+
+ return FALSE;
}
bool TDERootSystemDevice::canHibernate() {
@@ -164,8 +182,9 @@ bool TDERootSystemDevice::canHibernate() {
return FALSE;
}
}
- else {
+
#ifdef WITH_UPOWER
+ {
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
if (dbusConn.isConnected()) {
TQT_DBusProxy upowerProperties("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", dbusConn);
@@ -177,21 +196,38 @@ bool TDERootSystemDevice::canHibernate() {
if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
return reply[0].toVariant().value.toBool();
}
- else {
- return FALSE;
- }
- }
- else {
- return FALSE;
}
}
- else {
- return FALSE;
- }
-#else // WITH_UPOWER
- return FALSE;
+ }
#endif// WITH_UPOWER
+
+#ifdef WITH_HAL
+ {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy halProperties("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device", dbusConn);
+ if (halProperties.canSend()) {
+ // can hibernate?
+ TQValueList<TQT_DBusData> params;
+ TQT_DBusMessage reply;
+ params.clear();
+ params << TQT_DBusData::fromString("power_management.can_hibernate");
+ reply = halProperties.sendWithReply("GetPropertyBoolean", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toBool();
+ }
+ params.clear();
+ params << TQT_DBusData::fromString("power_management.can_suspend_to_disk");
+ reply = halProperties.sendWithReply("GetPropertyBoolean", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toBool();
+ }
+ }
+ }
}
+#endif // WITH_HAL
+
+ return FALSE;
}
bool TDERootSystemDevice::canPowerOff() {
@@ -324,8 +360,9 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
file.close();
return true;
}
- else {
+
#ifdef WITH_UPOWER
+ {
TQT_DBusConnection dbusConn;
dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
if ( dbusConn.isConnected() ) {
@@ -335,8 +372,10 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
"/org/freedesktop/UPower",
"org.freedesktop.UPower",
"Suspend");
- dbusConn.sendWithReply(msg);
- return true;
+ TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage) {
+ return true;
+ }
}
else if (ps == TDESystemPowerState::Hibernate) {
TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
@@ -344,20 +383,49 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
"/org/freedesktop/UPower",
"org.freedesktop.UPower",
"Hibernate");
- dbusConn.sendWithReply(msg);
- return true;
- }
- else {
- return false;
+ TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage) {
+ return true;
+ }
}
}
- else {
- return false;
- }
-#else // WITH_UPOWER
- return false;
+ }
#endif // WITH_UPOWER
+
+#ifdef WITH_HAL
+ {
+ TQT_DBusConnection dbusConn;
+ dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if ( dbusConn.isConnected() ) {
+ if (ps == TDESystemPowerState::Suspend) {
+ TQT_DBusProxy halPowerManagement(
+ "org.freedesktop.Hal",
+ "/org/freedesktop/Hal/devices/computer",
+ "org.freedesktop.Hal.Device.SystemPowerManagement",
+ dbusConn);
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromInt32(0);
+ TQT_DBusMessage reply = halPowerManagement.sendWithReply("Suspend", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage) {
+ return true;
+ }
+ }
+ else if (ps == TDESystemPowerState::Hibernate) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.Hal",
+ "/org/freedesktop/Hal/devices/computer",
+ "org.freedesktop.Hal.Device.SystemPowerManagement",
+ "Hibernate");
+ TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage) {
+ return true;
+ }
+ }
+ }
}
+#endif // WITH_HAL
+
+ return false;
}
else if (ps == TDESystemPowerState::PowerOff) {
#ifdef WITH_CONSOLEKIT