KCalendarCore

vcalformat.h
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 1998 Preston Brown <[email protected]>
5  SPDX-FileCopyrightText: 2001-2003 Cornelius Schumacher <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 /**
10  @file
11  This file is part of the API for handling calendar data and
12  defines the VCalFormat base class.
13 
14  This class implements the vCalendar format. It provides methods for
15  loading/saving/converting vCalendar format data into the internal
16  representation as Calendar and Incidences.
17 
18  @brief
19  vCalendar format implementation.
20 
21  @author Preston Brown <[email protected]>
22  @author Cornelius Schumacher <[email protected]>
23 */
24 
25 #ifndef KCALCORE_VCALFORMAT_H
26 #define KCALCORE_VCALFORMAT_H
27 
28 #include "kcalendarcore_export.h"
29 #include "attendee.h"
30 #include "calformat.h"
31 #include "event.h"
32 #include "todo.h"
33 #include "journal.h"
34 
35 struct VObject;
36 
37 class QDate;
38 
39 #define _VCAL_VERSION "1.0"
40 
41 /* extensions for iMIP / iTIP */
42 #define ICOrganizerProp "X-ORGANIZER"
43 #define ICMethodProp "X-METHOD"
44 #define ICRequestStatusProp "X-REQUEST-STATUS"
45 
46 namespace KCalendarCore
47 {
48 
49 class Event;
50 class Todo;
51 
52 /**
53  @brief
54  vCalendar format implementation.
55 
56  This class implements the vCalendar format. It provides methods for
57  loading/saving/converting vCalendar format data into the internal
58  representation as Calendar and Incidences.
59 */
60 class KCALENDARCORE_EXPORT VCalFormat : public CalFormat
61 {
62 public:
63  /**
64  Constructor a new vCalendar Format object.
65  */
66  VCalFormat();
67 
68  /**
69  Destructor.
70  */
71  ~VCalFormat() override;
72 
73  /**
74  @copydoc
75  CalFormat::load()
76  */
77  bool load(const Calendar::Ptr &calendar, const QString &fileName) override;
78 
79  /**
80  @copydoc
81  CalFormat::save()
82  */
83  bool save(const Calendar::Ptr &calendar, const QString &fileName) override;
84 
85  /**
86  @copydoc
87  CalFormat::fromString()
88  */
89  Q_REQUIRED_RESULT bool fromString(const Calendar::Ptr &calendar, const QString &string,
90  bool deleted = false, const QString &notebook = QString()) override;
91 
92  /**
93  @copydoc
94  CalFormat::toString()
95  */
96  Q_REQUIRED_RESULT QString toString(const Calendar::Ptr &calendar, const QString &notebook = QString(),
97  bool deleted = false) override;
98 
99  /**
100  @copydoc
101  CalFormat::fromRawString()
102  */
103  Q_REQUIRED_RESULT bool fromRawString(const Calendar::Ptr &calendar, const QByteArray &string,
104  bool deleted = false, const QString &notebook = QString()) override;
105 
106 protected:
107  /**
108  Translates a VObject of the TODO type into an Event.
109  @param vtodo is a pointer to a valid VObject object.
110  */
111  Todo::Ptr VTodoToEvent(VObject *vtodo);
112 
113  /**
114  Translates a VObject into a Event and returns a pointer to it.
115  @param vevent is a pointer to a valid VObject object.
116  */
117  Event::Ptr VEventToEvent(VObject *vevent);
118 
119  /**
120  Parse TZ tag from vtimezone.
121  */
122  QString parseTZ(const QByteArray &timezone) const;
123 
124  /**
125  Parse DAYLIGHT tag from vtimezone.
126  */
127  QString parseDst(QByteArray &timezone) const;
128 
129  /**
130  Takes a QDate and returns a string in the format YYYYMMDDTHHMMSS.
131  @param date is the date to format.
132  */
133  QString qDateToISO(const QDate &date);
134 
135  /**
136  Takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS.
137  @param date is the date to format.
138  @param zulu if true, then shift the date to UTC.
139  */
140  QString qDateTimeToISO(const QDateTime &date, bool zulu = true);
141 
142  /**
143  Takes a string in YYYYMMDDTHHMMSS format and returns a valid QDateTime.
144  @param dtStr is a QString containing the date to convert. If this value
145  is invalid, then QDateTime() is returned.
146  */
147  QDateTime ISOToQDateTime(const QString &dtStr);
148 
149  /**
150  Takes a string in the YYYYMMDD format and returns a valid QDate.
151  @param dtStr is a QString containing the date to convert. If this value
152  is invalid, then QDateTime() is returned.
153  */
154  QDate ISOToQDate(const QString &dtStr);
155 
156  /**
157  Parse one of the myriad of ISO8601 timezone offset formats, e.g.
158  +- hh : mm
159  +- hh mm
160  +- hh
161 
162  @param s string to be parsed.
163  @param result timezone offset in seconds, if parse succeeded.
164  @return Whether the parse succeeded or not.
165  */
166  bool parseTZOffsetISO8601(const QString &s, int &result);
167 
168  /**
169  Takes a vCalendar tree of VObjects, and puts all of them that have the
170  "event" property into the dictionary, todos in the todo-list, etc.
171  */
172  void populate(VObject *vcal, bool deleted = false, const QString &notebook = QString());
173 
174  /**
175  Converts a two letter representation of the day (i.e. MO, TU, WE, etc) and
176  returns a number 0-6 corresponding to that ordinal day of the week.
177  @param day is the QString containing the two letter day representation.
178  */
179  int numFromDay(const QString &day);
180 
181  /**
182  Converts a status string into an Attendee::PartStat.
183  @param s is a null-terminated character string containing the status to convert.
184 
185  @return a valid Attendee::PartStat. If the string provided is empty, null,
186  or the contents are unrecognized, then Attendee::NeedsAction is returned.
187  */
188  Attendee::PartStat readStatus(const char *s) const;
189 
190  /**
191  Converts an Attendee::PartStat into a QByteArray string.
192  @param status is the Attendee::PartStat to convert.
193 
194  @return a QByteArray containing the status string.
195  */
196  QByteArray writeStatus(Attendee::PartStat status) const;
197 
198  void readCustomProperties(VObject *o, const Incidence::Ptr &i);
199  void writeCustomProperties(VObject *o, const Incidence::Ptr &i);
200 
201 protected:
202  /**
203  @copydoc
204  IncidenceBase::virtual_hook()
205  */
206  void virtual_hook(int id, void *data) override;
207 
208 private:
209  //@cond PRIVATE
210  Q_DISABLE_COPY(VCalFormat)
211  class Private;
212  Private *const d;
213  //@endcond
214 };
215 
216 }
217 
218 #endif
This file is part of the API for handling calendar data and defines the Attendee class.
An abstract base class that provides an interface to various calendar formats.
Definition: calformat.h:36
This file is part of the API for handling calendar data and defines the CalFormat abstract base class...
PartStat
The different types of participant status.
Definition: attendee.h:65
This file is part of the API for handling calendar data and defines the Todo class.
This file is part of the API for handling calendar data and defines the Journal class.
This file is part of the API for handling calendar data and defines the Event class.
vCalendar format implementation.
Definition: vcalformat.h:60
Namespace for all KCalendarCore types.
Definition: alarm.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Mar 4 2021 22:52:01 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.