1/*
2 This file is part of the kcal library.
3
4 Copyright (c) 1998 Preston Brown <pbrown@kde.org>
5 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
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
25 defines the VCalFormat base class.
26
27 This class implements the vCalendar format. It provides methods for
28 loading/saving/converting vCalendar format data into the internal
29 representation as Calendar and Incidences.
30
31 @brief
32 vCalendar format implementation.
33
34 @author Preston Brown \<pbrown@kde.org\>
35 @author Cornelius Schumacher \<schumacher@kde.org\>
36*/
37
38#ifndef KCAL_VCALFORMAT_H
39#define KCAL_VCALFORMAT_H
40
41#include "calformat.h"
42#include "todo.h"
43#include "event.h"
44#include "kcal_export.h"
45
46#include <kdatetime.h>
47
48#include <QtCore/QByteArray>
49
50#define _VCAL_VERSION "1.0"
51
52struct VObject;
53
54namespace KCal {
55
56class KCAL_DEPRECATED_EXPORT VCalFormat : public CalFormat
57{
58 public:
59 VCalFormat();
60 virtual ~VCalFormat();
61
62 /**
63 @copydoc
64 CalFormat::load()
65 */
66 bool load( Calendar *calendar, const QString &fileName );
67
68 /**
69 @copydoc
70 CalFormat::save()
71 */
72 bool save( Calendar *calendar, const QString &fileName );
73
74 /**
75 @copydoc
76 CalFormat::fromString()
77 */
78 bool fromString( Calendar *calendar, const QString &string );
79
80 /**
81 @copydoc
82 CalFormat::toString()
83 */
84 QString toString( Calendar *calendar );
85
86 /**
87 @copydoc
88 CalFormat::fromRawString()
89 */
90 bool fromRawString( Calendar *calendar, const QByteArray &string );
91
92 protected:
93 /**
94 Translates a VObject of the TODO type into an Event.
95 */
96 Todo *VTodoToEvent( VObject *vtodo );
97
98 /**
99 Translates a VObject into a Event and returns a pointer to it.
100 */
101 Event *VEventToEvent( VObject *vevent );
102
103 /**
104 Translates an Event into a VTodo-type VObject and return pointer.
105 */
106 VObject *eventToVTodo( const Todo *anEvent );
107
108 /**
109 Translates an Event into a VObject and returns a pointer to it.
110 */
111 VObject *eventToVEvent( const Event *anEvent );
112
113 /**
114 Takes a QDate and returns a string in the format YYYYMMDDTHHMMSS.
115 */
116 QString qDateToISO( const QDate &date );
117
118 /**
119 Takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS.
120 */
121 QString kDateTimeToISO( const KDateTime &date, bool zulu=true );
122
123 /**
124 Takes a string in YYYYMMDDTHHMMSS format and returns a valid QDateTime.
125 */
126 KDateTime ISOToKDateTime( const QString &dtStr );
127
128 /**
129 Takes a string in the YYYYMMDD format and returns a valid QDate.
130 */
131 QDate ISOToQDate( const QString &dtStr );
132
133 /**
134 Takes a vCalendar tree of VObjects, and puts all of them that have the
135 "event" property into the dictionary, todos in the todo-list, etc.
136 */
137 void populate( VObject *vcal );
138
139 /**
140 Takes a number 0 - 6 and returns the two letter string of that day,
141 i.e. MO, TU, WE, etc.
142
143 @param day number of the day to get a two letter name for. Range @c 0 - @c 6
144 */
145 const char *dayFromNum( int day );
146
147 /** the reverse of the above function. */
148 int numFromDay( const QString &day );
149
150 Attendee::PartStat readStatus( const char *s ) const;
151 QByteArray writeStatus( Attendee::PartStat status ) const;
152
153 private:
154 /**
155 The Pilot synchronization states.
156 */
157 enum PilotState {
158 SYNCNONE = 0,
159 SYNCMOD = 1,
160 SYNCDEL = 3
161 };
162
163 //@cond PRIVATE
164 Q_DISABLE_COPY( VCalFormat )
165 class Private;
166 Private *const d;
167 //@endcond
168};
169
170}
171
172#endif
173