Ticket #7749: use_session_to_shutdown.patch
| File use_session_to_shutdown.patch, 3.9 KB (added by , 16 years ago) |
|---|
-
programs/mythfrontend/mythfrontend.pro
5 5 QT += network xml sql webkit 6 6 7 7 TEMPLATE = app 8 CONFIG += thread 8 CONFIG += thread qdbus 9 9 TARGET = mythfrontend 10 10 target.path = $${PREFIX}/bin 11 11 INSTALLS = target -
programs/mythfrontend/exitprompt.cpp
1 1 2 2 #include <QCoreApplication> 3 #include <QtDBus> 4 #include <QDBusInterface> 3 5 4 6 #include "exitprompt.h" 5 7 #include "mythcontext.h" … … 15 17 16 18 void ExitPrompter::halt() 17 19 { 18 QString halt_cmd = gContext->GetSetting("HaltCommand", 19 "sudo /sbin/halt -p"); 20 if (!halt_cmd.isEmpty()) 20 //QDBusInterface xfce("org.xfce.SessionManager", "/org/xfce/SessionManager", 21 // "org.xfce.Session.Manager"); 22 QDBusInterface kde("org.kde.ksmserver", "/KSMServer", 23 "org.kde.KSMServerInterface"); 24 QDBusInterface gnome("org.gnome.SessionManager", "/org/gnome/SessionManager", 25 "org.gnome.SessionManager"); 26 27 QDBusReply<void> void_reply = kde.call("logout", 0, 2, 2); 28 29 //XFCE dbus interface appears broken for now 30 //https://bugs.launchpad.net/ubuntu/+source/xfce4-session/+bug/496094 31 //if (!void_reply.isValid()) 32 // void_reply = xfce.call("Shutdown", (uint) 2, (bool) false); 33 if (!void_reply.isValid()) 21 34 { 22 myth_system(halt_cmd); 35 QDBusReply<bool> bool_reply = gnome.call("CanShutdown"); 36 if (bool_reply.isValid() && bool_reply.value() == 1) 37 void_reply=gnome.call("RequestShutdown"); 23 38 } 24 else 25 VERBOSE(VB_IMPORTANT, "Cannot halt - null command!"); 39 if (!void_reply.isValid()) 40 { 41 QString halt_cmd = gContext->GetSetting("HaltCommand", 42 "sudo /sbin/halt -p"); 43 if (!halt_cmd.isEmpty()) 44 myth_system(halt_cmd); 45 else 46 VERBOSE(VB_IMPORTANT, "Cannot halt - null command!"); 47 } 26 48 } 27 49 28 50 void ExitPrompter::reboot() 29 51 { 30 QString reboot_cmd = gContext->GetSetting("RebootCommand", 31 "sudo /sbin/reboot"); 32 if (!reboot_cmd.isEmpty()) 52 //QDBusInterface xfce("org.xfce.SessionManager", "/org/xfce/SessionManager", 53 // "org.xfce.Session.Manager"); 54 QDBusInterface kde("org.kde.ksmserver", "/KSMServer", 55 "org.kde.KSMServerInterface"); 56 QDBusInterface gnome("org.gnome.SessionManager", "/org/gnome/SessionManager", 57 "org.gnome.SessionManager"); 58 59 QDBusReply<void> void_reply = kde.call("logout", 0, 1, 2); 60 61 //XFCE dbus interface appears broken for now 62 //https://bugs.launchpad.net/ubuntu/+source/xfce4-session/+bug/496094 63 //if (!void_reply.isValid()) 64 // void_reply = xfce.call("Shutdown", (uint) 3, (bool) false); 65 if (!void_reply.isValid()) 33 66 { 34 myth_system(reboot_cmd); 67 QDBusReply<bool> bool_reply = gnome.call("CanShutdown"); 68 if (bool_reply.isValid() && bool_reply.value() == 1) 69 void_reply=gnome.call("RequestReboot"); 35 70 } 36 else 37 VERBOSE(VB_IMPORTANT, "Cannot reboot - null command!"); 71 if (!void_reply.isValid()) 72 { 73 QString reboot_cmd = gContext->GetSetting("RebootCommand", 74 "sudo /sbin/reboot"); 75 if (!reboot_cmd.isEmpty()) 76 myth_system(reboot_cmd); 77 else 78 VERBOSE(VB_IMPORTANT, "Cannot reboot - null command!"); 79 } 38 80 } 39 81 40 82 void ExitPrompter::handleExit()
