~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to powerdevil/daemon/backends/hal/powerdevilhalbackend.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

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 Kevin Ottens <ervin@kde.org>
 
3
    Copyright (C) 2008-2010 Dario Freddi <drf@kde.org>
 
4
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
 
 
19
*/
 
20
 
 
21
#ifndef POWERDEVILHALBACKEND_H
 
22
#define POWERDEVILHALBACKEND_H
 
23
 
 
24
#include <powerdevilbackendinterface.h>
 
25
 
 
26
#include <QtDBus/QDBusConnection>
 
27
#include <QtDBus/QDBusInterface>
 
28
 
 
29
#include <kdemacros.h>
 
30
 
 
31
#include <solid/devicenotifier.h>
 
32
#include <solid/device.h>
 
33
#include <solid/button.h>
 
34
 
 
35
namespace Solid {
 
36
class Device;
 
37
}
 
38
 
 
39
 
 
40
class KDE_EXPORT PowerDevilHALBackend : public PowerDevil::BackendInterface
 
41
{
 
42
    Q_OBJECT
 
43
    Q_DISABLE_COPY(PowerDevilHALBackend)
 
44
public:
 
45
    explicit PowerDevilHALBackend(QObject* parent);
 
46
    virtual ~PowerDevilHALBackend();
 
47
 
 
48
    virtual void init();
 
49
    static bool isAvailable();
 
50
 
 
51
    virtual float brightness(BrightnessControlType type = Screen) const;
 
52
 
 
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);
 
56
 
 
57
private:
 
58
    void computeAcAdapters();
 
59
    void computeBatteries();
 
60
    void computeButtons();
 
61
 
 
62
private slots:
 
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);
 
69
 
 
70
private:
 
71
    QMap<QString, Solid::Device *> m_acAdapters;
 
72
    QMap<QString, Solid::Device *> m_batteries;
 
73
    QMap<QString, Solid::Device *> m_buttons;
 
74
 
 
75
    int m_pluggedAdapterCount;
 
76
 
 
77
    int m_currentBatteryCharge;
 
78
    int m_maxBatteryCharge;
 
79
    int m_warningBatteryCharge;
 
80
    int m_lowBatteryCharge;
 
81
    int m_criticalBatteryCharge;
 
82
    int m_estimatedBatteryTime;
 
83
 
 
84
    bool m_brightnessInHardware;
 
85
    float m_cachedBrightness;
 
86
 
 
87
    mutable QDBusInterface m_halComputer;
 
88
    mutable QDBusInterface m_halPowerManagement;
 
89
    mutable QDBusInterface m_halCpuFreq;
 
90
    mutable QDBusInterface m_halManager;
 
91
};
 
92
 
 
93
#endif // POWERDEVILHALBACKEND_H