karm

idletimedetector.h
1 #ifndef KARM_IDLE_TIME_DETECTOR_H
2 #define KARM_IDLE_TIME_DETECTOR_H
3 
4 #include <tqobject.h>
5 #include "config.h" // HAVE_LIBXSS
6 #include <tqdatetime.h>
7 #include <kdebug.h>
8 
9 class TQTimer;
10 
11 #ifdef HAVE_LIBXSS
12  #include <X11/Xlib.h>
13  #include <X11/Xutil.h>
14  #include <X11/extensions/scrnsaver.h>
15  #include <fixx11h.h>
16 #endif // HAVE_LIBXSS
17 
18 // Seconds per minutes - useful for speeding debugging up!
19 const int secsPerMinute = 60;
20 
21 // Minutes between each idle overrun test.
22 const int testInterval= secsPerMinute * 1000;
23 
28 class IdleTimeDetector :public TQObject
29 {
30 Q_OBJECT
31  TQ_OBJECT
32 
33 public:
38  IdleTimeDetector(int maxIdle);
39 
46 
47 signals:
54  void extractTime(int minutes);
55 
57  void stopAllTimers();
58 
60  void stopAllTimersAt(TQDateTime qdt);
61 
62 public slots:
67  void setMaxIdle(int maxIdle);
68 
72  void startIdleDetection();
73 
77  void stopIdleDetection();
78 
84  void toggleOverAllIdleDetection(bool on);
85 
86 
87 protected:
88 #ifdef HAVE_LIBXSS
89  void informOverrun(int idle);
90 #endif // HAVE_LIBXSS
91 
92 protected slots:
93  void check();
94 
95 private:
96 #ifdef HAVE_LIBXSS
97  XScreenSaverInfo *_mit_info;
98 #endif
99  bool _idleDetectionPossible;
100  bool _overAllIdleDetect; // Based on preferences.
101  int _maxIdle;
102  TQTimer *_timer;
103 };
104 
105 #endif // KARM_IDLE_TIME_DETECTOR_H