• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kalarm

kalarmapp.h

Go to the documentation of this file.
00001 /*
00002  *  kalarmapp.h  -  the KAlarm application object
00003  *  Program:  kalarm
00004  *  Copyright © 2001-2008 by David Jarvie <djarvie@kde.org>
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 along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef KALARMAPP_H
00022 #define KALARMAPP_H
00023 
00026 #include <QPointer>
00027 #include <QQueue>
00028 #include <QList>
00029 class KDateTime;
00030 
00031 #include <kuniqueapplication.h>
00032 #include <kurl.h>
00033 namespace KCal { class Event; }
00034 
00035 #include "alarmevent.h"
00036 #include "kamail.h"
00037 class DBusHandler;
00038 class MainWindow;
00039 class TrayWindow;
00040 class ShellProcess;
00041 
00042 
00043 class KAlarmApp : public KUniqueApplication
00044 {
00045         Q_OBJECT
00046     public:
00047         ~KAlarmApp();
00048         virtual int        newInstance();
00049         static KAlarmApp*  getInstance();
00050         bool               checkCalendar()                 { return initCheck(); }
00051         bool               wantShowInSystemTray() const;
00052         bool               alarmsEnabled() const           { return mAlarmsEnabled; }
00053         bool               speechEnabled() const           { return mSpeechEnabled; }
00054         bool               korganizerEnabled() const       { return mKOrganizerEnabled; }
00055         bool               restoreSession();
00056         bool               sessionClosingDown() const      { return mSessionClosingDown; }
00057         void               quitIf()                        { quitIf(0); }
00058         void               doQuit(QWidget* parent);
00059         static void        displayFatalError(const QString& message);
00060         void               addWindow(TrayWindow* w)        { mTrayWindow = w; }
00061         void               removeWindow(TrayWindow*);
00062         TrayWindow*        trayWindow() const              { return mTrayWindow; }
00063         MainWindow*        trayMainWindow() const;
00064         bool               displayTrayIcon(bool show, MainWindow* = 0);
00065         bool               trayIconDisplayed() const       { return mTrayWindow; }
00066         bool               editNewAlarm(MainWindow* = 0);
00067         virtual void       commitData(QSessionManager&);
00068 
00069         void*              execAlarm(KAEvent&, const KAAlarm&, bool reschedule, bool allowDefer = true, bool noPreAction = false);
00070         ShellProcess*      execCommandAlarm(const KAEvent&, const KAAlarm&, const QObject* receiver = 0, const char* slot = 0);
00071         void               alarmCompleted(const KAEvent&);
00072         void               rescheduleAlarm(KAEvent& e, const KAAlarm& a)   { rescheduleAlarm(e, a, true); }
00073         bool               deleteEvent(const QString& eventID)         { return handleEvent(eventID, EVENT_CANCEL); }
00074         void               purgeAll()             { purge(0); }
00075         void               commandMessage(ShellProcess*, QWidget* parent);
00076         // Methods called indirectly by the DCOP interface
00077         bool               scheduleEvent(KAEvent::Action, const QString& text, const KDateTime&,
00078                                          int lateCancel, int flags, const QColor& bg, const QColor& fg,
00079                                          const QFont&, const QString& audioFile, float audioVolume,
00080                                          int reminderMinutes, const KARecurrence& recurrence,
00081                          int repeatInterval, int repeatCount,
00082                                          uint mailFromID = 0, const EmailAddressList& mailAddresses = EmailAddressList(),
00083                                          const QString& mailSubject = QString(),
00084                                          const QStringList& mailAttachments = QStringList());
00085         bool               dbusTriggerEvent(const QString& eventID)   { return dbusHandleEvent(eventID, EVENT_TRIGGER); }
00086         bool               dbusDeleteEvent(const QString& eventID)    { return dbusHandleEvent(eventID, EVENT_CANCEL); }
00087     public slots:
00088         void               processQueue();
00089         void               setAlarmsEnabled(bool);
00090         void               emailSent(KAMail::JobData&, const QStringList& errmsgs, bool copyerr = false);
00091     signals:
00092         void               trayIconToggled();
00093         void               alarmEnabledToggled(bool);
00094         void               execAlarmSuccess();
00095     protected:
00096         KAlarmApp();
00097     private:
00098         typedef Preferences::Feb29Type Feb29Type;   // allow it to be used in SIGNAL mechanism
00099     private slots:
00100         void               quitFatal();
00101         void               checkNextDueAlarm();
00102         void               slotShowInSystemTrayChanged();
00103         void               changeStartOfDay();
00104         void               slotFeb29TypeChanged(Feb29Type);
00105         void               setArchivePurgeDays();
00106         void               slotPurge()                     { purge(mArchivedPurgeDays); }
00107         void               slotCommandExited(ShellProcess*);
00108     private:
00109         enum EventFunc
00110         {
00111             EVENT_HANDLE,    // if the alarm is due, execute it and then reschedule it
00112             EVENT_TRIGGER,   // execute the alarm regardless, and then reschedule it if it already due
00113             EVENT_CANCEL     // delete the alarm
00114         };
00115         struct ProcData
00116         {
00117             ProcData(ShellProcess*, KAEvent*, KAAlarm*, int flags = 0);
00118             ~ProcData();
00119             enum { PRE_ACTION = 0x01, POST_ACTION = 0x02, RESCHEDULE = 0x04, ALLOW_DEFER = 0x08,
00120                    TEMP_FILE = 0x10, EXEC_IN_XTERM = 0x20, DISP_OUTPUT = 0x40 };
00121             bool                 preAction() const   { return flags & PRE_ACTION; }
00122             bool                 postAction() const  { return flags & POST_ACTION; }
00123             bool                 reschedule() const  { return flags & RESCHEDULE; }
00124             bool                 allowDefer() const  { return flags & ALLOW_DEFER; }
00125             bool                 tempFile() const    { return flags & TEMP_FILE; }
00126             bool                 execInXterm() const { return flags & EXEC_IN_XTERM; }
00127             bool                 dispOutput() const  { return flags & DISP_OUTPUT; }
00128             ShellProcess*          process;
00129             KAEvent*               event;
00130             KAAlarm*               alarm;
00131             QPointer<QWidget>      messageBoxParent;
00132             QStringList            tempFiles;
00133             int                    flags;
00134         };
00135         struct DcopQEntry
00136         {
00137             DcopQEntry(EventFunc f, const QString& id) : function(f), eventId(id) { }
00138             DcopQEntry(const KAEvent& e, EventFunc f = EVENT_HANDLE) : function(f), event(e) { }
00139             DcopQEntry() { }
00140             EventFunc  function;
00141             QString    eventId;
00142             KAEvent    event;
00143         };
00144 
00145         bool               initCheck(bool calendarOnly = false);
00146         void               quitIf(int exitCode, bool force = false);
00147         bool               checkSystemTray();
00148         void               startProcessQueue();
00149         void               queueAlarmId(const QString& id);
00150         bool               dbusHandleEvent(const QString& eventID, EventFunc);
00151         bool               handleEvent(const QString& eventID, EventFunc);
00152         void               rescheduleAlarm(KAEvent&, const KAAlarm&, bool updateCalAndDisplay);
00153         bool               cancelAlarm(KAEvent&, KAAlarm::Type, bool updateCalAndDisplay);
00154         ShellProcess*      doShellCommand(const QString& command, const KAEvent&, const KAAlarm*, int flags = 0, const QObject* receiver = 0, const char* slot = 0);
00155         QString            createTempScriptFile(const QString& command, bool insertShell, const KAEvent&, const KAAlarm&);
00156         void               commandErrorMsg(const ShellProcess*, const KAEvent&, const KAAlarm*, int flags = 0);
00157         void               purge(int daysToKeep);
00158 
00159         static KAlarmApp*  theInstance;          // the one and only KAlarmApp instance
00160         static int         mActiveCount;         // number of active instances without main windows
00161         static int         mFatalError;          // a fatal error has occurred - just wait to exit
00162         static QString     mFatalMessage;        // fatal error message to output
00163         bool               mInitialised;         // initialisation complete: ready to process execution queue
00164         bool               mQuitting;            // a forced quit is in progress
00165         bool               mLoginAlarmsDone;     // alarms repeated at login have been processed
00166         DBusHandler*       mDBusHandler;         // the parent of the main DCOP receiver object
00167         TrayWindow*        mTrayWindow;          // active system tray icon
00168         QTimer*            mAlarmTimer;          // activates KAlarm when next alarm is due
00169         QTime              mStartOfDay;          // start-of-day time currently in use
00170         QColor             mPrefsArchivedColour; // archived alarms text colour
00171         int                mArchivedPurgeDays;   // how long to keep archived alarms, 0 = don't keep, -1 = keep indefinitely
00172         int                mPurgeDaysQueued;     // >= 0 to purge the archive calendar from KAlarmApp::processLoop()
00173         QList<ProcData*>   mCommandProcesses;    // currently active command alarm processes
00174         QQueue<DcopQEntry> mDcopQueue;           // DCOP command queue
00175         int                mPendingQuitCode;     // exit code for a pending quit
00176         bool               mPendingQuit;         // quit once the DCOP command and shell command queues have been processed
00177         bool               mProcessingQueue;     // a mDcopQueue entry is currently being processed
00178         bool               mNoSystemTray;        // no system tray exists
00179         bool               mSessionClosingDown;  // session manager is closing the application
00180         bool               mOldShowInSystemTray; // showing in system tray was selected
00181         bool               mAlarmsEnabled;       // alarms are enabled
00182         bool               mSpeechEnabled;       // speech synthesis is enabled (kttsd exists)
00183         bool               mKOrganizerEnabled;   // KOrganizer options are enabled (korganizer exists)
00184 };
00185 
00186 inline KAlarmApp* theApp()  { return KAlarmApp::getInstance(); }
00187 
00188 #endif // KALARMAPP_H

kalarm

Skip menu "kalarm"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal