summaryrefslogtreecommitdiffstats
path: root/ksmserver/shutdown.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2012-05-20 18:22:04 -0500
committerTimothy Pearson <[email protected]>2012-05-20 18:22:04 -0500
commit193d9afcdb186902317c5bef5d6c769fc8933f1a (patch)
tree7634b1ddfbef08527a9fc55841ccbbdac2de7cae /ksmserver/shutdown.cpp
parent2f2f32d31cb1548defcd7aa84187ac7df6479cce (diff)
downloadtdebase-193d9afcdb186902317c5bef5d6c769fc8933f1a.tar.gz
tdebase-193d9afcdb186902317c5bef5d6c769fc8933f1a.zip
Fix desktop lock not engaging on suspend
This closes Bug 1003
Diffstat (limited to 'ksmserver/shutdown.cpp')
-rw-r--r--ksmserver/shutdown.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/ksmserver/shutdown.cpp b/ksmserver/shutdown.cpp
index 09cb2d743..ef0c0c92f 100644
--- a/ksmserver/shutdown.cpp
+++ b/ksmserver/shutdown.cpp
@@ -83,6 +83,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <libkrsync/krsync.h>
+#ifdef WITH_UPOWER
+ #include <tqdbusdata.h>
+ #include <tqdbusmessage.h>
+ #include <tqdbusproxy.h>
+ #include <tqdbusvariant.h>
+#endif
+
#include "server.h"
#include "global.h"
#include "shutdowndlg.h"
@@ -169,14 +176,48 @@ void KSMServer::shutdownInternal( KApplication::ShutdownConfirm confirm,
dialogActive = true;
if ( !logoutConfirmed ) {
+ int selection;
KSMShutdownFeedback::start(); // make the screen gray
logoutConfirmed =
- KSMShutdownDlg::confirmShutdown( maysd, sdtype, bopt );
+ KSMShutdownDlg::confirmShutdown( maysd, sdtype, bopt, &selection );
// ###### We can't make the screen remain gray while talking to the apps,
// because this prevents interaction ("do you want to save", etc.)
// TODO: turn the feedback widget into a list of apps to be closed,
// with an indicator of the current status for each.
KSMShutdownFeedback::stop(); // make the screen become normal again
+ if (selection != 0) {
+ // respect lock on resume & disable suspend/hibernate settings
+ // from power-manager
+ KConfig config("power-managerrc");
+ bool lockOnResume = config.readBoolEntry("lockOnResume", true);
+ if (lockOnResume) {
+ DCOPRef("kdesktop", "KScreensaverIface").send("lock");
+ }
+#ifdef WITH_UPOWER
+ TQT_DBusConnection dbusConn;
+ dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (selection == 1) { // Suspend
+ if ( dbusConn.isConnected() ) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.UPower",
+ "/org/freedesktop/UPower",
+ "org.freedesktop.UPower",
+ "Suspend");
+ dbusConn.sendWithReply(msg);
+ }
+ }
+ if (selection == 2) { // Hibernate
+ if( dbusConn.isConnected() ) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.UPower",
+ "/org/freedesktop/UPower",
+ "org.freedesktop.UPower",
+ "Hibernate");
+ dbusConn.sendWithReply(msg);
+ }
+ }
+#endif // WITH_UPOWER
+ }
}
if ( logoutConfirmed ) {