184 |
184 |
185 DavNamespace* dav_get_namespace_s(DavContext *context, sstr_t prefix) { |
185 DavNamespace* dav_get_namespace_s(DavContext *context, sstr_t prefix) { |
186 return ucx_map_sstr_get(context->namespaces, prefix); |
186 return ucx_map_sstr_get(context->namespaces, prefix); |
187 } |
187 } |
188 |
188 |
|
189 int dav_enable_namespace_encryption(DavContext *context, const char *ns, DavBool encrypt) { |
|
190 DavNSInfo *info = ucx_map_cstr_get(context->namespaceinfo, ns); |
|
191 if(!info) { |
|
192 info = calloc(1, sizeof(DavNSInfo)); |
|
193 info->encrypt = encrypt; |
|
194 ucx_map_cstr_put(context->namespaceinfo, ns, info); |
|
195 } else { |
|
196 info->encrypt = encrypt; |
|
197 } |
|
198 return 0; |
|
199 } |
|
200 |
|
201 int dav_namespace_is_encrypted(DavContext *context, const char *ns) { |
|
202 DavNSInfo *info = ucx_map_cstr_get(context->namespaceinfo, ns); |
|
203 if(info) { |
|
204 return info->encrypt; |
|
205 } |
|
206 return 0; |
|
207 } |
|
208 |
189 void dav_get_property_namespace_str( |
209 void dav_get_property_namespace_str( |
190 DavContext *ctx, |
210 DavContext *ctx, |
191 char *prefixed_name, |
211 char *prefixed_name, |
192 char **ns, |
212 char **ns, |
193 char **name) |
213 char **name) |
299 |
319 |
300 |
320 |
301 int dav_propfind(DavSession *sn, DavResource *root, UcxBuffer *rqbuf) { |
321 int dav_propfind(DavSession *sn, DavResource *root, UcxBuffer *rqbuf) { |
302 // clean resource properties |
322 // clean resource properties |
303 DavResourceData *data = root->data; |
323 DavResourceData *data = root->data; |
304 ucx_map_clear(data->properties); |
324 ucx_map_clear(data->properties); // TODO: free existing content |
305 |
325 |
306 CURL *handle = sn->handle; |
326 CURL *handle = sn->handle; |
307 util_set_url(sn, dav_resource_get_href(root)); |
327 util_set_url(sn, dav_resource_get_href(root)); |
308 |
328 |
309 UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); |
329 UcxBuffer *rpbuf = ucx_buffer_new(NULL, 4096, UCX_BUFFER_AUTOEXTEND); |
313 long error = 0; |
333 long error = 0; |
314 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
334 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status); |
315 if(ret == CURLE_OK && status == 207) { |
335 if(ret == CURLE_OK && status == 207) { |
316 //printf("response\n%s\n", rpbuf->space); |
336 //printf("response\n%s\n", rpbuf->space); |
317 dav_set_effective_href(sn, resource); |
337 dav_set_effective_href(sn, resource); |
|
338 // TODO: use PropfindParser |
318 resource = parse_propfind_response(sn, resource, rpbuf); |
339 resource = parse_propfind_response(sn, resource, rpbuf); |
319 sn->error = DAV_OK; |
340 sn->error = DAV_OK; |
320 root->exists = 1; |
341 root->exists = 1; |
321 } else { |
342 } else { |
322 dav_session_set_error(sn, ret, status); |
343 dav_session_set_error(sn, ret, status); |