author | zautrix <zautrix> | 2004-07-11 09:44:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-11 09:44:35 (UTC) |
commit | 2aeb681a7e8a0696608485f36d9c0561ba505c5c (patch) (unidiff) | |
tree | 72918e536cb8d447e6e8acb213294299ec09de56 | |
parent | e5707eabc31da78bc299029de2cefd84d77291cd (diff) | |
download | kdepimpi-2aeb681a7e8a0696608485f36d9c0561ba505c5c.zip kdepimpi-2aeb681a7e8a0696608485f36d9c0561ba505c5c.tar.gz kdepimpi-2aeb681a7e8a0696608485f36d9c0561ba505c5c.tar.bz2 |
removed two debug output
-rw-r--r-- | libkcal/icalformatimpl.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 964ffe3..3437f45 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -1,2174 +1,2174 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qdatetime.h> | 21 | #include <qdatetime.h> |
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | #include <qptrlist.h> | 23 | #include <qptrlist.h> |
24 | #include <qfile.h> | 24 | #include <qfile.h> |
25 | 25 | ||
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kglobal.h> | 28 | #include <kglobal.h> |
29 | 29 | ||
30 | extern "C" { | 30 | extern "C" { |
31 | #include <ical.h> | 31 | #include <ical.h> |
32 | #include <icalss.h> | 32 | #include <icalss.h> |
33 | #include <icalparser.h> | 33 | #include <icalparser.h> |
34 | #include <icalrestriction.h> | 34 | #include <icalrestriction.h> |
35 | } | 35 | } |
36 | 36 | ||
37 | #include "calendar.h" | 37 | #include "calendar.h" |
38 | #include "journal.h" | 38 | #include "journal.h" |
39 | #include "icalformat.h" | 39 | #include "icalformat.h" |
40 | #include "icalformatimpl.h" | 40 | #include "icalformatimpl.h" |
41 | #include "compat.h" | 41 | #include "compat.h" |
42 | 42 | ||
43 | #define _ICAL_VERSION "2.0" | 43 | #define _ICAL_VERSION "2.0" |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | const int gSecondsPerMinute = 60; | 47 | const int gSecondsPerMinute = 60; |
48 | const int gSecondsPerHour = gSecondsPerMinute * 60; | 48 | const int gSecondsPerHour = gSecondsPerMinute * 60; |
49 | const int gSecondsPerDay = gSecondsPerHour * 24; | 49 | const int gSecondsPerDay = gSecondsPerHour * 24; |
50 | const int gSecondsPerWeek = gSecondsPerDay * 7; | 50 | const int gSecondsPerWeek = gSecondsPerDay * 7; |
51 | 51 | ||
52 | ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) : | 52 | ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) : |
53 | mParent( parent ), mCalendarVersion( 0 ) | 53 | mParent( parent ), mCalendarVersion( 0 ) |
54 | { | 54 | { |
55 | mCompat = new Compat; | 55 | mCompat = new Compat; |
56 | } | 56 | } |
57 | 57 | ||
58 | ICalFormatImpl::~ICalFormatImpl() | 58 | ICalFormatImpl::~ICalFormatImpl() |
59 | { | 59 | { |
60 | delete mCompat; | 60 | delete mCompat; |
61 | } | 61 | } |
62 | 62 | ||
63 | class ToStringVisitor : public Incidence::Visitor | 63 | class ToStringVisitor : public Incidence::Visitor |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {} | 66 | ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {} |
67 | 67 | ||
68 | bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; } | 68 | bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; } |
69 | bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; } | 69 | bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; } |
70 | bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; } | 70 | bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; } |
71 | 71 | ||
72 | icalcomponent *component() { return mComponent; } | 72 | icalcomponent *component() { return mComponent; } |
73 | 73 | ||
74 | private: | 74 | private: |
75 | ICalFormatImpl *mImpl; | 75 | ICalFormatImpl *mImpl; |
76 | icalcomponent *mComponent; | 76 | icalcomponent *mComponent; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence) | 79 | icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence) |
80 | { | 80 | { |
81 | ToStringVisitor v( this ); | 81 | ToStringVisitor v( this ); |
82 | incidence->accept(v); | 82 | incidence->accept(v); |
83 | return v.component(); | 83 | return v.component(); |
84 | } | 84 | } |
85 | 85 | ||
86 | icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) | 86 | icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) |
87 | { | 87 | { |
88 | QString tmpStr; | 88 | QString tmpStr; |
89 | QStringList tmpStrList; | 89 | QStringList tmpStrList; |
90 | 90 | ||
91 | icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT); | 91 | icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT); |
92 | 92 | ||
93 | writeIncidence(vtodo,todo); | 93 | writeIncidence(vtodo,todo); |
94 | 94 | ||
95 | // due date | 95 | // due date |
96 | if (todo->hasDueDate()) { | 96 | if (todo->hasDueDate()) { |
97 | icaltimetype due; | 97 | icaltimetype due; |
98 | if (todo->doesFloat()) { | 98 | if (todo->doesFloat()) { |
99 | due = writeICalDate(todo->dtDue().date()); | 99 | due = writeICalDate(todo->dtDue().date()); |
100 | } else { | 100 | } else { |
101 | due = writeICalDateTime(todo->dtDue()); | 101 | due = writeICalDateTime(todo->dtDue()); |
102 | } | 102 | } |
103 | icalcomponent_add_property(vtodo,icalproperty_new_due(due)); | 103 | icalcomponent_add_property(vtodo,icalproperty_new_due(due)); |
104 | } | 104 | } |
105 | 105 | ||
106 | // start time | 106 | // start time |
107 | if (todo->hasStartDate()) { | 107 | if (todo->hasStartDate()) { |
108 | icaltimetype start; | 108 | icaltimetype start; |
109 | if (todo->doesFloat()) { | 109 | if (todo->doesFloat()) { |
110 | // kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl; | 110 | // kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl; |
111 | start = writeICalDate(todo->dtStart().date()); | 111 | start = writeICalDate(todo->dtStart().date()); |
112 | } else { | 112 | } else { |
113 | // kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; | 113 | // kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; |
114 | start = writeICalDateTime(todo->dtStart()); | 114 | start = writeICalDateTime(todo->dtStart()); |
115 | } | 115 | } |
116 | icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); | 116 | icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); |
117 | } | 117 | } |
118 | 118 | ||
119 | // completion date | 119 | // completion date |
120 | if (todo->isCompleted()) { | 120 | if (todo->isCompleted()) { |
121 | if (!todo->hasCompletedDate()) { | 121 | if (!todo->hasCompletedDate()) { |
122 | // If todo was created by KOrganizer <2.2 it has no correct completion | 122 | // If todo was created by KOrganizer <2.2 it has no correct completion |
123 | // date. Set it to now. | 123 | // date. Set it to now. |
124 | todo->setCompleted(QDateTime::currentDateTime()); | 124 | todo->setCompleted(QDateTime::currentDateTime()); |
125 | } | 125 | } |
126 | icaltimetype completed = writeICalDateTime(todo->completed()); | 126 | icaltimetype completed = writeICalDateTime(todo->completed()); |
127 | icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); | 127 | icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); |
128 | } | 128 | } |
129 | 129 | ||
130 | icalcomponent_add_property(vtodo, | 130 | icalcomponent_add_property(vtodo, |
131 | icalproperty_new_percentcomplete(todo->percentComplete())); | 131 | icalproperty_new_percentcomplete(todo->percentComplete())); |
132 | 132 | ||
133 | return vtodo; | 133 | return vtodo; |
134 | } | 134 | } |
135 | 135 | ||
136 | icalcomponent *ICalFormatImpl::writeEvent(Event *event) | 136 | icalcomponent *ICalFormatImpl::writeEvent(Event *event) |
137 | { | 137 | { |
138 | kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() | 138 | kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() |
139 | << ")" << endl; | 139 | << ")" << endl; |
140 | 140 | ||
141 | QString tmpStr; | 141 | QString tmpStr; |
142 | QStringList tmpStrList; | 142 | QStringList tmpStrList; |
143 | 143 | ||
144 | icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); | 144 | icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); |
145 | 145 | ||
146 | writeIncidence(vevent,event); | 146 | writeIncidence(vevent,event); |
147 | 147 | ||
148 | // start time | 148 | // start time |
149 | icaltimetype start; | 149 | icaltimetype start; |
150 | if (event->doesFloat()) { | 150 | if (event->doesFloat()) { |
151 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; | 151 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; |
152 | start = writeICalDate(event->dtStart().date()); | 152 | start = writeICalDate(event->dtStart().date()); |
153 | } else { | 153 | } else { |
154 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; | 154 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; |
155 | start = writeICalDateTime(event->dtStart()); | 155 | start = writeICalDateTime(event->dtStart()); |
156 | } | 156 | } |
157 | icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); | 157 | icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); |
158 | 158 | ||
159 | if (event->hasEndDate()) { | 159 | if (event->hasEndDate()) { |
160 | // end time | 160 | // end time |
161 | icaltimetype end; | 161 | icaltimetype end; |
162 | if (event->doesFloat()) { | 162 | if (event->doesFloat()) { |
163 | // kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; | 163 | // kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; |
164 | // +1 day because end date is non-inclusive. | 164 | // +1 day because end date is non-inclusive. |
165 | end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); | 165 | end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); |
166 | } else { | 166 | } else { |
167 | // kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; | 167 | // kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; |
168 | end = writeICalDateTime(event->dtEnd()); | 168 | end = writeICalDateTime(event->dtEnd()); |
169 | } | 169 | } |
170 | icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); | 170 | icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); |
171 | } | 171 | } |
172 | 172 | ||
173 | // TODO: attachments, resources | 173 | // TODO: attachments, resources |
174 | #if 0 | 174 | #if 0 |
175 | // attachments | 175 | // attachments |
176 | tmpStrList = anEvent->attachments(); | 176 | tmpStrList = anEvent->attachments(); |
177 | for ( QStringList::Iterator it = tmpStrList.begin(); | 177 | for ( QStringList::Iterator it = tmpStrList.begin(); |
178 | it != tmpStrList.end(); | 178 | it != tmpStrList.end(); |
179 | ++it ) | 179 | ++it ) |
180 | addPropValue(vevent, VCAttachProp, (*it).utf8()); | 180 | addPropValue(vevent, VCAttachProp, (*it).utf8()); |
181 | 181 | ||
182 | // resources | 182 | // resources |
183 | tmpStrList = anEvent->resources(); | 183 | tmpStrList = anEvent->resources(); |
184 | tmpStr = tmpStrList.join(";"); | 184 | tmpStr = tmpStrList.join(";"); |
185 | if (!tmpStr.isEmpty()) | 185 | if (!tmpStr.isEmpty()) |
186 | addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); | 186 | addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); |
187 | 187 | ||
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | // Transparency | 190 | // Transparency |
191 | switch( event->transparency() ) { | 191 | switch( event->transparency() ) { |
192 | case Event::Transparent: | 192 | case Event::Transparent: |
193 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); | 193 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); |
194 | break; | 194 | break; |
195 | case Event::Opaque: | 195 | case Event::Opaque: |
196 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); | 196 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); |
197 | break; | 197 | break; |
198 | } | 198 | } |
199 | 199 | ||
200 | return vevent; | 200 | return vevent; |
201 | } | 201 | } |
202 | 202 | ||
203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, | 203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, |
204 | Scheduler::Method method) | 204 | Scheduler::Method method) |
205 | { | 205 | { |
206 | #if QT_VERSION >= 300 | 206 | #if QT_VERSION >= 300 |
207 | kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: " | 207 | kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: " |
208 | << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: " | 208 | << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: " |
209 | << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl; | 209 | << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl; |
210 | #endif | 210 | #endif |
211 | 211 | ||
212 | icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); | 212 | icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); |
213 | 213 | ||
214 | writeIncidenceBase(vfreebusy,freebusy); | 214 | writeIncidenceBase(vfreebusy,freebusy); |
215 | 215 | ||
216 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( | 216 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( |
217 | writeICalDateTime(freebusy->dtStart()))); | 217 | writeICalDateTime(freebusy->dtStart()))); |
218 | 218 | ||
219 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( | 219 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( |
220 | writeICalDateTime(freebusy->dtEnd()))); | 220 | writeICalDateTime(freebusy->dtEnd()))); |
221 | 221 | ||
222 | if (method == Scheduler::Request) { | 222 | if (method == Scheduler::Request) { |
223 | icalcomponent_add_property(vfreebusy,icalproperty_new_uid( | 223 | icalcomponent_add_property(vfreebusy,icalproperty_new_uid( |
224 | freebusy->uid().utf8())); | 224 | freebusy->uid().utf8())); |
225 | } | 225 | } |
226 | 226 | ||
227 | //Loops through all the periods in the freebusy object | 227 | //Loops through all the periods in the freebusy object |
228 | QValueList<Period> list = freebusy->busyPeriods(); | 228 | QValueList<Period> list = freebusy->busyPeriods(); |
229 | QValueList<Period>::Iterator it; | 229 | QValueList<Period>::Iterator it; |
230 | icalperiodtype period; | 230 | icalperiodtype period; |
231 | for (it = list.begin(); it!= list.end(); ++it) { | 231 | for (it = list.begin(); it!= list.end(); ++it) { |
232 | period.start = writeICalDateTime((*it).start()); | 232 | period.start = writeICalDateTime((*it).start()); |
233 | period.end = writeICalDateTime((*it).end()); | 233 | period.end = writeICalDateTime((*it).end()); |
234 | icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); | 234 | icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); |
235 | } | 235 | } |
236 | 236 | ||
237 | return vfreebusy; | 237 | return vfreebusy; |
238 | } | 238 | } |
239 | 239 | ||
240 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) | 240 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) |
241 | { | 241 | { |
242 | icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); | 242 | icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); |
243 | 243 | ||
244 | writeIncidence(vjournal,journal); | 244 | writeIncidence(vjournal,journal); |
245 | 245 | ||
246 | // start time | 246 | // start time |
247 | if (journal->dtStart().isValid()) { | 247 | if (journal->dtStart().isValid()) { |
248 | icaltimetype start; | 248 | icaltimetype start; |
249 | if (journal->doesFloat()) { | 249 | if (journal->doesFloat()) { |
250 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; | 250 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; |
251 | start = writeICalDate(journal->dtStart().date()); | 251 | start = writeICalDate(journal->dtStart().date()); |
252 | } else { | 252 | } else { |
253 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; | 253 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; |
254 | start = writeICalDateTime(journal->dtStart()); | 254 | start = writeICalDateTime(journal->dtStart()); |
255 | } | 255 | } |
256 | icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); | 256 | icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); |
257 | } | 257 | } |
258 | 258 | ||
259 | return vjournal; | 259 | return vjournal; |
260 | } | 260 | } |
261 | 261 | ||
262 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | 262 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) |
263 | { | 263 | { |
264 | // pilot sync stuff | 264 | // pilot sync stuff |
265 | // TODO: move this application-specific code to kpilot | 265 | // TODO: move this application-specific code to kpilot |
266 | if (incidence->pilotId()) { | 266 | if (incidence->pilotId()) { |
267 | incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); | 267 | incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); |
268 | incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); | 268 | incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); |
269 | } | 269 | } |
270 | if (incidence->zaurusId() >= 0) { | 270 | if (incidence->zaurusId() >= 0) { |
271 | incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId())); | 271 | incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId())); |
272 | } | 272 | } |
273 | 273 | ||
274 | if (incidence->zaurusUid() > 0) { | 274 | if (incidence->zaurusUid() > 0) { |
275 | incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid())); | 275 | incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid())); |
276 | } | 276 | } |
277 | if (incidence->zaurusStat() > 0) { | 277 | if (incidence->zaurusStat() > 0) { |
278 | incidence->setNonKDECustomProperty("X-ZAURUSSTAT", QString::number(incidence->zaurusStat())); | 278 | incidence->setNonKDECustomProperty("X-ZAURUSSTAT", QString::number(incidence->zaurusStat())); |
279 | } | 279 | } |
280 | 280 | ||
281 | writeIncidenceBase(parent,incidence); | 281 | writeIncidenceBase(parent,incidence); |
282 | if (incidence->cancelled()) { | 282 | if (incidence->cancelled()) { |
283 | icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); | 283 | icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); |
284 | } | 284 | } |
285 | 285 | ||
286 | // creation date | 286 | // creation date |
287 | icalcomponent_add_property(parent,icalproperty_new_created( | 287 | icalcomponent_add_property(parent,icalproperty_new_created( |
288 | writeICalDateTime(incidence->created()))); | 288 | writeICalDateTime(incidence->created()))); |
289 | 289 | ||
290 | // unique id | 290 | // unique id |
291 | icalcomponent_add_property(parent,icalproperty_new_uid( | 291 | icalcomponent_add_property(parent,icalproperty_new_uid( |
292 | incidence->uid().utf8())); | 292 | incidence->uid().utf8())); |
293 | 293 | ||
294 | // revision | 294 | // revision |
295 | icalcomponent_add_property(parent,icalproperty_new_sequence( | 295 | icalcomponent_add_property(parent,icalproperty_new_sequence( |
296 | incidence->revision())); | 296 | incidence->revision())); |
297 | 297 | ||
298 | // last modification date | 298 | // last modification date |
299 | icalcomponent_add_property(parent,icalproperty_new_lastmodified( | 299 | icalcomponent_add_property(parent,icalproperty_new_lastmodified( |
300 | writeICalDateTime(incidence->lastModified()))); | 300 | writeICalDateTime(incidence->lastModified()))); |
301 | 301 | ||
302 | // description | 302 | // description |
303 | if (!incidence->description().isEmpty()) { | 303 | if (!incidence->description().isEmpty()) { |
304 | icalcomponent_add_property(parent,icalproperty_new_description( | 304 | icalcomponent_add_property(parent,icalproperty_new_description( |
305 | incidence->description().utf8())); | 305 | incidence->description().utf8())); |
306 | } | 306 | } |
307 | 307 | ||
308 | // summary | 308 | // summary |
309 | if (!incidence->summary().isEmpty()) { | 309 | if (!incidence->summary().isEmpty()) { |
310 | icalcomponent_add_property(parent,icalproperty_new_summary( | 310 | icalcomponent_add_property(parent,icalproperty_new_summary( |
311 | incidence->summary().utf8())); | 311 | incidence->summary().utf8())); |
312 | } | 312 | } |
313 | 313 | ||
314 | // location | 314 | // location |
315 | if (!incidence->location().isEmpty()) { | 315 | if (!incidence->location().isEmpty()) { |
316 | icalcomponent_add_property(parent,icalproperty_new_location( | 316 | icalcomponent_add_property(parent,icalproperty_new_location( |
317 | incidence->location().utf8())); | 317 | incidence->location().utf8())); |
318 | } | 318 | } |
319 | 319 | ||
320 | // TODO: | 320 | // TODO: |
321 | // status | 321 | // status |
322 | // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); | 322 | // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); |
323 | 323 | ||
324 | // secrecy | 324 | // secrecy |
325 | enum icalproperty_class classInt; | 325 | enum icalproperty_class classInt; |
326 | switch (incidence->secrecy()) { | 326 | switch (incidence->secrecy()) { |
327 | case Incidence::SecrecyPublic: | 327 | case Incidence::SecrecyPublic: |
328 | classInt = ICAL_CLASS_PUBLIC; | 328 | classInt = ICAL_CLASS_PUBLIC; |
329 | break; | 329 | break; |
330 | case Incidence::SecrecyConfidential: | 330 | case Incidence::SecrecyConfidential: |
331 | classInt = ICAL_CLASS_CONFIDENTIAL; | 331 | classInt = ICAL_CLASS_CONFIDENTIAL; |
332 | break; | 332 | break; |
333 | case Incidence::SecrecyPrivate: | 333 | case Incidence::SecrecyPrivate: |
334 | classInt =ICAL_CLASS_PRIVATE ; | 334 | classInt =ICAL_CLASS_PRIVATE ; |
335 | default: | 335 | default: |
336 | classInt =ICAL_CLASS_PRIVATE ; | 336 | classInt =ICAL_CLASS_PRIVATE ; |
337 | break; | 337 | break; |
338 | } | 338 | } |
339 | icalcomponent_add_property(parent,icalproperty_new_class(classInt)); | 339 | icalcomponent_add_property(parent,icalproperty_new_class(classInt)); |
340 | 340 | ||
341 | // priority | 341 | // priority |
342 | icalcomponent_add_property(parent,icalproperty_new_priority( | 342 | icalcomponent_add_property(parent,icalproperty_new_priority( |
343 | incidence->priority())); | 343 | incidence->priority())); |
344 | 344 | ||
345 | // categories | 345 | // categories |
346 | QStringList categories = incidence->categories(); | 346 | QStringList categories = incidence->categories(); |
347 | QStringList::Iterator it; | 347 | QStringList::Iterator it; |
348 | for(it = categories.begin(); it != categories.end(); ++it ) { | 348 | for(it = categories.begin(); it != categories.end(); ++it ) { |
349 | icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); | 349 | icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); |
350 | } | 350 | } |
351 | // TODO: Ensure correct concatenation of categories properties. | 351 | // TODO: Ensure correct concatenation of categories properties. |
352 | 352 | ||
353 | /* | 353 | /* |
354 | // categories | 354 | // categories |
355 | tmpStrList = incidence->getCategories(); | 355 | tmpStrList = incidence->getCategories(); |
356 | tmpStr = ""; | 356 | tmpStr = ""; |
357 | QString catStr; | 357 | QString catStr; |
358 | for ( QStringList::Iterator it = tmpStrList.begin(); | 358 | for ( QStringList::Iterator it = tmpStrList.begin(); |
359 | it != tmpStrList.end(); | 359 | it != tmpStrList.end(); |
360 | ++it ) { | 360 | ++it ) { |
361 | catStr = *it; | 361 | catStr = *it; |
362 | if (catStr[0] == ' ') | 362 | if (catStr[0] == ' ') |
363 | tmpStr += catStr.mid(1); | 363 | tmpStr += catStr.mid(1); |
364 | else | 364 | else |
365 | tmpStr += catStr; | 365 | tmpStr += catStr; |
366 | // this must be a ';' character as the vCalendar specification requires! | 366 | // this must be a ';' character as the vCalendar specification requires! |
367 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 367 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
368 | // read in. | 368 | // read in. |
369 | tmpStr += ";"; | 369 | tmpStr += ";"; |
370 | } | 370 | } |
371 | if (!tmpStr.isEmpty()) { | 371 | if (!tmpStr.isEmpty()) { |
372 | tmpStr.truncate(tmpStr.length()-1); | 372 | tmpStr.truncate(tmpStr.length()-1); |
373 | icalcomponent_add_property(parent,icalproperty_new_categories( | 373 | icalcomponent_add_property(parent,icalproperty_new_categories( |
374 | writeText(incidence->getCategories().join(";")))); | 374 | writeText(incidence->getCategories().join(";")))); |
375 | } | 375 | } |
376 | */ | 376 | */ |
377 | 377 | ||
378 | // related event | 378 | // related event |
379 | if (incidence->relatedTo()) { | 379 | if (incidence->relatedTo()) { |
380 | icalcomponent_add_property(parent,icalproperty_new_relatedto( | 380 | icalcomponent_add_property(parent,icalproperty_new_relatedto( |
381 | incidence->relatedTo()->uid().utf8())); | 381 | incidence->relatedTo()->uid().utf8())); |
382 | } | 382 | } |
383 | 383 | ||
384 | // recurrence rule stuff | 384 | // recurrence rule stuff |
385 | Recurrence *recur = incidence->recurrence(); | 385 | Recurrence *recur = incidence->recurrence(); |
386 | if (recur->doesRecur()) { | 386 | if (recur->doesRecur()) { |
387 | 387 | ||
388 | icalcomponent_add_property(parent,writeRecurrenceRule(recur)); | 388 | icalcomponent_add_property(parent,writeRecurrenceRule(recur)); |
389 | } | 389 | } |
390 | 390 | ||
391 | // recurrence excpetion dates | 391 | // recurrence excpetion dates |
392 | DateList dateList = incidence->exDates(); | 392 | DateList dateList = incidence->exDates(); |
393 | DateList::ConstIterator exIt; | 393 | DateList::ConstIterator exIt; |
394 | for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { | 394 | for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { |
395 | icalcomponent_add_property(parent,icalproperty_new_exdate( | 395 | icalcomponent_add_property(parent,icalproperty_new_exdate( |
396 | writeICalDate(*exIt))); | 396 | writeICalDate(*exIt))); |
397 | } | 397 | } |
398 | 398 | ||
399 | // attachments | 399 | // attachments |
400 | QPtrList<Attachment> attachments = incidence->attachments(); | 400 | QPtrList<Attachment> attachments = incidence->attachments(); |
401 | for (Attachment *at = attachments.first(); at; at = attachments.next()) | 401 | for (Attachment *at = attachments.first(); at; at = attachments.next()) |
402 | icalcomponent_add_property(parent,writeAttachment(at)); | 402 | icalcomponent_add_property(parent,writeAttachment(at)); |
403 | 403 | ||
404 | // alarms | 404 | // alarms |
405 | QPtrList<Alarm> alarms = incidence->alarms(); | 405 | QPtrList<Alarm> alarms = incidence->alarms(); |
406 | Alarm* alarm; | 406 | Alarm* alarm; |
407 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 407 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
408 | if (alarm->enabled()) { | 408 | if (alarm->enabled()) { |
409 | kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; | 409 | kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; |
410 | icalcomponent_add_component(parent,writeAlarm(alarm)); | 410 | icalcomponent_add_component(parent,writeAlarm(alarm)); |
411 | } | 411 | } |
412 | } | 412 | } |
413 | 413 | ||
414 | // duration | 414 | // duration |
415 | 415 | ||
416 | // turned off as it always is set to PTS0 (and must not occur together with DTEND | 416 | // turned off as it always is set to PTS0 (and must not occur together with DTEND |
417 | 417 | ||
418 | // if (incidence->hasDuration()) { | 418 | // if (incidence->hasDuration()) { |
419 | // icaldurationtype duration; | 419 | // icaldurationtype duration; |
420 | // duration = writeICalDuration(incidence->duration()); | 420 | // duration = writeICalDuration(incidence->duration()); |
421 | // icalcomponent_add_property(parent,icalproperty_new_duration(duration)); | 421 | // icalcomponent_add_property(parent,icalproperty_new_duration(duration)); |
422 | // } | 422 | // } |
423 | } | 423 | } |
424 | 424 | ||
425 | void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 425 | void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) |
426 | { | 426 | { |
427 | icalcomponent_add_property(parent,icalproperty_new_dtstamp( | 427 | icalcomponent_add_property(parent,icalproperty_new_dtstamp( |
428 | writeICalDateTime(QDateTime::currentDateTime()))); | 428 | writeICalDateTime(QDateTime::currentDateTime()))); |
429 | 429 | ||
430 | // organizer stuff | 430 | // organizer stuff |
431 | icalcomponent_add_property(parent,icalproperty_new_organizer( | 431 | icalcomponent_add_property(parent,icalproperty_new_organizer( |
432 | ("MAILTO:" + incidenceBase->organizer()).utf8())); | 432 | ("MAILTO:" + incidenceBase->organizer()).utf8())); |
433 | 433 | ||
434 | // attendees | 434 | // attendees |
435 | if (incidenceBase->attendeeCount() != 0) { | 435 | if (incidenceBase->attendeeCount() != 0) { |
436 | QPtrList<Attendee> al = incidenceBase->attendees(); | 436 | QPtrList<Attendee> al = incidenceBase->attendees(); |
437 | QPtrListIterator<Attendee> ai(al); | 437 | QPtrListIterator<Attendee> ai(al); |
438 | for (; ai.current(); ++ai) { | 438 | for (; ai.current(); ++ai) { |
439 | icalcomponent_add_property(parent,writeAttendee(ai.current())); | 439 | icalcomponent_add_property(parent,writeAttendee(ai.current())); |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | // custom properties | 443 | // custom properties |
444 | writeCustomProperties(parent, incidenceBase); | 444 | writeCustomProperties(parent, incidenceBase); |
445 | } | 445 | } |
446 | 446 | ||
447 | void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) | 447 | void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) |
448 | { | 448 | { |
449 | QMap<QCString, QString> custom = properties->customProperties(); | 449 | QMap<QCString, QString> custom = properties->customProperties(); |
450 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { | 450 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { |
451 | icalproperty *p = icalproperty_new_x(c.data().utf8()); | 451 | icalproperty *p = icalproperty_new_x(c.data().utf8()); |
452 | icalproperty_set_x_name(p,c.key()); | 452 | icalproperty_set_x_name(p,c.key()); |
453 | icalcomponent_add_property(parent,p); | 453 | icalcomponent_add_property(parent,p); |
454 | } | 454 | } |
455 | } | 455 | } |
456 | 456 | ||
457 | icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) | 457 | icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) |
458 | { | 458 | { |
459 | icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); | 459 | icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); |
460 | 460 | ||
461 | if (!attendee->name().isEmpty()) { | 461 | if (!attendee->name().isEmpty()) { |
462 | icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); | 462 | icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | icalproperty_add_parameter(p,icalparameter_new_rsvp( | 466 | icalproperty_add_parameter(p,icalparameter_new_rsvp( |
467 | attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); | 467 | attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); |
468 | 468 | ||
469 | icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; | 469 | icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; |
470 | switch (attendee->status()) { | 470 | switch (attendee->status()) { |
471 | default: | 471 | default: |
472 | case Attendee::NeedsAction: | 472 | case Attendee::NeedsAction: |
473 | status = ICAL_PARTSTAT_NEEDSACTION; | 473 | status = ICAL_PARTSTAT_NEEDSACTION; |
474 | break; | 474 | break; |
475 | case Attendee::Accepted: | 475 | case Attendee::Accepted: |
476 | status = ICAL_PARTSTAT_ACCEPTED; | 476 | status = ICAL_PARTSTAT_ACCEPTED; |
477 | break; | 477 | break; |
478 | case Attendee::Declined: | 478 | case Attendee::Declined: |
479 | status = ICAL_PARTSTAT_DECLINED; | 479 | status = ICAL_PARTSTAT_DECLINED; |
480 | break; | 480 | break; |
481 | case Attendee::Tentative: | 481 | case Attendee::Tentative: |
482 | status = ICAL_PARTSTAT_TENTATIVE; | 482 | status = ICAL_PARTSTAT_TENTATIVE; |
483 | break; | 483 | break; |
484 | case Attendee::Delegated: | 484 | case Attendee::Delegated: |
485 | status = ICAL_PARTSTAT_DELEGATED; | 485 | status = ICAL_PARTSTAT_DELEGATED; |
486 | break; | 486 | break; |
487 | case Attendee::Completed: | 487 | case Attendee::Completed: |
488 | status = ICAL_PARTSTAT_COMPLETED; | 488 | status = ICAL_PARTSTAT_COMPLETED; |
489 | break; | 489 | break; |
490 | case Attendee::InProcess: | 490 | case Attendee::InProcess: |
491 | status = ICAL_PARTSTAT_INPROCESS; | 491 | status = ICAL_PARTSTAT_INPROCESS; |
492 | break; | 492 | break; |
493 | } | 493 | } |
494 | icalproperty_add_parameter(p,icalparameter_new_partstat(status)); | 494 | icalproperty_add_parameter(p,icalparameter_new_partstat(status)); |
495 | 495 | ||
496 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; | 496 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; |
497 | switch (attendee->role()) { | 497 | switch (attendee->role()) { |
498 | case Attendee::Chair: | 498 | case Attendee::Chair: |
499 | role = ICAL_ROLE_CHAIR; | 499 | role = ICAL_ROLE_CHAIR; |
500 | break; | 500 | break; |
501 | default: | 501 | default: |
502 | case Attendee::ReqParticipant: | 502 | case Attendee::ReqParticipant: |
503 | role = ICAL_ROLE_REQPARTICIPANT; | 503 | role = ICAL_ROLE_REQPARTICIPANT; |
504 | break; | 504 | break; |
505 | case Attendee::OptParticipant: | 505 | case Attendee::OptParticipant: |
506 | role = ICAL_ROLE_OPTPARTICIPANT; | 506 | role = ICAL_ROLE_OPTPARTICIPANT; |
507 | break; | 507 | break; |
508 | case Attendee::NonParticipant: | 508 | case Attendee::NonParticipant: |
509 | role = ICAL_ROLE_NONPARTICIPANT; | 509 | role = ICAL_ROLE_NONPARTICIPANT; |
510 | break; | 510 | break; |
511 | } | 511 | } |
512 | icalproperty_add_parameter(p,icalparameter_new_role(role)); | 512 | icalproperty_add_parameter(p,icalparameter_new_role(role)); |
513 | 513 | ||
514 | if (!attendee->uid().isEmpty()) { | 514 | if (!attendee->uid().isEmpty()) { |
515 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); | 515 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); |
516 | icalparameter_set_xname(icalparameter_uid,"X-UID"); | 516 | icalparameter_set_xname(icalparameter_uid,"X-UID"); |
517 | icalproperty_add_parameter(p,icalparameter_uid); | 517 | icalproperty_add_parameter(p,icalparameter_uid); |
518 | } | 518 | } |
519 | 519 | ||
520 | return p; | 520 | return p; |
521 | } | 521 | } |
522 | 522 | ||
523 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) | 523 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) |
524 | { | 524 | { |
525 | #if 0 | 525 | #if 0 |
526 | icalattachtype* attach = icalattachtype_new(); | 526 | icalattachtype* attach = icalattachtype_new(); |
527 | if (att->isURI()) | 527 | if (att->isURI()) |
528 | icalattachtype_set_url(attach, att->uri().utf8().data()); | 528 | icalattachtype_set_url(attach, att->uri().utf8().data()); |
529 | else | 529 | else |
530 | icalattachtype_set_base64(attach, att->data(), 0); | 530 | icalattachtype_set_base64(attach, att->data(), 0); |
531 | #endif | 531 | #endif |
532 | icalattach *attach; | 532 | icalattach *attach; |
533 | if (att->isURI()) | 533 | if (att->isURI()) |
534 | attach = icalattach_new_from_url( att->uri().utf8().data()); | 534 | attach = icalattach_new_from_url( att->uri().utf8().data()); |
535 | else | 535 | else |
536 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); | 536 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); |
537 | icalproperty *p = icalproperty_new_attach(attach); | 537 | icalproperty *p = icalproperty_new_attach(attach); |
538 | if (!att->mimeType().isEmpty()) | 538 | if (!att->mimeType().isEmpty()) |
539 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); | 539 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); |
540 | 540 | ||
541 | if (att->isBinary()) { | 541 | if (att->isBinary()) { |
542 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); | 542 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); |
543 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); | 543 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); |
544 | } | 544 | } |
545 | return p; | 545 | return p; |
546 | } | 546 | } |
547 | 547 | ||
548 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) | 548 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) |
549 | { | 549 | { |
550 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; | 550 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; |
551 | 551 | ||
552 | icalrecurrencetype r; | 552 | icalrecurrencetype r; |
553 | 553 | ||
554 | icalrecurrencetype_clear(&r); | 554 | icalrecurrencetype_clear(&r); |
555 | 555 | ||
556 | int index = 0; | 556 | int index = 0; |
557 | int index2 = 0; | 557 | int index2 = 0; |
558 | 558 | ||
559 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 559 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
560 | QPtrList<int> tmpDays; | 560 | QPtrList<int> tmpDays; |
561 | int *tmpDay; | 561 | int *tmpDay; |
562 | Recurrence::rMonthPos *tmpPos; | 562 | Recurrence::rMonthPos *tmpPos; |
563 | bool datetime = false; | 563 | bool datetime = false; |
564 | int day; | 564 | int day; |
565 | int i; | 565 | int i; |
566 | 566 | ||
567 | switch(recur->doesRecur()) { | 567 | switch(recur->doesRecur()) { |
568 | case Recurrence::rMinutely: | 568 | case Recurrence::rMinutely: |
569 | r.freq = ICAL_MINUTELY_RECURRENCE; | 569 | r.freq = ICAL_MINUTELY_RECURRENCE; |
570 | datetime = true; | 570 | datetime = true; |
571 | break; | 571 | break; |
572 | case Recurrence::rHourly: | 572 | case Recurrence::rHourly: |
573 | r.freq = ICAL_HOURLY_RECURRENCE; | 573 | r.freq = ICAL_HOURLY_RECURRENCE; |
574 | datetime = true; | 574 | datetime = true; |
575 | break; | 575 | break; |
576 | case Recurrence::rDaily: | 576 | case Recurrence::rDaily: |
577 | r.freq = ICAL_DAILY_RECURRENCE; | 577 | r.freq = ICAL_DAILY_RECURRENCE; |
578 | break; | 578 | break; |
579 | case Recurrence::rWeekly: | 579 | case Recurrence::rWeekly: |
580 | r.freq = ICAL_WEEKLY_RECURRENCE; | 580 | r.freq = ICAL_WEEKLY_RECURRENCE; |
581 | r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); | 581 | r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); |
582 | for (i = 0; i < 7; i++) { | 582 | for (i = 0; i < 7; i++) { |
583 | if (recur->days().testBit(i)) { | 583 | if (recur->days().testBit(i)) { |
584 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 584 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
585 | r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); | 585 | r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 588 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
589 | break; | 589 | break; |
590 | case Recurrence::rMonthlyPos: | 590 | case Recurrence::rMonthlyPos: |
591 | r.freq = ICAL_MONTHLY_RECURRENCE; | 591 | r.freq = ICAL_MONTHLY_RECURRENCE; |
592 | 592 | ||
593 | tmpPositions = recur->monthPositions(); | 593 | tmpPositions = recur->monthPositions(); |
594 | for (tmpPos = tmpPositions.first(); | 594 | for (tmpPos = tmpPositions.first(); |
595 | tmpPos; | 595 | tmpPos; |
596 | tmpPos = tmpPositions.next()) { | 596 | tmpPos = tmpPositions.next()) { |
597 | for (i = 0; i < 7; i++) { | 597 | for (i = 0; i < 7; i++) { |
598 | if (tmpPos->rDays.testBit(i)) { | 598 | if (tmpPos->rDays.testBit(i)) { |
599 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 599 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
600 | day += tmpPos->rPos*8; | 600 | day += tmpPos->rPos*8; |
601 | if (tmpPos->negative) day = -day; | 601 | if (tmpPos->negative) day = -day; |
602 | r.by_day[index++] = day; | 602 | r.by_day[index++] = day; |
603 | } | 603 | } |
604 | } | 604 | } |
605 | } | 605 | } |
606 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 606 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
607 | break; | 607 | break; |
608 | case Recurrence::rMonthlyDay: | 608 | case Recurrence::rMonthlyDay: |
609 | r.freq = ICAL_MONTHLY_RECURRENCE; | 609 | r.freq = ICAL_MONTHLY_RECURRENCE; |
610 | 610 | ||
611 | tmpDays = recur->monthDays(); | 611 | tmpDays = recur->monthDays(); |
612 | for (tmpDay = tmpDays.first(); | 612 | for (tmpDay = tmpDays.first(); |
613 | tmpDay; | 613 | tmpDay; |
614 | tmpDay = tmpDays.next()) { | 614 | tmpDay = tmpDays.next()) { |
615 | r.by_month_day[index++] = icalrecurrencetype_day_position(*tmpDay*8);//*tmpDay); | 615 | r.by_month_day[index++] = icalrecurrencetype_day_position(*tmpDay*8);//*tmpDay); |
616 | } | 616 | } |
617 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 617 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
618 | break; | 618 | break; |
619 | case Recurrence::rYearlyMonth: | 619 | case Recurrence::rYearlyMonth: |
620 | case Recurrence::rYearlyPos: | 620 | case Recurrence::rYearlyPos: |
621 | r.freq = ICAL_YEARLY_RECURRENCE; | 621 | r.freq = ICAL_YEARLY_RECURRENCE; |
622 | 622 | ||
623 | tmpDays = recur->yearNums(); | 623 | tmpDays = recur->yearNums(); |
624 | for (tmpDay = tmpDays.first(); | 624 | for (tmpDay = tmpDays.first(); |
625 | tmpDay; | 625 | tmpDay; |
626 | tmpDay = tmpDays.next()) { | 626 | tmpDay = tmpDays.next()) { |
627 | r.by_month[index++] = *tmpDay; | 627 | r.by_month[index++] = *tmpDay; |
628 | } | 628 | } |
629 | // r.by_set_pos[index] = ICAL_RECURRENCE_ARRAY_MAX; | 629 | // r.by_set_pos[index] = ICAL_RECURRENCE_ARRAY_MAX; |
630 | if (recur->doesRecur() == Recurrence::rYearlyPos) { | 630 | if (recur->doesRecur() == Recurrence::rYearlyPos) { |
631 | tmpPositions = recur->monthPositions(); | 631 | tmpPositions = recur->monthPositions(); |
632 | for (tmpPos = tmpPositions.first(); | 632 | for (tmpPos = tmpPositions.first(); |
633 | tmpPos; | 633 | tmpPos; |
634 | tmpPos = tmpPositions.next()) { | 634 | tmpPos = tmpPositions.next()) { |
635 | for (i = 0; i < 7; i++) { | 635 | for (i = 0; i < 7; i++) { |
636 | if (tmpPos->rDays.testBit(i)) { | 636 | if (tmpPos->rDays.testBit(i)) { |
637 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 637 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
638 | day += tmpPos->rPos*8; | 638 | day += tmpPos->rPos*8; |
639 | if (tmpPos->negative) day = -day; | 639 | if (tmpPos->negative) day = -day; |
640 | r.by_day[index2++] = day; | 640 | r.by_day[index2++] = day; |
641 | } | 641 | } |
642 | } | 642 | } |
643 | } | 643 | } |
644 | // r.by_day[index2] = ICAL_RECURRENCE_ARRAY_MAX; | 644 | // r.by_day[index2] = ICAL_RECURRENCE_ARRAY_MAX; |
645 | } | 645 | } |
646 | break; | 646 | break; |
647 | case Recurrence::rYearlyDay: | 647 | case Recurrence::rYearlyDay: |
648 | r.freq = ICAL_YEARLY_RECURRENCE; | 648 | r.freq = ICAL_YEARLY_RECURRENCE; |
649 | 649 | ||
650 | tmpDays = recur->yearNums(); | 650 | tmpDays = recur->yearNums(); |
651 | for (tmpDay = tmpDays.first(); | 651 | for (tmpDay = tmpDays.first(); |
652 | tmpDay; | 652 | tmpDay; |
653 | tmpDay = tmpDays.next()) { | 653 | tmpDay = tmpDays.next()) { |
654 | r.by_year_day[index++] = *tmpDay; | 654 | r.by_year_day[index++] = *tmpDay; |
655 | } | 655 | } |
656 | // r.by_year_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 656 | // r.by_year_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
657 | break; | 657 | break; |
658 | default: | 658 | default: |
659 | r.freq = ICAL_NO_RECURRENCE; | 659 | r.freq = ICAL_NO_RECURRENCE; |
660 | kdDebug(5800) << "ICalFormatImpl::writeRecurrence(): no recurrence" << endl; | 660 | kdDebug(5800) << "ICalFormatImpl::writeRecurrence(): no recurrence" << endl; |
661 | break; | 661 | break; |
662 | } | 662 | } |
663 | 663 | ||
664 | r.interval = recur->frequency(); | 664 | r.interval = recur->frequency(); |
665 | 665 | ||
666 | if (recur->duration() > 0) { | 666 | if (recur->duration() > 0) { |
667 | r.count = recur->duration(); | 667 | r.count = recur->duration(); |
668 | } else if (recur->duration() == -1) { | 668 | } else if (recur->duration() == -1) { |
669 | r.count = 0; | 669 | r.count = 0; |
670 | } else { | 670 | } else { |
671 | if (datetime) | 671 | if (datetime) |
672 | r.until = writeICalDateTime(recur->endDateTime()); | 672 | r.until = writeICalDateTime(recur->endDateTime()); |
673 | else | 673 | else |
674 | r.until = writeICalDate(recur->endDate()); | 674 | r.until = writeICalDate(recur->endDate()); |
675 | } | 675 | } |
676 | 676 | ||
677 | // Debug output | 677 | // Debug output |
678 | #if 0 | 678 | #if 0 |
679 | const char *str = icalrecurrencetype_as_string(&r); | 679 | const char *str = icalrecurrencetype_as_string(&r); |
680 | if (str) { | 680 | if (str) { |
681 | kdDebug(5800) << " String: " << str << endl; | 681 | kdDebug(5800) << " String: " << str << endl; |
682 | } else { | 682 | } else { |
683 | kdDebug(5800) << " No String" << endl; | 683 | kdDebug(5800) << " No String" << endl; |
684 | } | 684 | } |
685 | #endif | 685 | #endif |
686 | 686 | ||
687 | return icalproperty_new_rrule(r); | 687 | return icalproperty_new_rrule(r); |
688 | } | 688 | } |
689 | 689 | ||
690 | icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) | 690 | icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) |
691 | { | 691 | { |
692 | icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT); | 692 | icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT); |
693 | 693 | ||
694 | icalproperty_action action; | 694 | icalproperty_action action; |
695 | icalattach *attach = 0; | 695 | icalattach *attach = 0; |
696 | 696 | ||
697 | switch (alarm->type()) { | 697 | switch (alarm->type()) { |
698 | case Alarm::Procedure: | 698 | case Alarm::Procedure: |
699 | action = ICAL_ACTION_PROCEDURE; | 699 | action = ICAL_ACTION_PROCEDURE; |
700 | attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() ); | 700 | attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() ); |
701 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 701 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
702 | if (!alarm->programArguments().isEmpty()) { | 702 | if (!alarm->programArguments().isEmpty()) { |
703 | icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8())); | 703 | icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8())); |
704 | } | 704 | } |
705 | break; | 705 | break; |
706 | case Alarm::Audio: | 706 | case Alarm::Audio: |
707 | action = ICAL_ACTION_AUDIO; | 707 | action = ICAL_ACTION_AUDIO; |
708 | if (!alarm->audioFile().isEmpty()) { | 708 | if (!alarm->audioFile().isEmpty()) { |
709 | attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); | 709 | attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); |
710 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 710 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
711 | } | 711 | } |
712 | break; | 712 | break; |
713 | case Alarm::Email: { | 713 | case Alarm::Email: { |
714 | action = ICAL_ACTION_EMAIL; | 714 | action = ICAL_ACTION_EMAIL; |
715 | QValueList<Person> addresses = alarm->mailAddresses(); | 715 | QValueList<Person> addresses = alarm->mailAddresses(); |
716 | for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { | 716 | for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { |
717 | icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); | 717 | icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); |
718 | if (!(*ad).name().isEmpty()) { | 718 | if (!(*ad).name().isEmpty()) { |
719 | icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); | 719 | icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); |
720 | } | 720 | } |
721 | icalcomponent_add_property(a,p); | 721 | icalcomponent_add_property(a,p); |
722 | } | 722 | } |
723 | icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); | 723 | icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); |
724 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); | 724 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); |
725 | QStringList attachments = alarm->mailAttachments(); | 725 | QStringList attachments = alarm->mailAttachments(); |
726 | if (attachments.count() > 0) { | 726 | if (attachments.count() > 0) { |
727 | for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { | 727 | for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { |
728 | attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); | 728 | attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); |
729 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 729 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
730 | } | 730 | } |
731 | } | 731 | } |
732 | break; | 732 | break; |
733 | } | 733 | } |
734 | case Alarm::Display: | 734 | case Alarm::Display: |
735 | action = ICAL_ACTION_DISPLAY; | 735 | action = ICAL_ACTION_DISPLAY; |
736 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); | 736 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); |
737 | break; | 737 | break; |
738 | case Alarm::Invalid: | 738 | case Alarm::Invalid: |
739 | default: | 739 | default: |
740 | kdDebug(5800) << "Unknown type of alarm" << endl; | 740 | kdDebug(5800) << "Unknown type of alarm" << endl; |
741 | action = ICAL_ACTION_NONE; | 741 | action = ICAL_ACTION_NONE; |
742 | break; | 742 | break; |
743 | } | 743 | } |
744 | icalcomponent_add_property(a,icalproperty_new_action(action)); | 744 | icalcomponent_add_property(a,icalproperty_new_action(action)); |
745 | 745 | ||
746 | // Trigger time | 746 | // Trigger time |
747 | icaltriggertype trigger; | 747 | icaltriggertype trigger; |
748 | if ( alarm->hasTime() ) { | 748 | if ( alarm->hasTime() ) { |
749 | trigger.time = writeICalDateTime(alarm->time()); | 749 | trigger.time = writeICalDateTime(alarm->time()); |
750 | trigger.duration = icaldurationtype_null_duration(); | 750 | trigger.duration = icaldurationtype_null_duration(); |
751 | } else { | 751 | } else { |
752 | trigger.time = icaltime_null_time(); | 752 | trigger.time = icaltime_null_time(); |
753 | Duration offset; | 753 | Duration offset; |
754 | if ( alarm->hasStartOffset() ) | 754 | if ( alarm->hasStartOffset() ) |
755 | offset = alarm->startOffset(); | 755 | offset = alarm->startOffset(); |
756 | else | 756 | else |
757 | offset = alarm->endOffset(); | 757 | offset = alarm->endOffset(); |
758 | trigger.duration = icaldurationtype_from_int( offset.asSeconds() ); | 758 | trigger.duration = icaldurationtype_from_int( offset.asSeconds() ); |
759 | } | 759 | } |
760 | icalproperty *p = icalproperty_new_trigger(trigger); | 760 | icalproperty *p = icalproperty_new_trigger(trigger); |
761 | if ( alarm->hasEndOffset() ) | 761 | if ( alarm->hasEndOffset() ) |
762 | icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END)); | 762 | icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END)); |
763 | icalcomponent_add_property(a,p); | 763 | icalcomponent_add_property(a,p); |
764 | 764 | ||
765 | // Repeat count and duration | 765 | // Repeat count and duration |
766 | if (alarm->repeatCount()) { | 766 | if (alarm->repeatCount()) { |
767 | icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount())); | 767 | icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount())); |
768 | icalcomponent_add_property(a,icalproperty_new_duration( | 768 | icalcomponent_add_property(a,icalproperty_new_duration( |
769 | icaldurationtype_from_int(alarm->snoozeTime()*60))); | 769 | icaldurationtype_from_int(alarm->snoozeTime()*60))); |
770 | } | 770 | } |
771 | 771 | ||
772 | // Custom properties | 772 | // Custom properties |
773 | QMap<QCString, QString> custom = alarm->customProperties(); | 773 | QMap<QCString, QString> custom = alarm->customProperties(); |
774 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { | 774 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { |
775 | icalproperty *p = icalproperty_new_x(c.data().utf8()); | 775 | icalproperty *p = icalproperty_new_x(c.data().utf8()); |
776 | icalproperty_set_x_name(p,c.key()); | 776 | icalproperty_set_x_name(p,c.key()); |
777 | icalcomponent_add_property(a,p); | 777 | icalcomponent_add_property(a,p); |
778 | } | 778 | } |
779 | 779 | ||
780 | return a; | 780 | return a; |
781 | } | 781 | } |
782 | 782 | ||
783 | Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo) | 783 | Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo) |
784 | { | 784 | { |
785 | Todo *todo = new Todo; | 785 | Todo *todo = new Todo; |
786 | 786 | ||
787 | readIncidence(vtodo,todo); | 787 | readIncidence(vtodo,todo); |
788 | 788 | ||
789 | icalproperty *p = icalcomponent_get_first_property(vtodo,ICAL_ANY_PROPERTY); | 789 | icalproperty *p = icalcomponent_get_first_property(vtodo,ICAL_ANY_PROPERTY); |
790 | 790 | ||
791 | // int intvalue; | 791 | // int intvalue; |
792 | icaltimetype icaltime; | 792 | icaltimetype icaltime; |
793 | 793 | ||
794 | QStringList categories; | 794 | QStringList categories; |
795 | 795 | ||
796 | while (p) { | 796 | while (p) { |
797 | icalproperty_kind kind = icalproperty_isa(p); | 797 | icalproperty_kind kind = icalproperty_isa(p); |
798 | switch (kind) { | 798 | switch (kind) { |
799 | 799 | ||
800 | case ICAL_DUE_PROPERTY: // due date | 800 | case ICAL_DUE_PROPERTY: // due date |
801 | icaltime = icalproperty_get_due(p); | 801 | icaltime = icalproperty_get_due(p); |
802 | if (icaltime.is_date) { | 802 | if (icaltime.is_date) { |
803 | todo->setDtDue(QDateTime(readICalDate(icaltime),QTime(0,0,0))); | 803 | todo->setDtDue(QDateTime(readICalDate(icaltime),QTime(0,0,0))); |
804 | todo->setFloats(true); | 804 | todo->setFloats(true); |
805 | 805 | ||
806 | } else { | 806 | } else { |
807 | todo->setDtDue(readICalDateTime(icaltime)); | 807 | todo->setDtDue(readICalDateTime(icaltime)); |
808 | todo->setFloats(false); | 808 | todo->setFloats(false); |
809 | } | 809 | } |
810 | todo->setHasDueDate(true); | 810 | todo->setHasDueDate(true); |
811 | break; | 811 | break; |
812 | 812 | ||
813 | case ICAL_COMPLETED_PROPERTY: // completion date | 813 | case ICAL_COMPLETED_PROPERTY: // completion date |
814 | icaltime = icalproperty_get_completed(p); | 814 | icaltime = icalproperty_get_completed(p); |
815 | todo->setCompleted(readICalDateTime(icaltime)); | 815 | todo->setCompleted(readICalDateTime(icaltime)); |
816 | break; | 816 | break; |
817 | 817 | ||
818 | case ICAL_PERCENTCOMPLETE_PROPERTY: // Percent completed | 818 | case ICAL_PERCENTCOMPLETE_PROPERTY: // Percent completed |
819 | todo->setPercentComplete(icalproperty_get_percentcomplete(p)); | 819 | todo->setPercentComplete(icalproperty_get_percentcomplete(p)); |
820 | break; | 820 | break; |
821 | 821 | ||
822 | case ICAL_RELATEDTO_PROPERTY: // related todo (parent) | 822 | case ICAL_RELATEDTO_PROPERTY: // related todo (parent) |
823 | todo->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); | 823 | todo->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); |
824 | mTodosRelate.append(todo); | 824 | mTodosRelate.append(todo); |
825 | break; | 825 | break; |
826 | 826 | ||
827 | case ICAL_DTSTART_PROPERTY: | 827 | case ICAL_DTSTART_PROPERTY: |
828 | // Flag that todo has start date. Value is read in by readIncidence(). | 828 | // Flag that todo has start date. Value is read in by readIncidence(). |
829 | todo->setHasStartDate(true); | 829 | todo->setHasStartDate(true); |
830 | break; | 830 | break; |
831 | 831 | ||
832 | default: | 832 | default: |
833 | // kdDebug(5800) << "ICALFormat::readTodo(): Unknown property: " << kind | 833 | // kdDebug(5800) << "ICALFormat::readTodo(): Unknown property: " << kind |
834 | // << endl; | 834 | // << endl; |
835 | break; | 835 | break; |
836 | } | 836 | } |
837 | 837 | ||
838 | p = icalcomponent_get_next_property(vtodo,ICAL_ANY_PROPERTY); | 838 | p = icalcomponent_get_next_property(vtodo,ICAL_ANY_PROPERTY); |
839 | } | 839 | } |
840 | 840 | ||
841 | return todo; | 841 | return todo; |
842 | } | 842 | } |
843 | 843 | ||
844 | Event *ICalFormatImpl::readEvent(icalcomponent *vevent) | 844 | Event *ICalFormatImpl::readEvent(icalcomponent *vevent) |
845 | { | 845 | { |
846 | Event *event = new Event; | 846 | Event *event = new Event; |
847 | event->setFloats(false); | 847 | event->setFloats(false); |
848 | 848 | ||
849 | readIncidence(vevent,event); | 849 | readIncidence(vevent,event); |
850 | 850 | ||
851 | icalproperty *p = icalcomponent_get_first_property(vevent,ICAL_ANY_PROPERTY); | 851 | icalproperty *p = icalcomponent_get_first_property(vevent,ICAL_ANY_PROPERTY); |
852 | 852 | ||
853 | // int intvalue; | 853 | // int intvalue; |
854 | icaltimetype icaltime; | 854 | icaltimetype icaltime; |
855 | 855 | ||
856 | QStringList categories; | 856 | QStringList categories; |
857 | QString transparency; | 857 | QString transparency; |
858 | 858 | ||
859 | while (p) { | 859 | while (p) { |
860 | icalproperty_kind kind = icalproperty_isa(p); | 860 | icalproperty_kind kind = icalproperty_isa(p); |
861 | switch (kind) { | 861 | switch (kind) { |
862 | 862 | ||
863 | case ICAL_DTEND_PROPERTY: // start date and time | 863 | case ICAL_DTEND_PROPERTY: // start date and time |
864 | icaltime = icalproperty_get_dtend(p); | 864 | icaltime = icalproperty_get_dtend(p); |
865 | if (icaltime.is_date) { | 865 | if (icaltime.is_date) { |
866 | event->setFloats( true ); | 866 | event->setFloats( true ); |
867 | // End date is non-inclusive | 867 | // End date is non-inclusive |
868 | QDate endDate = readICalDate( icaltime ).addDays( -1 ); | 868 | QDate endDate = readICalDate( icaltime ).addDays( -1 ); |
869 | mCompat->fixFloatingEnd( endDate ); | 869 | mCompat->fixFloatingEnd( endDate ); |
870 | if ( endDate < event->dtStart().date() ) { | 870 | if ( endDate < event->dtStart().date() ) { |
871 | endDate = event->dtStart().date(); | 871 | endDate = event->dtStart().date(); |
872 | } | 872 | } |
873 | event->setDtEnd( QDateTime( endDate, QTime( 0, 0, 0 ) ) ); | 873 | event->setDtEnd( QDateTime( endDate, QTime( 0, 0, 0 ) ) ); |
874 | } else { | 874 | } else { |
875 | event->setDtEnd(readICalDateTime(icaltime)); | 875 | event->setDtEnd(readICalDateTime(icaltime)); |
876 | } | 876 | } |
877 | break; | 877 | break; |
878 | 878 | ||
879 | // TODO: | 879 | // TODO: |
880 | // at this point, there should be at least a start or end time. | 880 | // at this point, there should be at least a start or end time. |
881 | // fix up for events that take up no time but have a time associated | 881 | // fix up for events that take up no time but have a time associated |
882 | #if 0 | 882 | #if 0 |
883 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) | 883 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) |
884 | anEvent->setDtStart(anEvent->dtEnd()); | 884 | anEvent->setDtStart(anEvent->dtEnd()); |
885 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) | 885 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) |
886 | anEvent->setDtEnd(anEvent->dtStart()); | 886 | anEvent->setDtEnd(anEvent->dtStart()); |
887 | #endif | 887 | #endif |
888 | 888 | ||
889 | // TODO: exdates | 889 | // TODO: exdates |
890 | #if 0 | 890 | #if 0 |
891 | // recurrence exceptions | 891 | // recurrence exceptions |
892 | if ((vo = isAPropertyOf(vevent, VCExDateProp)) != 0) { | 892 | if ((vo = isAPropertyOf(vevent, VCExDateProp)) != 0) { |
893 | anEvent->setExDates(s = fakeCString(vObjectUStringZValue(vo))); | 893 | anEvent->setExDates(s = fakeCString(vObjectUStringZValue(vo))); |
894 | deleteStr(s); | 894 | deleteStr(s); |
895 | } | 895 | } |
896 | #endif | 896 | #endif |
897 | 897 | ||
898 | #if 0 | 898 | #if 0 |
899 | // secrecy | 899 | // secrecy |
900 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { | 900 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { |
901 | anEvent->setSecrecy(s = fakeCString(vObjectUStringZValue(vo))); | 901 | anEvent->setSecrecy(s = fakeCString(vObjectUStringZValue(vo))); |
902 | deleteStr(s); | 902 | deleteStr(s); |
903 | } | 903 | } |
904 | else | 904 | else |
905 | anEvent->setSecrecy("PUBLIC"); | 905 | anEvent->setSecrecy("PUBLIC"); |
906 | 906 | ||
907 | // attachments | 907 | // attachments |
908 | tmpStrList.clear(); | 908 | tmpStrList.clear(); |
909 | initPropIterator(&voi, vevent); | 909 | initPropIterator(&voi, vevent); |
910 | while (moreIteration(&voi)) { | 910 | while (moreIteration(&voi)) { |
911 | vo = nextVObject(&voi); | 911 | vo = nextVObject(&voi); |
912 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { | 912 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { |
913 | tmpStrList.append(s = fakeCString(vObjectUStringZValue(vo))); | 913 | tmpStrList.append(s = fakeCString(vObjectUStringZValue(vo))); |
914 | deleteStr(s); | 914 | deleteStr(s); |
915 | } | 915 | } |
916 | } | 916 | } |
917 | anEvent->setAttachments(tmpStrList); | 917 | anEvent->setAttachments(tmpStrList); |
918 | 918 | ||
919 | // resources | 919 | // resources |
920 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 920 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
921 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 921 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
922 | deleteStr(s); | 922 | deleteStr(s); |
923 | tmpStrList.clear(); | 923 | tmpStrList.clear(); |
924 | index1 = 0; | 924 | index1 = 0; |
925 | index2 = 0; | 925 | index2 = 0; |
926 | QString resource; | 926 | QString resource; |
927 | while ((index2 = resources.find(';', index1)) != -1) { | 927 | while ((index2 = resources.find(';', index1)) != -1) { |
928 | resource = resources.mid(index1, (index2 - index1)); | 928 | resource = resources.mid(index1, (index2 - index1)); |
929 | tmpStrList.append(resource); | 929 | tmpStrList.append(resource); |
930 | index1 = index2; | 930 | index1 = index2; |
931 | } | 931 | } |
932 | anEvent->setResources(tmpStrList); | 932 | anEvent->setResources(tmpStrList); |
933 | } | 933 | } |
934 | #endif | 934 | #endif |
935 | 935 | ||
936 | case ICAL_RELATEDTO_PROPERTY: // releated event (parent) | 936 | case ICAL_RELATEDTO_PROPERTY: // releated event (parent) |
937 | event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); | 937 | event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); |
938 | mEventsRelate.append(event); | 938 | mEventsRelate.append(event); |
939 | break; | 939 | break; |
940 | 940 | ||
941 | case ICAL_TRANSP_PROPERTY: // Transparency | 941 | case ICAL_TRANSP_PROPERTY: // Transparency |
942 | if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) | 942 | if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) |
943 | event->setTransparency( Event::Transparent ); | 943 | event->setTransparency( Event::Transparent ); |
944 | else | 944 | else |
945 | event->setTransparency( Event::Opaque ); | 945 | event->setTransparency( Event::Opaque ); |
946 | break; | 946 | break; |
947 | 947 | ||
948 | default: | 948 | default: |
949 | // kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind | 949 | // kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind |
950 | // << endl; | 950 | // << endl; |
951 | break; | 951 | break; |
952 | } | 952 | } |
953 | 953 | ||
954 | p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); | 954 | p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); |
955 | } | 955 | } |
956 | 956 | ||
957 | QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); | 957 | QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); |
958 | if (!msade.isNull()) { | 958 | if (!msade.isNull()) { |
959 | bool floats = (msade == QString::fromLatin1("TRUE")); | 959 | bool floats = (msade == QString::fromLatin1("TRUE")); |
960 | kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; | 960 | kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; |
961 | event->setFloats(floats); | 961 | event->setFloats(floats); |
962 | if (floats) { | 962 | if (floats) { |
963 | QDateTime endDate = event->dtEnd(); | 963 | QDateTime endDate = event->dtEnd(); |
964 | event->setDtEnd(endDate.addDays(-1)); | 964 | event->setDtEnd(endDate.addDays(-1)); |
965 | } | 965 | } |
966 | } | 966 | } |
967 | 967 | ||
968 | // some stupid vCal exporters ignore the standard and use Description | 968 | // some stupid vCal exporters ignore the standard and use Description |
969 | // instead of Summary for the default field. Correct for this. | 969 | // instead of Summary for the default field. Correct for this. |
970 | if (event->summary().isEmpty() && | 970 | if (event->summary().isEmpty() && |
971 | !(event->description().isEmpty())) { | 971 | !(event->description().isEmpty())) { |
972 | QString tmpStr = event->description().simplifyWhiteSpace(); | 972 | QString tmpStr = event->description().simplifyWhiteSpace(); |
973 | event->setDescription(""); | 973 | event->setDescription(""); |
974 | event->setSummary(tmpStr); | 974 | event->setSummary(tmpStr); |
975 | } | 975 | } |
976 | 976 | ||
977 | return event; | 977 | return event; |
978 | } | 978 | } |
979 | 979 | ||
980 | FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy) | 980 | FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy) |
981 | { | 981 | { |
982 | FreeBusy *freebusy = new FreeBusy; | 982 | FreeBusy *freebusy = new FreeBusy; |
983 | 983 | ||
984 | readIncidenceBase(vfreebusy,freebusy); | 984 | readIncidenceBase(vfreebusy,freebusy); |
985 | 985 | ||
986 | icalproperty *p = icalcomponent_get_first_property(vfreebusy,ICAL_ANY_PROPERTY); | 986 | icalproperty *p = icalcomponent_get_first_property(vfreebusy,ICAL_ANY_PROPERTY); |
987 | 987 | ||
988 | icaltimetype icaltime; | 988 | icaltimetype icaltime; |
989 | icalperiodtype icalperiod; | 989 | icalperiodtype icalperiod; |
990 | QDateTime period_start, period_end; | 990 | QDateTime period_start, period_end; |
991 | 991 | ||
992 | while (p) { | 992 | while (p) { |
993 | icalproperty_kind kind = icalproperty_isa(p); | 993 | icalproperty_kind kind = icalproperty_isa(p); |
994 | switch (kind) { | 994 | switch (kind) { |
995 | 995 | ||
996 | case ICAL_DTSTART_PROPERTY: // start date and time | 996 | case ICAL_DTSTART_PROPERTY: // start date and time |
997 | icaltime = icalproperty_get_dtstart(p); | 997 | icaltime = icalproperty_get_dtstart(p); |
998 | freebusy->setDtStart(readICalDateTime(icaltime)); | 998 | freebusy->setDtStart(readICalDateTime(icaltime)); |
999 | break; | 999 | break; |
1000 | 1000 | ||
1001 | case ICAL_DTEND_PROPERTY: // start End Date and Time | 1001 | case ICAL_DTEND_PROPERTY: // start End Date and Time |
1002 | icaltime = icalproperty_get_dtend(p); | 1002 | icaltime = icalproperty_get_dtend(p); |
1003 | freebusy->setDtEnd(readICalDateTime(icaltime)); | 1003 | freebusy->setDtEnd(readICalDateTime(icaltime)); |
1004 | break; | 1004 | break; |
1005 | 1005 | ||
1006 | case ICAL_FREEBUSY_PROPERTY: //Any FreeBusy Times | 1006 | case ICAL_FREEBUSY_PROPERTY: //Any FreeBusy Times |
1007 | icalperiod = icalproperty_get_freebusy(p); | 1007 | icalperiod = icalproperty_get_freebusy(p); |
1008 | period_start = readICalDateTime(icalperiod.start); | 1008 | period_start = readICalDateTime(icalperiod.start); |
1009 | period_end = readICalDateTime(icalperiod.end); | 1009 | period_end = readICalDateTime(icalperiod.end); |
1010 | freebusy->addPeriod(period_start, period_end); | 1010 | freebusy->addPeriod(period_start, period_end); |
1011 | break; | 1011 | break; |
1012 | 1012 | ||
1013 | default: | 1013 | default: |
1014 | kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1014 | kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1015 | << endl; | 1015 | << endl; |
1016 | break; | 1016 | break; |
1017 | } | 1017 | } |
1018 | p = icalcomponent_get_next_property(vfreebusy,ICAL_ANY_PROPERTY); | 1018 | p = icalcomponent_get_next_property(vfreebusy,ICAL_ANY_PROPERTY); |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | return freebusy; | 1021 | return freebusy; |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | Journal *ICalFormatImpl::readJournal(icalcomponent *vjournal) | 1024 | Journal *ICalFormatImpl::readJournal(icalcomponent *vjournal) |
1025 | { | 1025 | { |
1026 | Journal *journal = new Journal; | 1026 | Journal *journal = new Journal; |
1027 | 1027 | ||
1028 | readIncidence(vjournal,journal); | 1028 | readIncidence(vjournal,journal); |
1029 | 1029 | ||
1030 | return journal; | 1030 | return journal; |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) | 1033 | Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) |
1034 | { | 1034 | { |
1035 | icalparameter *p = 0; | 1035 | icalparameter *p = 0; |
1036 | 1036 | ||
1037 | QString email = QString::fromUtf8(icalproperty_get_attendee(attendee)); | 1037 | QString email = QString::fromUtf8(icalproperty_get_attendee(attendee)); |
1038 | 1038 | ||
1039 | QString name; | 1039 | QString name; |
1040 | QString uid = QString::null; | 1040 | QString uid = QString::null; |
1041 | p = icalproperty_get_first_parameter(attendee,ICAL_CN_PARAMETER); | 1041 | p = icalproperty_get_first_parameter(attendee,ICAL_CN_PARAMETER); |
1042 | if (p) { | 1042 | if (p) { |
1043 | name = QString::fromUtf8(icalparameter_get_cn(p)); | 1043 | name = QString::fromUtf8(icalparameter_get_cn(p)); |
1044 | } else { | 1044 | } else { |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | bool rsvp=false; | 1047 | bool rsvp=false; |
1048 | p = icalproperty_get_first_parameter(attendee,ICAL_RSVP_PARAMETER); | 1048 | p = icalproperty_get_first_parameter(attendee,ICAL_RSVP_PARAMETER); |
1049 | if (p) { | 1049 | if (p) { |
1050 | icalparameter_rsvp rsvpParameter = icalparameter_get_rsvp(p); | 1050 | icalparameter_rsvp rsvpParameter = icalparameter_get_rsvp(p); |
1051 | if (rsvpParameter == ICAL_RSVP_TRUE) rsvp = true; | 1051 | if (rsvpParameter == ICAL_RSVP_TRUE) rsvp = true; |
1052 | } | 1052 | } |
1053 | 1053 | ||
1054 | Attendee::PartStat status = Attendee::NeedsAction; | 1054 | Attendee::PartStat status = Attendee::NeedsAction; |
1055 | p = icalproperty_get_first_parameter(attendee,ICAL_PARTSTAT_PARAMETER); | 1055 | p = icalproperty_get_first_parameter(attendee,ICAL_PARTSTAT_PARAMETER); |
1056 | if (p) { | 1056 | if (p) { |
1057 | icalparameter_partstat partStatParameter = icalparameter_get_partstat(p); | 1057 | icalparameter_partstat partStatParameter = icalparameter_get_partstat(p); |
1058 | switch(partStatParameter) { | 1058 | switch(partStatParameter) { |
1059 | default: | 1059 | default: |
1060 | case ICAL_PARTSTAT_NEEDSACTION: | 1060 | case ICAL_PARTSTAT_NEEDSACTION: |
1061 | status = Attendee::NeedsAction; | 1061 | status = Attendee::NeedsAction; |
1062 | break; | 1062 | break; |
1063 | case ICAL_PARTSTAT_ACCEPTED: | 1063 | case ICAL_PARTSTAT_ACCEPTED: |
1064 | status = Attendee::Accepted; | 1064 | status = Attendee::Accepted; |
1065 | break; | 1065 | break; |
1066 | case ICAL_PARTSTAT_DECLINED: | 1066 | case ICAL_PARTSTAT_DECLINED: |
1067 | status = Attendee::Declined; | 1067 | status = Attendee::Declined; |
1068 | break; | 1068 | break; |
1069 | case ICAL_PARTSTAT_TENTATIVE: | 1069 | case ICAL_PARTSTAT_TENTATIVE: |
1070 | status = Attendee::Tentative; | 1070 | status = Attendee::Tentative; |
1071 | break; | 1071 | break; |
1072 | case ICAL_PARTSTAT_DELEGATED: | 1072 | case ICAL_PARTSTAT_DELEGATED: |
1073 | status = Attendee::Delegated; | 1073 | status = Attendee::Delegated; |
1074 | break; | 1074 | break; |
1075 | case ICAL_PARTSTAT_COMPLETED: | 1075 | case ICAL_PARTSTAT_COMPLETED: |
1076 | status = Attendee::Completed; | 1076 | status = Attendee::Completed; |
1077 | break; | 1077 | break; |
1078 | case ICAL_PARTSTAT_INPROCESS: | 1078 | case ICAL_PARTSTAT_INPROCESS: |
1079 | status = Attendee::InProcess; | 1079 | status = Attendee::InProcess; |
1080 | break; | 1080 | break; |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | Attendee::Role role = Attendee::ReqParticipant; | 1084 | Attendee::Role role = Attendee::ReqParticipant; |
1085 | p = icalproperty_get_first_parameter(attendee,ICAL_ROLE_PARAMETER); | 1085 | p = icalproperty_get_first_parameter(attendee,ICAL_ROLE_PARAMETER); |
1086 | if (p) { | 1086 | if (p) { |
1087 | icalparameter_role roleParameter = icalparameter_get_role(p); | 1087 | icalparameter_role roleParameter = icalparameter_get_role(p); |
1088 | switch(roleParameter) { | 1088 | switch(roleParameter) { |
1089 | case ICAL_ROLE_CHAIR: | 1089 | case ICAL_ROLE_CHAIR: |
1090 | role = Attendee::Chair; | 1090 | role = Attendee::Chair; |
1091 | break; | 1091 | break; |
1092 | default: | 1092 | default: |
1093 | case ICAL_ROLE_REQPARTICIPANT: | 1093 | case ICAL_ROLE_REQPARTICIPANT: |
1094 | role = Attendee::ReqParticipant; | 1094 | role = Attendee::ReqParticipant; |
1095 | break; | 1095 | break; |
1096 | case ICAL_ROLE_OPTPARTICIPANT: | 1096 | case ICAL_ROLE_OPTPARTICIPANT: |
1097 | role = Attendee::OptParticipant; | 1097 | role = Attendee::OptParticipant; |
1098 | break; | 1098 | break; |
1099 | case ICAL_ROLE_NONPARTICIPANT: | 1099 | case ICAL_ROLE_NONPARTICIPANT: |
1100 | role = Attendee::NonParticipant; | 1100 | role = Attendee::NonParticipant; |
1101 | break; | 1101 | break; |
1102 | } | 1102 | } |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); | 1105 | p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); |
1106 | uid = icalparameter_get_xvalue(p); | 1106 | uid = icalparameter_get_xvalue(p); |
1107 | // This should be added, but there seems to be a libical bug here. | 1107 | // This should be added, but there seems to be a libical bug here. |
1108 | /*while (p) { | 1108 | /*while (p) { |
1109 | // if (icalparameter_get_xname(p) == "X-UID") { | 1109 | // if (icalparameter_get_xname(p) == "X-UID") { |
1110 | uid = icalparameter_get_xvalue(p); | 1110 | uid = icalparameter_get_xvalue(p); |
1111 | p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); | 1111 | p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); |
1112 | } */ | 1112 | } */ |
1113 | 1113 | ||
1114 | return new Attendee( name, email, rsvp, status, role, uid ); | 1114 | return new Attendee( name, email, rsvp, status, role, uid ); |
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) | 1117 | Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) |
1118 | { | 1118 | { |
1119 | icalattach *a = icalproperty_get_attach(attach); | 1119 | icalattach *a = icalproperty_get_attach(attach); |
1120 | icalparameter_value v = ICAL_VALUE_NONE; | 1120 | icalparameter_value v = ICAL_VALUE_NONE; |
1121 | icalparameter_encoding e = ICAL_ENCODING_NONE; | 1121 | icalparameter_encoding e = ICAL_ENCODING_NONE; |
1122 | 1122 | ||
1123 | Attachment *attachment = 0; | 1123 | Attachment *attachment = 0; |
1124 | /* | 1124 | /* |
1125 | icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); | 1125 | icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); |
1126 | if (vp) | 1126 | if (vp) |
1127 | v = icalparameter_get_value(vp); | 1127 | v = icalparameter_get_value(vp); |
1128 | 1128 | ||
1129 | icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); | 1129 | icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); |
1130 | if (ep) | 1130 | if (ep) |
1131 | e = icalparameter_get_encoding(ep); | 1131 | e = icalparameter_get_encoding(ep); |
1132 | */ | 1132 | */ |
1133 | int isurl = icalattach_get_is_url (a); | 1133 | int isurl = icalattach_get_is_url (a); |
1134 | if (isurl == 0) | 1134 | if (isurl == 0) |
1135 | attachment = new Attachment((const char*)icalattach_get_data(a)); | 1135 | attachment = new Attachment((const char*)icalattach_get_data(a)); |
1136 | else { | 1136 | else { |
1137 | attachment = new Attachment(QString(icalattach_get_url(a))); | 1137 | attachment = new Attachment(QString(icalattach_get_url(a))); |
1138 | } | 1138 | } |
1139 | 1139 | ||
1140 | icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); | 1140 | icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); |
1141 | if (p) | 1141 | if (p) |
1142 | attachment->setMimeType(QString(icalparameter_get_fmttype(p))); | 1142 | attachment->setMimeType(QString(icalparameter_get_fmttype(p))); |
1143 | 1143 | ||
1144 | return attachment; | 1144 | return attachment; |
1145 | } | 1145 | } |
1146 | #include <qtextcodec.h> | 1146 | #include <qtextcodec.h> |
1147 | void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | 1147 | void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) |
1148 | { | 1148 | { |
1149 | readIncidenceBase(parent,incidence); | 1149 | readIncidenceBase(parent,incidence); |
1150 | 1150 | ||
1151 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1151 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1152 | bool readrec = false; | 1152 | bool readrec = false; |
1153 | const char *text; | 1153 | const char *text; |
1154 | int intvalue; | 1154 | int intvalue; |
1155 | icaltimetype icaltime; | 1155 | icaltimetype icaltime; |
1156 | icaldurationtype icalduration; | 1156 | icaldurationtype icalduration; |
1157 | struct icalrecurrencetype rectype; | 1157 | struct icalrecurrencetype rectype; |
1158 | QStringList categories; | 1158 | QStringList categories; |
1159 | 1159 | ||
1160 | while (p) { | 1160 | while (p) { |
1161 | icalproperty_kind kind = icalproperty_isa(p); | 1161 | icalproperty_kind kind = icalproperty_isa(p); |
1162 | switch (kind) { | 1162 | switch (kind) { |
1163 | 1163 | ||
1164 | case ICAL_CREATED_PROPERTY: | 1164 | case ICAL_CREATED_PROPERTY: |
1165 | icaltime = icalproperty_get_created(p); | 1165 | icaltime = icalproperty_get_created(p); |
1166 | incidence->setCreated(readICalDateTime(icaltime)); | 1166 | incidence->setCreated(readICalDateTime(icaltime)); |
1167 | break; | 1167 | break; |
1168 | 1168 | ||
1169 | case ICAL_SEQUENCE_PROPERTY: // sequence | 1169 | case ICAL_SEQUENCE_PROPERTY: // sequence |
1170 | intvalue = icalproperty_get_sequence(p); | 1170 | intvalue = icalproperty_get_sequence(p); |
1171 | incidence->setRevision(intvalue); | 1171 | incidence->setRevision(intvalue); |
1172 | break; | 1172 | break; |
1173 | 1173 | ||
1174 | case ICAL_LASTMODIFIED_PROPERTY: // last modification date | 1174 | case ICAL_LASTMODIFIED_PROPERTY: // last modification date |
1175 | icaltime = icalproperty_get_lastmodified(p); | 1175 | icaltime = icalproperty_get_lastmodified(p); |
1176 | incidence->setLastModified(readICalDateTime(icaltime)); | 1176 | incidence->setLastModified(readICalDateTime(icaltime)); |
1177 | break; | 1177 | break; |
1178 | 1178 | ||
1179 | case ICAL_DTSTART_PROPERTY: // start date and time | 1179 | case ICAL_DTSTART_PROPERTY: // start date and time |
1180 | icaltime = icalproperty_get_dtstart(p); | 1180 | icaltime = icalproperty_get_dtstart(p); |
1181 | if (icaltime.is_date) { | 1181 | if (icaltime.is_date) { |
1182 | incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0))); | 1182 | incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0))); |
1183 | incidence->setFloats(true); | 1183 | incidence->setFloats(true); |
1184 | } else { | 1184 | } else { |
1185 | incidence->setDtStart(readICalDateTime(icaltime)); | 1185 | incidence->setDtStart(readICalDateTime(icaltime)); |
1186 | } | 1186 | } |
1187 | break; | 1187 | break; |
1188 | 1188 | ||
1189 | case ICAL_DURATION_PROPERTY: // start date and time | 1189 | case ICAL_DURATION_PROPERTY: // start date and time |
1190 | icalduration = icalproperty_get_duration(p); | 1190 | icalduration = icalproperty_get_duration(p); |
1191 | incidence->setDuration(readICalDuration(icalduration)); | 1191 | incidence->setDuration(readICalDuration(icalduration)); |
1192 | break; | 1192 | break; |
1193 | 1193 | ||
1194 | case ICAL_DESCRIPTION_PROPERTY: // description | 1194 | case ICAL_DESCRIPTION_PROPERTY: // description |
1195 | text = icalproperty_get_description(p); | 1195 | text = icalproperty_get_description(p); |
1196 | incidence->setDescription(QString::fromUtf8(text)); | 1196 | incidence->setDescription(QString::fromUtf8(text)); |
1197 | break; | 1197 | break; |
1198 | 1198 | ||
1199 | case ICAL_SUMMARY_PROPERTY: // summary | 1199 | case ICAL_SUMMARY_PROPERTY: // summary |
1200 | { | 1200 | { |
1201 | text = icalproperty_get_summary(p); | 1201 | text = icalproperty_get_summary(p); |
1202 | incidence->setSummary(QString::fromUtf8(text)); | 1202 | incidence->setSummary(QString::fromUtf8(text)); |
1203 | } | 1203 | } |
1204 | break; | 1204 | break; |
1205 | case ICAL_STATUS_PROPERTY: // summary | 1205 | case ICAL_STATUS_PROPERTY: // summary |
1206 | { | 1206 | { |
1207 | if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) | 1207 | if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) |
1208 | incidence->setCancelled( true ); | 1208 | incidence->setCancelled( true ); |
1209 | } | 1209 | } |
1210 | break; | 1210 | break; |
1211 | 1211 | ||
1212 | case ICAL_LOCATION_PROPERTY: // location | 1212 | case ICAL_LOCATION_PROPERTY: // location |
1213 | text = icalproperty_get_location(p); | 1213 | text = icalproperty_get_location(p); |
1214 | incidence->setLocation(QString::fromUtf8(text)); | 1214 | incidence->setLocation(QString::fromUtf8(text)); |
1215 | break; | 1215 | break; |
1216 | 1216 | ||
1217 | #if 0 | 1217 | #if 0 |
1218 | // status | 1218 | // status |
1219 | if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { | 1219 | if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { |
1220 | incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); | 1220 | incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); |
1221 | deleteStr(s); | 1221 | deleteStr(s); |
1222 | } | 1222 | } |
1223 | else | 1223 | else |
1224 | incidence->setStatus("NEEDS ACTION"); | 1224 | incidence->setStatus("NEEDS ACTION"); |
1225 | #endif | 1225 | #endif |
1226 | 1226 | ||
1227 | case ICAL_PRIORITY_PROPERTY: // priority | 1227 | case ICAL_PRIORITY_PROPERTY: // priority |
1228 | intvalue = icalproperty_get_priority(p); | 1228 | intvalue = icalproperty_get_priority(p); |
1229 | incidence->setPriority(intvalue); | 1229 | incidence->setPriority(intvalue); |
1230 | break; | 1230 | break; |
1231 | 1231 | ||
1232 | case ICAL_CATEGORIES_PROPERTY: // categories | 1232 | case ICAL_CATEGORIES_PROPERTY: // categories |
1233 | text = icalproperty_get_categories(p); | 1233 | text = icalproperty_get_categories(p); |
1234 | categories.append(QString::fromUtf8(text)); | 1234 | categories.append(QString::fromUtf8(text)); |
1235 | break; | 1235 | break; |
1236 | //******************************************* | 1236 | //******************************************* |
1237 | case ICAL_RRULE_PROPERTY: | 1237 | case ICAL_RRULE_PROPERTY: |
1238 | // we do need (maybe )start datetime of incidence for recurrence | 1238 | // we do need (maybe )start datetime of incidence for recurrence |
1239 | // such that we can read recurrence only after we read incidence completely | 1239 | // such that we can read recurrence only after we read incidence completely |
1240 | readrec = true; | 1240 | readrec = true; |
1241 | rectype = icalproperty_get_rrule(p); | 1241 | rectype = icalproperty_get_rrule(p); |
1242 | break; | 1242 | break; |
1243 | 1243 | ||
1244 | case ICAL_EXDATE_PROPERTY: | 1244 | case ICAL_EXDATE_PROPERTY: |
1245 | icaltime = icalproperty_get_exdate(p); | 1245 | icaltime = icalproperty_get_exdate(p); |
1246 | incidence->addExDate(readICalDate(icaltime)); | 1246 | incidence->addExDate(readICalDate(icaltime)); |
1247 | break; | 1247 | break; |
1248 | 1248 | ||
1249 | case ICAL_CLASS_PROPERTY: { | 1249 | case ICAL_CLASS_PROPERTY: { |
1250 | int inttext = icalproperty_get_class(p); | 1250 | int inttext = icalproperty_get_class(p); |
1251 | if (inttext == ICAL_CLASS_PUBLIC ) { | 1251 | if (inttext == ICAL_CLASS_PUBLIC ) { |
1252 | incidence->setSecrecy(Incidence::SecrecyPublic); | 1252 | incidence->setSecrecy(Incidence::SecrecyPublic); |
1253 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { | 1253 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { |
1254 | incidence->setSecrecy(Incidence::SecrecyConfidential); | 1254 | incidence->setSecrecy(Incidence::SecrecyConfidential); |
1255 | } else { | 1255 | } else { |
1256 | incidence->setSecrecy(Incidence::SecrecyPrivate); | 1256 | incidence->setSecrecy(Incidence::SecrecyPrivate); |
1257 | } | 1257 | } |
1258 | } | 1258 | } |
1259 | break; | 1259 | break; |
1260 | 1260 | ||
1261 | case ICAL_ATTACH_PROPERTY: // attachments | 1261 | case ICAL_ATTACH_PROPERTY: // attachments |
1262 | incidence->addAttachment(readAttachment(p)); | 1262 | incidence->addAttachment(readAttachment(p)); |
1263 | break; | 1263 | break; |
1264 | 1264 | ||
1265 | default: | 1265 | default: |
1266 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1266 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1267 | // << endl; | 1267 | // << endl; |
1268 | break; | 1268 | break; |
1269 | } | 1269 | } |
1270 | 1270 | ||
1271 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1271 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1272 | } | 1272 | } |
1273 | if ( readrec ) { | 1273 | if ( readrec ) { |
1274 | readRecurrenceRule(rectype,incidence); | 1274 | readRecurrenceRule(rectype,incidence); |
1275 | } | 1275 | } |
1276 | // kpilot stuff | 1276 | // kpilot stuff |
1277 | // TODO: move this application-specific code to kpilot | 1277 | // TODO: move this application-specific code to kpilot |
1278 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); | 1278 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); |
1279 | if (!kp.isNull()) { | 1279 | if (!kp.isNull()) { |
1280 | incidence->setPilotId(kp.toInt()); | 1280 | incidence->setPilotId(kp.toInt()); |
1281 | } | 1281 | } |
1282 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); | 1282 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); |
1283 | if (!kp.isNull()) { | 1283 | if (!kp.isNull()) { |
1284 | incidence->setSyncStatus(kp.toInt()); | 1284 | incidence->setSyncStatus(kp.toInt()); |
1285 | } | 1285 | } |
1286 | kp = incidence->nonKDECustomProperty("X-ZAURUSID"); | 1286 | kp = incidence->nonKDECustomProperty("X-ZAURUSID"); |
1287 | if (!kp.isNull()) { | 1287 | if (!kp.isNull()) { |
1288 | incidence->setZaurusId(kp.toInt()); | 1288 | incidence->setZaurusId(kp.toInt()); |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); | 1291 | kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); |
1292 | if (!kp.isNull()) { | 1292 | if (!kp.isNull()) { |
1293 | incidence->setZaurusUid(kp.toInt()); | 1293 | incidence->setZaurusUid(kp.toInt()); |
1294 | } | 1294 | } |
1295 | 1295 | ||
1296 | kp = incidence->nonKDECustomProperty("X-ZAURUSSTAT"); | 1296 | kp = incidence->nonKDECustomProperty("X-ZAURUSSTAT"); |
1297 | if (!kp.isNull()) { | 1297 | if (!kp.isNull()) { |
1298 | incidence->setZaurusStat(kp.toInt()); | 1298 | incidence->setZaurusStat(kp.toInt()); |
1299 | } | 1299 | } |
1300 | 1300 | ||
1301 | // Cancel backwards compatibility mode for subsequent changes by the application | 1301 | // Cancel backwards compatibility mode for subsequent changes by the application |
1302 | incidence->recurrence()->setCompatVersion(); | 1302 | incidence->recurrence()->setCompatVersion(); |
1303 | 1303 | ||
1304 | // add categories | 1304 | // add categories |
1305 | incidence->setCategories(categories); | 1305 | incidence->setCategories(categories); |
1306 | 1306 | ||
1307 | // iterate through all alarms | 1307 | // iterate through all alarms |
1308 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); | 1308 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); |
1309 | alarm; | 1309 | alarm; |
1310 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { | 1310 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { |
1311 | readAlarm(alarm,incidence); | 1311 | readAlarm(alarm,incidence); |
1312 | } | 1312 | } |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 1315 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) |
1316 | { | 1316 | { |
1317 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1317 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1318 | 1318 | ||
1319 | while (p) { | 1319 | while (p) { |
1320 | icalproperty_kind kind = icalproperty_isa(p); | 1320 | icalproperty_kind kind = icalproperty_isa(p); |
1321 | switch (kind) { | 1321 | switch (kind) { |
1322 | 1322 | ||
1323 | case ICAL_UID_PROPERTY: // unique id | 1323 | case ICAL_UID_PROPERTY: // unique id |
1324 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); | 1324 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); |
1325 | break; | 1325 | break; |
1326 | 1326 | ||
1327 | case ICAL_ORGANIZER_PROPERTY: // organizer | 1327 | case ICAL_ORGANIZER_PROPERTY: // organizer |
1328 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); | 1328 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); |
1329 | break; | 1329 | break; |
1330 | 1330 | ||
1331 | case ICAL_ATTENDEE_PROPERTY: // attendee | 1331 | case ICAL_ATTENDEE_PROPERTY: // attendee |
1332 | incidenceBase->addAttendee(readAttendee(p)); | 1332 | incidenceBase->addAttendee(readAttendee(p)); |
1333 | break; | 1333 | break; |
1334 | 1334 | ||
1335 | default: | 1335 | default: |
1336 | break; | 1336 | break; |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1339 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | // custom properties | 1342 | // custom properties |
1343 | readCustomProperties(parent, incidenceBase); | 1343 | readCustomProperties(parent, incidenceBase); |
1344 | } | 1344 | } |
1345 | 1345 | ||
1346 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) | 1346 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) |
1347 | { | 1347 | { |
1348 | QMap<QCString, QString> customProperties; | 1348 | QMap<QCString, QString> customProperties; |
1349 | 1349 | ||
1350 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); | 1350 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); |
1351 | 1351 | ||
1352 | while (p) { | 1352 | while (p) { |
1353 | QString value = QString::fromUtf8(icalproperty_get_x(p)); | 1353 | QString value = QString::fromUtf8(icalproperty_get_x(p)); |
1354 | customProperties[icalproperty_get_x_name(p)] = value; | 1354 | customProperties[icalproperty_get_x_name(p)] = value; |
1355 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); | 1355 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); |
1356 | 1356 | ||
1357 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); | 1357 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); |
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | properties->setCustomProperties(customProperties); | 1360 | properties->setCustomProperties(customProperties); |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) | 1363 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) |
1364 | { | 1364 | { |
1365 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; | 1365 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; |
1366 | 1366 | ||
1367 | Recurrence *recur = incidence->recurrence(); | 1367 | Recurrence *recur = incidence->recurrence(); |
1368 | recur->setCompatVersion(mCalendarVersion); | 1368 | recur->setCompatVersion(mCalendarVersion); |
1369 | recur->unsetRecurs(); | 1369 | recur->unsetRecurs(); |
1370 | 1370 | ||
1371 | struct icalrecurrencetype r = rrule; | 1371 | struct icalrecurrencetype r = rrule; |
1372 | 1372 | ||
1373 | dumpIcalRecurrence(r); | 1373 | dumpIcalRecurrence(r); |
1374 | readRecurrence( r, recur, incidence); | 1374 | readRecurrence( r, recur, incidence); |
1375 | } | 1375 | } |
1376 | 1376 | ||
1377 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) | 1377 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) |
1378 | { | 1378 | { |
1379 | int wkst; | 1379 | int wkst; |
1380 | int index = 0; | 1380 | int index = 0; |
1381 | short day = 0; | 1381 | short day = 0; |
1382 | QBitArray qba(7); | 1382 | QBitArray qba(7); |
1383 | int frequ = r.freq; | 1383 | int frequ = r.freq; |
1384 | int interv = r.interval; | 1384 | int interv = r.interval; |
1385 | // preprocessing for odd recurrence definitions | 1385 | // preprocessing for odd recurrence definitions |
1386 | 1386 | ||
1387 | if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { | 1387 | if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { |
1388 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1388 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1389 | interv = 12; | 1389 | interv = 12; |
1390 | } | 1390 | } |
1391 | } | 1391 | } |
1392 | if ( r.freq == ICAL_YEARLY_RECURRENCE ) { | 1392 | if ( r.freq == ICAL_YEARLY_RECURRENCE ) { |
1393 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1393 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1394 | frequ = ICAL_MONTHLY_RECURRENCE; | 1394 | frequ = ICAL_MONTHLY_RECURRENCE; |
1395 | interv = 12* r.interval; | 1395 | interv = 12* r.interval; |
1396 | } | 1396 | } |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | switch (frequ) { | 1399 | switch (frequ) { |
1400 | case ICAL_MINUTELY_RECURRENCE: | 1400 | case ICAL_MINUTELY_RECURRENCE: |
1401 | if (!icaltime_is_null_time(r.until)) { | 1401 | if (!icaltime_is_null_time(r.until)) { |
1402 | recur->setMinutely(interv,readICalDateTime(r.until)); | 1402 | recur->setMinutely(interv,readICalDateTime(r.until)); |
1403 | } else { | 1403 | } else { |
1404 | if (r.count == 0) | 1404 | if (r.count == 0) |
1405 | recur->setMinutely(interv,-1); | 1405 | recur->setMinutely(interv,-1); |
1406 | else | 1406 | else |
1407 | recur->setMinutely(interv,r.count); | 1407 | recur->setMinutely(interv,r.count); |
1408 | } | 1408 | } |
1409 | break; | 1409 | break; |
1410 | case ICAL_HOURLY_RECURRENCE: | 1410 | case ICAL_HOURLY_RECURRENCE: |
1411 | if (!icaltime_is_null_time(r.until)) { | 1411 | if (!icaltime_is_null_time(r.until)) { |
1412 | recur->setHourly(interv,readICalDateTime(r.until)); | 1412 | recur->setHourly(interv,readICalDateTime(r.until)); |
1413 | } else { | 1413 | } else { |
1414 | if (r.count == 0) | 1414 | if (r.count == 0) |
1415 | recur->setHourly(interv,-1); | 1415 | recur->setHourly(interv,-1); |
1416 | else | 1416 | else |
1417 | recur->setHourly(interv,r.count); | 1417 | recur->setHourly(interv,r.count); |
1418 | } | 1418 | } |
1419 | break; | 1419 | break; |
1420 | case ICAL_DAILY_RECURRENCE: | 1420 | case ICAL_DAILY_RECURRENCE: |
1421 | if (!icaltime_is_null_time(r.until)) { | 1421 | if (!icaltime_is_null_time(r.until)) { |
1422 | recur->setDaily(interv,readICalDate(r.until)); | 1422 | recur->setDaily(interv,readICalDate(r.until)); |
1423 | } else { | 1423 | } else { |
1424 | if (r.count == 0) | 1424 | if (r.count == 0) |
1425 | recur->setDaily(interv,-1); | 1425 | recur->setDaily(interv,-1); |
1426 | else | 1426 | else |
1427 | recur->setDaily(interv,r.count); | 1427 | recur->setDaily(interv,r.count); |
1428 | } | 1428 | } |
1429 | break; | 1429 | break; |
1430 | case ICAL_WEEKLY_RECURRENCE: | 1430 | case ICAL_WEEKLY_RECURRENCE: |
1431 | // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; | 1431 | // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; |
1432 | wkst = (r.week_start + 5)%7 + 1; | 1432 | wkst = (r.week_start + 5)%7 + 1; |
1433 | if (!icaltime_is_null_time(r.until)) { | 1433 | if (!icaltime_is_null_time(r.until)) { |
1434 | recur->setWeekly(interv,qba,readICalDate(r.until),wkst); | 1434 | recur->setWeekly(interv,qba,readICalDate(r.until),wkst); |
1435 | } else { | 1435 | } else { |
1436 | if (r.count == 0) | 1436 | if (r.count == 0) |
1437 | recur->setWeekly(interv,qba,-1,wkst); | 1437 | recur->setWeekly(interv,qba,-1,wkst); |
1438 | else | 1438 | else |
1439 | recur->setWeekly(interv,qba,r.count,wkst); | 1439 | recur->setWeekly(interv,qba,r.count,wkst); |
1440 | } | 1440 | } |
1441 | if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { | 1441 | if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { |
1442 | int wday = incidence->dtStart().date().dayOfWeek ()-1; | 1442 | int wday = incidence->dtStart().date().dayOfWeek ()-1; |
1443 | //qDebug("weekly error found "); | 1443 | //qDebug("weekly error found "); |
1444 | qba.setBit(wday); | 1444 | qba.setBit(wday); |
1445 | } else { | 1445 | } else { |
1446 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1446 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1447 | // kdDebug(5800) << " " << day << endl; | 1447 | // kdDebug(5800) << " " << day << endl; |
1448 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1448 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1449 | } | 1449 | } |
1450 | } | 1450 | } |
1451 | break; | 1451 | break; |
1452 | case ICAL_MONTHLY_RECURRENCE: | 1452 | case ICAL_MONTHLY_RECURRENCE: |
1453 | 1453 | ||
1454 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1454 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1455 | if (!icaltime_is_null_time(r.until)) { | 1455 | if (!icaltime_is_null_time(r.until)) { |
1456 | recur->setMonthly(Recurrence::rMonthlyPos,interv, | 1456 | recur->setMonthly(Recurrence::rMonthlyPos,interv, |
1457 | readICalDate(r.until)); | 1457 | readICalDate(r.until)); |
1458 | } else { | 1458 | } else { |
1459 | if (r.count == 0) | 1459 | if (r.count == 0) |
1460 | recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); | 1460 | recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); |
1461 | else | 1461 | else |
1462 | recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); | 1462 | recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); |
1463 | } | 1463 | } |
1464 | bool useSetPos = false; | 1464 | bool useSetPos = false; |
1465 | short pos = 0; | 1465 | short pos = 0; |
1466 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1466 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1467 | // kdDebug(5800) << "----a " << index << ": " << day << endl; | 1467 | // kdDebug(5800) << "----a " << index << ": " << day << endl; |
1468 | pos = icalrecurrencetype_day_position(day); | 1468 | pos = icalrecurrencetype_day_position(day); |
1469 | if (pos) { | 1469 | if (pos) { |
1470 | day = icalrecurrencetype_day_day_of_week(day); | 1470 | day = icalrecurrencetype_day_day_of_week(day); |
1471 | QBitArray ba(7); // don't wipe qba | 1471 | QBitArray ba(7); // don't wipe qba |
1472 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1472 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1473 | recur->addMonthlyPos(pos,ba); | 1473 | recur->addMonthlyPos(pos,ba); |
1474 | } else { | 1474 | } else { |
1475 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1475 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1476 | useSetPos = true; | 1476 | useSetPos = true; |
1477 | } | 1477 | } |
1478 | } | 1478 | } |
1479 | if (useSetPos) { | 1479 | if (useSetPos) { |
1480 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1480 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1481 | recur->addMonthlyPos(r.by_set_pos[0],qba); | 1481 | recur->addMonthlyPos(r.by_set_pos[0],qba); |
1482 | } | 1482 | } |
1483 | } | 1483 | } |
1484 | } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1484 | } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1485 | if (!icaltime_is_null_time(r.until)) { | 1485 | if (!icaltime_is_null_time(r.until)) { |
1486 | recur->setMonthly(Recurrence::rMonthlyDay,interv, | 1486 | recur->setMonthly(Recurrence::rMonthlyDay,interv, |
1487 | readICalDate(r.until)); | 1487 | readICalDate(r.until)); |
1488 | } else { | 1488 | } else { |
1489 | if (r.count == 0) | 1489 | if (r.count == 0) |
1490 | recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); | 1490 | recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); |
1491 | else | 1491 | else |
1492 | recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); | 1492 | recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); |
1493 | } | 1493 | } |
1494 | while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1494 | while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1495 | // kdDebug(5800) << "----b " << day << endl; | 1495 | // kdDebug(5800) << "----b " << day << endl; |
1496 | recur->addMonthlyDay(day); | 1496 | recur->addMonthlyDay(day); |
1497 | } | 1497 | } |
1498 | } | 1498 | } |
1499 | break; | 1499 | break; |
1500 | case ICAL_YEARLY_RECURRENCE: | 1500 | case ICAL_YEARLY_RECURRENCE: |
1501 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1501 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1502 | qDebug(" YEARLY DAY OF YEAR"); | 1502 | //qDebug(" YEARLY DAY OF YEAR"); |
1503 | if (!icaltime_is_null_time(r.until)) { | 1503 | if (!icaltime_is_null_time(r.until)) { |
1504 | recur->setYearly(Recurrence::rYearlyDay,interv, | 1504 | recur->setYearly(Recurrence::rYearlyDay,interv, |
1505 | readICalDate(r.until)); | 1505 | readICalDate(r.until)); |
1506 | } else { | 1506 | } else { |
1507 | if (r.count == 0) | 1507 | if (r.count == 0) |
1508 | recur->setYearly(Recurrence::rYearlyDay,interv,-1); | 1508 | recur->setYearly(Recurrence::rYearlyDay,interv,-1); |
1509 | else | 1509 | else |
1510 | recur->setYearly(Recurrence::rYearlyDay,interv,r.count); | 1510 | recur->setYearly(Recurrence::rYearlyDay,interv,r.count); |
1511 | } | 1511 | } |
1512 | while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1512 | while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1513 | recur->addYearlyNum(day); | 1513 | recur->addYearlyNum(day); |
1514 | } | 1514 | } |
1515 | } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { | 1515 | } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { |
1516 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1516 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1517 | qDebug("YEARLY POS NOT SUPPORTED BY GUI"); | 1517 | qDebug("YEARLY POS NOT SUPPORTED BY GUI"); |
1518 | if (!icaltime_is_null_time(r.until)) { | 1518 | if (!icaltime_is_null_time(r.until)) { |
1519 | recur->setYearly(Recurrence::rYearlyPos,interv, | 1519 | recur->setYearly(Recurrence::rYearlyPos,interv, |
1520 | readICalDate(r.until)); | 1520 | readICalDate(r.until)); |
1521 | } else { | 1521 | } else { |
1522 | if (r.count == 0) | 1522 | if (r.count == 0) |
1523 | recur->setYearly(Recurrence::rYearlyPos,interv,-1); | 1523 | recur->setYearly(Recurrence::rYearlyPos,interv,-1); |
1524 | else | 1524 | else |
1525 | recur->setYearly(Recurrence::rYearlyPos,interv,r.count); | 1525 | recur->setYearly(Recurrence::rYearlyPos,interv,r.count); |
1526 | } | 1526 | } |
1527 | bool useSetPos = false; | 1527 | bool useSetPos = false; |
1528 | short pos = 0; | 1528 | short pos = 0; |
1529 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1529 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1530 | // kdDebug(5800) << "----a " << index << ": " << day << endl; | 1530 | // kdDebug(5800) << "----a " << index << ": " << day << endl; |
1531 | pos = icalrecurrencetype_day_position(day); | 1531 | pos = icalrecurrencetype_day_position(day); |
1532 | if (pos) { | 1532 | if (pos) { |
1533 | day = icalrecurrencetype_day_day_of_week(day); | 1533 | day = icalrecurrencetype_day_day_of_week(day); |
1534 | QBitArray ba(7); // don't wipe qba | 1534 | QBitArray ba(7); // don't wipe qba |
1535 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1535 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1536 | recur->addYearlyMonthPos(pos,ba); | 1536 | recur->addYearlyMonthPos(pos,ba); |
1537 | } else { | 1537 | } else { |
1538 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1538 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1539 | useSetPos = true; | 1539 | useSetPos = true; |
1540 | } | 1540 | } |
1541 | } | 1541 | } |
1542 | if (useSetPos) { | 1542 | if (useSetPos) { |
1543 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1543 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1544 | recur->addYearlyMonthPos(r.by_set_pos[0],qba); | 1544 | recur->addYearlyMonthPos(r.by_set_pos[0],qba); |
1545 | } | 1545 | } |
1546 | } | 1546 | } |
1547 | } else { | 1547 | } else { |
1548 | qDebug("YEARLY MONTH "); | 1548 | //qDebug("YEARLY MONTH "); |
1549 | if (!icaltime_is_null_time(r.until)) { | 1549 | if (!icaltime_is_null_time(r.until)) { |
1550 | recur->setYearly(Recurrence::rYearlyMonth,interv, | 1550 | recur->setYearly(Recurrence::rYearlyMonth,interv, |
1551 | readICalDate(r.until)); | 1551 | readICalDate(r.until)); |
1552 | } else { | 1552 | } else { |
1553 | if (r.count == 0) | 1553 | if (r.count == 0) |
1554 | recur->setYearly(Recurrence::rYearlyMonth,interv,-1); | 1554 | recur->setYearly(Recurrence::rYearlyMonth,interv,-1); |
1555 | else | 1555 | else |
1556 | recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); | 1556 | recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); |
1557 | } | 1557 | } |
1558 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1558 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1559 | index = 0; | 1559 | index = 0; |
1560 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1560 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1561 | recur->addYearlyNum(day); | 1561 | recur->addYearlyNum(day); |
1562 | } | 1562 | } |
1563 | } else { | 1563 | } else { |
1564 | recur->addYearlyNum(incidence->dtStart().date().month()); | 1564 | recur->addYearlyNum(incidence->dtStart().date().month()); |
1565 | } | 1565 | } |
1566 | } | 1566 | } |
1567 | 1567 | ||
1568 | } | 1568 | } |
1569 | break; | 1569 | break; |
1570 | default: | 1570 | default: |
1571 | ; | 1571 | ; |
1572 | break; | 1572 | break; |
1573 | } | 1573 | } |
1574 | } | 1574 | } |
1575 | 1575 | ||
1576 | void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) | 1576 | void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) |
1577 | { | 1577 | { |
1578 | //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; | 1578 | //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; |
1579 | 1579 | ||
1580 | Alarm* ialarm = incidence->newAlarm(); | 1580 | Alarm* ialarm = incidence->newAlarm(); |
1581 | ialarm->setRepeatCount(0); | 1581 | ialarm->setRepeatCount(0); |
1582 | ialarm->setEnabled(true); | 1582 | ialarm->setEnabled(true); |
1583 | 1583 | ||
1584 | // Determine the alarm's action type | 1584 | // Determine the alarm's action type |
1585 | icalproperty *p = icalcomponent_get_first_property(alarm,ICAL_ACTION_PROPERTY); | 1585 | icalproperty *p = icalcomponent_get_first_property(alarm,ICAL_ACTION_PROPERTY); |
1586 | if ( !p ) { | 1586 | if ( !p ) { |
1587 | return; | 1587 | return; |
1588 | } | 1588 | } |
1589 | 1589 | ||
1590 | icalproperty_action action = icalproperty_get_action(p); | 1590 | icalproperty_action action = icalproperty_get_action(p); |
1591 | Alarm::Type type = Alarm::Display; | 1591 | Alarm::Type type = Alarm::Display; |
1592 | switch ( action ) { | 1592 | switch ( action ) { |
1593 | case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; | 1593 | case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; |
1594 | case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; | 1594 | case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; |
1595 | case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; | 1595 | case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; |
1596 | case ICAL_ACTION_EMAIL: type = Alarm::Email; break; | 1596 | case ICAL_ACTION_EMAIL: type = Alarm::Email; break; |
1597 | default: | 1597 | default: |
1598 | ; | 1598 | ; |
1599 | return; | 1599 | return; |
1600 | } | 1600 | } |
1601 | ialarm->setType(type); | 1601 | ialarm->setType(type); |
1602 | 1602 | ||
1603 | p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); | 1603 | p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); |
1604 | while (p) { | 1604 | while (p) { |
1605 | icalproperty_kind kind = icalproperty_isa(p); | 1605 | icalproperty_kind kind = icalproperty_isa(p); |
1606 | 1606 | ||
1607 | switch (kind) { | 1607 | switch (kind) { |
1608 | case ICAL_TRIGGER_PROPERTY: { | 1608 | case ICAL_TRIGGER_PROPERTY: { |
1609 | icaltriggertype trigger = icalproperty_get_trigger(p); | 1609 | icaltriggertype trigger = icalproperty_get_trigger(p); |
1610 | if (icaltime_is_null_time(trigger.time)) { | 1610 | if (icaltime_is_null_time(trigger.time)) { |
1611 | if (icaldurationtype_is_null_duration(trigger.duration)) { | 1611 | if (icaldurationtype_is_null_duration(trigger.duration)) { |
1612 | kdDebug(5800) << "ICalFormatImpl::readAlarm(): Trigger has no time and no duration." << endl; | 1612 | kdDebug(5800) << "ICalFormatImpl::readAlarm(): Trigger has no time and no duration." << endl; |
1613 | } else { | 1613 | } else { |
1614 | Duration duration = icaldurationtype_as_int( trigger.duration ); | 1614 | Duration duration = icaldurationtype_as_int( trigger.duration ); |
1615 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_RELATED_PARAMETER); | 1615 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_RELATED_PARAMETER); |
1616 | if (param && icalparameter_get_related(param) == ICAL_RELATED_END) | 1616 | if (param && icalparameter_get_related(param) == ICAL_RELATED_END) |
1617 | ialarm->setEndOffset(duration); | 1617 | ialarm->setEndOffset(duration); |
1618 | else | 1618 | else |
1619 | ialarm->setStartOffset(duration); | 1619 | ialarm->setStartOffset(duration); |
1620 | } | 1620 | } |
1621 | } else { | 1621 | } else { |
1622 | ialarm->setTime(readICalDateTime(trigger.time)); | 1622 | ialarm->setTime(readICalDateTime(trigger.time)); |
1623 | } | 1623 | } |
1624 | break; | 1624 | break; |
1625 | } | 1625 | } |
1626 | case ICAL_DURATION_PROPERTY: { | 1626 | case ICAL_DURATION_PROPERTY: { |
1627 | icaldurationtype duration = icalproperty_get_duration(p); | 1627 | icaldurationtype duration = icalproperty_get_duration(p); |
1628 | ialarm->setSnoozeTime(icaldurationtype_as_int(duration)/60); | 1628 | ialarm->setSnoozeTime(icaldurationtype_as_int(duration)/60); |
1629 | break; | 1629 | break; |
1630 | } | 1630 | } |
1631 | case ICAL_REPEAT_PROPERTY: | 1631 | case ICAL_REPEAT_PROPERTY: |
1632 | ialarm->setRepeatCount(icalproperty_get_repeat(p)); | 1632 | ialarm->setRepeatCount(icalproperty_get_repeat(p)); |
1633 | break; | 1633 | break; |
1634 | 1634 | ||
1635 | // Only in DISPLAY and EMAIL and PROCEDURE alarms | 1635 | // Only in DISPLAY and EMAIL and PROCEDURE alarms |
1636 | case ICAL_DESCRIPTION_PROPERTY: { | 1636 | case ICAL_DESCRIPTION_PROPERTY: { |
1637 | QString description = QString::fromUtf8(icalproperty_get_description(p)); | 1637 | QString description = QString::fromUtf8(icalproperty_get_description(p)); |
1638 | switch ( action ) { | 1638 | switch ( action ) { |
1639 | case ICAL_ACTION_DISPLAY: | 1639 | case ICAL_ACTION_DISPLAY: |
1640 | ialarm->setText( description ); | 1640 | ialarm->setText( description ); |
1641 | break; | 1641 | break; |
1642 | case ICAL_ACTION_PROCEDURE: | 1642 | case ICAL_ACTION_PROCEDURE: |
1643 | ialarm->setProgramArguments( description ); | 1643 | ialarm->setProgramArguments( description ); |
1644 | break; | 1644 | break; |
1645 | case ICAL_ACTION_EMAIL: | 1645 | case ICAL_ACTION_EMAIL: |
1646 | ialarm->setMailText( description ); | 1646 | ialarm->setMailText( description ); |
1647 | break; | 1647 | break; |
1648 | default: | 1648 | default: |
1649 | break; | 1649 | break; |
1650 | } | 1650 | } |
1651 | break; | 1651 | break; |
1652 | } | 1652 | } |
1653 | // Only in EMAIL alarm | 1653 | // Only in EMAIL alarm |
1654 | case ICAL_SUMMARY_PROPERTY: | 1654 | case ICAL_SUMMARY_PROPERTY: |
1655 | ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); | 1655 | ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); |
1656 | break; | 1656 | break; |
1657 | 1657 | ||
1658 | // Only in EMAIL alarm | 1658 | // Only in EMAIL alarm |
1659 | case ICAL_ATTENDEE_PROPERTY: { | 1659 | case ICAL_ATTENDEE_PROPERTY: { |
1660 | QString email = QString::fromUtf8(icalproperty_get_attendee(p)); | 1660 | QString email = QString::fromUtf8(icalproperty_get_attendee(p)); |
1661 | QString name; | 1661 | QString name; |
1662 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); | 1662 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); |
1663 | if (param) { | 1663 | if (param) { |
1664 | name = QString::fromUtf8(icalparameter_get_cn(param)); | 1664 | name = QString::fromUtf8(icalparameter_get_cn(param)); |
1665 | } | 1665 | } |
1666 | ialarm->addMailAddress(Person(name, email)); | 1666 | ialarm->addMailAddress(Person(name, email)); |
1667 | break; | 1667 | break; |
1668 | } | 1668 | } |
1669 | // Only in AUDIO and EMAIL and PROCEDURE alarms | 1669 | // Only in AUDIO and EMAIL and PROCEDURE alarms |
1670 | case ICAL_ATTACH_PROPERTY: { | 1670 | case ICAL_ATTACH_PROPERTY: { |
1671 | icalattach *attach = icalproperty_get_attach(p); | 1671 | icalattach *attach = icalproperty_get_attach(p); |
1672 | QString url = QFile::decodeName(icalattach_get_url(attach)); | 1672 | QString url = QFile::decodeName(icalattach_get_url(attach)); |
1673 | switch ( action ) { | 1673 | switch ( action ) { |
1674 | case ICAL_ACTION_AUDIO: | 1674 | case ICAL_ACTION_AUDIO: |
1675 | ialarm->setAudioFile( url ); | 1675 | ialarm->setAudioFile( url ); |
1676 | break; | 1676 | break; |
1677 | case ICAL_ACTION_PROCEDURE: | 1677 | case ICAL_ACTION_PROCEDURE: |
1678 | ialarm->setProgramFile( url ); | 1678 | ialarm->setProgramFile( url ); |
1679 | break; | 1679 | break; |
1680 | case ICAL_ACTION_EMAIL: | 1680 | case ICAL_ACTION_EMAIL: |
1681 | ialarm->addMailAttachment( url ); | 1681 | ialarm->addMailAttachment( url ); |
1682 | break; | 1682 | break; |
1683 | default: | 1683 | default: |
1684 | break; | 1684 | break; |
1685 | } | 1685 | } |
1686 | break; | 1686 | break; |
1687 | } | 1687 | } |
1688 | default: | 1688 | default: |
1689 | break; | 1689 | break; |
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | p = icalcomponent_get_next_property(alarm,ICAL_ANY_PROPERTY); | 1692 | p = icalcomponent_get_next_property(alarm,ICAL_ANY_PROPERTY); |
1693 | } | 1693 | } |
1694 | 1694 | ||
1695 | // custom properties | 1695 | // custom properties |
1696 | readCustomProperties(alarm, ialarm); | 1696 | readCustomProperties(alarm, ialarm); |
1697 | 1697 | ||
1698 | // TODO: check for consistency of alarm properties | 1698 | // TODO: check for consistency of alarm properties |
1699 | } | 1699 | } |
1700 | 1700 | ||
1701 | icaltimetype ICalFormatImpl::writeICalDate(const QDate &date) | 1701 | icaltimetype ICalFormatImpl::writeICalDate(const QDate &date) |
1702 | { | 1702 | { |
1703 | icaltimetype t; | 1703 | icaltimetype t; |
1704 | 1704 | ||
1705 | t.year = date.year(); | 1705 | t.year = date.year(); |
1706 | t.month = date.month(); | 1706 | t.month = date.month(); |
1707 | t.day = date.day(); | 1707 | t.day = date.day(); |
1708 | 1708 | ||
1709 | t.hour = 0; | 1709 | t.hour = 0; |
1710 | t.minute = 0; | 1710 | t.minute = 0; |
1711 | t.second = 0; | 1711 | t.second = 0; |
1712 | 1712 | ||
1713 | t.is_date = 1; | 1713 | t.is_date = 1; |
1714 | 1714 | ||
1715 | t.is_utc = 0; | 1715 | t.is_utc = 0; |
1716 | 1716 | ||
1717 | t.zone = 0; | 1717 | t.zone = 0; |
1718 | 1718 | ||
1719 | return t; | 1719 | return t; |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | icaltimetype ICalFormatImpl::writeICalDateTime(const QDateTime &dt ) | 1722 | icaltimetype ICalFormatImpl::writeICalDateTime(const QDateTime &dt ) |
1723 | { | 1723 | { |
1724 | icaltimetype t; | 1724 | icaltimetype t; |
1725 | t.is_date = 0; | 1725 | t.is_date = 0; |
1726 | t.zone = 0; | 1726 | t.zone = 0; |
1727 | QDateTime datetime; | 1727 | QDateTime datetime; |
1728 | if ( mParent->utc() ) { | 1728 | if ( mParent->utc() ) { |
1729 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 1729 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
1730 | datetime = dt.addSecs ( -offset*60); | 1730 | datetime = dt.addSecs ( -offset*60); |
1731 | t.is_utc = 1; | 1731 | t.is_utc = 1; |
1732 | } | 1732 | } |
1733 | else { | 1733 | else { |
1734 | datetime = dt; | 1734 | datetime = dt; |
1735 | t.is_utc = 0; | 1735 | t.is_utc = 0; |
1736 | 1736 | ||
1737 | } | 1737 | } |
1738 | t.year = datetime.date().year(); | 1738 | t.year = datetime.date().year(); |
1739 | t.month = datetime.date().month(); | 1739 | t.month = datetime.date().month(); |
1740 | t.day = datetime.date().day(); | 1740 | t.day = datetime.date().day(); |
1741 | 1741 | ||
1742 | t.hour = datetime.time().hour(); | 1742 | t.hour = datetime.time().hour(); |
1743 | t.minute = datetime.time().minute(); | 1743 | t.minute = datetime.time().minute(); |
1744 | t.second = datetime.time().second(); | 1744 | t.second = datetime.time().second(); |
1745 | 1745 | ||
1746 | //qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); | 1746 | //qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); |
1747 | 1747 | ||
1748 | // if ( mParent->utc() ) { | 1748 | // if ( mParent->utc() ) { |
1749 | // datetime = KGlobal::locale()->localTime( dt ); | 1749 | // datetime = KGlobal::locale()->localTime( dt ); |
1750 | // qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); | 1750 | // qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); |
1751 | // if (mParent->timeZoneId().isEmpty()) | 1751 | // if (mParent->timeZoneId().isEmpty()) |
1752 | // t = icaltime_as_utc(t, 0); | 1752 | // t = icaltime_as_utc(t, 0); |
1753 | // else | 1753 | // else |
1754 | // t = icaltime_as_utc(t,mParent->timeZoneId().local8Bit()); | 1754 | // t = icaltime_as_utc(t,mParent->timeZoneId().local8Bit()); |
1755 | // } | 1755 | // } |
1756 | 1756 | ||
1757 | return t; | 1757 | return t; |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | QDateTime ICalFormatImpl::readICalDateTime(icaltimetype t) | 1760 | QDateTime ICalFormatImpl::readICalDateTime(icaltimetype t) |
1761 | { | 1761 | { |
1762 | QDateTime dt (QDate(t.year,t.month,t.day), | 1762 | QDateTime dt (QDate(t.year,t.month,t.day), |
1763 | QTime(t.hour,t.minute,t.second) ); | 1763 | QTime(t.hour,t.minute,t.second) ); |
1764 | 1764 | ||
1765 | if (t.is_utc) { | 1765 | if (t.is_utc) { |
1766 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 1766 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
1767 | dt = dt.addSecs ( offset*60); | 1767 | dt = dt.addSecs ( offset*60); |
1768 | } | 1768 | } |
1769 | 1769 | ||
1770 | return dt; | 1770 | return dt; |
1771 | } | 1771 | } |
1772 | 1772 | ||
1773 | QDate ICalFormatImpl::readICalDate(icaltimetype t) | 1773 | QDate ICalFormatImpl::readICalDate(icaltimetype t) |
1774 | { | 1774 | { |
1775 | return QDate(t.year,t.month,t.day); | 1775 | return QDate(t.year,t.month,t.day); |
1776 | } | 1776 | } |
1777 | 1777 | ||
1778 | icaldurationtype ICalFormatImpl::writeICalDuration(int seconds) | 1778 | icaldurationtype ICalFormatImpl::writeICalDuration(int seconds) |
1779 | { | 1779 | { |
1780 | icaldurationtype d; | 1780 | icaldurationtype d; |
1781 | 1781 | ||
1782 | d.weeks = seconds % gSecondsPerWeek; | 1782 | d.weeks = seconds % gSecondsPerWeek; |
1783 | seconds -= d.weeks * gSecondsPerWeek; | 1783 | seconds -= d.weeks * gSecondsPerWeek; |
1784 | d.days = seconds % gSecondsPerDay; | 1784 | d.days = seconds % gSecondsPerDay; |
1785 | seconds -= d.days * gSecondsPerDay; | 1785 | seconds -= d.days * gSecondsPerDay; |
1786 | d.hours = seconds % gSecondsPerHour; | 1786 | d.hours = seconds % gSecondsPerHour; |
1787 | seconds -= d.hours * gSecondsPerHour; | 1787 | seconds -= d.hours * gSecondsPerHour; |
1788 | d.minutes = seconds % gSecondsPerMinute; | 1788 | d.minutes = seconds % gSecondsPerMinute; |
1789 | seconds -= d.minutes * gSecondsPerMinute; | 1789 | seconds -= d.minutes * gSecondsPerMinute; |
1790 | d.seconds = seconds; | 1790 | d.seconds = seconds; |
1791 | d.is_neg = 0; | 1791 | d.is_neg = 0; |
1792 | 1792 | ||
1793 | return d; | 1793 | return d; |
1794 | } | 1794 | } |
1795 | 1795 | ||
1796 | int ICalFormatImpl::readICalDuration(icaldurationtype d) | 1796 | int ICalFormatImpl::readICalDuration(icaldurationtype d) |
1797 | { | 1797 | { |
1798 | int result = 0; | 1798 | int result = 0; |
1799 | 1799 | ||
1800 | result += d.weeks * gSecondsPerWeek; | 1800 | result += d.weeks * gSecondsPerWeek; |
1801 | result += d.days * gSecondsPerDay; | 1801 | result += d.days * gSecondsPerDay; |
1802 | result += d.hours * gSecondsPerHour; | 1802 | result += d.hours * gSecondsPerHour; |
1803 | result += d.minutes * gSecondsPerMinute; | 1803 | result += d.minutes * gSecondsPerMinute; |
1804 | result += d.seconds; | 1804 | result += d.seconds; |
1805 | 1805 | ||
1806 | if (d.is_neg) result *= -1; | 1806 | if (d.is_neg) result *= -1; |
1807 | 1807 | ||
1808 | return result; | 1808 | return result; |
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | icalcomponent *ICalFormatImpl::createCalendarComponent(Calendar *cal) | 1811 | icalcomponent *ICalFormatImpl::createCalendarComponent(Calendar *cal) |
1812 | { | 1812 | { |
1813 | icalcomponent *calendar; | 1813 | icalcomponent *calendar; |
1814 | 1814 | ||
1815 | // Root component | 1815 | // Root component |
1816 | calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT); | 1816 | calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT); |
1817 | 1817 | ||
1818 | icalproperty *p; | 1818 | icalproperty *p; |
1819 | 1819 | ||
1820 | // Product Identifier | 1820 | // Product Identifier |
1821 | p = icalproperty_new_prodid(CalFormat::productId().utf8()); | 1821 | p = icalproperty_new_prodid(CalFormat::productId().utf8()); |
1822 | icalcomponent_add_property(calendar,p); | 1822 | icalcomponent_add_property(calendar,p); |
1823 | 1823 | ||
1824 | // TODO: Add time zone | 1824 | // TODO: Add time zone |
1825 | 1825 | ||
1826 | // iCalendar version (2.0) | 1826 | // iCalendar version (2.0) |
1827 | p = icalproperty_new_version(const_cast<char *>(_ICAL_VERSION)); | 1827 | p = icalproperty_new_version(const_cast<char *>(_ICAL_VERSION)); |
1828 | icalcomponent_add_property(calendar,p); | 1828 | icalcomponent_add_property(calendar,p); |
1829 | 1829 | ||
1830 | // Custom properties | 1830 | // Custom properties |
1831 | if( cal != 0 ) | 1831 | if( cal != 0 ) |
1832 | writeCustomProperties(calendar, cal); | 1832 | writeCustomProperties(calendar, cal); |
1833 | 1833 | ||
1834 | return calendar; | 1834 | return calendar; |
1835 | } | 1835 | } |
1836 | 1836 | ||
1837 | 1837 | ||
1838 | 1838 | ||
1839 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. | 1839 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. |
1840 | // and break it down from its tree-like format into the dictionary format | 1840 | // and break it down from its tree-like format into the dictionary format |
1841 | // that is used internally in the ICalFormatImpl. | 1841 | // that is used internally in the ICalFormatImpl. |
1842 | bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar) | 1842 | bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar) |
1843 | { | 1843 | { |
1844 | // this function will populate the caldict dictionary and other event | 1844 | // this function will populate the caldict dictionary and other event |
1845 | // lists. It turns vevents into Events and then inserts them. | 1845 | // lists. It turns vevents into Events and then inserts them. |
1846 | 1846 | ||
1847 | if (!calendar) return false; | 1847 | if (!calendar) return false; |
1848 | 1848 | ||
1849 | // TODO: check for METHOD | 1849 | // TODO: check for METHOD |
1850 | #if 0 | 1850 | #if 0 |
1851 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { | 1851 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { |
1852 | char *methodType = 0; | 1852 | char *methodType = 0; |
1853 | methodType = fakeCString(vObjectUStringZValue(curVO)); | 1853 | methodType = fakeCString(vObjectUStringZValue(curVO)); |
1854 | if (mEnableDialogs) | 1854 | if (mEnableDialogs) |
1855 | KMessageBox::information(mTopWidget, | 1855 | KMessageBox::information(mTopWidget, |
1856 | i18n("This calendar is an iTIP transaction of type \"%1\".") | 1856 | i18n("This calendar is an iTIP transaction of type \"%1\".") |
1857 | .arg(methodType), | 1857 | .arg(methodType), |
1858 | i18n("%1: iTIP Transaction").arg(CalFormat::application())); | 1858 | i18n("%1: iTIP Transaction").arg(CalFormat::application())); |
1859 | delete methodType; | 1859 | delete methodType; |
1860 | } | 1860 | } |
1861 | #endif | 1861 | #endif |
1862 | 1862 | ||
1863 | icalproperty *p; | 1863 | icalproperty *p; |
1864 | 1864 | ||
1865 | p = icalcomponent_get_first_property(calendar,ICAL_PRODID_PROPERTY); | 1865 | p = icalcomponent_get_first_property(calendar,ICAL_PRODID_PROPERTY); |
1866 | if (!p) { | 1866 | if (!p) { |
1867 | // TODO: does no PRODID really matter? | 1867 | // TODO: does no PRODID really matter? |
1868 | // mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 1868 | // mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
1869 | // return false; | 1869 | // return false; |
1870 | mLoadedProductId = ""; | 1870 | mLoadedProductId = ""; |
1871 | mCalendarVersion = 0; | 1871 | mCalendarVersion = 0; |
1872 | } else { | 1872 | } else { |
1873 | mLoadedProductId = QString::fromUtf8(icalproperty_get_prodid(p)); | 1873 | mLoadedProductId = QString::fromUtf8(icalproperty_get_prodid(p)); |
1874 | mCalendarVersion = CalFormat::calendarVersion(mLoadedProductId); | 1874 | mCalendarVersion = CalFormat::calendarVersion(mLoadedProductId); |
1875 | 1875 | ||
1876 | delete mCompat; | 1876 | delete mCompat; |
1877 | mCompat = CompatFactory::createCompat( mLoadedProductId ); | 1877 | mCompat = CompatFactory::createCompat( mLoadedProductId ); |
1878 | } | 1878 | } |
1879 | 1879 | ||
1880 | // TODO: check for unknown PRODID | 1880 | // TODO: check for unknown PRODID |
1881 | #if 0 | 1881 | #if 0 |
1882 | if (!mCalendarVersion | 1882 | if (!mCalendarVersion |
1883 | && CalFormat::productId() != mLoadedProductId) { | 1883 | && CalFormat::productId() != mLoadedProductId) { |
1884 | // warn the user that we might have trouble reading non-known calendar. | 1884 | // warn the user that we might have trouble reading non-known calendar. |
1885 | if (mEnableDialogs) | 1885 | if (mEnableDialogs) |
1886 | KMessageBox::information(mTopWidget, | 1886 | KMessageBox::information(mTopWidget, |
1887 | i18n("This vCalendar file was not created by KOrganizer " | 1887 | i18n("This vCalendar file was not created by KOrganizer " |
1888 | "or any other product we support. Loading anyway..."), | 1888 | "or any other product we support. Loading anyway..."), |
1889 | i18n("%1: Unknown vCalendar Vendor").arg(CalFormat::application())); | 1889 | i18n("%1: Unknown vCalendar Vendor").arg(CalFormat::application())); |
1890 | } | 1890 | } |
1891 | #endif | 1891 | #endif |
1892 | 1892 | ||
1893 | p = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY); | 1893 | p = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY); |
1894 | if (!p) { | 1894 | if (!p) { |
1895 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 1895 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
1896 | return false; | 1896 | return false; |
1897 | } else { | 1897 | } else { |
1898 | const char *version = icalproperty_get_version(p); | 1898 | const char *version = icalproperty_get_version(p); |
1899 | 1899 | ||
1900 | if (strcmp(version,"1.0") == 0) { | 1900 | if (strcmp(version,"1.0") == 0) { |
1901 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersion1, | 1901 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersion1, |
1902 | i18n("Expected iCalendar format"))); | 1902 | i18n("Expected iCalendar format"))); |
1903 | return false; | 1903 | return false; |
1904 | } else if (strcmp(version,"2.0") != 0) { | 1904 | } else if (strcmp(version,"2.0") != 0) { |
1905 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 1905 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
1906 | return false; | 1906 | return false; |
1907 | } | 1907 | } |
1908 | } | 1908 | } |
1909 | 1909 | ||
1910 | 1910 | ||
1911 | // TODO: check for calendar format version | 1911 | // TODO: check for calendar format version |
1912 | #if 0 | 1912 | #if 0 |
1913 | // warn the user we might have trouble reading this unknown version. | 1913 | // warn the user we might have trouble reading this unknown version. |
1914 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1914 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1915 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1915 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1916 | if (strcmp(_VCAL_VERSION, s) != 0) | 1916 | if (strcmp(_VCAL_VERSION, s) != 0) |
1917 | if (mEnableDialogs) | 1917 | if (mEnableDialogs) |
1918 | KMessageBox::sorry(mTopWidget, | 1918 | KMessageBox::sorry(mTopWidget, |
1919 | i18n("This vCalendar file has version %1.\n" | 1919 | i18n("This vCalendar file has version %1.\n" |
1920 | "We only support %2.") | 1920 | "We only support %2.") |
1921 | .arg(s).arg(_VCAL_VERSION), | 1921 | .arg(s).arg(_VCAL_VERSION), |
1922 | i18n("%1: Unknown vCalendar Version").arg(CalFormat::application())); | 1922 | i18n("%1: Unknown vCalendar Version").arg(CalFormat::application())); |
1923 | deleteStr(s); | 1923 | deleteStr(s); |
1924 | } | 1924 | } |
1925 | #endif | 1925 | #endif |
1926 | 1926 | ||
1927 | // custom properties | 1927 | // custom properties |
1928 | readCustomProperties(calendar, cal); | 1928 | readCustomProperties(calendar, cal); |
1929 | 1929 | ||
1930 | // TODO: set time zone | 1930 | // TODO: set time zone |
1931 | #if 0 | 1931 | #if 0 |
1932 | // set the time zone | 1932 | // set the time zone |
1933 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1933 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1934 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1934 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1935 | cal->setTimeZone(s); | 1935 | cal->setTimeZone(s); |
1936 | deleteStr(s); | 1936 | deleteStr(s); |
1937 | } | 1937 | } |
1938 | #endif | 1938 | #endif |
1939 | 1939 | ||
1940 | // Store all events with a relatedTo property in a list for post-processing | 1940 | // Store all events with a relatedTo property in a list for post-processing |
1941 | mEventsRelate.clear(); | 1941 | mEventsRelate.clear(); |
1942 | mTodosRelate.clear(); | 1942 | mTodosRelate.clear(); |
1943 | // TODO: make sure that only actually added ecvens go to this lists. | 1943 | // TODO: make sure that only actually added ecvens go to this lists. |
1944 | 1944 | ||
1945 | icalcomponent *c; | 1945 | icalcomponent *c; |
1946 | 1946 | ||
1947 | // Iterate through all todos | 1947 | // Iterate through all todos |
1948 | c = icalcomponent_get_first_component(calendar,ICAL_VTODO_COMPONENT); | 1948 | c = icalcomponent_get_first_component(calendar,ICAL_VTODO_COMPONENT); |
1949 | while (c) { | 1949 | while (c) { |
1950 | // kdDebug(5800) << "----Todo found" << endl; | 1950 | // kdDebug(5800) << "----Todo found" << endl; |
1951 | Todo *todo = readTodo(c); | 1951 | Todo *todo = readTodo(c); |
1952 | if (!cal->todo(todo->uid())) cal->addTodo(todo); | 1952 | if (!cal->todo(todo->uid())) cal->addTodo(todo); |
1953 | c = icalcomponent_get_next_component(calendar,ICAL_VTODO_COMPONENT); | 1953 | c = icalcomponent_get_next_component(calendar,ICAL_VTODO_COMPONENT); |
1954 | } | 1954 | } |
1955 | 1955 | ||
1956 | // Iterate through all events | 1956 | // Iterate through all events |
1957 | c = icalcomponent_get_first_component(calendar,ICAL_VEVENT_COMPONENT); | 1957 | c = icalcomponent_get_first_component(calendar,ICAL_VEVENT_COMPONENT); |
1958 | while (c) { | 1958 | while (c) { |
1959 | // kdDebug(5800) << "----Event found" << endl; | 1959 | // kdDebug(5800) << "----Event found" << endl; |
1960 | Event *event = readEvent(c); | 1960 | Event *event = readEvent(c); |
1961 | if (!cal->event(event->uid())) cal->addEvent(event); | 1961 | if (!cal->event(event->uid())) cal->addEvent(event); |
1962 | c = icalcomponent_get_next_component(calendar,ICAL_VEVENT_COMPONENT); | 1962 | c = icalcomponent_get_next_component(calendar,ICAL_VEVENT_COMPONENT); |
1963 | } | 1963 | } |
1964 | 1964 | ||
1965 | // Iterate through all journals | 1965 | // Iterate through all journals |
1966 | c = icalcomponent_get_first_component(calendar,ICAL_VJOURNAL_COMPONENT); | 1966 | c = icalcomponent_get_first_component(calendar,ICAL_VJOURNAL_COMPONENT); |
1967 | while (c) { | 1967 | while (c) { |
1968 | // kdDebug(5800) << "----Journal found" << endl; | 1968 | // kdDebug(5800) << "----Journal found" << endl; |
1969 | Journal *journal = readJournal(c); | 1969 | Journal *journal = readJournal(c); |
1970 | if (!cal->journal(journal->uid())) cal->addJournal(journal); | 1970 | if (!cal->journal(journal->uid())) cal->addJournal(journal); |
1971 | c = icalcomponent_get_next_component(calendar,ICAL_VJOURNAL_COMPONENT); | 1971 | c = icalcomponent_get_next_component(calendar,ICAL_VJOURNAL_COMPONENT); |
1972 | } | 1972 | } |
1973 | 1973 | ||
1974 | #if 0 | 1974 | #if 0 |
1975 | initPropIterator(&i, vcal); | 1975 | initPropIterator(&i, vcal); |
1976 | 1976 | ||
1977 | // go through all the vobjects in the vcal | 1977 | // go through all the vobjects in the vcal |
1978 | while (moreIteration(&i)) { | 1978 | while (moreIteration(&i)) { |
1979 | curVO = nextVObject(&i); | 1979 | curVO = nextVObject(&i); |
1980 | 1980 | ||
1981 | /************************************************************************/ | 1981 | /************************************************************************/ |
1982 | 1982 | ||
1983 | // now, check to see that the object is an event or todo. | 1983 | // now, check to see that the object is an event or todo. |
1984 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1984 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1985 | 1985 | ||
1986 | if ((curVOProp = isAPropertyOf(curVO, KPilotStatusProp)) != 0) { | 1986 | if ((curVOProp = isAPropertyOf(curVO, KPilotStatusProp)) != 0) { |
1987 | char *s; | 1987 | char *s; |
1988 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1988 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1989 | // check to see if event was deleted by the kpilot conduit | 1989 | // check to see if event was deleted by the kpilot conduit |
1990 | if (atoi(s) == Event::SYNCDEL) { | 1990 | if (atoi(s) == Event::SYNCDEL) { |
1991 | deleteStr(s); | 1991 | deleteStr(s); |
1992 | goto SKIP; | 1992 | goto SKIP; |
1993 | } | 1993 | } |
1994 | deleteStr(s); | 1994 | deleteStr(s); |
1995 | } | 1995 | } |
1996 | 1996 | ||
1997 | // this code checks to see if we are trying to read in an event | 1997 | // this code checks to see if we are trying to read in an event |
1998 | // that we already find to be in the calendar. If we find this | 1998 | // that we already find to be in the calendar. If we find this |
1999 | // to be the case, we skip the event. | 1999 | // to be the case, we skip the event. |
2000 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 2000 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
2001 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 2001 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
2002 | QString tmpStr(s); | 2002 | QString tmpStr(s); |
2003 | deleteStr(s); | 2003 | deleteStr(s); |
2004 | 2004 | ||
2005 | if (cal->event(tmpStr)) { | 2005 | if (cal->event(tmpStr)) { |
2006 | goto SKIP; | 2006 | goto SKIP; |
2007 | } | 2007 | } |
2008 | if (cal->todo(tmpStr)) { | 2008 | if (cal->todo(tmpStr)) { |
2009 | goto SKIP; | 2009 | goto SKIP; |
2010 | } | 2010 | } |
2011 | } | 2011 | } |
2012 | 2012 | ||
2013 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && | 2013 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && |
2014 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { | 2014 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { |
2015 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 2015 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
2016 | goto SKIP; | 2016 | goto SKIP; |
2017 | } | 2017 | } |
2018 | 2018 | ||
2019 | anEvent = VEventToEvent(curVO); | 2019 | anEvent = VEventToEvent(curVO); |
2020 | // we now use addEvent instead of insertEvent so that the | 2020 | // we now use addEvent instead of insertEvent so that the |
2021 | // signal/slot get connected. | 2021 | // signal/slot get connected. |
2022 | if (anEvent) | 2022 | if (anEvent) |
2023 | cal->addEvent(anEvent); | 2023 | cal->addEvent(anEvent); |
2024 | else { | 2024 | else { |
2025 | // some sort of error must have occurred while in translation. | 2025 | // some sort of error must have occurred while in translation. |
2026 | goto SKIP; | 2026 | goto SKIP; |
2027 | } | 2027 | } |
2028 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { | 2028 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { |
2029 | anEvent = VTodoToEvent(curVO); | 2029 | anEvent = VTodoToEvent(curVO); |
2030 | cal->addTodo(anEvent); | 2030 | cal->addTodo(anEvent); |
2031 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || | 2031 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || |
2032 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || | 2032 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || |
2033 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { | 2033 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { |
2034 | // do nothing, we know these properties and we want to skip them. | 2034 | // do nothing, we know these properties and we want to skip them. |
2035 | // we have either already processed them or are ignoring them. | 2035 | // we have either already processed them or are ignoring them. |
2036 | ; | 2036 | ; |
2037 | } else { | 2037 | } else { |
2038 | ; | 2038 | ; |
2039 | } | 2039 | } |
2040 | SKIP: | 2040 | SKIP: |
2041 | ; | 2041 | ; |
2042 | } // while | 2042 | } // while |
2043 | #endif | 2043 | #endif |
2044 | 2044 | ||
2045 | // Post-Process list of events with relations, put Event objects in relation | 2045 | // Post-Process list of events with relations, put Event objects in relation |
2046 | Event *ev; | 2046 | Event *ev; |
2047 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { | 2047 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { |
2048 | ev->setRelatedTo(cal->event(ev->relatedToUid())); | 2048 | ev->setRelatedTo(cal->event(ev->relatedToUid())); |
2049 | } | 2049 | } |
2050 | Todo *todo; | 2050 | Todo *todo; |
2051 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { | 2051 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { |
2052 | todo->setRelatedTo(cal->todo(todo->relatedToUid())); | 2052 | todo->setRelatedTo(cal->todo(todo->relatedToUid())); |
2053 | } | 2053 | } |
2054 | 2054 | ||
2055 | return true; | 2055 | return true; |
2056 | } | 2056 | } |
2057 | 2057 | ||
2058 | QString ICalFormatImpl::extractErrorProperty(icalcomponent *c) | 2058 | QString ICalFormatImpl::extractErrorProperty(icalcomponent *c) |
2059 | { | 2059 | { |
2060 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " | 2060 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " |
2061 | // << icalcomponent_as_ical_string(c) << endl; | 2061 | // << icalcomponent_as_ical_string(c) << endl; |
2062 | 2062 | ||
2063 | QString errorMessage; | 2063 | QString errorMessage; |
2064 | 2064 | ||
2065 | icalproperty *error; | 2065 | icalproperty *error; |
2066 | error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY); | 2066 | error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY); |
2067 | while(error) { | 2067 | while(error) { |
2068 | errorMessage += icalproperty_get_xlicerror(error); | 2068 | errorMessage += icalproperty_get_xlicerror(error); |
2069 | errorMessage += "\n"; | 2069 | errorMessage += "\n"; |
2070 | error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY); | 2070 | error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY); |
2071 | } | 2071 | } |
2072 | 2072 | ||
2073 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl; | 2073 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl; |
2074 | 2074 | ||
2075 | return errorMessage; | 2075 | return errorMessage; |
2076 | } | 2076 | } |
2077 | 2077 | ||
2078 | void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r) | 2078 | void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r) |
2079 | { | 2079 | { |
2080 | int i; | 2080 | int i; |
2081 | 2081 | ||
2082 | 2082 | ||
2083 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2083 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2084 | int index = 0; | 2084 | int index = 0; |
2085 | QString out = " By Day: "; | 2085 | QString out = " By Day: "; |
2086 | while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2086 | while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2087 | out.append(QString::number(i) + " "); | 2087 | out.append(QString::number(i) + " "); |
2088 | } | 2088 | } |
2089 | } | 2089 | } |
2090 | if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2090 | if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2091 | int index = 0; | 2091 | int index = 0; |
2092 | QString out = " By Month Day: "; | 2092 | QString out = " By Month Day: "; |
2093 | while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2093 | while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2094 | out.append(QString::number(i) + " "); | 2094 | out.append(QString::number(i) + " "); |
2095 | } | 2095 | } |
2096 | } | 2096 | } |
2097 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2097 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2098 | int index = 0; | 2098 | int index = 0; |
2099 | QString out = " By Year Day: "; | 2099 | QString out = " By Year Day: "; |
2100 | while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2100 | while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2101 | out.append(QString::number(i) + " "); | 2101 | out.append(QString::number(i) + " "); |
2102 | } | 2102 | } |
2103 | } | 2103 | } |
2104 | if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2104 | if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2105 | int index = 0; | 2105 | int index = 0; |
2106 | QString out = " By Month: "; | 2106 | QString out = " By Month: "; |
2107 | while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2107 | while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2108 | out.append(QString::number(i) + " "); | 2108 | out.append(QString::number(i) + " "); |
2109 | } | 2109 | } |
2110 | } | 2110 | } |
2111 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2111 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2112 | int index = 0; | 2112 | int index = 0; |
2113 | QString out = " By Set Pos: "; | 2113 | QString out = " By Set Pos: "; |
2114 | while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2114 | while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2115 | out.append(QString::number(i) + " "); | 2115 | out.append(QString::number(i) + " "); |
2116 | } | 2116 | } |
2117 | } | 2117 | } |
2118 | } | 2118 | } |
2119 | 2119 | ||
2120 | icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence, | 2120 | icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence, |
2121 | Scheduler::Method method) | 2121 | Scheduler::Method method) |
2122 | { | 2122 | { |
2123 | icalcomponent *message = createCalendarComponent(); | 2123 | icalcomponent *message = createCalendarComponent(); |
2124 | 2124 | ||
2125 | icalproperty_method icalmethod = ICAL_METHOD_NONE; | 2125 | icalproperty_method icalmethod = ICAL_METHOD_NONE; |
2126 | 2126 | ||
2127 | switch (method) { | 2127 | switch (method) { |
2128 | case Scheduler::Publish: | 2128 | case Scheduler::Publish: |
2129 | icalmethod = ICAL_METHOD_PUBLISH; | 2129 | icalmethod = ICAL_METHOD_PUBLISH; |
2130 | break; | 2130 | break; |
2131 | case Scheduler::Request: | 2131 | case Scheduler::Request: |
2132 | icalmethod = ICAL_METHOD_REQUEST; | 2132 | icalmethod = ICAL_METHOD_REQUEST; |
2133 | break; | 2133 | break; |
2134 | case Scheduler::Refresh: | 2134 | case Scheduler::Refresh: |
2135 | icalmethod = ICAL_METHOD_REFRESH; | 2135 | icalmethod = ICAL_METHOD_REFRESH; |
2136 | break; | 2136 | break; |
2137 | case Scheduler::Cancel: | 2137 | case Scheduler::Cancel: |
2138 | icalmethod = ICAL_METHOD_CANCEL; | 2138 | icalmethod = ICAL_METHOD_CANCEL; |
2139 | break; | 2139 | break; |
2140 | case Scheduler::Add: | 2140 | case Scheduler::Add: |
2141 | icalmethod = ICAL_METHOD_ADD; | 2141 | icalmethod = ICAL_METHOD_ADD; |
2142 | break; | 2142 | break; |
2143 | case Scheduler::Reply: | 2143 | case Scheduler::Reply: |
2144 | icalmethod = ICAL_METHOD_REPLY; | 2144 | icalmethod = ICAL_METHOD_REPLY; |
2145 | break; | 2145 | break; |
2146 | case Scheduler::Counter: | 2146 | case Scheduler::Counter: |
2147 | icalmethod = ICAL_METHOD_COUNTER; | 2147 | icalmethod = ICAL_METHOD_COUNTER; |
2148 | break; | 2148 | break; |
2149 | case Scheduler::Declinecounter: | 2149 | case Scheduler::Declinecounter: |
2150 | icalmethod = ICAL_METHOD_DECLINECOUNTER; | 2150 | icalmethod = ICAL_METHOD_DECLINECOUNTER; |
2151 | break; | 2151 | break; |
2152 | default: | 2152 | default: |
2153 | 2153 | ||
2154 | return message; | 2154 | return message; |
2155 | } | 2155 | } |
2156 | 2156 | ||
2157 | icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); | 2157 | icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); |
2158 | 2158 | ||
2159 | // TODO: check, if dynamic cast is required | 2159 | // TODO: check, if dynamic cast is required |
2160 | if(incidence->type() == "Todo") { | 2160 | if(incidence->type() == "Todo") { |
2161 | Todo *todo = static_cast<Todo *>(incidence); | 2161 | Todo *todo = static_cast<Todo *>(incidence); |
2162 | icalcomponent_add_component(message,writeTodo(todo)); | 2162 | icalcomponent_add_component(message,writeTodo(todo)); |
2163 | } | 2163 | } |
2164 | if(incidence->type() == "Event") { | 2164 | if(incidence->type() == "Event") { |
2165 | Event *event = static_cast<Event *>(incidence); | 2165 | Event *event = static_cast<Event *>(incidence); |
2166 | icalcomponent_add_component(message,writeEvent(event)); | 2166 | icalcomponent_add_component(message,writeEvent(event)); |
2167 | } | 2167 | } |
2168 | if(incidence->type() == "FreeBusy") { | 2168 | if(incidence->type() == "FreeBusy") { |
2169 | FreeBusy *freebusy = static_cast<FreeBusy *>(incidence); | 2169 | FreeBusy *freebusy = static_cast<FreeBusy *>(incidence); |
2170 | icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); | 2170 | icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | return message; | 2173 | return message; |
2174 | } | 2174 | } |