author | zautrix <zautrix> | 2005-03-16 23:10:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-16 23:10:29 (UTC) |
commit | d2be5ea1cd22f5222aecb0f70a2fe8657fae9698 (patch) (unidiff) | |
tree | 5de4c2b05428d837e2451df06b3ea313bd02c1b8 /libkcal | |
parent | b7184073d5e552e0f04b14c5fc0c20a7bfd26d3d (diff) | |
download | kdepimpi-d2be5ea1cd22f5222aecb0f70a2fe8657fae9698.zip kdepimpi-d2be5ea1cd22f5222aecb0f70a2fe8657fae9698.tar.gz kdepimpi-d2be5ea1cd22f5222aecb0f70a2fe8657fae9698.tar.bz2 |
fixes
-rw-r--r-- | libkcal/vcalformat.cpp | 50 |
1 files changed, 7 insertions, 43 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 223aa5a..62a31ae 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -138,359 +138,358 @@ bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | |||
138 | { | 138 | { |
139 | // TODO: Factor out VCalFormat::fromString() | 139 | // TODO: Factor out VCalFormat::fromString() |
140 | 140 | ||
141 | QCString data = text.utf8(); | 141 | QCString data = text.utf8(); |
142 | 142 | ||
143 | if ( !data.size() ) return false; | 143 | if ( !data.size() ) return false; |
144 | 144 | ||
145 | VObject *vcal = Parse_MIME( data.data(), data.size()); | 145 | VObject *vcal = Parse_MIME( data.data(), data.size()); |
146 | if ( !vcal ) return false; | 146 | if ( !vcal ) return false; |
147 | 147 | ||
148 | VObjectIterator i; | 148 | VObjectIterator i; |
149 | VObject *curvo; | 149 | VObject *curvo; |
150 | initPropIterator( &i, vcal ); | 150 | initPropIterator( &i, vcal ); |
151 | 151 | ||
152 | // we only take the first object. TODO: parse all incidences. | 152 | // we only take the first object. TODO: parse all incidences. |
153 | do { | 153 | do { |
154 | curvo = nextVObject( &i ); | 154 | curvo = nextVObject( &i ); |
155 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && | 155 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && |
156 | strcmp( vObjectName( curvo ), VCTodoProp ) ); | 156 | strcmp( vObjectName( curvo ), VCTodoProp ) ); |
157 | 157 | ||
158 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { | 158 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { |
159 | Event *event = VEventToEvent( curvo ); | 159 | Event *event = VEventToEvent( curvo ); |
160 | calendar->addEvent( event ); | 160 | calendar->addEvent( event ); |
161 | } else { | 161 | } else { |
162 | qDebug("VCalFormat::fromString(): Unknown object type. "); | 162 | qDebug("VCalFormat::fromString(): Unknown object type. "); |
163 | deleteVObject( vcal ); | 163 | deleteVObject( vcal ); |
164 | return false; | 164 | return false; |
165 | } | 165 | } |
166 | 166 | ||
167 | deleteVObject( vcal ); | 167 | deleteVObject( vcal ); |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) | 172 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) |
173 | { | 173 | { |
174 | 174 | ||
175 | if ( !event ) return QString::null; | 175 | if ( !event ) return QString::null; |
176 | bool useL = useLocalTime; | 176 | bool useL = useLocalTime; |
177 | useLocalTime = useLocal; | 177 | useLocalTime = useLocal; |
178 | mCalendar = calendar; | 178 | mCalendar = calendar; |
179 | VObject *vevent = eventToVEvent( event ); | 179 | VObject *vevent = eventToVEvent( event ); |
180 | char *buf = writeMemVObject( 0, 0, vevent ); | 180 | char *buf = writeMemVObject( 0, 0, vevent ); |
181 | QString result( buf ); | 181 | QString result( buf ); |
182 | cleanVObject( vevent ); | 182 | cleanVObject( vevent ); |
183 | useLocalTime = useL; | 183 | useLocalTime = useL; |
184 | return result; | 184 | return result; |
185 | } | 185 | } |
186 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) | 186 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) |
187 | { | 187 | { |
188 | 188 | ||
189 | if ( !todo ) return QString::null; | 189 | if ( !todo ) return QString::null; |
190 | bool useL = useLocalTime; | 190 | bool useL = useLocalTime; |
191 | useLocalTime = useLocal; | 191 | useLocalTime = useLocal; |
192 | mCalendar = calendar; | 192 | mCalendar = calendar; |
193 | VObject *vevent = eventToVTodo( todo ); | 193 | VObject *vevent = eventToVTodo( todo ); |
194 | char *buf = writeMemVObject( 0, 0, vevent ); | 194 | char *buf = writeMemVObject( 0, 0, vevent ); |
195 | QString result( buf ); | 195 | QString result( buf ); |
196 | cleanVObject( vevent ); | 196 | cleanVObject( vevent ); |
197 | useLocalTime = useL; | 197 | useLocalTime = useL; |
198 | return result; | 198 | return result; |
199 | } | 199 | } |
200 | 200 | ||
201 | QString VCalFormat::toString( Calendar *calendar ) | 201 | QString VCalFormat::toString( Calendar *calendar ) |
202 | { | 202 | { |
203 | // TODO: Factor out VCalFormat::asString() | 203 | // TODO: Factor out VCalFormat::asString() |
204 | 204 | ||
205 | VObject *vcal = newVObject(VCCalProp); | 205 | VObject *vcal = newVObject(VCCalProp); |
206 | 206 | ||
207 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); | 207 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); |
208 | QString tmpStr = mCalendar->getTimeZoneStr(); | 208 | QString tmpStr = mCalendar->getTimeZoneStr(); |
209 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); | 209 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); |
210 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); | 210 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); |
211 | 211 | ||
212 | // TODO: Use all data. | 212 | // TODO: Use all data. |
213 | QPtrList<Event> events = calendar->events(); | 213 | QPtrList<Event> events = calendar->events(); |
214 | Event *event = events.first(); | 214 | Event *event = events.first(); |
215 | if ( !event ) return QString::null; | 215 | if ( !event ) return QString::null; |
216 | 216 | ||
217 | VObject *vevent = eventToVEvent( event ); | 217 | VObject *vevent = eventToVEvent( event ); |
218 | 218 | ||
219 | addVObjectProp( vcal, vevent ); | 219 | addVObjectProp( vcal, vevent ); |
220 | 220 | ||
221 | char *buf = writeMemVObject( 0, 0, vcal ); | 221 | char *buf = writeMemVObject( 0, 0, vcal ); |
222 | 222 | ||
223 | QString result( buf ); | 223 | QString result( buf ); |
224 | 224 | ||
225 | cleanVObject( vcal ); | 225 | cleanVObject( vcal ); |
226 | 226 | ||
227 | return result; | 227 | return result; |
228 | } | 228 | } |
229 | 229 | ||
230 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | 230 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) |
231 | { | 231 | { |
232 | VObject *vtodo; | 232 | VObject *vtodo; |
233 | QString tmpStr; | 233 | QString tmpStr; |
234 | QStringList tmpStrList; | 234 | |
235 | 235 | ||
236 | vtodo = newVObject(VCTodoProp); | 236 | vtodo = newVObject(VCTodoProp); |
237 | 237 | ||
238 | // due date | 238 | // due date |
239 | if (anEvent->hasDueDate()) { | 239 | if (anEvent->hasDueDate()) { |
240 | tmpStr = qDateTimeToISO(anEvent->dtDue(), | 240 | tmpStr = qDateTimeToISO(anEvent->dtDue(), |
241 | !anEvent->doesFloat()); | 241 | !anEvent->doesFloat()); |
242 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); | 242 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); |
243 | } | 243 | } |
244 | 244 | ||
245 | // start date | 245 | // start date |
246 | if (anEvent->hasStartDate()) { | 246 | if (anEvent->hasStartDate()) { |
247 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 247 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
248 | !anEvent->doesFloat()); | 248 | !anEvent->doesFloat()); |
249 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); | 249 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); |
250 | } | 250 | } |
251 | 251 | ||
252 | // creation date | 252 | // creation date |
253 | tmpStr = qDateTimeToISO(anEvent->created()); | 253 | tmpStr = qDateTimeToISO(anEvent->created()); |
254 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); | 254 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); |
255 | 255 | ||
256 | // unique id | 256 | // unique id |
257 | addPropValue(vtodo, VCUniqueStringProp, | 257 | addPropValue(vtodo, VCUniqueStringProp, |
258 | anEvent->uid().local8Bit()); | 258 | anEvent->uid().local8Bit()); |
259 | 259 | ||
260 | // revision | 260 | // revision |
261 | tmpStr.sprintf("%i", anEvent->revision()); | 261 | tmpStr.sprintf("%i", anEvent->revision()); |
262 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); | 262 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); |
263 | 263 | ||
264 | // last modification date | 264 | // last modification date |
265 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 265 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
266 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); | 266 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); |
267 | 267 | ||
268 | // organizer stuff | 268 | // organizer stuff |
269 | tmpStr = "MAILTO:" + anEvent->organizer(); | 269 | tmpStr = "MAILTO:" + anEvent->organizer(); |
270 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); | 270 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); |
271 | 271 | ||
272 | // attendees | 272 | // attendees |
273 | if (anEvent->attendeeCount() != 0) { | 273 | if (anEvent->attendeeCount() != 0) { |
274 | QPtrList<Attendee> al = anEvent->attendees(); | 274 | QPtrList<Attendee> al = anEvent->attendees(); |
275 | QPtrListIterator<Attendee> ai(al); | 275 | QPtrListIterator<Attendee> ai(al); |
276 | Attendee *curAttendee; | 276 | Attendee *curAttendee; |
277 | 277 | ||
278 | for (; ai.current(); ++ai) { | 278 | for (; ai.current(); ++ai) { |
279 | curAttendee = ai.current(); | 279 | curAttendee = ai.current(); |
280 | if (!curAttendee->email().isEmpty() && | 280 | if (!curAttendee->email().isEmpty() && |
281 | !curAttendee->name().isEmpty()) | 281 | !curAttendee->name().isEmpty()) |
282 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 282 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
283 | curAttendee->email() + ">"; | 283 | curAttendee->email() + ">"; |
284 | else if (curAttendee->name().isEmpty()) | 284 | else if (curAttendee->name().isEmpty()) |
285 | tmpStr = "MAILTO: " + curAttendee->email(); | 285 | tmpStr = "MAILTO: " + curAttendee->email(); |
286 | else if (curAttendee->email().isEmpty()) | 286 | else if (curAttendee->email().isEmpty()) |
287 | tmpStr = "MAILTO: " + curAttendee->name(); | 287 | tmpStr = "MAILTO: " + curAttendee->name(); |
288 | else if (curAttendee->name().isEmpty() && | 288 | else if (curAttendee->name().isEmpty() && |
289 | curAttendee->email().isEmpty()) | 289 | curAttendee->email().isEmpty()) |
290 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 290 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
291 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); | 291 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); |
292 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); | 292 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); |
293 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 293 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
294 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 294 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
295 | } | 295 | } |
296 | } | 296 | } |
297 | 297 | ||
298 | // description BL: | 298 | // description BL: |
299 | if (!anEvent->description().isEmpty()) { | 299 | if (!anEvent->description().isEmpty()) { |
300 | VObject *d = addPropValue(vtodo, VCDescriptionProp, | 300 | VObject *d = addPropValue(vtodo, VCDescriptionProp, |
301 | anEvent->description().local8Bit()); | 301 | anEvent->description().local8Bit()); |
302 | if (anEvent->description().find('\n') != -1) | 302 | if (anEvent->description().find('\n') != -1) |
303 | addProp(d, VCQuotedPrintableProp); | 303 | addProp(d, VCQuotedPrintableProp); |
304 | } | 304 | } |
305 | 305 | ||
306 | // summary | 306 | // summary |
307 | if (!anEvent->summary().isEmpty()) | 307 | if (!anEvent->summary().isEmpty()) |
308 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); | 308 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); |
309 | 309 | ||
310 | if (!anEvent->location().isEmpty()) | 310 | if (!anEvent->location().isEmpty()) |
311 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); | 311 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); |
312 | 312 | ||
313 | // completed | 313 | // completed |
314 | // status | 314 | // status |
315 | // backward compatibility, KOrganizer used to interpret only these two values | 315 | // backward compatibility, KOrganizer used to interpret only these two values |
316 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : | 316 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : |
317 | "NEEDS_ACTION"); | 317 | "NEEDS_ACTION"); |
318 | // completion date | 318 | // completion date |
319 | if (anEvent->hasCompletedDate()) { | 319 | if (anEvent->hasCompletedDate()) { |
320 | tmpStr = qDateTimeToISO(anEvent->completed()); | 320 | tmpStr = qDateTimeToISO(anEvent->completed()); |
321 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); | 321 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); |
322 | } | 322 | } |
323 | 323 | ||
324 | // priority | 324 | // priority |
325 | tmpStr.sprintf("%i",anEvent->priority()); | 325 | tmpStr.sprintf("%i",anEvent->priority()); |
326 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); | 326 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); |
327 | 327 | ||
328 | // related event | 328 | // related event |
329 | if (anEvent->relatedTo()) { | 329 | if (anEvent->relatedTo()) { |
330 | addPropValue(vtodo, VCRelatedToProp, | 330 | addPropValue(vtodo, VCRelatedToProp, |
331 | anEvent->relatedTo()->uid().local8Bit()); | 331 | anEvent->relatedTo()->uid().local8Bit()); |
332 | } | 332 | } |
333 | 333 | ||
334 | // categories | 334 | // categories |
335 | tmpStrList = anEvent->categories(); | 335 | QStringList tmpStrList = anEvent->categories(); |
336 | tmpStr = ""; | 336 | tmpStr = ""; |
337 | QString catStr; | 337 | QString catStr; |
338 | for ( QStringList::Iterator it = tmpStrList.begin(); | 338 | for ( QStringList::Iterator it = tmpStrList.begin(); |
339 | it != tmpStrList.end(); | 339 | it != tmpStrList.end(); |
340 | ++it ) { | 340 | ++it ) { |
341 | catStr = *it; | 341 | catStr = *it; |
342 | if (catStr[0] == ' ') | 342 | if (catStr[0] == ' ') |
343 | tmpStr += catStr.mid(1); | 343 | tmpStr += catStr.mid(1); |
344 | else | 344 | else |
345 | tmpStr += catStr; | 345 | tmpStr += catStr; |
346 | // this must be a ';' character as the vCalendar specification requires! | 346 | // this must be a ';' character as the vCalendar specification requires! |
347 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 347 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
348 | // read in. | 348 | // read in. |
349 | tmpStr += ";"; | 349 | tmpStr += ";"; |
350 | } | 350 | } |
351 | if (!tmpStr.isEmpty()) { | 351 | if (!tmpStr.isEmpty()) { |
352 | tmpStr.truncate(tmpStr.length()-1); | 352 | tmpStr.truncate(tmpStr.length()-1); |
353 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); | 353 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); |
354 | } | 354 | } |
355 | 355 | ||
356 | // alarm stuff | 356 | // alarm stuff |
357 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; | 357 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; |
358 | QPtrList<Alarm> alarms = anEvent->alarms(); | 358 | QPtrList<Alarm> alarms = anEvent->alarms(); |
359 | Alarm* alarm; | 359 | Alarm* alarm; |
360 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 360 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
361 | if (alarm->enabled()) { | 361 | if (alarm->enabled()) { |
362 | VObject *a; | 362 | VObject *a; |
363 | tmpStr = qDateTimeToISO(alarm->time()); | 363 | tmpStr = qDateTimeToISO(alarm->time()); |
364 | if (alarm->type() == Alarm::Audio) { | 364 | if (alarm->type() == Alarm::Audio) { |
365 | a = addProp(vtodo, VCAAlarmProp); | 365 | a = addProp(vtodo, VCAAlarmProp); |
366 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 366 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
367 | addPropValue(a, VCRepeatCountProp, "1"); | 367 | addPropValue(a, VCRepeatCountProp, "1"); |
368 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 368 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
369 | } | 369 | } |
370 | else if (alarm->type() == Alarm::Procedure) { | 370 | else if (alarm->type() == Alarm::Procedure) { |
371 | a = addProp(vtodo, VCPAlarmProp); | 371 | a = addProp(vtodo, VCPAlarmProp); |
372 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 372 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
373 | addPropValue(a, VCRepeatCountProp, "1"); | 373 | addPropValue(a, VCRepeatCountProp, "1"); |
374 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 374 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
375 | } else { | 375 | } else { |
376 | a = addProp(vtodo, VCDAlarmProp); | 376 | a = addProp(vtodo, VCDAlarmProp); |
377 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 377 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
378 | addPropValue(a, VCRepeatCountProp, "1"); | 378 | addPropValue(a, VCRepeatCountProp, "1"); |
379 | addPropValue(a, VCDisplayStringProp, "beep!"); | 379 | addPropValue(a, VCDisplayStringProp, "beep!"); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | if (anEvent->pilotId()) { | 384 | if (anEvent->pilotId()) { |
385 | // pilot sync stuff | 385 | // pilot sync stuff |
386 | tmpStr.sprintf("%i",anEvent->pilotId()); | 386 | tmpStr.sprintf("%i",anEvent->pilotId()); |
387 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); | 387 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); |
388 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 388 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
389 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); | 389 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); |
390 | } | 390 | } |
391 | 391 | ||
392 | return vtodo; | 392 | return vtodo; |
393 | } | 393 | } |
394 | 394 | ||
395 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 395 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) |
396 | { | 396 | { |
397 | VObject *vevent; | 397 | VObject *vevent; |
398 | QString tmpStr; | 398 | QString tmpStr; |
399 | QStringList tmpStrList; | 399 | |
400 | |||
401 | vevent = newVObject(VCEventProp); | 400 | vevent = newVObject(VCEventProp); |
402 | 401 | ||
403 | // start and end time | 402 | // start and end time |
404 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 403 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
405 | !anEvent->doesFloat()); | 404 | !anEvent->doesFloat()); |
406 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 405 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
407 | 406 | ||
408 | // events that have time associated but take up no time should | 407 | // events that have time associated but take up no time should |
409 | // not have both DTSTART and DTEND. | 408 | // not have both DTSTART and DTEND. |
410 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 409 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
411 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 410 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
412 | !anEvent->doesFloat()); | 411 | !anEvent->doesFloat()); |
413 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); | 412 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); |
414 | } | 413 | } |
415 | 414 | ||
416 | // creation date | 415 | // creation date |
417 | tmpStr = qDateTimeToISO(anEvent->created()); | 416 | tmpStr = qDateTimeToISO(anEvent->created()); |
418 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); | 417 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); |
419 | 418 | ||
420 | // unique id | 419 | // unique id |
421 | addPropValue(vevent, VCUniqueStringProp, | 420 | addPropValue(vevent, VCUniqueStringProp, |
422 | anEvent->uid().local8Bit()); | 421 | anEvent->uid().local8Bit()); |
423 | 422 | ||
424 | // revision | 423 | // revision |
425 | tmpStr.sprintf("%i", anEvent->revision()); | 424 | tmpStr.sprintf("%i", anEvent->revision()); |
426 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); | 425 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); |
427 | 426 | ||
428 | // last modification date | 427 | // last modification date |
429 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 428 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
430 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); | 429 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); |
431 | 430 | ||
432 | // attendee and organizer stuff | 431 | // attendee and organizer stuff |
433 | tmpStr = "MAILTO:" + anEvent->organizer(); | 432 | tmpStr = "MAILTO:" + anEvent->organizer(); |
434 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); | 433 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); |
435 | 434 | ||
436 | if (anEvent->attendeeCount() != 0) { | 435 | if (anEvent->attendeeCount() != 0) { |
437 | QPtrList<Attendee> al = anEvent->attendees(); | 436 | QPtrList<Attendee> al = anEvent->attendees(); |
438 | QPtrListIterator<Attendee> ai(al); | 437 | QPtrListIterator<Attendee> ai(al); |
439 | Attendee *curAttendee; | 438 | Attendee *curAttendee; |
440 | 439 | ||
441 | // TODO: Put this functionality into Attendee class | 440 | // TODO: Put this functionality into Attendee class |
442 | for (; ai.current(); ++ai) { | 441 | for (; ai.current(); ++ai) { |
443 | curAttendee = ai.current(); | 442 | curAttendee = ai.current(); |
444 | if (!curAttendee->email().isEmpty() && | 443 | if (!curAttendee->email().isEmpty() && |
445 | !curAttendee->name().isEmpty()) | 444 | !curAttendee->name().isEmpty()) |
446 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 445 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
447 | curAttendee->email() + ">"; | 446 | curAttendee->email() + ">"; |
448 | else if (curAttendee->name().isEmpty()) | 447 | else if (curAttendee->name().isEmpty()) |
449 | tmpStr = "MAILTO: " + curAttendee->email(); | 448 | tmpStr = "MAILTO: " + curAttendee->email(); |
450 | else if (curAttendee->email().isEmpty()) | 449 | else if (curAttendee->email().isEmpty()) |
451 | tmpStr = "MAILTO: " + curAttendee->name(); | 450 | tmpStr = "MAILTO: " + curAttendee->name(); |
452 | else if (curAttendee->name().isEmpty() && | 451 | else if (curAttendee->name().isEmpty() && |
453 | curAttendee->email().isEmpty()) | 452 | curAttendee->email().isEmpty()) |
454 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 453 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
455 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); | 454 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); |
456 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); | 455 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); |
457 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 456 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
458 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 457 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
459 | } | 458 | } |
460 | } | 459 | } |
461 | 460 | ||
462 | // recurrence rule stuff | 461 | // recurrence rule stuff |
463 | if (anEvent->recurrence()->doesRecur()) { | 462 | if (anEvent->recurrence()->doesRecur()) { |
464 | // some more variables | 463 | // some more variables |
465 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 464 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
466 | QPtrList<int> tmpDays; | 465 | QPtrList<int> tmpDays; |
467 | int *tmpDay; | 466 | int *tmpDay; |
468 | Recurrence::rMonthPos *tmpPos; | 467 | Recurrence::rMonthPos *tmpPos; |
469 | QString tmpStr2; | 468 | QString tmpStr2; |
470 | int i; | 469 | int i; |
471 | 470 | ||
472 | switch(anEvent->recurrence()->doesRecur()) { | 471 | switch(anEvent->recurrence()->doesRecur()) { |
473 | case Recurrence::rDaily: | 472 | case Recurrence::rDaily: |
474 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); | 473 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); |
475 | // if (anEvent->rDuration > 0) | 474 | // if (anEvent->rDuration > 0) |
476 | //tmpStr += "#"; | 475 | //tmpStr += "#"; |
477 | break; | 476 | break; |
478 | case Recurrence::rWeekly: | 477 | case Recurrence::rWeekly: |
479 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); | 478 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); |
480 | for (i = 0; i < 7; i++) { | 479 | for (i = 0; i < 7; i++) { |
481 | if (anEvent->recurrence()->days().testBit(i)) | 480 | if (anEvent->recurrence()->days().testBit(i)) |
482 | tmpStr += dayFromNum(i); | 481 | tmpStr += dayFromNum(i); |
483 | } | 482 | } |
484 | break; | 483 | break; |
485 | case Recurrence::rMonthlyPos: | 484 | case Recurrence::rMonthlyPos: |
486 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); | 485 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); |
487 | // write out all rMonthPos's | 486 | // write out all rMonthPos's |
488 | tmpPositions = anEvent->recurrence()->monthPositions(); | 487 | tmpPositions = anEvent->recurrence()->monthPositions(); |
489 | for (tmpPos = tmpPositions.first(); | 488 | for (tmpPos = tmpPositions.first(); |
490 | tmpPos; | 489 | tmpPos; |
491 | tmpPos = tmpPositions.next()) { | 490 | tmpPos = tmpPositions.next()) { |
492 | 491 | ||
493 | tmpStr2.sprintf("%i", tmpPos->rPos); | 492 | tmpStr2.sprintf("%i", tmpPos->rPos); |
494 | if (tmpPos->negative) | 493 | if (tmpPos->negative) |
495 | tmpStr2 += "- "; | 494 | tmpStr2 += "- "; |
496 | else | 495 | else |
@@ -510,193 +509,193 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent) | |||
510 | tmpDay; | 509 | tmpDay; |
511 | tmpDay = tmpDays.next()) { | 510 | tmpDay = tmpDays.next()) { |
512 | tmpStr2.sprintf("%i ", *tmpDay); | 511 | tmpStr2.sprintf("%i ", *tmpDay); |
513 | tmpStr += tmpStr2; | 512 | tmpStr += tmpStr2; |
514 | } | 513 | } |
515 | break; | 514 | break; |
516 | case Recurrence::rYearlyMonth: | 515 | case Recurrence::rYearlyMonth: |
517 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); | 516 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); |
518 | // write out all the rYearNums; | 517 | // write out all the rYearNums; |
519 | tmpDays = anEvent->recurrence()->yearNums(); | 518 | tmpDays = anEvent->recurrence()->yearNums(); |
520 | for (tmpDay = tmpDays.first(); | 519 | for (tmpDay = tmpDays.first(); |
521 | tmpDay; | 520 | tmpDay; |
522 | tmpDay = tmpDays.next()) { | 521 | tmpDay = tmpDays.next()) { |
523 | tmpStr2.sprintf("%i ", *tmpDay); | 522 | tmpStr2.sprintf("%i ", *tmpDay); |
524 | tmpStr += tmpStr2; | 523 | tmpStr += tmpStr2; |
525 | } | 524 | } |
526 | break; | 525 | break; |
527 | case Recurrence::rYearlyDay: | 526 | case Recurrence::rYearlyDay: |
528 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); | 527 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); |
529 | // write out all the rYearNums; | 528 | // write out all the rYearNums; |
530 | tmpDays = anEvent->recurrence()->yearNums(); | 529 | tmpDays = anEvent->recurrence()->yearNums(); |
531 | for (tmpDay = tmpDays.first(); | 530 | for (tmpDay = tmpDays.first(); |
532 | tmpDay; | 531 | tmpDay; |
533 | tmpDay = tmpDays.next()) { | 532 | tmpDay = tmpDays.next()) { |
534 | tmpStr2.sprintf("%i ", *tmpDay); | 533 | tmpStr2.sprintf("%i ", *tmpDay); |
535 | tmpStr += tmpStr2; | 534 | tmpStr += tmpStr2; |
536 | } | 535 | } |
537 | break; | 536 | break; |
538 | default: | 537 | default: |
539 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; | 538 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; |
540 | break; | 539 | break; |
541 | } // switch | 540 | } // switch |
542 | 541 | ||
543 | if (anEvent->recurrence()->duration() > 0) { | 542 | if (anEvent->recurrence()->duration() > 0) { |
544 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); | 543 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); |
545 | tmpStr += tmpStr2; | 544 | tmpStr += tmpStr2; |
546 | } else if (anEvent->recurrence()->duration() == -1) { | 545 | } else if (anEvent->recurrence()->duration() == -1) { |
547 | tmpStr += "#0"; // defined as repeat forever | 546 | tmpStr += "#0"; // defined as repeat forever |
548 | } else { | 547 | } else { |
549 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); | 548 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); |
550 | } | 549 | } |
551 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); | 550 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); |
552 | 551 | ||
553 | } // event repeats | 552 | } // event repeats |
554 | 553 | ||
555 | // exceptions to recurrence | 554 | // exceptions to recurrence |
556 | DateList dateList = anEvent->exDates(); | 555 | DateList dateList = anEvent->exDates(); |
557 | DateList::ConstIterator it; | 556 | DateList::ConstIterator it; |
558 | QString tmpStr2; | 557 | QString tmpStr2; |
559 | 558 | ||
560 | for (it = dateList.begin(); it != dateList.end(); ++it) { | 559 | for (it = dateList.begin(); it != dateList.end(); ++it) { |
561 | tmpStr = qDateToISO(*it) + ";"; | 560 | tmpStr = qDateToISO(*it) + ";"; |
562 | tmpStr2 += tmpStr; | 561 | tmpStr2 += tmpStr; |
563 | } | 562 | } |
564 | if (!tmpStr2.isEmpty()) { | 563 | if (!tmpStr2.isEmpty()) { |
565 | tmpStr2.truncate(tmpStr2.length()-1); | 564 | tmpStr2.truncate(tmpStr2.length()-1); |
566 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); | 565 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); |
567 | } | 566 | } |
568 | 567 | ||
569 | // description | 568 | // description |
570 | if (!anEvent->description().isEmpty()) { | 569 | if (!anEvent->description().isEmpty()) { |
571 | VObject *d = addPropValue(vevent, VCDescriptionProp, | 570 | VObject *d = addPropValue(vevent, VCDescriptionProp, |
572 | anEvent->description().local8Bit()); | 571 | anEvent->description().local8Bit()); |
573 | if (anEvent->description().find('\n') != -1) | 572 | if (anEvent->description().find('\n') != -1) |
574 | addProp(d, VCQuotedPrintableProp); | 573 | addProp(d, VCQuotedPrintableProp); |
575 | } | 574 | } |
576 | 575 | ||
577 | // summary | 576 | // summary |
578 | if (!anEvent->summary().isEmpty()) | 577 | if (!anEvent->summary().isEmpty()) |
579 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); | 578 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); |
580 | 579 | ||
581 | if (!anEvent->location().isEmpty()) | 580 | if (!anEvent->location().isEmpty()) |
582 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); | 581 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); |
583 | 582 | ||
584 | // status | 583 | // status |
585 | // TODO: define Event status | 584 | // TODO: define Event status |
586 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); | 585 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); |
587 | 586 | ||
588 | // secrecy | 587 | // secrecy |
589 | const char *text = 0; | 588 | const char *text = 0; |
590 | switch (anEvent->secrecy()) { | 589 | switch (anEvent->secrecy()) { |
591 | case Incidence::SecrecyPublic: | 590 | case Incidence::SecrecyPublic: |
592 | text = "PUBLIC"; | 591 | text = "PUBLIC"; |
593 | break; | 592 | break; |
594 | case Incidence::SecrecyPrivate: | 593 | case Incidence::SecrecyPrivate: |
595 | text = "PRIVATE"; | 594 | text = "PRIVATE"; |
596 | break; | 595 | break; |
597 | case Incidence::SecrecyConfidential: | 596 | case Incidence::SecrecyConfidential: |
598 | text = "CONFIDENTIAL"; | 597 | text = "CONFIDENTIAL"; |
599 | break; | 598 | break; |
600 | } | 599 | } |
601 | if (text) { | 600 | if (text) { |
602 | addPropValue(vevent, VCClassProp, text); | 601 | addPropValue(vevent, VCClassProp, text); |
603 | } | 602 | } |
604 | 603 | ||
605 | // categories | 604 | // categories |
606 | tmpStrList = anEvent->categories(); | 605 | QStringList tmpStrList = anEvent->categories(); |
607 | tmpStr = ""; | 606 | tmpStr = ""; |
608 | QString catStr; | 607 | QString catStr; |
609 | for ( QStringList::Iterator it = tmpStrList.begin(); | 608 | for ( QStringList::Iterator it = tmpStrList.begin(); |
610 | it != tmpStrList.end(); | 609 | it != tmpStrList.end(); |
611 | ++it ) { | 610 | ++it ) { |
612 | catStr = *it; | 611 | catStr = *it; |
613 | if (catStr[0] == ' ') | 612 | if (catStr[0] == ' ') |
614 | tmpStr += catStr.mid(1); | 613 | tmpStr += catStr.mid(1); |
615 | else | 614 | else |
616 | tmpStr += catStr; | 615 | tmpStr += catStr; |
617 | // this must be a ';' character as the vCalendar specification requires! | 616 | // 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 | 617 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
619 | // read in. | 618 | // read in. |
620 | tmpStr += ";"; | 619 | tmpStr += ";"; |
621 | } | 620 | } |
622 | if (!tmpStr.isEmpty()) { | 621 | if (!tmpStr.isEmpty()) { |
623 | tmpStr.truncate(tmpStr.length()-1); | 622 | tmpStr.truncate(tmpStr.length()-1); |
624 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); | 623 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); |
625 | } | 624 | } |
626 | 625 | ||
627 | // attachments | 626 | // attachments |
628 | // TODO: handle binary attachments! | 627 | // TODO: handle binary attachments! |
629 | QPtrList<Attachment> attachments = anEvent->attachments(); | 628 | QPtrList<Attachment> attachments = anEvent->attachments(); |
630 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) | 629 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) |
631 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); | 630 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); |
632 | 631 | ||
633 | // resources | 632 | // resources |
634 | tmpStrList = anEvent->resources(); | 633 | tmpStrList = anEvent->resources(); |
635 | tmpStr = tmpStrList.join(";"); | 634 | tmpStr = tmpStrList.join(";"); |
636 | if (!tmpStr.isEmpty()) | 635 | if (!tmpStr.isEmpty()) |
637 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); | 636 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); |
638 | 637 | ||
639 | // alarm stuff | 638 | // alarm stuff |
640 | QPtrList<Alarm> alarms = anEvent->alarms(); | 639 | QPtrList<Alarm> alarms = anEvent->alarms(); |
641 | Alarm* alarm; | 640 | Alarm* alarm; |
642 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 641 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
643 | if (alarm->enabled()) { | 642 | if (alarm->enabled()) { |
644 | VObject *a ; | 643 | VObject *a ; |
645 | tmpStr = qDateTimeToISO(alarm->time()); | 644 | tmpStr = qDateTimeToISO(alarm->time()); |
646 | if (alarm->type() == Alarm::Audio) { | 645 | if (alarm->type() == Alarm::Audio) { |
647 | a = addProp(vevent, VCAAlarmProp); | 646 | a = addProp(vevent, VCAAlarmProp); |
648 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 647 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
649 | addPropValue(a, VCRepeatCountProp, "1"); | 648 | addPropValue(a, VCRepeatCountProp, "1"); |
650 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 649 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
651 | } | 650 | } |
652 | if (alarm->type() == Alarm::Procedure) { | 651 | if (alarm->type() == Alarm::Procedure) { |
653 | a = addProp(vevent, VCPAlarmProp); | 652 | a = addProp(vevent, VCPAlarmProp); |
654 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 653 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
655 | addPropValue(a, VCRepeatCountProp, "1"); | 654 | addPropValue(a, VCRepeatCountProp, "1"); |
656 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 655 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
657 | } else { | 656 | } else { |
658 | a = addProp(vevent, VCDAlarmProp); | 657 | a = addProp(vevent, VCDAlarmProp); |
659 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 658 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
660 | addPropValue(a, VCRepeatCountProp, "1"); | 659 | addPropValue(a, VCRepeatCountProp, "1"); |
661 | addPropValue(a, VCDisplayStringProp, "beep!"); | 660 | addPropValue(a, VCDisplayStringProp, "beep!"); |
662 | 661 | ||
663 | } | 662 | } |
664 | } | 663 | } |
665 | } | 664 | } |
666 | 665 | ||
667 | // priority | 666 | // priority |
668 | tmpStr.sprintf("%i",anEvent->priority()); | 667 | tmpStr.sprintf("%i",anEvent->priority()); |
669 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); | 668 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); |
670 | 669 | ||
671 | // transparency | 670 | // transparency |
672 | tmpStr.sprintf("%i",anEvent->transparency()); | 671 | tmpStr.sprintf("%i",anEvent->transparency()); |
673 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); | 672 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); |
674 | 673 | ||
675 | // related event | 674 | // related event |
676 | if (anEvent->relatedTo()) { | 675 | if (anEvent->relatedTo()) { |
677 | addPropValue(vevent, VCRelatedToProp, | 676 | addPropValue(vevent, VCRelatedToProp, |
678 | anEvent->relatedTo()->uid().local8Bit()); | 677 | anEvent->relatedTo()->uid().local8Bit()); |
679 | } | 678 | } |
680 | 679 | ||
681 | if (anEvent->pilotId()) { | 680 | if (anEvent->pilotId()) { |
682 | // pilot sync stuff | 681 | // pilot sync stuff |
683 | tmpStr.sprintf("%i",anEvent->pilotId()); | 682 | tmpStr.sprintf("%i",anEvent->pilotId()); |
684 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); | 683 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); |
685 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 684 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
686 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); | 685 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); |
687 | } | 686 | } |
688 | 687 | ||
689 | return vevent; | 688 | return vevent; |
690 | } | 689 | } |
691 | 690 | ||
692 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | 691 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) |
693 | { | 692 | { |
694 | VObject *vo; | 693 | VObject *vo; |
695 | VObjectIterator voi; | 694 | VObjectIterator voi; |
696 | char *s; | 695 | char *s; |
697 | 696 | ||
698 | Todo *anEvent = new Todo; | 697 | Todo *anEvent = new Todo; |
699 | 698 | ||
700 | // creation date | 699 | // creation date |
701 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { | 700 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { |
702 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 701 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
@@ -776,210 +775,197 @@ Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | |||
776 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 775 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
777 | deleteStr(s); | 776 | deleteStr(s); |
778 | } | 777 | } |
779 | 778 | ||
780 | // summary | 779 | // summary |
781 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { | 780 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { |
782 | s = fakeCString(vObjectUStringZValue(vo)); | 781 | s = fakeCString(vObjectUStringZValue(vo)); |
783 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 782 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
784 | deleteStr(s); | 783 | deleteStr(s); |
785 | } | 784 | } |
786 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { | 785 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { |
787 | s = fakeCString(vObjectUStringZValue(vo)); | 786 | s = fakeCString(vObjectUStringZValue(vo)); |
788 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 787 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
789 | deleteStr(s); | 788 | deleteStr(s); |
790 | } | 789 | } |
791 | 790 | ||
792 | 791 | ||
793 | // completed | 792 | // completed |
794 | // was: status | 793 | // was: status |
795 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { | 794 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { |
796 | s = fakeCString(vObjectUStringZValue(vo)); | 795 | s = fakeCString(vObjectUStringZValue(vo)); |
797 | if (strcmp(s,"COMPLETED") == 0) { | 796 | if (strcmp(s,"COMPLETED") == 0) { |
798 | anEvent->setCompleted(true); | 797 | anEvent->setCompleted(true); |
799 | } else { | 798 | } else { |
800 | anEvent->setCompleted(false); | 799 | anEvent->setCompleted(false); |
801 | } | 800 | } |
802 | deleteStr(s); | 801 | deleteStr(s); |
803 | } | 802 | } |
804 | else | 803 | else |
805 | anEvent->setCompleted(false); | 804 | anEvent->setCompleted(false); |
806 | 805 | ||
807 | // completion date | 806 | // completion date |
808 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { | 807 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { |
809 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 808 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
810 | deleteStr(s); | 809 | deleteStr(s); |
811 | } | 810 | } |
812 | 811 | ||
813 | // priority | 812 | // priority |
814 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { | 813 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { |
815 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 814 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
816 | deleteStr(s); | 815 | deleteStr(s); |
817 | } | 816 | } |
818 | 817 | ||
819 | // due date | 818 | // due date |
820 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { | 819 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { |
821 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 820 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
822 | deleteStr(s); | 821 | deleteStr(s); |
823 | anEvent->setHasDueDate(true); | 822 | anEvent->setHasDueDate(true); |
824 | } else { | 823 | } else { |
825 | anEvent->setHasDueDate(false); | 824 | anEvent->setHasDueDate(false); |
826 | } | 825 | } |
827 | 826 | ||
828 | // start time | 827 | // start time |
829 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { | 828 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { |
830 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 829 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
831 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 830 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
832 | deleteStr(s); | 831 | deleteStr(s); |
833 | anEvent->setHasStartDate(true); | 832 | anEvent->setHasStartDate(true); |
834 | } else { | 833 | } else { |
835 | anEvent->setHasStartDate(false); | 834 | anEvent->setHasStartDate(false); |
836 | } | 835 | } |
837 | 836 | ||
838 | /* alarm stuff */ | 837 | /* alarm stuff */ |
839 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; | 838 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; |
840 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { | 839 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { |
841 | Alarm* alarm = anEvent->newAlarm(); | 840 | Alarm* alarm = anEvent->newAlarm(); |
842 | VObject *a; | 841 | VObject *a; |
843 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 842 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
844 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 843 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
845 | deleteStr(s); | 844 | deleteStr(s); |
846 | } | 845 | } |
847 | alarm->setEnabled(true); | 846 | alarm->setEnabled(true); |
848 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { | 847 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { |
849 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 848 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
850 | s = fakeCString(vObjectUStringZValue(a)); | 849 | s = fakeCString(vObjectUStringZValue(a)); |
851 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 850 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
852 | deleteStr(s); | 851 | deleteStr(s); |
853 | } | 852 | } |
854 | } | 853 | } |
855 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { | 854 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { |
856 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 855 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
857 | s = fakeCString(vObjectUStringZValue(a)); | 856 | s = fakeCString(vObjectUStringZValue(a)); |
858 | alarm->setAudioAlarm(QFile::decodeName(s)); | 857 | alarm->setAudioAlarm(QFile::decodeName(s)); |
859 | deleteStr(s); | 858 | deleteStr(s); |
860 | } | 859 | } |
861 | } | 860 | } |
862 | } | 861 | } |
863 | 862 | ||
864 | // related todo | 863 | // related todo |
865 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { | 864 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { |
866 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 865 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
867 | deleteStr(s); | 866 | deleteStr(s); |
868 | mTodosRelate.append(anEvent); | 867 | mTodosRelate.append(anEvent); |
869 | } | 868 | } |
870 | 869 | ||
871 | // categories | 870 | // categories |
872 | QStringList tmpStrList; | ||
873 | int index1 = 0; | ||
874 | int index2 = 0; | ||
875 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { | 871 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { |
876 | s = fakeCString(vObjectUStringZValue(vo)); | 872 | s = fakeCString(vObjectUStringZValue(vo)); |
877 | QString categories = QString::fromLocal8Bit(s); | 873 | QString categories = QString::fromLocal8Bit(s); |
878 | deleteStr(s); | 874 | deleteStr(s); |
879 | //const char* category; | 875 | QStringList tmpStrList = QStringList::split( ';', categories ); |
880 | QString category; | ||
881 | while ((index2 = categories.find(',', index1)) != -1) { | ||
882 | //category = (const char *) categories.mid(index1, (index2 - index1)); | ||
883 | category = categories.mid(index1, (index2 - index1)); | ||
884 | tmpStrList.append(category); | ||
885 | index1 = index2+1; | ||
886 | } | ||
887 | // get last category | ||
888 | category = categories.mid(index1, (categories.length()-index1)); | ||
889 | tmpStrList.append(category); | ||
890 | anEvent->setCategories(tmpStrList); | 876 | anEvent->setCategories(tmpStrList); |
891 | } | 877 | } |
892 | 878 | ||
893 | /* PILOT SYNC STUFF */ | 879 | /* PILOT SYNC STUFF */ |
894 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { | 880 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { |
895 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 881 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
896 | deleteStr(s); | 882 | deleteStr(s); |
897 | } | 883 | } |
898 | else | 884 | else |
899 | anEvent->setPilotId(0); | 885 | anEvent->setPilotId(0); |
900 | 886 | ||
901 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { | 887 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { |
902 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 888 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
903 | deleteStr(s); | 889 | deleteStr(s); |
904 | } | 890 | } |
905 | else | 891 | else |
906 | anEvent->setSyncStatus(Event::SYNCMOD); | 892 | anEvent->setSyncStatus(Event::SYNCMOD); |
907 | 893 | ||
908 | return anEvent; | 894 | return anEvent; |
909 | } | 895 | } |
910 | 896 | ||
911 | Event* VCalFormat::VEventToEvent(VObject *vevent) | 897 | Event* VCalFormat::VEventToEvent(VObject *vevent) |
912 | { | 898 | { |
913 | VObject *vo; | 899 | VObject *vo; |
914 | VObjectIterator voi; | 900 | VObjectIterator voi; |
915 | char *s; | 901 | char *s; |
916 | 902 | ||
917 | Event *anEvent = new Event; | 903 | Event *anEvent = new Event; |
918 | 904 | ||
919 | // creation date | 905 | // creation date |
920 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { | 906 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { |
921 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 907 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
922 | deleteStr(s); | 908 | deleteStr(s); |
923 | } | 909 | } |
924 | 910 | ||
925 | // unique id | 911 | // unique id |
926 | vo = isAPropertyOf(vevent, VCUniqueStringProp); | 912 | vo = isAPropertyOf(vevent, VCUniqueStringProp); |
927 | // while the UID property is preferred, it is not required. We'll use the | 913 | // while the UID property is preferred, it is not required. We'll use the |
928 | // default Event UID if none is given. | 914 | // default Event UID if none is given. |
929 | if (vo) { | 915 | if (vo) { |
930 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 916 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
931 | deleteStr(s); | 917 | deleteStr(s); |
932 | } | 918 | } |
933 | 919 | ||
934 | // revision | 920 | // revision |
935 | // again NSCAL doesn't give us much to work with, so we improvise... | 921 | // again NSCAL doesn't give us much to work with, so we improvise... |
936 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { | 922 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { |
937 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 923 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
938 | deleteStr(s); | 924 | deleteStr(s); |
939 | } | 925 | } |
940 | else | 926 | else |
941 | anEvent->setRevision(0); | 927 | anEvent->setRevision(0); |
942 | 928 | ||
943 | // last modification date | 929 | // last modification date |
944 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { | 930 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { |
945 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 931 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
946 | deleteStr(s); | 932 | deleteStr(s); |
947 | } | 933 | } |
948 | else | 934 | else |
949 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 935 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
950 | QTime::currentTime())); | 936 | QTime::currentTime())); |
951 | 937 | ||
952 | // organizer | 938 | // organizer |
953 | // if our extension property for the event's ORGANIZER exists, add it. | 939 | // if our extension property for the event's ORGANIZER exists, add it. |
954 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { | 940 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { |
955 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 941 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
956 | deleteStr(s); | 942 | deleteStr(s); |
957 | } else { | 943 | } else { |
958 | anEvent->setOrganizer(mCalendar->getEmail()); | 944 | anEvent->setOrganizer(mCalendar->getEmail()); |
959 | } | 945 | } |
960 | 946 | ||
961 | // deal with attendees. | 947 | // deal with attendees. |
962 | initPropIterator(&voi, vevent); | 948 | initPropIterator(&voi, vevent); |
963 | while (moreIteration(&voi)) { | 949 | while (moreIteration(&voi)) { |
964 | vo = nextVObject(&voi); | 950 | vo = nextVObject(&voi); |
965 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 951 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
966 | Attendee *a; | 952 | Attendee *a; |
967 | VObject *vp; | 953 | VObject *vp; |
968 | s = fakeCString(vObjectUStringZValue(vo)); | 954 | s = fakeCString(vObjectUStringZValue(vo)); |
969 | QString tmpStr = QString::fromLocal8Bit(s); | 955 | QString tmpStr = QString::fromLocal8Bit(s); |
970 | deleteStr(s); | 956 | deleteStr(s); |
971 | tmpStr = tmpStr.simplifyWhiteSpace(); | 957 | tmpStr = tmpStr.simplifyWhiteSpace(); |
972 | int emailPos1, emailPos2; | 958 | int emailPos1, emailPos2; |
973 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 959 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
974 | // both email address and name | 960 | // both email address and name |
975 | emailPos2 = tmpStr.findRev('>'); | 961 | emailPos2 = tmpStr.findRev('>'); |
976 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 962 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
977 | tmpStr.mid(emailPos1 + 1, | 963 | tmpStr.mid(emailPos1 + 1, |
978 | emailPos2 - (emailPos1 + 1))); | 964 | emailPos2 - (emailPos1 + 1))); |
979 | } else if (tmpStr.find('@') > 0) { | 965 | } else if (tmpStr.find('@') > 0) { |
980 | // just an email address | 966 | // just an email address |
981 | a = new Attendee(0, tmpStr); | 967 | a = new Attendee(0, tmpStr); |
982 | } else { | 968 | } else { |
983 | // just a name | 969 | // just a name |
984 | //QString email = tmpStr.replace( QRegExp(" "), "." ); | 970 | //QString email = tmpStr.replace( QRegExp(" "), "." ); |
985 | a = new Attendee(tmpStr,0); | 971 | a = new Attendee(tmpStr,0); |
@@ -1235,240 +1221,218 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) | |||
1235 | // e.g. YD1 123 #0 | 1221 | // e.g. YD1 123 #0 |
1236 | while (index < last) { | 1222 | while (index < last) { |
1237 | int index2 = tmpStr.find(' ', index); | 1223 | int index2 = tmpStr.find(' ', index); |
1238 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1224 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1239 | index = index2+1; | 1225 | index = index2+1; |
1240 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1226 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1241 | } // while != # | 1227 | } // while != # |
1242 | } | 1228 | } |
1243 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1229 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1244 | if (tmpStr.find('T', index) != -1) { | 1230 | if (tmpStr.find('T', index) != -1) { |
1245 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1231 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1246 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); | 1232 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); |
1247 | } else { | 1233 | } else { |
1248 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1234 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1249 | if (rDuration == 0) | 1235 | if (rDuration == 0) |
1250 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); | 1236 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); |
1251 | else | 1237 | else |
1252 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); | 1238 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); |
1253 | } | 1239 | } |
1254 | } else { | 1240 | } else { |
1255 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; | 1241 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; |
1256 | } // if | 1242 | } // if |
1257 | } // repeats | 1243 | } // repeats |
1258 | 1244 | ||
1259 | 1245 | ||
1260 | // recurrence exceptions | 1246 | // recurrence exceptions |
1261 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { | 1247 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { |
1262 | s = fakeCString(vObjectUStringZValue(vo)); | 1248 | s = fakeCString(vObjectUStringZValue(vo)); |
1263 | QStringList exDates = QStringList::split(",",s); | 1249 | QStringList exDates = QStringList::split(",",s); |
1264 | QStringList::ConstIterator it; | 1250 | QStringList::ConstIterator it; |
1265 | for(it = exDates.begin(); it != exDates.end(); ++it ) { | 1251 | for(it = exDates.begin(); it != exDates.end(); ++it ) { |
1266 | anEvent->addExDate(ISOToQDate(*it)); | 1252 | anEvent->addExDate(ISOToQDate(*it)); |
1267 | } | 1253 | } |
1268 | deleteStr(s); | 1254 | deleteStr(s); |
1269 | } | 1255 | } |
1270 | 1256 | ||
1271 | // summary | 1257 | // summary |
1272 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { | 1258 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { |
1273 | s = fakeCString(vObjectUStringZValue(vo)); | 1259 | s = fakeCString(vObjectUStringZValue(vo)); |
1274 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 1260 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
1275 | deleteStr(s); | 1261 | deleteStr(s); |
1276 | } | 1262 | } |
1277 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { | 1263 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { |
1278 | s = fakeCString(vObjectUStringZValue(vo)); | 1264 | s = fakeCString(vObjectUStringZValue(vo)); |
1279 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 1265 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
1280 | deleteStr(s); | 1266 | deleteStr(s); |
1281 | } | 1267 | } |
1282 | 1268 | ||
1283 | // description | 1269 | // description |
1284 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { | 1270 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { |
1285 | s = fakeCString(vObjectUStringZValue(vo)); | 1271 | s = fakeCString(vObjectUStringZValue(vo)); |
1286 | if (!anEvent->description().isEmpty()) { | 1272 | if (!anEvent->description().isEmpty()) { |
1287 | anEvent->setDescription(anEvent->description() + "\n" + | 1273 | anEvent->setDescription(anEvent->description() + "\n" + |
1288 | QString::fromLocal8Bit(s)); | 1274 | QString::fromLocal8Bit(s)); |
1289 | } else { | 1275 | } else { |
1290 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 1276 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
1291 | } | 1277 | } |
1292 | deleteStr(s); | 1278 | deleteStr(s); |
1293 | } | 1279 | } |
1294 | 1280 | ||
1295 | // some stupid vCal exporters ignore the standard and use Description | 1281 | // some stupid vCal exporters ignore the standard and use Description |
1296 | // instead of Summary for the default field. Correct for this. | 1282 | // instead of Summary for the default field. Correct for this. |
1297 | if (anEvent->summary().isEmpty() && | 1283 | if (anEvent->summary().isEmpty() && |
1298 | !(anEvent->description().isEmpty())) { | 1284 | !(anEvent->description().isEmpty())) { |
1299 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); | 1285 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); |
1300 | anEvent->setDescription(""); | 1286 | anEvent->setDescription(""); |
1301 | anEvent->setSummary(tmpStr); | 1287 | anEvent->setSummary(tmpStr); |
1302 | } | 1288 | } |
1303 | 1289 | ||
1304 | #if 0 | 1290 | #if 0 |
1305 | // status | 1291 | // status |
1306 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { | 1292 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { |
1307 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); | 1293 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); |
1308 | deleteStr(s); | 1294 | deleteStr(s); |
1309 | // TODO: Define Event status | 1295 | // TODO: Define Event status |
1310 | // anEvent->setStatus(tmpStr); | 1296 | // anEvent->setStatus(tmpStr); |
1311 | } | 1297 | } |
1312 | else | 1298 | else |
1313 | // anEvent->setStatus("NEEDS ACTION"); | 1299 | // anEvent->setStatus("NEEDS ACTION"); |
1314 | #endif | 1300 | #endif |
1315 | 1301 | ||
1316 | // secrecy | 1302 | // secrecy |
1317 | int secrecy = Incidence::SecrecyPublic; | 1303 | int secrecy = Incidence::SecrecyPublic; |
1318 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { | 1304 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { |
1319 | s = fakeCString(vObjectUStringZValue(vo)); | 1305 | s = fakeCString(vObjectUStringZValue(vo)); |
1320 | if (strcmp(s,"PRIVATE") == 0) { | 1306 | if (strcmp(s,"PRIVATE") == 0) { |
1321 | secrecy = Incidence::SecrecyPrivate; | 1307 | secrecy = Incidence::SecrecyPrivate; |
1322 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { | 1308 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { |
1323 | secrecy = Incidence::SecrecyConfidential; | 1309 | secrecy = Incidence::SecrecyConfidential; |
1324 | } | 1310 | } |
1325 | deleteStr(s); | 1311 | deleteStr(s); |
1326 | } | 1312 | } |
1327 | anEvent->setSecrecy(secrecy); | 1313 | anEvent->setSecrecy(secrecy); |
1328 | 1314 | ||
1329 | // categories | 1315 | // categories |
1330 | QStringList tmpStrList; | 1316 | QStringList tmpStrList; |
1331 | int index1 = 0; | ||
1332 | int index2 = 0; | ||
1333 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { | 1317 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { |
1334 | s = fakeCString(vObjectUStringZValue(vo)); | 1318 | s = fakeCString(vObjectUStringZValue(vo)); |
1335 | QString categories = QString::fromLocal8Bit(s); | 1319 | QString categories = QString::fromLocal8Bit(s); |
1336 | deleteStr(s); | 1320 | deleteStr(s); |
1337 | //const char* category; | 1321 | tmpStrList = QStringList::split( ';', categories ); |
1338 | QString category; | ||
1339 | while ((index2 = categories.find(',', index1)) != -1) { | ||
1340 | //category = (const char *) categories.mid(index1, (index2 - index1)); | ||
1341 | category = categories.mid(index1, (index2 - index1)); | ||
1342 | tmpStrList.append(category); | ||
1343 | index1 = index2+1; | ||
1344 | } | ||
1345 | // get last category | ||
1346 | category = categories.mid(index1, (categories.length()-index1)); | ||
1347 | tmpStrList.append(category); | ||
1348 | anEvent->setCategories(tmpStrList); | 1322 | anEvent->setCategories(tmpStrList); |
1349 | } | 1323 | } |
1350 | 1324 | ||
1351 | // attachments | 1325 | // attachments |
1352 | tmpStrList.clear(); | ||
1353 | initPropIterator(&voi, vevent); | 1326 | initPropIterator(&voi, vevent); |
1354 | while (moreIteration(&voi)) { | 1327 | while (moreIteration(&voi)) { |
1355 | vo = nextVObject(&voi); | 1328 | vo = nextVObject(&voi); |
1356 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { | 1329 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { |
1357 | s = fakeCString(vObjectUStringZValue(vo)); | 1330 | s = fakeCString(vObjectUStringZValue(vo)); |
1358 | anEvent->addAttachment(new Attachment(QString(s))); | 1331 | anEvent->addAttachment(new Attachment(QString(s))); |
1359 | deleteStr(s); | 1332 | deleteStr(s); |
1360 | } | 1333 | } |
1361 | } | 1334 | } |
1362 | 1335 | ||
1363 | // resources | 1336 | // resources |
1364 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 1337 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
1365 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 1338 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
1366 | deleteStr(s); | 1339 | deleteStr(s); |
1367 | tmpStrList.clear(); | 1340 | tmpStrList = QStringList::split( ';', resources ); |
1368 | index1 = 0; | ||
1369 | index2 = 0; | ||
1370 | QString resource; | ||
1371 | while ((index2 = resources.find(';', index1)) != -1) { | ||
1372 | resource = resources.mid(index1, (index2 - index1)); | ||
1373 | tmpStrList.append(resource); | ||
1374 | index1 = index2; | ||
1375 | } | ||
1376 | anEvent->setResources(tmpStrList); | 1341 | anEvent->setResources(tmpStrList); |
1377 | } | 1342 | } |
1378 | |||
1379 | /* alarm stuff */ | 1343 | /* alarm stuff */ |
1380 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { | 1344 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { |
1381 | Alarm* alarm = anEvent->newAlarm(); | 1345 | Alarm* alarm = anEvent->newAlarm(); |
1382 | VObject *a; | 1346 | VObject *a; |
1383 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 1347 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
1384 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 1348 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
1385 | deleteStr(s); | 1349 | deleteStr(s); |
1386 | } | 1350 | } |
1387 | alarm->setEnabled(true); | 1351 | alarm->setEnabled(true); |
1388 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { | 1352 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { |
1389 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 1353 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
1390 | s = fakeCString(vObjectUStringZValue(a)); | 1354 | s = fakeCString(vObjectUStringZValue(a)); |
1391 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 1355 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
1392 | deleteStr(s); | 1356 | deleteStr(s); |
1393 | } | 1357 | } |
1394 | } | 1358 | } |
1395 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { | 1359 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { |
1396 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 1360 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
1397 | s = fakeCString(vObjectUStringZValue(a)); | 1361 | s = fakeCString(vObjectUStringZValue(a)); |
1398 | alarm->setAudioAlarm(QFile::decodeName(s)); | 1362 | alarm->setAudioAlarm(QFile::decodeName(s)); |
1399 | deleteStr(s); | 1363 | deleteStr(s); |
1400 | } | 1364 | } |
1401 | } | 1365 | } |
1402 | } | 1366 | } |
1403 | 1367 | ||
1404 | // priority | 1368 | // priority |
1405 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { | 1369 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { |
1406 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1370 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1407 | deleteStr(s); | 1371 | deleteStr(s); |
1408 | } | 1372 | } |
1409 | 1373 | ||
1410 | // transparency | 1374 | // transparency |
1411 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { | 1375 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { |
1412 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); | 1376 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); |
1413 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); | 1377 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); |
1414 | deleteStr(s); | 1378 | deleteStr(s); |
1415 | } | 1379 | } |
1416 | 1380 | ||
1417 | // related event | 1381 | // related event |
1418 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { | 1382 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { |
1419 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 1383 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
1420 | deleteStr(s); | 1384 | deleteStr(s); |
1421 | mEventsRelate.append(anEvent); | 1385 | mEventsRelate.append(anEvent); |
1422 | } | 1386 | } |
1423 | 1387 | ||
1424 | /* PILOT SYNC STUFF */ | 1388 | /* PILOT SYNC STUFF */ |
1425 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { | 1389 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { |
1426 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1390 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1427 | deleteStr(s); | 1391 | deleteStr(s); |
1428 | } | 1392 | } |
1429 | else | 1393 | else |
1430 | anEvent->setPilotId(0); | 1394 | anEvent->setPilotId(0); |
1431 | 1395 | ||
1432 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { | 1396 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { |
1433 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1397 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1434 | deleteStr(s); | 1398 | deleteStr(s); |
1435 | } | 1399 | } |
1436 | else | 1400 | else |
1437 | anEvent->setSyncStatus(Event::SYNCMOD); | 1401 | anEvent->setSyncStatus(Event::SYNCMOD); |
1438 | 1402 | ||
1439 | return anEvent; | 1403 | return anEvent; |
1440 | } | 1404 | } |
1441 | 1405 | ||
1442 | 1406 | ||
1443 | QString VCalFormat::qDateToISO(const QDate &qd) | 1407 | QString VCalFormat::qDateToISO(const QDate &qd) |
1444 | { | 1408 | { |
1445 | QString tmpStr; | 1409 | QString tmpStr; |
1446 | 1410 | ||
1447 | ASSERT(qd.isValid()); | 1411 | ASSERT(qd.isValid()); |
1448 | 1412 | ||
1449 | tmpStr.sprintf("%.2d%.2d%.2d", | 1413 | tmpStr.sprintf("%.2d%.2d%.2d", |
1450 | qd.year(), qd.month(), qd.day()); | 1414 | qd.year(), qd.month(), qd.day()); |
1451 | return tmpStr; | 1415 | return tmpStr; |
1452 | 1416 | ||
1453 | } | 1417 | } |
1454 | 1418 | ||
1455 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1419 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) |
1456 | { | 1420 | { |
1457 | QString tmpStr; | 1421 | QString tmpStr; |
1458 | 1422 | ||
1459 | ASSERT(qdt.date().isValid()); | 1423 | ASSERT(qdt.date().isValid()); |
1460 | ASSERT(qdt.time().isValid()); | 1424 | ASSERT(qdt.time().isValid()); |
1461 | if (zulu && !useLocalTime ) { | 1425 | if (zulu && !useLocalTime ) { |
1462 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); | 1426 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); |
1463 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", | 1427 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", |
1464 | tmpDT.date().year(), tmpDT.date().month(), | 1428 | tmpDT.date().year(), tmpDT.date().month(), |
1465 | tmpDT.date().day(), tmpDT.time().hour(), | 1429 | tmpDT.date().day(), tmpDT.time().hour(), |
1466 | tmpDT.time().minute(), tmpDT.time().second()); | 1430 | tmpDT.time().minute(), tmpDT.time().second()); |
1467 | } else { | 1431 | } else { |
1468 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", | 1432 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", |
1469 | qdt.date().year(), qdt.date().month(), | 1433 | qdt.date().year(), qdt.date().month(), |
1470 | qdt.date().day(), qdt.time().hour(), | 1434 | qdt.date().day(), qdt.time().hour(), |
1471 | qdt.time().minute(), qdt.time().second()); | 1435 | qdt.time().minute(), qdt.time().second()); |
1472 | } | 1436 | } |
1473 | return tmpStr; | 1437 | return tmpStr; |
1474 | } | 1438 | } |