kalarm Library API Documentation

kalarmapp.h

00001 /*
00002  *  kalarmapp.h  -  the KAlarm application object
00003  *  Program:  kalarm
00004  *  (C) 2001, 2002 by David Jarvie  software@astrojar.org.uk
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #ifndef KALARMAPP_H
00022 #define KALARMAPP_H
00023 
00024 class QDateTime;
00025 
00026 #include <kuniqueapp.h>
00027 #include <kurl.h>
00028 class KAction;
00029 
00030 #include "msgevent.h"
00031 class AlarmCalendar;
00032 class KAlarmMainWindow;
00033 class MessageWin;
00034 class TrayWindow;
00035 class DaemonGuiHandler;
00036 class Settings;
00037 class ActionAlarmsEnabled;
00038 
00039 extern const char* DAEMON_APP_NAME;
00040 extern const char* DAEMON_DCOP_OBJECT;
00041 extern const char* GUI_DCOP_OBJECT_NAME;
00042 
00043 
00044 class DcopHandler : public QWidget, DCOPObject
00045 {
00046                 Q_OBJECT
00047         public:
00048                 DcopHandler(const char* name);
00049                 ~DcopHandler()  { }
00050                 virtual bool process(const QCString& func, const QByteArray& data, QCString& replyType, QByteArray& replyData);
00051 };
00052 
00053 
00054 class KAlarmApp : public KUniqueApplication
00055 {
00056                 Q_OBJECT
00057         public:
00058                 ~KAlarmApp();
00059                 virtual int       newInstance();
00060                 static KAlarmApp* getInstance();
00061                 AlarmCalendar&    getCalendar()                   { return *mCalendar; }
00062                 void              checkCalendar()                 { initCheck(); }
00063                 Settings*         settings()                      { return mSettings; }
00064                 bool              KDEDesktop() const              { return mKDEDesktop; }
00065                 bool              runInSystemTray() const;
00066                 bool              restoreSession();
00067                 bool              sessionClosingDown() const      { return mSessionClosingDown; }
00068                 void              quitIf()                        { quitIf(0); }
00069                 void              addWindow(TrayWindow* w)        { mTrayWindow = w; }
00070                 void              removeWindow(TrayWindow*);
00071                 TrayWindow*       trayWindow() const              { return mTrayWindow; }
00072                 KAlarmMainWindow* trayMainWindow() const;
00073                 bool              displayTrayIcon(bool show, KAlarmMainWindow* = 0L);
00074                 bool              trayIconDisplayed() const       { return !!mTrayWindow; }
00075                 DaemonGuiHandler* daemonGuiHandler() const        { return mDaemonGuiHandler; }
00076                 ActionAlarmsEnabled* actionAlarmEnable() const    { return mActionAlarmEnable; }
00077                 KAction*          actionPreferences() const       { return mActionPrefs; }
00078                 KAction*          actionDaemonControl() const     { return mActionDaemonControl; }
00079                 void              resetDaemon();
00080                 bool              isDaemonRunning();
00081                 void              readDaemonCheckInterval();
00082                 QSize             readConfigWindowSize(const char* window, const QSize& defaultSize);
00083                 void              writeConfigWindowSize(const char* window, const QSize&);
00084                 virtual void      commitData(QSessionManager&);
00085 
00086                 bool              addEvent(const KAlarmEvent&, KAlarmMainWindow*);
00087                 void              modifyEvent(const QString& oldEventID, const KAlarmEvent& newEvent, KAlarmMainWindow*);
00088                 void              updateEvent(const KAlarmEvent&, KAlarmMainWindow*);
00089                 void              deleteEvent(KAlarmEvent&, KAlarmMainWindow*, bool tellDaemon = true);
00090                 bool              execAlarm(KAlarmEvent&, const KAlarmAlarm&, bool reschedule, bool allowDefer = true);
00091                 void              rescheduleAlarm(KAlarmEvent&, int alarmID);
00092                 void              deleteEvent(const QString& eventID)         { handleEvent(eventID, EVENT_CANCEL); }
00093                 int               maxLateness();
00094                 // Methods called indirectly by the DCOP interface
00095                 bool              scheduleEvent(const QString& text, const QDateTime&, const QColor& bg, int flags,
00096                                                 const QString& audioFile, KAlarmAlarm::Type, KAlarmEvent::RecurType,
00097                                                 int repeatInterval, int repeatCount, const QDateTime& endTime);
00098                 void              handleEvent(const QString& calendarFile, const QString& eventID)    { handleEvent(calendarFile, eventID, EVENT_HANDLE); }
00099                 void              triggerEvent(const QString& calendarFile, const QString& eventID)   { handleEvent(calendarFile, eventID, EVENT_TRIGGER); }
00100                 void              deleteEvent(const QString& calendarFile, const QString& eventID)    { handleEvent(calendarFile, eventID, EVENT_CANCEL); }
00101 
00102                 static int        isTextFile(const KURL&);
00103         public slots:
00104                 void              displayMainWindow();
00105                 void              slotDaemonControl();
00106         signals:
00107                 void              trayIconToggled();
00108         protected:
00109                 KAlarmApp();
00110         private slots:
00111                 void              slotPreferences();
00112                 void              toggleAlarmsEnabled();
00113                 void              slotSettingsChanged();
00114         private:
00115                 enum EventFunc { EVENT_HANDLE, EVENT_TRIGGER, EVENT_CANCEL };
00116                 enum AlarmFunc { ALARM_TRIGGER, ALARM_CANCEL, ALARM_RESCHEDULE };
00117                 bool              initCheck(bool calendarOnly = false);
00118                 void              quitIf(int exitCode);
00119                 void              changeStartOfDay();
00120                 void              setUpDcop();
00121                 bool              stopDaemon();
00122                 void              startDaemon();
00123                 void              reloadDaemon();
00124                 void              registerWithDaemon(bool reregister);
00125                 void              handleEvent(const QString& calendarFile, const QString& eventID, EventFunc);
00126                 bool              handleEvent(const QString& eventID, EventFunc);
00127                 void              handleAlarm(KAlarmEvent&, KAlarmAlarm&, AlarmFunc, bool updateCalAndDisplay);
00128 
00129                 static KAlarmApp*     theInstance;         // the one and only KAlarmApp instance
00130                 static int            activeCount;         // number of active instances without main windows
00131                 DcopHandler*          mDcopHandler;        // the parent of the main DCOP receiver object
00132                 DaemonGuiHandler*     mDaemonGuiHandler;   // the parent of the system tray DCOP receiver object
00133                 TrayWindow*           mTrayWindow;         // active system tray icon
00134                 AlarmCalendar*        mCalendar;           // the calendar containing all the alarms
00135                 ActionAlarmsEnabled*  mActionAlarmEnable;  // action to enable/disable alarms
00136                 KAction*              mActionPrefs;        // action to display the preferences dialog
00137                 KAction*              mActionDaemonControl;// action to display the alarm daemon control dialog
00138                 Settings*             mSettings;           // program preferences
00139                 QDateTime             mLastDaemonCheck;    // last time daemon checked alarms before check interval change
00140                 QDateTime             mNextDaemonCheck;    // next time daemon will check alarms after check interval change
00141                 QTime                 mStartOfDay;         // start-of-day time currently in use
00142                 int                   mDaemonCheckInterval;// daemon check interval (seconds)
00143                 bool                  mDaemonRegistered;   // true if we've registered with alarm daemon
00144                 bool                  mKDEDesktop;         // running on KDE desktop
00145                 bool                  mDaemonRunning;      // whether the alarm daemon is currently running
00146                 bool                  mSessionClosingDown; // session manager is closing the application
00147                 bool                  mOldRunInSystemTray; // running continuously in system tray was selected
00148                 bool                  mDisableAlarmsIfStopped; // disable alarms whenever KAlarm is not running
00149 };
00150 
00151 inline KAlarmApp* theApp()  { return KAlarmApp::getInstance(); }
00152 
00153 #endif // KALARMAPP_H
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:26 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001