File indexing completed on 2024-04-28 05:36:16
0001 /* 0002 * SPDX-FileCopyrightText: 2008 Kevin Ottens <ervin@kde.org> 0003 * SPDX-FileCopyrightText: 2008-2010 Dario Freddi <drf@kde.org> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include <QObject> 0011 0012 #include "controllers/batterycontroller.h" 0013 #include "powerdevilenums.h" 0014 #include "powerdevilpolicyagent.h" 0015 0016 namespace PowerDevil 0017 { 0018 class Core; 0019 0020 class FdoConnector : public QObject, protected QDBusContext 0021 { 0022 Q_OBJECT 0023 Q_DISABLE_COPY(FdoConnector) 0024 0025 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.PowerManagement") 0026 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.PowerManagement.Inhibit") 0027 0028 public: 0029 explicit FdoConnector(PowerDevil::Core *parent); 0030 0031 bool CanHibernate(); 0032 bool CanSuspend(); 0033 bool CanHybridSuspend(); 0034 bool CanSuspendThenHibernate(); 0035 0036 bool GetPowerSaveStatus(); 0037 0038 void Suspend(); 0039 void Hibernate(); 0040 0041 bool HasInhibit(); 0042 0043 int Inhibit(const QString &application, const QString &reason); 0044 void UnInhibit(int cookie); 0045 void ForceUnInhibitAll(); 0046 0047 Q_SIGNALS: 0048 void CanSuspendChanged(bool canSuspend); 0049 void CanHibernateChanged(bool canHibernate); 0050 void CanHybridSuspendChanged(bool canHybridSuspend); 0051 void CanSuspendThenHibernateChanged(bool canSuspendThenHibernate); 0052 void PowerSaveStatusChanged(bool savePower); 0053 0054 void HasInhibitChanged(bool hasInhibit); 0055 0056 private Q_SLOTS: 0057 void onAcAdapterStateChanged(BatteryController::AcAdapterState); 0058 void onUnavailablePoliciesChanged(PowerDevil::PolicyAgent::RequiredPolicies); 0059 void triggerSuspendSession(PowerDevil::PowerButtonAction action); 0060 0061 private: 0062 PowerDevil::Core *m_core; 0063 }; 0064 0065 }