X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit-ng%2Fserver%2Fcaldav_reports.c;h=76a0ee43d1438a9c65999552254827f3b752d6b9;hb=747c2d11b3641e4dc4cc0033e96bb0266e074446;hp=ef9072829d65d070f56a543e909ffe163db2543b;hpb=ff8b822cefb034b780dc3c8b1f2c679191a168d9;p=citadel.git diff --git a/webcit-ng/server/caldav_reports.c b/webcit-ng/server/caldav_reports.c index ef9072829..76a0ee43d 100644 --- a/webcit-ng/server/caldav_reports.c +++ b/webcit-ng/server/caldav_reports.c @@ -274,10 +274,11 @@ void caldav_report_one_item(struct http_transaction *h, struct ctdlsession *c, S // Recursive function to apply CalDAV FILTERS to a calendar item. // Returns zero if the calendar item was disqualified by a filter, nonzero if the calendar item still qualifies. -int caldav_apply_filters(void *cal, Array *filters) { +int caldav_apply_filters(void *cal, Array *filters, int start_at_level) { int f = 0; // filter number iterator int qual = 1; // 0 for disqualify, 1 for qualify + int previous_level = -1; while ( (f, looking for <%s>, rejecting", + if (icalcomponent_isa(cal) == icalcomponent_string_to_kind(t[3]) ) { + syslog(LOG_DEBUG, "caldav: component at level %d is <%s>, looking for <%s>, recursing...", + start_at_level, icalcomponent_kind_to_string(icalcomponent_isa(cal)), t[3] ); + + // We have a match. Drill down into the subcomponents. + + icalcomponent *c = NULL; + int number_of_subcomponents = 0; + int number_of_matches = 0; + for ( c = icalcomponent_get_first_component(cal, ICAL_ANY_COMPONENT); + (c != 0); + c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT) + ) { + ++number_of_subcomponents; + if (caldav_apply_filters(c, filters, level+1)) { + syslog(LOG_DEBUG, "Subcomponent %d might match", number_of_subcomponents); + ++number_of_matches; + } + } + if (number_of_matches > 0) { // something matched + qual = 1; + } + else if (number_of_subcomponents > 0) { // nothing matched + return(0); // but only fail if there *were* subcomponents. + } + + } + else { + syslog(LOG_DEBUG, "caldav: component at level %d is <%s>, looking for <%s>, rejecting", + start_at_level, + icalcomponent_kind_to_string(icalcomponent_isa(cal)), + t[3] + ); return(0); } } @@ -338,6 +379,7 @@ int caldav_apply_filters(void *cal, Array *filters) { ++f; } + syslog(LOG_DEBUG, "caldav: we reached the end of level %d , returning %d", start_at_level, qual); return(qual); } @@ -404,7 +446,7 @@ void caldav_report(struct http_transaction *h, struct ctdlsession *c) { // If there was a filter stanza, run this calendar item through the filters. syslog(LOG_DEBUG, "Evaluating message \033[33m%ld\033[0m...", m); - qualify = caldav_apply_filters(cal, crp.filters); + qualify = caldav_apply_filters(cal, crp.filters, 0); syslog(LOG_DEBUG, "Message %ld %s\033[0m qualify", m, (qualify ? "\033[32mDOES" : "\033[31mDOES NOT")); syslog(LOG_DEBUG, "");