X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fical_subst.c;h=ffacf41f471a3016e5dd818b45d14cdbd24614c0;hb=97bdaff4147703998a868ed6d19232c4342acca4;hp=43a10f2eb503cbbb336425ec0d7b0de1b43fc7f5;hpb=6cc8e02c78fa3b6e46f447396cda18f190f3d0d1;p=citadel.git diff --git a/webcit/ical_subst.c b/webcit/ical_subst.c index 43a10f2eb..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) { @@ -265,14 +266,16 @@ void tmplput_CtxICalPropertyDate(StrBuf *Target, WCTemplputParams *TP) -void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset) +void render_MIME_ICS_TPL(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset) { + wc_mime_attachment *Mime = CTX(CTX_MIME_ATACH); icalproperty_method the_method = ICAL_METHOD_NONE; icalproperty *method = NULL; icalcomponent *cal; icalcomponent *c; WCTemplputParams SubTP; WCTemplputParams SuperTP; + static int divcount = 0; if (StrLength(Mime->Data) == 0) { @@ -288,6 +291,8 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun } putlbstr("divname", ++divcount); + + putbstr("cal_partnum", NewStrBufDup(Mime->PartNum)); putlbstr("msgnum", Mime->msgnum); @@ -305,8 +310,12 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun the_method = icalproperty_get_method(method); } - SuperTP.Context = &the_method; - SuperTP.Filter.ContextType = CTX_ICALMETHOD, + StackContext (TP, + &SuperTP, + &the_method, + CTX_ICALMETHOD, + 0, + TP->Tokens); StackContext (&SuperTP, &SubTP, @@ -327,6 +336,7 @@ void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun "EnableOrDisableCheckButton(); \n" ); + UnStackContext(&SuperTP); UnStackContext(&SubTP); icalcomponent_free(cal); } @@ -368,40 +378,65 @@ 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); @@ -410,8 +445,6 @@ HashList* IterateGetAttendees() cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum); } */ -} - void @@ -430,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);