After finally getting to the point where we are recursing up
through both the nested components and the nested queries in a
way that matches them properly, we are now able to start writing
the individual property and parameter queries defined in the RFC.
time-range (section 9.9) is the obvious first choice to implement
because it is the most useful. Wrote and bound the skeleton
function to do this.
+// Compare function for "time-range" tests (RFC4791 section 9.9)
+// Returns nonzero if the supplied icalcomponent occurs within the specified time range
+int caldav_time_range_filter_matches(icalcomponent *cal, char *start, char *end) {
+
+ TRACE;
+ syslog(LOG_DEBUG, "Does this %s fall between %s and %s ?",
+ icalcomponent_kind_to_string(icalcomponent_isa(cal)),
+ start,
+ end
+ );
+
+ return(1);
+}
+
+
// 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 apply_at_level) {
// 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 apply_at_level) {
syslog(LOG_DEBUG, "text match filter at level %d FIXME not implemented yet", this_rule_level);
}
syslog(LOG_DEBUG, "text match filter at level %d FIXME not implemented yet", this_rule_level);
}
- else if (!strcasecmp(t[1], "time-range")) {
+ else if (!strcasecmp(t[1], "time-range")) { // RFC4791 9.9
syslog(LOG_DEBUG, "time range filter at level %d FIXME not implemented yet", this_rule_level);
syslog(LOG_DEBUG, "time range filter at level %d FIXME not implemented yet", this_rule_level);
- for (int i=0; i<num_tokens; ++i) {
- syslog(LOG_DEBUG, "token %2d : <%s>", i, t[i]);
+ for (int i=2; (i+1)<num_tokens; i+=2) {
+ char *tr_start = NULL;
+ char *tr_end = NULL;
+ if (!strcasecmp(t[i], "start")) {
+ tr_start = t[i+1];
+ }
+ else if (!strcasecmp(t[i], "end")) {
+ tr_end = t[i+1];
+ }
+ if (caldav_time_range_filter_matches(cal, tr_start, tr_end)) {
+ syslog(LOG_DEBUG, "time range matches");
+ }
+ else {
+ syslog(LOG_DEBUG, "time range does not match -- rejecting");
+ qual = 0;
+ }