libidav/methods.c

changeset 331
9ca1e4706acc
parent 315
7db4dbf4e6f9
child 354
067ea2315a8a
--- a/libidav/methods.c	Thu Oct 12 20:37:46 2017 +0200
+++ b/libidav/methods.c	Sun Oct 22 12:58:07 2017 +0200
@@ -34,6 +34,7 @@
 #include "methods.h"
 #include "crypto.h"
 #include "session.h"
+#include "xml.h"
 
 #include <ucx/utils.h>
 
@@ -107,7 +108,7 @@
     util_capture_header(handle, NULL);
     ucx_map_free_content(respheaders, free);
     ucx_map_free(respheaders);
-    
+       
     return ret;
 }
 
@@ -530,12 +531,7 @@
     // add properties
     UCX_FOREACH(elm, response->properties) {
         xmlNode *prop = elm->data;
-        
-        // TODO: add xml data instead of a string
-        char *text = util_xml_get_text(prop);
-        if(text) {
-            resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, text);
-        }
+        resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, prop->children);
     }
     
     set_davprops(res);
@@ -667,12 +663,7 @@
     // add properties
     UCX_FOREACH(elm, properties) {
         xmlNode *prop = elm->data;
-        
-        // TODO: add xml data instead of a string
-        char *text = util_xml_get_text(prop);
-        if(text) {
-            resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, text);
-        }
+        resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, prop->children);
     }
     ucx_list_free(properties);
     
@@ -685,10 +676,10 @@
 }
 
 void set_davprops(DavResource *res) {
-    char *cl = dav_get_property_ns(res, "DAV:", "getcontentlength");
-    char *ct = dav_get_property_ns(res, "DAV:", "getcontenttype");
-    char *cd = dav_get_property_ns(res, "DAV:", "creationdate");
-    char *lm = dav_get_property_ns(res, "DAV:", "getlastmodified");
+    char *cl = dav_get_string_property_ns(res, "DAV:", "getcontentlength");
+    char *ct = dav_get_string_property_ns(res, "DAV:", "getcontenttype");
+    char *cd = dav_get_string_property_ns(res, "DAV:", "creationdate");
+    char *lm = dav_get_string_property_ns(res, "DAV:", "getlastmodified");
     
     res->contenttype = ct;
     if(cl) {
@@ -807,6 +798,7 @@
                 prefix = "D";
             }
             
+            // begin tag
             s = S("<");
             ucx_buffer_write(s.ptr, 1, s.length, buf);
             s = sstr(prefix);
@@ -817,8 +809,16 @@
             ucx_buffer_write(s.ptr, 1, s.length, buf);
             s = S(">");
             ucx_buffer_write(s.ptr, 1, s.length, buf);
-            s = sstr(property->value);
-            ucx_buffer_write(s.ptr, 1, s.length, buf);
+            
+            // content
+            DavXmlNode *content = property->value;
+            if(content->type == DAV_XML_TEXT) {
+                ucx_buffer_write(content->content, 1, content->contentlength, buf);
+            } else {
+                // TODO: implement
+            }
+            
+            // end tag
             s = S("</");
             ucx_buffer_write(s.ptr, 1, s.length, buf);
             s = sstr(prefix);

mercurial