kalarm

alarmcalendar.h
1/*
2 * alarmcalendar.h - KAlarm calendar file access
3 * Program: kalarm
4 * Copyright © 2001-2006 by David Jarvie <software@astrojar.org.uk>
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 ALARMCALENDAR_H
22#define ALARMCALENDAR_H
23
24#include <tqobject.h>
25#include <kurl.h>
26#include <libkcal/calendarlocal.h>
27#include "alarmevent.h"
28
29class TDEConfig;
30
31
36class AlarmCalendar : public TQObject
37{
38 TQ_OBJECT
39
40 public:
41 virtual ~AlarmCalendar();
42 bool valid() const { return mUrl.isValid(); }
43 KAEvent::Status type() const { return mType; }
44 bool open();
45 int load();
46 bool reload();
47 bool save();
48 void close();
49 void startUpdate();
50 bool endUpdate();
51 KCal::Event* event(const TQString& uniqueID);
52 KCal::Event::List events();
53 KCal::Event::List eventsWithAlarms(const TQDateTime& from, const TQDateTime& to);
54 KCal::Event* addEvent(KAEvent&, bool useEventID = false);
55 void updateEvent(const KAEvent&);
56 bool deleteEvent(const TQString& eventID, bool save = false);
57 void emitEmptyStatus();
58 void purgeAll() { purge(0); }
59 void setPurgeDays(int days);
60 void purgeIfQueued(); // must only be called from KAlarmApp::processQueue()
61 bool isOpen() const { return mOpen; }
62 TQString path() const { return mUrl.prettyURL(); }
63 TQString urlString() const { return mUrl.url(); }
64
65 static TQString icalProductId();
66 static bool initialiseCalendars();
67 static void terminateCalendars();
68 static AlarmCalendar* activeCalendar() { return mCalendars[ACTIVE]; }
69 static AlarmCalendar* expiredCalendar() { return mCalendars[EXPIRED]; }
70 static AlarmCalendar* displayCalendar() { return mCalendars[DISPLAY]; }
71 static AlarmCalendar* templateCalendar() { return mCalendars[TEMPLATE]; }
72 static AlarmCalendar* activeCalendarOpen() { return calendarOpen(ACTIVE); }
73 static AlarmCalendar* expiredCalendarOpen() { return calendarOpen(EXPIRED); }
74 static AlarmCalendar* displayCalendarOpen() { return calendarOpen(DISPLAY); }
75 static AlarmCalendar* templateCalendarOpen() { return calendarOpen(TEMPLATE); }
76 static bool importAlarms(TQWidget*);
77 static const KCal::Event* getEvent(const TQString& uniqueID);
78
79 enum CalID { ACTIVE, EXPIRED, DISPLAY, TEMPLATE, NCALS };
80
81 signals:
82 void calendarSaved(AlarmCalendar*);
83 void purged();
84 void emptyStatus(bool empty);
85
86 private slots:
87 void slotPurge();
88
89 private:
90 AlarmCalendar(const TQString& file, CalID, const TQString& icalFile = TQString(),
91 const TQString& configKey = TQString());
92 bool create();
93 bool saveCal(const TQString& newFile = TQString());
94 void purge(int daysToKeep);
95 void startPurgeTimer();
96 static AlarmCalendar* createCalendar(CalID, TDEConfig*, TQString& writePath, const TQString& configKey = TQString());
97 static AlarmCalendar* calendarOpen(CalID);
98
99 static AlarmCalendar* mCalendars[NCALS]; // the calendars
100
101 KCal::CalendarLocal* mCalendar;
102 KURL mUrl; // URL of current calendar file
103 KURL mICalUrl; // URL of iCalendar file
104 TQString mLocalFile; // calendar file, or local copy if it's a remote file
105 TQString mConfigKey; // config file key for this calendar's URL
106 KAEvent::Status mType; // what type of events the calendar file is for
107 int mPurgeDays; // how long to keep alarms, 0 = don't keep, -1 = keep indefinitely
108 bool mOpen; // true if the calendar file is open
109 int mPurgeDaysQueued; // >= 0 to purge the calendar when called from KAlarmApp::processLoop()
110 int mUpdateCount; // nesting level of group of calendar update calls
111 bool mUpdateSave; // save() was called while mUpdateCount > 0
112 bool mVCal; // true if calendar file is in VCal format
113};
114
115#endif // ALARMCALENDAR_H
represents calendar alarms and events
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