128 |
128 |
129 s = S("<D:propfind xmlns:D=\"DAV:\">\n"); |
129 s = S("<D:propfind xmlns:D=\"DAV:\">\n"); |
130 ucx_buffer_write(s.ptr, 1, s.length, buf); |
130 ucx_buffer_write(s.ptr, 1, s.length, buf); |
131 |
131 |
132 s = S("<D:allprop/></D:propfind>\n"); |
132 s = S("<D:allprop/></D:propfind>\n"); |
|
133 ucx_buffer_write(s.ptr, 1, s.length, buf); |
|
134 |
|
135 return buf; |
|
136 } |
|
137 |
|
138 UcxBuffer* create_cryptoprop_propfind_request(void) { |
|
139 UcxBuffer *buf = ucx_buffer_new(NULL, 256, UCX_BUFFER_AUTOFREE); |
|
140 scstr_t s; |
|
141 |
|
142 s = SC("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
|
143 ucx_buffer_write(s.ptr, 1, s.length, buf); |
|
144 |
|
145 s = SC("<D:propfind xmlns:D=\"DAV:\" xmlns:idav=\"" DAV_NS "\">\n"); |
|
146 ucx_buffer_write(s.ptr, 1, s.length, buf); |
|
147 |
|
148 s = SC("<D:prop><idav:crypto-prop/></D:prop></D:propfind>\n"); |
133 ucx_buffer_write(s.ptr, 1, s.length, buf); |
149 ucx_buffer_write(s.ptr, 1, s.length, buf); |
134 |
150 |
135 return buf; |
151 return buf; |
136 } |
152 } |
137 |
153 |
532 } |
548 } |
533 |
549 |
534 void add_properties(DavResource *res, ResponseTag *response) { |
550 void add_properties(DavResource *res, ResponseTag *response) { |
535 res->iscollection = response->iscollection; |
551 res->iscollection = response->iscollection; |
536 |
552 |
|
553 int decrypt_props = DAV_ENCRYPT_PROPERTIES(res->session); |
|
554 xmlNode *crypto_prop = NULL; |
|
555 char *crypto_key = NULL; |
|
556 |
537 // add properties |
557 // add properties |
538 UCX_FOREACH(elm, response->properties) { |
558 UCX_FOREACH(elm, response->properties) { |
539 xmlNode *prop = elm->data; |
559 xmlNode *prop = elm->data; |
540 resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, prop->children); |
560 resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, prop->children); |
|
561 |
|
562 if (decrypt_props && |
|
563 prop->children && |
|
564 prop->children->type == XML_TEXT_NODE && |
|
565 xstreq(prop->ns->href, DAV_NS)) |
|
566 { |
|
567 if(xstreq(prop->name, "crypto-prop")) { |
|
568 crypto_prop = prop; |
|
569 } else if(xstreq(prop->name, "crypto-key")) { |
|
570 crypto_key = util_xml_get_text(prop); |
|
571 } |
|
572 } |
|
573 } |
|
574 |
|
575 if(crypto_prop && crypto_key) { |
|
576 char *crypto_prop_content = util_xml_get_text(crypto_prop); |
|
577 DavKey *key = dav_context_get_key(res->session->context, crypto_key); |
|
578 if(crypto_prop_content) { |
|
579 UcxMap *cprops = parse_crypto_prop_str(res->session, key, crypto_prop_content); |
|
580 resource_set_crypto_properties(res, cprops); |
|
581 } |
541 } |
582 } |
542 |
583 |
543 set_davprops(res); |
584 set_davprops(res); |
544 } |
585 } |
545 |
586 |
665 dav_session_free(sn, name); |
706 dav_session_free(sn, name); |
666 } |
707 } |
667 res->iscollection = iscollection; |
708 res->iscollection = iscollection; |
668 |
709 |
669 // add properties |
710 // add properties |
|
711 int decrypt_props = DAV_ENCRYPT_PROPERTIES(res->session); |
|
712 xmlNode *crypto_prop = NULL; |
|
713 |
670 UCX_FOREACH(elm, properties) { |
714 UCX_FOREACH(elm, properties) { |
671 xmlNode *prop = elm->data; |
715 xmlNode *prop = elm->data; |
672 resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, prop->children); |
716 resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, prop->children); |
|
717 |
|
718 if (decrypt_props && |
|
719 prop->children && |
|
720 prop->children->type == XML_TEXT_NODE && |
|
721 xstreq(prop->ns->href, DAV_NS)) |
|
722 { |
|
723 if(xstreq(prop->name, "crypto-prop")) { |
|
724 crypto_prop = prop; |
|
725 } |
|
726 } |
673 } |
727 } |
674 ucx_list_free(properties); |
728 ucx_list_free(properties); |
|
729 |
|
730 if(crypto_prop && crypto_key) { |
|
731 char *crypto_prop_content = util_xml_get_text(crypto_prop); |
|
732 DavKey *key = dav_context_get_key(res->session->context, crypto_key); |
|
733 if(crypto_prop_content && key) { |
|
734 UcxMap *cprops = parse_crypto_prop_str(res->session, key, crypto_prop_content); |
|
735 resource_set_crypto_properties(res, cprops); |
|
736 } |
|
737 } |
|
738 |
675 |
739 |
676 set_davprops(res); |
740 set_davprops(res); |
677 if(res != resource) { |
741 if(res != resource) { |
678 resource_add_child(resource, res); |
742 resource_add_child(resource, res); |
679 } |
743 } |