dav/methods.c

changeset 27
e584c351b402
parent 24
a317202ae787
child 29
938957a4eea7
--- a/dav/methods.c	Tue Aug 20 11:34:44 2013 +0200
+++ b/dav/methods.c	Wed Aug 21 13:08:22 2013 +0200
@@ -32,6 +32,7 @@
 
 #include "utils.h"
 #include "methods.h"
+#include "davql.h"
 
 #define xstreq(a,b) xmlStrEqual(BAD_CAST a, BAD_CAST b)
 
@@ -150,7 +151,7 @@
     return buf;
 }
 
-DavResource* parse_propfind_response(DavSession *sn, DavResource *root, UcxBuffer *response) {
+DavResource* parse_propfind_response(DavSession *sn, DavResource *root, UcxBuffer *response, DavQOp *cond, size_t len) {
     char *url = NULL;
     curl_easy_getinfo(sn->handle, CURLINFO_EFFECTIVE_URL, &url);
     if(!root) {
@@ -169,7 +170,7 @@
     while(node) {
         if(node->type == XML_ELEMENT_NODE) {
             if(xstreq(node->name, "response")) {
-                parse_response_tag(root, node);
+                parse_response_tag(root, node, cond, len);
             }
         }
         
@@ -179,7 +180,7 @@
     return root;
 }
 
-int parse_response_tag(DavResource *resource, xmlNode *node) {
+int parse_response_tag(DavResource *resource, xmlNode *node, DavQOp *cond, size_t clen) {
     DavResource *res = resource;
     node = node->children;
     while(node) {
@@ -195,7 +196,7 @@
                     res = resource;
                 } else {
                     res = resource_new_href(resource->session, (char*)href_content->content);
-                    resource_add_child(resource, res);
+                    res->parent = resource;
                 }
             } else if(xstreq(node->name, "propstat")) {
                 xmlNode *n = node->children;
@@ -258,6 +259,15 @@
     }
     
     set_davprops(res);
+    if(res != resource) {
+        if(clen > 0) {
+            if(!condition_eval(res, cond, clen)) {
+                // skip resource
+                return 0;
+            }
+        }
+        resource_add_child(resource, res);
+    }
     
     return 0;
 }

mercurial