not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / libs / solid / control / ifaces / powermanager.h
blobfe9e975a859c44b95e0e86aa2d8dbd2d1b87b1d8
1 /* This file is part of the KDE project
2 Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
3 Copyright (C) 2008 Dario Freddi <drf54321@gmail.com>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
21 #ifndef SOLID_IFACES_POWERMANAGER_H
22 #define SOLID_IFACES_POWERMANAGER_H
24 #include <QtCore/QObject>
25 #include <QtCore/QStringList>
27 #include "../solid_control_export.h"
29 #include "../powermanager.h"
31 class KJob;
33 namespace Solid
35 namespace Control
37 namespace Ifaces
39 /**
40 * This class specifies the interface a backend will have to implement in
41 * order to be used in the system.
43 * A power manager allows to control or query the power management features
44 * or the underlying platform.
46 class SOLIDCONTROLIFACES_EXPORT PowerManager : public QObject
48 Q_OBJECT
50 public:
51 /**
52 * Constructs a PowerManager
54 PowerManager(QObject *parent = 0);
56 /**
57 * Destructs a PowerManager object
59 virtual ~PowerManager();
62 /**
63 * Retrieves the list of power management schemes available on this system.
65 * @return the available power management schemes
67 virtual QStringList supportedSchemes() const = 0;
69 /**
70 * Retrieves a localized description corresponding to the given scheme.
72 * @param schemeName the name of the scheme we request the description for
73 * @return the associated description
75 virtual QString schemeDescription(const QString &schemeName) const = 0;
77 /**
78 * Retrieves the name of the current power management scheme used
79 * by the system.
81 * @return the current scheme
83 virtual QString scheme() const = 0;
85 /**
86 * Changes the current power management scheme.
88 * @param name the name of the new scheme
89 * @return true if the scheme change succeeded, false otherwise
91 virtual bool setScheme(const QString &name) = 0;
94 /**
95 * Retrieves the current state of the system battery.
97 * @return the current battery state
98 * @see Solid::Control::PowerManager::BatteryState
100 virtual Solid::Control::PowerManager::BatteryState batteryState() const = 0;
103 * Retrieves the current charge percentage of the system batteries.
105 * @return the current global battery charge percentage
107 virtual int batteryChargePercent() const = 0;
110 * Retrieves the current estimated remaining time of the system batteries
112 * @return the current global estimated remaining time in milliseconds
114 virtual int batteryRemainingTime() const = 0;
117 * Retrieves the current state of the system AC adapter.
119 * @return the current AC adapter state
120 * @see Solid::Control::PowerManager::AcAdapterState
122 virtual Solid::Control::PowerManager::AcAdapterState acAdapterState() const = 0;
126 * Retrieves the set of suspend methods supported by the system.
128 * @return the suspend methods supported by this system
129 * @see Solid::Control::PowerManager::SuspendMethod
130 * @see Solid::Control::PowerManager::SuspendMethods
132 virtual Solid::Control::PowerManager::SuspendMethods supportedSuspendMethods() const = 0;
135 * Requests a suspend of the system.
137 * @param method the suspend method to use
138 * @return the job handling the operation
140 virtual KJob *suspend(Solid::Control::PowerManager::SuspendMethod method) const = 0;
144 * Retrieves the set of CPU frequency policies supported by the system.
146 * @return the CPU frequency policies supported by this system
147 * @see Solid::Control::PowerManager::CpuFreqPolicy
148 * @see Solid::Control::PowerManager::CpuFreqPolicies
150 virtual Solid::Control::PowerManager::CpuFreqPolicies supportedCpuFreqPolicies() const = 0;
153 * Retrieves the current CPU frequency policy of the system.
155 * @return the current CPU frequency policy used by the system
156 * @see Solid::Control::PowerManager::CpuFreqPolicy
158 virtual Solid::Control::PowerManager::CpuFreqPolicy cpuFreqPolicy() const = 0;
161 * Changes the current CPU frequency policy of the system.
163 * @param newPolicy the new policy
164 * @return true if the policy change succeeded, false otherwise
165 * @see Solid::Control::PowerManager::CpuFreqPolicy
167 virtual bool setCpuFreqPolicy(Solid::Control::PowerManager::CpuFreqPolicy newPolicy) = 0;
170 * Checks if a CPU can be disabled.
172 * @param cpuNum the number of the CPU we want to check
173 * @return true if the given CPU can be disabled, false otherwise
175 virtual bool canDisableCpu(int cpuNum) const = 0;
178 * Enables or disables a CPU.
180 * @param cpuNum the number of the CPU we want to enable or disable
181 * @param enabled the new state of the CPU
182 * @return true if the state change succeeded, false otherwise
184 virtual bool setCpuEnabled(int cpuNum, bool enabled) = 0;
187 * Checks if brightness controls are enabled on this system.
189 * @return a list of the devices available to control
191 virtual Solid::Control::PowerManager::BrightnessControlsList brightnessControlsAvailable() = 0;
194 * Gets the screen brightness.
196 * @param device the name of the device that you would like to control
197 * @return the brightness of the device, as a percentage
199 virtual float brightness(const QString &device = QString()) = 0;
202 * Sets the screen brightness.
204 * @param brightness the desired screen brightness, as a percentage
205 * @param device the name of the device that you would like to control, as given by brightnessControlsAvailable
206 * @return true if the brightness change succeeded, false otherwise
208 virtual bool setBrightness(float brightness, const QString &panel = QString()) = 0;
210 Q_SIGNALS:
212 * This signal is emitted when the power management scheme has changed.
214 * @param newScheme the new scheme name
216 void schemeChanged(QString newScheme);
219 * This signal is emitted when the AC adapter is plugged or unplugged.
221 * @param newState the new state of the AC adapter, it's one of the
222 * type @see Solid::Control::PowerManager::AcAdapterState
224 void acAdapterStateChanged(int newState);
227 * This signal is emitted when the system battery state changed.
229 * @param newState the new state of the system battery, it's one of the
230 * type @see Solid::Control::PowerManager::BatteryState
232 void batteryStateChanged(int newState);
235 * This signal is emitted when a button has been pressed.
237 * @param buttonType the pressed button type, it's one of the
238 * type @see Solid::Control::PowerManager::ButtonType
240 void buttonPressed(int buttonType);
243 * This signal is emitted when the brightness changes.
245 * @param brightness the new brightness level
247 void brightnessChanged(float brightness);
250 * This signal is emitted when the estimated battery remaining time changes.
252 * @param brightness the new remaining time
254 void batteryRemainingTimeChanged(int time);
260 #endif