mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 12:59:56 -07:00
Blind implementation of auto-shutdown for Mac OS
This commit is contained in:
parent
df677789d2
commit
e311239a28
1 changed files with 48 additions and 10 deletions
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) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue