summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2004-10-25 15:27:39 (UTC)
committer zautrix <zautrix>2004-10-25 15:27:39 (UTC)
commit03ca6830a9e6742b8873aee04d77b3e094b65d30 (patch) (side-by-side diff)
tree170ab278ffeb371aae783815101f64275cd30c53 /libkcal
parent62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3 (diff)
downloadkdepimpi-03ca6830a9e6742b8873aee04d77b3e094b65d30.zip
kdepimpi-03ca6830a9e6742b8873aee04d77b3e094b65d30.tar.gz
kdepimpi-03ca6830a9e6742b8873aee04d77b3e094b65d30.tar.bz2
fix of vcal crash
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/vcalformat.cpp39
-rw-r--r--libkcal/vcalformat.h3
-rw-r--r--libkcal/versit/vcc.c3
3 files changed, 37 insertions, 8 deletions
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index df93209..223aa5a 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -284,16 +284,17 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
else if (curAttendee->name().isEmpty())
tmpStr = "MAILTO: " + curAttendee->email();
else if (curAttendee->email().isEmpty())
tmpStr = "MAILTO: " + curAttendee->name();
else if (curAttendee->name().isEmpty() &&
curAttendee->email().isEmpty())
kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit());
+ addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role()));
addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
}
}
// description BL:
if (!anEvent->description().isEmpty()) {
VObject *d = addPropValue(vtodo, VCDescriptionProp,
@@ -447,17 +448,18 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent)
else if (curAttendee->name().isEmpty())
tmpStr = "MAILTO: " + curAttendee->email();
else if (curAttendee->email().isEmpty())
tmpStr = "MAILTO: " + curAttendee->name();
else if (curAttendee->name().isEmpty() &&
curAttendee->email().isEmpty())
kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit());
- addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");;
+ addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role()));
+ addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
}
}
// recurrence rule stuff
if (anEvent->recurrence()->doesRecur()) {
// some more variables
QPtrList<Recurrence::rMonthPos> tmpPositions;
@@ -746,20 +748,22 @@ Todo *VCalFormat::VTodoToEvent(VObject *vtodo)
a = new Attendee(tmpStr.left(emailPos1 - 1),
tmpStr.mid(emailPos1 + 1,
emailPos2 - (emailPos1 + 1)));
} else if (tmpStr.find('@') > 0) {
// just an email address
a = new Attendee(0, tmpStr);
} else {
// just a name
- QString email = tmpStr.replace( QRegExp(" "), "." );
- a = new Attendee(tmpStr,email);
+ // QString email = tmpStr.replace( QRegExp(" "), "." );
+ a = new Attendee(tmpStr,0);
}
-
+ // is there a Role property?
+ if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0)
+ a->setRole(readRole(vObjectStringZValue(vp)));
// is there an RSVP property?
if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0)
a->setRSVP(vObjectStringZValue(vp));
// is there a status property?
if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0)
a->setStatus(readStatus(vObjectStringZValue(vp)));
// add the attendee
anEvent->addAttendee(a);
@@ -972,20 +976,25 @@ Event* VCalFormat::VEventToEvent(VObject *vevent)
a = new Attendee(tmpStr.left(emailPos1 - 1),
tmpStr.mid(emailPos1 + 1,
emailPos2 - (emailPos1 + 1)));
} else if (tmpStr.find('@') > 0) {
// just an email address
a = new Attendee(0, tmpStr);
} else {
// just a name
- QString email = tmpStr.replace( QRegExp(" "), "." );
- a = new Attendee(tmpStr,email);
+ //QString email = tmpStr.replace( QRegExp(" "), "." );
+ a = new Attendee(tmpStr,0);
}
+
+ // is there a Role property?
+ if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0)
+ a->setRole(readRole(vObjectStringZValue(vp)));
+
// is there an RSVP property?
if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0)
a->setRSVP(vObjectStringZValue(vp));
// is there a status property?
if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0)
a->setStatus(readStatus(vObjectStringZValue(vp)));
// add the attendee
anEvent->addAttendee(a);
@@ -1653,17 +1662,35 @@ int VCalFormat::numFromDay(const QString &day)
if (day == "WE ") return 2;
if (day == "TH ") return 3;
if (day == "FR ") return 4;
if (day == "SA ") return 5;
if (day == "SU ") return 6;
return -1; // something bad happened. :)
}
+Attendee::Role VCalFormat::readRole(const char *s) const
+{
+ QString statStr = s;
+ statStr = statStr.upper();
+ Attendee::Role role = Attendee::ReqParticipant;
+
+ if ( statStr == "OWNER")
+ role = Attendee::Chair;
+ // enum Role { ReqParticipant, OptParticipant, NonParticipant, Chair };
+
+ return role;
+}
+QCString VCalFormat::writeRole(Attendee::Role role) const
+{
+ if ( role == Attendee::Chair )
+ return "OWNER";
+ return "ATTENDEE";
+}
Attendee::PartStat VCalFormat::readStatus(const char *s) const
{
QString statStr = s;
statStr = statStr.upper();
Attendee::PartStat status;
if (statStr == "X-ACTION")
status = Attendee::NeedsAction;
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h
index 5bef7ed..c7df017 100644
--- a/libkcal/vcalformat.h
+++ b/libkcal/vcalformat.h
@@ -90,17 +90,18 @@ class VCalFormat : public CalFormat {
* the "event" property into the dictionary, todos in the todo-list, etc. */
void populate(VObject *vcal);
/** takes a number 0 - 6 and returns the two letter string of that day,
* i.e. MO, TU, WE, etc. */
const char *dayFromNum(int day);
/** the reverse of the above function. */
int numFromDay(const QString &day);
-
+ Attendee::Role VCalFormat::readRole(const char *s) const;
+ QCString writeRole(Attendee::Role role) const;
Attendee::PartStat readStatus(const char *s) const;
QCString writeStatus(Attendee::PartStat status) const;
private:
Calendar *mCalendar;
bool useLocalTime;
QPtrList<Event> mEventsRelate; // events with relations
diff --git a/libkcal/versit/vcc.c b/libkcal/versit/vcc.c
index 9be752d..5413813 100644
--- a/libkcal/versit/vcc.c
+++ b/libkcal/versit/vcc.c
@@ -1757,17 +1757,18 @@ static void lexSkipWhite() {
}
}
static char* lexGetWord() {
int c;
lexSkipWhite();
lexClearToken();
c = lexLookahead();
- while (c != EOF && !strchr("\t\n ;:=",c)) {
+ // LR while (c != EOF && !strchr("\t\n ;:=",c)) {
+ while (c != EOF && !strchr("\t\n;:=",c)) {
lexAppendc(c);
lexSkipLookahead();
c = lexLookahead();
}
lexAppendc(0);
return lexStr();
}