summaryrefslogtreecommitdiffabout
path: root/libkcal/vcalformat.cpp
Unidiff
Diffstat (limited to 'libkcal/vcalformat.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/vcalformat.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 62a31ae..8efc1ea 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -305,51 +305,51 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
305 305
306 // summary 306 // summary
307 if (!anEvent->summary().isEmpty()) 307 if (!anEvent->summary().isEmpty())
308 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); 308 addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit());
309 309
310 if (!anEvent->location().isEmpty()) 310 if (!anEvent->location().isEmpty())
311 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); 311 addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit());
312 312
313 // completed 313 // completed
314 // status 314 // status
315 // backward compatibility, KOrganizer used to interpret only these two values 315 // backward compatibility, KOrganizer used to interpret only these two values
316 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : 316 addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" :
317 "NEEDS_ACTION"); 317 "NEEDS_ACTION");
318 // completion date 318 // completion date
319 if (anEvent->hasCompletedDate()) { 319 if (anEvent->hasCompletedDate()) {
320 tmpStr = qDateTimeToISO(anEvent->completed()); 320 tmpStr = qDateTimeToISO(anEvent->completed());
321 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); 321 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit());
322 } 322 }
323 323
324 // priority 324 // priority
325 tmpStr.sprintf("%i",anEvent->priority()); 325 tmpStr.sprintf("%i",anEvent->priority());
326 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); 326 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit());
327 327
328 // related event 328 // related event
329 if (anEvent->relatedTo()) { 329 if (anEvent->relatedToUid()) {
330 addPropValue(vtodo, VCRelatedToProp, 330 addPropValue(vtodo, VCRelatedToProp,
331 anEvent->relatedTo()->uid().local8Bit()); 331 anEvent->relatedToUid().local8Bit());
332 } 332 }
333 333
334 // categories 334 // categories
335 QStringList tmpStrList = anEvent->categories(); 335 QStringList tmpStrList = anEvent->categories();
336 tmpStr = ""; 336 tmpStr = "";
337 QString catStr; 337 QString catStr;
338 for ( QStringList::Iterator it = tmpStrList.begin(); 338 for ( QStringList::Iterator it = tmpStrList.begin();
339 it != tmpStrList.end(); 339 it != tmpStrList.end();
340 ++it ) { 340 ++it ) {
341 catStr = *it; 341 catStr = *it;
342 if (catStr[0] == ' ') 342 if (catStr[0] == ' ')
343 tmpStr += catStr.mid(1); 343 tmpStr += catStr.mid(1);
344 else 344 else
345 tmpStr += catStr; 345 tmpStr += catStr;
346 // this must be a ';' character as the vCalendar specification requires! 346 // this must be a ';' character as the vCalendar specification requires!
347 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 347 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
348 // read in. 348 // read in.
349 tmpStr += ";"; 349 tmpStr += ";";
350 } 350 }
351 if (!tmpStr.isEmpty()) { 351 if (!tmpStr.isEmpty()) {
352 tmpStr.truncate(tmpStr.length()-1); 352 tmpStr.truncate(tmpStr.length()-1);
353 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); 353 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit());
354 } 354 }
355 355
@@ -651,51 +651,51 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent)
651 if (alarm->type() == Alarm::Procedure) { 651 if (alarm->type() == Alarm::Procedure) {
652 a = addProp(vevent, VCPAlarmProp); 652 a = addProp(vevent, VCPAlarmProp);
653 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 653 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
654 addPropValue(a, VCRepeatCountProp, "1"); 654 addPropValue(a, VCRepeatCountProp, "1");
655 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 655 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
656 } else { 656 } else {
657 a = addProp(vevent, VCDAlarmProp); 657 a = addProp(vevent, VCDAlarmProp);
658 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 658 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
659 addPropValue(a, VCRepeatCountProp, "1"); 659 addPropValue(a, VCRepeatCountProp, "1");
660 addPropValue(a, VCDisplayStringProp, "beep!"); 660 addPropValue(a, VCDisplayStringProp, "beep!");
661 661
662 } 662 }
663 } 663 }
664 } 664 }
665 665
666 // priority 666 // priority
667 tmpStr.sprintf("%i",anEvent->priority()); 667 tmpStr.sprintf("%i",anEvent->priority());
668 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); 668 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit());
669 669
670 // transparency 670 // transparency
671 tmpStr.sprintf("%i",anEvent->transparency()); 671 tmpStr.sprintf("%i",anEvent->transparency());
672 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); 672 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit());
673 673
674 // related event 674 // related event
675 if (anEvent->relatedTo()) { 675 if (anEvent->relatedToUid()) {
676 addPropValue(vevent, VCRelatedToProp, 676 addPropValue(vevent, VCRelatedToProp,
677 anEvent->relatedTo()->uid().local8Bit()); 677 anEvent->relatedToUid().local8Bit());
678 } 678 }
679 679
680 if (anEvent->pilotId()) { 680 if (anEvent->pilotId()) {
681 // pilot sync stuff 681 // pilot sync stuff
682 tmpStr.sprintf("%i",anEvent->pilotId()); 682 tmpStr.sprintf("%i",anEvent->pilotId());
683 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); 683 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit());
684 tmpStr.sprintf("%i",anEvent->syncStatus()); 684 tmpStr.sprintf("%i",anEvent->syncStatus());
685 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); 685 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit());
686 } 686 }
687 687
688 return vevent; 688 return vevent;
689} 689}
690 690
691Todo *VCalFormat::VTodoToEvent(VObject *vtodo) 691Todo *VCalFormat::VTodoToEvent(VObject *vtodo)
692{ 692{
693 VObject *vo; 693 VObject *vo;
694 VObjectIterator voi; 694 VObjectIterator voi;
695 char *s; 695 char *s;
696 696
697 Todo *anEvent = new Todo; 697 Todo *anEvent = new Todo;
698 698
699 // creation date 699 // creation date
700 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { 700 if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) {
701 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); 701 anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))));
@@ -1583,53 +1583,57 @@ void VCalFormat::populate(VObject *vcal)
1583 } 1583 }
1584 } else { 1584 } else {
1585 // some sort of error must have occurred while in translation. 1585 // some sort of error must have occurred while in translation.
1586 goto SKIP; 1586 goto SKIP;
1587 } 1587 }
1588 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { 1588 } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) {
1589 Todo *aTodo = VTodoToEvent(curVO); 1589 Todo *aTodo = VTodoToEvent(curVO);
1590 mCalendar->addTodo(aTodo); 1590 mCalendar->addTodo(aTodo);
1591 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || 1591 } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) ||
1592 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || 1592 (strcmp(vObjectName(curVO), VCProdIdProp) == 0) ||
1593 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { 1593 (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) {
1594 // do nothing, we know these properties and we want to skip them. 1594 // do nothing, we know these properties and we want to skip them.
1595 // we have either already processed them or are ignoring them. 1595 // we have either already processed them or are ignoring them.
1596 ; 1596 ;
1597 } else { 1597 } else {
1598 kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; 1598 kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl;
1599 } 1599 }
1600 SKIP: 1600 SKIP:
1601 ; 1601 ;
1602 } // while 1602 } // while
1603 1603
1604 // Post-Process list of events with relations, put Event objects in relation 1604 // Post-Process list of events with relations, put Event objects in relation
1605 Event *ev; 1605 Event *ev;
1606 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { 1606 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) {
1607 ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); 1607 Incidence * inc = mCalendar->event(ev->relatedToUid());
1608 if ( inc )
1609 ev->setRelatedTo( inc );
1608 } 1610 }
1609 Todo *todo; 1611 Todo *todo;
1610 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { 1612 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) {
1611 todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); 1613 Incidence * inc = mCalendar->todo(todo->relatedToUid());
1614 if ( inc )
1615 todo->setRelatedTo( inc );
1612 } 1616 }
1613} 1617}
1614 1618
1615const char *VCalFormat::dayFromNum(int day) 1619const char *VCalFormat::dayFromNum(int day)
1616{ 1620{
1617 const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; 1621 const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " };
1618 1622
1619 return days[day]; 1623 return days[day];
1620} 1624}
1621 1625
1622int VCalFormat::numFromDay(const QString &day) 1626int VCalFormat::numFromDay(const QString &day)
1623{ 1627{
1624 if (day == "MO ") return 0; 1628 if (day == "MO ") return 0;
1625 if (day == "TU ") return 1; 1629 if (day == "TU ") return 1;
1626 if (day == "WE ") return 2; 1630 if (day == "WE ") return 2;
1627 if (day == "TH ") return 3; 1631 if (day == "TH ") return 3;
1628 if (day == "FR ") return 4; 1632 if (day == "FR ") return 4;
1629 if (day == "SA ") return 5; 1633 if (day == "SA ") return 5;
1630 if (day == "SU ") return 6; 1634 if (day == "SU ") return 6;
1631 1635
1632 return -1; // something bad happened. :) 1636 return -1; // something bad happened. :)
1633} 1637}
1634Attendee::Role VCalFormat::readRole(const char *s) const 1638Attendee::Role VCalFormat::readRole(const char *s) const
1635{ 1639{