From: Art Cancro Date: Wed, 21 Feb 2024 04:43:13 +0000 (-0500) Subject: Shorthand for the XML namespace X-Git-Tag: v999~42 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=ab43dc8da7d977206827b0f7a5ebcbbbedb2d557 Shorthand for the XML namespace --- diff --git a/webcit-ng/server/caldav_reports.c b/webcit-ng/server/caldav_reports.c index 514885766..9c0fe32a0 100644 --- a/webcit-ng/server/caldav_reports.c +++ b/webcit-ng/server/caldav_reports.c @@ -4,6 +4,9 @@ #include "webcit.h" +// Shorthand for the XML namespace of CalDAV +#define CAL "urn:ietf:params:xml:ns:caldav:" +#define CALLEN sizeof(CAL)-1 // A CalDAV REPORT can only be one type. This is stored in the report_type member. enum cr_type { @@ -34,7 +37,7 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { int i; char indent[256]; indent[0] = 0; - for (i=0; itag_nesting_level; ++i) { + lor (i=0; itag_nesting_level; ++i) { strcat(indent, " "); } syslog(LOG_DEBUG, "%s<%s>", indent, el); @@ -50,37 +53,37 @@ void caldav_xml_start(void *data, const char *el, const char **attr) { #endif // RFC4791 7.8 "calendar-query" REPORT - Client will send a lot of search criteria. - if (!strcasecmp(el, "urn:ietf:params:xml:ns:caldav:calendar-query")) { + if (!strcasecmp(el, CAL"calendar-query")) { crp->report_type = cr_calendar_query; } // RFC4791 7.9 "calendar-multiget" REPORT - Client will supply a list of specific hrefs. - else if (!strcasecmp(el, "urn:ietf:params:xml:ns:caldav:calendar-multiget")) { + else if (!strcasecmp(el, CAL"calendar-multiget")) { crp->report_type = cr_calendar_multiget; } // RFC4791 7.10 "free-busy-query" REPORT - else if (!strcasecmp(el, "urn:ietf:params:xml:ns:caldav:free-busy-query")) { + else if (!strcasecmp(el, CAL"free-busy-query")) { crp->report_type = cr_freebusy_query; } - // RFC4791 9.7 create a filter array if this query contains a "CALDAV:filter" stanza - else if (!strcasecmp(el, "urn:ietf:params:xml:ns:caldav:filter")) { + // RFC4791 9.7 create a filter array if this query contains a "filter" stanza + else if (!strcasecmp(el, CAL"filter")) { crp->filters = array_new(SIZ); } // Handle the filters defined in RFC4791 9.7.1 through 9.7.5 - else if ( ( (!strcasecmp(el, "urn:ietf:params:xml:ns:caldav:comp-filter")) - || (!strcasecmp(el, "urn:ietf:params:xml:ns:caldav:prop-filter")) - || (!strcasecmp(el, "urn:ietf:params:xml:ns:caldav:param-filter")) - || (!strcasecmp(el, "urn:ietf:params:xml:ns:caldav:is-not-defined")) - || (!strcasecmp(el, "urn:ietf:params:xml:ns:caldav:text-match")) + else if ( ( (!strcasecmp(el, CAL"comp-filter")) + || (!strcasecmp(el, CAL"prop-filter")) + || (!strcasecmp(el, CAL"param-filter")) + || (!strcasecmp(el, CAL"is-not-defined")) + || (!strcasecmp(el, CAL"text-match")) ) && (crp->filters) // Make sure we actually allocated an array ) { char newfilter[SIZ]; int a = 0; - int len = snprintf(newfilter, SIZ, &el[30]); // strip off "urn:ietf:params:xml:ns:caldav:" for our purposes + int len = snprintf(newfilter, SIZ, &el[CALLEN]); // strip off the namespace for our purposes while (attr[a]) { len += snprintf(&newfilter[len], SIZ-len, "|%s", attr[a++]); // now save the attributes } @@ -280,10 +283,24 @@ int caldav_apply_one_filter(void *cal, char *filter) { ++num_tokens; } + // BEGIN experimental block -- see what happens when we cast to the wrong type + + //icalcomponent *foo_comp = (icalcomponent *) cal; + //icalproperty *foo_prop = (icalproperty *) cal; + //icalparameter *foo_param = (icalparameter *) cal; + + // END experimental block + // Handle the individual filters defined in RFC4791 9.7.1 through 9.7.5 if (!strcasecmp(t[0], "comp-filter")) { // RFC4791 9.7.1 - filter by component syslog(LOG_DEBUG, "component filter FIXME not implemented yet"); + if (icalcomponent_isa_component(cal)) { + syslog(LOG_DEBUG, "\033[32m yes this is a component \033[0m"); + } + else { + syslog(LOG_DEBUG, "\033[31m no this is not a component \033[0m"); + } } else if (!strcasecmp(t[0], "prop-filter")) { // RFC4791 9.7.2 - filter by property