|
|
@ -57,27 +57,21 @@ void PowerManagementInhibitor::requestIdle() |
|
|
|
if ((m_state == Error) || (m_state == Idle) || (m_state == RequestIdle) || (m_state == RequestBusy)) |
|
|
|
if ((m_state == Error) || (m_state == Idle) || (m_state == RequestIdle) || (m_state == RequestBusy)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_state = RequestIdle; |
|
|
|
qDebug("D-Bus: PowerManagementInhibitor: Requesting idle"); |
|
|
|
qDebug("D-Bus: PowerManagementInhibitor: Requesting idle"); |
|
|
|
|
|
|
|
|
|
|
|
QDBusMessage call; |
|
|
|
QDBusMessage call = m_useGSM |
|
|
|
if (!m_useGSM) |
|
|
|
? QDBusMessage::createMethodCall( |
|
|
|
call = QDBusMessage::createMethodCall( |
|
|
|
u"org.gnome.SessionManager"_qs, |
|
|
|
|
|
|
|
u"/org/gnome/SessionManager"_qs, |
|
|
|
|
|
|
|
u"org.gnome.SessionManager"_qs, |
|
|
|
|
|
|
|
u"Uninhibit"_qs) |
|
|
|
|
|
|
|
: QDBusMessage::createMethodCall( |
|
|
|
u"org.freedesktop.PowerManagement"_qs, |
|
|
|
u"org.freedesktop.PowerManagement"_qs, |
|
|
|
u"/org/freedesktop/PowerManagement/Inhibit"_qs, |
|
|
|
u"/org/freedesktop/PowerManagement/Inhibit"_qs, |
|
|
|
u"org.freedesktop.PowerManagement.Inhibit"_qs, |
|
|
|
u"org.freedesktop.PowerManagement.Inhibit"_qs, |
|
|
|
u"UnInhibit"_qs); |
|
|
|
u"UnInhibit"_qs); |
|
|
|
else |
|
|
|
call.setArguments({m_cookie}); |
|
|
|
call = QDBusMessage::createMethodCall( |
|
|
|
|
|
|
|
u"org.gnome.SessionManager"_qs, |
|
|
|
|
|
|
|
u"/org/gnome/SessionManager"_qs, |
|
|
|
|
|
|
|
u"org.gnome.SessionManager"_qs, |
|
|
|
|
|
|
|
u"Uninhibit"_qs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_state = RequestIdle; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QVariant> args; |
|
|
|
|
|
|
|
args << m_cookie; |
|
|
|
|
|
|
|
call.setArguments(args); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDBusPendingCall pcall = QDBusConnection::sessionBus().asyncCall(call, 1000); |
|
|
|
QDBusPendingCall pcall = QDBusConnection::sessionBus().asyncCall(call, 1000); |
|
|
|
auto *watcher = new QDBusPendingCallWatcher(pcall, this); |
|
|
|
auto *watcher = new QDBusPendingCallWatcher(pcall, this); |
|
|
@ -91,28 +85,27 @@ void PowerManagementInhibitor::requestBusy() |
|
|
|
if ((m_state == Error) || (m_state == Busy) || (m_state == RequestBusy) || (m_state == RequestIdle)) |
|
|
|
if ((m_state == Error) || (m_state == Busy) || (m_state == RequestBusy) || (m_state == RequestIdle)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_state = RequestBusy; |
|
|
|
qDebug("D-Bus: PowerManagementInhibitor: Requesting busy"); |
|
|
|
qDebug("D-Bus: PowerManagementInhibitor: Requesting busy"); |
|
|
|
|
|
|
|
|
|
|
|
QDBusMessage call; |
|
|
|
QDBusMessage call = m_useGSM |
|
|
|
if (!m_useGSM) |
|
|
|
? QDBusMessage::createMethodCall( |
|
|
|
call = QDBusMessage::createMethodCall( |
|
|
|
|
|
|
|
u"org.freedesktop.PowerManagement"_qs, |
|
|
|
|
|
|
|
u"/org/freedesktop/PowerManagement/Inhibit"_qs, |
|
|
|
|
|
|
|
u"org.freedesktop.PowerManagement.Inhibit"_qs, |
|
|
|
|
|
|
|
u"Inhibit"_qs); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
call = QDBusMessage::createMethodCall( |
|
|
|
|
|
|
|
u"org.gnome.SessionManager"_qs, |
|
|
|
u"org.gnome.SessionManager"_qs, |
|
|
|
u"/org/gnome/SessionManager"_qs, |
|
|
|
u"/org/gnome/SessionManager"_qs, |
|
|
|
u"org.gnome.SessionManager"_qs, |
|
|
|
u"org.gnome.SessionManager"_qs, |
|
|
|
|
|
|
|
u"Inhibit"_qs) |
|
|
|
|
|
|
|
: QDBusMessage::createMethodCall( |
|
|
|
|
|
|
|
u"org.freedesktop.PowerManagement"_qs, |
|
|
|
|
|
|
|
u"/org/freedesktop/PowerManagement/Inhibit"_qs, |
|
|
|
|
|
|
|
u"org.freedesktop.PowerManagement.Inhibit"_qs, |
|
|
|
u"Inhibit"_qs); |
|
|
|
u"Inhibit"_qs); |
|
|
|
|
|
|
|
|
|
|
|
m_state = RequestBusy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QList<QVariant> args = {u"qBittorrent"_qs}; |
|
|
|
QList<QVariant> args = {u"qBittorrent"_qs}; |
|
|
|
if (m_useGSM) args << 0u; |
|
|
|
if (m_useGSM) |
|
|
|
|
|
|
|
args << 0u; |
|
|
|
args << u"Active torrents are presented"_qs; |
|
|
|
args << u"Active torrents are presented"_qs; |
|
|
|
if (m_useGSM) args << 8u; |
|
|
|
if (m_useGSM) |
|
|
|
|
|
|
|
args << 8u; |
|
|
|
call.setArguments(args); |
|
|
|
call.setArguments(args); |
|
|
|
|
|
|
|
|
|
|
|
QDBusPendingCall pcall = QDBusConnection::sessionBus().asyncCall(call, 1000); |
|
|
|
QDBusPendingCall pcall = QDBusConnection::sessionBus().asyncCall(call, 1000); |
|
|
|