Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[D-BUS Service]
Name=org.deepin.dde.Power1
Exec=/usr/bin/deepin-service-manager -n org.deepin.dde.Power1
SystemdService=org.deepin.dde.Power1.service
SystemdService=deepin-service-plugin@org.deepin.dde.Power1.service
11 changes: 0 additions & 11 deletions src/plugin-qt/power/session/misc/org.deepin.dde.Power1.service

This file was deleted.

36 changes: 22 additions & 14 deletions src/plugin-qt/power/session/sessiondbusproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
#include "sessiondbusproxy.h"
#include "../powerconstants.h"

#include <QDBusConnection>

Check warning on line 8 in src/plugin-qt/power/session/sessiondbusproxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnection> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusArgument>

Check warning on line 9 in src/plugin-qt/power/session/sessiondbusproxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusArgument> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusInterface>

Check warning on line 10 in src/plugin-qt/power/session/sessiondbusproxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusInterface> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusMessage>

Check warning on line 11 in src/plugin-qt/power/session/sessiondbusproxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusMessage> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusPendingCallWatcher>

Check warning on line 12 in src/plugin-qt/power/session/sessiondbusproxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusPendingCallWatcher> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusPendingReply>

Check warning on line 13 in src/plugin-qt/power/session/sessiondbusproxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusPendingReply> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusReply>

Check warning on line 14 in src/plugin-qt/power/session/sessiondbusproxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusReply> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDBusServiceWatcher>
#include <QDBusVariant>
#include <QDBusUnixFileDescriptor>
Expand All @@ -21,6 +22,12 @@
constexpr auto kAmbientBrightnessService = "org.deepin.dde.AmbientBrightness1";
constexpr auto kAmbientBrightnessPath = "/org/deepin/dde/AmbientBrightness1";
constexpr auto kAmbientBrightnessInterface = "org.deepin.dde.AmbientBrightness1";

void asyncShutdownFrontCall(const QString &method)
{
QDBusConnection::sessionBus().asyncCall(QDBusMessage::createMethodCall(
kShutdownFront, kShutdownPath, kShutdownFront, method));
}
}

SessionDBusProxy::SessionDBusProxy(QObject *parent)
Expand All @@ -31,18 +38,9 @@
, m_sessionManagerInter(new DDBusInterface(
kSessionManager, kSessionPath, kSessionManager,
QDBusConnection::sessionBus(), this))
, m_shutdownFrontInter(new DDBusInterface(
kShutdownFront, kShutdownPath, kShutdownFront,
QDBusConnection::sessionBus(), this))
, m_login1Inter(new DDBusInterface(
kLogin1Service, kLogin1Path, kLogin1Manager,
QDBusConnection::systemBus(), this))
, m_lockFrontInter(new DDBusInterface(
kLockFront, kLockFrontPath, kLockFront,
QDBusConnection::sessionBus(), this))
, m_blackScreenInter(new DDBusInterface(
kBlackScreen, kBlackScreenPath, kBlackScreen,
QDBusConnection::sessionBus(), this))
, m_displayInter(new DDBusInterface(
kDisplay, kDisplayPath, kDisplay,
QDBusConnection::sessionBus(), nullptr))
Expand Down Expand Up @@ -322,22 +320,31 @@

void SessionDBusProxy::requestSuspendByFront()
{
m_shutdownFrontInter->asyncCall("Suspend");
// Raw messages only: a DDBusInterface call resolves the remote meta object
// with a blocking Introspect, which deadlocks while the front-end is busy.
asyncShutdownFrontCall(QStringLiteral("Suspend"));
}

void SessionDBusProxy::requestHibernateByFront()
{
m_shutdownFrontInter->asyncCall("Hibernate");
asyncShutdownFrontCall(QStringLiteral("Hibernate"));
}

void SessionDBusProxy::requestShutdownByFront()
{
m_shutdownFrontInter->asyncCall("Shutdown");
asyncShutdownFrontCall(QStringLiteral("Shutdown"));
}

void SessionDBusProxy::showLockAuth(bool autoStart)
{
m_lockFrontInter->call("ShowAuth", autoStart);
// Keep the synchronous barrier, but never wait for the front-end's own
// blocking call to finish: one second is enough to deliver ShowAuth.
QDBusMessage msg = QDBusMessage::createMethodCall(
kLockFront, kLockFrontPath, kLockFront, QStringLiteral("ShowAuth"));
msg << autoStart;
const QDBusMessage reply = QDBusConnection::sessionBus().call(msg, QDBus::Block, 1000);
if (reply.type() == QDBusMessage::ErrorMessage)
qWarning("[Proxy] ShowAuth(%d) failed: %s", autoStart, qPrintable(reply.errorMessage()));
}

void SessionDBusProxy::lockSession(const QString &sessionId)
Expand Down Expand Up @@ -369,7 +376,8 @@

void SessionDBusProxy::setBlackScreenActive(bool active)
{
m_blackScreenInter->asyncCall("setActive", active);
QDBusConnection::sessionBus().asyncCall(QDBusMessage::createMethodCall(
kBlackScreen, kBlackScreenPath, kBlackScreen, QStringLiteral("setActive")) << active);
QDBusInterface kwin(QStringLiteral("org.kde.KWin"), QStringLiteral("/BlackScreen"),
QStringLiteral("org.kde.kwin.BlackScreen"),
QDBusConnection::sessionBus());
Expand Down
3 changes: 0 additions & 3 deletions src/plugin-qt/power/session/sessiondbusproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,7 @@ private Q_SLOTS:

DDBusInterface *m_powerInter;
DDBusInterface *m_sessionManagerInter;
DDBusInterface *m_shutdownFrontInter;
DDBusInterface *m_login1Inter;
DDBusInterface *m_lockFrontInter;
DDBusInterface *m_blackScreenInter;
DDBusInterface *m_displayInter;
DDBusInterface *m_notificationsInter;
DDBusInterface *m_sessionWatcherInter;
Expand Down
Loading