libidav/resource.c

changeset 181
a8f8cdbf85df
parent 178
e137883e620f
child 182
ca07f14f7bfe
equal deleted inserted replaced
180:5b58389ab9dd 181:a8f8cdbf85df
627 627
628 // store properties 628 // store properties
629 if(data->set || data->remove) { 629 if(data->set || data->remove) {
630 UcxBuffer *request = create_proppatch_request(data); 630 UcxBuffer *request = create_proppatch_request(data);
631 UcxBuffer *response = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND); 631 UcxBuffer *response = ucx_buffer_new(NULL, 1024, UCX_BUFFER_AUTOEXTEND);
632 //printf("request:\n%.*s\n\n", request->pos, request->space);
632 633
633 CURLcode ret = do_proppatch_request(sn->handle, request, response); 634 CURLcode ret = do_proppatch_request(sn->handle, request, response);
634 int status = 0; 635 int status = 0;
635 curl_easy_getinfo (sn->handle, CURLINFO_RESPONSE_CODE, &status); 636 curl_easy_getinfo (sn->handle, CURLINFO_RESPONSE_CODE, &status);
636 if(ret == CURLE_OK && status == 207) { 637 if(ret == CURLE_OK && status == 207) {
868 dav_session_set_error(sn, ret, status); 869 dav_session_set_error(sn, ret, status);
869 return 0; 870 return 0;
870 } 871 }
871 } 872 }
872 873
874 static int dav_cp_mv(DavResource *res, char *newpath, _Bool copy, _Bool override) {
875 DavSession *sn = res->session;
876 CURL *handle = sn->handle;
877 util_set_url(sn, dav_resource_get_href(res));
878
879 char *dest = dav_session_get_href(sn, newpath);
880 dav_session_free(sn, dest);
881 char *desturl = util_get_url(sn, dest);
882
883 CURLcode ret = do_copy_move_request(handle, desturl, copy, override);
884 free(desturl);
885 int status = 0;
886 curl_easy_getinfo (handle, CURLINFO_RESPONSE_CODE, &status);
887 if(ret == CURLE_OK && (status >= 200 && status < 300)) {
888 return 0;
889 } else {
890 dav_session_set_error(sn, ret, status);
891 return 1;
892 }
893 }
894
895 int dav_copy(DavResource *res, char *newpath) {
896 return dav_cp_mv(res, newpath, 1, 0);
897 }
898
899 int dav_move(DavResource *res, char *newpath) {
900 return dav_cp_mv(res, newpath, 0, 0);
901 }
902
873 903
874 int resource_add_crypto_info(DavSession *sn, char *href, char *name, char *hash) { 904 int resource_add_crypto_info(DavSession *sn, char *href, char *name, char *hash) {
875 if(!DAV_IS_ENCRYPTED(sn)) { 905 if(!DAV_IS_ENCRYPTED(sn)) {
876 return 0; 906 return 0;
877 } 907 }

mercurial