18 | | QString halt_cmd = gContext->GetSetting("HaltCommand", |
19 | | "sudo /sbin/halt -p"); |
20 | | if (!halt_cmd.isEmpty()) |
| 20 | QDBusInterface kde("org.kde.ksmserver", |
| 21 | "/KSMServer", |
| 22 | "org.kde.KSMServerInterface"); |
| 23 | QDBusInterface gnome("org.gnome.SessionManager", |
| 24 | "/org/gnome/SessionManager", |
| 25 | "org.gnome.SessionManager"); |
| 26 | QDBusInterface consolekit("org.freedesktop.ConsoleKit", |
| 27 | "/org/freedesktop/ConsoleKit/Manager", |
| 28 | "org.freedesktop.ConsoleKit.Manager", |
| 29 | QDBusConnection::systemBus()); |
| 30 | QDBusInterface hal("org.freedesktop.Hal", |
| 31 | "/org/freedesktop/Hal/devices/computer", |
| 32 | "org.freedesktop.Hal.Device.SystemPowerManagement", |
| 33 | QDBusConnection::systemBus()); |
| 34 | |
| 35 | QDBusReply<void> void_reply = kde.call("logout", 0, 2, 2); |
| 36 | QDBusReply<bool> bool_reply; |
| 37 | QDBusReply<int> int_reply; |
| 38 | |
| 39 | if (!void_reply.isValid()) |
24 | | else |
25 | | VERBOSE(VB_IMPORTANT, "Cannot halt - null command!"); |
| 45 | if (!void_reply.isValid()) |
| 46 | { |
| 47 | bool_reply = consolekit.call("CanStop"); |
| 48 | if (bool_reply.isValid() && bool_reply.value() == 1) |
| 49 | void_reply = consolekit.call("Stop"); |
| 50 | } |
| 51 | if (!void_reply.isValid()) |
| 52 | int_reply = hal.call("Shutdown"); |
| 53 | if (!void_reply.isValid() && !int_reply.isValid()) |
| 54 | { |
| 55 | QString halt_cmd = gContext->GetSetting("HaltCommand", |
| 56 | "sudo /sbin/halt -p"); |
| 57 | if (!halt_cmd.isEmpty()) |
| 58 | myth_system(halt_cmd); |
| 59 | else |
| 60 | VERBOSE(VB_IMPORTANT, "Cannot halt - null command!"); |
| 61 | } |
30 | | QString reboot_cmd = gContext->GetSetting("RebootCommand", |
31 | | "sudo /sbin/reboot"); |
32 | | if (!reboot_cmd.isEmpty()) |
| 66 | QDBusInterface kde("org.kde.ksmserver", |
| 67 | "/KSMServer", |
| 68 | "org.kde.KSMServerInterface"); |
| 69 | QDBusInterface gnome("org.gnome.SessionManager", |
| 70 | "/org/gnome/SessionManager", |
| 71 | "org.gnome.SessionManager"); |
| 72 | QDBusInterface consolekit("org.freedesktop.ConsoleKit", |
| 73 | "/org/freedesktop/ConsoleKit/Manager", |
| 74 | "org.freedesktop.ConsoleKit.Manager", |
| 75 | QDBusConnection::systemBus()); |
| 76 | QDBusInterface hal("org.freedesktop.Hal", |
| 77 | "/org/freedesktop/Hal/devices/computer", |
| 78 | "org.freedesktop.Hal.Device.SystemPowerManagement", |
| 79 | QDBusConnection::systemBus()); |
| 80 | |
| 81 | QDBusReply<void> void_reply = kde.call("logout", 0, 1, 2); |
| 82 | QDBusReply<bool> bool_reply; |
| 83 | QDBusReply<int> int_reply; |
| 84 | |
| 85 | if (!void_reply.isValid()) |
36 | | else |
37 | | VERBOSE(VB_IMPORTANT, "Cannot reboot - null command!"); |
| 91 | if (!void_reply.isValid()) |
| 92 | { |
| 93 | bool_reply = consolekit.call("CanRestart"); |
| 94 | if (bool_reply.isValid() && bool_reply.value() == 1) |
| 95 | void_reply = consolekit.call("Restart"); |
| 96 | } |
| 97 | if (!void_reply.isValid()) |
| 98 | int_reply = hal.call("Reboot"); |
| 99 | if (!void_reply.isValid() && !int_reply.isValid()) |
| 100 | { |
| 101 | QString reboot_cmd = gContext->GetSetting("RebootCommand", |
| 102 | "sudo /sbin/reboot"); |
| 103 | if (!reboot_cmd.isEmpty()) |
| 104 | myth_system(reboot_cmd); |
| 105 | else |
| 106 | VERBOSE(VB_IMPORTANT, "Cannot reboot - null command!"); |
| 107 | } |