libidav/resource.c

changeset 807
b41630ecc481
parent 789
378b5ab86f77
equal deleted inserted replaced
806:673a803d2203 807:b41630ecc481
38 #include "crypto.h" 38 #include "crypto.h"
39 #include <cx/buffer.h> 39 #include <cx/buffer.h>
40 #include <cx/utils.h> 40 #include <cx/utils.h>
41 #include <cx/hash_map.h> 41 #include <cx/hash_map.h>
42 #include <cx/printf.h> 42 #include <cx/printf.h>
43 #include <cx/basic_mempool.h> 43 #include <cx/mempool.h>
44 #include <cx/array_list.h> 44 #include <cx/array_list.h>
45 45
46 #include "resource.h" 46 #include "resource.h"
47 #include "xml.h" 47 #include "xml.h"
48 #include "davqlexec.h" 48 #include "davqlexec.h"
785 cxBufferFree(rqbuf); 785 cxBufferFree(rqbuf);
786 return ret; 786 return ret;
787 } 787 }
788 788
789 int dav_load_prop(DavResource *res, DavPropName *properties, size_t numprop) { 789 int dav_load_prop(DavResource *res, DavPropName *properties, size_t numprop) {
790 CxMempool *mp = cxBasicMempoolCreate(64); 790 CxMempool *mp = cxMempoolCreate(64, NULL);
791 const CxAllocator *a = mp->allocator; 791 const CxAllocator *a = mp->allocator;
792 792
793 CxList *proplist = cxArrayListCreate(a, NULL, sizeof(DavProperty), numprop); 793 CxList *proplist = cxArrayListCreate(a, NULL, sizeof(DavProperty), numprop);
794 for(size_t i=0;i<numprop;i++) { 794 for(size_t i=0;i<numprop;i++) {
795 DavProperty p; 795 DavProperty p;
854 DavLock *lock = dav_get_lock(sn, res->path); 854 DavLock *lock = dav_get_lock(sn, res->path);
855 char *locktoken = lock ? lock->token : NULL; 855 char *locktoken = lock ? lock->token : NULL;
856 856
857 // store content 857 // store content
858 if(data->content) { 858 if(data->content) {
859 curl_easy_setopt(sn->handle, CURLOPT_XFERINFOFUNCTION, dav_session_put_progress);
860 curl_easy_setopt(sn->handle, CURLOPT_XFERINFODATA, res);
861 curl_easy_setopt(sn->handle, CURLOPT_NOPROGRESS, 0L);
862
859 int encryption = DAV_ENCRYPT_CONTENT(sn) && sn->key; 863 int encryption = DAV_ENCRYPT_CONTENT(sn) && sn->key;
860 CURLcode ret; 864 CURLcode ret;
861 if(encryption) { 865 if(encryption) {
862 AESEncrypter *enc = NULL; 866 AESEncrypter *enc = NULL;
863 CxBuffer *buf = NULL; 867 CxBuffer *buf = NULL;
898 902
899 // add crypto properties 903 // add crypto properties
900 // TODO: store the properties later 904 // TODO: store the properties later
901 if(resource_add_crypto_info(sn, res->href, res->name, enc_hash)) { 905 if(resource_add_crypto_info(sn, res->href, res->name, enc_hash)) {
902 free(enc_hash); 906 free(enc_hash);
907 curl_easy_setopt(sn->handle, CURLOPT_XFERINFOFUNCTION, NULL);
908 curl_easy_setopt(sn->handle, CURLOPT_NOPROGRESS, 1L);
903 return 1; 909 return 1;
904 } 910 }
905 resource_add_string_property(res, DAV_NS, "crypto-hash", enc_hash); 911 resource_add_string_property(res, DAV_NS, "crypto-hash", enc_hash);
906 free(enc_hash); 912 free(enc_hash);
907 } else if((sn->flags & DAV_SESSION_STORE_HASH) == DAV_SESSION_STORE_HASH) { 913 } else if((sn->flags & DAV_SESSION_STORE_HASH) == DAV_SESSION_STORE_HASH) {
946 data->content, 952 data->content,
947 data->read, 953 data->read,
948 data->seek, 954 data->seek,
949 data->length); 955 data->length);
950 } 956 }
957
958 curl_easy_setopt(sn->handle, CURLOPT_XFERINFOFUNCTION, NULL);
959 curl_easy_setopt(sn->handle, CURLOPT_NOPROGRESS, 1L);
951 960
952 long status = 0; 961 long status = 0;
953 curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &status); 962 curl_easy_getinfo(sn->handle, CURLINFO_RESPONSE_CODE, &status);
954 if(ret == CURLE_OK && (status >= 200 && status < 300)) { 963 if(ret == CURLE_OK && (status >= 200 && status < 300)) {
955 res->session->error = 0; 964 res->session->error = 0;

mercurial