-rw-r--r-- | libkcal/vcalformat.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 309c699..a6ae1bc 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -1,1717 +1,1713 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brwon | 3 | Copyright (c) 1998 Preston Brwon |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qclipboard.h> | 27 | #include <qclipboard.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kmessagebox.h> | 33 | #include <kmessagebox.h> |
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | 36 | ||
37 | #include "vcc.h" | 37 | #include "vcc.h" |
38 | #include "vobject.h" | 38 | #include "vobject.h" |
39 | 39 | ||
40 | #include "vcaldrag.h" | 40 | #include "vcaldrag.h" |
41 | #include "calendar.h" | 41 | #include "calendar.h" |
42 | 42 | ||
43 | #include "vcalformat.h" | 43 | #include "vcalformat.h" |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | VCalFormat::VCalFormat() | 47 | VCalFormat::VCalFormat() |
48 | { | 48 | { |
49 | mCalendar = 0; | 49 | mCalendar = 0; |
50 | useLocalTime = false; | 50 | useLocalTime = false; |
51 | } | 51 | } |
52 | 52 | ||
53 | VCalFormat::~VCalFormat() | 53 | VCalFormat::~VCalFormat() |
54 | { | 54 | { |
55 | } | 55 | } |
56 | 56 | ||
57 | void VCalFormat::setLocalTime ( bool b ) | 57 | void VCalFormat::setLocalTime ( bool b ) |
58 | { | 58 | { |
59 | useLocalTime = b; | 59 | useLocalTime = b; |
60 | } | 60 | } |
61 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) | 61 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) |
62 | { | 62 | { |
63 | mCalendar = calendar; | 63 | mCalendar = calendar; |
64 | clearException(); | 64 | clearException(); |
65 | 65 | useLocalTime = mCalendar->isLocalTime(); | |
66 | kdDebug(5800) << "VCalFormat::load() " << fileName << endl; | ||
67 | |||
68 | VObject *vcal = 0; | 66 | VObject *vcal = 0; |
69 | 67 | ||
70 | // this is not necessarily only 1 vcal. Could be many vcals, or include | 68 | // this is not necessarily only 1 vcal. Could be many vcals, or include |
71 | // a vcard... | 69 | // a vcard... |
72 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); | 70 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); |
73 | 71 | ||
74 | if (!vcal) { | 72 | if (!vcal) { |
75 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 73 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
76 | return FALSE; | 74 | return FALSE; |
77 | } | 75 | } |
78 | 76 | ||
79 | // any other top-level calendar stuff should be added/initialized here | 77 | // any other top-level calendar stuff should be added/initialized here |
80 | 78 | ||
81 | // put all vobjects into their proper places | 79 | // put all vobjects into their proper places |
82 | populate(vcal); | 80 | populate(vcal); |
83 | 81 | ||
84 | // clean up from vcal API stuff | 82 | // clean up from vcal API stuff |
85 | cleanVObjects(vcal); | 83 | cleanVObjects(vcal); |
86 | cleanStrTbl(); | 84 | cleanStrTbl(); |
87 | 85 | ||
88 | return true; | 86 | return true; |
89 | } | 87 | } |
90 | 88 | ||
91 | 89 | ||
92 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) | 90 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) |
93 | { | 91 | { |
94 | mCalendar = calendar; | 92 | mCalendar = calendar; |
93 | useLocalTime = mCalendar->isLocalTime(); | ||
95 | 94 | ||
96 | QString tmpStr; | 95 | QString tmpStr; |
97 | VObject *vcal, *vo; | 96 | VObject *vcal, *vo; |
98 | 97 | ||
99 | kdDebug(5800) << "VCalFormat::save(): " << fileName << endl; | ||
100 | 98 | ||
101 | vcal = newVObject(VCCalProp); | 99 | vcal = newVObject(VCCalProp); |
102 | 100 | ||
103 | // addPropValue(vcal,VCLocationProp, "0.0"); | 101 | // addPropValue(vcal,VCLocationProp, "0.0"); |
104 | addPropValue(vcal,VCProdIdProp, productId()); | 102 | addPropValue(vcal,VCProdIdProp, productId()); |
105 | tmpStr = mCalendar->getTimeZoneStr(); | 103 | tmpStr = mCalendar->getTimeZoneStr(); |
106 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); | 104 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); |
107 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); | 105 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); |
108 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); | 106 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); |
109 | 107 | ||
110 | // TODO STUFF | 108 | // TODO STUFF |
111 | QPtrList<Todo> todoList = mCalendar->rawTodos(); | 109 | QPtrList<Todo> todoList = mCalendar->rawTodos(); |
112 | QPtrListIterator<Todo> qlt(todoList); | 110 | QPtrListIterator<Todo> qlt(todoList); |
113 | for (; qlt.current(); ++qlt) { | 111 | for (; qlt.current(); ++qlt) { |
114 | vo = eventToVTodo(qlt.current()); | 112 | vo = eventToVTodo(qlt.current()); |
115 | addVObjectProp(vcal, vo); | 113 | addVObjectProp(vcal, vo); |
116 | } | 114 | } |
117 | 115 | ||
118 | // EVENT STUFF | 116 | // EVENT STUFF |
119 | QPtrList<Event> events = mCalendar->rawEvents(); | 117 | QPtrList<Event> events = mCalendar->rawEvents(); |
120 | Event *ev; | 118 | Event *ev; |
121 | for(ev=events.first();ev;ev=events.next()) { | 119 | for(ev=events.first();ev;ev=events.next()) { |
122 | vo = eventToVEvent(ev); | 120 | vo = eventToVEvent(ev); |
123 | addVObjectProp(vcal, vo); | 121 | addVObjectProp(vcal, vo); |
124 | } | 122 | } |
125 | 123 | ||
126 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); | 124 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); |
127 | cleanVObjects(vcal); | 125 | cleanVObjects(vcal); |
128 | cleanStrTbl(); | 126 | cleanStrTbl(); |
129 | 127 | ||
130 | if (QFile::exists(fileName)) { | 128 | if (QFile::exists(fileName)) { |
131 | kdDebug(5800) << "No error" << endl; | ||
132 | return true; | 129 | return true; |
133 | } else { | 130 | } else { |
134 | kdDebug(5800) << "Error" << endl; | ||
135 | return false; // error | 131 | return false; // error |
136 | } | 132 | } |
137 | } | 133 | } |
138 | 134 | ||
139 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | 135 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) |
140 | { | 136 | { |
141 | // TODO: Factor out VCalFormat::fromString() | 137 | // TODO: Factor out VCalFormat::fromString() |
142 | 138 | ||
143 | QCString data = text.utf8(); | 139 | QCString data = text.utf8(); |
144 | 140 | ||
145 | if ( !data.size() ) return false; | 141 | if ( !data.size() ) return false; |
146 | 142 | ||
147 | VObject *vcal = Parse_MIME( data.data(), data.size()); | 143 | VObject *vcal = Parse_MIME( data.data(), data.size()); |
148 | if ( !vcal ) return false; | 144 | if ( !vcal ) return false; |
149 | 145 | ||
150 | VObjectIterator i; | 146 | VObjectIterator i; |
151 | VObject *curvo; | 147 | VObject *curvo; |
152 | initPropIterator( &i, vcal ); | 148 | initPropIterator( &i, vcal ); |
153 | 149 | ||
154 | // we only take the first object. TODO: parse all incidences. | 150 | // we only take the first object. TODO: parse all incidences. |
155 | do { | 151 | do { |
156 | curvo = nextVObject( &i ); | 152 | curvo = nextVObject( &i ); |
157 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && | 153 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && |
158 | strcmp( vObjectName( curvo ), VCTodoProp ) ); | 154 | strcmp( vObjectName( curvo ), VCTodoProp ) ); |
159 | 155 | ||
160 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { | 156 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { |
161 | Event *event = VEventToEvent( curvo ); | 157 | Event *event = VEventToEvent( curvo ); |
162 | calendar->addEvent( event ); | 158 | calendar->addEvent( event ); |
163 | } else { | 159 | } else { |
164 | kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl; | 160 | qDebug("VCalFormat::fromString(): Unknown object type. "); |
165 | deleteVObject( vcal ); | 161 | deleteVObject( vcal ); |
166 | return false; | 162 | return false; |
167 | } | 163 | } |
168 | 164 | ||
169 | deleteVObject( vcal ); | 165 | deleteVObject( vcal ); |
170 | 166 | ||
171 | return true; | 167 | return true; |
172 | } | 168 | } |
173 | 169 | ||
174 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) | 170 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) |
175 | { | 171 | { |
176 | 172 | ||
177 | if ( !event ) return QString::null; | 173 | if ( !event ) return QString::null; |
178 | bool useL = useLocalTime; | 174 | bool useL = useLocalTime; |
179 | useLocalTime = useLocal; | 175 | useLocalTime = useLocal; |
180 | mCalendar = calendar; | 176 | mCalendar = calendar; |
181 | VObject *vevent = eventToVEvent( event ); | 177 | VObject *vevent = eventToVEvent( event ); |
182 | char *buf = writeMemVObject( 0, 0, vevent ); | 178 | char *buf = writeMemVObject( 0, 0, vevent ); |
183 | QString result( buf ); | 179 | QString result( buf ); |
184 | cleanVObject( vevent ); | 180 | cleanVObject( vevent ); |
185 | useLocalTime = useL; | 181 | useLocalTime = useL; |
186 | return result; | 182 | return result; |
187 | } | 183 | } |
188 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) | 184 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) |
189 | { | 185 | { |
190 | 186 | ||
191 | if ( !todo ) return QString::null; | 187 | if ( !todo ) return QString::null; |
192 | bool useL = useLocalTime; | 188 | bool useL = useLocalTime; |
193 | useLocalTime = useLocal; | 189 | useLocalTime = useLocal; |
194 | mCalendar = calendar; | 190 | mCalendar = calendar; |
195 | VObject *vevent = eventToVTodo( todo ); | 191 | VObject *vevent = eventToVTodo( todo ); |
196 | char *buf = writeMemVObject( 0, 0, vevent ); | 192 | char *buf = writeMemVObject( 0, 0, vevent ); |
197 | QString result( buf ); | 193 | QString result( buf ); |
198 | cleanVObject( vevent ); | 194 | cleanVObject( vevent ); |
199 | useLocalTime = useL; | 195 | useLocalTime = useL; |
200 | return result; | 196 | return result; |
201 | } | 197 | } |
202 | 198 | ||
203 | QString VCalFormat::toString( Calendar *calendar ) | 199 | QString VCalFormat::toString( Calendar *calendar ) |
204 | { | 200 | { |
205 | // TODO: Factor out VCalFormat::asString() | 201 | // TODO: Factor out VCalFormat::asString() |
206 | 202 | ||
207 | VObject *vcal = newVObject(VCCalProp); | 203 | VObject *vcal = newVObject(VCCalProp); |
208 | 204 | ||
209 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); | 205 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); |
210 | QString tmpStr = mCalendar->getTimeZoneStr(); | 206 | QString tmpStr = mCalendar->getTimeZoneStr(); |
211 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); | 207 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); |
212 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); | 208 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); |
213 | 209 | ||
214 | // TODO: Use all data. | 210 | // TODO: Use all data. |
215 | QPtrList<Event> events = calendar->events(); | 211 | QPtrList<Event> events = calendar->events(); |
216 | Event *event = events.first(); | 212 | Event *event = events.first(); |
217 | if ( !event ) return QString::null; | 213 | if ( !event ) return QString::null; |
218 | 214 | ||
219 | VObject *vevent = eventToVEvent( event ); | 215 | VObject *vevent = eventToVEvent( event ); |
220 | 216 | ||
221 | addVObjectProp( vcal, vevent ); | 217 | addVObjectProp( vcal, vevent ); |
222 | 218 | ||
223 | char *buf = writeMemVObject( 0, 0, vcal ); | 219 | char *buf = writeMemVObject( 0, 0, vcal ); |
224 | 220 | ||
225 | QString result( buf ); | 221 | QString result( buf ); |
226 | 222 | ||
227 | cleanVObject( vcal ); | 223 | cleanVObject( vcal ); |
228 | 224 | ||
229 | return result; | 225 | return result; |
230 | } | 226 | } |
231 | 227 | ||
232 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | 228 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) |
233 | { | 229 | { |
234 | VObject *vtodo; | 230 | VObject *vtodo; |
235 | QString tmpStr; | 231 | QString tmpStr; |
236 | QStringList tmpStrList; | 232 | QStringList tmpStrList; |
237 | 233 | ||
238 | vtodo = newVObject(VCTodoProp); | 234 | vtodo = newVObject(VCTodoProp); |
239 | 235 | ||
240 | // due date | 236 | // due date |
241 | if (anEvent->hasDueDate()) { | 237 | if (anEvent->hasDueDate()) { |
242 | tmpStr = qDateTimeToISO(anEvent->dtDue(), | 238 | tmpStr = qDateTimeToISO(anEvent->dtDue(), |
243 | !anEvent->doesFloat()); | 239 | !anEvent->doesFloat()); |
244 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); | 240 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); |
245 | } | 241 | } |
246 | 242 | ||
247 | // start date | 243 | // start date |
248 | if (anEvent->hasStartDate()) { | 244 | if (anEvent->hasStartDate()) { |
249 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 245 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
250 | !anEvent->doesFloat()); | 246 | !anEvent->doesFloat()); |
251 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); | 247 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); |
252 | } | 248 | } |
253 | 249 | ||
254 | // creation date | 250 | // creation date |
255 | tmpStr = qDateTimeToISO(anEvent->created()); | 251 | tmpStr = qDateTimeToISO(anEvent->created()); |
256 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); | 252 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); |
257 | 253 | ||
258 | // unique id | 254 | // unique id |
259 | addPropValue(vtodo, VCUniqueStringProp, | 255 | addPropValue(vtodo, VCUniqueStringProp, |
260 | anEvent->uid().local8Bit()); | 256 | anEvent->uid().local8Bit()); |
261 | 257 | ||
262 | // revision | 258 | // revision |
263 | tmpStr.sprintf("%i", anEvent->revision()); | 259 | tmpStr.sprintf("%i", anEvent->revision()); |
264 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); | 260 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); |
265 | 261 | ||
266 | // last modification date | 262 | // last modification date |
267 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 263 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
268 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); | 264 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); |
269 | 265 | ||
270 | // organizer stuff | 266 | // organizer stuff |
271 | tmpStr = "MAILTO:" + anEvent->organizer(); | 267 | tmpStr = "MAILTO:" + anEvent->organizer(); |
272 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); | 268 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); |
273 | 269 | ||
274 | // attendees | 270 | // attendees |
275 | if (anEvent->attendeeCount() != 0) { | 271 | if (anEvent->attendeeCount() != 0) { |
276 | QPtrList<Attendee> al = anEvent->attendees(); | 272 | QPtrList<Attendee> al = anEvent->attendees(); |
277 | QPtrListIterator<Attendee> ai(al); | 273 | QPtrListIterator<Attendee> ai(al); |
278 | Attendee *curAttendee; | 274 | Attendee *curAttendee; |
279 | 275 | ||
280 | for (; ai.current(); ++ai) { | 276 | for (; ai.current(); ++ai) { |
281 | curAttendee = ai.current(); | 277 | curAttendee = ai.current(); |
282 | if (!curAttendee->email().isEmpty() && | 278 | if (!curAttendee->email().isEmpty() && |
283 | !curAttendee->name().isEmpty()) | 279 | !curAttendee->name().isEmpty()) |
284 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 280 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
285 | curAttendee->email() + ">"; | 281 | curAttendee->email() + ">"; |
286 | else if (curAttendee->name().isEmpty()) | 282 | else if (curAttendee->name().isEmpty()) |
287 | tmpStr = "MAILTO: " + curAttendee->email(); | 283 | tmpStr = "MAILTO: " + curAttendee->email(); |
288 | else if (curAttendee->email().isEmpty()) | 284 | else if (curAttendee->email().isEmpty()) |
289 | tmpStr = "MAILTO: " + curAttendee->name(); | 285 | tmpStr = "MAILTO: " + curAttendee->name(); |
290 | else if (curAttendee->name().isEmpty() && | 286 | else if (curAttendee->name().isEmpty() && |
291 | curAttendee->email().isEmpty()) | 287 | curAttendee->email().isEmpty()) |
292 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 288 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
293 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); | 289 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); |
294 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 290 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
295 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 291 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
296 | } | 292 | } |
297 | } | 293 | } |
298 | 294 | ||
299 | // description BL: | 295 | // description BL: |
300 | if (!anEvent->description().isEmpty()) { | 296 | if (!anEvent->description().isEmpty()) { |
301 | VObject *d = addPropValue(vtodo, VCDescriptionProp, | 297 | VObject *d = addPropValue(vtodo, VCDescriptionProp, |
302 | anEvent->description().local8Bit()); | 298 | anEvent->description().local8Bit()); |
303 | if (anEvent->description().find('\n') != -1) | 299 | if (anEvent->description().find('\n') != -1) |
304 | addProp(d, VCQuotedPrintableProp); | 300 | addProp(d, VCQuotedPrintableProp); |
305 | } | 301 | } |
306 | 302 | ||
307 | // summary | 303 | // summary |
308 | if (!anEvent->summary().isEmpty()) | 304 | if (!anEvent->summary().isEmpty()) |
309 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); | 305 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); |
310 | 306 | ||
311 | if (!anEvent->location().isEmpty()) | 307 | if (!anEvent->location().isEmpty()) |
312 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); | 308 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); |
313 | 309 | ||
314 | // completed | 310 | // completed |
315 | // status | 311 | // status |
316 | // backward compatibility, KOrganizer used to interpret only these two values | 312 | // backward compatibility, KOrganizer used to interpret only these two values |
317 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : | 313 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : |
318 | "NEEDS_ACTION"); | 314 | "NEEDS_ACTION"); |
319 | // completion date | 315 | // completion date |
320 | if (anEvent->hasCompletedDate()) { | 316 | if (anEvent->hasCompletedDate()) { |
321 | tmpStr = qDateTimeToISO(anEvent->completed()); | 317 | tmpStr = qDateTimeToISO(anEvent->completed()); |
322 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); | 318 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); |
323 | } | 319 | } |
324 | 320 | ||
325 | // priority | 321 | // priority |
326 | tmpStr.sprintf("%i",anEvent->priority()); | 322 | tmpStr.sprintf("%i",anEvent->priority()); |
327 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); | 323 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); |
328 | 324 | ||
329 | // related event | 325 | // related event |
330 | if (anEvent->relatedTo()) { | 326 | if (anEvent->relatedTo()) { |
331 | addPropValue(vtodo, VCRelatedToProp, | 327 | addPropValue(vtodo, VCRelatedToProp, |
332 | anEvent->relatedTo()->uid().local8Bit()); | 328 | anEvent->relatedTo()->uid().local8Bit()); |
333 | } | 329 | } |
334 | 330 | ||
335 | // categories | 331 | // categories |
336 | tmpStrList = anEvent->categories(); | 332 | tmpStrList = anEvent->categories(); |
337 | tmpStr = ""; | 333 | tmpStr = ""; |
338 | QString catStr; | 334 | QString catStr; |
339 | for ( QStringList::Iterator it = tmpStrList.begin(); | 335 | for ( QStringList::Iterator it = tmpStrList.begin(); |
340 | it != tmpStrList.end(); | 336 | it != tmpStrList.end(); |
341 | ++it ) { | 337 | ++it ) { |
342 | catStr = *it; | 338 | catStr = *it; |
343 | if (catStr[0] == ' ') | 339 | if (catStr[0] == ' ') |
344 | tmpStr += catStr.mid(1); | 340 | tmpStr += catStr.mid(1); |
345 | else | 341 | else |
346 | tmpStr += catStr; | 342 | tmpStr += catStr; |
347 | // this must be a ';' character as the vCalendar specification requires! | 343 | // this must be a ';' character as the vCalendar specification requires! |
348 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 344 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
349 | // read in. | 345 | // read in. |
350 | tmpStr += ";"; | 346 | tmpStr += ";"; |
351 | } | 347 | } |
352 | if (!tmpStr.isEmpty()) { | 348 | if (!tmpStr.isEmpty()) { |
353 | tmpStr.truncate(tmpStr.length()-1); | 349 | tmpStr.truncate(tmpStr.length()-1); |
354 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); | 350 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); |
355 | } | 351 | } |
356 | 352 | ||
357 | // alarm stuff | 353 | // alarm stuff |
358 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; | 354 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; |
359 | QPtrList<Alarm> alarms = anEvent->alarms(); | 355 | QPtrList<Alarm> alarms = anEvent->alarms(); |
360 | Alarm* alarm; | 356 | Alarm* alarm; |
361 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 357 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
362 | if (alarm->enabled()) { | 358 | if (alarm->enabled()) { |
363 | VObject *a; | 359 | VObject *a; |
364 | tmpStr = qDateTimeToISO(alarm->time()); | 360 | tmpStr = qDateTimeToISO(alarm->time()); |
365 | if (alarm->type() == Alarm::Audio) { | 361 | if (alarm->type() == Alarm::Audio) { |
366 | a = addProp(vtodo, VCAAlarmProp); | 362 | a = addProp(vtodo, VCAAlarmProp); |
367 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 363 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
368 | addPropValue(a, VCRepeatCountProp, "1"); | 364 | addPropValue(a, VCRepeatCountProp, "1"); |
369 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 365 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
370 | } | 366 | } |
371 | else if (alarm->type() == Alarm::Procedure) { | 367 | else if (alarm->type() == Alarm::Procedure) { |
372 | a = addProp(vtodo, VCPAlarmProp); | 368 | a = addProp(vtodo, VCPAlarmProp); |
373 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 369 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
374 | addPropValue(a, VCRepeatCountProp, "1"); | 370 | addPropValue(a, VCRepeatCountProp, "1"); |
375 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 371 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
376 | } else { | 372 | } else { |
377 | a = addProp(vtodo, VCDAlarmProp); | 373 | a = addProp(vtodo, VCDAlarmProp); |
378 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 374 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
379 | addPropValue(a, VCRepeatCountProp, "1"); | 375 | addPropValue(a, VCRepeatCountProp, "1"); |
380 | addPropValue(a, VCDisplayStringProp, "beep!"); | 376 | addPropValue(a, VCDisplayStringProp, "beep!"); |
381 | } | 377 | } |
382 | } | 378 | } |
383 | } | 379 | } |
384 | 380 | ||
385 | if (anEvent->pilotId()) { | 381 | if (anEvent->pilotId()) { |
386 | // pilot sync stuff | 382 | // pilot sync stuff |
387 | tmpStr.sprintf("%i",anEvent->pilotId()); | 383 | tmpStr.sprintf("%i",anEvent->pilotId()); |
388 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); | 384 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); |
389 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 385 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
390 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); | 386 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); |
391 | } | 387 | } |
392 | 388 | ||
393 | return vtodo; | 389 | return vtodo; |
394 | } | 390 | } |
395 | 391 | ||
396 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 392 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) |
397 | { | 393 | { |
398 | VObject *vevent; | 394 | VObject *vevent; |
399 | QString tmpStr; | 395 | QString tmpStr; |
400 | QStringList tmpStrList; | 396 | QStringList tmpStrList; |
401 | 397 | ||
402 | vevent = newVObject(VCEventProp); | 398 | vevent = newVObject(VCEventProp); |
403 | 399 | ||
404 | // start and end time | 400 | // start and end time |
405 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 401 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
406 | !anEvent->doesFloat()); | 402 | !anEvent->doesFloat()); |
407 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 403 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
408 | 404 | ||
409 | // events that have time associated but take up no time should | 405 | // events that have time associated but take up no time should |
410 | // not have both DTSTART and DTEND. | 406 | // not have both DTSTART and DTEND. |
411 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 407 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
412 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 408 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
413 | !anEvent->doesFloat()); | 409 | !anEvent->doesFloat()); |
414 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); | 410 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); |
415 | } | 411 | } |
416 | 412 | ||
417 | // creation date | 413 | // creation date |
418 | tmpStr = qDateTimeToISO(anEvent->created()); | 414 | tmpStr = qDateTimeToISO(anEvent->created()); |
419 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); | 415 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); |
420 | 416 | ||
421 | // unique id | 417 | // unique id |
422 | addPropValue(vevent, VCUniqueStringProp, | 418 | addPropValue(vevent, VCUniqueStringProp, |
423 | anEvent->uid().local8Bit()); | 419 | anEvent->uid().local8Bit()); |
424 | 420 | ||
425 | // revision | 421 | // revision |
426 | tmpStr.sprintf("%i", anEvent->revision()); | 422 | tmpStr.sprintf("%i", anEvent->revision()); |
427 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); | 423 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); |
428 | 424 | ||
429 | // last modification date | 425 | // last modification date |
430 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 426 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
431 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); | 427 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); |
432 | 428 | ||
433 | // attendee and organizer stuff | 429 | // attendee and organizer stuff |
434 | tmpStr = "MAILTO:" + anEvent->organizer(); | 430 | tmpStr = "MAILTO:" + anEvent->organizer(); |
435 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); | 431 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); |
436 | 432 | ||
437 | if (anEvent->attendeeCount() != 0) { | 433 | if (anEvent->attendeeCount() != 0) { |
438 | QPtrList<Attendee> al = anEvent->attendees(); | 434 | QPtrList<Attendee> al = anEvent->attendees(); |
439 | QPtrListIterator<Attendee> ai(al); | 435 | QPtrListIterator<Attendee> ai(al); |
440 | Attendee *curAttendee; | 436 | Attendee *curAttendee; |
441 | 437 | ||
442 | // TODO: Put this functionality into Attendee class | 438 | // TODO: Put this functionality into Attendee class |
443 | for (; ai.current(); ++ai) { | 439 | for (; ai.current(); ++ai) { |
444 | curAttendee = ai.current(); | 440 | curAttendee = ai.current(); |
445 | if (!curAttendee->email().isEmpty() && | 441 | if (!curAttendee->email().isEmpty() && |
446 | !curAttendee->name().isEmpty()) | 442 | !curAttendee->name().isEmpty()) |
447 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 443 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
448 | curAttendee->email() + ">"; | 444 | curAttendee->email() + ">"; |
449 | else if (curAttendee->name().isEmpty()) | 445 | else if (curAttendee->name().isEmpty()) |
450 | tmpStr = "MAILTO: " + curAttendee->email(); | 446 | tmpStr = "MAILTO: " + curAttendee->email(); |
451 | else if (curAttendee->email().isEmpty()) | 447 | else if (curAttendee->email().isEmpty()) |
452 | tmpStr = "MAILTO: " + curAttendee->name(); | 448 | tmpStr = "MAILTO: " + curAttendee->name(); |
453 | else if (curAttendee->name().isEmpty() && | 449 | else if (curAttendee->name().isEmpty() && |
454 | curAttendee->email().isEmpty()) | 450 | curAttendee->email().isEmpty()) |
455 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 451 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
456 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); | 452 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); |
457 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; | 453 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; |
458 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 454 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
459 | } | 455 | } |
460 | } | 456 | } |
461 | 457 | ||
462 | // recurrence rule stuff | 458 | // recurrence rule stuff |
463 | if (anEvent->recurrence()->doesRecur()) { | 459 | if (anEvent->recurrence()->doesRecur()) { |
464 | // some more variables | 460 | // some more variables |
465 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 461 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
466 | QPtrList<int> tmpDays; | 462 | QPtrList<int> tmpDays; |
467 | int *tmpDay; | 463 | int *tmpDay; |
468 | Recurrence::rMonthPos *tmpPos; | 464 | Recurrence::rMonthPos *tmpPos; |
469 | QString tmpStr2; | 465 | QString tmpStr2; |
470 | int i; | 466 | int i; |
471 | 467 | ||
472 | switch(anEvent->recurrence()->doesRecur()) { | 468 | switch(anEvent->recurrence()->doesRecur()) { |
473 | case Recurrence::rDaily: | 469 | case Recurrence::rDaily: |
474 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); | 470 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); |
475 | // if (anEvent->rDuration > 0) | 471 | // if (anEvent->rDuration > 0) |
476 | //tmpStr += "#"; | 472 | //tmpStr += "#"; |
477 | break; | 473 | break; |
478 | case Recurrence::rWeekly: | 474 | case Recurrence::rWeekly: |
479 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); | 475 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); |
480 | for (i = 0; i < 7; i++) { | 476 | for (i = 0; i < 7; i++) { |
481 | if (anEvent->recurrence()->days().testBit(i)) | 477 | if (anEvent->recurrence()->days().testBit(i)) |
482 | tmpStr += dayFromNum(i); | 478 | tmpStr += dayFromNum(i); |
483 | } | 479 | } |
484 | break; | 480 | break; |
485 | case Recurrence::rMonthlyPos: | 481 | case Recurrence::rMonthlyPos: |
486 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); | 482 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); |
487 | // write out all rMonthPos's | 483 | // write out all rMonthPos's |
488 | tmpPositions = anEvent->recurrence()->monthPositions(); | 484 | tmpPositions = anEvent->recurrence()->monthPositions(); |
489 | for (tmpPos = tmpPositions.first(); | 485 | for (tmpPos = tmpPositions.first(); |
490 | tmpPos; | 486 | tmpPos; |
491 | tmpPos = tmpPositions.next()) { | 487 | tmpPos = tmpPositions.next()) { |
492 | 488 | ||
493 | tmpStr2.sprintf("%i", tmpPos->rPos); | 489 | tmpStr2.sprintf("%i", tmpPos->rPos); |
494 | if (tmpPos->negative) | 490 | if (tmpPos->negative) |
495 | tmpStr2 += "- "; | 491 | tmpStr2 += "- "; |
496 | else | 492 | else |
497 | tmpStr2 += "+ "; | 493 | tmpStr2 += "+ "; |
498 | tmpStr += tmpStr2; | 494 | tmpStr += tmpStr2; |
499 | for (i = 0; i < 7; i++) { | 495 | for (i = 0; i < 7; i++) { |
500 | if (tmpPos->rDays.testBit(i)) | 496 | if (tmpPos->rDays.testBit(i)) |
501 | tmpStr += dayFromNum(i); | 497 | tmpStr += dayFromNum(i); |
502 | } | 498 | } |
503 | } // loop for all rMonthPos's | 499 | } // loop for all rMonthPos's |
504 | break; | 500 | break; |
505 | case Recurrence::rMonthlyDay: | 501 | case Recurrence::rMonthlyDay: |
506 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); | 502 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); |
507 | // write out all rMonthDays; | 503 | // write out all rMonthDays; |
508 | tmpDays = anEvent->recurrence()->monthDays(); | 504 | tmpDays = anEvent->recurrence()->monthDays(); |
509 | for (tmpDay = tmpDays.first(); | 505 | for (tmpDay = tmpDays.first(); |
510 | tmpDay; | 506 | tmpDay; |
511 | tmpDay = tmpDays.next()) { | 507 | tmpDay = tmpDays.next()) { |
512 | tmpStr2.sprintf("%i ", *tmpDay); | 508 | tmpStr2.sprintf("%i ", *tmpDay); |
513 | tmpStr += tmpStr2; | 509 | tmpStr += tmpStr2; |
514 | } | 510 | } |
515 | break; | 511 | break; |
516 | case Recurrence::rYearlyMonth: | 512 | case Recurrence::rYearlyMonth: |
517 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); | 513 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); |
518 | // write out all the rYearNums; | 514 | // write out all the rYearNums; |
519 | tmpDays = anEvent->recurrence()->yearNums(); | 515 | tmpDays = anEvent->recurrence()->yearNums(); |
520 | for (tmpDay = tmpDays.first(); | 516 | for (tmpDay = tmpDays.first(); |
521 | tmpDay; | 517 | tmpDay; |
522 | tmpDay = tmpDays.next()) { | 518 | tmpDay = tmpDays.next()) { |
523 | tmpStr2.sprintf("%i ", *tmpDay); | 519 | tmpStr2.sprintf("%i ", *tmpDay); |
524 | tmpStr += tmpStr2; | 520 | tmpStr += tmpStr2; |
525 | } | 521 | } |
526 | break; | 522 | break; |
527 | case Recurrence::rYearlyDay: | 523 | case Recurrence::rYearlyDay: |
528 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); | 524 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); |
529 | // write out all the rYearNums; | 525 | // write out all the rYearNums; |
530 | tmpDays = anEvent->recurrence()->yearNums(); | 526 | tmpDays = anEvent->recurrence()->yearNums(); |
531 | for (tmpDay = tmpDays.first(); | 527 | for (tmpDay = tmpDays.first(); |
532 | tmpDay; | 528 | tmpDay; |
533 | tmpDay = tmpDays.next()) { | 529 | tmpDay = tmpDays.next()) { |
534 | tmpStr2.sprintf("%i ", *tmpDay); | 530 | tmpStr2.sprintf("%i ", *tmpDay); |
535 | tmpStr += tmpStr2; | 531 | tmpStr += tmpStr2; |
536 | } | 532 | } |
537 | break; | 533 | break; |
538 | default: | 534 | default: |
539 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; | 535 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; |
540 | break; | 536 | break; |
541 | } // switch | 537 | } // switch |
542 | 538 | ||
543 | if (anEvent->recurrence()->duration() > 0) { | 539 | if (anEvent->recurrence()->duration() > 0) { |
544 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); | 540 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); |
545 | tmpStr += tmpStr2; | 541 | tmpStr += tmpStr2; |
546 | } else if (anEvent->recurrence()->duration() == -1) { | 542 | } else if (anEvent->recurrence()->duration() == -1) { |
547 | tmpStr += "#0"; // defined as repeat forever | 543 | tmpStr += "#0"; // defined as repeat forever |
548 | } else { | 544 | } else { |
549 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); | 545 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); |
550 | } | 546 | } |
551 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); | 547 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); |
552 | 548 | ||
553 | } // event repeats | 549 | } // event repeats |
554 | 550 | ||
555 | // exceptions to recurrence | 551 | // exceptions to recurrence |
556 | DateList dateList = anEvent->exDates(); | 552 | DateList dateList = anEvent->exDates(); |
557 | DateList::ConstIterator it; | 553 | DateList::ConstIterator it; |
558 | QString tmpStr2; | 554 | QString tmpStr2; |
559 | 555 | ||
560 | for (it = dateList.begin(); it != dateList.end(); ++it) { | 556 | for (it = dateList.begin(); it != dateList.end(); ++it) { |
561 | tmpStr = qDateToISO(*it) + ";"; | 557 | tmpStr = qDateToISO(*it) + ";"; |
562 | tmpStr2 += tmpStr; | 558 | tmpStr2 += tmpStr; |
563 | } | 559 | } |
564 | if (!tmpStr2.isEmpty()) { | 560 | if (!tmpStr2.isEmpty()) { |
565 | tmpStr2.truncate(tmpStr2.length()-1); | 561 | tmpStr2.truncate(tmpStr2.length()-1); |
566 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); | 562 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); |
567 | } | 563 | } |
568 | 564 | ||
569 | // description | 565 | // description |
570 | if (!anEvent->description().isEmpty()) { | 566 | if (!anEvent->description().isEmpty()) { |
571 | VObject *d = addPropValue(vevent, VCDescriptionProp, | 567 | VObject *d = addPropValue(vevent, VCDescriptionProp, |
572 | anEvent->description().local8Bit()); | 568 | anEvent->description().local8Bit()); |
573 | if (anEvent->description().find('\n') != -1) | 569 | if (anEvent->description().find('\n') != -1) |
574 | addProp(d, VCQuotedPrintableProp); | 570 | addProp(d, VCQuotedPrintableProp); |
575 | } | 571 | } |
576 | 572 | ||
577 | // summary | 573 | // summary |
578 | if (!anEvent->summary().isEmpty()) | 574 | if (!anEvent->summary().isEmpty()) |
579 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); | 575 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); |
580 | 576 | ||
581 | if (!anEvent->location().isEmpty()) | 577 | if (!anEvent->location().isEmpty()) |
582 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); | 578 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); |
583 | 579 | ||
584 | // status | 580 | // status |
585 | // TODO: define Event status | 581 | // TODO: define Event status |
586 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); | 582 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); |
587 | 583 | ||
588 | // secrecy | 584 | // secrecy |
589 | const char *text = 0; | 585 | const char *text = 0; |
590 | switch (anEvent->secrecy()) { | 586 | switch (anEvent->secrecy()) { |
591 | case Incidence::SecrecyPublic: | 587 | case Incidence::SecrecyPublic: |
592 | text = "PUBLIC"; | 588 | text = "PUBLIC"; |
593 | break; | 589 | break; |
594 | case Incidence::SecrecyPrivate: | 590 | case Incidence::SecrecyPrivate: |
595 | text = "PRIVATE"; | 591 | text = "PRIVATE"; |
596 | break; | 592 | break; |
597 | case Incidence::SecrecyConfidential: | 593 | case Incidence::SecrecyConfidential: |
598 | text = "CONFIDENTIAL"; | 594 | text = "CONFIDENTIAL"; |
599 | break; | 595 | break; |
600 | } | 596 | } |
601 | if (text) { | 597 | if (text) { |
602 | addPropValue(vevent, VCClassProp, text); | 598 | addPropValue(vevent, VCClassProp, text); |
603 | } | 599 | } |
604 | 600 | ||
605 | // categories | 601 | // categories |
606 | tmpStrList = anEvent->categories(); | 602 | tmpStrList = anEvent->categories(); |
607 | tmpStr = ""; | 603 | tmpStr = ""; |
608 | QString catStr; | 604 | QString catStr; |
609 | for ( QStringList::Iterator it = tmpStrList.begin(); | 605 | for ( QStringList::Iterator it = tmpStrList.begin(); |
610 | it != tmpStrList.end(); | 606 | it != tmpStrList.end(); |
611 | ++it ) { | 607 | ++it ) { |
612 | catStr = *it; | 608 | catStr = *it; |
613 | if (catStr[0] == ' ') | 609 | if (catStr[0] == ' ') |
614 | tmpStr += catStr.mid(1); | 610 | tmpStr += catStr.mid(1); |
615 | else | 611 | else |
616 | tmpStr += catStr; | 612 | tmpStr += catStr; |
617 | // this must be a ';' character as the vCalendar specification requires! | 613 | // this must be a ';' character as the vCalendar specification requires! |
618 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 614 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
619 | // read in. | 615 | // read in. |
620 | tmpStr += ";"; | 616 | tmpStr += ";"; |
621 | } | 617 | } |
622 | if (!tmpStr.isEmpty()) { | 618 | if (!tmpStr.isEmpty()) { |
623 | tmpStr.truncate(tmpStr.length()-1); | 619 | tmpStr.truncate(tmpStr.length()-1); |
624 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); | 620 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); |
625 | } | 621 | } |
626 | 622 | ||
627 | // attachments | 623 | // attachments |
628 | // TODO: handle binary attachments! | 624 | // TODO: handle binary attachments! |
629 | QPtrList<Attachment> attachments = anEvent->attachments(); | 625 | QPtrList<Attachment> attachments = anEvent->attachments(); |
630 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) | 626 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) |
631 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); | 627 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); |
632 | 628 | ||
633 | // resources | 629 | // resources |
634 | tmpStrList = anEvent->resources(); | 630 | tmpStrList = anEvent->resources(); |
635 | tmpStr = tmpStrList.join(";"); | 631 | tmpStr = tmpStrList.join(";"); |
636 | if (!tmpStr.isEmpty()) | 632 | if (!tmpStr.isEmpty()) |
637 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); | 633 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); |
638 | 634 | ||
639 | // alarm stuff | 635 | // alarm stuff |
640 | QPtrList<Alarm> alarms = anEvent->alarms(); | 636 | QPtrList<Alarm> alarms = anEvent->alarms(); |
641 | Alarm* alarm; | 637 | Alarm* alarm; |
642 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 638 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
643 | if (alarm->enabled()) { | 639 | if (alarm->enabled()) { |
644 | VObject *a ; | 640 | VObject *a ; |
645 | tmpStr = qDateTimeToISO(alarm->time()); | 641 | tmpStr = qDateTimeToISO(alarm->time()); |
646 | if (alarm->type() == Alarm::Audio) { | 642 | if (alarm->type() == Alarm::Audio) { |
647 | a = addProp(vevent, VCAAlarmProp); | 643 | a = addProp(vevent, VCAAlarmProp); |
648 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 644 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
649 | addPropValue(a, VCRepeatCountProp, "1"); | 645 | addPropValue(a, VCRepeatCountProp, "1"); |
650 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 646 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
651 | } | 647 | } |
652 | if (alarm->type() == Alarm::Procedure) { | 648 | if (alarm->type() == Alarm::Procedure) { |
653 | a = addProp(vevent, VCPAlarmProp); | 649 | a = addProp(vevent, VCPAlarmProp); |
654 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 650 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
655 | addPropValue(a, VCRepeatCountProp, "1"); | 651 | addPropValue(a, VCRepeatCountProp, "1"); |
656 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 652 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
657 | } else { | 653 | } else { |
658 | a = addProp(vevent, VCDAlarmProp); | 654 | a = addProp(vevent, VCDAlarmProp); |
659 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 655 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
660 | addPropValue(a, VCRepeatCountProp, "1"); | 656 | addPropValue(a, VCRepeatCountProp, "1"); |
661 | addPropValue(a, VCDisplayStringProp, "beep!"); | 657 | addPropValue(a, VCDisplayStringProp, "beep!"); |
662 | 658 | ||
663 | } | 659 | } |
664 | } | 660 | } |
665 | } | 661 | } |
666 | 662 | ||
667 | // priority | 663 | // priority |
668 | tmpStr.sprintf("%i",anEvent->priority()); | 664 | tmpStr.sprintf("%i",anEvent->priority()); |
669 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); | 665 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); |
670 | 666 | ||
671 | // transparency | 667 | // transparency |
672 | tmpStr.sprintf("%i",anEvent->transparency()); | 668 | tmpStr.sprintf("%i",anEvent->transparency()); |
673 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); | 669 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); |
674 | 670 | ||
675 | // related event | 671 | // related event |
676 | if (anEvent->relatedTo()) { | 672 | if (anEvent->relatedTo()) { |
677 | addPropValue(vevent, VCRelatedToProp, | 673 | addPropValue(vevent, VCRelatedToProp, |
678 | anEvent->relatedTo()->uid().local8Bit()); | 674 | anEvent->relatedTo()->uid().local8Bit()); |
679 | } | 675 | } |
680 | 676 | ||
681 | if (anEvent->pilotId()) { | 677 | if (anEvent->pilotId()) { |
682 | // pilot sync stuff | 678 | // pilot sync stuff |
683 | tmpStr.sprintf("%i",anEvent->pilotId()); | 679 | tmpStr.sprintf("%i",anEvent->pilotId()); |
684 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); | 680 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); |
685 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 681 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
686 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); | 682 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); |
687 | } | 683 | } |
688 | 684 | ||
689 | return vevent; | 685 | return vevent; |
690 | } | 686 | } |
691 | 687 | ||
692 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | 688 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) |
693 | { | 689 | { |
694 | VObject *vo; | 690 | VObject *vo; |
695 | VObjectIterator voi; | 691 | VObjectIterator voi; |
696 | char *s; | 692 | char *s; |
697 | 693 | ||
698 | Todo *anEvent = new Todo; | 694 | Todo *anEvent = new Todo; |
699 | 695 | ||
700 | // creation date | 696 | // creation date |
701 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { | 697 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { |
702 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 698 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
703 | deleteStr(s); | 699 | deleteStr(s); |
704 | } | 700 | } |
705 | 701 | ||
706 | // unique id | 702 | // unique id |
707 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); | 703 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); |
708 | // while the UID property is preferred, it is not required. We'll use the | 704 | // while the UID property is preferred, it is not required. We'll use the |
709 | // default Event UID if none is given. | 705 | // default Event UID if none is given. |
710 | if (vo) { | 706 | if (vo) { |
711 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 707 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
712 | deleteStr(s); | 708 | deleteStr(s); |
713 | } | 709 | } |
714 | 710 | ||
715 | // last modification date | 711 | // last modification date |
716 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { | 712 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { |
717 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 713 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
718 | deleteStr(s); | 714 | deleteStr(s); |
719 | } | 715 | } |
720 | else | 716 | else |
721 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 717 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
722 | QTime::currentTime())); | 718 | QTime::currentTime())); |
723 | 719 | ||
724 | // organizer | 720 | // organizer |
725 | // if our extension property for the event's ORGANIZER exists, add it. | 721 | // if our extension property for the event's ORGANIZER exists, add it. |
726 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { | 722 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { |
727 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 723 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
728 | deleteStr(s); | 724 | deleteStr(s); |
729 | } else { | 725 | } else { |
730 | anEvent->setOrganizer(mCalendar->getEmail()); | 726 | anEvent->setOrganizer(mCalendar->getEmail()); |
731 | } | 727 | } |
732 | 728 | ||
733 | // attendees. | 729 | // attendees. |
734 | initPropIterator(&voi, vtodo); | 730 | initPropIterator(&voi, vtodo); |
735 | while (moreIteration(&voi)) { | 731 | while (moreIteration(&voi)) { |
736 | vo = nextVObject(&voi); | 732 | vo = nextVObject(&voi); |
737 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 733 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
738 | Attendee *a; | 734 | Attendee *a; |
739 | VObject *vp; | 735 | VObject *vp; |
740 | s = fakeCString(vObjectUStringZValue(vo)); | 736 | s = fakeCString(vObjectUStringZValue(vo)); |
741 | QString tmpStr = QString::fromLocal8Bit(s); | 737 | QString tmpStr = QString::fromLocal8Bit(s); |
742 | deleteStr(s); | 738 | deleteStr(s); |
743 | tmpStr = tmpStr.simplifyWhiteSpace(); | 739 | tmpStr = tmpStr.simplifyWhiteSpace(); |
744 | int emailPos1, emailPos2; | 740 | int emailPos1, emailPos2; |
745 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 741 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
746 | // both email address and name | 742 | // both email address and name |
747 | emailPos2 = tmpStr.findRev('>'); | 743 | emailPos2 = tmpStr.findRev('>'); |
748 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 744 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
749 | tmpStr.mid(emailPos1 + 1, | 745 | tmpStr.mid(emailPos1 + 1, |
750 | emailPos2 - (emailPos1 + 1))); | 746 | emailPos2 - (emailPos1 + 1))); |
751 | } else if (tmpStr.find('@') > 0) { | 747 | } else if (tmpStr.find('@') > 0) { |
752 | // just an email address | 748 | // just an email address |
753 | a = new Attendee(0, tmpStr); | 749 | a = new Attendee(0, tmpStr); |
754 | } else { | 750 | } else { |
755 | // just a name | 751 | // just a name |
756 | QString email = tmpStr.replace( QRegExp(" "), "." ); | 752 | QString email = tmpStr.replace( QRegExp(" "), "." ); |
757 | a = new Attendee(tmpStr,email); | 753 | a = new Attendee(tmpStr,email); |
758 | } | 754 | } |
759 | 755 | ||
760 | // is there an RSVP property? | 756 | // is there an RSVP property? |
761 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 757 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
762 | a->setRSVP(vObjectStringZValue(vp)); | 758 | a->setRSVP(vObjectStringZValue(vp)); |
763 | // is there a status property? | 759 | // is there a status property? |
764 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 760 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
765 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 761 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
766 | // add the attendee | 762 | // add the attendee |
767 | anEvent->addAttendee(a); | 763 | anEvent->addAttendee(a); |
768 | } | 764 | } |
769 | } | 765 | } |
770 | 766 | ||
771 | // description for todo | 767 | // description for todo |
772 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { | 768 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { |
773 | s = fakeCString(vObjectUStringZValue(vo)); | 769 | s = fakeCString(vObjectUStringZValue(vo)); |
774 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 770 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
775 | deleteStr(s); | 771 | deleteStr(s); |
776 | } | 772 | } |
777 | 773 | ||
778 | // summary | 774 | // summary |
779 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { | 775 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { |
780 | s = fakeCString(vObjectUStringZValue(vo)); | 776 | s = fakeCString(vObjectUStringZValue(vo)); |
781 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 777 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
782 | deleteStr(s); | 778 | deleteStr(s); |
783 | } | 779 | } |
784 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { | 780 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { |
785 | s = fakeCString(vObjectUStringZValue(vo)); | 781 | s = fakeCString(vObjectUStringZValue(vo)); |
786 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 782 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
787 | deleteStr(s); | 783 | deleteStr(s); |
788 | } | 784 | } |
789 | 785 | ||
790 | 786 | ||
791 | // completed | 787 | // completed |
792 | // was: status | 788 | // was: status |
793 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { | 789 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { |
794 | s = fakeCString(vObjectUStringZValue(vo)); | 790 | s = fakeCString(vObjectUStringZValue(vo)); |
795 | if (strcmp(s,"COMPLETED") == 0) { | 791 | if (strcmp(s,"COMPLETED") == 0) { |
796 | anEvent->setCompleted(true); | 792 | anEvent->setCompleted(true); |
797 | } else { | 793 | } else { |
798 | anEvent->setCompleted(false); | 794 | anEvent->setCompleted(false); |
799 | } | 795 | } |
800 | deleteStr(s); | 796 | deleteStr(s); |
801 | } | 797 | } |
802 | else | 798 | else |
803 | anEvent->setCompleted(false); | 799 | anEvent->setCompleted(false); |
804 | 800 | ||
805 | // completion date | 801 | // completion date |
806 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { | 802 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { |
807 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 803 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
808 | deleteStr(s); | 804 | deleteStr(s); |
809 | } | 805 | } |
810 | 806 | ||
811 | // priority | 807 | // priority |
812 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { | 808 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { |
813 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 809 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
814 | deleteStr(s); | 810 | deleteStr(s); |
815 | } | 811 | } |
816 | 812 | ||
817 | // due date | 813 | // due date |
818 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { | 814 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { |
819 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 815 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
820 | deleteStr(s); | 816 | deleteStr(s); |
821 | anEvent->setHasDueDate(true); | 817 | anEvent->setHasDueDate(true); |
822 | } else { | 818 | } else { |
823 | anEvent->setHasDueDate(false); | 819 | anEvent->setHasDueDate(false); |
824 | } | 820 | } |
825 | 821 | ||
826 | // start time | 822 | // start time |
827 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { | 823 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { |
828 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 824 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
829 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 825 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
830 | deleteStr(s); | 826 | deleteStr(s); |
831 | anEvent->setHasStartDate(true); | 827 | anEvent->setHasStartDate(true); |
832 | } else { | 828 | } else { |
833 | anEvent->setHasStartDate(false); | 829 | anEvent->setHasStartDate(false); |
834 | } | 830 | } |
835 | 831 | ||
836 | /* alarm stuff */ | 832 | /* alarm stuff */ |
837 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; | 833 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; |
838 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { | 834 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { |
839 | Alarm* alarm = anEvent->newAlarm(); | 835 | Alarm* alarm = anEvent->newAlarm(); |
840 | VObject *a; | 836 | VObject *a; |
841 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 837 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
842 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 838 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
843 | deleteStr(s); | 839 | deleteStr(s); |
844 | } | 840 | } |
845 | alarm->setEnabled(true); | 841 | alarm->setEnabled(true); |
846 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { | 842 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { |
847 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 843 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
848 | s = fakeCString(vObjectUStringZValue(a)); | 844 | s = fakeCString(vObjectUStringZValue(a)); |
849 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 845 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
850 | deleteStr(s); | 846 | deleteStr(s); |
851 | } | 847 | } |
852 | } | 848 | } |
853 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { | 849 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { |
854 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 850 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
855 | s = fakeCString(vObjectUStringZValue(a)); | 851 | s = fakeCString(vObjectUStringZValue(a)); |
856 | alarm->setAudioAlarm(QFile::decodeName(s)); | 852 | alarm->setAudioAlarm(QFile::decodeName(s)); |
857 | deleteStr(s); | 853 | deleteStr(s); |
858 | } | 854 | } |
859 | } | 855 | } |
860 | } | 856 | } |
861 | 857 | ||
862 | // related todo | 858 | // related todo |
863 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { | 859 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { |
864 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 860 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
865 | deleteStr(s); | 861 | deleteStr(s); |
866 | mTodosRelate.append(anEvent); | 862 | mTodosRelate.append(anEvent); |
867 | } | 863 | } |
868 | 864 | ||
869 | // categories | 865 | // categories |
870 | QStringList tmpStrList; | 866 | QStringList tmpStrList; |
871 | int index1 = 0; | 867 | int index1 = 0; |
872 | int index2 = 0; | 868 | int index2 = 0; |
873 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { | 869 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { |
874 | s = fakeCString(vObjectUStringZValue(vo)); | 870 | s = fakeCString(vObjectUStringZValue(vo)); |
875 | QString categories = QString::fromLocal8Bit(s); | 871 | QString categories = QString::fromLocal8Bit(s); |
876 | deleteStr(s); | 872 | deleteStr(s); |
877 | //const char* category; | 873 | //const char* category; |
878 | QString category; | 874 | QString category; |
879 | while ((index2 = categories.find(',', index1)) != -1) { | 875 | while ((index2 = categories.find(',', index1)) != -1) { |
880 | //category = (const char *) categories.mid(index1, (index2 - index1)); | 876 | //category = (const char *) categories.mid(index1, (index2 - index1)); |
881 | category = categories.mid(index1, (index2 - index1)); | 877 | category = categories.mid(index1, (index2 - index1)); |
882 | tmpStrList.append(category); | 878 | tmpStrList.append(category); |
883 | index1 = index2+1; | 879 | index1 = index2+1; |
884 | } | 880 | } |
885 | // get last category | 881 | // get last category |
886 | category = categories.mid(index1, (categories.length()-index1)); | 882 | category = categories.mid(index1, (categories.length()-index1)); |
887 | tmpStrList.append(category); | 883 | tmpStrList.append(category); |
888 | anEvent->setCategories(tmpStrList); | 884 | anEvent->setCategories(tmpStrList); |
889 | } | 885 | } |
890 | 886 | ||
891 | /* PILOT SYNC STUFF */ | 887 | /* PILOT SYNC STUFF */ |
892 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { | 888 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { |
893 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 889 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
894 | deleteStr(s); | 890 | deleteStr(s); |
895 | } | 891 | } |
896 | else | 892 | else |
897 | anEvent->setPilotId(0); | 893 | anEvent->setPilotId(0); |
898 | 894 | ||
899 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { | 895 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { |
900 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 896 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
901 | deleteStr(s); | 897 | deleteStr(s); |
902 | } | 898 | } |
903 | else | 899 | else |
904 | anEvent->setSyncStatus(Event::SYNCMOD); | 900 | anEvent->setSyncStatus(Event::SYNCMOD); |
905 | 901 | ||
906 | return anEvent; | 902 | return anEvent; |
907 | } | 903 | } |
908 | 904 | ||
909 | Event* VCalFormat::VEventToEvent(VObject *vevent) | 905 | Event* VCalFormat::VEventToEvent(VObject *vevent) |
910 | { | 906 | { |
911 | VObject *vo; | 907 | VObject *vo; |
912 | VObjectIterator voi; | 908 | VObjectIterator voi; |
913 | char *s; | 909 | char *s; |
914 | 910 | ||
915 | Event *anEvent = new Event; | 911 | Event *anEvent = new Event; |
916 | 912 | ||
917 | // creation date | 913 | // creation date |
918 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { | 914 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { |
919 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 915 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
920 | deleteStr(s); | 916 | deleteStr(s); |
921 | } | 917 | } |
922 | 918 | ||
923 | // unique id | 919 | // unique id |
924 | vo = isAPropertyOf(vevent, VCUniqueStringProp); | 920 | vo = isAPropertyOf(vevent, VCUniqueStringProp); |
925 | // while the UID property is preferred, it is not required. We'll use the | 921 | // while the UID property is preferred, it is not required. We'll use the |
926 | // default Event UID if none is given. | 922 | // default Event UID if none is given. |
927 | if (vo) { | 923 | if (vo) { |
928 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 924 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
929 | deleteStr(s); | 925 | deleteStr(s); |
930 | } | 926 | } |
931 | 927 | ||
932 | // revision | 928 | // revision |
933 | // again NSCAL doesn't give us much to work with, so we improvise... | 929 | // again NSCAL doesn't give us much to work with, so we improvise... |
934 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { | 930 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { |
935 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 931 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
936 | deleteStr(s); | 932 | deleteStr(s); |
937 | } | 933 | } |
938 | else | 934 | else |
939 | anEvent->setRevision(0); | 935 | anEvent->setRevision(0); |
940 | 936 | ||
941 | // last modification date | 937 | // last modification date |
942 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { | 938 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { |
943 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 939 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
944 | deleteStr(s); | 940 | deleteStr(s); |
945 | } | 941 | } |
946 | else | 942 | else |
947 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 943 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
948 | QTime::currentTime())); | 944 | QTime::currentTime())); |
949 | 945 | ||
950 | // organizer | 946 | // organizer |
951 | // if our extension property for the event's ORGANIZER exists, add it. | 947 | // if our extension property for the event's ORGANIZER exists, add it. |
952 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { | 948 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { |
953 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 949 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
954 | deleteStr(s); | 950 | deleteStr(s); |
955 | } else { | 951 | } else { |
956 | anEvent->setOrganizer(mCalendar->getEmail()); | 952 | anEvent->setOrganizer(mCalendar->getEmail()); |
957 | } | 953 | } |
958 | 954 | ||
959 | // deal with attendees. | 955 | // deal with attendees. |
960 | initPropIterator(&voi, vevent); | 956 | initPropIterator(&voi, vevent); |
961 | while (moreIteration(&voi)) { | 957 | while (moreIteration(&voi)) { |
962 | vo = nextVObject(&voi); | 958 | vo = nextVObject(&voi); |
963 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 959 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
964 | Attendee *a; | 960 | Attendee *a; |
965 | VObject *vp; | 961 | VObject *vp; |
966 | s = fakeCString(vObjectUStringZValue(vo)); | 962 | s = fakeCString(vObjectUStringZValue(vo)); |
967 | QString tmpStr = QString::fromLocal8Bit(s); | 963 | QString tmpStr = QString::fromLocal8Bit(s); |
968 | deleteStr(s); | 964 | deleteStr(s); |
969 | tmpStr = tmpStr.simplifyWhiteSpace(); | 965 | tmpStr = tmpStr.simplifyWhiteSpace(); |
970 | int emailPos1, emailPos2; | 966 | int emailPos1, emailPos2; |
971 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 967 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
972 | // both email address and name | 968 | // both email address and name |
973 | emailPos2 = tmpStr.findRev('>'); | 969 | emailPos2 = tmpStr.findRev('>'); |
974 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 970 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
975 | tmpStr.mid(emailPos1 + 1, | 971 | tmpStr.mid(emailPos1 + 1, |
976 | emailPos2 - (emailPos1 + 1))); | 972 | emailPos2 - (emailPos1 + 1))); |
977 | } else if (tmpStr.find('@') > 0) { | 973 | } else if (tmpStr.find('@') > 0) { |
978 | // just an email address | 974 | // just an email address |
979 | a = new Attendee(0, tmpStr); | 975 | a = new Attendee(0, tmpStr); |
980 | } else { | 976 | } else { |
981 | // just a name | 977 | // just a name |
982 | QString email = tmpStr.replace( QRegExp(" "), "." ); | 978 | QString email = tmpStr.replace( QRegExp(" "), "." ); |
983 | a = new Attendee(tmpStr,email); | 979 | a = new Attendee(tmpStr,email); |
984 | } | 980 | } |
985 | 981 | ||
986 | // is there an RSVP property? | 982 | // is there an RSVP property? |
987 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 983 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
988 | a->setRSVP(vObjectStringZValue(vp)); | 984 | a->setRSVP(vObjectStringZValue(vp)); |
989 | // is there a status property? | 985 | // is there a status property? |
990 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 986 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
991 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 987 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
992 | // add the attendee | 988 | // add the attendee |
993 | anEvent->addAttendee(a); | 989 | anEvent->addAttendee(a); |
994 | } | 990 | } |
995 | } | 991 | } |
996 | 992 | ||
997 | // This isn't strictly true. An event that doesn't have a start time | 993 | // This isn't strictly true. An event that doesn't have a start time |
998 | // or an end time doesn't "float", it has an anchor in time but it doesn't | 994 | // or an end time doesn't "float", it has an anchor in time but it doesn't |
999 | // "take up" any time. | 995 | // "take up" any time. |
1000 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || | 996 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || |
1001 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { | 997 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { |
1002 | anEvent->setFloats(TRUE); | 998 | anEvent->setFloats(TRUE); |
1003 | } else { | 999 | } else { |
1004 | }*/ | 1000 | }*/ |
1005 | 1001 | ||
1006 | anEvent->setFloats(FALSE); | 1002 | anEvent->setFloats(FALSE); |
1007 | 1003 | ||
1008 | // start time | 1004 | // start time |
1009 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { | 1005 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { |
1010 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1006 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1011 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 1007 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
1012 | deleteStr(s); | 1008 | deleteStr(s); |
1013 | if (anEvent->dtStart().time().isNull()) | 1009 | if (anEvent->dtStart().time().isNull()) |
1014 | anEvent->setFloats(TRUE); | 1010 | anEvent->setFloats(TRUE); |
1015 | } | 1011 | } |
1016 | 1012 | ||
1017 | // stop time | 1013 | // stop time |
1018 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { | 1014 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { |
1019 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1015 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1020 | deleteStr(s); | 1016 | deleteStr(s); |
1021 | if (anEvent->dtEnd().time().isNull()) | 1017 | if (anEvent->dtEnd().time().isNull()) |
1022 | anEvent->setFloats(TRUE); | 1018 | anEvent->setFloats(TRUE); |
1023 | } | 1019 | } |
1024 | 1020 | ||
1025 | // at this point, there should be at least a start or end time. | 1021 | // at this point, there should be at least a start or end time. |
1026 | // fix up for events that take up no time but have a time associated | 1022 | // fix up for events that take up no time but have a time associated |
1027 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) | 1023 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) |
1028 | anEvent->setDtStart(anEvent->dtEnd()); | 1024 | anEvent->setDtStart(anEvent->dtEnd()); |
1029 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) | 1025 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) |
1030 | anEvent->setDtEnd(anEvent->dtStart()); | 1026 | anEvent->setDtEnd(anEvent->dtStart()); |
1031 | 1027 | ||
1032 | /////////////////////////////////////////////////////////////////////////// | 1028 | /////////////////////////////////////////////////////////////////////////// |
1033 | 1029 | ||
1034 | // repeat stuff | 1030 | // repeat stuff |
1035 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { | 1031 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { |
1036 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); | 1032 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); |
1037 | deleteStr(s); | 1033 | deleteStr(s); |
1038 | tmpStr.simplifyWhiteSpace(); | 1034 | tmpStr.simplifyWhiteSpace(); |
1039 | tmpStr = tmpStr.upper(); | 1035 | tmpStr = tmpStr.upper(); |
1040 | 1036 | ||
1041 | /********************************* DAILY ******************************/ | 1037 | /********************************* DAILY ******************************/ |
1042 | if (tmpStr.left(1) == "D") { | 1038 | if (tmpStr.left(1) == "D") { |
1043 | int index = tmpStr.find(' '); | 1039 | int index = tmpStr.find(' '); |
1044 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1040 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1045 | index = tmpStr.findRev(' ') + 1; // advance to last field | 1041 | index = tmpStr.findRev(' ') + 1; // advance to last field |
1046 | if (tmpStr.mid(index,1) == "#") index++; | 1042 | if (tmpStr.mid(index,1) == "#") index++; |
1047 | if (tmpStr.find('T', index) != -1) { | 1043 | if (tmpStr.find('T', index) != -1) { |
1048 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1044 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1049 | anEvent->recurrence()->setDaily(rFreq, rEndDate); | 1045 | anEvent->recurrence()->setDaily(rFreq, rEndDate); |
1050 | } else { | 1046 | } else { |
1051 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1047 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1052 | if (rDuration == 0) // VEvents set this to 0 forever, we use -1 | 1048 | if (rDuration == 0) // VEvents set this to 0 forever, we use -1 |
1053 | anEvent->recurrence()->setDaily(rFreq, -1); | 1049 | anEvent->recurrence()->setDaily(rFreq, -1); |
1054 | else | 1050 | else |
1055 | anEvent->recurrence()->setDaily(rFreq, rDuration); | 1051 | anEvent->recurrence()->setDaily(rFreq, rDuration); |
1056 | } | 1052 | } |
1057 | } | 1053 | } |
1058 | /********************************* WEEKLY ******************************/ | 1054 | /********************************* WEEKLY ******************************/ |
1059 | else if (tmpStr.left(1) == "W") { | 1055 | else if (tmpStr.left(1) == "W") { |
1060 | int index = tmpStr.find(' '); | 1056 | int index = tmpStr.find(' '); |
1061 | int last = tmpStr.findRev(' ') + 1; | 1057 | int last = tmpStr.findRev(' ') + 1; |
1062 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1058 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1063 | index += 1; // advance to beginning of stuff after freq | 1059 | index += 1; // advance to beginning of stuff after freq |
1064 | QBitArray qba(7); | 1060 | QBitArray qba(7); |
1065 | QString dayStr; | 1061 | QString dayStr; |
1066 | if( index == last ) { | 1062 | if( index == last ) { |
1067 | // e.g. W1 #0 | 1063 | // e.g. W1 #0 |
1068 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); | 1064 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); |
1069 | } | 1065 | } |
1070 | else { | 1066 | else { |
1071 | // e.g. W1 SU #0 | 1067 | // e.g. W1 SU #0 |
1072 | while (index < last) { | 1068 | while (index < last) { |
1073 | dayStr = tmpStr.mid(index, 3); | 1069 | dayStr = tmpStr.mid(index, 3); |
1074 | int dayNum = numFromDay(dayStr); | 1070 | int dayNum = numFromDay(dayStr); |
1075 | qba.setBit(dayNum); | 1071 | qba.setBit(dayNum); |
1076 | index += 3; // advance to next day, or possibly "#" | 1072 | index += 3; // advance to next day, or possibly "#" |
1077 | } | 1073 | } |
1078 | } | 1074 | } |
1079 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1075 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1080 | if (tmpStr.find('T', index) != -1) { | 1076 | if (tmpStr.find('T', index) != -1) { |
1081 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1077 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1082 | anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); | 1078 | anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); |
1083 | } else { | 1079 | } else { |
1084 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1080 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1085 | if (rDuration == 0) | 1081 | if (rDuration == 0) |
1086 | anEvent->recurrence()->setWeekly(rFreq, qba, -1); | 1082 | anEvent->recurrence()->setWeekly(rFreq, qba, -1); |
1087 | else | 1083 | else |
1088 | anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); | 1084 | anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); |
1089 | } | 1085 | } |
1090 | } | 1086 | } |
1091 | /**************************** MONTHLY-BY-POS ***************************/ | 1087 | /**************************** MONTHLY-BY-POS ***************************/ |
1092 | else if (tmpStr.left(2) == "MP") { | 1088 | else if (tmpStr.left(2) == "MP") { |
1093 | int index = tmpStr.find(' '); | 1089 | int index = tmpStr.find(' '); |
1094 | int last = tmpStr.findRev(' ') + 1; | 1090 | int last = tmpStr.findRev(' ') + 1; |
1095 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1091 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1096 | index += 1; // advance to beginning of stuff after freq | 1092 | index += 1; // advance to beginning of stuff after freq |
1097 | QBitArray qba(7); | 1093 | QBitArray qba(7); |
1098 | short tmpPos; | 1094 | short tmpPos; |
1099 | if( index == last ) { | 1095 | if( index == last ) { |
1100 | // e.g. MP1 #0 | 1096 | // e.g. MP1 #0 |
1101 | tmpPos = anEvent->dtStart().date().day()/7 + 1; | 1097 | tmpPos = anEvent->dtStart().date().day()/7 + 1; |
1102 | if( tmpPos == 5 ) | 1098 | if( tmpPos == 5 ) |
1103 | tmpPos = -1; | 1099 | tmpPos = -1; |
1104 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); | 1100 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); |
1105 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); | 1101 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); |
1106 | } | 1102 | } |
1107 | else { | 1103 | else { |
1108 | // e.g. MP1 1+ SU #0 | 1104 | // e.g. MP1 1+ SU #0 |
1109 | while (index < last) { | 1105 | while (index < last) { |
1110 | tmpPos = tmpStr.mid(index,1).toShort(); | 1106 | tmpPos = tmpStr.mid(index,1).toShort(); |
1111 | index += 1; | 1107 | index += 1; |
1112 | if (tmpStr.mid(index,1) == "-") | 1108 | if (tmpStr.mid(index,1) == "-") |
1113 | // convert tmpPos to negative | 1109 | // convert tmpPos to negative |
1114 | tmpPos = 0 - tmpPos; | 1110 | tmpPos = 0 - tmpPos; |
1115 | index += 2; // advance to day(s) | 1111 | index += 2; // advance to day(s) |
1116 | while (numFromDay(tmpStr.mid(index,3)) >= 0) { | 1112 | while (numFromDay(tmpStr.mid(index,3)) >= 0) { |
1117 | int dayNum = numFromDay(tmpStr.mid(index,3)); | 1113 | int dayNum = numFromDay(tmpStr.mid(index,3)); |
1118 | qba.setBit(dayNum); | 1114 | qba.setBit(dayNum); |
1119 | index += 3; // advance to next day, or possibly pos or "#" | 1115 | index += 3; // advance to next day, or possibly pos or "#" |
1120 | } | 1116 | } |
1121 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); | 1117 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); |
1122 | qba.detach(); | 1118 | qba.detach(); |
1123 | qba.fill(FALSE); // clear out | 1119 | qba.fill(FALSE); // clear out |
1124 | } // while != "#" | 1120 | } // while != "#" |
1125 | } | 1121 | } |
1126 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1122 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1127 | if (tmpStr.find('T', index) != -1) { | 1123 | if (tmpStr.find('T', index) != -1) { |
1128 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - | 1124 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - |
1129 | index))).date(); | 1125 | index))).date(); |
1130 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); | 1126 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); |
1131 | } else { | 1127 | } else { |
1132 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1128 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1133 | if (rDuration == 0) | 1129 | if (rDuration == 0) |
1134 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); | 1130 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); |
1135 | else | 1131 | else |
1136 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); | 1132 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); |
1137 | } | 1133 | } |
1138 | } | 1134 | } |
1139 | 1135 | ||
1140 | /**************************** MONTHLY-BY-DAY ***************************/ | 1136 | /**************************** MONTHLY-BY-DAY ***************************/ |
1141 | else if (tmpStr.left(2) == "MD") { | 1137 | else if (tmpStr.left(2) == "MD") { |
1142 | int index = tmpStr.find(' '); | 1138 | int index = tmpStr.find(' '); |
1143 | int last = tmpStr.findRev(' ') + 1; | 1139 | int last = tmpStr.findRev(' ') + 1; |
1144 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1140 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1145 | index += 1; | 1141 | index += 1; |
1146 | short tmpDay; | 1142 | short tmpDay; |
1147 | if( index == last ) { | 1143 | if( index == last ) { |
1148 | // e.g. MD1 #0 | 1144 | // e.g. MD1 #0 |
1149 | tmpDay = anEvent->dtStart().date().day(); | 1145 | tmpDay = anEvent->dtStart().date().day(); |
1150 | anEvent->recurrence()->addMonthlyDay(tmpDay); | 1146 | anEvent->recurrence()->addMonthlyDay(tmpDay); |
1151 | } | 1147 | } |
1152 | else { | 1148 | else { |
1153 | // e.g. MD1 3 #0 | 1149 | // e.g. MD1 3 #0 |
1154 | while (index < last) { | 1150 | while (index < last) { |
1155 | int index2 = tmpStr.find(' ', index); | 1151 | int index2 = tmpStr.find(' ', index); |
1156 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1152 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1157 | index = index2-1; | 1153 | index = index2-1; |
1158 | if (tmpStr.mid(index, 1) == "-") | 1154 | if (tmpStr.mid(index, 1) == "-") |
1159 | tmpDay = 0 - tmpDay; | 1155 | tmpDay = 0 - tmpDay; |
1160 | index += 2; // advance the index; | 1156 | index += 2; // advance the index; |
1161 | anEvent->recurrence()->addMonthlyDay(tmpDay); | 1157 | anEvent->recurrence()->addMonthlyDay(tmpDay); |
1162 | } // while != # | 1158 | } // while != # |
1163 | } | 1159 | } |
1164 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1160 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1165 | if (tmpStr.find('T', index) != -1) { | 1161 | if (tmpStr.find('T', index) != -1) { |
1166 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1162 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1167 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); | 1163 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); |
1168 | } else { | 1164 | } else { |
1169 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1165 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1170 | if (rDuration == 0) | 1166 | if (rDuration == 0) |
1171 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); | 1167 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); |
1172 | else | 1168 | else |
1173 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); | 1169 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); |
1174 | } | 1170 | } |
1175 | } | 1171 | } |
1176 | 1172 | ||
1177 | /*********************** YEARLY-BY-MONTH *******************************/ | 1173 | /*********************** YEARLY-BY-MONTH *******************************/ |
1178 | else if (tmpStr.left(2) == "YM") { | 1174 | else if (tmpStr.left(2) == "YM") { |
1179 | int index = tmpStr.find(' '); | 1175 | int index = tmpStr.find(' '); |
1180 | int last = tmpStr.findRev(' ') + 1; | 1176 | int last = tmpStr.findRev(' ') + 1; |
1181 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1177 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1182 | index += 1; | 1178 | index += 1; |
1183 | short tmpMonth; | 1179 | short tmpMonth; |
1184 | if( index == last ) { | 1180 | if( index == last ) { |
1185 | // e.g. YM1 #0 | 1181 | // e.g. YM1 #0 |
1186 | tmpMonth = anEvent->dtStart().date().month(); | 1182 | tmpMonth = anEvent->dtStart().date().month(); |
1187 | anEvent->recurrence()->addYearlyNum(tmpMonth); | 1183 | anEvent->recurrence()->addYearlyNum(tmpMonth); |
1188 | } | 1184 | } |
1189 | else { | 1185 | else { |
1190 | // e.g. YM1 3 #0 | 1186 | // e.g. YM1 3 #0 |
1191 | while (index < last) { | 1187 | while (index < last) { |
1192 | int index2 = tmpStr.find(' ', index); | 1188 | int index2 = tmpStr.find(' ', index); |
1193 | tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); | 1189 | tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); |
1194 | index = index2+1; | 1190 | index = index2+1; |
1195 | anEvent->recurrence()->addYearlyNum(tmpMonth); | 1191 | anEvent->recurrence()->addYearlyNum(tmpMonth); |
1196 | } // while != # | 1192 | } // while != # |
1197 | } | 1193 | } |
1198 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1194 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1199 | if (tmpStr.find('T', index) != -1) { | 1195 | if (tmpStr.find('T', index) != -1) { |
1200 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1196 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1201 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); | 1197 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); |
1202 | } else { | 1198 | } else { |
1203 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1199 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1204 | if (rDuration == 0) | 1200 | if (rDuration == 0) |
1205 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); | 1201 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); |
1206 | else | 1202 | else |
1207 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); | 1203 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); |
1208 | } | 1204 | } |
1209 | } | 1205 | } |
1210 | 1206 | ||
1211 | /*********************** YEARLY-BY-DAY *********************************/ | 1207 | /*********************** YEARLY-BY-DAY *********************************/ |
1212 | else if (tmpStr.left(2) == "YD") { | 1208 | else if (tmpStr.left(2) == "YD") { |
1213 | int index = tmpStr.find(' '); | 1209 | int index = tmpStr.find(' '); |
1214 | int last = tmpStr.findRev(' ') + 1; | 1210 | int last = tmpStr.findRev(' ') + 1; |
1215 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1211 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1216 | index += 1; | 1212 | index += 1; |
1217 | short tmpDay; | 1213 | short tmpDay; |
1218 | if( index == last ) { | 1214 | if( index == last ) { |
1219 | // e.g. YD1 #0 | 1215 | // e.g. YD1 #0 |
1220 | tmpDay = anEvent->dtStart().date().dayOfYear(); | 1216 | tmpDay = anEvent->dtStart().date().dayOfYear(); |
1221 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1217 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1222 | } | 1218 | } |
1223 | else { | 1219 | else { |
1224 | // e.g. YD1 123 #0 | 1220 | // e.g. YD1 123 #0 |
1225 | while (index < last) { | 1221 | while (index < last) { |
1226 | int index2 = tmpStr.find(' ', index); | 1222 | int index2 = tmpStr.find(' ', index); |
1227 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1223 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1228 | index = index2+1; | 1224 | index = index2+1; |
1229 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1225 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1230 | } // while != # | 1226 | } // while != # |
1231 | } | 1227 | } |
1232 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1228 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1233 | if (tmpStr.find('T', index) != -1) { | 1229 | if (tmpStr.find('T', index) != -1) { |
1234 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1230 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1235 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); | 1231 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); |
1236 | } else { | 1232 | } else { |
1237 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1233 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1238 | if (rDuration == 0) | 1234 | if (rDuration == 0) |
1239 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); | 1235 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); |
1240 | else | 1236 | else |
1241 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); | 1237 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); |
1242 | } | 1238 | } |
1243 | } else { | 1239 | } else { |
1244 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; | 1240 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; |
1245 | } // if | 1241 | } // if |
1246 | } // repeats | 1242 | } // repeats |
1247 | 1243 | ||
1248 | 1244 | ||
1249 | // recurrence exceptions | 1245 | // recurrence exceptions |
1250 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { | 1246 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { |
1251 | s = fakeCString(vObjectUStringZValue(vo)); | 1247 | s = fakeCString(vObjectUStringZValue(vo)); |
1252 | QStringList exDates = QStringList::split(",",s); | 1248 | QStringList exDates = QStringList::split(",",s); |
1253 | QStringList::ConstIterator it; | 1249 | QStringList::ConstIterator it; |
1254 | for(it = exDates.begin(); it != exDates.end(); ++it ) { | 1250 | for(it = exDates.begin(); it != exDates.end(); ++it ) { |
1255 | anEvent->addExDate(ISOToQDate(*it)); | 1251 | anEvent->addExDate(ISOToQDate(*it)); |
1256 | } | 1252 | } |
1257 | deleteStr(s); | 1253 | deleteStr(s); |
1258 | } | 1254 | } |
1259 | 1255 | ||
1260 | // summary | 1256 | // summary |
1261 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { | 1257 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { |
1262 | s = fakeCString(vObjectUStringZValue(vo)); | 1258 | s = fakeCString(vObjectUStringZValue(vo)); |
1263 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 1259 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
1264 | deleteStr(s); | 1260 | deleteStr(s); |
1265 | } | 1261 | } |
1266 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { | 1262 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { |
1267 | s = fakeCString(vObjectUStringZValue(vo)); | 1263 | s = fakeCString(vObjectUStringZValue(vo)); |
1268 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 1264 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
1269 | deleteStr(s); | 1265 | deleteStr(s); |
1270 | } | 1266 | } |
1271 | 1267 | ||
1272 | // description | 1268 | // description |
1273 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { | 1269 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { |
1274 | s = fakeCString(vObjectUStringZValue(vo)); | 1270 | s = fakeCString(vObjectUStringZValue(vo)); |
1275 | if (!anEvent->description().isEmpty()) { | 1271 | if (!anEvent->description().isEmpty()) { |
1276 | anEvent->setDescription(anEvent->description() + "\n" + | 1272 | anEvent->setDescription(anEvent->description() + "\n" + |
1277 | QString::fromLocal8Bit(s)); | 1273 | QString::fromLocal8Bit(s)); |
1278 | } else { | 1274 | } else { |
1279 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 1275 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
1280 | } | 1276 | } |
1281 | deleteStr(s); | 1277 | deleteStr(s); |
1282 | } | 1278 | } |
1283 | 1279 | ||
1284 | // some stupid vCal exporters ignore the standard and use Description | 1280 | // some stupid vCal exporters ignore the standard and use Description |
1285 | // instead of Summary for the default field. Correct for this. | 1281 | // instead of Summary for the default field. Correct for this. |
1286 | if (anEvent->summary().isEmpty() && | 1282 | if (anEvent->summary().isEmpty() && |
1287 | !(anEvent->description().isEmpty())) { | 1283 | !(anEvent->description().isEmpty())) { |
1288 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); | 1284 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); |
1289 | anEvent->setDescription(""); | 1285 | anEvent->setDescription(""); |
1290 | anEvent->setSummary(tmpStr); | 1286 | anEvent->setSummary(tmpStr); |
1291 | } | 1287 | } |
1292 | 1288 | ||
1293 | #if 0 | 1289 | #if 0 |
1294 | // status | 1290 | // status |
1295 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { | 1291 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { |
1296 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); | 1292 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); |
1297 | deleteStr(s); | 1293 | deleteStr(s); |
1298 | // TODO: Define Event status | 1294 | // TODO: Define Event status |
1299 | // anEvent->setStatus(tmpStr); | 1295 | // anEvent->setStatus(tmpStr); |
1300 | } | 1296 | } |
1301 | else | 1297 | else |
1302 | // anEvent->setStatus("NEEDS ACTION"); | 1298 | // anEvent->setStatus("NEEDS ACTION"); |
1303 | #endif | 1299 | #endif |
1304 | 1300 | ||
1305 | // secrecy | 1301 | // secrecy |
1306 | int secrecy = Incidence::SecrecyPublic; | 1302 | int secrecy = Incidence::SecrecyPublic; |
1307 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { | 1303 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { |
1308 | s = fakeCString(vObjectUStringZValue(vo)); | 1304 | s = fakeCString(vObjectUStringZValue(vo)); |
1309 | if (strcmp(s,"PRIVATE") == 0) { | 1305 | if (strcmp(s,"PRIVATE") == 0) { |
1310 | secrecy = Incidence::SecrecyPrivate; | 1306 | secrecy = Incidence::SecrecyPrivate; |
1311 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { | 1307 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { |
1312 | secrecy = Incidence::SecrecyConfidential; | 1308 | secrecy = Incidence::SecrecyConfidential; |
1313 | } | 1309 | } |
1314 | deleteStr(s); | 1310 | deleteStr(s); |
1315 | } | 1311 | } |
1316 | anEvent->setSecrecy(secrecy); | 1312 | anEvent->setSecrecy(secrecy); |
1317 | 1313 | ||
1318 | // categories | 1314 | // categories |
1319 | QStringList tmpStrList; | 1315 | QStringList tmpStrList; |
1320 | int index1 = 0; | 1316 | int index1 = 0; |
1321 | int index2 = 0; | 1317 | int index2 = 0; |
1322 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { | 1318 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { |
1323 | s = fakeCString(vObjectUStringZValue(vo)); | 1319 | s = fakeCString(vObjectUStringZValue(vo)); |
1324 | QString categories = QString::fromLocal8Bit(s); | 1320 | QString categories = QString::fromLocal8Bit(s); |
1325 | deleteStr(s); | 1321 | deleteStr(s); |
1326 | //const char* category; | 1322 | //const char* category; |
1327 | QString category; | 1323 | QString category; |
1328 | while ((index2 = categories.find(',', index1)) != -1) { | 1324 | while ((index2 = categories.find(',', index1)) != -1) { |
1329 | //category = (const char *) categories.mid(index1, (index2 - index1)); | 1325 | //category = (const char *) categories.mid(index1, (index2 - index1)); |
1330 | category = categories.mid(index1, (index2 - index1)); | 1326 | category = categories.mid(index1, (index2 - index1)); |
1331 | tmpStrList.append(category); | 1327 | tmpStrList.append(category); |
1332 | index1 = index2+1; | 1328 | index1 = index2+1; |
1333 | } | 1329 | } |
1334 | // get last category | 1330 | // get last category |
1335 | category = categories.mid(index1, (categories.length()-index1)); | 1331 | category = categories.mid(index1, (categories.length()-index1)); |
1336 | tmpStrList.append(category); | 1332 | tmpStrList.append(category); |
1337 | anEvent->setCategories(tmpStrList); | 1333 | anEvent->setCategories(tmpStrList); |
1338 | } | 1334 | } |
1339 | 1335 | ||
1340 | // attachments | 1336 | // attachments |
1341 | tmpStrList.clear(); | 1337 | tmpStrList.clear(); |
1342 | initPropIterator(&voi, vevent); | 1338 | initPropIterator(&voi, vevent); |
1343 | while (moreIteration(&voi)) { | 1339 | while (moreIteration(&voi)) { |
1344 | vo = nextVObject(&voi); | 1340 | vo = nextVObject(&voi); |
1345 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { | 1341 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { |
1346 | s = fakeCString(vObjectUStringZValue(vo)); | 1342 | s = fakeCString(vObjectUStringZValue(vo)); |
1347 | anEvent->addAttachment(new Attachment(QString(s))); | 1343 | anEvent->addAttachment(new Attachment(QString(s))); |
1348 | deleteStr(s); | 1344 | deleteStr(s); |
1349 | } | 1345 | } |
1350 | } | 1346 | } |
1351 | 1347 | ||
1352 | // resources | 1348 | // resources |
1353 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 1349 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
1354 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 1350 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
1355 | deleteStr(s); | 1351 | deleteStr(s); |
1356 | tmpStrList.clear(); | 1352 | tmpStrList.clear(); |
1357 | index1 = 0; | 1353 | index1 = 0; |
1358 | index2 = 0; | 1354 | index2 = 0; |
1359 | QString resource; | 1355 | QString resource; |
1360 | while ((index2 = resources.find(';', index1)) != -1) { | 1356 | while ((index2 = resources.find(';', index1)) != -1) { |
1361 | resource = resources.mid(index1, (index2 - index1)); | 1357 | resource = resources.mid(index1, (index2 - index1)); |
1362 | tmpStrList.append(resource); | 1358 | tmpStrList.append(resource); |
1363 | index1 = index2; | 1359 | index1 = index2; |
1364 | } | 1360 | } |
1365 | anEvent->setResources(tmpStrList); | 1361 | anEvent->setResources(tmpStrList); |
1366 | } | 1362 | } |
1367 | 1363 | ||
1368 | /* alarm stuff */ | 1364 | /* alarm stuff */ |
1369 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { | 1365 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { |
1370 | Alarm* alarm = anEvent->newAlarm(); | 1366 | Alarm* alarm = anEvent->newAlarm(); |
1371 | VObject *a; | 1367 | VObject *a; |
1372 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 1368 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
1373 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 1369 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
1374 | deleteStr(s); | 1370 | deleteStr(s); |
1375 | } | 1371 | } |
1376 | alarm->setEnabled(true); | 1372 | alarm->setEnabled(true); |
1377 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { | 1373 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { |
1378 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 1374 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
1379 | s = fakeCString(vObjectUStringZValue(a)); | 1375 | s = fakeCString(vObjectUStringZValue(a)); |
1380 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 1376 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
1381 | deleteStr(s); | 1377 | deleteStr(s); |
1382 | } | 1378 | } |
1383 | } | 1379 | } |
1384 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { | 1380 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { |
1385 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 1381 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
1386 | s = fakeCString(vObjectUStringZValue(a)); | 1382 | s = fakeCString(vObjectUStringZValue(a)); |
1387 | alarm->setAudioAlarm(QFile::decodeName(s)); | 1383 | alarm->setAudioAlarm(QFile::decodeName(s)); |
1388 | deleteStr(s); | 1384 | deleteStr(s); |
1389 | } | 1385 | } |
1390 | } | 1386 | } |
1391 | } | 1387 | } |
1392 | 1388 | ||
1393 | // priority | 1389 | // priority |
1394 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { | 1390 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { |
1395 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1391 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1396 | deleteStr(s); | 1392 | deleteStr(s); |
1397 | } | 1393 | } |
1398 | 1394 | ||
1399 | // transparency | 1395 | // transparency |
1400 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { | 1396 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { |
1401 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); | 1397 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); |
1402 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); | 1398 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); |
1403 | deleteStr(s); | 1399 | deleteStr(s); |
1404 | } | 1400 | } |
1405 | 1401 | ||
1406 | // related event | 1402 | // related event |
1407 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { | 1403 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { |
1408 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 1404 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
1409 | deleteStr(s); | 1405 | deleteStr(s); |
1410 | mEventsRelate.append(anEvent); | 1406 | mEventsRelate.append(anEvent); |
1411 | } | 1407 | } |
1412 | 1408 | ||
1413 | /* PILOT SYNC STUFF */ | 1409 | /* PILOT SYNC STUFF */ |
1414 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { | 1410 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { |
1415 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1411 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1416 | deleteStr(s); | 1412 | deleteStr(s); |
1417 | } | 1413 | } |
1418 | else | 1414 | else |
1419 | anEvent->setPilotId(0); | 1415 | anEvent->setPilotId(0); |
1420 | 1416 | ||
1421 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { | 1417 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { |
1422 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1418 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1423 | deleteStr(s); | 1419 | deleteStr(s); |
1424 | } | 1420 | } |
1425 | else | 1421 | else |
1426 | anEvent->setSyncStatus(Event::SYNCMOD); | 1422 | anEvent->setSyncStatus(Event::SYNCMOD); |
1427 | 1423 | ||
1428 | return anEvent; | 1424 | return anEvent; |
1429 | } | 1425 | } |
1430 | 1426 | ||
1431 | 1427 | ||
1432 | QString VCalFormat::qDateToISO(const QDate &qd) | 1428 | QString VCalFormat::qDateToISO(const QDate &qd) |
1433 | { | 1429 | { |
1434 | QString tmpStr; | 1430 | QString tmpStr; |
1435 | 1431 | ||
1436 | ASSERT(qd.isValid()); | 1432 | ASSERT(qd.isValid()); |
1437 | 1433 | ||
1438 | tmpStr.sprintf("%.2d%.2d%.2d", | 1434 | tmpStr.sprintf("%.2d%.2d%.2d", |
1439 | qd.year(), qd.month(), qd.day()); | 1435 | qd.year(), qd.month(), qd.day()); |
1440 | return tmpStr; | 1436 | return tmpStr; |
1441 | 1437 | ||
1442 | } | 1438 | } |
1443 | 1439 | ||
1444 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1440 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) |
1445 | { | 1441 | { |
1446 | QString tmpStr; | 1442 | QString tmpStr; |
1447 | 1443 | ||
1448 | ASSERT(qdt.date().isValid()); | 1444 | ASSERT(qdt.date().isValid()); |
1449 | ASSERT(qdt.time().isValid()); | 1445 | ASSERT(qdt.time().isValid()); |
1450 | if (zulu && !useLocalTime ) { | 1446 | if (zulu && !useLocalTime ) { |
1451 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); | 1447 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); |
1452 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", | 1448 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", |
1453 | tmpDT.date().year(), tmpDT.date().month(), | 1449 | tmpDT.date().year(), tmpDT.date().month(), |
1454 | tmpDT.date().day(), tmpDT.time().hour(), | 1450 | tmpDT.date().day(), tmpDT.time().hour(), |
1455 | tmpDT.time().minute(), tmpDT.time().second()); | 1451 | tmpDT.time().minute(), tmpDT.time().second()); |
1456 | } else { | 1452 | } else { |
1457 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", | 1453 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", |
1458 | qdt.date().year(), qdt.date().month(), | 1454 | qdt.date().year(), qdt.date().month(), |
1459 | qdt.date().day(), qdt.time().hour(), | 1455 | qdt.date().day(), qdt.time().hour(), |
1460 | qdt.time().minute(), qdt.time().second()); | 1456 | qdt.time().minute(), qdt.time().second()); |
1461 | } | 1457 | } |
1462 | return tmpStr; | 1458 | return tmpStr; |
1463 | } | 1459 | } |
1464 | 1460 | ||
1465 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) | 1461 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) |
1466 | { | 1462 | { |
1467 | QDate tmpDate; | 1463 | QDate tmpDate; |
1468 | QTime tmpTime; | 1464 | QTime tmpTime; |
1469 | QString tmpStr; | 1465 | QString tmpStr; |
1470 | int year, month, day, hour, minute, second; | 1466 | int year, month, day, hour, minute, second; |
1471 | 1467 | ||
1472 | tmpStr = dtStr; | 1468 | tmpStr = dtStr; |
1473 | year = tmpStr.left(4).toInt(); | 1469 | year = tmpStr.left(4).toInt(); |
1474 | month = tmpStr.mid(4,2).toInt(); | 1470 | month = tmpStr.mid(4,2).toInt(); |
1475 | day = tmpStr.mid(6,2).toInt(); | 1471 | day = tmpStr.mid(6,2).toInt(); |
1476 | hour = tmpStr.mid(9,2).toInt(); | 1472 | hour = tmpStr.mid(9,2).toInt(); |
1477 | minute = tmpStr.mid(11,2).toInt(); | 1473 | minute = tmpStr.mid(11,2).toInt(); |
1478 | second = tmpStr.mid(13,2).toInt(); | 1474 | second = tmpStr.mid(13,2).toInt(); |
1479 | tmpDate.setYMD(year, month, day); | 1475 | tmpDate.setYMD(year, month, day); |
1480 | tmpTime.setHMS(hour, minute, second); | 1476 | tmpTime.setHMS(hour, minute, second); |
1481 | 1477 | ||
1482 | ASSERT(tmpDate.isValid()); | 1478 | ASSERT(tmpDate.isValid()); |
1483 | ASSERT(tmpTime.isValid()); | 1479 | ASSERT(tmpTime.isValid()); |
1484 | QDateTime tmpDT(tmpDate, tmpTime); | 1480 | QDateTime tmpDT(tmpDate, tmpTime); |
1485 | // correct for GMT if string is in Zulu format | 1481 | // correct for GMT if string is in Zulu format |
1486 | if (dtStr.at(dtStr.length()-1) == 'Z') | 1482 | if (dtStr.at(dtStr.length()-1) == 'Z') |
1487 | tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); | 1483 | tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); |
1488 | return tmpDT; | 1484 | return tmpDT; |
1489 | } | 1485 | } |
1490 | 1486 | ||
1491 | QDate VCalFormat::ISOToQDate(const QString &dateStr) | 1487 | QDate VCalFormat::ISOToQDate(const QString &dateStr) |
1492 | { | 1488 | { |
1493 | int year, month, day; | 1489 | int year, month, day; |
1494 | 1490 | ||
1495 | year = dateStr.left(4).toInt(); | 1491 | year = dateStr.left(4).toInt(); |
1496 | month = dateStr.mid(4,2).toInt(); | 1492 | month = dateStr.mid(4,2).toInt(); |
1497 | day = dateStr.mid(6,2).toInt(); | 1493 | day = dateStr.mid(6,2).toInt(); |
1498 | 1494 | ||
1499 | return(QDate(year, month, day)); | 1495 | return(QDate(year, month, day)); |
1500 | } | 1496 | } |
1501 | 1497 | ||
1502 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. | 1498 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. |
1503 | // and break it down from it's tree-like format into the dictionary format | 1499 | // and break it down from it's tree-like format into the dictionary format |
1504 | // that is used internally in the VCalFormat. | 1500 | // that is used internally in the VCalFormat. |
1505 | void VCalFormat::populate(VObject *vcal) | 1501 | void VCalFormat::populate(VObject *vcal) |
1506 | { | 1502 | { |
1507 | // this function will populate the caldict dictionary and other event | 1503 | // this function will populate the caldict dictionary and other event |
1508 | // lists. It turns vevents into Events and then inserts them. | 1504 | // lists. It turns vevents into Events and then inserts them. |
1509 | 1505 | ||
1510 | VObjectIterator i; | 1506 | VObjectIterator i; |
1511 | VObject *curVO, *curVOProp; | 1507 | VObject *curVO, *curVOProp; |
1512 | Event *anEvent; | 1508 | Event *anEvent; |
1513 | 1509 | ||
1514 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { | 1510 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { |
1515 | char *methodType = 0; | 1511 | char *methodType = 0; |
1516 | methodType = fakeCString(vObjectUStringZValue(curVO)); | 1512 | methodType = fakeCString(vObjectUStringZValue(curVO)); |
1517 | kdDebug() << "This calendar is an iTIP transaction of type '" | 1513 | kdDebug() << "This calendar is an iTIP transaction of type '" |
1518 | << methodType << "'" << endl; | 1514 | << methodType << "'" << endl; |
1519 | delete methodType; | 1515 | delete methodType; |
1520 | } | 1516 | } |
1521 | 1517 | ||
1522 | // warn the user that we might have trouble reading non-known calendar. | 1518 | // warn the user that we might have trouble reading non-known calendar. |
1523 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { | 1519 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { |
1524 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1520 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1525 | if (strcmp(productId().local8Bit(), s) != 0) | 1521 | if (strcmp(productId().local8Bit(), s) != 0) |
1526 | kdDebug() << "This vCalendar file was not created by KOrganizer " | 1522 | kdDebug() << "This vCalendar file was not created by KOrganizer " |
1527 | "or any other product we support. Loading anyway..." << endl; | 1523 | "or any other product we support. Loading anyway..." << endl; |
1528 | mLoadedProductId = s; | 1524 | mLoadedProductId = s; |
1529 | deleteStr(s); | 1525 | deleteStr(s); |
1530 | } | 1526 | } |
1531 | 1527 | ||
1532 | // warn the user we might have trouble reading this unknown version. | 1528 | // warn the user we might have trouble reading this unknown version. |
1533 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1529 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1534 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1530 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1535 | if (strcmp(_VCAL_VERSION, s) != 0) | 1531 | if (strcmp(_VCAL_VERSION, s) != 0) |
1536 | kdDebug() << "This vCalendar file has version " << s | 1532 | kdDebug() << "This vCalendar file has version " << s |
1537 | << "We only support " << _VCAL_VERSION << endl; | 1533 | << "We only support " << _VCAL_VERSION << endl; |
1538 | deleteStr(s); | 1534 | deleteStr(s); |
1539 | } | 1535 | } |
1540 | 1536 | ||
1541 | // set the time zone | 1537 | // set the time zone |
1542 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1538 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1543 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1539 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1544 | mCalendar->setTimeZone(s); | 1540 | mCalendar->setTimeZone(s); |
1545 | deleteStr(s); | 1541 | deleteStr(s); |
1546 | } | 1542 | } |
1547 | 1543 | ||
1548 | 1544 | ||
1549 | // Store all events with a relatedTo property in a list for post-processing | 1545 | // Store all events with a relatedTo property in a list for post-processing |
1550 | mEventsRelate.clear(); | 1546 | mEventsRelate.clear(); |
1551 | mTodosRelate.clear(); | 1547 | mTodosRelate.clear(); |
1552 | 1548 | ||
1553 | initPropIterator(&i, vcal); | 1549 | initPropIterator(&i, vcal); |
1554 | 1550 | ||
1555 | // go through all the vobjects in the vcal | 1551 | // go through all the vobjects in the vcal |
1556 | while (moreIteration(&i)) { | 1552 | while (moreIteration(&i)) { |
1557 | curVO = nextVObject(&i); | 1553 | curVO = nextVObject(&i); |
1558 | 1554 | ||
1559 | /************************************************************************/ | 1555 | /************************************************************************/ |
1560 | 1556 | ||
1561 | // now, check to see that the object is an event or todo. | 1557 | // now, check to see that the object is an event or todo. |
1562 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1558 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1563 | 1559 | ||
1564 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { | 1560 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { |
1565 | char *s; | 1561 | char *s; |
1566 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1562 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1567 | // check to see if event was deleted by the kpilot conduit | 1563 | // check to see if event was deleted by the kpilot conduit |
1568 | if (atoi(s) == Event::SYNCDEL) { | 1564 | if (atoi(s) == Event::SYNCDEL) { |
1569 | deleteStr(s); | 1565 | deleteStr(s); |
1570 | kdDebug(5800) << "skipping pilot-deleted event" << endl; | 1566 | kdDebug(5800) << "skipping pilot-deleted event" << endl; |
1571 | goto SKIP; | 1567 | goto SKIP; |
1572 | } | 1568 | } |
1573 | deleteStr(s); | 1569 | deleteStr(s); |
1574 | } | 1570 | } |
1575 | 1571 | ||
1576 | // this code checks to see if we are trying to read in an event | 1572 | // this code checks to see if we are trying to read in an event |
1577 | // that we already find to be in the calendar. If we find this | 1573 | // that we already find to be in the calendar. If we find this |
1578 | // to be the case, we skip the event. | 1574 | // to be the case, we skip the event. |
1579 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 1575 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
1580 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 1576 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
1581 | QString tmpStr(s); | 1577 | QString tmpStr(s); |
1582 | deleteStr(s); | 1578 | deleteStr(s); |
1583 | 1579 | ||
1584 | if (mCalendar->event(tmpStr)) { | 1580 | if (mCalendar->event(tmpStr)) { |
1585 | goto SKIP; | 1581 | goto SKIP; |
1586 | } | 1582 | } |
1587 | if (mCalendar->todo(tmpStr)) { | 1583 | if (mCalendar->todo(tmpStr)) { |
1588 | goto SKIP; | 1584 | goto SKIP; |
1589 | } | 1585 | } |
1590 | } | 1586 | } |
1591 | 1587 | ||
1592 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && | 1588 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && |
1593 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { | 1589 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { |
1594 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 1590 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
1595 | goto SKIP; | 1591 | goto SKIP; |
1596 | } | 1592 | } |
1597 | 1593 | ||
1598 | anEvent = VEventToEvent(curVO); | 1594 | anEvent = VEventToEvent(curVO); |
1599 | // we now use addEvent instead of insertEvent so that the | 1595 | // we now use addEvent instead of insertEvent so that the |
1600 | // signal/slot get connected. | 1596 | // signal/slot get connected. |
1601 | if (anEvent) { | 1597 | if (anEvent) { |
1602 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { | 1598 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { |
1603 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." | 1599 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." |
1604 | << endl; | 1600 | << endl; |
1605 | } else { | 1601 | } else { |
1606 | mCalendar->addEvent(anEvent); | 1602 | mCalendar->addEvent(anEvent); |
1607 | } | 1603 | } |
1608 | } else { | 1604 | } else { |
1609 | // some sort of error must have occurred while in translation. | 1605 | // some sort of error must have occurred while in translation. |
1610 | goto SKIP; | 1606 | goto SKIP; |
1611 | } | 1607 | } |
1612 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { | 1608 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { |
1613 | Todo *aTodo = VTodoToEvent(curVO); | 1609 | Todo *aTodo = VTodoToEvent(curVO); |
1614 | mCalendar->addTodo(aTodo); | 1610 | mCalendar->addTodo(aTodo); |
1615 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || | 1611 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || |
1616 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || | 1612 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || |
1617 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { | 1613 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { |
1618 | // do nothing, we know these properties and we want to skip them. | 1614 | // do nothing, we know these properties and we want to skip them. |
1619 | // we have either already processed them or are ignoring them. | 1615 | // we have either already processed them or are ignoring them. |
1620 | ; | 1616 | ; |
1621 | } else { | 1617 | } else { |
1622 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; | 1618 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; |
1623 | } | 1619 | } |
1624 | SKIP: | 1620 | SKIP: |
1625 | ; | 1621 | ; |
1626 | } // while | 1622 | } // while |
1627 | 1623 | ||
1628 | // Post-Process list of events with relations, put Event objects in relation | 1624 | // Post-Process list of events with relations, put Event objects in relation |
1629 | Event *ev; | 1625 | Event *ev; |
1630 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { | 1626 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { |
1631 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); | 1627 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); |
1632 | } | 1628 | } |
1633 | Todo *todo; | 1629 | Todo *todo; |
1634 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { | 1630 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { |
1635 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); | 1631 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); |
1636 | } | 1632 | } |
1637 | } | 1633 | } |
1638 | 1634 | ||
1639 | const char *VCalFormat::dayFromNum(int day) | 1635 | const char *VCalFormat::dayFromNum(int day) |
1640 | { | 1636 | { |
1641 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; | 1637 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; |
1642 | 1638 | ||
1643 | return days[day]; | 1639 | return days[day]; |
1644 | } | 1640 | } |
1645 | 1641 | ||
1646 | int VCalFormat::numFromDay(const QString &day) | 1642 | int VCalFormat::numFromDay(const QString &day) |
1647 | { | 1643 | { |
1648 | if (day == "MO ") return 0; | 1644 | if (day == "MO ") return 0; |
1649 | if (day == "TU ") return 1; | 1645 | if (day == "TU ") return 1; |
1650 | if (day == "WE ") return 2; | 1646 | if (day == "WE ") return 2; |
1651 | if (day == "TH ") return 3; | 1647 | if (day == "TH ") return 3; |
1652 | if (day == "FR ") return 4; | 1648 | if (day == "FR ") return 4; |
1653 | if (day == "SA ") return 5; | 1649 | if (day == "SA ") return 5; |
1654 | if (day == "SU ") return 6; | 1650 | if (day == "SU ") return 6; |
1655 | 1651 | ||
1656 | return -1; // something bad happened. :) | 1652 | return -1; // something bad happened. :) |
1657 | } | 1653 | } |
1658 | 1654 | ||
1659 | Attendee::PartStat VCalFormat::readStatus(const char *s) const | 1655 | Attendee::PartStat VCalFormat::readStatus(const char *s) const |
1660 | { | 1656 | { |
1661 | QString statStr = s; | 1657 | QString statStr = s; |
1662 | statStr = statStr.upper(); | 1658 | statStr = statStr.upper(); |
1663 | Attendee::PartStat status; | 1659 | Attendee::PartStat status; |
1664 | 1660 | ||
1665 | if (statStr == "X-ACTION") | 1661 | if (statStr == "X-ACTION") |
1666 | status = Attendee::NeedsAction; | 1662 | status = Attendee::NeedsAction; |
1667 | else if (statStr == "NEEDS ACTION") | 1663 | else if (statStr == "NEEDS ACTION") |
1668 | status = Attendee::NeedsAction; | 1664 | status = Attendee::NeedsAction; |
1669 | else if (statStr== "ACCEPTED") | 1665 | else if (statStr== "ACCEPTED") |
1670 | status = Attendee::Accepted; | 1666 | status = Attendee::Accepted; |
1671 | else if (statStr== "SENT") | 1667 | else if (statStr== "SENT") |
1672 | status = Attendee::NeedsAction; | 1668 | status = Attendee::NeedsAction; |
1673 | else if (statStr== "TENTATIVE") | 1669 | else if (statStr== "TENTATIVE") |
1674 | status = Attendee::Tentative; | 1670 | status = Attendee::Tentative; |
1675 | else if (statStr== "CONFIRMED") | 1671 | else if (statStr== "CONFIRMED") |
1676 | status = Attendee::Accepted; | 1672 | status = Attendee::Accepted; |
1677 | else if (statStr== "DECLINED") | 1673 | else if (statStr== "DECLINED") |
1678 | status = Attendee::Declined; | 1674 | status = Attendee::Declined; |
1679 | else if (statStr== "COMPLETED") | 1675 | else if (statStr== "COMPLETED") |
1680 | status = Attendee::Completed; | 1676 | status = Attendee::Completed; |
1681 | else if (statStr== "DELEGATED") | 1677 | else if (statStr== "DELEGATED") |
1682 | status = Attendee::Delegated; | 1678 | status = Attendee::Delegated; |
1683 | else { | 1679 | else { |
1684 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; | 1680 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; |
1685 | status = Attendee::NeedsAction; | 1681 | status = Attendee::NeedsAction; |
1686 | } | 1682 | } |
1687 | 1683 | ||
1688 | return status; | 1684 | return status; |
1689 | } | 1685 | } |
1690 | 1686 | ||
1691 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const | 1687 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const |
1692 | { | 1688 | { |
1693 | switch(status) { | 1689 | switch(status) { |
1694 | default: | 1690 | default: |
1695 | case Attendee::NeedsAction: | 1691 | case Attendee::NeedsAction: |
1696 | return "NEEDS ACTION"; | 1692 | return "NEEDS ACTION"; |
1697 | break; | 1693 | break; |
1698 | case Attendee::Accepted: | 1694 | case Attendee::Accepted: |
1699 | return "ACCEPTED"; | 1695 | return "ACCEPTED"; |
1700 | break; | 1696 | break; |
1701 | case Attendee::Declined: | 1697 | case Attendee::Declined: |
1702 | return "DECLINED"; | 1698 | return "DECLINED"; |
1703 | break; | 1699 | break; |
1704 | case Attendee::Tentative: | 1700 | case Attendee::Tentative: |
1705 | return "TENTATIVE"; | 1701 | return "TENTATIVE"; |
1706 | break; | 1702 | break; |
1707 | case Attendee::Delegated: | 1703 | case Attendee::Delegated: |
1708 | return "DELEGATED"; | 1704 | return "DELEGATED"; |
1709 | break; | 1705 | break; |
1710 | case Attendee::Completed: | 1706 | case Attendee::Completed: |
1711 | return "COMPLETED"; | 1707 | return "COMPLETED"; |
1712 | break; | 1708 | break; |
1713 | case Attendee::InProcess: | 1709 | case Attendee::InProcess: |
1714 | return "NEEDS ACTION"; | 1710 | return "NEEDS ACTION"; |
1715 | break; | 1711 | break; |
1716 | } | 1712 | } |
1717 | } | 1713 | } |