File indexing completed on 2024-04-28 16:55:14

0001 /***************************************************************************
0002  *   Copyright (C) 2008 by Kevin Ottens <ervin@kde.org>                    *
0003  *   Copyright (C) 2008-2010 by Dario Freddi <drf@kde.org>                 *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
0019  ***************************************************************************/
0020 
0021 #ifndef POWERDEVILFDOCONNECTOR_H
0022 #define POWERDEVILFDOCONNECTOR_H
0023 
0024 #include <QObject>
0025 
0026 #include "powerdevilbackendinterface.h"
0027 #include "powerdevilpolicyagent.h"
0028 
0029 namespace PowerDevil {
0030 class Core;
0031 
0032 class FdoConnector : public QObject, protected QDBusContext
0033 {
0034     Q_OBJECT
0035     Q_DISABLE_COPY(FdoConnector)
0036 
0037     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.PowerManagement")
0038     Q_CLASSINFO("D-Bus Interface", "org.freedesktop.PowerManagement.Inhibit")
0039 
0040 public:
0041     explicit FdoConnector(PowerDevil::Core *parent);
0042 
0043     bool CanHibernate();
0044     bool CanSuspend();
0045     bool CanHybridSuspend();
0046     bool CanSuspendThenHibernate();
0047 
0048     bool GetPowerSaveStatus();
0049 
0050     void Suspend();
0051     void Hibernate();
0052     void HybridSuspend();
0053     void SuspendThenHibernate();
0054 
0055     bool HasInhibit();
0056 
0057     int Inhibit(const QString &application, const QString &reason);
0058     void UnInhibit(int cookie);
0059     void ForceUnInhibitAll();
0060 
0061 Q_SIGNALS:
0062     void CanSuspendChanged(bool canSuspend);
0063     void CanHibernateChanged(bool canHibernate);
0064     void CanHybridSuspendChanged(bool canHybridSuspend);
0065     void CanSuspendThenHibernateChanged(bool canSuspendThenHibernate);
0066     void PowerSaveStatusChanged(bool savePower);
0067 
0068     void HasInhibitChanged(bool hasInhibit);
0069 
0070 private Q_SLOTS:
0071     void onAcAdapterStateChanged(PowerDevil::BackendInterface::AcAdapterState);
0072     void onUnavailablePoliciesChanged(PowerDevil::PolicyAgent::RequiredPolicies);
0073     void triggerSuspendSession(uint action);
0074 
0075 private:
0076     PowerDevil::Core *m_core;
0077 };
0078 
0079 }
0080 
0081 #endif /*POWERDEVILFDOCONNECTOR_H*/