kalarm

alarmevent.h
Go to the documentation of this file.
1 /*
2  * alarmevent.h - represents calendar alarms and events
3  * Program: kalarm
4  * Copyright © 2001-2008 by David Jarvie <djarvie@kde.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef KALARMEVENT_H
22 #define KALARMEVENT_H
23 
26 #include <tqcolor.h>
27 #include <tqfont.h>
28 
29 #include <libkcal/person.h>
30 #include <libkcal/event.h>
31 namespace KCal {
32  class Calendar;
33  class CalendarLocal;
34 }
35 
36 #include "datetime.h"
37 #include "karecurrence.h"
38 
39 class AlarmCalendar;
40 class KARecurrence;
41 struct AlarmData;
42 
43 
45 class EmailAddressList : public TQValueList<KCal::Person>
46 {
47  public:
48  EmailAddressList() : TQValueList<KCal::Person>() { }
49  EmailAddressList(const TQValueList<KCal::Person>& list) { operator=(list); }
50  EmailAddressList& operator=(const TQValueList<KCal::Person>&);
51  TQString join(const TQString& separator) const;
52 };
53 
54 
55 // Base class containing data common to KAAlarm and KAEvent
56 class KAAlarmEventBase
57 {
58  public:
59  ~KAAlarmEventBase() { }
60  const TQString& cleanText() const { return mText; }
61  TQString message() const { return (mActionType == T_MESSAGE || mActionType == T_EMAIL) ? mText : TQString(); }
62  TQString fileName() const { return (mActionType == T_FILE) ? mText : TQString(); }
63  TQString command() const { return (mActionType == T_COMMAND) ? mText : TQString(); }
64  uint emailFromId() const { return mEmailFromIdentity; }
65  const EmailAddressList& emailAddresses() const { return mEmailAddresses; }
66  TQString emailAddresses(const TQString& sep) const { return mEmailAddresses.join(sep); }
67  const TQString& emailSubject() const { return mEmailSubject; }
68  const TQStringList& emailAttachments() const { return mEmailAttachments; }
69  TQString emailAttachments(const TQString& sep) const { return mEmailAttachments.join(sep); }
70  bool emailBcc() const { return mEmailBcc; }
71  const TQColor& bgColour() const { return mBgColour; }
72  const TQColor& fgColour() const { return mFgColour; }
73  bool defaultFont() const { return mDefaultFont; }
74  const TQFont& font() const;
75  int lateCancel() const { return mLateCancel; }
76  bool autoClose() const { return mAutoClose; }
77  bool commandScript() const { return mCommandScript; }
78  bool confirmAck() const { return mConfirmAck; }
79  bool repeatAtLogin() const { return mRepeatAtLogin; }
80  int repeatCount() const { return mRepeatCount; }
81  int repeatInterval() const { return mRepeatInterval; }
82  bool displaying() const { return mDisplaying; }
83  bool beep() const { return mBeep; }
84  bool speak() const { return (mActionType == T_MESSAGE) && mSpeak; }
85  int flags() const;
86 #ifdef NDEBUG
87  void dumpDebug() const { }
88 #else
89  void dumpDebug() const;
90 #endif
91 
92  protected:
93  enum Type { T_MESSAGE, T_FILE, T_COMMAND, T_AUDIO, T_EMAIL };
94 
95  KAAlarmEventBase() : mRepeatCount(0), mLateCancel(0), mAutoClose(false), mBeep(false), mRepeatAtLogin(false),
96  mDisplaying(false), mEmailBcc(false), mConfirmAck(false) { }
97  KAAlarmEventBase(const KAAlarmEventBase& rhs) { copy(rhs); }
98  KAAlarmEventBase& operator=(const KAAlarmEventBase& rhs) { copy(rhs); return *this; }
99  void copy(const KAAlarmEventBase&);
100  void set(int flags);
101 
102  TQString mEventID; // UID: KCal::Event unique ID
103  TQString mText; // message text, file URL, command, email body [or audio file for KAAlarm]
104  DateTime mNextMainDateTime; // next time to display the alarm, excluding repetitions
105  TQColor mBgColour; // background colour of alarm message
106  TQColor mFgColour; // foreground colour of alarm message, or invalid for default
107  TQFont mFont; // font of alarm message (ignored if mDefaultFont true)
108  uint mEmailFromIdentity;// KMail identity for email 'From' field, or empty
109  EmailAddressList mEmailAddresses; // ATTENDEE: addresses to send email to
110  TQString mEmailSubject; // SUMMARY: subject line of email
111  TQStringList mEmailAttachments; // ATTACH: email attachment file names
112  float mSoundVolume; // volume for sound file, or < 0 for unspecified
113  float mFadeVolume; // initial volume for sound file, or < 0 for no fade
114  int mFadeSeconds; // fade time for sound file, or 0 if none
115  Type mActionType; // alarm action type
116  int mRepeatCount; // sub-repetition count (excluding the first time)
117  int mRepeatInterval; // sub-repetition interval (minutes)
118  int mNextRepeat; // repetition count of next due sub-repetition
119  int mLateCancel; // how many minutes late will cancel the alarm, or 0 for no cancellation
120  bool mAutoClose; // whether to close the alarm window after the late-cancel period
121  bool mCommandScript; // the command text is a script, not a shell command line
122  bool mBeep; // whether to beep when the alarm is displayed
123  bool mSpeak; // whether to speak the message when the alarm is displayed
124  bool mRepeatSound; // whether to repeat the sound file while the alarm is displayed
125  bool mRepeatAtLogin; // whether to repeat the alarm at every login
126  bool mDisplaying; // whether the alarm is currently being displayed
127  bool mEmailBcc; // blind copy the email to the user
128  bool mConfirmAck; // alarm acknowledgement requires confirmation by user
129  bool mDefaultFont; // use default message font, not mFont
130 
131  friend class AlarmData;
132 };
133 
134 
135 // KAAlarm corresponds to a single KCal::Alarm instance.
136 // A KAEvent may contain multiple KAAlarm's.
137 class KAAlarm : public KAAlarmEventBase
138 {
139  public:
140  // Define the basic KAAlaem action types
141  enum Action
142  {
143  MESSAGE = T_MESSAGE, // KCal::Alarm::Display type: display a text message
144  FILE = T_FILE, // KCal::Alarm::Display type: display a file (URL given by the alarm text)
145  COMMAND = T_COMMAND, // KCal::Alarm::Procedure type: execute a shell command
146  EMAIL = T_EMAIL, // KCal::Alarm::Email type: send an email
147  AUDIO = T_AUDIO // KCal::Alarm::Audio type: play a sound file
148  };
149  // Define the KAAlarm types.
150  // KAAlarm's of different types may be contained in a KAEvent,
151  // each defining a different component of the overall alarm.
152  enum Type
153  {
154  INVALID_ALARM = 0, // not an alarm
155  MAIN_ALARM = 1, // THE real alarm. Must be the first in the enumeration.
156  // The following values may be used in combination as a bimask 0x0E
157  REMINDER_ALARM = 0x02, // reminder in advance of main alarm
158  DEFERRED_ALARM = 0x04, // deferred alarm
159  DEFERRED_REMINDER_ALARM = REMINDER_ALARM | DEFERRED_ALARM, // deferred early warning
160  // The following values must be greater than the preceding ones, to
161  // ensure that in ordered processing they are processed afterwards.
162  AT_LOGIN_ALARM = 0x10, // additional repeat-at-login trigger
163  DISPLAYING_ALARM = 0x20, // copy of the alarm currently being displayed
164  // The following values are for internal KAEvent use only
165  AUDIO_ALARM = 0x30, // sound to play when displaying the alarm
166  PRE_ACTION_ALARM = 0x40, // command to execute before displaying the alarm
167  POST_ACTION_ALARM = 0x50 // command to execute after the alarm window is closed
168  };
169  enum SubType
170  {
171  INVALID__ALARM = INVALID_ALARM,
172  MAIN__ALARM = MAIN_ALARM,
173  // The following values may be used in combination as a bimask 0x0E
174  REMINDER__ALARM = REMINDER_ALARM,
175  TIMED_DEFERRAL_FLAG = 0x08, // deferral has a time; if clear, it is date-only
176  DEFERRED_DATE__ALARM = DEFERRED_ALARM, // deferred alarm - date-only
177  DEFERRED_TIME__ALARM = DEFERRED_ALARM | TIMED_DEFERRAL_FLAG,
178  DEFERRED_REMINDER_DATE__ALARM = REMINDER_ALARM | DEFERRED_ALARM, // deferred early warning (date-only)
179  DEFERRED_REMINDER_TIME__ALARM = REMINDER_ALARM | DEFERRED_ALARM | TIMED_DEFERRAL_FLAG, // deferred early warning (date/time)
180  // The following values must be greater than the preceding ones, to
181  // ensure that in ordered processing they are processed afterwards.
182  AT_LOGIN__ALARM = AT_LOGIN_ALARM,
183  DISPLAYING__ALARM = DISPLAYING_ALARM,
184  // The following values are for internal KAEvent use only
185  AUDIO__ALARM = AUDIO_ALARM,
186  PRE_ACTION__ALARM = PRE_ACTION_ALARM,
187  POST_ACTION__ALARM = POST_ACTION_ALARM
188  };
189 
190  KAAlarm() : mType(INVALID__ALARM), mDeferred(false) { }
191  KAAlarm(const KAAlarm&);
192  ~KAAlarm() { }
193  Action action() const { return (Action)mActionType; }
194  bool valid() const { return mType != INVALID__ALARM; }
195  Type type() const { return static_cast<Type>(mType & ~TIMED_DEFERRAL_FLAG); }
196  SubType subType() const { return mType; }
197  const TQString& eventID() const { return mEventID; }
198  DateTime dateTime(bool withRepeats = false) const
199  { return (withRepeats && mNextRepeat && mRepeatInterval)
200  ? mNextMainDateTime.addSecs(mNextRepeat * mRepeatInterval * 60) : mNextMainDateTime; }
201  TQDate date() const { return mNextMainDateTime.date(); }
202  TQTime time() const { return mNextMainDateTime.time(); }
203  TQString audioFile() const { return (mActionType == T_AUDIO) && !mBeep ? mText : TQString(); }
204  float soundVolume() const { return (mActionType == T_AUDIO) && !mBeep && !mText.isEmpty() ? mSoundVolume : -1; }
205  float fadeVolume() const { return (mActionType == T_AUDIO) && mSoundVolume >= 0 && mFadeSeconds && !mBeep && !mText.isEmpty() ? mFadeVolume : -1; }
206  int fadeSeconds() const { return (mActionType == T_AUDIO) && mSoundVolume >= 0 && mFadeVolume >= 0 && !mBeep && !mText.isEmpty() ? mFadeSeconds : 0; }
207  bool repeatSound() const { return (mActionType == T_AUDIO) && mRepeatSound && !mBeep && !mText.isEmpty(); }
208  bool reminder() const { return mType == REMINDER__ALARM; }
209  bool deferred() const { return mDeferred; }
210  void setTime(const DateTime& dt) { mNextMainDateTime = dt; }
211  void setTime(const TQDateTime& dt) { mNextMainDateTime = dt; }
212  int flags() const;
213 #ifdef NDEBUG
214  void dumpDebug() const { }
215  static const char* debugType(Type) { return ""; }
216 #else
217  void dumpDebug() const;
218  static const char* debugType(Type);
219 #endif
220 
221  private:
222  SubType mType; // alarm type
223  bool mRecurs; // there is a recurrence rule for the alarm
224  bool mDeferred; // whether the alarm is an extra deferred/deferred-reminder alarm
225 
226  friend class KAEvent;
227 };
228 
229 
231 class KAEvent : public KAAlarmEventBase
232 {
233  public:
234  enum // flags for use in DCOP calls, etc.
235  {
236 #ifdef OLD_DCOP
237  // *** DON'T CHANGE THESE VALUES ***
238  // because they are part of KAlarm's external DCOP interface.
239  // (But it's alright to add new values.)
240  LATE_CANCEL = 0x01, // cancel alarm if not triggered within a minute of its scheduled time
241 #endif
242  BEEP = 0x02, // sound audible beep when alarm is displayed
243  REPEAT_AT_LOGIN = 0x04, // repeat alarm at every login
244  ANY_TIME = 0x08, // only a date is specified for the alarm, not a time
245  CONFIRM_ACK = 0x10, // closing the alarm message window requires confirmation prompt
246  EMAIL_BCC = 0x20, // blind copy the email to the user
247  DEFAULT_FONT = 0x40, // use default alarm message font
248  REPEAT_SOUND = 0x80, // repeat sound file while alarm is displayed
249  DISABLED = 0x100, // alarm is currently disabled
250  AUTO_CLOSE = 0x200, // auto-close alarm window after late-cancel period
251  SCRIPT = 0x400, // command is a script, not a shell command line
252  EXEC_IN_XTERM = 0x800, // execute command in terminal window
253  SPEAK = 0x1000, // speak the message when the alarm is displayed
254  COPY_KORGANIZER = 0x2000, // KOrganizer should hold a copy of the event
255 #ifdef OLD_DCOP
256  // The following are read-only internal values, and may be changed
257 #else
258  // The following are read-only internal values
259 #endif
260  REMINDER = 0x10000,
261  DEFERRAL = 0x20000,
262  TIMED_FLAG = 0x40000,
263  DATE_DEFERRAL = DEFERRAL,
264  TIME_DEFERRAL = DEFERRAL | TIMED_FLAG,
265  DISPLAYING_ = 0x80000,
266  READ_ONLY_FLAGS = 0xF0000 // mask for all read-only internal values
267  };
269  enum Status
270  {
271  ACTIVE, // the event is currently active
272  EXPIRED, // the event has expired
273  DISPLAYING, // the event is currently being displayed
274  TEMPLATE, // the event is an alarm template
275  KORGANIZER // the event is a copy of a KAlarm event, held by KOrganizer
276  };
277  enum Action
278  {
279  MESSAGE = T_MESSAGE,
280  FILE = T_FILE,
281  COMMAND = T_COMMAND,
282  EMAIL = T_EMAIL
283  };
284  enum OccurType // what type of occurrence is due
285  {
286  NO_OCCURRENCE = 0, // no occurrence is due
287  FIRST_OR_ONLY_OCCURRENCE = 0x01, // the first occurrence (takes precedence over LAST_RECURRENCE)
288  RECURRENCE_DATE = 0x02, // a recurrence with only a date, not a time
289  RECURRENCE_DATE_TIME = 0x03, // a recurrence with a date and time
290  LAST_RECURRENCE = 0x04, // the last recurrence
291  OCCURRENCE_REPEAT = 0x10, // (bimask for a repetition of an occurrence)
292  FIRST_OR_ONLY_OCCURRENCE_REPEAT = OCCURRENCE_REPEAT | FIRST_OR_ONLY_OCCURRENCE, // a repetition of the first occurrence
293  RECURRENCE_DATE_REPEAT = OCCURRENCE_REPEAT | RECURRENCE_DATE, // a repetition of a date-only recurrence
294  RECURRENCE_DATE_TIME_REPEAT = OCCURRENCE_REPEAT | RECURRENCE_DATE_TIME, // a repetition of a date/time recurrence
295  LAST_RECURRENCE_REPEAT = OCCURRENCE_REPEAT | LAST_RECURRENCE // a repetition of the last recurrence
296  };
297  enum OccurOption // options for nextOccurrence()
298  {
299  IGNORE_REPETITION, // check for recurrences only, ignore repetitions
300  RETURN_REPETITION, // return repetition if it's the next occurrence
301  ALLOW_FOR_REPETITION // check for repetition being the next occurrence, but return recurrence
302  };
303  enum DeferLimitType // what type of occurrence currently limits a deferral
304  {
305  LIMIT_NONE,
306  LIMIT_MAIN,
307  LIMIT_RECURRENCE,
308  LIMIT_REPETITION,
309  LIMIT_REMINDER
310  };
311 
312  KAEvent() : mRevision(0), mRecurrence(0), mAlarmCount(0) { }
313  KAEvent(const TQDateTime& dt, const TQString& message, const TQColor& bg, const TQColor& fg, const TQFont& f, Action action, int lateCancel, int flags)
314  : mRecurrence(0) { set(dt, message, bg, fg, f, action, lateCancel, flags); }
315  explicit KAEvent(const KCal::Event& e) : mRecurrence(0) { set(e); }
316  KAEvent(const KAEvent& e) : KAAlarmEventBase(e), mRecurrence(0) { copy(e); }
317  ~KAEvent() { delete mRecurrence; }
318  KAEvent& operator=(const KAEvent& e) { if (&e != this) copy(e); return *this; }
319  void set(const KCal::Event&);
320  void set(const TQDateTime&, const TQString& message, const TQColor& bg, const TQColor& fg, const TQFont&, Action, int lateCancel, int flags);
321  void setEmail(uint from, const EmailAddressList&, const TQString& subject, const TQStringList& attachments);
322  void setAudioFile(const TQString& filename, float volume, float fadeVolume, int fadeSeconds);
323  void setTemplate(const TQString& name, int afterTime = -1) { mTemplateName = name; mTemplateAfterTime = afterTime; mUpdated = true; }
324  void setActions(const TQString& pre, const TQString& post) { mPreAction = pre; mPostAction = post; mUpdated = true; }
325  OccurType setNextOccurrence(const TQDateTime& preDateTime);
326  void setFirstRecurrence();
327  void setEventID(const TQString& id) { mEventID = id; mUpdated = true; }
328  void setDate(const TQDate& d) { mNextMainDateTime.set(d); mUpdated = true; }
329  void setTime(const TQDateTime& dt) { mNextMainDateTime.set(dt); mUpdated = true; }
330  void setSaveDateTime(const TQDateTime& dt) { mSaveDateTime = dt; mUpdated = true; }
331  void setLateCancel(int lc) { mLateCancel = lc; mUpdated = true; }
332  void setAutoClose(bool ac) { mAutoClose = ac; mUpdated = true; }
333  void setRepeatAtLogin(bool rl) { mRepeatAtLogin = rl; mUpdated = true; }
334  void setUid(Status s) { mEventID = uid(mEventID, s); mUpdated = true; }
335  void setKMailSerialNumber(unsigned long n) { mKMailSerialNumber = n; }
336  void setLogFile(const TQString& logfile);
337  void setReminder(int minutes, bool onceOnly);
338  bool defer(const DateTime&, bool reminder, bool adjustRecurrence = false);
339  void cancelDefer();
340  void cancelCancelledDeferral();
341  void setDeferDefaultMinutes(int minutes) { mDeferDefaultMinutes = minutes; mUpdated = true; }
342  bool setDisplaying(const KAEvent&, KAAlarm::Type, const TQDateTime&);
343  void reinstateFromDisplaying(const KAEvent& dispEvent);
344  void setArchive() { mArchive = true; mUpdated = true; }
345  void setEnabled(bool enable) { mEnabled = enable; mUpdated = true; }
346  void setUpdated() { mUpdated = true; }
347  void clearUpdated() const { mUpdated = false; }
348  void removeExpiredAlarm(KAAlarm::Type);
349  void incrementRevision() { ++mRevision; mUpdated = true; }
350 
351  KCal::Event* event() const; // convert to new Event
352  bool isTemplate() const { return !mTemplateName.isEmpty(); }
353  const TQString& templateName() const { return mTemplateName; }
354  bool usingDefaultTime() const { return mTemplateAfterTime == 0; }
355  int templateAfterTime() const { return mTemplateAfterTime; }
356  KAAlarm alarm(KAAlarm::Type) const;
357  KAAlarm firstAlarm() const;
358  KAAlarm nextAlarm(const KAAlarm& al) const { return nextAlarm(al.type()); }
359  KAAlarm nextAlarm(KAAlarm::Type) const;
360  KAAlarm convertDisplayingAlarm() const;
361  bool updateKCalEvent(KCal::Event&, bool checkUid = true, bool original = false, bool cancelCancelledDefer = false) const;
362  Action action() const { return (Action)mActionType; }
363  bool displayAction() const { return mActionType == T_MESSAGE || mActionType == T_FILE; }
364  const TQString& id() const { return mEventID; }
365  bool valid() const { return mAlarmCount && (mAlarmCount != 1 || !mRepeatAtLogin); }
366  int alarmCount() const { return mAlarmCount; }
367  const DateTime& startDateTime() const { return mStartDateTime; }
368  DateTime mainDateTime(bool withRepeats = false) const
369  { return (withRepeats && mNextRepeat && mRepeatInterval)
370  ? mNextMainDateTime.addSecs(mNextRepeat * mRepeatInterval * 60) : mNextMainDateTime; }
371  TQDate mainDate() const { return mNextMainDateTime.date(); }
372  TQTime mainTime() const { return mNextMainDateTime.time(); }
373  DateTime mainEndRepeatTime() const { return (mRepeatCount > 0 && mRepeatInterval)
374  ? mNextMainDateTime.addSecs(mRepeatCount * mRepeatInterval * 60) : mNextMainDateTime; }
375  int reminder() const { return mReminderMinutes; }
376  bool reminderOnceOnly() const { return mReminderOnceOnly; }
377  bool reminderDeferral() const { return mDeferral == REMINDER_DEFERRAL; }
378  int reminderArchived() const { return mArchiveReminderMinutes; }
379  DateTime deferDateTime() const { return mDeferralTime; }
380  DateTime deferralLimit(DeferLimitType* = 0) const;
381  int deferDefaultMinutes() const { return mDeferDefaultMinutes; }
382  DateTime displayDateTime() const;
383  const TQString& messageFileOrCommand() const { return mText; }
384  TQString logFile() const { return mLogFile; }
385  bool commandXterm() const { return mCommandXterm; }
386  unsigned long kmailSerialNumber() const { return mKMailSerialNumber; }
387  bool copyToKOrganizer() const { return mCopyToKOrganizer; }
388  const TQString& audioFile() const { return mAudioFile; }
389  float soundVolume() const { return !mAudioFile.isEmpty() ? mSoundVolume : -1; }
390  float fadeVolume() const { return !mAudioFile.isEmpty() && mSoundVolume >= 0 && mFadeSeconds ? mFadeVolume : -1; }
391  int fadeSeconds() const { return !mAudioFile.isEmpty() && mSoundVolume >= 0 && mFadeVolume >= 0 ? mFadeSeconds : 0; }
392  bool repeatSound() const { return mRepeatSound && !mAudioFile.isEmpty(); }
393  const TQString& preAction() const { return mPreAction; }
394  const TQString& postAction() const { return mPostAction; }
395  bool recurs() const { return checkRecur() != KARecurrence::NO_RECUR; }
396  KARecurrence::Type recurType() const { return checkRecur(); }
397  KARecurrence* recurrence() const { return mRecurrence; }
398  int recurInterval() const; // recurrence period in units of the recurrence period type (minutes, days, etc)
399  int longestRecurrenceInterval() const { return mRecurrence ? mRecurrence->longestInterval() : 0; }
400  TQString recurrenceText(bool brief = false) const;
401  TQString repetitionText(bool brief = false) const;
402  bool occursAfter(const TQDateTime& preDateTime, bool includeRepetitions) const;
403  OccurType nextOccurrence(const TQDateTime& preDateTime, DateTime& result, OccurOption = IGNORE_REPETITION) const;
404  OccurType previousOccurrence(const TQDateTime& afterDateTime, DateTime& result, bool includeRepetitions = false) const;
405  int flags() const;
406  bool deferred() const { return mDeferral > 0; }
407  bool toBeArchived() const { return mArchive; }
408  bool enabled() const { return mEnabled; }
409  bool updated() const { return mUpdated; }
410  bool mainExpired() const { return mMainExpired; }
411  bool expired() const { return (mDisplaying && mMainExpired) || uidStatus(mEventID) == EXPIRED; }
412  Status uidStatus() const { return uidStatus(mEventID); }
413  static Status uidStatus(const TQString& uid);
414  static TQString uid(const TQString& id, Status);
415  static KAEvent findTemplateName(AlarmCalendar&, const TQString& name);
416 
417  struct MonthPos
418  {
419  MonthPos() : days(7) { }
420  int weeknum; // week in month, or < 0 to count from end of month
421  TQBitArray days; // days in week
422  };
423  bool setRepetition(int interval, int count);
424  void setNoRecur() { clearRecur(); }
425  void setRecurrence(const KARecurrence&);
426  bool setRecurMinutely(int freq, int count, const TQDateTime& end);
427  bool setRecurDaily(int freq, const TQBitArray& days, int count, const TQDate& end);
428  bool setRecurWeekly(int freq, const TQBitArray& days, int count, const TQDate& end);
429  bool setRecurMonthlyByDate(int freq, const TQValueList<int>& days, int count, const TQDate& end);
430  bool setRecurMonthlyByPos(int freq, const TQValueList<MonthPos>& pos, int count, const TQDate& end);
431  bool setRecurAnnualByDate(int freq, const TQValueList<int>& months, int day, KARecurrence::Feb29Type, int count, const TQDate& end);
432  bool setRecurAnnualByPos(int freq, const TQValueList<MonthPos>& pos, const TQValueList<int>& months, int count, const TQDate& end);
433 // static TQValueList<MonthPos> convRecurPos(const TQValueList<KCal::RecurrenceRule::WDayPos>&);
434 #ifdef NDEBUG
435  void dumpDebug() const { }
436 #else
437  void dumpDebug() const;
438 #endif
439  static int calVersion();
440  static TQString calVersionString();
441  static bool adjustStartOfDay(const KCal::Event::List&);
442  static void convertKCalEvents(KCal::Calendar&, int version, bool adjustSummerTime);
443  static void convertRepetitions(KCal::CalendarLocal&);
444 
445  private:
446  enum DeferType {
447  CANCEL_DEFERRAL = -1, // there was a deferred alarm, but it has been cancelled
448  NO_DEFERRAL = 0, // there is no deferred alarm
449  NORMAL_DEFERRAL, // the main alarm, a recurrence or a repeat is deferred
450  REMINDER_DEFERRAL // a reminder alarm is deferred
451  };
452 
453  void copy(const KAEvent&);
454  bool setRecur(KCal::RecurrenceRule::PeriodType, int freq, int count, const TQDateTime& end, KARecurrence::Feb29Type = KARecurrence::FEB29_FEB29);
455  void clearRecur();
456  KARecurrence::Type checkRecur() const;
457  void checkRepetition() const;
458  OccurType nextRecurrence(const TQDateTime& preDateTime, DateTime& result) const;
459  OccurType previousRecurrence(const TQDateTime& afterDateTime, DateTime& result) const;
460  static bool convertRepetition(KCal::Event*);
461  KCal::Alarm* initKCalAlarm(KCal::Event&, const DateTime&, const TQStringList& types, KAAlarm::Type = KAAlarm::INVALID_ALARM) const;
462  KCal::Alarm* initKCalAlarm(KCal::Event&, int startOffsetSecs, const TQStringList& types, KAAlarm::Type = KAAlarm::INVALID_ALARM) const;
463  static DateTime readDateTime(const KCal::Event&, bool dateOnly, DateTime& start);
464  static void readAlarms(const KCal::Event&, void* alarmMap);
465  static void readAlarm(const KCal::Alarm&, AlarmData&);
466  inline void set_deferral(DeferType);
467  inline void set_reminder(int minutes);
468  inline void set_archiveReminder();
469 
470  TQString mTemplateName; // alarm template's name, or null if normal event
471  TQString mAudioFile; // ATTACH: audio file to play
472  TQString mPreAction; // command to execute before alarm is displayed
473  TQString mPostAction; // command to execute after alarm window is closed
474  DateTime mStartDateTime; // DTSTART and DTEND: start and end time for event
475  TQDateTime mSaveDateTime; // CREATED: date event was created, or saved in expired calendar
476  TQDateTime mAtLoginDateTime; // repeat-at-login time
477  DateTime mDeferralTime; // extra time to trigger alarm (if alarm or reminder deferred)
478  DateTime mDisplayingTime; // date/time shown in the alarm currently being displayed
479  int mDisplayingFlags; // type of alarm which is currently being displayed
480  int mReminderMinutes; // how long in advance reminder is to be, or 0 if none
481  int mArchiveReminderMinutes; // original reminder period if now expired, or 0 if none
482  int mDeferDefaultMinutes; // default number of minutes for deferral dialogue, or 0 to select time control
483  int mRevision; // SEQUENCE: revision number of the original alarm, or 0
484  KARecurrence* mRecurrence; // RECUR: recurrence specification, or 0 if none
485  int mAlarmCount; // number of alarms: count of !mMainExpired, mRepeatAtLogin, mDeferral, mReminderMinutes, mDisplaying
486  DeferType mDeferral; // whether the alarm is an extra deferred/deferred-reminder alarm
487  unsigned long mKMailSerialNumber;// if email text, message's KMail serial number
488  int mTemplateAfterTime;// time not specified: use n minutes after default time, or -1 (applies to templates only)
489  TQString mLogFile; // alarm output is to be logged to this URL
490  bool mCommandXterm; // command alarm is to be executed in a terminal window
491  bool mCopyToKOrganizer; // KOrganizer should hold a copy of the event
492  bool mReminderOnceOnly; // the reminder is output only for the first recurrence
493  bool mMainExpired; // main alarm has expired (in which case a deferral alarm will exist)
494  bool mArchiveRepeatAtLogin; // if now expired, original event was repeat-at-login
495  bool mArchive; // event has triggered in the past, so archive it when closed
496  bool mEnabled; // false if event is disabled
497  mutable bool mUpdated; // event has been updated but not written to calendar file
498 };
499 
500 #endif // KALARMEVENT_H
Provides read and write access to calendar files.
Definition: alarmcalendar.h:37
KAEvent corresponds to a KCal::Event instance.
Definition: alarmevent.h:232
Status
The category of an event, indicated by the middle part of its UID.
Definition: alarmevent.h:270