1
/***************************************************************************
2
* Copyright (C) 2010 by Dario Freddi <drf@kde.org> *
4
* This program is free software; you can redistribute it and/or modify *
5
* it under the terms of the GNU General Public License as published by *
6
* the Free Software Foundation; either version 2 of the License, or *
7
* (at your option) any later version. *
9
* This program 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 *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18
***************************************************************************/
20
#include "powerdevilbackendinterface.h"
25
class BackendInterface::Private
28
Private() : isReady(false), isError(false), isLidClosed(false) {}
31
AcAdapterState acAdapterState;
32
qulonglong batteryRemainingTime;
33
BatteryState batteryState;
34
QHash< BrightnessControlType, float > brightness;
35
BrightnessControlsList brightnessControlsAvailable;
36
Capabilities capabilities;
37
SuspendMethods suspendMethods;
42
QHash< QString, uint > capacities;
43
QList< RecallNotice > recallNotices;
46
BackendInterface::BackendInterface(QObject* parent)
52
BackendInterface::~BackendInterface()
57
BackendInterface::AcAdapterState BackendInterface::acAdapterState() const
59
return d->acAdapterState;
62
qulonglong BackendInterface::batteryRemainingTime() const
64
return d->batteryRemainingTime;
67
BackendInterface::BatteryState BackendInterface::batteryState() const
69
return d->batteryState;
72
float BackendInterface::brightness(BackendInterface::BrightnessControlType type) const
74
return d->brightness[type];
77
BackendInterface::BrightnessControlsList BackendInterface::brightnessControlsAvailable() const
79
return d->brightnessControlsAvailable;
82
QHash< QString, uint > BackendInterface::capacities() const
87
QList< BackendInterface::RecallNotice > BackendInterface::recallNotices() const
89
return d->recallNotices;
92
BackendInterface::SuspendMethods BackendInterface::supportedSuspendMethods() const
94
return d->suspendMethods;
97
bool BackendInterface::isLidClosed() const
99
return d->isLidClosed;
102
void BackendInterface::setAcAdapterState(PowerDevil::BackendInterface::AcAdapterState state)
104
d->acAdapterState = state;
105
emit acAdapterStateChanged(state);
108
void BackendInterface::setBackendHasError(const QString& errorDetails)
110
Q_UNUSED(errorDetails)
113
void BackendInterface::setBackendIsReady(BrightnessControlsList availableBrightnessControls,
114
BackendInterface::SuspendMethods supportedSuspendMethods)
116
d->brightnessControlsAvailable = availableBrightnessControls;
117
d->suspendMethods = supportedSuspendMethods;
123
void BackendInterface::setBatteryRemainingTime(qulonglong time)
125
d->batteryRemainingTime = time;
126
emit batteryRemainingTimeChanged(time);
129
void BackendInterface::setBatteryState(PowerDevil::BackendInterface::BatteryState state)
131
d->batteryState = state;
132
emit batteryStateChanged(state);
135
void BackendInterface::setButtonPressed(PowerDevil::BackendInterface::ButtonType type)
137
if (type == LidClose) {
138
d->isLidClosed = true;
139
} else if (type == LidOpen) {
140
d->isLidClosed = false;
142
emit buttonPressed(type);
145
void BackendInterface::setCapacityForBattery(const QString& batteryId, uint percent)
147
d->capacities.insert(batteryId, percent);
150
void BackendInterface::setRecallNotices(const QList< BackendInterface::RecallNotice >& notices)
152
d->recallNotices = notices;
155
void BackendInterface::onBrightnessChanged(BackendInterface::BrightnessControlType device, float brightness)
157
d->brightness[device] = brightness;
158
emit brightnessChanged(brightness, device);
161
void BackendInterface::setResumeFromSuspend()
163
emit resumeFromSuspend();
166
BackendInterface::Capabilities BackendInterface::capabilities() const
168
return d->capabilities;
171
void BackendInterface::setCapabilities(BackendInterface::Capabilities capabilities)
173
d->capabilities = capabilities;
178
#include "powerdevilbackendinterface.moc"