dtor first
[personal-kdebase.git] / workspace / powerdevil / daemon / PowerDevilDaemon.h
blob75a45ca2a36aa2308b7afbef3055e9d6fae324d3
1 /***************************************************************************
2 * Copyright (C) 2008 by Dario Freddi <drf@kdemod.ath.cx> *
3 * *
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. *
8 * *
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. *
13 * *
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 #ifndef POWERDEVILDAEMON_H
21 #define POWERDEVILDAEMON_H
23 #include <kdedmodule.h>
24 #include <solid/control/powermanager.h>
25 #include <solid/battery.h>
26 #include <KComponentData>
27 #include <QStringList>
28 #include <QPointer>
30 #include "AbstractSystemPoller.h"
32 class QWidget;
33 class QTimer;
34 class PollSystemLoader;
35 class SuspensionLockHandler;
36 class KNotification;
37 class OrgFreedesktopScreenSaverInterface;
38 class OrgKdeKSMServerInterfaceInterface;
39 class OrgKdeScreensaverInterface;
41 class KDE_EXPORT PowerDevilDaemon : public KDEDModule
43 Q_OBJECT
44 Q_CLASSINFO("D-Bus Interface", "org.kde.PowerDevil")
46 public:
47 PowerDevilDaemon(QObject *parent, const QList<QVariant>&);
48 virtual ~PowerDevilDaemon();
50 public Q_SLOTS:
51 void refreshStatus();
52 void emitWarningNotification(const QString &evid, const QString &message = QString(),
53 const char *slot = 0, const QString &iconname = "dialog-warning");
54 void emitNotification(const QString &evid, const QString &message = QString(),
55 const char *slot = 0, const QString &iconname = "dialog-ok-apply");
56 void setProfile(const QString & profile);
57 void reloadAndStream();
58 void streamData();
60 void setGovernor(int governor);
61 void suspend(int method);
62 void setPowersavingScheme(const QString &scheme);
63 void setBrightness(int value);
64 void turnOffScreen();
66 void setUpPollingSystem();
68 void unloadDaemon() {
69 deleteLater();
72 QVariantMap getSupportedGovernors();
73 QStringList getSupportedSchemes();
74 QVariantMap getSupportedSuspendMethods();
75 QVariantMap getSupportedPollingSystems();
77 SuspensionLockHandler *lockHandler();
79 private Q_SLOTS:
80 void acAdapterStateChanged(int state, bool forced = false);
81 void batteryChargePercentChanged(int percent, const QString &udi);
83 void decreaseBrightness();
84 void increaseBrightness();
86 void shutdown(bool automated = false);
87 void shutdownDialog();
88 void suspendJobResult(KJob * job);
89 void suspendToDisk(bool automated = false);
90 void suspendToRam(bool automated = false);
91 void standby(bool automated = false);
93 void shutdownNotification(bool automated = false);
94 void suspendToDiskNotification(bool automated = false);
95 void suspendToRamNotification(bool automated = false);
96 void standbyNotification(bool automated = false);
98 void buttonPressed(int but);
100 void poll(int idle);
101 void resumeFromIdle();
103 void reloadProfile(int state = -1);
104 QString profile() const;
106 void setBatteryPercent(int newpercent);
107 void setACPlugged(bool newplugged);
108 void setCurrentProfile(const QString &profile);
109 void setAvailableProfiles(const QStringList &aProfiles);
111 bool toggleCompositing(bool enabled);
113 void cleanUpTimer();
115 void setUpDPMS();
117 void emitCriticalNotification(const QString &evid, const QString &message = QString(),
118 const char *slot = 0, const QString &iconname = "dialog-error");
120 void batteryRemainingTimeChanged(int time);
122 Q_SIGNALS:
123 void lidClosed(int code, const QString &action);
124 void errorTriggered(const QString &error);
126 void stateChanged(int, bool);
127 void profileChanged(const QString &, const QStringList &);
129 private:
130 void lockScreen();
132 KConfigGroup *getCurrentProfile(bool forcereload = false);
133 void applyProfile();
135 void setUpNextTimeout(int idle, int minDimEvent);
137 void profileFirstLoad();
139 void restoreDefaultProfiles();
141 bool loadPollingSystem(AbstractSystemPoller::PollingType type);
143 bool recacheBatteryPointer(bool force = false);
145 public:
146 enum IdleAction {
147 None = 0,
148 Standby = 1,
149 S2Ram = 2,
150 S2Disk = 4,
151 Shutdown = 8,
152 Lock = 16,
153 ShutdownDialog = 32
156 enum IdleStatus {
157 NoAction = 0,
158 Action = 1,
159 DimHalf = 2,
160 DimThreeQuarters = 4,
161 DimTotal = 8
164 private:
165 class Private;
166 Private *d;
169 #endif /*POWERDEVILDAEMON_H*/