From 039b9853552f136d0cf7fe85638f13d81db7d7cb Mon Sep 17 00:00:00 2001 From: chenjun Date: Fri, 30 Oct 2020 15:25:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E7=94=A8com.deepin.daemon.Powe?= =?UTF-8?q?rManager=E6=8E=A5=E5=8F=A3=E6=9D=A5=E5=88=A4=E6=96=AD=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=98=AF=E5=90=A6=E6=94=AF=E6=8C=81=E5=BE=85=E6=9C=BA?= =?UTF-8?q?=E5=92=8C=E4=BC=91=E7=9C=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 因为有些机型不支持待机,但是后端中是否支持待机的接口返回值不对需要修改,因此后端在System DBus中新增了一个 com.deepin.daemon.PowerManager接口,任务栏需要调整使用此接口来判断显示待机和休眠选项 Log: 修复待机后电源无法唤醒,只能硬重启问题 Bug: https://pms.uniontech.com/zentao/bug-view-48165.html Change-Id: I31641df56fc69965e16a92c09b6a725f8465185b --- plugins/shutdown/dbus/dbuslogin1manager.cpp | 53 --- plugins/shutdown/dbus/dbuslogin1manager.h | 413 -------------------- plugins/shutdown/dbus/dbuspowermanager.cpp | 26 ++ plugins/shutdown/dbus/dbuspowermanager.h | 73 ++++ plugins/shutdown/shutdownplugin.cpp | 7 +- plugins/shutdown/shutdownplugin.h | 4 +- 6 files changed, 104 insertions(+), 472 deletions(-) delete mode 100644 plugins/shutdown/dbus/dbuslogin1manager.cpp delete mode 100644 plugins/shutdown/dbus/dbuslogin1manager.h create mode 100644 plugins/shutdown/dbus/dbuspowermanager.cpp create mode 100644 plugins/shutdown/dbus/dbuspowermanager.h diff --git a/plugins/shutdown/dbus/dbuslogin1manager.cpp b/plugins/shutdown/dbus/dbuslogin1manager.cpp deleted file mode 100644 index 06036657a..000000000 --- a/plugins/shutdown/dbus/dbuslogin1manager.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: sbw - * kirigaya - * Hualet - * - * Maintainer: sbw - * kirigaya - * Hualet - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -c DBusLogin1Manager -p dbuslogin1manager orgfreedesktop.login1.xml - * - * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "dbuslogin1manager.h" - -/* - * Implementation of interface class DBusLogin1Manager - */ - -DBusLogin1Manager::DBusLogin1Manager(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ - QDBusConnection::systemBus().connect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); -} - -DBusLogin1Manager::~DBusLogin1Manager() -{ - QDBusConnection::systemBus().disconnect(this->service(), this->path(), "org.freedesktop.DBus.Properties", "PropertiesChanged","sa{sv}as", this, SLOT(__propertyChanged__(QDBusMessage))); -} - diff --git a/plugins/shutdown/dbus/dbuslogin1manager.h b/plugins/shutdown/dbus/dbuslogin1manager.h deleted file mode 100644 index 2d7980715..000000000 --- a/plugins/shutdown/dbus/dbuslogin1manager.h +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Copyright (C) 2015 ~ 2018 Deepin Technology Co., Ltd. - * - * Author: sbw - * kirigaya - * Hualet - * - * Maintainer: sbw - * kirigaya - * Hualet - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* - * This file was generated by qdbusxml2cpp version 0.8 - * Command line was: qdbusxml2cpp -c DBusLogin1Manager -p dbuslogin1manager orgfreedesktop.login1.xml - * - * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * Do not edit! All changes made to it will be lost. - */ - -#ifndef DBUSLOGIN1MANAGER_H_1447400884 -#define DBUSLOGIN1MANAGER_H_1447400884 - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Proxy class for interface org.freedesktop.login1.Manager - */ -class DBusLogin1Manager: public QDBusAbstractInterface -{ - Q_OBJECT - Q_SLOT void __propertyChanged__(const QDBusMessage& msg) - { - QList arguments = msg.arguments(); - if (3 != arguments.count()) - return; - QString interfaceName = msg.arguments().at(0).toString(); - if (interfaceName !="org.freedesktop.login1.Manager") - return; - QVariantMap changedProps = qdbus_cast(arguments.at(1).value()); - QStringList keys = changedProps.keys(); - foreach(const QString &prop, keys) { - const QMetaObject* self = metaObject(); - for (int i=self->propertyOffset(); i < self->propertyCount(); ++i) { - QMetaProperty p = self->property(i); - if (p.name() == prop) { - Q_EMIT p.notifySignal().invoke(this); - } - } - } - } -public: - static inline const char *staticInterfaceName() - { return "org.freedesktop.login1.Manager"; } - -public: - DBusLogin1Manager(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~DBusLogin1Manager(); - - Q_PROPERTY(QString BlockInhibited READ blockInhibited NOTIFY BlockInhibitedChanged) - inline QString blockInhibited() const - { return qvariant_cast< QString >(property("BlockInhibited")); } - - Q_PROPERTY(QString ControlGroupHierarchy READ controlGroupHierarchy) - inline QString controlGroupHierarchy() const - { return qvariant_cast< QString >(property("ControlGroupHierarchy")); } - - Q_PROPERTY(QStringList Controllers READ controllers) - inline QStringList controllers() const - { return qvariant_cast< QStringList >(property("Controllers")); } - - Q_PROPERTY(QString DelayInhibited READ delayInhibited) - inline QString delayInhibited() const - { return qvariant_cast< QString >(property("DelayInhibited")); } - - Q_PROPERTY(QString HandleHibernateKey READ handleHibernateKey) - inline QString handleHibernateKey() const - { return qvariant_cast< QString >(property("HandleHibernateKey")); } - - Q_PROPERTY(QString HandleLidSwitch READ handleLidSwitch) - inline QString handleLidSwitch() const - { return qvariant_cast< QString >(property("HandleLidSwitch")); } - - Q_PROPERTY(QString HandlePowerKey READ handlePowerKey) - inline QString handlePowerKey() const - { return qvariant_cast< QString >(property("HandlePowerKey")); } - - Q_PROPERTY(QString HandleSuspendKey READ handleSuspendKey) - inline QString handleSuspendKey() const - { return qvariant_cast< QString >(property("HandleSuspendKey")); } - - Q_PROPERTY(QString IdleAction READ idleAction) - inline QString idleAction() const - { return qvariant_cast< QString >(property("IdleAction")); } - - Q_PROPERTY(qulonglong IdleActionUSec READ idleActionUSec) - inline qulonglong idleActionUSec() const - { return qvariant_cast< qulonglong >(property("IdleActionUSec")); } - - Q_PROPERTY(bool IdleHint READ idleHint) - inline bool idleHint() const - { return qvariant_cast< bool >(property("IdleHint")); } - - Q_PROPERTY(qulonglong IdleSinceHint READ idleSinceHint) - inline qulonglong idleSinceHint() const - { return qvariant_cast< qulonglong >(property("IdleSinceHint")); } - - Q_PROPERTY(qulonglong IdleSinceHintMonotonic READ idleSinceHintMonotonic) - inline qulonglong idleSinceHintMonotonic() const - { return qvariant_cast< qulonglong >(property("IdleSinceHintMonotonic")); } - - Q_PROPERTY(qulonglong InhibitDelayMaxUSec READ inhibitDelayMaxUSec) - inline qulonglong inhibitDelayMaxUSec() const - { return qvariant_cast< qulonglong >(property("InhibitDelayMaxUSec")); } - - Q_PROPERTY(QStringList KillExcludeUsers READ killExcludeUsers) - inline QStringList killExcludeUsers() const - { return qvariant_cast< QStringList >(property("KillExcludeUsers")); } - - Q_PROPERTY(QStringList KillOnlyUsers READ killOnlyUsers) - inline QStringList killOnlyUsers() const - { return qvariant_cast< QStringList >(property("KillOnlyUsers")); } - - Q_PROPERTY(bool KillUserProcesses READ killUserProcesses) - inline bool killUserProcesses() const - { return qvariant_cast< bool >(property("KillUserProcesses")); } - - Q_PROPERTY(uint NAutoVTs READ nAutoVTs) - inline uint nAutoVTs() const - { return qvariant_cast< uint >(property("NAutoVTs")); } - - Q_PROPERTY(bool PreparingForShutdown READ preparingForShutdown) - inline bool preparingForShutdown() const - { return qvariant_cast< bool >(property("PreparingForShutdown")); } - - Q_PROPERTY(bool PreparingForSleep READ preparingForSleep) - inline bool preparingForSleep() const - { return qvariant_cast< bool >(property("PreparingForSleep")); } - - Q_PROPERTY(QStringList ResetControllers READ resetControllers) - inline QStringList resetControllers() const - { return qvariant_cast< QStringList >(property("ResetControllers")); } - -public Q_SLOTS: // METHODS - inline QDBusPendingReply<> ActivateSession(const QString &id) - { - QList argumentList; - argumentList << QVariant::fromValue(id); - return asyncCallWithArgumentList(QLatin1String("ActivateSession"), argumentList); - } - - inline QDBusPendingReply<> ActivateSessionOnSeat(const QString &id, const QString &seat) - { - QList argumentList; - argumentList << QVariant::fromValue(id) << QVariant::fromValue(seat); - return asyncCallWithArgumentList(QLatin1String("ActivateSessionOnSeat"), argumentList); - } - - inline QDBusPendingReply<> AttachDevice(const QString &seat, const QString &sysfs, bool interactive) - { - QList argumentList; - argumentList << QVariant::fromValue(seat) << QVariant::fromValue(sysfs) << QVariant::fromValue(interactive); - return asyncCallWithArgumentList(QLatin1String("AttachDevice"), argumentList); - } - - inline QDBusPendingReply CanHibernate() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("CanHibernate"), argumentList); - } - - inline QDBusPendingReply CanHybridSleep() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("CanHybridSleep"), argumentList); - } - - inline QDBusPendingReply CanPowerOff() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("CanPowerOff"), argumentList); - } - - inline QDBusPendingReply CanReboot() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("CanReboot"), argumentList); - } - - inline QDBusPendingReply CanSuspend() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("CanSuspend"), argumentList); - } - -// inline QDBusPendingReply CreateSession(uint uid, uint leader, const QString &service, const QString &type, const QString &class, const QString &seat, uint vtnr, const QString &tty, const QString &display, bool remote, const QString &remote_user, const QString &remote_host, const QStringList &controllers, const QStringList &reset_controllers, bool kill_processes) -// { -// QList argumentList; -// argumentList << QVariant::fromValue(uid) << QVariant::fromValue(leader) << QVariant::fromValue(service) << QVariant::fromValue(type) << QVariant::fromValue(class) << QVariant::fromValue(seat) << QVariant::fromValue(vtnr) << QVariant::fromValue(tty) << QVariant::fromValue(display) << QVariant::fromValue(remote) << QVariant::fromValue(remote_user) << QVariant::fromValue(remote_host) << QVariant::fromValue(controllers) << QVariant::fromValue(reset_controllers) << QVariant::fromValue(kill_processes); -// return asyncCallWithArgumentList(QLatin1String("CreateSession"), argumentList); -// } -// inline QDBusReply CreateSession(uint uid, uint leader, const QString &service, const QString &type, const QString &class, const QString &seat, uint vtnr, const QString &tty, const QString &display, bool remote, const QString &remote_user, const QString &remote_host, const QStringList &controllers, const QStringList &reset_controllers, bool kill_processes, QDBusObjectPath &path, QDBusObjectPath &runtime_path, QDBusUnixFileDescriptor &fd, QString &seat_, uint &vtnr_, bool &existing) -// { -// QList argumentList; -// argumentList << QVariant::fromValue(uid) << QVariant::fromValue(leader) << QVariant::fromValue(service) << QVariant::fromValue(type) << QVariant::fromValue(class) << QVariant::fromValue(seat) << QVariant::fromValue(vtnr) << QVariant::fromValue(tty) << QVariant::fromValue(display) << QVariant::fromValue(remote) << QVariant::fromValue(remote_user) << QVariant::fromValue(remote_host) << QVariant::fromValue(controllers) << QVariant::fromValue(reset_controllers) << QVariant::fromValue(kill_processes); -// QDBusMessage reply = callWithArgumentList(QDBus::Block, QLatin1String("CreateSession"), argumentList); -// if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 7) { -// path = qdbus_cast(reply.arguments().at(1)); -// runtime_path = qdbus_cast(reply.arguments().at(2)); -// fd = qdbus_cast(reply.arguments().at(3)); -// seat_ = qdbus_cast(reply.arguments().at(4)); -// vtnr_ = qdbus_cast(reply.arguments().at(5)); -// existing = qdbus_cast(reply.arguments().at(6)); -// } -// return reply; -// } - - inline QDBusPendingReply<> FlushDevices(bool interactive) - { - QList argumentList; - argumentList << QVariant::fromValue(interactive); - return asyncCallWithArgumentList(QLatin1String("FlushDevices"), argumentList); - } - - inline QDBusPendingReply GetSeat(const QString &id) - { - QList argumentList; - argumentList << QVariant::fromValue(id); - return asyncCallWithArgumentList(QLatin1String("GetSeat"), argumentList); - } - - inline QDBusPendingReply GetSession(const QString &id) - { - QList argumentList; - argumentList << QVariant::fromValue(id); - return asyncCallWithArgumentList(QLatin1String("GetSession"), argumentList); - } - - inline QDBusPendingReply GetSessionByPID(uint pid) - { - QList argumentList; - argumentList << QVariant::fromValue(pid); - return asyncCallWithArgumentList(QLatin1String("GetSessionByPID"), argumentList); - } - - inline QDBusPendingReply GetUser(uint uid) - { - QList argumentList; - argumentList << QVariant::fromValue(uid); - return asyncCallWithArgumentList(QLatin1String("GetUser"), argumentList); - } - - inline QDBusPendingReply<> Hibernate(bool interactive) - { - QList argumentList; - argumentList << QVariant::fromValue(interactive); - return asyncCallWithArgumentList(QLatin1String("Hibernate"), argumentList); - } - - inline QDBusPendingReply<> HybridSleep(bool interactive) - { - QList argumentList; - argumentList << QVariant::fromValue(interactive); - return asyncCallWithArgumentList(QLatin1String("HybridSleep"), argumentList); - } - - inline QDBusPendingReply Inhibit(const QString &what, const QString &who, const QString &why, const QString &mode) - { - QList argumentList; - argumentList << QVariant::fromValue(what) << QVariant::fromValue(who) << QVariant::fromValue(why) << QVariant::fromValue(mode); - return asyncCallWithArgumentList(QLatin1String("Inhibit"), argumentList); - } - - inline QDBusPendingReply<> KillSession(const QString &id, const QString &who, const QString &signal) - { - QList argumentList; - argumentList << QVariant::fromValue(id) << QVariant::fromValue(who) << QVariant::fromValue(signal); - return asyncCallWithArgumentList(QLatin1String("KillSession"), argumentList); - } - - inline QDBusPendingReply<> KillUser(uint uid, const QString &signal) - { - QList argumentList; - argumentList << QVariant::fromValue(uid) << QVariant::fromValue(signal); - return asyncCallWithArgumentList(QLatin1String("KillUser"), argumentList); - } - - inline QDBusPendingReply<> LockSession(const QString &id) - { - QList argumentList; - argumentList << QVariant::fromValue(id); - return asyncCallWithArgumentList(QLatin1String("LockSession"), argumentList); - } - - inline QDBusPendingReply<> LockSessions() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("LockSessions"), argumentList); - } - - inline QDBusPendingReply<> PowerOff(bool interactive) - { - QList argumentList; - argumentList << QVariant::fromValue(interactive); - return asyncCallWithArgumentList(QLatin1String("PowerOff"), argumentList); - } - - inline QDBusPendingReply<> Reboot(bool interactive) - { - QList argumentList; - argumentList << QVariant::fromValue(interactive); - return asyncCallWithArgumentList(QLatin1String("Reboot"), argumentList); - } - - inline QDBusPendingReply<> ReleaseSession(const QString &id) - { - QList argumentList; - argumentList << QVariant::fromValue(id); - return asyncCallWithArgumentList(QLatin1String("ReleaseSession"), argumentList); - } - - inline QDBusPendingReply<> SetUserLinger(uint uid, bool b, bool interactive) - { - QList argumentList; - argumentList << QVariant::fromValue(uid) << QVariant::fromValue(b) << QVariant::fromValue(interactive); - return asyncCallWithArgumentList(QLatin1String("SetUserLinger"), argumentList); - } - - inline QDBusPendingReply<> Suspend(bool interactive) - { - QList argumentList; - argumentList << QVariant::fromValue(interactive); - return asyncCallWithArgumentList(QLatin1String("Suspend"), argumentList); - } - - inline QDBusPendingReply<> TerminateSeat(const QString &id) - { - QList argumentList; - argumentList << QVariant::fromValue(id); - return asyncCallWithArgumentList(QLatin1String("TerminateSeat"), argumentList); - } - - inline QDBusPendingReply<> TerminateSession(const QString &id) - { - QList argumentList; - argumentList << QVariant::fromValue(id); - return asyncCallWithArgumentList(QLatin1String("TerminateSession"), argumentList); - } - - inline QDBusPendingReply<> TerminateUser(uint uid) - { - QList argumentList; - argumentList << QVariant::fromValue(uid); - return asyncCallWithArgumentList(QLatin1String("TerminateUser"), argumentList); - } - - inline QDBusPendingReply<> UnlockSession(const QString &id) - { - QList argumentList; - argumentList << QVariant::fromValue(id); - return asyncCallWithArgumentList(QLatin1String("UnlockSession"), argumentList); - } - - inline QDBusPendingReply<> UnlockSessions() - { - QList argumentList; - return asyncCallWithArgumentList(QLatin1String("UnlockSessions"), argumentList); - } - -Q_SIGNALS: // SIGNALS - void BlockInhibitedChanged(); - - void PrepareForShutdown(bool active); - void PrepareForSleep(bool active); - void SeatNew(const QString &id, const QDBusObjectPath &path); - void SeatRemoved(const QString &id, const QDBusObjectPath &path); - void SessionNew(const QString &id, const QDBusObjectPath &path); - void SessionRemoved(const QString &id, const QDBusObjectPath &path); - void UserNew(uint uid, const QDBusObjectPath &path); - void UserRemoved(uint uid, const QDBusObjectPath &path); -}; - -namespace org { - namespace freedesktop { - namespace login1 { - typedef ::DBusLogin1Manager Manager; - } - } -} -#endif diff --git a/plugins/shutdown/dbus/dbuspowermanager.cpp b/plugins/shutdown/dbus/dbuspowermanager.cpp new file mode 100644 index 000000000..2cc5e4f79 --- /dev/null +++ b/plugins/shutdown/dbus/dbuspowermanager.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c PowerManager -p com_deepin_daemon_powermanager com.deepin.daemon.PowerManager.xml + * + * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "dbuspowermanager.h" + +/* + * Implementation of interface class PowerManager + */ + +DBusPowerManager::DBusPowerManager(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +DBusPowerManager::~DBusPowerManager() +{ +} + diff --git a/plugins/shutdown/dbus/dbuspowermanager.h b/plugins/shutdown/dbus/dbuspowermanager.h new file mode 100644 index 000000000..a9c91e723 --- /dev/null +++ b/plugins/shutdown/dbus/dbuspowermanager.h @@ -0,0 +1,73 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -c PowerManager -p com_deepin_daemon_powermanager com.deepin.daemon.PowerManager.xml + * + * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef COM_DEEPIN_DAEMON_POWERMANAGER_H +#define COM_DEEPIN_DAEMON_POWERMANAGER_H + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface com.deepin.daemon.PowerManager + */ +class DBusPowerManager: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "com.deepin.daemon.PowerManager"; } + +public: + DBusPowerManager(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr); + + ~DBusPowerManager(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply CanHibernate() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("CanHibernate"), argumentList); + } + + inline QDBusPendingReply CanReboot() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("CanReboot"), argumentList); + } + + inline QDBusPendingReply CanShutdown() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("CanShutdown"), argumentList); + } + + inline QDBusPendingReply CanSuspend() + { + QList argumentList; + return asyncCallWithArgumentList(QStringLiteral("CanSuspend"), argumentList); + } + +Q_SIGNALS: // SIGNALS +}; + +namespace com { + namespace deepin { + namespace daemon { + typedef ::DBusPowerManager PowerManager; + } + } +} +#endif diff --git a/plugins/shutdown/shutdownplugin.cpp b/plugins/shutdown/shutdownplugin.cpp index 217118fa1..705830468 100644 --- a/plugins/shutdown/shutdownplugin.cpp +++ b/plugins/shutdown/shutdownplugin.cpp @@ -39,8 +39,7 @@ ShutdownPlugin::ShutdownPlugin(QObject *parent) m_pluginLoaded(false), m_tipsLabel(new TipsWidget), - m_login1Inter(new DBusLogin1Manager("org.freedesktop.login1", "/org/freedesktop/login1", QDBusConnection::systemBus(), this)) - + m_powerManagerInter(new DBusPowerManager("com.deepin.daemon.PowerManager", "/com/deepin/daemon/PowerManager", QDBusConnection::systemBus(), this)) { m_tipsLabel->setVisible(false); m_tipsLabel->setAccessibleName("shutdown"); @@ -130,7 +129,7 @@ const QString ShutdownPlugin::itemContextMenu(const QString &itemKey) QProcessEnvironment enviromentVar = QProcessEnvironment::systemEnvironment(); bool can_sleep = enviromentVar.contains("POWER_CAN_SLEEP") ? QVariant(enviromentVar.value("POWER_CAN_SLEEP")).toBool() : valueByQSettings("Power", "sleep", true) && - m_login1Inter->CanSuspend().value().contains("yes"); + m_powerManagerInter->CanSuspend(); ; if (can_sleep) { QMap suspend; @@ -141,7 +140,7 @@ const QString ShutdownPlugin::itemContextMenu(const QString &itemKey) } bool can_hibernate = enviromentVar.contains("POWER_CAN_HIBERNATE") ? QVariant(enviromentVar.value("POWER_CAN_HIBERNATE")).toBool() - : checkSwap() && m_login1Inter->CanHibernate().value().contains("yes"); + : checkSwap() && m_powerManagerInter->CanHibernate(); if (can_hibernate) { QMap hibernate; diff --git a/plugins/shutdown/shutdownplugin.h b/plugins/shutdown/shutdownplugin.h index cd9bde14d..57dab6a12 100644 --- a/plugins/shutdown/shutdownplugin.h +++ b/plugins/shutdown/shutdownplugin.h @@ -24,7 +24,7 @@ #include "pluginsiteminterface.h" #include "shutdownwidget.h" -#include "./dbus/dbuslogin1manager.h" +#include "./dbus/dbuspowermanager.h" #include @@ -111,7 +111,7 @@ private: ShutdownWidget *m_shutdownWidget; Dock::TipsWidget *m_tipsLabel; - DBusLogin1Manager* m_login1Inter; + DBusPowerManager* m_powerManagerInter; }; #endif // SHUTDOWNPLUGIN_H