00001
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 <tqobject.h>
00025 #include <tqdatetime.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 TQObject
00038 {
00039 Q_OBJECT
00040 TQ_OBJECT
00041 public:
00042 static void initialise();
00043 static void createDcopHandler();
00044 static bool isDcopHandlerReady() { return mDcopHandler; }
00045 static AlarmEnableAction* createAlarmEnableAction(KActionCollection*, const char* name);
00046 static bool start();
00047 static bool reregister() { return registerWith(true); }
00048 static bool reset();
00049 static bool stop();
00050 static bool autoStart();
00051 static void enableAutoStart(bool enable);
00052 static void notifyTimeChanged();
00053 static void setAlarmsEnabled() { mInstance->setAlarmsEnabled(true); }
00054 static void checkStatus() { checkIfRunning(); }
00055 static bool monitoringAlarms();
00056 static bool isRunning(bool startDaemon = true);
00057 static int maxTimeSinceCheck();
00058 static bool isRegistered() { return mStatus == REGISTERED; }
00059 static void allowRegisterFailMsg() { mRegisterFailMsg = false; }
00060
00061 static void queueEvent(const TQString& eventID);
00062 static void savingEvent(const TQString& eventID);
00063 static void eventHandled(const TQString& eventID, bool reloadCal);
00064
00065 signals:
00066 void daemonRunning(bool running);
00067
00068 private slots:
00069 void slotCalendarSaved(AlarmCalendar*);
00070 void checkIfStarted();
00071 void slotStarted() { updateRegisteredStatus(true); }
00072 void registerTimerExpired() { registrationResult((mStatus == REGISTERED), KAlarmd::FAILURE); }
00073
00074 void setAlarmsEnabled(bool enable);
00075 void timerCheckIfRunning();
00076 void slotPreferencesChanged();
00077
00078 private:
00079 enum Status
00080 {
00081 STOPPED,
00082 RUNNING,
00083 READY,
00084 REGISTERED
00085 };
00086 Daemon() { }
00087 static bool registerWith(bool reregister);
00088 static void registrationResult(bool reregister, int result, int version = 0);
00089 static void reload();
00090 static void notifyEventHandled(const TQString& eventID, bool reloadCal);
00091 static void updateRegisteredStatus(bool timeout = false);
00092 static void enableCalendar(bool enable);
00093 static void calendarIsEnabled(bool enabled);
00094 static bool checkIfRunning();
00095 static void setFastCheck();
00096
00097 static Daemon* mInstance;
00098 static NotificationHandler* mDcopHandler;
00099 static TQValueList<TQString> mQueuedEvents;
00100 static TQValueList<TQString> mSavingEvents;
00101 static TQTimer* mStartTimer;
00102 static TQTimer* mRegisterTimer;
00103 static TQTimer* mStatusTimer;
00104 static int mStatusTimerCount;
00105 static int mStatusTimerInterval;
00106 static int mStartTimeout;
00107 static Status mStatus;
00108 static bool mRunning;
00109 static bool mCalendarDisabled;
00110 static bool mEnableCalPending;
00111 static bool mRegisterFailMsg;
00112
00113 friend class NotificationHandler;
00114 };
00115
00116
00117
00118
00119
00120 class AlarmEnableAction : public KToggleAction
00121 {
00122 Q_OBJECT
00123 TQ_OBJECT
00124 public:
00125 AlarmEnableAction(int accel, TQObject* parent, const char* name = 0);
00126 public slots:
00127 void setCheckedActual(bool);
00128 virtual void setChecked(bool);
00129 signals:
00130 void switched(bool);
00131 void userClicked(bool);
00132 private:
00133 bool mInitialised;
00134 };
00135
00136 #endif // DAEMON_H