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.
24 #include <QtDBus/QDBusConnection>
25 #include <QtDBus/QDBusInterface>
27 #include <kdemacros.h>
29 #include <solid/devicenotifier.h>
30 #include <solid/device.h>
31 #include <solid/button.h>
33 #include <solid/control/ifaces/powermanager.h>
35 class KDE_EXPORT HalPower
: public Solid::Control::Ifaces::PowerManager
40 HalPower(QObject
*parent
, const QStringList
&args
);
43 virtual QStringList
supportedSchemes() const;
44 virtual QString
schemeDescription(const QString
&schemeName
) const;
45 virtual QString
scheme() const;
46 virtual bool setScheme(const QString
&name
);
48 virtual Solid::Control::PowerManager::BatteryState
batteryState() const;
49 virtual int batteryChargePercent() const;
50 virtual int batteryRemainingTime() const;
51 virtual Solid::Control::PowerManager::AcAdapterState
acAdapterState() const;
53 virtual Solid::Control::PowerManager::SuspendMethods
supportedSuspendMethods() const;
54 virtual KJob
*suspend(Solid::Control::PowerManager::SuspendMethod method
) const;
56 virtual Solid::Control::PowerManager::CpuFreqPolicies
supportedCpuFreqPolicies() const;
57 virtual Solid::Control::PowerManager::CpuFreqPolicy
cpuFreqPolicy() const;
58 virtual bool setCpuFreqPolicy(Solid::Control::PowerManager::CpuFreqPolicy newPolicy
);
59 virtual bool canDisableCpu(int cpuNum
) const;
60 virtual bool setCpuEnabled(int cpuNum
, bool enabled
);
62 virtual Solid::Control::PowerManager::BrightnessControlsList
brightnessControlsAvailable();
63 virtual float brightness(const QString
&device
);
64 virtual bool setBrightness(float brightness
, const QString
&device
);
67 void computeAcAdapters();
68 void computeBatteries();
69 void computeButtons();
72 void updateBatteryStats();
73 void slotPlugStateChanged(bool newState
);
74 void slotButtonPressed(Solid::Button::ButtonType type
);
75 void slotDeviceAdded(const QString
&udi
);
76 void slotDeviceRemoved(const QString
&udi
);
77 void slotBatteryPropertyChanged(const QMap
<QString
,int> &changes
);
80 QMap
<QString
, Solid::Device
*> m_acAdapters
;
81 QMap
<QString
, Solid::Device
*> m_batteries
;
82 QMap
<QString
, Solid::Device
*> m_buttons
;
84 int m_pluggedAdapterCount
;
86 int m_currentBatteryCharge
;
87 int m_maxBatteryCharge
;
88 int m_warningBatteryCharge
;
89 int m_lowBatteryCharge
;
90 int m_criticalBatteryCharge
;
91 int m_estimatedBatteryTime
;
93 mutable QDBusInterface m_halComputer
;
94 mutable QDBusInterface m_halPowerManagement
;
95 mutable QDBusInterface m_halCpuFreq
;
96 mutable QDBusInterface m_halManager
;