karm

idletimedetector.h

00001 #ifndef KARM_IDLE_TIME_DETECTOR_H
00002 #define KARM_IDLE_TIME_DETECTOR_H
00003 
00004 #include <tqobject.h>
00005 #include "config.h"     // HAVE_LIBXSS
00006 #include <tqdatetime.h>
00007 #include <kdebug.h>
00008 
00009 class TQTimer;
00010 
00011 #ifdef HAVE_LIBXSS
00012  #include <X11/Xlib.h>
00013  #include <X11/Xutil.h>
00014  #include <X11/extensions/scrnsaver.h>
00015  #include <fixx11h.h>
00016 #endif // HAVE_LIBXSS
00017 
00018 // Seconds per minutes - useful for speeding debugging up!
00019 const int secsPerMinute = 60;
00020 
00021 // Minutes between each idle overrun test.
00022 const int testInterval= secsPerMinute * 1000;
00023 
00028 class IdleTimeDetector :public TQObject
00029 {
00030 Q_OBJECT
00031   
00032 
00033 public:
00038   IdleTimeDetector(int maxIdle);
00039 
00045   bool isIdleDetectionPossible();
00046 
00047 signals:
00054   void extractTime(int minutes);
00055 
00057   void stopAllTimers();
00058 
00060   void stopAllTimersAt(TQDateTime qdt);
00061 
00062 public slots:
00067   void setMaxIdle(int maxIdle);
00068 
00072   void startIdleDetection();
00073 
00077   void stopIdleDetection();
00078 
00084   void toggleOverAllIdleDetection(bool on);
00085 
00086 
00087 protected:
00088 #ifdef HAVE_LIBXSS
00089   void informOverrun(int idle);
00090 #endif // HAVE_LIBXSS
00091 
00092 protected slots:
00093   void check();
00094 
00095 private:
00096 #ifdef HAVE_LIBXSS
00097   XScreenSaverInfo *_mit_info;
00098 #endif
00099   bool _idleDetectionPossible;
00100   bool _overAllIdleDetect; // Based on preferences.
00101   int _maxIdle;
00102   TQTimer *_timer;
00103 };
00104 
00105 #endif // KARM_IDLE_TIME_DETECTOR_H