diff options
author | Darrell Anderson <[email protected]> | 2013-01-14 14:52:37 -0600 |
---|---|---|
committer | Darrell Anderson <[email protected]> | 2013-01-14 14:52:37 -0600 |
commit | b979556fbb9e880ed619abcb791e169b9a227486 (patch) | |
tree | 9c13e2cd8b5ea542aac48d9890ea090fe7c1e971 | |
parent | 2c10a4aac71b1e66d4e3fc0c9401e8b283e73be3 (diff) | |
parent | 4443b6dd886ce7d6fc6f99c594023fdd71d010b3 (diff) | |
download | tdelibs-b979556fbb9e880ed619abcb791e169b9a227486.tar.gz tdelibs-b979556fbb9e880ed619abcb791e169b9a227486.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tdelibs
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | tdecore/CMakeLists.txt | 7 | ||||
-rw-r--r-- | tdecore/tdehardwaredevices.cpp | 81 | ||||
-rw-r--r-- | tdeui/knuminput.cpp | 2 |
4 files changed, 88 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 74f783b02..37a05bf5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,7 @@ OPTION( WITH_PCRE "Enable pcre regex support for kjs" ON ) OPTION( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} ) OPTION( WITH_INOTIFY "Enable inotify support for kio" ON ) OPTION( WITH_GAMIN "Enable FAM/GAMIN support" ${WITH_ALL_OPTIONS} ) +option( WITH_UPOWER "Enable UPOWER support" ${WITH_ALL_OPTIONS} ) OPTION( WITH_NETWORK_MANAGER_BACKEND "Enable network-manager support" OFF ) OPTION( WITH_SUDO_TDESU_BACKEND "Use sudo as backend for tdesu (default is su)" OFF ) diff --git a/tdecore/CMakeLists.txt b/tdecore/CMakeLists.txt index 2e00d6afa..f0ea3b5b4 100644 --- a/tdecore/CMakeLists.txt +++ b/tdecore/CMakeLists.txt @@ -14,6 +14,13 @@ add_subdirectory( network ) add_subdirectory( kconfig_compiler ) add_subdirectory( hwlibdata ) +if( NOT DBUS_SYSTEM_BUS ) + set( DBUS_SYSTEM_BUS "unix:path=/var/run/dbus/system_bus_socket" CACHE INTERNAL "" FORCE ) +endif() + +if( WITH_UPOWER ) + add_definitions( -DWITH_UPOWER ) +endif( ) if( WITH_LIBART ) add_subdirectory( svgicons ) diff --git a/tdecore/tdehardwaredevices.cpp b/tdecore/tdehardwaredevices.cpp index c0c97679a..b69c40d45 100644 --- a/tdecore/tdehardwaredevices.cpp +++ b/tdecore/tdehardwaredevices.cpp @@ -63,7 +63,16 @@ #include "config.h" #ifdef WITH_NETWORK_MANAGER_BACKEND -#include "networkbackends/network-manager/network-manager.h" + #include "networkbackends/network-manager/network-manager.h" +#endif // WITH_NETWORK_MANAGER_BACKEND + +// uPower integration +#ifdef WITH_UPOWER + #include <tqdbusdata.h> + #include <tqdbusmessage.h> + #include <tqdbusproxy.h> + #include <tqdbusvariant.h> + #include <tqdbusconnection.h> #endif // WITH_NETWORK_MANAGER_BACKEND // BEGIN BLOCK @@ -1113,7 +1122,25 @@ bool TDERootSystemDevice::canSuspend() { } } 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); + + // can suspend? + TQValueList<TQT_DBusData> params; + params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanSuspend"); + TQT_DBusMessage reply = upowerProperties.sendWithReply("Get", params); + if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { + return reply[0].toVariant().value.toBool(); + } + } + else { + return FALSE; + } +#else // WITH_UPOWER return FALSE; +#endif// WITH_UPOWER } } @@ -1129,7 +1156,25 @@ bool TDERootSystemDevice::canHibernate() { } } 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); + + // can hibernate? + TQValueList<TQT_DBusData> params; + params << TQT_DBusData::fromString(upowerProperties.interface()) << TQT_DBusData::fromString("CanHibernate"); + TQT_DBusMessage reply = upowerProperties.sendWithReply("Get", params); + if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) { + return reply[0].toVariant().value.toBool(); + } + } + else { + return FALSE; + } +#else // WITH_UPOWER return FALSE; +#endif// WITH_UPOWER } } @@ -1196,6 +1241,40 @@ 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() ) { + if (ps == TDESystemPowerState::Suspend) { + TQT_DBusMessage msg = TQT_DBusMessage::methodCall( + "org.freedesktop.UPower", + "/org/freedesktop/UPower", + "org.freedesktop.UPower", + "Suspend"); + dbusConn.sendWithReply(msg); + return true; + } + else if (ps == TDESystemPowerState::Hibernate) { + TQT_DBusMessage msg = TQT_DBusMessage::methodCall( + "org.freedesktop.UPower", + "/org/freedesktop/UPower", + "org.freedesktop.UPower", + "Hibernate"); + dbusConn.sendWithReply(msg); + return true; + } + else { + return false; + } + } + else { + return false; + } +#else // WITH_UPOWER + return false; +#endif // WITH_UPOWER + } } else if (ps == TDESystemPowerState::PowerOff) { // Power down the system using a DCOP command diff --git a/tdeui/knuminput.cpp b/tdeui/knuminput.cpp index 118af6c22..238eeee7a 100644 --- a/tdeui/knuminput.cpp +++ b/tdeui/knuminput.cpp @@ -1099,7 +1099,6 @@ double KDoubleSpinBox::minValue() const { void KDoubleSpinBox::setMinValue( double value ) { bool ok = false; int min = d->mapToInt( value, &ok ); - if ( !ok ) return; base::setMinValue( min ); updateValidator(); } @@ -1112,7 +1111,6 @@ double KDoubleSpinBox::maxValue() const { void KDoubleSpinBox::setMaxValue( double value ) { bool ok = false; int max = d->mapToInt( value, &ok ); - if ( !ok ) return; base::setMaxValue( max ); updateValidator(); } |