1 | /* |
2 | This file is part of the kcal library. |
3 | |
4 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
6 | |
7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. |
21 | */ |
22 | /** |
23 | @file |
24 | This file is part of the API for handling calendar data and defines |
25 | classes for managing compatibility between different calendar formats. |
26 | |
27 | @author Cornelius Schumacher \<schumacher@kde.org\> |
28 | @author Reinhold Kainhofer \<reinhold@kainhofer.com\> |
29 | */ |
30 | |
31 | #ifndef KCAL_COMPAT_H |
32 | #define KCAL_COMPAT_H |
33 | |
34 | #include "kcal_export.h" |
35 | #include <QtCore/QString> |
36 | |
37 | class QDate; |
38 | |
39 | namespace KCal { |
40 | |
41 | class Incidence; |
42 | class Compat; |
43 | |
44 | /** |
45 | @brief |
46 | Factory for creating the right Compat object. |
47 | */ |
48 | class CompatFactory |
49 | { |
50 | public: |
51 | /** |
52 | Creates the appropriate Compat class as determined by the Product ID. |
53 | |
54 | @param productId is a string containing a valid Product ID from |
55 | a supported calendar format. |
56 | @return A pointer to a Compat object which is owned by the caller. |
57 | */ |
58 | static Compat *createCompat( const QString &productId ); |
59 | }; |
60 | |
61 | /** |
62 | @brief |
63 | This class provides compatibility to older or broken calendar files. |
64 | */ |
65 | class Compat |
66 | { |
67 | public: |
68 | /** |
69 | Constructor. |
70 | */ |
71 | Compat() {} |
72 | |
73 | /** |
74 | Destructor. |
75 | */ |
76 | virtual ~Compat() {} |
77 | |
78 | /** |
79 | Fixes the recurrence rule for an incidence. |
80 | @param incidence is a pointer to an Incidence object that may |
81 | need its recurrence rule fixed. |
82 | */ |
83 | virtual void fixRecurrence( Incidence *incidence ); |
84 | |
85 | /** |
86 | Fixes an empty summary for an incidence. |
87 | @param incidence is a pointer to an Incidence object that may need |
88 | its summary fixed. |
89 | */ |
90 | virtual void fixEmptySummary( Incidence *incidence ); |
91 | |
92 | /** |
93 | Fixes the alarms list an incidence. |
94 | @param incidence is a pointer to an Incidence object that may need |
95 | its alarms fixed. |
96 | */ |
97 | virtual void fixAlarms( Incidence *incidence ) { Q_UNUSED( incidence ); } |
98 | |
99 | /** |
100 | Fixes the end date for floating events. |
101 | @param date is the end date to fix. |
102 | */ |
103 | virtual void fixFloatingEnd( QDate &date ); |
104 | |
105 | /** |
106 | Fixes the priority. |
107 | @param priority is the priority value to fix. |
108 | @return an integer representing a valid priority value. |
109 | */ |
110 | virtual int fixPriority( int priority ) { return priority; } |
111 | |
112 | /** |
113 | Returns true if a timezone shift should be used; false otherwise. |
114 | */ |
115 | virtual bool useTimeZoneShift() { return true; } |
116 | |
117 | private: |
118 | //@cond PRIVATE |
119 | Q_DISABLE_COPY( Compat ) |
120 | class Private; |
121 | Private *d; |
122 | //@endcond |
123 | }; |
124 | |
125 | /** |
126 | @brief |
127 | Compatibility class for KOrganizer pre-3.5 calendar files. |
128 | |
129 | Before kde 3.5, the start date was not automatically a recurring date. |
130 | So, if the start date doesn't match the recurrence rule, we need to add |
131 | an ex-date for the date start. If a duration was given, the DTSTART was |
132 | only counted if it matched, so by accident this was already the correct |
133 | behavior, so we don't need to adjust the duration. |
134 | */ |
135 | class CompatPre35 : public Compat |
136 | { |
137 | public: |
138 | /** |
139 | @copydoc |
140 | Compat::fixRecurrence() |
141 | */ |
142 | virtual void fixRecurrence( Incidence *incidence ); |
143 | |
144 | private: |
145 | //@cond PRIVATE |
146 | class Private; |
147 | Private *d; |
148 | //@endcond |
149 | }; |
150 | |
151 | class CompatPre34 : public CompatPre35 |
152 | { |
153 | public: |
154 | /** |
155 | @copydoc |
156 | Compat::fixPriority() |
157 | */ |
158 | virtual int fixPriority( int priority ); |
159 | |
160 | private: |
161 | //@cond PRIVATE |
162 | class Private; |
163 | Private *d; |
164 | //@endcond |
165 | }; |
166 | |
167 | /** |
168 | @brief |
169 | Compatibility class for KOrganizer pre-3.2 calendar files. |
170 | |
171 | The recurrence has a specified number of repetitions. |
172 | Pre-3.2, this was extended by the number of exception dates. |
173 | This is also rfc 2445-compliant. The duration of an RRULE also counts |
174 | events that are later excluded via EXDATE or EXRULE. |
175 | */ |
176 | class CompatPre32 : public CompatPre34 |
177 | { |
178 | public: |
179 | /** |
180 | @copydoc |
181 | Compat::fixRecurrence() |
182 | */ |
183 | virtual void fixRecurrence( Incidence *incidence ); |
184 | |
185 | private: |
186 | //@cond PRIVATE |
187 | |
188 | class Private; |
189 | Private *d; |
190 | //@endcond |
191 | }; |
192 | |
193 | /** |
194 | @brief |
195 | Compatibility class for KOrganizer pre-3.1 calendar files. |
196 | |
197 | Before kde 3.1, floating events (events without a date) had 0:00 of their |
198 | last day as the end date. E.g. 28.5.2005 0:00 until 28.5.2005 0:00 for an |
199 | event that lasted the whole day on May 28, 2005. According to RFC 2445, the |
200 | end date for such an event needs to be 29.5.2005 0:00. |
201 | |
202 | Update: We misunderstood rfc 2445 in this regard. For all-day events, the |
203 | DTEND is the last day of the event. See a mail from the Author or rfc 2445: |
204 | http://www.imc.org/ietf-calendar/archive1/msg03648.html |
205 | However, as all other applications also got this wrong, we'll just leave it |
206 | as it is and use the wrong interpretation (was also discussed on ietf-calsify) |
207 | */ |
208 | class CompatPre31 : public CompatPre32 |
209 | { |
210 | public: |
211 | /** |
212 | @copydoc |
213 | Compat::fixFloatingEnd() |
214 | */ |
215 | virtual void fixFloatingEnd( QDate &date ); |
216 | |
217 | /** |
218 | @copydoc |
219 | Compat::fixRecurrence() |
220 | */ |
221 | virtual void fixRecurrence( Incidence *incidence ); |
222 | |
223 | private: |
224 | //@cond PRIVATE |
225 | class Private; |
226 | Private *d; |
227 | //@endcond |
228 | }; |
229 | |
230 | class Compat32PrereleaseVersions : public Compat |
231 | { |
232 | public: |
233 | /** |
234 | @copydoc |
235 | Compat::useTimeZoneShift() |
236 | */ |
237 | virtual bool useTimeZoneShift() { return false; } |
238 | |
239 | private: |
240 | //@cond PRIVATE |
241 | class Private; |
242 | Private *d; |
243 | //@endcond |
244 | }; |
245 | |
246 | /** |
247 | @brief |
248 | Compatibility class for Outlook 9 calendar files. |
249 | |
250 | In Outlook 9, alarms have the wrong sign. I.e. RFC 2445 says that negative |
251 | values for the trigger are before the event's start. Outlook/exchange, |
252 | however used positive values. |
253 | */ |
254 | class CompatOutlook9 : public Compat |
255 | { |
256 | public: |
257 | /** |
258 | @copydoc |
259 | Compat::fixAlarms() |
260 | */ |
261 | virtual void fixAlarms( Incidence *incidence ); |
262 | |
263 | private: |
264 | //@cond PRIVATE |
265 | class Private; |
266 | Private *d; |
267 | //@endcond |
268 | }; |
269 | |
270 | } |
271 | |
272 | #endif |
273 | |