• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdeutils
  • Sitemap
  • Contact Us
 

klaptopdaemon

laptop_daemon.h

Go to the documentation of this file.
00001 #ifndef LAPTOPDAEMON
00002 #define LAPTOPDAEMON 1
00003 /*
00004  * laptop_daemon.h
00005  * Copyright (C) 1999 Paul Campbell <paul@taniwha.com>
00006  *
00007  * This file contains the implementation of the main laptop battery monitoring daemon
00008  *
00009  * $Id: laptop_daemon.h 733093 2007-11-05 14:20:18Z dfaure $
00010  *
00011  *  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version.
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public License
00022  *  along with this program; if not, write to the Free Software
00023  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  */
00025 
00026 #include "daemon_state.h"
00027 
00028 #include <QDir>
00029 //Added by qt3to4:
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 //#include <kaudio.h>
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; }               // make it quit
00069     void done() { while (!finished()) msleep(100); quitting = 0; }// wait 'till it's done
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);   // routine to do it
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     // Capability
00120     bool    hasAudio;
00121     //KAudio  audioServer;
00122 
00123     // General settings
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;      // autolock timer is active
00142 
00143     int power_time;
00144 
00145         // PCMCIA related
00146         KPCMCIA *_pcmcia;
00147 
00148     // sony jog-bar support
00149 
00150     int  sony_fd;           // file desc form open /dev/sonypi
00151     Display *sony_disp;     // X display
00152     QSocketNotifier *sony_notifier; // how we know data is waiting
00153 
00154     // brightness
00155 
00156     int  brightness;        // actual brightness, -1 if not known
00157 
00158     bool lid_state;
00159     bool power_state;
00160     ButtonThread    buttonThread;
00161 
00162 
00163     //
00164     XAutoLock   autoLock;       // timer/UI maint
00165     bool    need_wait;          // undo sleep stuff
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;        // the timer for the above running
00170     QPoint  wakepos;        // the mouse pos at the beginning of time
00171     void    WakeUpAuto();
00172     QTimer  *backoffTimer;      // backoff
00173 
00174     bool    power_button_off;           // imagined state of the power button
00175     bool    button_bright_saved;            // saved button state
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;          // saved daemon state from config file
00183 
00184     XWidget     *xwidget;
00185 };
00186 #endif

klaptopdaemon

Skip menu "klaptopdaemon"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdelirc
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • kjots
  • klaptopdaemon
  • kmilo
  • ksim
  • ktimer
  • kwallet
  • superkaramba
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal