1
/* This file is part of the KDE project
2
Copyright (C) 2006-2007 Kevin Ottens <ervin@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License version 2 as published by the Free Software Foundation.
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public License
14
along with this library; see the file COPYING.LIB. If not, write to
15
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
Boston, MA 02110-1301, USA.
20
#ifndef SOLID_POWERMANAGER_H
21
#define SOLID_POWERMANAGER_H
23
#include <QtCore/QObject>
25
#include <solid/control/solid_control_export.h>
34
* This namespace allows to query the underlying system to obtain information
35
* about the hardware available.
37
* It's the unique entry point for power management. Applications should use
38
* it to control or query the power management features of the system.
40
* Note that it's implemented as a singleton and encapsulates the backend logic.
42
* @author Kevin Ottens <ervin@kde.org>
44
namespace PowerManager
47
* This enum type defines the different states of the system battery.
49
* - NoBatteryState: No battery available
50
* - Normal: The battery is at its normal charge level
51
* - Warning: The battery is at its warning charge level
52
* - Low: The battery is at its low charge level
53
* - Critical: The battery is at its critical charge level
55
enum BatteryState{ NoBatteryState, Normal, Warning, Low, Critical };
58
* This enum type defines the different states of the AC adapter.
60
* - UnknownAcAdapterState: The AC adapter has an unknown state
61
* - Plugged: The AC adapter is plugged
62
* - Unplugged: The AC adapter is unplugged
64
enum AcAdapterState{ UnknownAcAdapterState, Plugged, Unplugged };
67
* This enum type defines the types of system button events.
69
* - UnknownButtonType: An unknown button
70
* - PowerButton: A power button pressed event, generally used to turn on or off the system
71
* - SleepButton: A sleep button pressed event, generally used to make the system asleep
72
* - LidOpen: A laptop lid open event
73
* - LidClose: A laptop lid close event
75
enum ButtonType{ UnknownButtonType, PowerButton, SleepButton, LidOpen, LidClose };
78
* This enum type defines the different suspend methods.
80
* - UnknownSuspendMethod: The name says it all
81
* - Standby: Processes are stopped, some hardware is deactivated (ACPI S1)
82
* - ToRam: Most devices are deactivated, only RAM is powered (ACPI S3)
83
* - ToDisk: State of the machine is saved to disk, and it's powered down (ACPI S4)
85
enum SuspendMethod{ UnknownSuspendMethod = 0, Standby = 1, ToRam = 2, ToDisk = 4};
88
* This type stores an OR combination of SuspendMethod values.
90
Q_DECLARE_FLAGS(SuspendMethods, SuspendMethod)
93
* This enum type defines the different CPU frequency policies.
95
* - UnknownCpuFreqPolicy: The name says it all
96
* - OnDemand: Frequency is changed by the kernel depending on the processor load
97
* - Userspace: Frequency is changed by a userspace agent depending on the processor load
98
* - Powersave: Frequency is always set to the lowest available
99
* - Performance: Frequency is always set to the highest available
101
enum CpuFreqPolicy{ UnknownCpuFreqPolicy = 0, OnDemand = 1, Userspace = 2, Powersave = 4, Performance = 8 };
104
* This type stores an OR combination of CpuFreqPolicy values.
106
Q_DECLARE_FLAGS(CpuFreqPolicies, CpuFreqPolicy)
111
* Retrieves the list of power management schemes available on this system.
113
* @return the available power management schemes
115
SOLIDCONTROL_EXPORT QStringList supportedSchemes();
118
* Retrieves a localized description corresponding to the given scheme.
120
* @param schemeName the name of the scheme we request the description for
121
* @return the associated description
123
SOLIDCONTROL_EXPORT QString schemeDescription(const QString &schemeName);
126
* Retrieves the name of the current power management scheme used
129
* @return the current scheme
131
SOLIDCONTROL_EXPORT QString scheme();
134
* Changes the current power management scheme.
136
* @param name the name of the new scheme
137
* @return true if the scheme change succeeded, false otherwise
139
SOLIDCONTROL_EXPORT bool setScheme(const QString &name);
143
* Retrieves the current state of the system battery.
145
* @return the current battery state
146
* @see Solid::Control::PowerManager::BatteryState
148
SOLIDCONTROL_EXPORT BatteryState batteryState();
151
* Retrieves the current charge percentage of the system batteries.
153
* @return the current global battery charge percentage
155
SOLIDCONTROL_EXPORT int batteryChargePercent();
158
* Retrieves the current state of the system AC adapter.
160
* @return the current AC adapter state
161
* @see Solid::Control::PowerManager::AcAdapterState
163
SOLIDCONTROL_EXPORT AcAdapterState acAdapterState();
167
* Retrieves the set of suspend methods supported by the system.
169
* @return the suspend methods supported by this system
170
* @see Solid::Control::PowerManager::SuspendMethod
171
* @see Solid::Control::PowerManager::SuspendMethods
173
SOLIDCONTROL_EXPORT SuspendMethods supportedSuspendMethods();
176
* Requests a suspend of the system.
178
* @param method the suspend method to use
179
* @return the job handling the operation
181
SOLIDCONTROL_EXPORT KJob *suspend(SuspendMethod method);
185
* Retrieves the set of CPU frequency policies supported by the system.
187
* @return the CPU frequency policies supported by this system
188
* @see Solid::Control::PowerManager::CpuFreqPolicy
189
* @see Solid::Control::PowerManager::CpuFreqPolicies
191
SOLIDCONTROL_EXPORT CpuFreqPolicies supportedCpuFreqPolicies();
194
* Retrieves the current CPU frequency policy of the system.
196
* @return the current CPU frequency policy used by the system
197
* @see Solid::Control::PowerManager::CpuFreqPolicy
199
SOLIDCONTROL_EXPORT CpuFreqPolicy cpuFreqPolicy();
202
* Changes the current CPU frequency policy of the system.
204
* @param newPolicy the new policy
205
* @return true if the policy change succeeded, false otherwise
206
* @see Solid::Control::PowerManager::CpuFreqPolicy
208
SOLIDCONTROL_EXPORT bool setCpuFreqPolicy(CpuFreqPolicy newPolicy);
211
* Checks if a CPU can be disabled.
213
* @param cpuNum the number of the CPU we want to check
214
* @return true if the given CPU can be disabled, false otherwise
216
SOLIDCONTROL_EXPORT bool canDisableCpu(int cpuNum);
219
* Enables or disables a CPU.
221
* @param cpuNum the number of the CPU we want to enable or disable
222
* @param enabled the new state of the CPU
223
* @return true if the state change succeeded, false otherwise
225
SOLIDCONTROL_EXPORT bool setCpuEnabled(int cpuNum, bool enabled);
227
class SOLIDCONTROL_EXPORT Notifier : public QObject
232
* This signal is emitted when the power management scheme has changed.
234
* @param newScheme the new scheme name
236
void schemeChanged(QString newScheme);
239
* This signal is emitted when the AC adapter is plugged or unplugged.
241
* @param newState the new state of the AC adapter, it's one of the
242
* type @see Solid::Control::PowerManager::AcAdapterState
244
void acAdapterStateChanged(int newState);
247
* This signal is emitted when the system battery state changed.
249
* @param newState the new state of the system battery, it's one of the
250
* type @see Solid::Control::PowerManager::BatteryState
252
void batteryStateChanged(int newState);
255
* This signal is emitted when a button has been pressed.
257
* @param buttonType the pressed button type, it's one of the
258
* type @see Solid::Control::PowerManager::ButtonType
260
void buttonPressed(int buttonType);
263
SOLIDCONTROL_EXPORT Notifier *notifier();
268
Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Control::PowerManager::SuspendMethods)
269
Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Control::PowerManager::CpuFreqPolicies)