-rw-r--r-- | libkcal/vcalformat.cpp | 39 | ||||
-rw-r--r-- | libkcal/vcalformat.h | 3 | ||||
-rw-r--r-- | libkcal/versit/vcc.c | 3 |
3 files changed, 37 insertions, 8 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index df93209..223aa5a 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -228,128 +228,129 @@ QString VCalFormat::toString( Calendar *calendar ) | |||
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 | QStringList tmpStrList; |
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, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 293 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
293 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 294 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
294 | } | 295 | } |
295 | } | 296 | } |
296 | 297 | ||
297 | // description BL: | 298 | // description BL: |
298 | if (!anEvent->description().isEmpty()) { | 299 | if (!anEvent->description().isEmpty()) { |
299 | VObject *d = addPropValue(vtodo, VCDescriptionProp, | 300 | VObject *d = addPropValue(vtodo, VCDescriptionProp, |
300 | anEvent->description().local8Bit()); | 301 | anEvent->description().local8Bit()); |
301 | if (anEvent->description().find('\n') != -1) | 302 | if (anEvent->description().find('\n') != -1) |
302 | addProp(d, VCQuotedPrintableProp); | 303 | addProp(d, VCQuotedPrintableProp); |
303 | } | 304 | } |
304 | 305 | ||
305 | // summary | 306 | // summary |
306 | if (!anEvent->summary().isEmpty()) | 307 | if (!anEvent->summary().isEmpty()) |
307 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); | 308 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); |
308 | 309 | ||
309 | if (!anEvent->location().isEmpty()) | 310 | if (!anEvent->location().isEmpty()) |
310 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); | 311 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); |
311 | 312 | ||
312 | // completed | 313 | // completed |
313 | // status | 314 | // status |
314 | // backward compatibility, KOrganizer used to interpret only these two values | 315 | // backward compatibility, KOrganizer used to interpret only these two values |
315 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : | 316 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : |
316 | "NEEDS_ACTION"); | 317 | "NEEDS_ACTION"); |
317 | // completion date | 318 | // completion date |
318 | if (anEvent->hasCompletedDate()) { | 319 | if (anEvent->hasCompletedDate()) { |
319 | tmpStr = qDateTimeToISO(anEvent->completed()); | 320 | tmpStr = qDateTimeToISO(anEvent->completed()); |
320 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); | 321 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); |
321 | } | 322 | } |
322 | 323 | ||
323 | // priority | 324 | // priority |
324 | tmpStr.sprintf("%i",anEvent->priority()); | 325 | tmpStr.sprintf("%i",anEvent->priority()); |
325 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); | 326 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); |
326 | 327 | ||
327 | // related event | 328 | // related event |
328 | if (anEvent->relatedTo()) { | 329 | if (anEvent->relatedTo()) { |
329 | addPropValue(vtodo, VCRelatedToProp, | 330 | addPropValue(vtodo, VCRelatedToProp, |
330 | anEvent->relatedTo()->uid().local8Bit()); | 331 | anEvent->relatedTo()->uid().local8Bit()); |
331 | } | 332 | } |
332 | 333 | ||
333 | // categories | 334 | // categories |
334 | tmpStrList = anEvent->categories(); | 335 | tmpStrList = anEvent->categories(); |
335 | tmpStr = ""; | 336 | tmpStr = ""; |
336 | QString catStr; | 337 | QString catStr; |
337 | for ( QStringList::Iterator it = tmpStrList.begin(); | 338 | for ( QStringList::Iterator it = tmpStrList.begin(); |
338 | it != tmpStrList.end(); | 339 | it != tmpStrList.end(); |
339 | ++it ) { | 340 | ++it ) { |
340 | catStr = *it; | 341 | catStr = *it; |
341 | if (catStr[0] == ' ') | 342 | if (catStr[0] == ' ') |
342 | tmpStr += catStr.mid(1); | 343 | tmpStr += catStr.mid(1); |
343 | else | 344 | else |
344 | tmpStr += catStr; | 345 | tmpStr += catStr; |
345 | // this must be a ';' character as the vCalendar specification requires! | 346 | // this must be a ';' character as the vCalendar specification requires! |
346 | // 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 |
347 | // read in. | 348 | // read in. |
348 | tmpStr += ";"; | 349 | tmpStr += ";"; |
349 | } | 350 | } |
350 | if (!tmpStr.isEmpty()) { | 351 | if (!tmpStr.isEmpty()) { |
351 | tmpStr.truncate(tmpStr.length()-1); | 352 | tmpStr.truncate(tmpStr.length()-1); |
352 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); | 353 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); |
353 | } | 354 | } |
354 | 355 | ||
355 | // alarm stuff | 356 | // alarm stuff |
@@ -391,129 +392,130 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | |||
391 | return vtodo; | 392 | return vtodo; |
392 | } | 393 | } |
393 | 394 | ||
394 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 395 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) |
395 | { | 396 | { |
396 | VObject *vevent; | 397 | VObject *vevent; |
397 | QString tmpStr; | 398 | QString tmpStr; |
398 | QStringList tmpStrList; | 399 | QStringList tmpStrList; |
399 | 400 | ||
400 | vevent = newVObject(VCEventProp); | 401 | vevent = newVObject(VCEventProp); |
401 | 402 | ||
402 | // start and end time | 403 | // start and end time |
403 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 404 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
404 | !anEvent->doesFloat()); | 405 | !anEvent->doesFloat()); |
405 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 406 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
406 | 407 | ||
407 | // events that have time associated but take up no time should | 408 | // events that have time associated but take up no time should |
408 | // not have both DTSTART and DTEND. | 409 | // not have both DTSTART and DTEND. |
409 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 410 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
410 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 411 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
411 | !anEvent->doesFloat()); | 412 | !anEvent->doesFloat()); |
412 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); | 413 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); |
413 | } | 414 | } |
414 | 415 | ||
415 | // creation date | 416 | // creation date |
416 | tmpStr = qDateTimeToISO(anEvent->created()); | 417 | tmpStr = qDateTimeToISO(anEvent->created()); |
417 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); | 418 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); |
418 | 419 | ||
419 | // unique id | 420 | // unique id |
420 | addPropValue(vevent, VCUniqueStringProp, | 421 | addPropValue(vevent, VCUniqueStringProp, |
421 | anEvent->uid().local8Bit()); | 422 | anEvent->uid().local8Bit()); |
422 | 423 | ||
423 | // revision | 424 | // revision |
424 | tmpStr.sprintf("%i", anEvent->revision()); | 425 | tmpStr.sprintf("%i", anEvent->revision()); |
425 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); | 426 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); |
426 | 427 | ||
427 | // last modification date | 428 | // last modification date |
428 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 429 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
429 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); | 430 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); |
430 | 431 | ||
431 | // attendee and organizer stuff | 432 | // attendee and organizer stuff |
432 | tmpStr = "MAILTO:" + anEvent->organizer(); | 433 | tmpStr = "MAILTO:" + anEvent->organizer(); |
433 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); | 434 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); |
434 | 435 | ||
435 | if (anEvent->attendeeCount() != 0) { | 436 | if (anEvent->attendeeCount() != 0) { |
436 | QPtrList<Attendee> al = anEvent->attendees(); | 437 | QPtrList<Attendee> al = anEvent->attendees(); |
437 | QPtrListIterator<Attendee> ai(al); | 438 | QPtrListIterator<Attendee> ai(al); |
438 | Attendee *curAttendee; | 439 | Attendee *curAttendee; |
439 | 440 | ||
440 | // TODO: Put this functionality into Attendee class | 441 | // TODO: Put this functionality into Attendee class |
441 | for (; ai.current(); ++ai) { | 442 | for (; ai.current(); ++ai) { |
442 | curAttendee = ai.current(); | 443 | curAttendee = ai.current(); |
443 | if (!curAttendee->email().isEmpty() && | 444 | if (!curAttendee->email().isEmpty() && |
444 | !curAttendee->name().isEmpty()) | 445 | !curAttendee->name().isEmpty()) |
445 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 446 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
446 | curAttendee->email() + ">"; | 447 | curAttendee->email() + ">"; |
447 | else if (curAttendee->name().isEmpty()) | 448 | else if (curAttendee->name().isEmpty()) |
448 | tmpStr = "MAILTO: " + curAttendee->email(); | 449 | tmpStr = "MAILTO: " + curAttendee->email(); |
449 | else if (curAttendee->email().isEmpty()) | 450 | else if (curAttendee->email().isEmpty()) |
450 | tmpStr = "MAILTO: " + curAttendee->name(); | 451 | tmpStr = "MAILTO: " + curAttendee->name(); |
451 | else if (curAttendee->name().isEmpty() && | 452 | else if (curAttendee->name().isEmpty() && |
452 | curAttendee->email().isEmpty()) | 453 | curAttendee->email().isEmpty()) |
453 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 454 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
454 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); | 455 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); |
455 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; | 456 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); |
457 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | ||
456 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 458 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
457 | } | 459 | } |
458 | } | 460 | } |
459 | 461 | ||
460 | // recurrence rule stuff | 462 | // recurrence rule stuff |
461 | if (anEvent->recurrence()->doesRecur()) { | 463 | if (anEvent->recurrence()->doesRecur()) { |
462 | // some more variables | 464 | // some more variables |
463 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 465 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
464 | QPtrList<int> tmpDays; | 466 | QPtrList<int> tmpDays; |
465 | int *tmpDay; | 467 | int *tmpDay; |
466 | Recurrence::rMonthPos *tmpPos; | 468 | Recurrence::rMonthPos *tmpPos; |
467 | QString tmpStr2; | 469 | QString tmpStr2; |
468 | int i; | 470 | int i; |
469 | 471 | ||
470 | switch(anEvent->recurrence()->doesRecur()) { | 472 | switch(anEvent->recurrence()->doesRecur()) { |
471 | case Recurrence::rDaily: | 473 | case Recurrence::rDaily: |
472 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); | 474 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); |
473 | // if (anEvent->rDuration > 0) | 475 | // if (anEvent->rDuration > 0) |
474 | //tmpStr += "#"; | 476 | //tmpStr += "#"; |
475 | break; | 477 | break; |
476 | case Recurrence::rWeekly: | 478 | case Recurrence::rWeekly: |
477 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); | 479 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); |
478 | for (i = 0; i < 7; i++) { | 480 | for (i = 0; i < 7; i++) { |
479 | if (anEvent->recurrence()->days().testBit(i)) | 481 | if (anEvent->recurrence()->days().testBit(i)) |
480 | tmpStr += dayFromNum(i); | 482 | tmpStr += dayFromNum(i); |
481 | } | 483 | } |
482 | break; | 484 | break; |
483 | case Recurrence::rMonthlyPos: | 485 | case Recurrence::rMonthlyPos: |
484 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); | 486 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); |
485 | // write out all rMonthPos's | 487 | // write out all rMonthPos's |
486 | tmpPositions = anEvent->recurrence()->monthPositions(); | 488 | tmpPositions = anEvent->recurrence()->monthPositions(); |
487 | for (tmpPos = tmpPositions.first(); | 489 | for (tmpPos = tmpPositions.first(); |
488 | tmpPos; | 490 | tmpPos; |
489 | tmpPos = tmpPositions.next()) { | 491 | tmpPos = tmpPositions.next()) { |
490 | 492 | ||
491 | tmpStr2.sprintf("%i", tmpPos->rPos); | 493 | tmpStr2.sprintf("%i", tmpPos->rPos); |
492 | if (tmpPos->negative) | 494 | if (tmpPos->negative) |
493 | tmpStr2 += "- "; | 495 | tmpStr2 += "- "; |
494 | else | 496 | else |
495 | tmpStr2 += "+ "; | 497 | tmpStr2 += "+ "; |
496 | tmpStr += tmpStr2; | 498 | tmpStr += tmpStr2; |
497 | for (i = 0; i < 7; i++) { | 499 | for (i = 0; i < 7; i++) { |
498 | if (tmpPos->rDays.testBit(i)) | 500 | if (tmpPos->rDays.testBit(i)) |
499 | tmpStr += dayFromNum(i); | 501 | tmpStr += dayFromNum(i); |
500 | } | 502 | } |
501 | } // loop for all rMonthPos's | 503 | } // loop for all rMonthPos's |
502 | break; | 504 | break; |
503 | case Recurrence::rMonthlyDay: | 505 | case Recurrence::rMonthlyDay: |
504 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); | 506 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); |
505 | // write out all rMonthDays; | 507 | // write out all rMonthDays; |
506 | tmpDays = anEvent->recurrence()->monthDays(); | 508 | tmpDays = anEvent->recurrence()->monthDays(); |
507 | for (tmpDay = tmpDays.first(); | 509 | for (tmpDay = tmpDays.first(); |
508 | tmpDay; | 510 | tmpDay; |
509 | tmpDay = tmpDays.next()) { | 511 | tmpDay = tmpDays.next()) { |
510 | tmpStr2.sprintf("%i ", *tmpDay); | 512 | tmpStr2.sprintf("%i ", *tmpDay); |
511 | tmpStr += tmpStr2; | 513 | tmpStr += tmpStr2; |
512 | } | 514 | } |
513 | break; | 515 | break; |
514 | case Recurrence::rYearlyMonth: | 516 | case Recurrence::rYearlyMonth: |
515 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); | 517 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); |
516 | // write out all the rYearNums; | 518 | // write out all the rYearNums; |
517 | tmpDays = anEvent->recurrence()->yearNums(); | 519 | tmpDays = anEvent->recurrence()->yearNums(); |
518 | for (tmpDay = tmpDays.first(); | 520 | for (tmpDay = tmpDays.first(); |
519 | tmpDay; | 521 | tmpDay; |
@@ -690,132 +692,134 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent) | |||
690 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | 692 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) |
691 | { | 693 | { |
692 | VObject *vo; | 694 | VObject *vo; |
693 | VObjectIterator voi; | 695 | VObjectIterator voi; |
694 | char *s; | 696 | char *s; |
695 | 697 | ||
696 | Todo *anEvent = new Todo; | 698 | Todo *anEvent = new Todo; |
697 | 699 | ||
698 | // creation date | 700 | // creation date |
699 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { | 701 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { |
700 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 702 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
701 | deleteStr(s); | 703 | deleteStr(s); |
702 | } | 704 | } |
703 | 705 | ||
704 | // unique id | 706 | // unique id |
705 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); | 707 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); |
706 | // while the UID property is preferred, it is not required. We'll use the | 708 | // while the UID property is preferred, it is not required. We'll use the |
707 | // default Event UID if none is given. | 709 | // default Event UID if none is given. |
708 | if (vo) { | 710 | if (vo) { |
709 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 711 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
710 | deleteStr(s); | 712 | deleteStr(s); |
711 | } | 713 | } |
712 | 714 | ||
713 | // last modification date | 715 | // last modification date |
714 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { | 716 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { |
715 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 717 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
716 | deleteStr(s); | 718 | deleteStr(s); |
717 | } | 719 | } |
718 | else | 720 | else |
719 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 721 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
720 | QTime::currentTime())); | 722 | QTime::currentTime())); |
721 | 723 | ||
722 | // organizer | 724 | // organizer |
723 | // if our extension property for the event's ORGANIZER exists, add it. | 725 | // if our extension property for the event's ORGANIZER exists, add it. |
724 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { | 726 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { |
725 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 727 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
726 | deleteStr(s); | 728 | deleteStr(s); |
727 | } else { | 729 | } else { |
728 | anEvent->setOrganizer(mCalendar->getEmail()); | 730 | anEvent->setOrganizer(mCalendar->getEmail()); |
729 | } | 731 | } |
730 | 732 | ||
731 | // attendees. | 733 | // attendees. |
732 | initPropIterator(&voi, vtodo); | 734 | initPropIterator(&voi, vtodo); |
733 | while (moreIteration(&voi)) { | 735 | while (moreIteration(&voi)) { |
734 | vo = nextVObject(&voi); | 736 | vo = nextVObject(&voi); |
735 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 737 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
736 | Attendee *a; | 738 | Attendee *a; |
737 | VObject *vp; | 739 | VObject *vp; |
738 | s = fakeCString(vObjectUStringZValue(vo)); | 740 | s = fakeCString(vObjectUStringZValue(vo)); |
739 | QString tmpStr = QString::fromLocal8Bit(s); | 741 | QString tmpStr = QString::fromLocal8Bit(s); |
740 | deleteStr(s); | 742 | deleteStr(s); |
741 | tmpStr = tmpStr.simplifyWhiteSpace(); | 743 | tmpStr = tmpStr.simplifyWhiteSpace(); |
742 | int emailPos1, emailPos2; | 744 | int emailPos1, emailPos2; |
743 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 745 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
744 | // both email address and name | 746 | // both email address and name |
745 | emailPos2 = tmpStr.findRev('>'); | 747 | emailPos2 = tmpStr.findRev('>'); |
746 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 748 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
747 | tmpStr.mid(emailPos1 + 1, | 749 | tmpStr.mid(emailPos1 + 1, |
748 | emailPos2 - (emailPos1 + 1))); | 750 | emailPos2 - (emailPos1 + 1))); |
749 | } else if (tmpStr.find('@') > 0) { | 751 | } else if (tmpStr.find('@') > 0) { |
750 | // just an email address | 752 | // just an email address |
751 | a = new Attendee(0, tmpStr); | 753 | a = new Attendee(0, tmpStr); |
752 | } else { | 754 | } else { |
753 | // just a name | 755 | // just a name |
754 | QString email = tmpStr.replace( QRegExp(" "), "." ); | 756 | // QString email = tmpStr.replace( QRegExp(" "), "." ); |
755 | a = new Attendee(tmpStr,email); | 757 | a = new Attendee(tmpStr,0); |
756 | } | 758 | } |
757 | 759 | // is there a Role property? | |
760 | if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) | ||
761 | a->setRole(readRole(vObjectStringZValue(vp))); | ||
758 | // is there an RSVP property? | 762 | // is there an RSVP property? |
759 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 763 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
760 | a->setRSVP(vObjectStringZValue(vp)); | 764 | a->setRSVP(vObjectStringZValue(vp)); |
761 | // is there a status property? | 765 | // is there a status property? |
762 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 766 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
763 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 767 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
764 | // add the attendee | 768 | // add the attendee |
765 | anEvent->addAttendee(a); | 769 | anEvent->addAttendee(a); |
766 | } | 770 | } |
767 | } | 771 | } |
768 | 772 | ||
769 | // description for todo | 773 | // description for todo |
770 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { | 774 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { |
771 | s = fakeCString(vObjectUStringZValue(vo)); | 775 | s = fakeCString(vObjectUStringZValue(vo)); |
772 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 776 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
773 | deleteStr(s); | 777 | deleteStr(s); |
774 | } | 778 | } |
775 | 779 | ||
776 | // summary | 780 | // summary |
777 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { | 781 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { |
778 | s = fakeCString(vObjectUStringZValue(vo)); | 782 | s = fakeCString(vObjectUStringZValue(vo)); |
779 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 783 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
780 | deleteStr(s); | 784 | deleteStr(s); |
781 | } | 785 | } |
782 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { | 786 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { |
783 | s = fakeCString(vObjectUStringZValue(vo)); | 787 | s = fakeCString(vObjectUStringZValue(vo)); |
784 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 788 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
785 | deleteStr(s); | 789 | deleteStr(s); |
786 | } | 790 | } |
787 | 791 | ||
788 | 792 | ||
789 | // completed | 793 | // completed |
790 | // was: status | 794 | // was: status |
791 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { | 795 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { |
792 | s = fakeCString(vObjectUStringZValue(vo)); | 796 | s = fakeCString(vObjectUStringZValue(vo)); |
793 | if (strcmp(s,"COMPLETED") == 0) { | 797 | if (strcmp(s,"COMPLETED") == 0) { |
794 | anEvent->setCompleted(true); | 798 | anEvent->setCompleted(true); |
795 | } else { | 799 | } else { |
796 | anEvent->setCompleted(false); | 800 | anEvent->setCompleted(false); |
797 | } | 801 | } |
798 | deleteStr(s); | 802 | deleteStr(s); |
799 | } | 803 | } |
800 | else | 804 | else |
801 | anEvent->setCompleted(false); | 805 | anEvent->setCompleted(false); |
802 | 806 | ||
803 | // completion date | 807 | // completion date |
804 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { | 808 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { |
805 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 809 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
806 | deleteStr(s); | 810 | deleteStr(s); |
807 | } | 811 | } |
808 | 812 | ||
809 | // priority | 813 | // priority |
810 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { | 814 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { |
811 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 815 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
812 | deleteStr(s); | 816 | deleteStr(s); |
813 | } | 817 | } |
814 | 818 | ||
815 | // due date | 819 | // due date |
816 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { | 820 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { |
817 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 821 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
818 | deleteStr(s); | 822 | deleteStr(s); |
819 | anEvent->setHasDueDate(true); | 823 | anEvent->setHasDueDate(true); |
820 | } else { | 824 | } else { |
821 | anEvent->setHasDueDate(false); | 825 | anEvent->setHasDueDate(false); |
@@ -916,132 +920,137 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) | |||
916 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { | 920 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { |
917 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 921 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
918 | deleteStr(s); | 922 | deleteStr(s); |
919 | } | 923 | } |
920 | 924 | ||
921 | // unique id | 925 | // unique id |
922 | vo = isAPropertyOf(vevent, VCUniqueStringProp); | 926 | vo = isAPropertyOf(vevent, VCUniqueStringProp); |
923 | // while the UID property is preferred, it is not required. We'll use the | 927 | // while the UID property is preferred, it is not required. We'll use the |
924 | // default Event UID if none is given. | 928 | // default Event UID if none is given. |
925 | if (vo) { | 929 | if (vo) { |
926 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 930 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
927 | deleteStr(s); | 931 | deleteStr(s); |
928 | } | 932 | } |
929 | 933 | ||
930 | // revision | 934 | // revision |
931 | // again NSCAL doesn't give us much to work with, so we improvise... | 935 | // again NSCAL doesn't give us much to work with, so we improvise... |
932 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { | 936 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { |
933 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 937 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
934 | deleteStr(s); | 938 | deleteStr(s); |
935 | } | 939 | } |
936 | else | 940 | else |
937 | anEvent->setRevision(0); | 941 | anEvent->setRevision(0); |
938 | 942 | ||
939 | // last modification date | 943 | // last modification date |
940 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { | 944 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { |
941 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 945 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
942 | deleteStr(s); | 946 | deleteStr(s); |
943 | } | 947 | } |
944 | else | 948 | else |
945 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 949 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
946 | QTime::currentTime())); | 950 | QTime::currentTime())); |
947 | 951 | ||
948 | // organizer | 952 | // organizer |
949 | // if our extension property for the event's ORGANIZER exists, add it. | 953 | // if our extension property for the event's ORGANIZER exists, add it. |
950 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { | 954 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { |
951 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 955 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
952 | deleteStr(s); | 956 | deleteStr(s); |
953 | } else { | 957 | } else { |
954 | anEvent->setOrganizer(mCalendar->getEmail()); | 958 | anEvent->setOrganizer(mCalendar->getEmail()); |
955 | } | 959 | } |
956 | 960 | ||
957 | // deal with attendees. | 961 | // deal with attendees. |
958 | initPropIterator(&voi, vevent); | 962 | initPropIterator(&voi, vevent); |
959 | while (moreIteration(&voi)) { | 963 | while (moreIteration(&voi)) { |
960 | vo = nextVObject(&voi); | 964 | vo = nextVObject(&voi); |
961 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 965 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
962 | Attendee *a; | 966 | Attendee *a; |
963 | VObject *vp; | 967 | VObject *vp; |
964 | s = fakeCString(vObjectUStringZValue(vo)); | 968 | s = fakeCString(vObjectUStringZValue(vo)); |
965 | QString tmpStr = QString::fromLocal8Bit(s); | 969 | QString tmpStr = QString::fromLocal8Bit(s); |
966 | deleteStr(s); | 970 | deleteStr(s); |
967 | tmpStr = tmpStr.simplifyWhiteSpace(); | 971 | tmpStr = tmpStr.simplifyWhiteSpace(); |
968 | int emailPos1, emailPos2; | 972 | int emailPos1, emailPos2; |
969 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 973 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
970 | // both email address and name | 974 | // both email address and name |
971 | emailPos2 = tmpStr.findRev('>'); | 975 | emailPos2 = tmpStr.findRev('>'); |
972 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 976 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
973 | tmpStr.mid(emailPos1 + 1, | 977 | tmpStr.mid(emailPos1 + 1, |
974 | emailPos2 - (emailPos1 + 1))); | 978 | emailPos2 - (emailPos1 + 1))); |
975 | } else if (tmpStr.find('@') > 0) { | 979 | } else if (tmpStr.find('@') > 0) { |
976 | // just an email address | 980 | // just an email address |
977 | a = new Attendee(0, tmpStr); | 981 | a = new Attendee(0, tmpStr); |
978 | } else { | 982 | } else { |
979 | // just a name | 983 | // just a name |
980 | QString email = tmpStr.replace( QRegExp(" "), "." ); | 984 | //QString email = tmpStr.replace( QRegExp(" "), "." ); |
981 | a = new Attendee(tmpStr,email); | 985 | a = new Attendee(tmpStr,0); |
982 | } | 986 | } |
983 | 987 | ||
988 | |||
989 | // is there a Role property? | ||
990 | if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) | ||
991 | a->setRole(readRole(vObjectStringZValue(vp))); | ||
992 | |||
984 | // is there an RSVP property? | 993 | // is there an RSVP property? |
985 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 994 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
986 | a->setRSVP(vObjectStringZValue(vp)); | 995 | a->setRSVP(vObjectStringZValue(vp)); |
987 | // is there a status property? | 996 | // is there a status property? |
988 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 997 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
989 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 998 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
990 | // add the attendee | 999 | // add the attendee |
991 | anEvent->addAttendee(a); | 1000 | anEvent->addAttendee(a); |
992 | } | 1001 | } |
993 | } | 1002 | } |
994 | 1003 | ||
995 | // This isn't strictly true. An event that doesn't have a start time | 1004 | // This isn't strictly true. An event that doesn't have a start time |
996 | // or an end time doesn't "float", it has an anchor in time but it doesn't | 1005 | // or an end time doesn't "float", it has an anchor in time but it doesn't |
997 | // "take up" any time. | 1006 | // "take up" any time. |
998 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || | 1007 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || |
999 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { | 1008 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { |
1000 | anEvent->setFloats(TRUE); | 1009 | anEvent->setFloats(TRUE); |
1001 | } else { | 1010 | } else { |
1002 | }*/ | 1011 | }*/ |
1003 | 1012 | ||
1004 | anEvent->setFloats(FALSE); | 1013 | anEvent->setFloats(FALSE); |
1005 | 1014 | ||
1006 | // start time | 1015 | // start time |
1007 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { | 1016 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { |
1008 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1017 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1009 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 1018 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
1010 | deleteStr(s); | 1019 | deleteStr(s); |
1011 | if (anEvent->dtStart().time().isNull()) | 1020 | if (anEvent->dtStart().time().isNull()) |
1012 | anEvent->setFloats(TRUE); | 1021 | anEvent->setFloats(TRUE); |
1013 | } | 1022 | } |
1014 | 1023 | ||
1015 | // stop time | 1024 | // stop time |
1016 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { | 1025 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { |
1017 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1026 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1018 | deleteStr(s); | 1027 | deleteStr(s); |
1019 | if (anEvent->dtEnd().time().isNull()) | 1028 | if (anEvent->dtEnd().time().isNull()) |
1020 | anEvent->setFloats(TRUE); | 1029 | anEvent->setFloats(TRUE); |
1021 | } | 1030 | } |
1022 | 1031 | ||
1023 | // at this point, there should be at least a start or end time. | 1032 | // at this point, there should be at least a start or end time. |
1024 | // fix up for events that take up no time but have a time associated | 1033 | // fix up for events that take up no time but have a time associated |
1025 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) | 1034 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) |
1026 | anEvent->setDtStart(anEvent->dtEnd()); | 1035 | anEvent->setDtStart(anEvent->dtEnd()); |
1027 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) | 1036 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) |
1028 | anEvent->setDtEnd(anEvent->dtStart()); | 1037 | anEvent->setDtEnd(anEvent->dtStart()); |
1029 | 1038 | ||
1030 | /////////////////////////////////////////////////////////////////////////// | 1039 | /////////////////////////////////////////////////////////////////////////// |
1031 | 1040 | ||
1032 | // repeat stuff | 1041 | // repeat stuff |
1033 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { | 1042 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { |
1034 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); | 1043 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); |
1035 | deleteStr(s); | 1044 | deleteStr(s); |
1036 | tmpStr.simplifyWhiteSpace(); | 1045 | tmpStr.simplifyWhiteSpace(); |
1037 | tmpStr = tmpStr.upper(); | 1046 | tmpStr = tmpStr.upper(); |
1038 | 1047 | ||
1039 | /********************************* DAILY ******************************/ | 1048 | /********************************* DAILY ******************************/ |
1040 | if (tmpStr.left(1) == "D") { | 1049 | if (tmpStr.left(1) == "D") { |
1041 | int index = tmpStr.find(' '); | 1050 | int index = tmpStr.find(' '); |
1042 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1051 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1043 | index = tmpStr.findRev(' ') + 1; // advance to last field | 1052 | index = tmpStr.findRev(' ') + 1; // advance to last field |
1044 | if (tmpStr.mid(index,1) == "#") index++; | 1053 | if (tmpStr.mid(index,1) == "#") index++; |
1045 | if (tmpStr.find('T', index) != -1) { | 1054 | if (tmpStr.find('T', index) != -1) { |
1046 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1055 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1047 | anEvent->recurrence()->setDaily(rFreq, rEndDate); | 1056 | anEvent->recurrence()->setDaily(rFreq, rEndDate); |
@@ -1597,124 +1606,142 @@ void VCalFormat::populate(VObject *vcal) | |||
1597 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 1606 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
1598 | goto SKIP; | 1607 | goto SKIP; |
1599 | } | 1608 | } |
1600 | 1609 | ||
1601 | anEvent = VEventToEvent(curVO); | 1610 | anEvent = VEventToEvent(curVO); |
1602 | // we now use addEvent instead of insertEvent so that the | 1611 | // we now use addEvent instead of insertEvent so that the |
1603 | // signal/slot get connected. | 1612 | // signal/slot get connected. |
1604 | if (anEvent) { | 1613 | if (anEvent) { |
1605 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { | 1614 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { |
1606 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." | 1615 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." |
1607 | << endl; | 1616 | << endl; |
1608 | } else { | 1617 | } else { |
1609 | mCalendar->addEvent(anEvent); | 1618 | mCalendar->addEvent(anEvent); |
1610 | } | 1619 | } |
1611 | } else { | 1620 | } else { |
1612 | // some sort of error must have occurred while in translation. | 1621 | // some sort of error must have occurred while in translation. |
1613 | goto SKIP; | 1622 | goto SKIP; |
1614 | } | 1623 | } |
1615 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { | 1624 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { |
1616 | Todo *aTodo = VTodoToEvent(curVO); | 1625 | Todo *aTodo = VTodoToEvent(curVO); |
1617 | mCalendar->addTodo(aTodo); | 1626 | mCalendar->addTodo(aTodo); |
1618 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || | 1627 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || |
1619 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || | 1628 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || |
1620 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { | 1629 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { |
1621 | // do nothing, we know these properties and we want to skip them. | 1630 | // do nothing, we know these properties and we want to skip them. |
1622 | // we have either already processed them or are ignoring them. | 1631 | // we have either already processed them or are ignoring them. |
1623 | ; | 1632 | ; |
1624 | } else { | 1633 | } else { |
1625 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; | 1634 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; |
1626 | } | 1635 | } |
1627 | SKIP: | 1636 | SKIP: |
1628 | ; | 1637 | ; |
1629 | } // while | 1638 | } // while |
1630 | 1639 | ||
1631 | // Post-Process list of events with relations, put Event objects in relation | 1640 | // Post-Process list of events with relations, put Event objects in relation |
1632 | Event *ev; | 1641 | Event *ev; |
1633 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { | 1642 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { |
1634 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); | 1643 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); |
1635 | } | 1644 | } |
1636 | Todo *todo; | 1645 | Todo *todo; |
1637 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { | 1646 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { |
1638 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); | 1647 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); |
1639 | } | 1648 | } |
1640 | } | 1649 | } |
1641 | 1650 | ||
1642 | const char *VCalFormat::dayFromNum(int day) | 1651 | const char *VCalFormat::dayFromNum(int day) |
1643 | { | 1652 | { |
1644 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; | 1653 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; |
1645 | 1654 | ||
1646 | return days[day]; | 1655 | return days[day]; |
1647 | } | 1656 | } |
1648 | 1657 | ||
1649 | int VCalFormat::numFromDay(const QString &day) | 1658 | int VCalFormat::numFromDay(const QString &day) |
1650 | { | 1659 | { |
1651 | if (day == "MO ") return 0; | 1660 | if (day == "MO ") return 0; |
1652 | if (day == "TU ") return 1; | 1661 | if (day == "TU ") return 1; |
1653 | if (day == "WE ") return 2; | 1662 | if (day == "WE ") return 2; |
1654 | if (day == "TH ") return 3; | 1663 | if (day == "TH ") return 3; |
1655 | if (day == "FR ") return 4; | 1664 | if (day == "FR ") return 4; |
1656 | if (day == "SA ") return 5; | 1665 | if (day == "SA ") return 5; |
1657 | if (day == "SU ") return 6; | 1666 | if (day == "SU ") return 6; |
1658 | 1667 | ||
1659 | return -1; // something bad happened. :) | 1668 | return -1; // something bad happened. :) |
1660 | } | 1669 | } |
1670 | Attendee::Role VCalFormat::readRole(const char *s) const | ||
1671 | { | ||
1672 | QString statStr = s; | ||
1673 | statStr = statStr.upper(); | ||
1674 | Attendee::Role role = Attendee::ReqParticipant; | ||
1675 | |||
1676 | if ( statStr == "OWNER") | ||
1677 | role = Attendee::Chair; | ||
1678 | // enum Role { ReqParticipant, OptParticipant, NonParticipant, Chair }; | ||
1679 | |||
1680 | return role; | ||
1681 | } | ||
1661 | 1682 | ||
1683 | QCString VCalFormat::writeRole(Attendee::Role role) const | ||
1684 | { | ||
1685 | if ( role == Attendee::Chair ) | ||
1686 | return "OWNER"; | ||
1687 | return "ATTENDEE"; | ||
1688 | } | ||
1662 | Attendee::PartStat VCalFormat::readStatus(const char *s) const | 1689 | Attendee::PartStat VCalFormat::readStatus(const char *s) const |
1663 | { | 1690 | { |
1664 | QString statStr = s; | 1691 | QString statStr = s; |
1665 | statStr = statStr.upper(); | 1692 | statStr = statStr.upper(); |
1666 | Attendee::PartStat status; | 1693 | Attendee::PartStat status; |
1667 | 1694 | ||
1668 | if (statStr == "X-ACTION") | 1695 | if (statStr == "X-ACTION") |
1669 | status = Attendee::NeedsAction; | 1696 | status = Attendee::NeedsAction; |
1670 | else if (statStr == "NEEDS ACTION") | 1697 | else if (statStr == "NEEDS ACTION") |
1671 | status = Attendee::NeedsAction; | 1698 | status = Attendee::NeedsAction; |
1672 | else if (statStr== "ACCEPTED") | 1699 | else if (statStr== "ACCEPTED") |
1673 | status = Attendee::Accepted; | 1700 | status = Attendee::Accepted; |
1674 | else if (statStr== "SENT") | 1701 | else if (statStr== "SENT") |
1675 | status = Attendee::NeedsAction; | 1702 | status = Attendee::NeedsAction; |
1676 | else if (statStr== "TENTATIVE") | 1703 | else if (statStr== "TENTATIVE") |
1677 | status = Attendee::Tentative; | 1704 | status = Attendee::Tentative; |
1678 | else if (statStr== "CONFIRMED") | 1705 | else if (statStr== "CONFIRMED") |
1679 | status = Attendee::Accepted; | 1706 | status = Attendee::Accepted; |
1680 | else if (statStr== "DECLINED") | 1707 | else if (statStr== "DECLINED") |
1681 | status = Attendee::Declined; | 1708 | status = Attendee::Declined; |
1682 | else if (statStr== "COMPLETED") | 1709 | else if (statStr== "COMPLETED") |
1683 | status = Attendee::Completed; | 1710 | status = Attendee::Completed; |
1684 | else if (statStr== "DELEGATED") | 1711 | else if (statStr== "DELEGATED") |
1685 | status = Attendee::Delegated; | 1712 | status = Attendee::Delegated; |
1686 | else { | 1713 | else { |
1687 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; | 1714 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; |
1688 | status = Attendee::NeedsAction; | 1715 | status = Attendee::NeedsAction; |
1689 | } | 1716 | } |
1690 | 1717 | ||
1691 | return status; | 1718 | return status; |
1692 | } | 1719 | } |
1693 | 1720 | ||
1694 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const | 1721 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const |
1695 | { | 1722 | { |
1696 | switch(status) { | 1723 | switch(status) { |
1697 | default: | 1724 | default: |
1698 | case Attendee::NeedsAction: | 1725 | case Attendee::NeedsAction: |
1699 | return "NEEDS ACTION"; | 1726 | return "NEEDS ACTION"; |
1700 | break; | 1727 | break; |
1701 | case Attendee::Accepted: | 1728 | case Attendee::Accepted: |
1702 | return "ACCEPTED"; | 1729 | return "ACCEPTED"; |
1703 | break; | 1730 | break; |
1704 | case Attendee::Declined: | 1731 | case Attendee::Declined: |
1705 | return "DECLINED"; | 1732 | return "DECLINED"; |
1706 | break; | 1733 | break; |
1707 | case Attendee::Tentative: | 1734 | case Attendee::Tentative: |
1708 | return "TENTATIVE"; | 1735 | return "TENTATIVE"; |
1709 | break; | 1736 | break; |
1710 | case Attendee::Delegated: | 1737 | case Attendee::Delegated: |
1711 | return "DELEGATED"; | 1738 | return "DELEGATED"; |
1712 | break; | 1739 | break; |
1713 | case Attendee::Completed: | 1740 | case Attendee::Completed: |
1714 | return "COMPLETED"; | 1741 | return "COMPLETED"; |
1715 | break; | 1742 | break; |
1716 | case Attendee::InProcess: | 1743 | case Attendee::InProcess: |
1717 | return "NEEDS ACTION"; | 1744 | return "NEEDS ACTION"; |
1718 | break; | 1745 | break; |
1719 | } | 1746 | } |
1720 | } | 1747 | } |
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index 5bef7ed..c7df017 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h | |||
@@ -34,79 +34,80 @@ namespace KCal { | |||
34 | This class implements the vCalendar format. It provides methods for | 34 | This class implements the vCalendar format. It provides methods for |
35 | loading/saving/converting vCalendar format data into the internal KOrganizer | 35 | loading/saving/converting vCalendar format data into the internal KOrganizer |
36 | representation as Calendar and Events. | 36 | representation as Calendar and Events. |
37 | 37 | ||
38 | @short vCalendar format implementation | 38 | @short vCalendar format implementation |
39 | */ | 39 | */ |
40 | class VCalFormat : public CalFormat { | 40 | class VCalFormat : public CalFormat { |
41 | public: | 41 | public: |
42 | VCalFormat(); | 42 | VCalFormat(); |
43 | virtual ~VCalFormat(); | 43 | virtual ~VCalFormat(); |
44 | 44 | ||
45 | /** loads a calendar on disk in vCalendar format into the current calendar. | 45 | /** loads a calendar on disk in vCalendar format into the current calendar. |
46 | * any information already present is lost. Returns TRUE if successful, | 46 | * any information already present is lost. Returns TRUE if successful, |
47 | * else returns FALSE. | 47 | * else returns FALSE. |
48 | * @param fileName the name of the calendar on disk. | 48 | * @param fileName the name of the calendar on disk. |
49 | */ | 49 | */ |
50 | bool load(Calendar *,const QString &fileName ); | 50 | bool load(Calendar *,const QString &fileName ); |
51 | /** writes out the calendar to disk in vCalendar format. Returns true if | 51 | /** writes out the calendar to disk in vCalendar format. Returns true if |
52 | * successful and false on error. | 52 | * successful and false on error. |
53 | * @param fileName the name of the file | 53 | * @param fileName the name of the file |
54 | */ | 54 | */ |
55 | bool save(Calendar *,const QString &fileName ); | 55 | bool save(Calendar *,const QString &fileName ); |
56 | 56 | ||
57 | /** | 57 | /** |
58 | Parse string and populate calendar with that information. | 58 | Parse string and populate calendar with that information. |
59 | */ | 59 | */ |
60 | bool fromString( Calendar *, const QString & ); | 60 | bool fromString( Calendar *, const QString & ); |
61 | /** | 61 | /** |
62 | Return calendar information as string. | 62 | Return calendar information as string. |
63 | */ | 63 | */ |
64 | void setLocalTime ( bool ); | 64 | void setLocalTime ( bool ); |
65 | QString toString( Calendar * ); | 65 | QString toString( Calendar * ); |
66 | QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true ); | 66 | QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true ); |
67 | QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true ); | 67 | QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true ); |
68 | 68 | ||
69 | protected: | 69 | protected: |
70 | /** translates a VObject of the TODO type into a Event */ | 70 | /** translates a VObject of the TODO type into a Event */ |
71 | Todo *VTodoToEvent(VObject *vtodo); | 71 | Todo *VTodoToEvent(VObject *vtodo); |
72 | /** translates a VObject into a Event and returns a pointer to it. */ | 72 | /** translates a VObject into a Event and returns a pointer to it. */ |
73 | Event *VEventToEvent(VObject *vevent); | 73 | Event *VEventToEvent(VObject *vevent); |
74 | /** translate a Event into a VTodo-type VObject and return pointer */ | 74 | /** translate a Event into a VTodo-type VObject and return pointer */ |
75 | VObject *eventToVTodo(const Todo *anEvent); | 75 | VObject *eventToVTodo(const Todo *anEvent); |
76 | /** translate a Event into a VObject and returns a pointer to it. */ | 76 | /** translate a Event into a VObject and returns a pointer to it. */ |
77 | VObject* eventToVEvent(const Event *anEvent); | 77 | VObject* eventToVEvent(const Event *anEvent); |
78 | 78 | ||
79 | /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ | 79 | /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ |
80 | QString qDateToISO(const QDate &); | 80 | QString qDateToISO(const QDate &); |
81 | /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ | 81 | /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ |
82 | QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); | 82 | QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); |
83 | /** takes a string in the format YYYYMMDDTHHMMSS and returns a | 83 | /** takes a string in the format YYYYMMDDTHHMMSS and returns a |
84 | * valid QDateTime. */ | 84 | * valid QDateTime. */ |
85 | QDateTime ISOToQDateTime(const QString & dtStr); | 85 | QDateTime ISOToQDateTime(const QString & dtStr); |
86 | /** takes a string in the format YYYYMMDD and returns a | 86 | /** takes a string in the format YYYYMMDD and returns a |
87 | * valid QDate. */ | 87 | * valid QDate. */ |
88 | QDate ISOToQDate(const QString & dtStr); | 88 | QDate ISOToQDate(const QString & dtStr); |
89 | /** takes a vCalendar tree of VObjects, and puts all of them that have | 89 | /** takes a vCalendar tree of VObjects, and puts all of them that have |
90 | * the "event" property into the dictionary, todos in the todo-list, etc. */ | 90 | * the "event" property into the dictionary, todos in the todo-list, etc. */ |
91 | void populate(VObject *vcal); | 91 | void populate(VObject *vcal); |
92 | 92 | ||
93 | /** takes a number 0 - 6 and returns the two letter string of that day, | 93 | /** takes a number 0 - 6 and returns the two letter string of that day, |
94 | * i.e. MO, TU, WE, etc. */ | 94 | * i.e. MO, TU, WE, etc. */ |
95 | const char *dayFromNum(int day); | 95 | const char *dayFromNum(int day); |
96 | /** the reverse of the above function. */ | 96 | /** the reverse of the above function. */ |
97 | int numFromDay(const QString &day); | 97 | int numFromDay(const QString &day); |
98 | 98 | Attendee::Role VCalFormat::readRole(const char *s) const; | |
99 | QCString writeRole(Attendee::Role role) const; | ||
99 | Attendee::PartStat readStatus(const char *s) const; | 100 | Attendee::PartStat readStatus(const char *s) const; |
100 | QCString writeStatus(Attendee::PartStat status) const; | 101 | QCString writeStatus(Attendee::PartStat status) const; |
101 | 102 | ||
102 | private: | 103 | private: |
103 | Calendar *mCalendar; | 104 | Calendar *mCalendar; |
104 | bool useLocalTime; | 105 | bool useLocalTime; |
105 | 106 | ||
106 | QPtrList<Event> mEventsRelate; // events with relations | 107 | QPtrList<Event> mEventsRelate; // events with relations |
107 | QPtrList<Todo> mTodosRelate; // todos with relations | 108 | QPtrList<Todo> mTodosRelate; // todos with relations |
108 | }; | 109 | }; |
109 | 110 | ||
110 | } | 111 | } |
111 | 112 | ||
112 | #endif | 113 | #endif |
diff --git a/libkcal/versit/vcc.c b/libkcal/versit/vcc.c index 9be752d..5413813 100644 --- a/libkcal/versit/vcc.c +++ b/libkcal/versit/vcc.c | |||
@@ -1701,129 +1701,130 @@ static int lexLookahead() { | |||
1701 | else if (c == '\n') { | 1701 | else if (c == '\n') { |
1702 | int a = (lexBuf.len>1)? | 1702 | int a = (lexBuf.len>1)? |
1703 | lexBuf.buf[lexBuf.getPtr+1]: | 1703 | lexBuf.buf[lexBuf.getPtr+1]: |
1704 | lexGeta_(1); | 1704 | lexGeta_(1); |
1705 | if (a == '\r') { | 1705 | if (a == '\r') { |
1706 | lexSkipLookahead(); | 1706 | lexSkipLookahead(); |
1707 | } | 1707 | } |
1708 | lexBuf.buf[lexBuf.getPtr] = '\n'; | 1708 | lexBuf.buf[lexBuf.getPtr] = '\n'; |
1709 | } | 1709 | } |
1710 | return c; | 1710 | return c; |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | static int lexGetc() { | 1713 | static int lexGetc() { |
1714 | int c = lexLookahead(); | 1714 | int c = lexLookahead(); |
1715 | if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { | 1715 | if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { |
1716 | /* EOF will remain in lookahead buffer */ | 1716 | /* EOF will remain in lookahead buffer */ |
1717 | lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; | 1717 | lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; |
1718 | lexBuf.len--; | 1718 | lexBuf.len--; |
1719 | } | 1719 | } |
1720 | return c; | 1720 | return c; |
1721 | } | 1721 | } |
1722 | 1722 | ||
1723 | static void lexSkipLookaheadWord() { | 1723 | static void lexSkipLookaheadWord() { |
1724 | if (lexBuf.strsLen <= lexBuf.len) { | 1724 | if (lexBuf.strsLen <= lexBuf.len) { |
1725 | lexBuf.len -= lexBuf.strsLen; | 1725 | lexBuf.len -= lexBuf.strsLen; |
1726 | lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD; | 1726 | lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD; |
1727 | } | 1727 | } |
1728 | } | 1728 | } |
1729 | 1729 | ||
1730 | static void lexClearToken() | 1730 | static void lexClearToken() |
1731 | { | 1731 | { |
1732 | lexBuf.strsLen = 0; | 1732 | lexBuf.strsLen = 0; |
1733 | } | 1733 | } |
1734 | 1734 | ||
1735 | static void lexAppendc(int c) | 1735 | static void lexAppendc(int c) |
1736 | { | 1736 | { |
1737 | lexBuf.strs[lexBuf.strsLen] = c; | 1737 | lexBuf.strs[lexBuf.strsLen] = c; |
1738 | /* append up to zero termination */ | 1738 | /* append up to zero termination */ |
1739 | if (c == 0) return; | 1739 | if (c == 0) return; |
1740 | lexBuf.strsLen++; | 1740 | lexBuf.strsLen++; |
1741 | if (lexBuf.strsLen > lexBuf.maxToken) { | 1741 | if (lexBuf.strsLen > lexBuf.maxToken) { |
1742 | /* double the token string size */ | 1742 | /* double the token string size */ |
1743 | lexBuf.maxToken <<= 1; | 1743 | lexBuf.maxToken <<= 1; |
1744 | lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken); | 1744 | lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken); |
1745 | } | 1745 | } |
1746 | } | 1746 | } |
1747 | 1747 | ||
1748 | static char* lexStr() { | 1748 | static char* lexStr() { |
1749 | return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1); | 1749 | return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1); |
1750 | } | 1750 | } |
1751 | 1751 | ||
1752 | static void lexSkipWhite() { | 1752 | static void lexSkipWhite() { |
1753 | int c = lexLookahead(); | 1753 | int c = lexLookahead(); |
1754 | while (c == ' ' || c == '\t') { | 1754 | while (c == ' ' || c == '\t') { |
1755 | lexSkipLookahead(); | 1755 | lexSkipLookahead(); |
1756 | c = lexLookahead(); | 1756 | c = lexLookahead(); |
1757 | } | 1757 | } |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | static char* lexGetWord() { | 1760 | static char* lexGetWord() { |
1761 | int c; | 1761 | int c; |
1762 | lexSkipWhite(); | 1762 | lexSkipWhite(); |
1763 | lexClearToken(); | 1763 | lexClearToken(); |
1764 | c = lexLookahead(); | 1764 | c = lexLookahead(); |
1765 | while (c != EOF && !strchr("\t\n ;:=",c)) { | 1765 | // LR while (c != EOF && !strchr("\t\n ;:=",c)) { |
1766 | while (c != EOF && !strchr("\t\n;:=",c)) { | ||
1766 | lexAppendc(c); | 1767 | lexAppendc(c); |
1767 | lexSkipLookahead(); | 1768 | lexSkipLookahead(); |
1768 | c = lexLookahead(); | 1769 | c = lexLookahead(); |
1769 | } | 1770 | } |
1770 | lexAppendc(0); | 1771 | lexAppendc(0); |
1771 | return lexStr(); | 1772 | return lexStr(); |
1772 | } | 1773 | } |
1773 | 1774 | ||
1774 | static void lexPushLookaheadc(int c) { | 1775 | static void lexPushLookaheadc(int c) { |
1775 | int putptr; | 1776 | int putptr; |
1776 | /* can't putback EOF, because it never leaves lookahead buffer */ | 1777 | /* can't putback EOF, because it never leaves lookahead buffer */ |
1777 | if (c == EOF) return; | 1778 | if (c == EOF) return; |
1778 | putptr = (int)lexBuf.getPtr - 1; | 1779 | putptr = (int)lexBuf.getPtr - 1; |
1779 | if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; | 1780 | if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; |
1780 | lexBuf.getPtr = putptr; | 1781 | lexBuf.getPtr = putptr; |
1781 | lexBuf.buf[putptr] = c; | 1782 | lexBuf.buf[putptr] = c; |
1782 | lexBuf.len += 1; | 1783 | lexBuf.len += 1; |
1783 | } | 1784 | } |
1784 | 1785 | ||
1785 | static char* lexLookaheadWord() { | 1786 | static char* lexLookaheadWord() { |
1786 | /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0 | 1787 | /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0 |
1787 | / and thing bigger than that will stop the lookahead and return 0; | 1788 | / and thing bigger than that will stop the lookahead and return 0; |
1788 | / leading white spaces are not recoverable. | 1789 | / leading white spaces are not recoverable. |
1789 | */ | 1790 | */ |
1790 | int c; | 1791 | int c; |
1791 | int len = 0; | 1792 | int len = 0; |
1792 | int curgetptr = 0; | 1793 | int curgetptr = 0; |
1793 | lexSkipWhite(); | 1794 | lexSkipWhite(); |
1794 | lexClearToken(); | 1795 | lexClearToken(); |
1795 | curgetptr = (int)lexBuf.getPtr;/* remember! */ | 1796 | curgetptr = (int)lexBuf.getPtr;/* remember! */ |
1796 | while (len < (MAX_LEX_LOOKAHEAD_0)) { | 1797 | while (len < (MAX_LEX_LOOKAHEAD_0)) { |
1797 | c = lexGetc(); | 1798 | c = lexGetc(); |
1798 | len++; | 1799 | len++; |
1799 | if (c == EOF || strchr("\t\n ;:=", c)) { | 1800 | if (c == EOF || strchr("\t\n ;:=", c)) { |
1800 | lexAppendc(0); | 1801 | lexAppendc(0); |
1801 | /* restore lookahead buf. */ | 1802 | /* restore lookahead buf. */ |
1802 | lexBuf.len += len; | 1803 | lexBuf.len += len; |
1803 | lexBuf.getPtr = curgetptr; | 1804 | lexBuf.getPtr = curgetptr; |
1804 | return lexStr(); | 1805 | return lexStr(); |
1805 | } | 1806 | } |
1806 | else | 1807 | else |
1807 | lexAppendc(c); | 1808 | lexAppendc(c); |
1808 | } | 1809 | } |
1809 | lexBuf.len += len;/* char that has been moved to lookahead buffer */ | 1810 | lexBuf.len += len;/* char that has been moved to lookahead buffer */ |
1810 | lexBuf.getPtr = curgetptr; | 1811 | lexBuf.getPtr = curgetptr; |
1811 | return 0; | 1812 | return 0; |
1812 | } | 1813 | } |
1813 | 1814 | ||
1814 | #ifdef _SUPPORT_LINE_FOLDING | 1815 | #ifdef _SUPPORT_LINE_FOLDING |
1815 | static void handleMoreRFC822LineBreak(int c) { | 1816 | static void handleMoreRFC822LineBreak(int c) { |
1816 | /* suport RFC 822 line break in cases like | 1817 | /* suport RFC 822 line break in cases like |
1817 | *ADR: foo; | 1818 | *ADR: foo; |
1818 | * morefoo; | 1819 | * morefoo; |
1819 | * more foo; | 1820 | * more foo; |
1820 | */ | 1821 | */ |
1821 | if (c == ';') { | 1822 | if (c == ';') { |
1822 | int a; | 1823 | int a; |
1823 | lexSkipLookahead(); | 1824 | lexSkipLookahead(); |
1824 | /* skip white spaces */ | 1825 | /* skip white spaces */ |
1825 | a = lexLookahead(); | 1826 | a = lexLookahead(); |
1826 | while (a == ' ' || a == '\t') { | 1827 | while (a == ' ' || a == '\t') { |
1827 | lexSkipLookahead(); | 1828 | lexSkipLookahead(); |
1828 | a = lexLookahead(); | 1829 | a = lexLookahead(); |
1829 | } | 1830 | } |