summaryrefslogtreecommitdiffabout
path: root/libkcal/vcalformat.cpp
Unidiff
Diffstat (limited to 'libkcal/vcalformat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/vcalformat.cpp22
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
@@ -303,99 +303,99 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
303 QString catStr; 303 QString catStr;
304 for ( QStringList::Iterator it = tmpStrList.begin(); 304 for ( QStringList::Iterator it = tmpStrList.begin();
305 it != tmpStrList.end(); 305 it != tmpStrList.end();
306 ++it ) { 306 ++it ) {
307 catStr = *it; 307 catStr = *it;
308 if (catStr[0] == ' ') 308 if (catStr[0] == ' ')
309 tmpStr += catStr.mid(1); 309 tmpStr += catStr.mid(1);
310 else 310 else
311 tmpStr += catStr; 311 tmpStr += catStr;
312 // this must be a ';' character as the vCalendar specification requires! 312 // this must be a ';' character as the vCalendar specification requires!
313 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 313 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
314 // read in. 314 // read in.
315 tmpStr += ";"; 315 tmpStr += ";";
316 } 316 }
317 if (!tmpStr.isEmpty()) { 317 if (!tmpStr.isEmpty()) {
318 tmpStr.truncate(tmpStr.length()-1); 318 tmpStr.truncate(tmpStr.length()-1);
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
359VObject* VCalFormat::eventToVEvent(const Event *anEvent) 359VObject* 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,
386 anEvent->uid().local8Bit()); 386 anEvent->uid().local8Bit());
387 387
388 // revision 388 // revision
389 tmpStr.sprintf("%i", anEvent->revision()); 389 tmpStr.sprintf("%i", anEvent->revision());
390 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); 390 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit());
391 391
392 // last modification date 392 // last modification date
393 tmpStr = qDateTimeToISO(anEvent->lastModified()); 393 tmpStr = qDateTimeToISO(anEvent->lastModified());
394 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); 394 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit());
395 395
396 // attendee and organizer stuff 396 // attendee and organizer stuff
397 tmpStr = "MAILTO:" + anEvent->organizer(); 397 tmpStr = "MAILTO:" + anEvent->organizer();
398 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); 398 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit());
399 399
400 if (anEvent->attendeeCount() != 0) { 400 if (anEvent->attendeeCount() != 0) {
401 QPtrList<Attendee> al = anEvent->attendees(); 401 QPtrList<Attendee> al = anEvent->attendees();
@@ -481,97 +481,97 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent)
481 // write out all the rYearNums; 481 // write out all the rYearNums;
482 tmpDays = anEvent->recurrence()->yearNums(); 482 tmpDays = anEvent->recurrence()->yearNums();
483 for (tmpDay = tmpDays.first(); 483 for (tmpDay = tmpDays.first();
484 tmpDay; 484 tmpDay;
485 tmpDay = tmpDays.next()) { 485 tmpDay = tmpDays.next()) {
486 tmpStr2.sprintf("%i ", *tmpDay); 486 tmpStr2.sprintf("%i ", *tmpDay);
487 tmpStr += tmpStr2; 487 tmpStr += tmpStr2;
488 } 488 }
489 break; 489 break;
490 case Recurrence::rYearlyDay: 490 case Recurrence::rYearlyDay:
491 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); 491 tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency());
492 // write out all the rYearNums; 492 // write out all the rYearNums;
493 tmpDays = anEvent->recurrence()->yearNums(); 493 tmpDays = anEvent->recurrence()->yearNums();
494 for (tmpDay = tmpDays.first(); 494 for (tmpDay = tmpDays.first();
495 tmpDay; 495 tmpDay;
496 tmpDay = tmpDays.next()) { 496 tmpDay = tmpDays.next()) {
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";
562 break; 562 break;
563 } 563 }
564 if (text) { 564 if (text) {
565 addPropValue(vevent, VCClassProp, text); 565 addPropValue(vevent, VCClassProp, text);
566 } 566 }
567 567
568 // categories 568 // categories
569 tmpStrList = anEvent->categories(); 569 tmpStrList = anEvent->categories();
570 tmpStr = ""; 570 tmpStr = "";
571 QString catStr; 571 QString catStr;
572 for ( QStringList::Iterator it = tmpStrList.begin(); 572 for ( QStringList::Iterator it = tmpStrList.begin();
573 it != tmpStrList.end(); 573 it != tmpStrList.end();
574 ++it ) { 574 ++it ) {
575 catStr = *it; 575 catStr = *it;
576 if (catStr[0] == ' ') 576 if (catStr[0] == ' ')
577 tmpStr += catStr.mid(1); 577 tmpStr += catStr.mid(1);
@@ -596,99 +596,99 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent)
596 // resources 596 // resources
597 tmpStrList = anEvent->resources(); 597 tmpStrList = anEvent->resources();
598 tmpStr = tmpStrList.join(";"); 598 tmpStr = tmpStrList.join(";");
599 if (!tmpStr.isEmpty()) 599 if (!tmpStr.isEmpty())
600 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); 600 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit());
601 601
602 // alarm stuff 602 // alarm stuff
603 QPtrList<Alarm> alarms = anEvent->alarms(); 603 QPtrList<Alarm> alarms = anEvent->alarms();
604 Alarm* alarm; 604 Alarm* alarm;
605 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 605 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
606 if (alarm->enabled()) { 606 if (alarm->enabled()) {
607 VObject *a = addProp(vevent, VCDAlarmProp); 607 VObject *a = addProp(vevent, VCDAlarmProp);
608 tmpStr = qDateTimeToISO(alarm->time()); 608 tmpStr = qDateTimeToISO(alarm->time());
609 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 609 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
610 addPropValue(a, VCRepeatCountProp, "1"); 610 addPropValue(a, VCRepeatCountProp, "1");
611 addPropValue(a, VCDisplayStringProp, "beep!"); 611 addPropValue(a, VCDisplayStringProp, "beep!");
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
652Todo *VCalFormat::VTodoToEvent(VObject *vtodo) 652Todo *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);
679 } 679 }
680 else 680 else
681 anEvent->setLastModified(QDateTime(QDate::currentDate(), 681 anEvent->setLastModified(QDateTime(QDate::currentDate(),
682 QTime::currentTime())); 682 QTime::currentTime()));
683 683
684 // organizer 684 // organizer
685 // if our extension property for the event's ORGANIZER exists, add it. 685 // if our extension property for the event's ORGANIZER exists, add it.
686 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { 686 if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) {
687 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); 687 anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo)));
688 deleteStr(s); 688 deleteStr(s);
689 } else { 689 } else {
690 anEvent->setOrganizer(mCalendar->getEmail()); 690 anEvent->setOrganizer(mCalendar->getEmail());
691 } 691 }
692 692
693 // attendees. 693 // attendees.
694 initPropIterator(&voi, vtodo); 694 initPropIterator(&voi, vtodo);
@@ -804,104 +804,104 @@ Todo *VCalFormat::VTodoToEvent(VObject *vtodo)
804 } 804 }
805 alarm->setEnabled(true); 805 alarm->setEnabled(true);
806 if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { 806 if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) {
807 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { 807 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
808 s = fakeCString(vObjectUStringZValue(a)); 808 s = fakeCString(vObjectUStringZValue(a));
809 alarm->setProcedureAlarm(QFile::decodeName(s)); 809 alarm->setProcedureAlarm(QFile::decodeName(s));
810 deleteStr(s); 810 deleteStr(s);
811 } 811 }
812 } 812 }
813 if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { 813 if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) {
814 if ((a = isAPropertyOf(vo, VCAudioContentProp))) { 814 if ((a = isAPropertyOf(vo, VCAudioContentProp))) {
815 s = fakeCString(vObjectUStringZValue(a)); 815 s = fakeCString(vObjectUStringZValue(a));
816 alarm->setAudioAlarm(QFile::decodeName(s)); 816 alarm->setAudioAlarm(QFile::decodeName(s));
817 deleteStr(s); 817 deleteStr(s);
818 } 818 }
819 } 819 }
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
869Event* VCalFormat::VEventToEvent(VObject *vevent) 869Event* 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
892 // revision 892 // revision
893 // again NSCAL doesn't give us much to work with, so we improvise... 893 // again NSCAL doesn't give us much to work with, so we improvise...
894 if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { 894 if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) {
895 anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); 895 anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo))));
896 deleteStr(s); 896 deleteStr(s);
897 } 897 }
898 else 898 else
899 anEvent->setRevision(0); 899 anEvent->setRevision(0);
900 900
901 // last modification date 901 // last modification date
902 if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { 902 if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) {
903 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 903 anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
904 deleteStr(s); 904 deleteStr(s);
905 } 905 }
906 else 906 else
907 anEvent->setLastModified(QDateTime(QDate::currentDate(), 907 anEvent->setLastModified(QDateTime(QDate::currentDate(),
@@ -1162,97 +1162,97 @@ Event* VCalFormat::VEventToEvent(VObject *vevent)
1162 } else { 1162 } else {
1163 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); 1163 int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt();
1164 if (rDuration == 0) 1164 if (rDuration == 0)
1165 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); 1165 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1);
1166 else 1166 else
1167 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); 1167 anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration);
1168 } 1168 }
1169 } 1169 }
1170 1170
1171 /*********************** YEARLY-BY-DAY *********************************/ 1171 /*********************** YEARLY-BY-DAY *********************************/
1172 else if (tmpStr.left(2) == "YD") { 1172 else if (tmpStr.left(2) == "YD") {
1173 int index = tmpStr.find(' '); 1173 int index = tmpStr.find(' ');
1174 int last = tmpStr.findRev(' ') + 1; 1174 int last = tmpStr.findRev(' ') + 1;
1175 int rFreq = tmpStr.mid(2, (index-1)).toInt(); 1175 int rFreq = tmpStr.mid(2, (index-1)).toInt();
1176 index += 1; 1176 index += 1;
1177 short tmpDay; 1177 short tmpDay;
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 }
1243 1243
1244 // some stupid vCal exporters ignore the standard and use Description 1244 // some stupid vCal exporters ignore the standard and use Description
1245 // instead of Summary for the default field. Correct for this. 1245 // instead of Summary for the default field. Correct for this.
1246 if (anEvent->summary().isEmpty() && 1246 if (anEvent->summary().isEmpty() &&
1247 !(anEvent->description().isEmpty())) { 1247 !(anEvent->description().isEmpty())) {
1248 QString tmpStr = anEvent->description().simplifyWhiteSpace(); 1248 QString tmpStr = anEvent->description().simplifyWhiteSpace();
1249 anEvent->setDescription(""); 1249 anEvent->setDescription("");
1250 anEvent->setSummary(tmpStr); 1250 anEvent->setSummary(tmpStr);
1251 } 1251 }
1252 1252
1253#if 0 1253#if 0
1254 // status 1254 // status
1255 if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { 1255 if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) {
1256 QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); 1256 QString tmpStr(s = fakeCString(vObjectUStringZValue(vo)));
1257 deleteStr(s); 1257 deleteStr(s);
1258// TODO: Define Event status 1258// TODO: Define Event status
@@ -1326,104 +1326,104 @@ Event* VCalFormat::VEventToEvent(VObject *vevent)
1326 } 1326 }
1327 1327
1328 /* alarm stuff */ 1328 /* alarm stuff */
1329 if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { 1329 if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) {
1330 Alarm* alarm = anEvent->newAlarm(); 1330 Alarm* alarm = anEvent->newAlarm();
1331 VObject *a; 1331 VObject *a;
1332 if ((a = isAPropertyOf(vo, VCRunTimeProp))) { 1332 if ((a = isAPropertyOf(vo, VCRunTimeProp))) {
1333 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); 1333 alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a))));
1334 deleteStr(s); 1334 deleteStr(s);
1335 } 1335 }
1336 alarm->setEnabled(true); 1336 alarm->setEnabled(true);
1337 if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { 1337 if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) {
1338 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { 1338 if ((a = isAPropertyOf(vo, VCProcedureNameProp))) {
1339 s = fakeCString(vObjectUStringZValue(a)); 1339 s = fakeCString(vObjectUStringZValue(a));
1340 alarm->setProcedureAlarm(QFile::decodeName(s)); 1340 alarm->setProcedureAlarm(QFile::decodeName(s));
1341 deleteStr(s); 1341 deleteStr(s);
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
1392QString VCalFormat::qDateToISO(const QDate &qd) 1392QString 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
1404QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) 1404QString 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",
1414 tmpDT.date().year(), tmpDT.date().month(), 1414 tmpDT.date().year(), tmpDT.date().month(),
1415 tmpDT.date().day(), tmpDT.time().hour(), 1415 tmpDT.date().day(), tmpDT.time().hour(),
1416 tmpDT.time().minute(), tmpDT.time().second()); 1416 tmpDT.time().minute(), tmpDT.time().second());
1417 } else { 1417 } else {
1418 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", 1418 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d",
1419 qdt.date().year(), qdt.date().month(), 1419 qdt.date().year(), qdt.date().month(),
1420 qdt.date().day(), qdt.time().hour(), 1420 qdt.date().day(), qdt.time().hour(),
1421 qdt.time().minute(), qdt.time().second()); 1421 qdt.time().minute(), qdt.time().second());
1422 } 1422 }
1423 return tmpStr; 1423 return tmpStr;
1424} 1424}
1425 1425
1426QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) 1426QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr)
1427{ 1427{
1428 QDate tmpDate; 1428 QDate tmpDate;
1429 QTime tmpTime; 1429 QTime tmpTime;
@@ -1477,97 +1477,97 @@ void VCalFormat::populate(VObject *vcal)
1477 methodType = fakeCString(vObjectUStringZValue(curVO)); 1477 methodType = fakeCString(vObjectUStringZValue(curVO));
1478 kdDebug() << "This calendar is an iTIP transaction of type '" 1478 kdDebug() << "This calendar is an iTIP transaction of type '"
1479 << methodType << "'" << endl; 1479 << methodType << "'" << endl;
1480 delete methodType; 1480 delete methodType;
1481 } 1481 }
1482 1482
1483 // warn the user that we might have trouble reading non-known calendar. 1483 // warn the user that we might have trouble reading non-known calendar.
1484 if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { 1484 if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) {
1485 char *s = fakeCString(vObjectUStringZValue(curVO)); 1485 char *s = fakeCString(vObjectUStringZValue(curVO));
1486 if (strcmp(productId().local8Bit(), s) != 0) 1486 if (strcmp(productId().local8Bit(), s) != 0)
1487 kdDebug() << "This vCalendar file was not created by KOrganizer " 1487 kdDebug() << "This vCalendar file was not created by KOrganizer "
1488 "or any other product we support. Loading anyway..." << endl; 1488 "or any other product we support. Loading anyway..." << endl;
1489 mLoadedProductId = s; 1489 mLoadedProductId = s;
1490 deleteStr(s); 1490 deleteStr(s);
1491 } 1491 }
1492 1492
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 }
1558 1558
1559 anEvent = VEventToEvent(curVO); 1559 anEvent = VEventToEvent(curVO);
1560 // we now use addEvent instead of insertEvent so that the 1560 // we now use addEvent instead of insertEvent so that the
1561 // signal/slot get connected. 1561 // signal/slot get connected.
1562 if (anEvent) { 1562 if (anEvent) {
1563 if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { 1563 if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) {
1564 kdDebug() << "VCalFormat::populate(): Event has invalid dates." 1564 kdDebug() << "VCalFormat::populate(): Event has invalid dates."
1565 << endl; 1565 << endl;
1566 } else { 1566 } else {
1567 mCalendar->addEvent(anEvent); 1567 mCalendar->addEvent(anEvent);
1568 } 1568 }
1569 } else { 1569 } else {
1570 // some sort of error must have occurred while in translation. 1570 // some sort of error must have occurred while in translation.
1571 goto SKIP; 1571 goto SKIP;
1572 } 1572 }
1573 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { 1573 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) {