kalarm
daemon.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef DAEMON_H
00022 #define DAEMON_H
00023
00024 #include <qobject.h>
00025 #include <qdatetime.h>
00026 #include <kaction.h>
00027
00028 #include <kalarmd/kalarmd.h>
00029 #include <kalarmd/alarmguiiface.h>
00030
00031 class KActionCollection;
00032 class AlarmCalendar;
00033 class AlarmEnableAction;
00034 class NotificationHandler;
00035
00036
00037 class Daemon : public QObject
00038 {
00039 Q_OBJECT
00040 public:
00041 static void initialise();
00042 static void createDcopHandler();
00043 static bool isDcopHandlerReady() { return mDcopHandler; }
00044 static AlarmEnableAction* createAlarmEnableAction(KActionCollection*, const char* name);
00045 static bool start();
00046 static bool reregister() { return registerWith(true); }
00047 static bool reset();
00048 static bool stop();
00049 static bool autoStart(bool defaultSetting);
00050 static void enableAutoStart(bool enable);
00051 static void setAlarmsEnabled() { mInstance->setAlarmsEnabled(true); }
00052 static void checkStatus() { checkIfRunning(); }
00053 static bool monitoringAlarms();
00054 static bool isRunning(bool startDaemon = true);
00055 static int maxTimeSinceCheck();
00056 static bool isRegistered() { return mStatus == REGISTERED; }
00057 static void allowRegisterFailMsg() { mRegisterFailMsg = false; }
00058
00059 signals:
00060 void daemonRunning(bool running);
00061
00062 private slots:
00063 void slotCalendarSaved(AlarmCalendar*);
00064 void checkIfStarted();
00065 void slotStarted() { updateRegisteredStatus(true); }
00066 void registerTimerExpired() { registrationResult((mStatus == REGISTERED), KAlarmd::FAILURE); }
00067
00068 void setAlarmsEnabled(bool enable);
00069 void timerCheckIfRunning();
00070 void slotPreferencesChanged();
00071
00072 private:
00073 enum Status
00074 {
00075 STOPPED,
00076 RUNNING,
00077 READY,
00078 REGISTERED
00079 };
00080 Daemon() { }
00081 static bool registerWith(bool reregister);
00082 static void registrationResult(bool reregister, int result);
00083 static void reload();
00084 static void updateRegisteredStatus(bool timeout = false);
00085 static void enableCalendar(bool enable);
00086 static void calendarIsEnabled(bool enabled);
00087 static bool checkIfRunning();
00088 static void setFastCheck();
00089
00090 static Daemon* mInstance;
00091 static NotificationHandler* mDcopHandler;
00092 static QTimer* mStartTimer;
00093 static QTimer* mRegisterTimer;
00094 static QTimer* mStatusTimer;
00095 static int mStatusTimerCount;
00096 static int mStatusTimerInterval;
00097 static int mStartTimeout;
00098 static Status mStatus;
00099 static bool mRunning;
00100 static bool mCalendarDisabled;
00101 static bool mEnableCalPending;
00102 static bool mRegisterFailMsg;
00103
00104 friend class NotificationHandler;
00105 };
00106
00107
00108
00109
00110
00111 class AlarmEnableAction : public KToggleAction
00112 {
00113 Q_OBJECT
00114 public:
00115 AlarmEnableAction(int accel, QObject* parent, const char* name = 0);
00116 public slots:
00117 void setCheckedActual(bool);
00118 virtual void setChecked(bool);
00119 signals:
00120 void switched(bool);
00121 void userClicked(bool);
00122 private:
00123 bool mInitialised;
00124 };
00125
00126 #endif // DAEMON_H
|