762 } |
762 } |
763 |
763 |
764 return r; |
764 return r; |
765 } |
765 } |
766 |
766 |
|
767 #if LIBCURL_VERSION_MAJOR >= 7 && LIBCURL_VERSION_MINOR >= 32 |
|
768 static void set_progressfunc(DavResource *res) { |
|
769 CURL *handle = res->session->handle; |
|
770 curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, dav_session_get_progress); |
|
771 curl_easy_setopt(handle, CURLOPT_XFERINFODATA, res); |
|
772 curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0L); |
|
773 } |
|
774 |
|
775 static void unset_progressfunc(DavResource *res) { |
|
776 CURL *handle = res->session->handle; |
|
777 curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, NULL); |
|
778 curl_easy_setopt(handle, CURLOPT_XFERINFODATA, NULL); |
|
779 curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 1L); |
|
780 } |
|
781 #else |
|
782 static void set_progressfunc(DavResource *res) { |
|
783 |
|
784 } |
|
785 static void unset_progressfunc(DavResource *res) { |
|
786 |
|
787 } |
|
788 #endif |
|
789 |
767 int dav_get_content(DavResource *res, void *stream, dav_write_func write_fnc) { |
790 int dav_get_content(DavResource *res, void *stream, dav_write_func write_fnc) { |
768 DavSession *sn = res->session; |
791 DavSession *sn = res->session; |
769 CURL *handle = sn->handle; |
792 CURL *handle = sn->handle; |
770 util_set_url(res->session, dav_resource_get_href(res)); |
793 util_set_url(res->session, dav_resource_get_href(res)); |
771 |
794 |
791 |
814 |
792 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_fnc); |
815 curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_fnc); |
793 curl_easy_setopt(handle, CURLOPT_WRITEDATA, stream); |
816 curl_easy_setopt(handle, CURLOPT_WRITEDATA, stream); |
794 |
817 |
795 if(sn->get_progress) { |
818 if(sn->get_progress) { |
796 curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, dav_session_get_progress); |
819 set_progressfunc(res); |
797 curl_easy_setopt(handle, CURLOPT_XFERINFODATA, res); |
|
798 curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 0L); |
|
799 } |
820 } |
800 |
821 |
801 long status = 0; |
822 long status = 0; |
802 CURLcode ret = dav_session_curl_perform(sn, &status); |
823 CURLcode ret = dav_session_curl_perform(sn, &status); |
803 |
824 |
804 if(sn->get_progress) { |
825 if(sn->get_progress) { |
805 curl_easy_setopt(handle, CURLOPT_XFERINFOFUNCTION, NULL); |
826 unset_progressfunc(res); |
806 curl_easy_setopt(handle, CURLOPT_XFERINFODATA, NULL); |
|
807 curl_easy_setopt(handle, CURLOPT_NOPROGRESS, 1L); |
|
808 } |
827 } |
809 |
828 |
810 char *hash = NULL; |
829 char *hash = NULL; |
811 if(dec) { |
830 if(dec) { |
812 aes_decrypter_shutdown(dec); // get final bytes |
831 aes_decrypter_shutdown(dec); // get final bytes |