-rw-r--r-- | libkcal/vcalformat.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 59030d5..72a781a 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -319,67 +319,67 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | |||
319 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); | 319 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); |
320 | } | 320 | } |
321 | 321 | ||
322 | // alarm stuff | 322 | // alarm stuff |
323 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; | 323 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; |
324 | QPtrList<Alarm> alarms = anEvent->alarms(); | 324 | QPtrList<Alarm> alarms = anEvent->alarms(); |
325 | Alarm* alarm; | 325 | Alarm* alarm; |
326 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 326 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
327 | if (alarm->enabled()) { | 327 | if (alarm->enabled()) { |
328 | VObject *a = addProp(vtodo, VCDAlarmProp); | 328 | VObject *a = addProp(vtodo, VCDAlarmProp); |
329 | tmpStr = qDateTimeToISO(alarm->time()); | 329 | tmpStr = qDateTimeToISO(alarm->time()); |
330 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 330 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
331 | addPropValue(a, VCRepeatCountProp, "1"); | 331 | addPropValue(a, VCRepeatCountProp, "1"); |
332 | addPropValue(a, VCDisplayStringProp, "beep!"); | 332 | addPropValue(a, VCDisplayStringProp, "beep!"); |
333 | if (alarm->type() == Alarm::Audio) { | 333 | if (alarm->type() == Alarm::Audio) { |
334 | a = addProp(vtodo, VCAAlarmProp); | 334 | a = addProp(vtodo, VCAAlarmProp); |
335 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 335 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
336 | addPropValue(a, VCRepeatCountProp, "1"); | 336 | addPropValue(a, VCRepeatCountProp, "1"); |
337 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 337 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
338 | } | 338 | } |
339 | else if (alarm->type() == Alarm::Procedure) { | 339 | else if (alarm->type() == Alarm::Procedure) { |
340 | a = addProp(vtodo, VCPAlarmProp); | 340 | a = addProp(vtodo, VCPAlarmProp); |
341 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 341 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
342 | addPropValue(a, VCRepeatCountProp, "1"); | 342 | addPropValue(a, VCRepeatCountProp, "1"); |
343 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 343 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | if (anEvent->pilotId()) { | 348 | if (anEvent->pilotId()) { |
349 | // pilot sync stuff | 349 | // pilot sync stuff |
350 | tmpStr.sprintf("%i",anEvent->pilotId()); | 350 | tmpStr.sprintf("%i",anEvent->pilotId()); |
351 | addPropValue(vtodo, KPilotIdProp, tmpStr.local8Bit()); | 351 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); |
352 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 352 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
353 | addPropValue(vtodo, KPilotStatusProp, tmpStr.local8Bit()); | 353 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); |
354 | } | 354 | } |
355 | 355 | ||
356 | return vtodo; | 356 | return vtodo; |
357 | } | 357 | } |
358 | 358 | ||
359 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 359 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) |
360 | { | 360 | { |
361 | VObject *vevent; | 361 | VObject *vevent; |
362 | QString tmpStr; | 362 | QString tmpStr; |
363 | QStringList tmpStrList; | 363 | QStringList tmpStrList; |
364 | 364 | ||
365 | vevent = newVObject(VCEventProp); | 365 | vevent = newVObject(VCEventProp); |
366 | 366 | ||
367 | // start and end time | 367 | // start and end time |
368 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 368 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
369 | !anEvent->doesFloat()); | 369 | !anEvent->doesFloat()); |
370 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 370 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
371 | 371 | ||
372 | // events that have time associated but take up no time should | 372 | // events that have time associated but take up no time should |
373 | // not have both DTSTART and DTEND. | 373 | // not have both DTSTART and DTEND. |
374 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 374 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
375 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 375 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
376 | !anEvent->doesFloat()); | 376 | !anEvent->doesFloat()); |
377 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); | 377 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); |
378 | } | 378 | } |
379 | 379 | ||
380 | // creation date | 380 | // creation date |
381 | tmpStr = qDateTimeToISO(anEvent->created()); | 381 | tmpStr = qDateTimeToISO(anEvent->created()); |
382 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); | 382 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); |
383 | 383 | ||
384 | // unique id | 384 | // unique id |
385 | addPropValue(vevent, VCUniqueStringProp, | 385 | addPropValue(vevent, VCUniqueStringProp, |
@@ -497,65 +497,65 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent) | |||
497 | tmpStr2.sprintf("%i ", *tmpDay); | 497 | tmpStr2.sprintf("%i ", *tmpDay); |
498 | tmpStr += tmpStr2; | 498 | tmpStr += tmpStr2; |
499 | } | 499 | } |
500 | break; | 500 | break; |
501 | default: | 501 | default: |
502 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; | 502 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; |
503 | break; | 503 | break; |
504 | } // switch | 504 | } // switch |
505 | 505 | ||
506 | if (anEvent->recurrence()->duration() > 0) { | 506 | if (anEvent->recurrence()->duration() > 0) { |
507 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); | 507 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); |
508 | tmpStr += tmpStr2; | 508 | tmpStr += tmpStr2; |
509 | } else if (anEvent->recurrence()->duration() == -1) { | 509 | } else if (anEvent->recurrence()->duration() == -1) { |
510 | tmpStr += "#0"; // defined as repeat forever | 510 | tmpStr += "#0"; // defined as repeat forever |
511 | } else { | 511 | } else { |
512 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); | 512 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); |
513 | } | 513 | } |
514 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); | 514 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); |
515 | 515 | ||
516 | } // event repeats | 516 | } // event repeats |
517 | 517 | ||
518 | // exceptions to recurrence | 518 | // exceptions to recurrence |
519 | DateList dateList = anEvent->exDates(); | 519 | DateList dateList = anEvent->exDates(); |
520 | DateList::ConstIterator it; | 520 | DateList::ConstIterator it; |
521 | QString tmpStr2; | 521 | QString tmpStr2; |
522 | 522 | ||
523 | for (it = dateList.begin(); it != dateList.end(); ++it) { | 523 | for (it = dateList.begin(); it != dateList.end(); ++it) { |
524 | tmpStr = qDateToISO(*it) + ";"; | 524 | tmpStr = qDateToISO(*it) + ";"; |
525 | tmpStr2 += tmpStr; | 525 | tmpStr2 += tmpStr; |
526 | } | 526 | } |
527 | if (!tmpStr2.isEmpty()) { | 527 | if (!tmpStr2.isEmpty()) { |
528 | tmpStr2.truncate(tmpStr2.length()-1); | 528 | tmpStr2.truncate(tmpStr2.length()-1); |
529 | addPropValue(vevent, VCExDateProp, tmpStr2.local8Bit()); | 529 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); |
530 | } | 530 | } |
531 | 531 | ||
532 | // description | 532 | // description |
533 | if (!anEvent->description().isEmpty()) { | 533 | if (!anEvent->description().isEmpty()) { |
534 | VObject *d = addPropValue(vevent, VCDescriptionProp, | 534 | VObject *d = addPropValue(vevent, VCDescriptionProp, |
535 | anEvent->description().local8Bit()); | 535 | anEvent->description().local8Bit()); |
536 | if (anEvent->description().find('\n') != -1) | 536 | if (anEvent->description().find('\n') != -1) |
537 | addProp(d, VCQuotedPrintableProp); | 537 | addProp(d, VCQuotedPrintableProp); |
538 | } | 538 | } |
539 | 539 | ||
540 | // summary | 540 | // summary |
541 | if (!anEvent->summary().isEmpty()) | 541 | if (!anEvent->summary().isEmpty()) |
542 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); | 542 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); |
543 | 543 | ||
544 | if (!anEvent->location().isEmpty()) | 544 | if (!anEvent->location().isEmpty()) |
545 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); | 545 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); |
546 | 546 | ||
547 | // status | 547 | // status |
548 | // TODO: define Event status | 548 | // TODO: define Event status |
549 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); | 549 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); |
550 | 550 | ||
551 | // secrecy | 551 | // secrecy |
552 | const char *text = 0; | 552 | const char *text = 0; |
553 | switch (anEvent->secrecy()) { | 553 | switch (anEvent->secrecy()) { |
554 | case Incidence::SecrecyPublic: | 554 | case Incidence::SecrecyPublic: |
555 | text = "PUBLIC"; | 555 | text = "PUBLIC"; |
556 | break; | 556 | break; |
557 | case Incidence::SecrecyPrivate: | 557 | case Incidence::SecrecyPrivate: |
558 | text = "PRIVATE"; | 558 | text = "PRIVATE"; |
559 | break; | 559 | break; |
560 | case Incidence::SecrecyConfidential: | 560 | case Incidence::SecrecyConfidential: |
561 | text = "CONFIDENTIAL"; | 561 | text = "CONFIDENTIAL"; |
@@ -612,67 +612,67 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent) | |||
612 | if (alarm->type() == Alarm::Audio) { | 612 | if (alarm->type() == Alarm::Audio) { |
613 | a = addProp(vevent, VCAAlarmProp); | 613 | a = addProp(vevent, VCAAlarmProp); |
614 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 614 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
615 | addPropValue(a, VCRepeatCountProp, "1"); | 615 | addPropValue(a, VCRepeatCountProp, "1"); |
616 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 616 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
617 | } | 617 | } |
618 | if (alarm->type() == Alarm::Procedure) { | 618 | if (alarm->type() == Alarm::Procedure) { |
619 | a = addProp(vevent, VCPAlarmProp); | 619 | a = addProp(vevent, VCPAlarmProp); |
620 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 620 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
621 | addPropValue(a, VCRepeatCountProp, "1"); | 621 | addPropValue(a, VCRepeatCountProp, "1"); |
622 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 622 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
623 | } | 623 | } |
624 | } | 624 | } |
625 | } | 625 | } |
626 | 626 | ||
627 | // priority | 627 | // priority |
628 | tmpStr.sprintf("%i",anEvent->priority()); | 628 | tmpStr.sprintf("%i",anEvent->priority()); |
629 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); | 629 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); |
630 | 630 | ||
631 | // transparency | 631 | // transparency |
632 | tmpStr.sprintf("%i",anEvent->transparency()); | 632 | tmpStr.sprintf("%i",anEvent->transparency()); |
633 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); | 633 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); |
634 | 634 | ||
635 | // related event | 635 | // related event |
636 | if (anEvent->relatedTo()) { | 636 | if (anEvent->relatedTo()) { |
637 | addPropValue(vevent, VCRelatedToProp, | 637 | addPropValue(vevent, VCRelatedToProp, |
638 | anEvent->relatedTo()->uid().local8Bit()); | 638 | anEvent->relatedTo()->uid().local8Bit()); |
639 | } | 639 | } |
640 | 640 | ||
641 | if (anEvent->pilotId()) { | 641 | if (anEvent->pilotId()) { |
642 | // pilot sync stuff | 642 | // pilot sync stuff |
643 | tmpStr.sprintf("%i",anEvent->pilotId()); | 643 | tmpStr.sprintf("%i",anEvent->pilotId()); |
644 | addPropValue(vevent, KPilotIdProp, tmpStr.local8Bit()); | 644 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); |
645 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 645 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
646 | addPropValue(vevent, KPilotStatusProp, tmpStr.local8Bit()); | 646 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); |
647 | } | 647 | } |
648 | 648 | ||
649 | return vevent; | 649 | return vevent; |
650 | } | 650 | } |
651 | 651 | ||
652 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | 652 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) |
653 | { | 653 | { |
654 | VObject *vo; | 654 | VObject *vo; |
655 | VObjectIterator voi; | 655 | VObjectIterator voi; |
656 | char *s; | 656 | char *s; |
657 | 657 | ||
658 | Todo *anEvent = new Todo; | 658 | Todo *anEvent = new Todo; |
659 | 659 | ||
660 | // creation date | 660 | // creation date |
661 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { | 661 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { |
662 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 662 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
663 | deleteStr(s); | 663 | deleteStr(s); |
664 | } | 664 | } |
665 | 665 | ||
666 | // unique id | 666 | // unique id |
667 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); | 667 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); |
668 | // while the UID property is preferred, it is not required. We'll use the | 668 | // while the UID property is preferred, it is not required. We'll use the |
669 | // default Event UID if none is given. | 669 | // default Event UID if none is given. |
670 | if (vo) { | 670 | if (vo) { |
671 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 671 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
672 | deleteStr(s); | 672 | deleteStr(s); |
673 | } | 673 | } |
674 | 674 | ||
675 | // last modification date | 675 | // last modification date |
676 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { | 676 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { |
677 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 677 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
678 | deleteStr(s); | 678 | deleteStr(s); |
@@ -820,72 +820,72 @@ Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | |||
820 | } | 820 | } |
821 | 821 | ||
822 | // related todo | 822 | // related todo |
823 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { | 823 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { |
824 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 824 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
825 | deleteStr(s); | 825 | deleteStr(s); |
826 | mTodosRelate.append(anEvent); | 826 | mTodosRelate.append(anEvent); |
827 | } | 827 | } |
828 | 828 | ||
829 | // categories | 829 | // categories |
830 | QStringList tmpStrList; | 830 | QStringList tmpStrList; |
831 | int index1 = 0; | 831 | int index1 = 0; |
832 | int index2 = 0; | 832 | int index2 = 0; |
833 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { | 833 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { |
834 | s = fakeCString(vObjectUStringZValue(vo)); | 834 | s = fakeCString(vObjectUStringZValue(vo)); |
835 | QString categories = QString::fromLocal8Bit(s); | 835 | QString categories = QString::fromLocal8Bit(s); |
836 | deleteStr(s); | 836 | deleteStr(s); |
837 | //const char* category; | 837 | //const char* category; |
838 | QString category; | 838 | QString category; |
839 | while ((index2 = categories.find(',', index1)) != -1) { | 839 | while ((index2 = categories.find(',', index1)) != -1) { |
840 | //category = (const char *) categories.mid(index1, (index2 - index1)); | 840 | //category = (const char *) categories.mid(index1, (index2 - index1)); |
841 | category = categories.mid(index1, (index2 - index1)); | 841 | category = categories.mid(index1, (index2 - index1)); |
842 | tmpStrList.append(category); | 842 | tmpStrList.append(category); |
843 | index1 = index2+1; | 843 | index1 = index2+1; |
844 | } | 844 | } |
845 | // get last category | 845 | // get last category |
846 | category = categories.mid(index1, (categories.length()-index1)); | 846 | category = categories.mid(index1, (categories.length()-index1)); |
847 | tmpStrList.append(category); | 847 | tmpStrList.append(category); |
848 | anEvent->setCategories(tmpStrList); | 848 | anEvent->setCategories(tmpStrList); |
849 | } | 849 | } |
850 | 850 | ||
851 | /* PILOT SYNC STUFF */ | 851 | /* PILOT SYNC STUFF */ |
852 | if ((vo = isAPropertyOf(vtodo, KPilotIdProp))) { | 852 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { |
853 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 853 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
854 | deleteStr(s); | 854 | deleteStr(s); |
855 | } | 855 | } |
856 | else | 856 | else |
857 | anEvent->setPilotId(0); | 857 | anEvent->setPilotId(0); |
858 | 858 | ||
859 | if ((vo = isAPropertyOf(vtodo, KPilotStatusProp))) { | 859 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { |
860 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 860 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
861 | deleteStr(s); | 861 | deleteStr(s); |
862 | } | 862 | } |
863 | else | 863 | else |
864 | anEvent->setSyncStatus(Event::SYNCMOD); | 864 | anEvent->setSyncStatus(Event::SYNCMOD); |
865 | 865 | ||
866 | return anEvent; | 866 | return anEvent; |
867 | } | 867 | } |
868 | 868 | ||
869 | Event* VCalFormat::VEventToEvent(VObject *vevent) | 869 | Event* VCalFormat::VEventToEvent(VObject *vevent) |
870 | { | 870 | { |
871 | VObject *vo; | 871 | VObject *vo; |
872 | VObjectIterator voi; | 872 | VObjectIterator voi; |
873 | char *s; | 873 | char *s; |
874 | 874 | ||
875 | Event *anEvent = new Event; | 875 | Event *anEvent = new Event; |
876 | 876 | ||
877 | // creation date | 877 | // creation date |
878 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { | 878 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { |
879 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 879 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
880 | deleteStr(s); | 880 | deleteStr(s); |
881 | } | 881 | } |
882 | 882 | ||
883 | // unique id | 883 | // unique id |
884 | vo = isAPropertyOf(vevent, VCUniqueStringProp); | 884 | vo = isAPropertyOf(vevent, VCUniqueStringProp); |
885 | // while the UID property is preferred, it is not required. We'll use the | 885 | // while the UID property is preferred, it is not required. We'll use the |
886 | // default Event UID if none is given. | 886 | // default Event UID if none is given. |
887 | if (vo) { | 887 | if (vo) { |
888 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 888 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
889 | deleteStr(s); | 889 | deleteStr(s); |
890 | } | 890 | } |
891 | 891 | ||
@@ -1178,65 +1178,65 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) | |||
1178 | if( index == last ) { | 1178 | if( index == last ) { |
1179 | // e.g. YD1 #0 | 1179 | // e.g. YD1 #0 |
1180 | tmpDay = anEvent->dtStart().date().dayOfYear(); | 1180 | tmpDay = anEvent->dtStart().date().dayOfYear(); |
1181 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1181 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1182 | } | 1182 | } |
1183 | else { | 1183 | else { |
1184 | // e.g. YD1 123 #0 | 1184 | // e.g. YD1 123 #0 |
1185 | while (index < last) { | 1185 | while (index < last) { |
1186 | int index2 = tmpStr.find(' ', index); | 1186 | int index2 = tmpStr.find(' ', index); |
1187 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1187 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1188 | index = index2+1; | 1188 | index = index2+1; |
1189 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1189 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1190 | } // while != # | 1190 | } // while != # |
1191 | } | 1191 | } |
1192 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1192 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1193 | if (tmpStr.find('T', index) != -1) { | 1193 | if (tmpStr.find('T', index) != -1) { |
1194 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1194 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1195 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); | 1195 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); |
1196 | } else { | 1196 | } else { |
1197 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1197 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1198 | if (rDuration == 0) | 1198 | if (rDuration == 0) |
1199 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); | 1199 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); |
1200 | else | 1200 | else |
1201 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); | 1201 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); |
1202 | } | 1202 | } |
1203 | } else { | 1203 | } else { |
1204 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; | 1204 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; |
1205 | } // if | 1205 | } // if |
1206 | } // repeats | 1206 | } // repeats |
1207 | 1207 | ||
1208 | 1208 | ||
1209 | // recurrence exceptions | 1209 | // recurrence exceptions |
1210 | if ((vo = isAPropertyOf(vevent, VCExDateProp)) != 0) { | 1210 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { |
1211 | s = fakeCString(vObjectUStringZValue(vo)); | 1211 | s = fakeCString(vObjectUStringZValue(vo)); |
1212 | QStringList exDates = QStringList::split(",",s); | 1212 | QStringList exDates = QStringList::split(",",s); |
1213 | QStringList::ConstIterator it; | 1213 | QStringList::ConstIterator it; |
1214 | for(it = exDates.begin(); it != exDates.end(); ++it ) { | 1214 | for(it = exDates.begin(); it != exDates.end(); ++it ) { |
1215 | anEvent->addExDate(ISOToQDate(*it)); | 1215 | anEvent->addExDate(ISOToQDate(*it)); |
1216 | } | 1216 | } |
1217 | deleteStr(s); | 1217 | deleteStr(s); |
1218 | } | 1218 | } |
1219 | 1219 | ||
1220 | // summary | 1220 | // summary |
1221 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { | 1221 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { |
1222 | s = fakeCString(vObjectUStringZValue(vo)); | 1222 | s = fakeCString(vObjectUStringZValue(vo)); |
1223 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 1223 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
1224 | deleteStr(s); | 1224 | deleteStr(s); |
1225 | } | 1225 | } |
1226 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { | 1226 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { |
1227 | s = fakeCString(vObjectUStringZValue(vo)); | 1227 | s = fakeCString(vObjectUStringZValue(vo)); |
1228 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 1228 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
1229 | deleteStr(s); | 1229 | deleteStr(s); |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | // description | 1232 | // description |
1233 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { | 1233 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { |
1234 | s = fakeCString(vObjectUStringZValue(vo)); | 1234 | s = fakeCString(vObjectUStringZValue(vo)); |
1235 | if (!anEvent->description().isEmpty()) { | 1235 | if (!anEvent->description().isEmpty()) { |
1236 | anEvent->setDescription(anEvent->description() + "\n" + | 1236 | anEvent->setDescription(anEvent->description() + "\n" + |
1237 | QString::fromLocal8Bit(s)); | 1237 | QString::fromLocal8Bit(s)); |
1238 | } else { | 1238 | } else { |
1239 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 1239 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
1240 | } | 1240 | } |
1241 | deleteStr(s); | 1241 | deleteStr(s); |
1242 | } | 1242 | } |
@@ -1342,72 +1342,72 @@ Event* VCalFormat::VEventToEvent(VObject *vevent) | |||
1342 | } | 1342 | } |
1343 | } | 1343 | } |
1344 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { | 1344 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { |
1345 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 1345 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
1346 | s = fakeCString(vObjectUStringZValue(a)); | 1346 | s = fakeCString(vObjectUStringZValue(a)); |
1347 | alarm->setAudioAlarm(QFile::decodeName(s)); | 1347 | alarm->setAudioAlarm(QFile::decodeName(s)); |
1348 | deleteStr(s); | 1348 | deleteStr(s); |
1349 | } | 1349 | } |
1350 | } | 1350 | } |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | // priority | 1353 | // priority |
1354 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { | 1354 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { |
1355 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1355 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1356 | deleteStr(s); | 1356 | deleteStr(s); |
1357 | } | 1357 | } |
1358 | 1358 | ||
1359 | // transparency | 1359 | // transparency |
1360 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { | 1360 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { |
1361 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); | 1361 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); |
1362 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); | 1362 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); |
1363 | deleteStr(s); | 1363 | deleteStr(s); |
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | // related event | 1366 | // related event |
1367 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { | 1367 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { |
1368 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 1368 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
1369 | deleteStr(s); | 1369 | deleteStr(s); |
1370 | mEventsRelate.append(anEvent); | 1370 | mEventsRelate.append(anEvent); |
1371 | } | 1371 | } |
1372 | 1372 | ||
1373 | /* PILOT SYNC STUFF */ | 1373 | /* PILOT SYNC STUFF */ |
1374 | if ((vo = isAPropertyOf(vevent, KPilotIdProp))) { | 1374 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { |
1375 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1375 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1376 | deleteStr(s); | 1376 | deleteStr(s); |
1377 | } | 1377 | } |
1378 | else | 1378 | else |
1379 | anEvent->setPilotId(0); | 1379 | anEvent->setPilotId(0); |
1380 | 1380 | ||
1381 | if ((vo = isAPropertyOf(vevent, KPilotStatusProp))) { | 1381 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { |
1382 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1382 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1383 | deleteStr(s); | 1383 | deleteStr(s); |
1384 | } | 1384 | } |
1385 | else | 1385 | else |
1386 | anEvent->setSyncStatus(Event::SYNCMOD); | 1386 | anEvent->setSyncStatus(Event::SYNCMOD); |
1387 | 1387 | ||
1388 | return anEvent; | 1388 | return anEvent; |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | 1391 | ||
1392 | QString VCalFormat::qDateToISO(const QDate &qd) | 1392 | QString VCalFormat::qDateToISO(const QDate &qd) |
1393 | { | 1393 | { |
1394 | QString tmpStr; | 1394 | QString tmpStr; |
1395 | 1395 | ||
1396 | ASSERT(qd.isValid()); | 1396 | ASSERT(qd.isValid()); |
1397 | 1397 | ||
1398 | tmpStr.sprintf("%.2d%.2d%.2d", | 1398 | tmpStr.sprintf("%.2d%.2d%.2d", |
1399 | qd.year(), qd.month(), qd.day()); | 1399 | qd.year(), qd.month(), qd.day()); |
1400 | return tmpStr; | 1400 | return tmpStr; |
1401 | 1401 | ||
1402 | } | 1402 | } |
1403 | 1403 | ||
1404 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1404 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) |
1405 | { | 1405 | { |
1406 | QString tmpStr; | 1406 | QString tmpStr; |
1407 | 1407 | ||
1408 | ASSERT(qdt.date().isValid()); | 1408 | ASSERT(qdt.date().isValid()); |
1409 | ASSERT(qdt.time().isValid()); | 1409 | ASSERT(qdt.time().isValid()); |
1410 | if (zulu) { | 1410 | if (zulu) { |
1411 | QDateTime tmpDT(qdt); | 1411 | QDateTime tmpDT(qdt); |
1412 | tmpDT = tmpDT.addSecs(60*(-mCalendar->getTimeZone())); // correct to GMT. | 1412 | tmpDT = tmpDT.addSecs(60*(-mCalendar->getTimeZone())); // correct to GMT. |
1413 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", | 1413 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", |
@@ -1493,65 +1493,65 @@ void VCalFormat::populate(VObject *vcal) | |||
1493 | // warn the user we might have trouble reading this unknown version. | 1493 | // warn the user we might have trouble reading this unknown version. |
1494 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1494 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1495 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1495 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1496 | if (strcmp(_VCAL_VERSION, s) != 0) | 1496 | if (strcmp(_VCAL_VERSION, s) != 0) |
1497 | kdDebug() << "This vCalendar file has version " << s | 1497 | kdDebug() << "This vCalendar file has version " << s |
1498 | << "We only support " << _VCAL_VERSION << endl; | 1498 | << "We only support " << _VCAL_VERSION << endl; |
1499 | deleteStr(s); | 1499 | deleteStr(s); |
1500 | } | 1500 | } |
1501 | 1501 | ||
1502 | // set the time zone | 1502 | // set the time zone |
1503 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1503 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1504 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1504 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1505 | mCalendar->setTimeZone(s); | 1505 | mCalendar->setTimeZone(s); |
1506 | deleteStr(s); | 1506 | deleteStr(s); |
1507 | } | 1507 | } |
1508 | 1508 | ||
1509 | 1509 | ||
1510 | // Store all events with a relatedTo property in a list for post-processing | 1510 | // Store all events with a relatedTo property in a list for post-processing |
1511 | mEventsRelate.clear(); | 1511 | mEventsRelate.clear(); |
1512 | mTodosRelate.clear(); | 1512 | mTodosRelate.clear(); |
1513 | 1513 | ||
1514 | initPropIterator(&i, vcal); | 1514 | initPropIterator(&i, vcal); |
1515 | 1515 | ||
1516 | // go through all the vobjects in the vcal | 1516 | // go through all the vobjects in the vcal |
1517 | while (moreIteration(&i)) { | 1517 | while (moreIteration(&i)) { |
1518 | curVO = nextVObject(&i); | 1518 | curVO = nextVObject(&i); |
1519 | 1519 | ||
1520 | /************************************************************************/ | 1520 | /************************************************************************/ |
1521 | 1521 | ||
1522 | // now, check to see that the object is an event or todo. | 1522 | // now, check to see that the object is an event or todo. |
1523 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1523 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1524 | 1524 | ||
1525 | if ((curVOProp = isAPropertyOf(curVO, KPilotStatusProp)) != 0) { | 1525 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { |
1526 | char *s; | 1526 | char *s; |
1527 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1527 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1528 | // check to see if event was deleted by the kpilot conduit | 1528 | // check to see if event was deleted by the kpilot conduit |
1529 | if (atoi(s) == Event::SYNCDEL) { | 1529 | if (atoi(s) == Event::SYNCDEL) { |
1530 | deleteStr(s); | 1530 | deleteStr(s); |
1531 | kdDebug(5800) << "skipping pilot-deleted event" << endl; | 1531 | kdDebug(5800) << "skipping pilot-deleted event" << endl; |
1532 | goto SKIP; | 1532 | goto SKIP; |
1533 | } | 1533 | } |
1534 | deleteStr(s); | 1534 | deleteStr(s); |
1535 | } | 1535 | } |
1536 | 1536 | ||
1537 | // this code checks to see if we are trying to read in an event | 1537 | // this code checks to see if we are trying to read in an event |
1538 | // that we already find to be in the calendar. If we find this | 1538 | // that we already find to be in the calendar. If we find this |
1539 | // to be the case, we skip the event. | 1539 | // to be the case, we skip the event. |
1540 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 1540 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
1541 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 1541 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
1542 | QString tmpStr(s); | 1542 | QString tmpStr(s); |
1543 | deleteStr(s); | 1543 | deleteStr(s); |
1544 | 1544 | ||
1545 | if (mCalendar->event(tmpStr)) { | 1545 | if (mCalendar->event(tmpStr)) { |
1546 | goto SKIP; | 1546 | goto SKIP; |
1547 | } | 1547 | } |
1548 | if (mCalendar->todo(tmpStr)) { | 1548 | if (mCalendar->todo(tmpStr)) { |
1549 | goto SKIP; | 1549 | goto SKIP; |
1550 | } | 1550 | } |
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && | 1553 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && |
1554 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { | 1554 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { |
1555 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 1555 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
1556 | goto SKIP; | 1556 | goto SKIP; |
1557 | } | 1557 | } |