Completed the first two filter tests.
[citadel.git] / webcit-ng / server / caldav_reports.c
index d93088076b8ba8a4296afb4da36ba68796213fbd..ef9072829d65d070f56a543e909ffe163db2543b 100644 (file)
@@ -296,10 +296,27 @@ int caldav_apply_filters(void *cal, Array *filters) {
                // Handle the individual filters defined in RFC4791 9.7.1 through 9.7.5
 
                if (!strcasecmp(t[1], "comp-filter")) {                         // RFC4791 9.7.1 - filter by component
-                       syslog(LOG_DEBUG, "component filter at level %d FIXME not implemented yet", level);
-                       if (icalcomponent_isa_component(cal)) {
-                               // yes this is a component
+                       syslog(LOG_DEBUG, "component filter at level %d", level);
+
+                       // Root element is NOT a component, but the root filter is "comp-filter" -- reject!
+                       if ( (!icalcomponent_isa_component(cal)) && (level == 0) ) {
+                               syslog(LOG_DEBUG, "caldav: root element is not a component, rejecting");
+                               return(0);
                        }
+
+                       // Root element IS a component and the root 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: root component is <%s>, looking for <%s>, rejecting",
+                                               icalcomponent_kind_to_string(icalcomponent_isa(cal)), t[3]
+                                       );
+                                       return(0);
+                               }
+                       }
+
                }
 
                else if (!strcasecmp(t[1], "prop-filter")) {                    // RFC4791 9.7.2 - filter by property