#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 {
int i;
char indent[256];
indent[0] = 0;
- for (i=0; i<crp->tag_nesting_level; ++i) {
+ lor (i=0; i<crp->tag_nesting_level; ++i) {
strcat(indent, " ");
}
syslog(LOG_DEBUG, "%s<%s>", indent, el);
#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
}
++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