From: Wilfried Goesgens Date: Sun, 28 Oct 2012 15:05:40 +0000 (+0100) Subject: ICAL: add handling for appointment attendees. X-Git-Tag: v8.20~199 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=97bdaff4147703998a868ed6d19232c4342acca4 ICAL: add handling for appointment attendees. --- diff --git a/webcit/ical_subst.c b/webcit/ical_subst.c index 428527eb4..ffacf41f4 100644 --- a/webcit/ical_subst.c +++ b/webcit/ical_subst.c @@ -20,6 +20,7 @@ CtxType CTX_ICAL = CTX_NONE; CtxType CTX_ICALPROPERTY = CTX_NONE; CtxType CTX_ICALMETHOD = CTX_NONE; CtxType CTX_ICALTIME = CTX_NONE; +CtxType CTX_ICALATTENDEE = CTX_NONE; #if 0 void SortPregetMatter(HashList *Cals) { @@ -380,33 +381,62 @@ int cond_ICalIsMethod(StrBuf *Target, WCTemplputParams *TP) void tmplput_Conflict(StrBuf *Target, WCTemplputParams *TP) {} -HashList* IterateGetAttendees() + +HashList *iterate_get_ical_attendees(StrBuf *Target, WCTemplputParams *TP) { -/* - /* If the component has attendees, iterate through them. * / + icalcomponent *cal = (icalcomponent *) CTX(CTX_ICAL); + icalparameter *partstat_param; + icalproperty *p; + CalAttendee *Att; + HashList *Attendees = NULL; + const char *ch; + int n = 0; + + /* If the component has attendees, iterate through them. */ for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY); (p != NULL); p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) { - StrBufAppendPrintf(Target, "
"); - StrBufAppendPrintf(Target, _("Attendee:")); - StrBufAppendPrintf(Target, "
"); ch = icalproperty_get_attendee(p); - if ((ch != NULL) && !strncasecmp(buf, "MAILTO:", 7)) { - - /** screen name or email address * / - safestrncpy(buf, ch + 7, sizeof(buf)); - striplt(buf); - StrEscAppend(Target, NULL, buf, 0, 0); - StrBufAppendPrintf(Target, " "); - - /** participant status * / - partstat_as_string(buf, p); - StrEscAppend(Target, NULL, buf, 0, 0); + if ((ch != NULL) && !strncasecmp(ch, "MAILTO:", 7)) { + Att = (CalAttendee*) malloc(sizeof(CalAttendee)); + + /** screen name or email address */ + Att->AttendeeStr = NewStrBufPlain(ch + 7, -1); + StrBufTrim(Att->AttendeeStr); + + /** participant status */ + partstat_param = icalproperty_get_first_parameter( + p, + ICAL_PARTSTAT_PARAMETER + ); + if (partstat_param == NULL) { + Att->partstat = ICAL_PARTSTAT_X; + } + else { + Att->partstat = icalparameter_get_partstat(partstat_param); + } + if (Attendees == NULL) + Attendees = NewHash(1, Flathash); + Put(Attendees, IKEY(n), Att, DeleteAtt); + n++; } - StrBufAppendPrintf(Target, "
\n"); } -*/ - return NULL; + return Attendees; +} + +void tmplput_ICalAttendee(StrBuf *Target, WCTemplputParams *TP) +{ + CalAttendee *Att = (CalAttendee*) CTX(CTX_ICALATTENDEE); + StrBufAppendTemplate(Target, TP, Att->AttendeeStr, 0); +} +int cond_ICalAttendeeState(StrBuf *Target, WCTemplputParams *TP) +{ + CalAttendee *Att = (CalAttendee*) CTX(CTX_ICALATTENDEE); + icalparameter_partstat which_partstat; + + which_partstat = GetTemplateTokenNumber(Target, TP, 2, ICAL_PARTSTAT_X); + return Att->partstat == which_partstat; +} /* If the component has subcomponents, recurse through them. * / for (c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT); (c != 0); @@ -415,7 +445,6 @@ HashList* IterateGetAttendees() cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum); } */ -} void @@ -434,6 +463,12 @@ InitModule_ICAL_SUBST RegisterNamespace("ICAL:SERV:CHECK:CONFLICT", 0, 0, tmplput_Conflict, NULL, CTX_ICAL); + RegisterCTX(CTX_ICALATTENDEE); + RegisterIterator("ICAL:ATTENDEES", 0, NULL, iterate_get_ical_attendees, + NULL, NULL, CTX_ICALATTENDEE, CTX_ICAL, IT_NOFLAG); + RegisterNamespace("ICAL:ATTENDEE", 1, 2, tmplput_ICalAttendee, NULL, CTX_ICALATTENDEE); + RegisterConditional("COND:ICAL:ATTENDEE", 1, cond_ICalAttendeeState, CTX_ICALATTENDEE); + RegisterCTX(CTX_ICALPROPERTY); RegisterNamespace("ICAL:ITEM", 1, 2, tmplput_ICalItem, NULL, CTX_ICAL); RegisterNamespace("ICAL:PROPERTY:STR", 0, 1, tmplput_CtxICalProperty, NULL, CTX_ICALPROPERTY); diff --git a/webcit/static/t/ical/attachment/display.html b/webcit/static/t/ical/attachment/display.html index c2654612b..24f506759 100644 --- a/webcit/static/t/ical/attachment/display.html +++ b/webcit/static/t/ical/attachment/display.html @@ -5,7 +5,6 @@    - @@ -20,53 +19,36 @@ -
- -
- - -
- + +
+
+
+ - - -
- - -
- +
+
- - -
- - +
- -
- +
- -
.
- +
.
+ +
- - + - -
-

_question"> @@ -77,11 +59,10 @@     _question','rsvp_title','','','Decline');">

- + - - +

_question" > Update to accept this reply and update your calendar.")>     @@ -89,9 +70,9 @@     _question','rsvp_title','','','Ignore');">

- + - if (recursion_level == 0) { +

 

- } + diff --git a/webcit/static/t/ical/attachment/display_attendees.html b/webcit/static/t/ical/attachment/display_attendees.html new file mode 100644 index 000000000..027292de5 --- /dev/null +++ b/webcit/static/t/ical/attachment/display_attendees.html @@ -0,0 +1,14 @@ +
+ +
+ +(x) + + + + + + + + +