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