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