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 "attendee.h"
29 #include "calformat.h"
30 #include "event.h"
31 #include "journal.h"
32 #include "kcalendarcore_export.h"
33 #include "todo.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 class Event;
49 class Todo;
50 
51 /**
52  @brief
53  vCalendar format implementation.
54 
55  This class implements the vCalendar format. It provides methods for
56  loading/saving/converting vCalendar format data into the internal
57  representation as Calendar and Incidences.
58 */
59 class KCALENDARCORE_EXPORT VCalFormat : public CalFormat
60 {
61 public:
62  /**
63  Constructor a new vCalendar Format object.
64  */
65  VCalFormat();
66 
67  /**
68  Destructor.
69  */
70  ~VCalFormat() override;
71 
72  /**
73  @copydoc
74  CalFormat::load()
75  */
76  bool load(const Calendar::Ptr &calendar, const QString &fileName) override;
77 
78  /**
79  @copydoc
80  CalFormat::save()
81  */
82  bool save(const Calendar::Ptr &calendar, const QString &fileName) override;
83 
84  /**
85  @copydoc
86  CalFormat::fromString()
87  */
88  Q_REQUIRED_RESULT bool fromString(const Calendar::Ptr &calendar, const QString &string, bool deleted = false, const QString &notebook = QString()) override;
89 
90  /**
91  @copydoc
92  CalFormat::toString()
93  */
94  Q_REQUIRED_RESULT QString toString(const Calendar::Ptr &calendar, const QString &notebook = QString(), bool deleted = false) override;
95 
96  /**
97  @copydoc
98  CalFormat::fromRawString()
99  */
100  Q_REQUIRED_RESULT bool
101  fromRawString(const Calendar::Ptr &calendar, const QByteArray &string, bool deleted = false, const QString &notebook = QString()) override;
102 
103 protected:
104  /**
105  Translates a VObject of the TODO type into an Event.
106  @param vtodo is a pointer to a valid VObject object.
107  */
108  Todo::Ptr VTodoToEvent(VObject *vtodo);
109 
110  /**
111  Translates a VObject into a Event and returns a pointer to it.
112  @param vevent is a pointer to a valid VObject object.
113  */
114  Event::Ptr VEventToEvent(VObject *vevent);
115 
116  /**
117  Parse TZ tag from vtimezone.
118  */
119  QString parseTZ(const QByteArray &timezone) const;
120 
121  /**
122  Parse DAYLIGHT tag from vtimezone.
123  */
124  QString parseDst(QByteArray &timezone) const;
125 
126  /**
127  Takes a QDate and returns a string in the format YYYYMMDDTHHMMSS.
128  @param date is the date to format.
129  */
130  QString qDateToISO(const QDate &date);
131 
132  /**
133  Takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS.
134  @param date is the date to format.
135  @param zulu if true, then shift the date to UTC.
136  */
137  QString qDateTimeToISO(const QDateTime &date, bool zulu = true);
138 
139  /**
140  Takes a string in YYYYMMDDTHHMMSS format and returns a valid QDateTime.
141  @param dtStr is a QString containing the date to convert. If this value
142  is invalid, then QDateTime() is returned.
143  */
144  QDateTime ISOToQDateTime(const QString &dtStr);
145 
146  /**
147  Takes a string in the YYYYMMDD format and returns a valid QDate.
148  @param dtStr is a QString containing the date to convert. If this value
149  is invalid, then QDateTime() is returned.
150  */
151  QDate ISOToQDate(const QString &dtStr);
152 
153  /**
154  Parse one of the myriad of ISO8601 timezone offset formats, e.g.
155  +- hh : mm
156  +- hh mm
157  +- hh
158 
159  @param s string to be parsed.
160  @param result timezone offset in seconds, if parse succeeded.
161  @return Whether the parse succeeded or not.
162  */
163  bool parseTZOffsetISO8601(const QString &s, int &result);
164 
165  /**
166  Takes a vCalendar tree of VObjects, and puts all of them that have the
167  "event" property into the dictionary, todos in the todo-list, etc.
168  */
169  void populate(VObject *vcal, bool deleted = false, const QString &notebook = QString());
170 
171  /**
172  Converts a two letter representation of the day (i.e. MO, TU, WE, etc) and
173  returns a number 0-6 corresponding to that ordinal day of the week.
174  @param day is the QString containing the two letter day representation.
175  */
176  int numFromDay(const QString &day);
177 
178  /**
179  Converts a status string into an Attendee::PartStat.
180  @param s is a null-terminated character string containing the status to convert.
181 
182  @return a valid Attendee::PartStat. If the string provided is empty, null,
183  or the contents are unrecognized, then Attendee::NeedsAction is returned.
184  */
185  Attendee::PartStat readStatus(const char *s) const;
186 
187  /**
188  Converts an Attendee::PartStat into a QByteArray string.
189  @param status is the Attendee::PartStat to convert.
190 
191  @return a QByteArray containing the status string.
192  */
193  QByteArray writeStatus(Attendee::PartStat status) const;
194 
195  void readCustomProperties(VObject *o, const Incidence::Ptr &i);
196  void writeCustomProperties(VObject *o, const Incidence::Ptr &i);
197 
198 protected:
199  /**
200  @copydoc
201  IncidenceBase::virtual_hook()
202  */
203  void virtual_hook(int id, void *data) override;
204 
205 private:
206  //@cond PRIVATE
207  Q_DISABLE_COPY(VCalFormat)
208  class Private;
209  Private *const d;
210  //@endcond
211 };
212 
213 }
214 
215 #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:35
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:64
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:59
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 Sep 23 2021 22:51:47 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.