Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.2:PowerPC
kdebase3
kickoff-shutdown-upower.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File kickoff-shutdown-upower.patch of Package kdebase3
diff -wruN kdebase-3.5.10.orig/kicker/kicker/ui/k_new_mnu.cpp kdebase-3.5.10/kicker/kicker/ui/k_new_mnu.cpp --- kdebase-3.5.10.orig/kicker/kicker/ui/k_new_mnu.cpp 2012-02-24 14:00:03.000000000 +0400 +++ kdebase-3.5.10/kicker/kicker/ui/k_new_mnu.cpp 2012-02-26 09:16:18.726727042 +0400 @@ -3685,54 +3685,41 @@ return 5; } -#define DBUS_HAL_INTERFACE "org.freedesktop.Hal" -#define DBUS_HAL_SYSTEM_POWER_INTERFACE "org.freedesktop.Hal.Device.SystemPowerManagement" -#define HAL_UDI_COMPUTER "/org/freedesktop/Hal/devices/computer" - #ifdef KDELIBS_SUSE -#include <liblazy.h> #include <X11/Xlib.h> #include <fixx11h.h> + +#include <dbus/qdbusdata.h> +#include <dbus/qdbusmessage.h> +#include <dbus/qdbusproxy.h> +#include <dbus/qdbusvariant.h> #endif void KMenu::insertSuspendOption( int &nId, int &index ) { #ifdef KDELIBS_SUSE - int supported = -1; + bool suspend_ram, suspend_disk, standby; - DCOPRef kpowersave( "kpowersave", "KPowersaveIface" ); - DCOPReply reply = kpowersave.call( "allowed_sleepingStates" ); - if( reply.isValid()) { - QStringList supported = reply; - suspend_ram = supported.contains( "suspendToRAM" ); - suspend_disk = supported.contains( "suspendToDisk" ); - standby = supported.contains( "standBy" ); - } else { - liblazy_hal_get_property_bool(HAL_UDI_COMPUTER, "power_management.can_suspend", &supported); - if (supported == 1) - suspend_ram = true; - else - suspend_ram = false; - liblazy_hal_get_property_bool(HAL_UDI_COMPUTER, "power_management.can_standby", &supported); - if (supported == 1) - standby = true; - else - standby = false; - liblazy_hal_get_property_bool(HAL_UDI_COMPUTER, "power_management.can_hibernate", &supported); - if (supported == 1) - suspend_disk = true; - else - suspend_disk = false; + m_dbusConn = QDBusConnection::addConnection(QDBusConnection::SystemBus); + + QDBusProxy upowerProperties("org.freedesktop.UPower", "/org/freedesktop/UPower", "org.freedesktop.DBus.Properties", m_dbusConn); + // can suspend? + QValueList<QDBusData> params; + params << QDBusData::fromString(upowerProperties.interface()) << QDBusData::fromString("CanSuspend"); + QDBusMessage reply = upowerProperties.sendWithReply("Get", params); + if(reply.type() == QDBusMessage::ReplyMessage && reply.count() == 1) + suspend_ram = reply[0].toVariant().value.toBool(); + + // can hibernate? + params.clear(); + params << QDBusData::fromString(upowerProperties.interface()) << QDBusData::fromString("CanHibernate"); + reply = upowerProperties.sendWithReply("Get", params); + if(reply.type() == QDBusMessage::ReplyMessage && reply.count() == 1) + suspend_disk = reply[0].toVariant().value.toBool(); - if (liblazy_hal_is_caller_privileged("org.freedesktop.hal.power-management.hibernate") != 1) - suspend_disk = false; - if (liblazy_hal_is_caller_privileged("org.freedesktop.hal.power-management.suspend") != 1) - suspend_ram = false; - if (liblazy_hal_is_caller_privileged("org.freedesktop.hal.power-management.standby") != 1) standby = false; - } if ( ! ( standby + suspend_ram + suspend_disk ) ) return; @@ -3756,59 +3743,29 @@ void KMenu::slotSuspend(int id) { #ifdef KDELIBS_SUSE - int error = 0; - - DCOPRef kpowersave( "kpowersave", "KPowersaveIface" ); - DCOPReply reply = kpowersave.call( "allowed_sleepingStates" ); - if( reply.isValid()) { - bool ok; - extern Time qt_x_time; - XUngrabKeyboard( qt_xdisplay(), qt_x_time ); - XUngrabPointer( qt_xdisplay(), qt_x_time ); - XSync( qt_xdisplay(), False ); - if( id == 1 ) - ok = kpowersave.call( "do_suspendToDisk" ); - else if( id == 2 ) - ok = kpowersave.call( "do_suspendToRAM" ); - else if( id == 3 ) - ok = kpowersave.call( "do_standBy" ); - else - return; - error = ok ? 0 : 1; - } else { - int wake = 0; - DBusMessage *reply = 0; if (id == 1) { - error = liblazy_dbus_system_send_method_call(DBUS_HAL_INTERFACE, - HAL_UDI_COMPUTER, - DBUS_HAL_SYSTEM_POWER_INTERFACE, - "Hibernate", - &reply, - DBUS_TYPE_INVALID); + if( m_dbusConn.isConnected() ) { + QDBusMessage msg = QDBusMessage::methodCall( + "org.freedesktop.UPower", + "/org/freedesktop/UPower", + "org.freedesktop.UPower", + "Hibernate"); + m_dbusConn.sendWithReply(msg); + } } else if (id == 2) - error = liblazy_dbus_system_send_method_call(DBUS_HAL_INTERFACE, - HAL_UDI_COMPUTER, - DBUS_HAL_SYSTEM_POWER_INTERFACE, - "Suspend", - &reply, - DBUS_TYPE_INT32, - &wake, - DBUS_TYPE_INVALID); - else if (id == 3) - error = liblazy_dbus_system_send_method_call(DBUS_HAL_INTERFACE, - HAL_UDI_COMPUTER, - DBUS_HAL_SYSTEM_POWER_INTERFACE, - "Standby", - &reply, - DBUS_TYPE_INVALID); + if( m_dbusConn.isConnected() ) { + QDBusMessage msg = QDBusMessage::methodCall( + "org.freedesktop.UPower", + "/org/freedesktop/UPower", + "org.freedesktop.UPower", + "Suspend"); + m_dbusConn.sendWithReply(msg); + } else return; - } - if (error) #endif - KMessageBox::error(this, i18n("Suspend failed")); } diff -wruN kdebase-3.5.10.orig/kicker/kicker/ui/k_new_mnu.h kdebase-3.5.10/kicker/kicker/ui/k_new_mnu.h --- kdebase-3.5.10.orig/kicker/kicker/ui/k_new_mnu.h 2012-02-24 14:28:32.000000000 +0400 +++ kdebase-3.5.10/kicker/kicker/ui/k_new_mnu.h 2012-02-26 09:14:15.733728378 +0400 @@ -41,6 +41,7 @@ #include "kmenubase.h" #include "service_mnu.h" #include "query.h" +#include <dbus/qdbusconnection.h> class KickerClientMenu; class KickoffTabBar; @@ -228,6 +229,7 @@ FlipScrollView * m_exitView; QVBox * m_searchWidget; QLabel * m_resizeHandle; + QDBusConnection m_dbusConn; bool m_isresizing; // timer for search without pressing enter feature
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor