void PowerManagementInhibitor::OnAsyncReply(QDBusPendingCallWatcher *call) { if (m_state == request_idle) { QDBusPendingReply<> reply = *call; if (reply.isError()) { qDebug("D-Bus: Reply: Error: %s", qPrintable(reply.error().message())); m_state = error; } else { m_state = idle; qDebug("D-Bus: PowerManagementInhibitor: Request successful"); if (m_intended_state == busy) RequestBusy(); } } else if (m_state == request_busy) { QDBusPendingReply<uint> reply = *call; if (reply.isError()) { qDebug("D-Bus: Reply: Error: %s", qPrintable(reply.error().message())); if (!m_use_gsm) { qDebug("D-Bus: Falling back to org.gnome.SessionManager"); m_use_gsm = true; m_state = idle; if (m_intended_state == busy) RequestBusy(); } else { m_state = error; } } else { m_state = busy; m_cookie = reply.value(); qDebug("D-Bus: PowerManagementInhibitor: Request successful, cookie is %d", m_cookie); if (m_intended_state == idle) RequestIdle(); } } else { qDebug("D-Bus: Unexpected reply in state %d", m_state); m_state = error; } call->deleteLater(); }
bool CPowerManagementInhibitorImpl::HandleReply(wxDBusMessage& msg) { if( msg.GetReplySerial() != m_serial ) { return false; } if (msg.GetType() == DBUS_MESSAGE_TYPE_ERROR) { if (m_handler->Debug()) printf("wxD-Bus: Reply: Error: %s\n", msg.GetString()); if (m_state == request_busy && !m_use_gsm) { if (m_handler->Debug()) printf("wxD-Bus: Falling back to org.gnome.SessionManager\n"); m_use_gsm = true; m_state = idle; if (m_intended_state == busy) RequestBusy(); } else m_state = error; } else if (m_state == request_idle) { m_state = idle; if (m_handler->Debug()) printf("wxD-Bus: CPowerManagementInhibitor: Request successful\n"); if (m_intended_state == busy) RequestBusy(); } else if (m_state == request_busy) { m_state = busy; msg.GetUInt(m_cookie); if (m_handler->Debug()) printf("wxD-Bus: CPowerManagementInhibitor: Request successful, cookie is %u\n", m_cookie); if (m_intended_state == idle) RequestIdle(); } else { if (m_handler->Debug()) printf("wxD-Bus: Unexpected reply in state %d\n", m_state); m_state = error; } return true; }