KCalendarCore

icalformat.h
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 2001-2003 Cornelius Schumacher <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 /**
9  @file
10  This file is part of the API for handling calendar data and
11  defines the ICalFormat class.
12 
13  @author Cornelius Schumacher <[email protected]>
14 */
15 #ifndef KCALCORE_ICALFORMAT_H
16 #define KCALCORE_ICALFORMAT_H
17 
18 #include "calformat.h"
19 #include "freebusy.h"
20 #include "incidence.h"
21 #include "kcalendarcore_export.h"
22 #include "schedulemessage.h"
23 
24 namespace KCalendarCore
25 {
26 class FreeBusy;
27 class ICalFormatPrivate;
28 class Incidence;
29 class IncidenceBase;
30 class RecurrenceRule;
31 
32 /**
33  @brief
34  iCalendar format implementation.
35 
36  This class implements the iCalendar format. It provides methods for
37  loading/saving/converting iCalendar format data into the internal
38  representation as Calendar and Incidences.
39 
40  @warning When importing/loading to a Calendar, there is only duplicate
41  check if those Incidences are loaded into the Calendar. If they are not
42  loaded it will create duplicates.
43 */
44 class KCALENDARCORE_EXPORT ICalFormat : public CalFormat
45 {
46 public:
47  /**
48  Constructor a new iCalendar Format object.
49  */
50  ICalFormat();
51 
52  /**
53  Destructor.
54  */
55  ~ICalFormat() override;
56 
57  /**
58  @copydoc
59  CalFormat::load()
60  */
61  bool load(const Calendar::Ptr &calendar, const QString &fileName) override;
62 
63  /**
64  @copydoc
65  CalFormat::save()
66  */
67  bool save(const Calendar::Ptr &calendar, const QString &fileName) override;
68 
69 #if KCALENDARCORE_BUILD_DEPRECATED_SINCE(5, 97)
70  /**
71  @copydoc
72  CalFormat::fromString()
73  */
74  KCALENDARCORE_DEPRECATED_VERSION(5, 97, "use fromString(const Calendar::Ptr &calendar, const QString &string, const QString &notebook)")
75  bool fromString(const Calendar::Ptr &calendar, const QString &string, bool deleted, const QString &notebook) override;
76 #endif
77  // make CalFromat::fromString(const Calendar::Ptr &calendar, const QString&, const QString&) visible here as well
79 
80  /**
81  Parses a string, returning the first iCal component as an Incidence.
82 
83  @param string is a QString containing the data to be parsed.
84 
85  @return non-zero pointer if the parsing was successful; 0 otherwise.
86  @see fromString(const Calendar::Ptr &, const QString &), fromRawString()
87  */
88  Incidence::Ptr fromString(const QString &string);
89 
90  /**
91  Parses a bytearray, returning the first iCal component as an Incidence, ignoring timezone information.
92 
93  This function is significantly faster than fromString by avoiding the overhead of parsing timezone information.
94  Timezones are instead solely interpreted by using system-timezones.
95 
96  @param string is a utf8 QByteArray containing the data to be parsed.
97 
98  @return non-zero pointer if the parsing was successful; 0 otherwise.
99  @see fromString(const QString &), fromRawString()
100  */
101  Incidence::Ptr readIncidence(const QByteArray &string);
102 
103  /**
104  Parses a string and fills a RecurrenceRule object with the information.
105 
106  @param rule is a pointer to a RecurrenceRule object.
107  @param string is a QString containing the data to be parsed.
108  @return true if successful; false otherwise.
109  */
110  Q_REQUIRED_RESULT bool fromString(RecurrenceRule *rule, const QString &string);
111 
112  /**
113  Parses a string representation of a duration.
114 
115  @param duration iCal representation of a duration.
116  @since 5.95
117  */
118  Q_REQUIRED_RESULT Duration durationFromString(const QString &duration) const;
119 
120  /**
121  @copydoc
122  CalFormat::fromRawString()
123  */
124  Q_REQUIRED_RESULT bool
125  fromRawString(const Calendar::Ptr &calendar, const QByteArray &string, bool deleted = false, const QString &notebook = QString()) override;
126 
127  /**
128  @copydoc
129  CalFormat::toString()
130  */
131  Q_REQUIRED_RESULT QString toString(const Calendar::Ptr &calendar, const QString &notebook = QString(), bool deleted = false) override;
132 
133  /**
134  Converts an Incidence to a QString.
135  @param incidence is a pointer to an Incidence object to be converted
136  into a QString.
137 
138  @return the QString will be Null if the conversion was unsuccessful.
139  */
140  Q_REQUIRED_RESULT QString toString(const Incidence::Ptr &incidence);
141 
142  /**
143  Converts an Incidence to a QByteArray.
144  @param incidence is a pointer to an Incidence object to be converted
145  into a QByteArray.
146 
147  @return the QString will be Null if the conversion was unsuccessful.
148  @since 4.7
149  */
150  Q_REQUIRED_RESULT QByteArray toRawString(const Incidence::Ptr &incidence);
151 
152  /**
153  Converts a RecurrenceRule to a QString.
154  @param rule is a pointer to a RecurrenceRule object to be converted
155  into a QString.
156 
157  @return the QString will be Null if the conversion was unsuccessful.
158  */
159  Q_REQUIRED_RESULT QString toString(RecurrenceRule *rule);
160 
161  /**
162  Converts a Duration to an iCal string.
163  @param duration a Duration object.
164  @return iCal formatted duration
165  @since 5.95
166  */
167  Q_REQUIRED_RESULT QString toString(const Duration &duration) const;
168 
169  /**
170  Converts an Incidence to iCalendar formatted text.
171 
172  @param incidence is a pointer to an Incidence object to be converted
173  into iCal formatted text.
174  @return the QString will be Null if the conversion was unsuccessful.
175  */
176  Q_REQUIRED_RESULT QString toICalString(const Incidence::Ptr &incidence);
177 
178  /**
179  Creates a scheduling message string for an Incidence.
180 
181  @param incidence is a pointer to an IncidenceBase object to be scheduled.
182  @param method is a Scheduler::Method
183 
184  @return a QString containing the message if successful; 0 otherwise.
185  */
186  Q_REQUIRED_RESULT QString createScheduleMessage(const IncidenceBase::Ptr &incidence, iTIPMethod method);
187 
188  /**
189  Parses a Calendar scheduling message string into ScheduleMessage object.
190 
191  @param calendar is a pointer to a Calendar object associated with the
192  scheduling message.
193  @param string is a QString containing the data to be parsed.
194 
195  @return a pointer to a ScheduleMessage object if successful; 0 otherwise.
196  The calling routine may later free the return memory.
197  */
198  ScheduleMessage::Ptr parseScheduleMessage(const Calendar::Ptr &calendar, const QString &string);
199 
200  /**
201  Converts a QString into a FreeBusy object.
202 
203  @param string is a QString containing the data to be parsed.
204  @return a pointer to a FreeBusy object if successful; 0 otherwise.
205 
206  @note Do not attempt to free the FreeBusy memory from the calling routine.
207  */
208  FreeBusy::Ptr parseFreeBusy(const QString &string);
209 
210  /**
211  Sets the iCalendar time zone.
212  @param timeZone is the time zone to set.
213  @see timeZone().
214  */
215  void setTimeZone(const QTimeZone &timeZone);
216 
217  /**
218  Returns the iCalendar time zone.
219  @see setTimeZone().
220  */
221  Q_REQUIRED_RESULT QTimeZone timeZone() const;
222 
223  /**
224  Returns the timezone id string used by the iCalendar; an empty string
225  if the iCalendar does not have a timezone.
226  */
227  Q_REQUIRED_RESULT QByteArray timeZoneId() const;
228 
229 protected:
230 #if KCALENDARCORE_BUILD_DEPRECATED_SINCE(5, 96)
231  /**
232  @copydoc
233  IncidenceBase::virtual_hook()
234  */
235  void virtual_hook(int id, void *data) override;
236 #endif
237 
238 private:
239  //@cond PRIVATE
240  Q_DISABLE_COPY(ICalFormat)
241  Q_DECLARE_PRIVATE(ICalFormat)
242 #if KCALENDARCORE_BUILD_DEPRECATED_SINCE(5, 96)
243  void *unused; // former dptr, just kept for ABI compatibility
244 #endif
245  //@endcond
246 };
247 
248 }
249 
250 #endif
Represents a span of time measured in seconds or days.
Definition: duration.h:43
Namespace for all KCalendarCore types.
Definition: alarm.h:36
iTIPMethod
iTIP methods.
This class represents a recurrence rule for a calendar incidence.
iCalendar format implementation.
Definition: icalformat.h:44
An abstract base class that provides an interface to various calendar formats.
Definition: calformat.h:38
virtual bool fromString(const Calendar::Ptr &calendar, const QString &string, bool deleted, const QString &notebook={})=0
Loads a calendar from a string.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 28 2023 03:53:12 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.