projects
/
citadel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
747c2d1
)
Refining XML rules
author
Art Cancro
<ajc@citadel.org>
Mon, 26 Feb 2024 23:00:19 +0000
(18:00 -0500)
committer
Art Cancro
<ajc@citadel.org>
Mon, 26 Feb 2024 23:00:19 +0000
(18:00 -0500)
webcit-ng/server/caldav_reports.c
patch
|
blob
|
history
diff --git
a/webcit-ng/server/caldav_reports.c
b/webcit-ng/server/caldav_reports.c
index 76a0ee43d1438a9c65999552254827f3b752d6b9..0c281efb43554c6f392f1f80f18f13705bff0b4f 100644
(file)
--- a/
webcit-ng/server/caldav_reports.c
+++ b/
webcit-ng/server/caldav_reports.c
@@
-81,6
+81,7
@@
void caldav_xml_start(void *data, const char *el, const char **attr) {
|| (!strcasecmp(el, CAL"param-filter"))
|| (!strcasecmp(el, CAL"is-not-defined"))
|| (!strcasecmp(el, CAL"text-match"))
|| (!strcasecmp(el, CAL"param-filter"))
|| (!strcasecmp(el, CAL"is-not-defined"))
|| (!strcasecmp(el, CAL"text-match"))
+ || (!strcasecmp(el, CAL"time-range"))
)
&& (crp->filters) // Make sure we actually allocated an array
) {
)
&& (crp->filters) // Make sure we actually allocated an array
) {
@@
-274,11
+275,12
@@
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.
// 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
start
_at_level) {
+int caldav_apply_filters(void *cal, Array *filters, int
apply
_at_level) {
int f = 0; // filter number iterator
int qual = 1; // 0 for disqualify, 1 for qualify
int previous_level = -1;
int f = 0; // filter number iterator
int qual = 1; // 0 for disqualify, 1 for qualify
int previous_level = -1;
+ int disregard_further_comp_filters = 0;
while ( (f<array_len(filters)) && (qual) ) {
while ( (f<array_len(filters)) && (qual) ) {
@@
-291,37
+293,38
@@
int caldav_apply_filters(void *cal, Array *filters, int start_at_level) {
while ( (t[num_tokens]=strtok_r(ft, "|", &ft)) && (num_tokens<10) ) {
++num_tokens;
}
while ( (t[num_tokens]=strtok_r(ft, "|", &ft)) && (num_tokens<10) ) {
++num_tokens;
}
- int level = atoi(t[0]);
- syslog(LOG_DEBUG, "caldav_apply_filters() filter=%d, level=%d, <%s>", f, level, array_get_element_at(filters, f) );
+ int
this_rule_
level = atoi(t[0]);
+ syslog(LOG_DEBUG, "caldav_apply_filters() filter=%d, level=%d, <%s>", f,
this_rule_
level, array_get_element_at(filters, f) );
// Handle the individual filters defined in RFC4791 9.7.1 through 9.7.5
// Handle the individual filters defined in RFC4791 9.7.1 through 9.7.5
- if (level < previous_level) {
+ if (
apply_at_
level < previous_level) {
syslog(LOG_DEBUG, "caldav: walking back down");
return(qual);
}
syslog(LOG_DEBUG, "caldav: walking back down");
return(qual);
}
- else if (
level < start
_at_level) {
- syslog(LOG_DEBUG, "caldav:
start_at_level=%d, level=%d, skipping this rule", start_at_level,
level);
+ else if (
this_rule_level != apply
_at_level) {
+ syslog(LOG_DEBUG, "caldav:
apply_at_level=%d, this_rule_level=%d, skipping this rule", apply_at_level, this_rule_
level);
}
}
- else if (!strcasecmp(t[1], "comp-filter")) { // RFC4791 9.7.1 - filter by component
- syslog(LOG_DEBUG, "component filter at level %d", level);
+ else if ( (!strcasecmp(t[1], "comp-filter"))
+ && (!disregard_further_comp_filters)
+ ) { // RFC4791 9.7.1 - filter by component
+ syslog(LOG_DEBUG, "component filter at level %d", this_rule_level);
// Root element is NOT a component, but the root filter is "comp-filter" -- reject!
// Root element is NOT a component, but the root filter is "comp-filter" -- reject!
- if ( (!icalcomponent_isa_component(cal)) && (level == 0) ) {
+ if ( (!icalcomponent_isa_component(cal)) && (
this_rule_
level == 0) ) {
syslog(LOG_DEBUG, "caldav: root element is not a component, rejecting");
return(0);
}
// Current element is a component and the filter is "comp-filter" -- see if it matches the requested type
if ( (icalcomponent_isa_component(cal))
syslog(LOG_DEBUG, "caldav: root element is not a component, rejecting");
return(0);
}
// Current element is a component and the filter is "comp-filter" -- see if it matches the requested type
if ( (icalcomponent_isa_component(cal))
- //&& (level == 0)
&& (!strcasecmp(t[2], "name"))
) {
if (icalcomponent_isa(cal) == icalcomponent_string_to_kind(t[3]) ) {
syslog(LOG_DEBUG, "caldav: component at level %d is <%s>, looking for <%s>, recursing...",
&& (!strcasecmp(t[2], "name"))
) {
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,
+
apply
_at_level,
icalcomponent_kind_to_string(icalcomponent_isa(cal)), t[3]
);
icalcomponent_kind_to_string(icalcomponent_isa(cal)), t[3]
);
@@
-335,13
+338,15
@@
int caldav_apply_filters(void *cal, Array *filters, int start_at_level) {
c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)
) {
++number_of_subcomponents;
c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)
) {
++number_of_subcomponents;
- if (caldav_apply_filters(c, filters, level+1)) {
+ if (caldav_apply_filters(c, filters,
apply_at_
level+1)) {
syslog(LOG_DEBUG, "Subcomponent %d might match", number_of_subcomponents);
++number_of_matches;
}
}
if (number_of_matches > 0) { // something matched
qual = 1;
syslog(LOG_DEBUG, "Subcomponent %d might match", number_of_subcomponents);
++number_of_matches;
}
}
if (number_of_matches > 0) { // something matched
qual = 1;
+ disregard_further_comp_filters = 1;
+
}
else if (number_of_subcomponents > 0) { // nothing matched
return(0); // but only fail if there *were* subcomponents.
}
else if (number_of_subcomponents > 0) { // nothing matched
return(0); // but only fail if there *were* subcomponents.
@@
-350,7
+355,7
@@
int caldav_apply_filters(void *cal, Array *filters, int start_at_level) {
}
else {
syslog(LOG_DEBUG, "caldav: component at level %d is <%s>, looking for <%s>, rejecting",
}
else {
syslog(LOG_DEBUG, "caldav: component at level %d is <%s>, looking for <%s>, rejecting",
-
start
_at_level,
+
apply
_at_level,
icalcomponent_kind_to_string(icalcomponent_isa(cal)),
t[3]
);
icalcomponent_kind_to_string(icalcomponent_isa(cal)),
t[3]
);
@@
-376,10
+381,14
@@
int caldav_apply_filters(void *cal, Array *filters, int start_at_level) {
syslog(LOG_DEBUG, "text match filter FIXME not implemented yet");
}
syslog(LOG_DEBUG, "text match filter FIXME not implemented yet");
}
+ else if (!strcasecmp(t[1], "time-range")) {
+ syslog(LOG_DEBUG, "time range filter \033[33mFIXME\033[0m not implemented yet");
+ }
+
++f;
}
++f;
}
- syslog(LOG_DEBUG, "caldav: we reached the end of level %d , returning %d",
start
_at_level, qual);
+ syslog(LOG_DEBUG, "caldav: we reached the end of level %d , returning %d",
apply
_at_level, qual);
return(qual);
}
return(qual);
}