summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-08-15 13:40:42 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-08-15 13:40:42 -0500
commitc8471f78105ca17b7dd95f896d0b3d41328f9ae6 (patch)
tree09fb36bb69007e4d3aae4786b787b4cb5a2c590b /tdecore/tdehw
parentb181191ccca178c6d3c9d34da3e3096c888308a2 (diff)
parent18b25099865045a1e5bee99fa1629fee01c5f302 (diff)
downloadtdelibs-c8471f78105ca17b7dd95f896d0b3d41328f9ae6.tar.gz
tdelibs-c8471f78105ca17b7dd95f896d0b3d41328f9ae6.zip
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tdelibs
Diffstat (limited to 'tdecore/tdehw')
-rw-r--r--tdecore/tdehw/CMakeLists.txt6
-rw-r--r--tdecore/tdehw/tderootsystemdevice.cpp67
2 files changed, 72 insertions, 1 deletions
diff --git a/tdecore/tdehw/CMakeLists.txt b/tdecore/tdehw/CMakeLists.txt
index a31d98146..553cd7032 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_HAL OR WITH_UPOWER OR WITH_UDISKS OR WITH_UDISKS2 OR
+if( WITH_TDEHWLIB_DAEMONS OR WITH_HAL OR WITH_DEVKITPOWER 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} )
@@ -32,6 +32,10 @@ if( WITH_HAL )
add_definitions( -DWITH_HAL )
endif( )
+if( WITH_DEVKITPOWER )
+ add_definitions( -DWITH_DEVKITPOWER )
+endif( )
+
if( WITH_UPOWER )
add_definitions( -DWITH_UPOWER )
endif( )
diff --git a/tdecore/tdehw/tderootsystemdevice.cpp b/tdecore/tdehw/tderootsystemdevice.cpp
index 56cfe9f8f..422ff50de 100644
--- a/tdecore/tdehw/tderootsystemdevice.cpp
+++ b/tdecore/tdehw/tderootsystemdevice.cpp
@@ -142,6 +142,24 @@ bool TDERootSystemDevice::canSuspend() {
}
#endif// WITH_UPOWER
+#ifdef WITH_DEVKITPOWER
+ {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy devkitpowerProperties("org.freedesktop.DeviceKit.Power", "/org/freedesktop/DeviceKit/Power", "org.freedesktop.DBus.Properties", dbusConn);
+ if (devkitpowerProperties.canSend()) {
+ // can suspend?
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(devkitpowerProperties.interface()) << TQT_DBusData::fromString("CanSuspend");
+ TQT_DBusMessage reply = devkitpowerProperties.sendWithReply("Get", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toVariant().value.toBool();
+ }
+ }
+ }
+ }
+#endif// WITH_DEVKITPOWER
+
#ifdef WITH_HAL
{
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
@@ -201,6 +219,24 @@ bool TDERootSystemDevice::canHibernate() {
}
#endif// WITH_UPOWER
+#ifdef WITH_DEVKITPOWER
+ {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy devkitpowerProperties("org.freedesktop.DeviceKit.Power", "/org/freedesktop/DeviceKit/Power", "org.freedesktop.DBus.Properties", dbusConn);
+ if (devkitpowerProperties.canSend()) {
+ // can hibernate?
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(devkitpowerProperties.interface()) << TQT_DBusData::fromString("CanHibernate");
+ TQT_DBusMessage reply = devkitpowerProperties.sendWithReply("Get", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return reply[0].toVariant().value.toBool();
+ }
+ }
+ }
+ }
+#endif// WITH_DEVKITPOWER
+
#ifdef WITH_HAL
{
TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
@@ -392,6 +428,37 @@ bool TDERootSystemDevice::setPowerState(TDESystemPowerState::TDESystemPowerState
}
#endif // WITH_UPOWER
+#ifdef WITH_DEVKITPOWER
+ {
+ TQT_DBusConnection dbusConn;
+ dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if ( dbusConn.isConnected() ) {
+ if (ps == TDESystemPowerState::Suspend) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.DeviceKit.Power",
+ "/org/freedesktop/DeviceKit/Power",
+ "org.freedesktop.DeviceKit.Power",
+ "Suspend");
+ 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(
+ "org.freedesktop.DeviceKit.Power",
+ "/org/freedesktop/DeviceKit/Power",
+ "org.freedesktop.DeviceKit.Power",
+ "Hibernate");
+ TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage) {
+ return true;
+ }
+ }
+ }
+ }
+#endif // WITH_DEVKITPOWER
+
#ifdef WITH_HAL
{
TQT_DBusConnection dbusConn;