mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 14:38:04 -06:00
Blind implementation of auto-shutdown for Mac OS
This commit is contained in:
38
src/misc.cpp
38
src/misc.cpp
@@ -196,6 +196,44 @@ void misc::shutdownComputer() {
|
|||||||
QDBusInterface computer("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", QDBusConnection::systemBus());
|
QDBusInterface computer("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", QDBusConnection::systemBus());
|
||||||
computer.call("Shutdown");
|
computer.call("Shutdown");
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
AEEventID EventToSend = kAEShutDown;
|
||||||
|
AEAddressDesc targetDesc;
|
||||||
|
static const ProcessSerialNumber kPSNOfSystemProcess = { 0, kSystemProcess };
|
||||||
|
AppleEvent eventReply = {typeNull, NULL};
|
||||||
|
AppleEvent appleEventToSend = {typeNull, NULL};
|
||||||
|
|
||||||
|
OSStatus error = noErr;
|
||||||
|
|
||||||
|
error = AECreateDesc(typeProcessSerialNumber, &kPSNOfSystemProcess,
|
||||||
|
sizeof(kPSNOfSystemProcess), &targetDesc);
|
||||||
|
|
||||||
|
if (error != noErr)
|
||||||
|
{
|
||||||
|
return(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
error = AECreateAppleEvent(kCoreEventClass, EventToSend, &targetDesc,
|
||||||
|
kAutoGenerateReturnID, kAnyTransactionID, &appleEventToSend);
|
||||||
|
|
||||||
|
AEDisposeDesc(&targetDesc);
|
||||||
|
if (error != noErr)
|
||||||
|
{
|
||||||
|
return(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
error = AESend(&appleEventToSend, &eventReply, kAENoReply,
|
||||||
|
kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
|
||||||
|
|
||||||
|
AEDisposeDesc(&appleEventToSend);
|
||||||
|
if (error != noErr)
|
||||||
|
{
|
||||||
|
return(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
AEDisposeDesc(&eventReply);
|
||||||
|
#endif
|
||||||
|
// TODO: Windows support
|
||||||
}
|
}
|
||||||
|
|
||||||
QString misc::truncateRootFolder(boost::intrusive_ptr<torrent_info> t) {
|
QString misc::truncateRootFolder(boost::intrusive_ptr<torrent_info> t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user