1
/* This file is part of the KDE project
2
Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
3
Copyright (C) 2008-2010 Dario Freddi <drf@kde.org>
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 POWERDEVILHALBACKEND_H
22
#define POWERDEVILHALBACKEND_H
24
#include <powerdevilbackendinterface.h>
26
#include <QtDBus/QDBusConnection>
27
#include <QtDBus/QDBusInterface>
29
#include <kdemacros.h>
31
#include <solid/devicenotifier.h>
32
#include <solid/device.h>
33
#include <solid/button.h>
40
class KDE_EXPORT PowerDevilHALBackend : public PowerDevil::BackendInterface
43
Q_DISABLE_COPY(PowerDevilHALBackend)
45
explicit PowerDevilHALBackend(QObject* parent);
46
virtual ~PowerDevilHALBackend();
49
static bool isAvailable();
51
virtual float brightness(BrightnessControlType type = Screen) const;
53
virtual void brightnessKeyPressed(PowerDevil::BackendInterface::BrightnessKeyType type);
54
virtual bool setBrightness(float brightness, PowerDevil::BackendInterface::BrightnessControlType type = Screen);
55
virtual KJob* suspend(PowerDevil::BackendInterface::SuspendMethod method);
58
void computeAcAdapters();
59
void computeBatteries();
60
void computeButtons();
63
void updateBatteryStats();
64
void slotPlugStateChanged(bool newState);
65
void slotButtonPressed(Solid::Button::ButtonType type);
66
void slotDeviceAdded(const QString &udi);
67
void slotDeviceRemoved(const QString &udi);
68
void slotBatteryPropertyChanged(const QMap<QString,int> &changes);
71
QMap<QString, Solid::Device *> m_acAdapters;
72
QMap<QString, Solid::Device *> m_batteries;
73
QMap<QString, Solid::Device *> m_buttons;
75
int m_pluggedAdapterCount;
77
int m_currentBatteryCharge;
78
int m_maxBatteryCharge;
79
int m_warningBatteryCharge;
80
int m_lowBatteryCharge;
81
int m_criticalBatteryCharge;
82
int m_estimatedBatteryTime;
84
bool m_brightnessInHardware;
85
float m_cachedBrightness;
87
mutable QDBusInterface m_halComputer;
88
mutable QDBusInterface m_halPowerManagement;
89
mutable QDBusInterface m_halCpuFreq;
90
mutable QDBusInterface m_halManager;
93
#endif // POWERDEVILHALBACKEND_H