~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to solid/control/solid/control/powermanager.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  This file is part of the KDE project
 
2
    Copyright (C) 2006-2007 Kevin Ottens <ervin@kde.org>
 
3
 
 
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.
 
7
 
 
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.
 
12
 
 
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.
 
17
 
 
18
*/
 
19
 
 
20
#ifndef SOLID_POWERMANAGER_H
 
21
#define SOLID_POWERMANAGER_H
 
22
 
 
23
#include <QtCore/QObject>
 
24
 
 
25
#include <solid/control/solid_control_export.h>
 
26
 
 
27
class KJob;
 
28
 
 
29
namespace Solid
 
30
{
 
31
namespace Control
 
32
{
 
33
    /**
 
34
     * This namespace allows to query the underlying system to obtain information
 
35
     * about the hardware available.
 
36
     *
 
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.
 
39
     *
 
40
     * Note that it's implemented as a singleton and encapsulates the backend logic.
 
41
     *
 
42
     * @author Kevin Ottens <ervin@kde.org>
 
43
     */
 
44
    namespace PowerManager
 
45
    {
 
46
       /**
 
47
         * This enum type defines the different states of the system battery.
 
48
         *
 
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
 
54
         */
 
55
        enum BatteryState{ NoBatteryState, Normal, Warning, Low, Critical };
 
56
 
 
57
        /**
 
58
         * This enum type defines the different states of the AC adapter.
 
59
         *
 
60
         * - UnknownAcAdapterState: The AC adapter has an unknown state
 
61
         * - Plugged: The AC adapter is plugged
 
62
         * - Unplugged: The AC adapter is unplugged
 
63
         */
 
64
        enum AcAdapterState{ UnknownAcAdapterState, Plugged, Unplugged };
 
65
 
 
66
        /**
 
67
         * This enum type defines the types of system button events.
 
68
         *
 
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
 
74
         */
 
75
        enum ButtonType{ UnknownButtonType, PowerButton, SleepButton, LidOpen, LidClose };
 
76
 
 
77
        /**
 
78
         * This enum type defines the different suspend methods.
 
79
         *
 
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)
 
84
         */
 
85
        enum SuspendMethod{ UnknownSuspendMethod = 0, Standby = 1, ToRam = 2, ToDisk = 4};
 
86
 
 
87
        /**
 
88
         * This type stores an OR combination of SuspendMethod values.
 
89
         */
 
90
        Q_DECLARE_FLAGS(SuspendMethods, SuspendMethod)
 
91
 
 
92
        /**
 
93
         * This enum type defines the different CPU frequency policies.
 
94
         *
 
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
 
100
         */
 
101
        enum CpuFreqPolicy{ UnknownCpuFreqPolicy = 0, OnDemand = 1, Userspace = 2, Powersave = 4, Performance = 8 };
 
102
 
 
103
        /**
 
104
         * This type stores an OR combination of CpuFreqPolicy values.
 
105
         */
 
106
        Q_DECLARE_FLAGS(CpuFreqPolicies, CpuFreqPolicy)
 
107
 
 
108
 
 
109
 
 
110
        /**
 
111
         * Retrieves the list of power management schemes available on this system.
 
112
         *
 
113
         * @return the available power management schemes
 
114
         */
 
115
        SOLIDCONTROL_EXPORT QStringList supportedSchemes();
 
116
 
 
117
        /**
 
118
         * Retrieves a localized description corresponding to the given scheme.
 
119
         *
 
120
         * @param schemeName the name of the scheme we request the description for
 
121
         * @return the associated description
 
122
         */
 
123
        SOLIDCONTROL_EXPORT QString schemeDescription(const QString &schemeName);
 
124
 
 
125
        /**
 
126
         * Retrieves the name of the current power management scheme used
 
127
         * by the system.
 
128
         *
 
129
         * @return the current scheme
 
130
         */
 
131
        SOLIDCONTROL_EXPORT QString scheme();
 
132
 
 
133
        /**
 
134
         * Changes the current power management scheme.
 
135
         *
 
136
         * @param name the name of the new scheme
 
137
         * @return true if the scheme change succeeded, false otherwise
 
138
         */
 
139
        SOLIDCONTROL_EXPORT bool setScheme(const QString &name);
 
140
 
 
141
 
 
142
        /**
 
143
         * Retrieves the current state of the system battery.
 
144
         *
 
145
         * @return the current battery state
 
146
         * @see Solid::Control::PowerManager::BatteryState
 
147
         */
 
148
        SOLIDCONTROL_EXPORT BatteryState batteryState();
 
149
 
 
150
        /**
 
151
         * Retrieves the current charge percentage of the system batteries.
 
152
         *
 
153
         * @return the current global battery charge percentage
 
154
         */
 
155
        SOLIDCONTROL_EXPORT int batteryChargePercent();
 
156
 
 
157
        /**
 
158
         * Retrieves the current state of the system AC adapter.
 
159
         *
 
160
         * @return the current AC adapter state
 
161
         * @see Solid::Control::PowerManager::AcAdapterState
 
162
         */
 
163
        SOLIDCONTROL_EXPORT AcAdapterState acAdapterState();
 
164
 
 
165
 
 
166
        /**
 
167
         * Retrieves the set of suspend methods supported by the system.
 
168
         *
 
169
         * @return the suspend methods supported by this system
 
170
         * @see Solid::Control::PowerManager::SuspendMethod
 
171
         * @see Solid::Control::PowerManager::SuspendMethods
 
172
         */
 
173
        SOLIDCONTROL_EXPORT SuspendMethods supportedSuspendMethods();
 
174
 
 
175
        /**
 
176
         * Requests a suspend of the system.
 
177
         *
 
178
         * @param method the suspend method to use
 
179
         * @return the job handling the operation
 
180
         */
 
181
        SOLIDCONTROL_EXPORT KJob *suspend(SuspendMethod method);
 
182
 
 
183
 
 
184
        /**
 
185
         * Retrieves the set of CPU frequency policies supported by the system.
 
186
         *
 
187
         * @return the CPU frequency policies supported by this system
 
188
         * @see Solid::Control::PowerManager::CpuFreqPolicy
 
189
         * @see Solid::Control::PowerManager::CpuFreqPolicies
 
190
         */
 
191
        SOLIDCONTROL_EXPORT CpuFreqPolicies supportedCpuFreqPolicies();
 
192
 
 
193
        /**
 
194
         * Retrieves the current CPU frequency policy of the system.
 
195
         *
 
196
         * @return the current CPU frequency policy used by the system
 
197
         * @see Solid::Control::PowerManager::CpuFreqPolicy
 
198
         */
 
199
        SOLIDCONTROL_EXPORT CpuFreqPolicy cpuFreqPolicy();
 
200
 
 
201
        /**
 
202
         * Changes the current CPU frequency policy of the system.
 
203
         *
 
204
         * @param newPolicy the new policy
 
205
         * @return true if the policy change succeeded, false otherwise
 
206
         * @see Solid::Control::PowerManager::CpuFreqPolicy
 
207
         */
 
208
        SOLIDCONTROL_EXPORT bool setCpuFreqPolicy(CpuFreqPolicy newPolicy);
 
209
 
 
210
        /**
 
211
         * Checks if a CPU can be disabled.
 
212
         *
 
213
         * @param cpuNum the number of the CPU we want to check
 
214
         * @return true if the given CPU can be disabled, false otherwise
 
215
         */
 
216
        SOLIDCONTROL_EXPORT bool canDisableCpu(int cpuNum);
 
217
 
 
218
        /**
 
219
         * Enables or disables a CPU.
 
220
         *
 
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
 
224
         */
 
225
        SOLIDCONTROL_EXPORT bool setCpuEnabled(int cpuNum, bool enabled);
 
226
 
 
227
        class SOLIDCONTROL_EXPORT Notifier : public QObject
 
228
        {
 
229
            Q_OBJECT
 
230
        Q_SIGNALS:
 
231
            /**
 
232
             * This signal is emitted when the power management scheme has changed.
 
233
             *
 
234
             * @param newScheme the new scheme name
 
235
             */
 
236
            void schemeChanged(QString newScheme);
 
237
 
 
238
            /**
 
239
             * This signal is emitted when the AC adapter is plugged or unplugged.
 
240
             *
 
241
             * @param newState the new state of the AC adapter, it's one of the
 
242
             * type @see Solid::Control::PowerManager::AcAdapterState
 
243
             */
 
244
            void acAdapterStateChanged(int newState);
 
245
 
 
246
            /**
 
247
             * This signal is emitted when the system battery state changed.
 
248
             *
 
249
             * @param newState the new state of the system battery, it's one of the
 
250
             * type @see Solid::Control::PowerManager::BatteryState
 
251
             */
 
252
            void batteryStateChanged(int newState);
 
253
 
 
254
            /**
 
255
             * This signal is emitted when a button has been pressed.
 
256
             *
 
257
             * @param buttonType the pressed button type, it's one of the
 
258
             * type @see Solid::Control::PowerManager::ButtonType
 
259
             */
 
260
            void buttonPressed(int buttonType);
 
261
        };
 
262
 
 
263
        SOLIDCONTROL_EXPORT Notifier *notifier();
 
264
    }
 
265
}
 
266
}
 
267
 
 
268
Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Control::PowerManager::SuspendMethods)
 
269
Q_DECLARE_OPERATORS_FOR_FLAGS(Solid::Control::PowerManager::CpuFreqPolicies)
 
270
 
 
271
#endif