FEATURE: Added Auto-Shutdown on downloads completion feature (Linux Only for now)

This commit is contained in:
Christophe Dumez 2010-08-16 17:35:32 +00:00
parent 0af44eadb6
commit df677789d2
10 changed files with 74 additions and 1 deletions

View file

@ -67,6 +67,11 @@ const int UNLEN = 256;
#include <winbase.h>
#endif
#ifdef Q_WS_X11
#include <QDBusInterface>
#include <QDBusMessage>
#endif
QString misc::QDesktopServicesDataLocation() {
#ifdef Q_WS_WIN
LPWSTR path=new WCHAR[256];
@ -184,6 +189,15 @@ long long misc::freeDiskSpaceOnPath(QString path) {
#endif
}
void misc::shutdownComputer() {
#ifdef Q_WS_X11
// Use dbus to power off the system
// dbus-send --print-reply --system --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
QDBusInterface computer("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", QDBusConnection::systemBus());
computer.call("Shutdown");
#endif
}
QString misc::truncateRootFolder(boost::intrusive_ptr<torrent_info> t) {
if(t->num_files() == 1) {
// Single file torrent