summaryrefslogtreecommitdiffabout
path: root/libkcal/vcalformat.cpp
authorzautrix <zautrix>2004-10-25 15:27:39 (UTC)
committer zautrix <zautrix>2004-10-25 15:27:39 (UTC)
commit03ca6830a9e6742b8873aee04d77b3e094b65d30 (patch) (unidiff)
tree170ab278ffeb371aae783815101f64275cd30c53 /libkcal/vcalformat.cpp
parent62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3 (diff)
downloadkdepimpi-03ca6830a9e6742b8873aee04d77b3e094b65d30.zip
kdepimpi-03ca6830a9e6742b8873aee04d77b3e094b65d30.tar.gz
kdepimpi-03ca6830a9e6742b8873aee04d77b3e094b65d30.tar.bz2
fix of vcal crash
Diffstat (limited to 'libkcal/vcalformat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/vcalformat.cpp39
1 files changed, 33 insertions, 6 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index df93209..223aa5a 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -284,16 +284,17 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
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,
@@ -447,17 +448,18 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent)
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;
@@ -746,20 +748,22 @@ Todo *VCalFormat::VTodoToEvent(VObject *vtodo)
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);
@@ -972,20 +976,25 @@ Event* VCalFormat::VEventToEvent(VObject *vevent)
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);
@@ -1653,17 +1662,35 @@ int VCalFormat::numFromDay(const QString &day)
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}
1670Attendee::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
1683QCString VCalFormat::writeRole(Attendee::Role role) const
1684{
1685 if ( role == Attendee::Chair )
1686 return "OWNER";
1687 return "ATTENDEE";
1688}
1662Attendee::PartStat VCalFormat::readStatus(const char *s) const 1689Attendee::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;