File indexing completed on 2024-05-12 09:41:28
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2006 Kevin Ottens <ervin@kde.org> 0003 SPDX-FileCopyrightText: 2008-2010 Dario Freddi <drf@kde.org> 0004 SPDX-FileCopyrightText: 2010 Alejandro Fiestas <alex@eyeos.org> 0005 SPDX-FileCopyrightText: 2010-2013 Lukáš Tinkl <ltinkl@redhat.com> 0006 SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de> 0007 SPDX-FileCopyrightText: 2023 Nicolas Fella <nicolas.fella@gmx.de> 0008 0009 SPDX-License-Identifier: LGPL-2.0-only 0010 */ 0011 0012 #pragma once 0013 0014 #include <QDBusInterface> 0015 #include <QObject> 0016 #include <QPointer> 0017 0018 #include <KJob> 0019 0020 #include <sessionmanagement.h> 0021 0022 #include "powerdevilcore_export.h" 0023 0024 class POWERDEVILCORE_EXPORT SuspendController : public QObject 0025 { 0026 Q_OBJECT 0027 public: 0028 SuspendController(); 0029 0030 /** 0031 * This enum type defines the different suspend methods. 0032 * 0033 * - UnknownSuspendMethod: The name says it all 0034 * - Standby: Processes are stopped, some hardware is deactivated (ACPI S1) 0035 * - ToRam: Most devices are deactivated, only RAM is powered (ACPI S3) 0036 * - ToDisk: State of the machine is saved to disk, and it's powered down (ACPI S4) 0037 * - SuspendThenHibernate: Same as ToRam, but after a delay it switches to ToDisk 0038 */ 0039 enum SuspendMethod { 0040 UnknownSuspendMethod = 0, 0041 Standby = 1, 0042 ToRam = 2, 0043 ToDisk = 4, 0044 HybridSuspend = 8, 0045 SuspendThenHibernate = 16, 0046 }; 0047 Q_ENUM(SuspendMethod) 0048 0049 /** 0050 * This type stores an OR combination of SuspendMethod values. 0051 */ 0052 Q_DECLARE_FLAGS(SuspendMethods, SuspendMethod) 0053 0054 bool canSuspend() const; 0055 void suspend(); 0056 0057 bool canHibernate() const; 0058 void hibernate(); 0059 0060 bool canHybridSuspend() const; 0061 void hybridSuspend(); 0062 0063 bool canSuspendThenHibernate() const; 0064 void suspendThenHibernate(); 0065 0066 Q_SIGNALS: 0067 /** 0068 * This signal is emitted when the PC is resuming from suspension 0069 */ 0070 void resumeFromSuspend(); 0071 0072 /** 0073 * This signal is emitted when the PC is about to suspend 0074 */ 0075 void aboutToSuspend(); 0076 0077 private Q_SLOTS: 0078 void slotLogin1PrepareForSleep(bool active); 0079 0080 private: 0081 SessionManagement m_sessionManagement; 0082 0083 // login1 interface 0084 QPointer<QDBusInterface> m_login1Interface; 0085 }; 0086 0087 Q_DECLARE_OPERATORS_FOR_FLAGS(SuspendController::SuspendMethods)