| 18 | | QString halt_cmd = gContext->GetSetting("HaltCommand", |
| 19 | | "sudo /sbin/halt -p"); |
| 20 | | if (!halt_cmd.isEmpty()) |
| | 20 | QDBusInterface kde("org.kde.ksmserver", "/KSMServer", |
| | 21 | "org.kde.KSMServerInterface"); |
| | 22 | QDBusInterface gnome("org.gnome.SessionManager", "/org/gnome/SessionManager", |
| | 23 | "org.gnome.SessionManager"); |
| | 24 | QDBusInterface consolekit("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", |
| | 25 | "org.freedesktop.ConsoleKit.Manager",QDBusConnection::systemBus()); |
| | 26 | |
| | 27 | QDBusReply<void> void_reply = kde.call("logout", 0, 2, 2); |
| | 28 | QDBusReply<bool> bool_reply = gnome.call("CanShutdown"); |
| | 29 | |
| | 30 | if (!void_reply.isValid() && bool_reply.isValid() && bool_reply.value() ==1) |
| | 31 | void_reply = gnome.call("RequestShutdown"); |
| | 32 | if (!void_reply.isValid()) |
| 30 | | QString reboot_cmd = gContext->GetSetting("RebootCommand", |
| 31 | | "sudo /sbin/reboot"); |
| 32 | | if (!reboot_cmd.isEmpty()) |
| | 51 | QDBusInterface kde("org.kde.ksmserver", "/KSMServer", |
| | 52 | "org.kde.KSMServerInterface"); |
| | 53 | QDBusInterface gnome("org.gnome.SessionManager", "/org/gnome/SessionManager", |
| | 54 | "org.gnome.SessionManager"); |
| | 55 | QDBusInterface consolekit("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", |
| | 56 | "org.freedesktop.ConsoleKit.Manager",QDBusConnection::systemBus()); |
| | 57 | |
| | 58 | QDBusReply<void> void_reply = kde.call("logout", 0, 1, 2); |
| | 59 | QDBusReply<bool> bool_reply = gnome.call("CanShutdown"); |
| | 60 | |
| | 61 | if (!void_reply.isValid() && bool_reply.isValid() && bool_reply.value() == 1) |
| 36 | | else |
| 37 | | VERBOSE(VB_IMPORTANT, "Cannot reboot - null command!"); |
| | 65 | if (!void_reply.isValid()) |
| | 66 | { |
| | 67 | bool_reply = consolekit.call("CanRestart"); |
| | 68 | if (bool_reply.isValid() && bool_reply.value() ==1) |
| | 69 | void_reply = consolekit.call("Restart"); |
| | 70 | } |
| | 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 | } |