klaptopdaemon
laptop_daemon.h
Go to the documentation of this file.00001 #ifndef LAPTOPDAEMON
00002 #define LAPTOPDAEMON 1
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "daemon_state.h"
00027
00028 #include <QDir>
00029
00030 #include <QTimerEvent>
00031 #include <Q3CString>
00032 #include <unistd.h>
00033 #include <time.h>
00034 #include <qmovie.h>
00035 #include <q3ptrlist.h>
00036 #include <qfileinfo.h>
00037 #include <qimage.h>
00038
00039 #include <kiconloader.h>
00040 #include <kprocess.h>
00041
00042
00043
00044 #include <X11/Xlib.h>
00045 #include <X11/extensions/XTest.h>
00046
00047 #include <qsocketnotifier.h>
00048
00049
00050
00051 #include <kdebug.h>
00052 #include <qthread.h>
00053
00054 #include "kpcmcia.h"
00055
00056 #include "daemondock.h"
00057 #include "xautolock.h"
00058 #include <kdedmodule.h>
00059
00060
00061 class laptop_daemon;
00062 class XWidget;
00063
00064 class ButtonThread : public QThread {
00065 public:
00066 ButtonThread() { quitting = 0; }
00067 void sethandle(laptop_daemon *h) { handle = h; }
00068 void quit() { quitting = 1; }
00069 void done() { while (!finished()) msleep(100); quitting = 0; }
00070 virtual void run();
00071 private:
00072 bool quitting;
00073 laptop_daemon *handle;
00074 };
00075
00076 class laptop_dock;
00077 class laptop_daemon: public KDEDModule
00078 {
00079 Q_OBJECT
00080 K_DCOP
00081 public:
00082 laptop_daemon(QObject* parent, const QList<QVariant>&);
00083 ~laptop_daemon();
00084 void setPollInterval(const int poll=60);
00085 void SetBrightness(bool blank, int v);
00086 int GetBrightness() { return brightness; }
00087 void SetThrottle(QString v);
00088 void SetPerformance(QString v);
00089 void ButtonThreadInternals();
00090 k_dcop:
00091 void restart();
00092 void quit();
00093 signals:
00094 void signal_checkBattery();
00095 protected:
00096 void timerEvent(QTimerEvent *);
00097 protected slots:
00098 void checkBatteryNow();
00099 void timerDone();
00100 void dock_quit();
00101 void updatePCMCIA(int num);
00102 void sonyDataReceived();
00103 void BackoffRestart();
00104 void WakeCheck();
00105 private:
00106 void haveBatteryLow(int t, const int num, const int type);
00107 int calcBatteryTime(int percent, long time, bool restart);
00108 void start_monitor();
00109 void invokeStandby();
00110 void invokeSuspend();
00111 void invokeHibernate();
00112 void invokeShutdown();
00113 void invokeLogout();
00114 void displayPixmap();
00115 void setBlankSaver(bool);
00116
00117 laptop_dock *dock_widget;
00118
00119
00120 bool hasAudio;
00121
00122
00123
00124 public:
00125 int val;
00126 int powered;
00127 int left;
00128 bool x11Event(XEvent *event);
00129 bool exists() { return s.exists; }
00130 QString noBatteryIcon() { return s.noBatteryIcon; }
00131 QString chargeIcon() { return s.chargeIcon; }
00132 QString noChargeIcon() { return s.noChargeIcon; }
00133 protected:
00134 int triggered[2];
00135
00136 int oldval, oldexists, oldpowered, oldleft, knownFullyCharged;
00137
00138 int changed;
00139
00140 int oldTimer;
00141 bool timer;
00142
00143 int power_time;
00144
00145
00146 KPCMCIA *_pcmcia;
00147
00148
00149
00150 int sony_fd;
00151 Display *sony_disp;
00152 QSocketNotifier *sony_notifier;
00153
00154
00155
00156 int brightness;
00157
00158 bool lid_state;
00159 bool power_state;
00160 ButtonThread buttonThread;
00161
00162
00163
00164 XAutoLock autoLock;
00165 bool need_wait;
00166 bool saved_brightness, saved_throttle, saved_performance;
00167 int saved_brightness_val;
00168 QString saved_performance_val, saved_throttle_val;
00169 QTimer *wake_timer;
00170 QPoint wakepos;
00171 void WakeUpAuto();
00172 QTimer *backoffTimer;
00173
00174 bool power_button_off;
00175 bool button_bright_saved;
00176 int button_bright_val;
00177 bool button_saved_performance;
00178 QString button_saved_performance_val;
00179 bool button_saved_throttle;
00180 QString button_saved_throttle_val;
00181
00182 daemon_state s;
00183
00184 XWidget *xwidget;
00185 };
00186 #endif