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
***************************************************************************/
21
#ifndef POWERDEVILCORE_H
22
#define POWERDEVILCORE_H
24
#include "powerdevilbackendinterface.h"
26
#include <QtCore/QWeakPointer>
27
#include <QtCore/QStringList>
29
#include <KComponentData>
31
typedef QMap< QString, QString > StringStringMap;
43
class BackendInterface;
46
class KDE_EXPORT Core : public QObject
50
Q_CLASSINFO("D-Bus Interface", "org.kde.Solid.PowerManagement")
53
explicit Core(QObject* parent, const KComponentData &componentData);
56
void reloadProfile(int state);
58
void emitNotification(const QString &evid, const QString &message = QString(),
59
const QString &iconname = "dialog-ok-apply");
61
BackendInterface *backend();
66
void loadCore(PowerDevil::BackendInterface *backend);
67
// Set of common action - useful for the DBus interface
68
uint backendCapabilities();
71
void reloadCurrentProfile();
72
void reparseConfiguration();
74
StringStringMap availableProfiles() const;
76
void loadProfile(const QString &name);
77
QString currentProfile() const;
79
int brightness() const;
80
void setBrightness(int percent);
82
qulonglong batteryRemainingTime() const;
84
void increaseBrightness();
85
void decreaseBrightness();
91
void onResumeFromSuspend();
95
void profileChanged(const QString &newProfile);
96
void configurationReloaded();
97
void brightnessChanged(int percent);
98
void batteryRemainingTimeChanged(qulonglong time);
99
void resumingFromSuspend();
102
void registerActionTimeout(Action *action, int timeout);
103
void unregisterActionTimeouts(Action *action);
105
void triggerSuspendSession(uint action);
109
BackendInterface *m_backend;
110
QStringList m_loadedBatteriesUdi;
112
QWeakPointer< KNotification > notification;
113
KComponentData m_applicationData;
114
KSharedConfigPtr m_profilesConfig;
116
QString m_currentProfile;
118
QHash< QString, int > m_batteriesPercent;
120
QTimer *m_criticalBatteryTimer;
122
// Idle time management
123
QHash< int, int > m_registeredIdleTimeouts;
124
QHash< Action*, QList< int > > m_registeredActionTimeouts;
125
QList< Action* > m_pendingResumeFromIdleActions;
128
void onBackendReady();
129
void onBackendError(const QString &error);
130
void onAcAdapterStateChanged(PowerDevil::BackendInterface::AcAdapterState);
131
void onBatteryChargePercentChanged(int,const QString&);
132
void onBrightnessChanged(float);
133
void onBatteryRemainingTimeChanged(qulonglong);
134
void onKIdleTimeoutReached(int,int);
135
void onResumingFromIdle();
136
void onDeviceAdded(const QString &udi);
137
void onDeviceRemoved(const QString &udi);
138
void onCriticalBatteryTimerExpired();
139
void checkBatteryStatus();
140
void powerOffButtonTriggered();
145
Q_DECLARE_METATYPE(StringStringMap)
147
#endif // POWERDEVILCORE_H