Thu, 28 Nov 2024 17:53:13 +0100
revert property set/remove list changes
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
361
b6f2462ee055
adds xattr lib and tag support
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
354
diff
changeset
|
4 | * Copyright 2018 Olaf Wintermann. All rights reserved. |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include <stdio.h> |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #include <stdlib.h> |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include <string.h> |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | #include "utils.h" |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | #include "methods.h" |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
35 | #include "crypto.h" |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
36 | #include "session.h" |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
37 | #include "xml.h" |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
39 | #include <cx/utils.h> |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
40 | #include <cx/printf.h> |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
41 | #include <cx/hash_map.h> |
156 | 42 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | #define xstreq(a,b) xmlStrEqual(BAD_CAST a, BAD_CAST b) |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | |
478
baa63fef5c5c
fixes redirects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
475
diff
changeset
|
45 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
46 | int dav_buffer_seek(CxBuffer *b, curl_off_t offset, int origin) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
47 | return cxBufferSeek(b, offset, origin) == 0 ? 0:CURL_SEEKFUNC_CANTSEEK; |
478
baa63fef5c5c
fixes redirects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
475
diff
changeset
|
48 | } |
baa63fef5c5c
fixes redirects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
475
diff
changeset
|
49 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | /* ----------------------------- PROPFIND ----------------------------- */ |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | CURLcode do_propfind_request( |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
53 | DavSession *sn, |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
54 | CxBuffer *request, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
55 | CxBuffer *response) |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | { |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
57 | CURL *handle = sn->handle; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "PROPFIND"); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | |
170
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
60 | // always try to get information about possible children |
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
61 | int depth = 1; |
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
62 | |
171
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
63 | int maxretry = 2; |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
64 | |
163
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
65 | struct curl_slist *headers = NULL; |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
66 | CURLcode ret = 0; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
69 | curl_easy_setopt(handle, CURLOPT_READFUNCTION, cxBufferRead); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
70 | curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, cxBufferSeek); |
753
8776125fd49c
fix crash when the seekfunction is used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
71 | curl_easy_setopt(handle, CURLOPT_READDATA, request); |
8776125fd49c
fix crash when the seekfunction is used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
72 | curl_easy_setopt(handle, CURLOPT_SEEKDATA, request); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
75 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, cxBufferWrite); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
77 | CxMap *respheaders = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 32); |
816
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
78 | cxDefineDestructor(respheaders, free); |
170
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
79 | util_capture_header(handle, respheaders); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | |
171
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
81 | for(int i=0;i<maxretry;i++) { |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
82 | if (depth == 1) { |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
83 | headers = curl_slist_append(headers, "Depth: 1"); |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
84 | } else if (depth == -1) { |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
85 | headers = curl_slist_append(headers, "Depth: infinity"); |
163
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
86 | } else { |
171
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
87 | headers = curl_slist_append(headers, "Depth: 0"); |
163
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
88 | } |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
89 | headers = curl_slist_append(headers, "Content-Type: text/xml"); |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
90 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
166
8911170d5e78
fixed incorrect response buffer reset in manual redirection handling in do_propfind_request
Mike Becker <universe@uap-core.de>
parents:
164
diff
changeset
|
91 | |
8911170d5e78
fixed incorrect response buffer reset in manual redirection handling in do_propfind_request
Mike Becker <universe@uap-core.de>
parents:
164
diff
changeset
|
92 | // reset buffers and perform request |
8911170d5e78
fixed incorrect response buffer reset in manual redirection handling in do_propfind_request
Mike Becker <universe@uap-core.de>
parents:
164
diff
changeset
|
93 | request->pos = 0; |
8911170d5e78
fixed incorrect response buffer reset in manual redirection handling in do_propfind_request
Mike Becker <universe@uap-core.de>
parents:
164
diff
changeset
|
94 | response->size = response->pos = 0; |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
95 | ret = dav_session_curl_perform_buf(sn, request, response, NULL); |
163
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
96 | curl_slist_free_all(headers); |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
97 | headers = NULL; |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
98 | |
170
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
99 | /* |
171
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
100 | * Handle two cases: |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
101 | * 1. We communicate with IIS and get a X-MSDAVEXT_Error: 589831 |
170
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
102 | * => try with depth 0 next time, it's not a collection |
171
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
103 | * 2. Other cases |
170
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
104 | * => the server handled our request and we can stop requesting |
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
105 | */ |
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
106 | char *msdavexterror; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
107 | msdavexterror = cxMapGet(respheaders, cx_hash_key_str("x-msdavext_error")); |
170
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
108 | int iishack = depth == 1 && |
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
109 | msdavexterror && !strncmp(msdavexterror, "589831;", 7); |
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
110 | |
171
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
111 | if(iishack) { |
170
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
112 | depth = 0; |
163
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
113 | } else { |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
114 | break; |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
115 | } |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
116 | } |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
117 | |
176
747f3796eddd
improved util_capture_header when deactivating the capturing
Mike Becker <universe@uap-core.de>
parents:
172
diff
changeset
|
118 | // deactivate header capturing and free captured map |
747f3796eddd
improved util_capture_header when deactivating the capturing
Mike Becker <universe@uap-core.de>
parents:
172
diff
changeset
|
119 | util_capture_header(handle, NULL); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
120 | cxMapDestroy(respheaders); |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
121 | |
74
da079dc0724c
fixed many memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
122 | return ret; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
125 | CxBuffer* create_allprop_propfind_request(void) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
126 | CxBuffer *buf = cxBufferCreate(NULL, 512, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
127 | cxstring s; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
129 | s = CX_STR("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
130 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
132 | s = CX_STR("<D:propfind xmlns:D=\"DAV:\">\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
133 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
135 | s = CX_STR("<D:allprop/></D:propfind>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
136 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | return buf; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
140 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
141 | CxBuffer* create_cryptoprop_propfind_request(void) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
142 | CxBuffer *buf = cxBufferCreate(NULL, 256, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
143 | cxstring s; |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
144 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
145 | s = CX_STR("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
146 | cxBufferWrite(s.ptr, 1, s.length, buf); |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
147 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
148 | s = CX_STR("<D:propfind xmlns:D=\"DAV:\" xmlns:idav=\"" DAV_NS "\">\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
149 | cxBufferWrite(s.ptr, 1, s.length, buf); |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
150 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
151 | s = CX_STR("<D:prop><idav:crypto-prop/></D:prop></D:propfind>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
152 | cxBufferWrite(s.ptr, 1, s.length, buf); |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
153 | |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
154 | return buf; |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
155 | } |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
156 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
157 | CxBuffer* create_propfind_request(DavSession *sn, CxList *properties, char *rootelm, DavBool nocrypt) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
158 | CxBuffer *buf = cxBufferCreate(NULL, 512, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
159 | cxstring s; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
161 | int add_crypto_name = 1; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
162 | int add_crypto_key = 1; |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
163 | int add_crypto_hash = 1; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
164 | char *crypto_ns = "idav"; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
165 | CxMap *namespaces = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
166 | if(properties) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
167 | CxIterator i = cxListIterator(properties); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
168 | cx_foreach(DavProperty*, p, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
169 | if(strcmp(p->ns->name, "DAV:")) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
170 | cxMapPut(namespaces, cx_hash_key_str(p->ns->prefix), p->ns); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
171 | } |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
172 | |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
173 | // if the properties list contains the idav properties crypto-name |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
174 | // and crypto-key, mark them as existent |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
175 | if(!strcmp(p->ns->name, DAV_NS)) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
176 | if(!strcmp(p->name, "crypto-name")) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
177 | add_crypto_name = 0; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
178 | crypto_ns = p->ns->prefix; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
179 | } else if(!strcmp(p->name, "crypto-key")) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
180 | add_crypto_key = 0; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
181 | crypto_ns = p->ns->prefix; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
182 | } else if(!strcmp(p->name, "crypto-hash")) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
183 | add_crypto_hash = 0; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
184 | crypto_ns = p->ns->prefix; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
185 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
186 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
187 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
188 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
189 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
190 | DavNamespace idav_ns; |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
191 | if(add_crypto_name && add_crypto_key && DAV_CRYPTO(sn) && !nocrypt) { |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
192 | idav_ns.prefix = "idav"; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
193 | idav_ns.name = DAV_NS; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
194 | cxMapPut(namespaces, cx_hash_key_str("idav"), &idav_ns); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
195 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
196 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
197 | s = CX_STR("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
198 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
200 | // write root element and namespaces |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
201 | cx_bprintf(buf, "<D:%s xmlns:D=\"DAV:\"", rootelm); |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
202 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
203 | CxIterator mapi = cxMapIteratorValues(namespaces); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
204 | cx_foreach(DavNamespace*, ns, mapi) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
205 | s = CX_STR(" xmlns:"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
206 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
207 | s = cx_str(ns->prefix); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
208 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
209 | s = CX_STR("=\""); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
210 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
211 | s = cx_str(ns->name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
212 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
213 | s = CX_STR("\""); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
214 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
215 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
216 | s = CX_STR(">\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
217 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 | // default properties |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
220 | s = CX_STR("<D:prop>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
221 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
222 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
223 | s = CX_STR("<D:creationdate />\n<D:getlastmodified />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
224 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
225 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
226 | s = CX_STR("<D:getcontentlength />\n<D:getcontenttype />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
227 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
228 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
229 | s = CX_STR("<D:resourcetype />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
230 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
231 | |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
232 | // crypto properties |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
233 | if(DAV_CRYPTO(sn) && !nocrypt) { |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
234 | if(add_crypto_name) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
235 | cxBufferPut(buf, '<'); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
236 | cxBufferPutString(buf, crypto_ns); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
237 | s = CX_STR(":crypto-name />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
238 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
239 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
240 | if(add_crypto_key) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
241 | cxBufferPut(buf, '<'); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
242 | cxBufferPutString(buf, crypto_ns); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
243 | s = CX_STR(":crypto-key />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
244 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
245 | } |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
246 | if(add_crypto_hash) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
247 | cxBufferPut(buf, '<'); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
248 | cxBufferPutString(buf, crypto_ns); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
249 | s = CX_STR(":crypto-hash />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
250 | cxBufferWrite(s.ptr, 1, s.length, buf); |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
251 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
252 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
253 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
254 | // extra properties |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
255 | if(properties) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
256 | CxIterator i = cxListIterator(properties); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
257 | cx_foreach(DavProperty*, prop, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
258 | s = CX_STR("<"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
259 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
260 | s = cx_str(prop->ns->prefix); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
261 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
262 | s = CX_STR(":"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
263 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
264 | s = cx_str(prop->name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
265 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
266 | s = CX_STR(" />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
267 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
268 | } |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
269 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
270 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
271 | // end |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
272 | cx_bprintf(buf, "</D:prop>\n</D:%s>\n", rootelm); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
273 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
274 | cxMapDestroy(namespaces); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
275 | return buf; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
276 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
277 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
278 | CxBuffer* create_basic_propfind_request(void) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
279 | CxBuffer *buf = cxBufferCreate(NULL, 512, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
280 | cxstring s; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
281 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
282 | s = CX_STR("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
283 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
284 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
285 | s = CX_STR("<D:propfind xmlns:D=\"DAV:\" xmlns:i=\""); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
286 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
287 | s = CX_STR(DAV_NS); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
288 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
289 | s = CX_STR("\" >\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
290 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
291 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
292 | // properties |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
293 | s = CX_STR("<D:prop>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
294 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
295 | s = CX_STR("<D:resourcetype />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
296 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
297 | s = CX_STR("<i:crypto-key />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
298 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
299 | s = CX_STR("<i:crypto-name />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
300 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
301 | s = CX_STR("<i:crypto-hash />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
302 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
303 | s = CX_STR("</D:prop>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
304 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
305 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
306 | // end |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
307 | s = CX_STR("</D:propfind>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
308 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
309 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
310 | return buf; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
311 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
312 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
313 | PropfindParser* create_propfind_parser(CxBuffer *response, char *url) { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
314 | PropfindParser *parser = malloc(sizeof(PropfindParser)); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
315 | if(!parser) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
316 | return NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
317 | } |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
318 | parser->document = xmlReadMemory(response->space, response->pos, url, NULL, 0); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
319 | parser->current = NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
320 | if(parser->document) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
321 | xmlNode *xml_root = xmlDocGetRootElement(parser->document); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
322 | if(xml_root) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
323 | xmlNode *node = xml_root->children; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
324 | while(node) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
325 | // find first response tag |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
326 | if(node->type == XML_ELEMENT_NODE) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
327 | if(xstreq(node->name, "response")) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
328 | parser->current = node; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
329 | break; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
330 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
331 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
332 | node = node->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
333 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
334 | return parser; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
335 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
336 | xmlFreeDoc(parser->document); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
337 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
338 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
339 | free(parser); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
340 | return NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
341 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
342 | |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
343 | void destroy_propfind_parser(PropfindParser *parser) { |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
344 | if(parser->document) { |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
345 | xmlFreeDoc(parser->document); |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
346 | } |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
347 | free(parser); |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
348 | } |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
349 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
350 | int get_propfind_response(PropfindParser *parser, ResponseTag *result) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
351 | if(parser->current == NULL) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
352 | return 0; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
353 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
354 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
355 | char *href = NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
356 | int iscollection = 0; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
357 | char *crypto_name = NULL; // name set by crypto-name property |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
358 | char *crypto_key = NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
359 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
360 | result->properties = cxLinkedListCreateSimple(CX_STORE_POINTERS); // xmlNode list |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
361 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
362 | xmlNode *node = parser->current->children; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
363 | while(node) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
364 | if(node->type == XML_ELEMENT_NODE) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
365 | if(xstreq(node->name, "href")) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
366 | xmlNode *href_node = node->children; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
367 | if(href_node->type != XML_TEXT_NODE) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
368 | // error |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
369 | return -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
370 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
371 | href = (char*)href_node->content; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
372 | } else if(xstreq(node->name, "propstat")) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
373 | xmlNode *n = node->children; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
374 | xmlNode *prop_node = NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
375 | int ok = 0; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
376 | // get the status code |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
377 | while(n) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
378 | if(n->type == XML_ELEMENT_NODE) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
379 | if(xstreq(n->name, "prop")) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
380 | prop_node = n; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
381 | } else if(xstreq(n->name, "status")) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
382 | xmlNode *status_node = n->children; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
383 | if(status_node->type != XML_TEXT_NODE) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
384 | // error |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
385 | return -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
386 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
387 | cxstring status_str = cx_str((char*)status_node->content); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
388 | if(status_str.length < 13) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
389 | // error |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
390 | return -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
391 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
392 | status_str = cx_strsubsl(status_str, 9, 3); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
393 | if(!cx_strcmp(status_str, CX_STR("200"))) { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
394 | ok = 1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
395 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
396 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
397 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
398 | n = n->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
399 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
400 | // if status is ok, get all properties |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
401 | if(ok) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
402 | n = prop_node->children; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
403 | while(n) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
404 | if(n->type == XML_ELEMENT_NODE) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
405 | cxListAdd(result->properties, n); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
406 | if(xstreq(n->name, "resourcetype")) { |
231
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
407 | if(parse_resource_type(n)) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
408 | iscollection = TRUE; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
409 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
410 | } else if(xstreq(n->ns->href, DAV_NS)) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
411 | if(xstreq(n->name, "crypto-name")) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
412 | crypto_name = util_xml_get_text(n); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
413 | } else if(xstreq(n->name, "crypto-key")) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
414 | crypto_key = util_xml_get_text(n); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
415 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
416 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
417 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
418 | n = n->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
419 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
420 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
421 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
422 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
423 | node = node->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
424 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
425 | |
156 | 426 | result->href = util_url_path(href); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
427 | result->iscollection = iscollection; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
428 | result->crypto_name = crypto_name; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
429 | result->crypto_key = crypto_key; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
430 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
431 | // find next response tag |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
432 | xmlNode *next = parser->current->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
433 | while(next) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
434 | if(next->type == XML_ELEMENT_NODE) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
435 | if(xstreq(next->name, "response")) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
436 | break; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
437 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
438 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
439 | next = next->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
440 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
441 | parser->current = next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
442 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
443 | return 1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
444 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
445 | |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
446 | void cleanup_response(ResponseTag *result) { |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
447 | if(result) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
448 | cxListDestroy(result->properties); |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
449 | } |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
450 | } |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
451 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
452 | int hrefeq(DavSession *sn, const char *href1, const char *href2) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
453 | cxmutstr href_s = cx_mutstr(util_url_decode(sn, href1)); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
454 | cxmutstr href_r = cx_mutstr(util_url_decode(sn, href2)); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
455 | int ret = 0; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
456 | if(!cx_strcmp(cx_strcast(href_s), cx_strcast(href_r))) { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
457 | ret = 1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
458 | } else if(href_s.length == href_r.length + 1) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
459 | if(href_s.ptr[href_s.length-1] == '/') { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
460 | href_s.length--; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
461 | if(!cx_strcmp(cx_strcast(href_s), cx_strcast(href_r))) { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
462 | ret = 1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
463 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
464 | } |
141
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
465 | } else if(href_r.length == href_s.length + 1) { |
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
466 | if(href_r.ptr[href_r.length-1] == '/') { |
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
467 | href_r.length--; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
468 | if(!cx_strcmp(cx_strcast(href_s), cx_strcast(href_r))) { |
141
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
469 | ret = 1; |
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
470 | } |
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
471 | } |
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
472 | } |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
473 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
474 | free(href_s.ptr); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
475 | free(href_r.ptr); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
476 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
477 | return ret; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
478 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
479 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
480 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
481 | DavResource* parse_propfind_response(DavSession *sn, DavResource *root, CxBuffer *response) { |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
482 | char *url = NULL; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
483 | curl_easy_getinfo(sn->handle, CURLINFO_EFFECTIVE_URL, &url); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
484 | if(!root) { |
225
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
485 | printf("methods.c: TODO: remove\n"); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
486 | root = dav_resource_new_href(sn, util_url_path(url)); // TODO: remove |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
487 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
488 | |
62
3b813c57c106
added property-set and property-get command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
489 | //printf("%.*s\n\n", response->size, response->space); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
490 | xmlDoc *doc = xmlReadMemory(response->space, response->size, url, NULL, 0); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
491 | if(!doc) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
492 | // TODO: free stuff |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
493 | sn->error = DAV_ERROR; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
494 | return NULL; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
495 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
496 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
497 | xmlNode *xml_root = xmlDocGetRootElement(doc); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
498 | xmlNode *node = xml_root->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
499 | while(node) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
500 | if(node->type == XML_ELEMENT_NODE) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
501 | if(xstreq(node->name, "response")) { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
502 | parse_response_tag(root, node); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
503 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
504 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
505 | node = node->next; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
506 | } |
74
da079dc0724c
fixed many memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
507 | xmlFreeDoc(doc); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
508 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
509 | return root; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
510 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
511 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
512 | DavResource* response2resource(DavSession *sn, ResponseTag *response, char *parent_path) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
513 | // create resource |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
514 | char *name = NULL; |
147
458a8dc68048
added password based keys and fixed crash when keys are missing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
515 | DavKey *key = NULL; |
458a8dc68048
added password based keys and fixed crash when keys are missing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
516 | if(DAV_DECRYPT_NAME(sn) && response->crypto_name && (key = dav_context_get_key(sn->context, response->crypto_key))) { |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
517 | if(!response->crypto_key) { |
225
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
518 | sn->error = DAV_ERROR; |
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
519 | dav_session_set_errstr(sn, "Missing crypto-key property"); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
520 | return NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
521 | } |
147
458a8dc68048
added password based keys and fixed crash when keys are missing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
522 | name = util_decrypt_str_k(sn, response->crypto_name, key); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
523 | if(!name) { |
225
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
524 | sn->error = DAV_ERROR; |
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
525 | dav_session_set_errstr(sn, "Cannot decrypt resource name"); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
526 | return NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
527 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
528 | } else { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
529 | cxstring resname = cx_str(util_resource_name(response->href)); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
530 | int nlen = 0; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
531 | char *uname = curl_easy_unescape( |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
532 | sn->handle, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
533 | resname.ptr, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
534 | resname.length, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
535 | &nlen); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
536 | name = dav_session_strdup(sn, uname); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
537 | curl_free(uname); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
538 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
539 | |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
540 | char *href = dav_session_strdup(sn, response->href); |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
541 | DavResource *res = NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
542 | if(parent_path) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
543 | res = dav_resource_new_full(sn, parent_path, name, href); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
544 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
545 | res = dav_resource_new_href(sn, href); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
546 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
547 | dav_session_free(sn, name); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
548 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
549 | add_properties(res, response); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
550 | return res; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
551 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
552 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
553 | void add_properties(DavResource *res, ResponseTag *response) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
554 | res->iscollection = response->iscollection; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
555 | |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
556 | int decrypt_props = DAV_ENCRYPT_PROPERTIES(res->session); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
557 | xmlNode *crypto_prop = NULL; |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
558 | char *crypto_key = NULL; |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
559 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
560 | // add properties |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
561 | if(response->properties) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
562 | CxIterator i = cxListIterator(response->properties); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
563 | cx_foreach(xmlNode*, prop, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
564 | resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, prop->children); |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
565 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
566 | if (decrypt_props && |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
567 | prop->children && |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
568 | prop->children->type == XML_TEXT_NODE && |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
569 | xstreq(prop->ns->href, DAV_NS)) |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
570 | { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
571 | if(xstreq(prop->name, "crypto-prop")) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
572 | crypto_prop = prop; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
573 | } else if(xstreq(prop->name, "crypto-key")) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
574 | crypto_key = util_xml_get_text(prop); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
575 | } |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
576 | } |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
577 | } |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
578 | } |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
579 | |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
580 | if(crypto_prop && crypto_key) { |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
581 | char *crypto_prop_content = util_xml_get_text(crypto_prop); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
582 | DavKey *key = dav_context_get_key(res->session->context, crypto_key); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
583 | if(crypto_prop_content) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
584 | CxMap *cprops = parse_crypto_prop_str(res->session, key, crypto_prop_content); |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
585 | resource_set_crypto_properties(res, cprops); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
586 | } |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
587 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
588 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
589 | set_davprops(res); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
590 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
591 | |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
592 | int parse_response_tag(DavResource *resource, xmlNode *node) { |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
593 | DavSession *sn = resource->session; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
594 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
595 | //DavResource *res = resource; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
596 | DavResource *res = NULL; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
597 | const char *href = NULL; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
598 | CxList *properties = cxLinkedListCreateSimple(CX_STORE_POINTERS); // xmlNode list |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
599 | char *crypto_name = NULL; // name set by crypto-name property |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
600 | char *crypto_key = NULL; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
601 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
602 | int iscollection = 0; // TODO: remove |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
603 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
604 | node = node->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
605 | while(node) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
606 | if(node->type == XML_ELEMENT_NODE) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
607 | if(xstreq(node->name, "href")) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
608 | xmlNode *href_node = node->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
609 | if(href_node->type != XML_TEXT_NODE) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
610 | // error |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
611 | sn->error = DAV_ERROR; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
612 | return 1; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
613 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
614 | //char *href = (char*)href_node->content; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
615 | href = util_url_path((const char*)href_node->content); |
60
cdca2eef48ee
fixed propfind response parser bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
44
diff
changeset
|
616 | |
164
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
617 | char *href_s = util_url_decode(resource->session, href); |
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
618 | char *href_r = util_url_decode(resource->session, resource->href); |
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
619 | |
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
620 | if(hrefeq(sn, href_s, href_r)) { |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
621 | res = resource; |
164
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
622 | } |
66 | 623 | |
164
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
624 | free(href_s); |
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
625 | free(href_r); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
626 | } else if(xstreq(node->name, "propstat")) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
627 | xmlNode *n = node->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
628 | xmlNode *prop_node = NULL; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
629 | int ok = 0; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
630 | // get the status code |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
631 | while(n) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
632 | if(n->type == XML_ELEMENT_NODE) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
633 | if(xstreq(n->name, "prop")) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
634 | prop_node = n; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
635 | } else if(xstreq(n->name, "status")) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
636 | xmlNode *status_node = n->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
637 | if(status_node->type != XML_TEXT_NODE) { |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
638 | sn->error = DAV_ERROR; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
639 | return 1; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
640 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
641 | cxstring status_str = cx_str((char*)status_node->content); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
642 | if(status_str.length < 13) { |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
643 | sn->error = DAV_ERROR; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
644 | return 1; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
645 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
646 | status_str = cx_strsubsl(status_str, 9, 3); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
647 | if(!cx_strcmp(status_str, CX_STR("200"))) { |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
648 | ok = 1; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
649 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
650 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
651 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
652 | n = n->next; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
653 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
654 | // if status is ok, get all properties |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
655 | if(ok) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
656 | n = prop_node->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
657 | while(n) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
658 | if(n->type == XML_ELEMENT_NODE) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
659 | cxListAdd(properties, n); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
660 | if(xstreq(n->name, "resourcetype")) { |
231
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
661 | if(parse_resource_type(n)) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
662 | iscollection = TRUE; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
663 | } |
743
716f6bf04c30
fix crash if the server sends a response with elements without namespaces
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
638
diff
changeset
|
664 | } else if(n->ns && xstreq(n->ns->href, DAV_NS)) { |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
665 | if(xstreq(n->name, "crypto-name")) { |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
666 | crypto_name = util_xml_get_text(n); |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
667 | } else if(xstreq(n->name, "crypto-key")) { |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
668 | crypto_key = util_xml_get_text(n); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
669 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
670 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
671 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
672 | n = n->next; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
673 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
674 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
675 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
676 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
677 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
678 | node = node->next; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
679 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
680 | |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
681 | if(!res) { |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
682 | // create new resource object |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
683 | char *name = NULL; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
684 | if(DAV_DECRYPT_NAME(sn) && crypto_name) { |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
685 | if(!crypto_key) { |
225
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
686 | sn->error = DAV_ERROR; |
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
687 | dav_session_set_errstr(sn, "Missing crypto-key property"); |
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
688 | return -1; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
689 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
690 | name = util_decrypt_str(sn, crypto_name, crypto_key); |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
691 | if(!name) { |
225
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
692 | sn->error = DAV_ERROR; |
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
693 | dav_session_set_errstr(sn, "Cannot decrypt resource name"); |
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
694 | return -1; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
695 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
696 | } else { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
697 | cxstring resname = cx_str(util_resource_name(href)); |
44
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
698 | int nlen = 0; |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
699 | char *uname = curl_easy_unescape( |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
700 | sn->handle, |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
701 | resname.ptr, |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
702 | resname.length, |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
703 | &nlen); |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
704 | name = dav_session_strdup(sn, uname); |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
705 | curl_free(uname); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
706 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
707 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
708 | char *href_cp = dav_session_strdup(sn, href); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
709 | res = dav_resource_new_full(sn, resource->path, name, href_cp); |
44
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
710 | |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
711 | dav_session_free(sn, name); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
712 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
713 | res->iscollection = iscollection; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
714 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
715 | // add properties |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
716 | int decrypt_props = DAV_ENCRYPT_PROPERTIES(res->session); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
717 | xmlNode *crypto_prop = NULL; |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
718 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
719 | CxIterator i = cxListIterator(properties); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
720 | cx_foreach(xmlNode*, prop, i) { |
743
716f6bf04c30
fix crash if the server sends a response with elements without namespaces
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
638
diff
changeset
|
721 | if(!prop->ns) { |
716f6bf04c30
fix crash if the server sends a response with elements without namespaces
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
638
diff
changeset
|
722 | continue; |
716f6bf04c30
fix crash if the server sends a response with elements without namespaces
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
638
diff
changeset
|
723 | } |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
724 | resource_add_property(res, (char*)prop->ns->href, (char*)prop->name, prop->children); |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
725 | |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
726 | if (decrypt_props && |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
727 | prop->children && |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
728 | prop->children->type == XML_TEXT_NODE && |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
729 | xstreq(prop->ns->href, DAV_NS)) |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
730 | { |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
731 | if(xstreq(prop->name, "crypto-prop")) { |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
732 | crypto_prop = prop; |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
733 | } |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
734 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
735 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
736 | cxListDestroy(properties); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
737 | |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
738 | if(crypto_prop && crypto_key) { |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
739 | char *crypto_prop_content = util_xml_get_text(crypto_prop); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
740 | DavKey *key = dav_context_get_key(res->session->context, crypto_key); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
741 | if(crypto_prop_content && key) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
742 | CxMap *cprops = parse_crypto_prop_str(res->session, key, crypto_prop_content); |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
743 | resource_set_crypto_properties(res, cprops); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
744 | } |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
745 | } |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
746 | |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
747 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
748 | set_davprops(res); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
749 | if(res != resource) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
750 | resource_add_child(resource, res); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
751 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
752 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
753 | return 0; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
754 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
755 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
756 | void set_davprops(DavResource *res) { |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
757 | char *cl = dav_get_string_property_ns(res, "DAV:", "getcontentlength"); |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
758 | char *ct = dav_get_string_property_ns(res, "DAV:", "getcontenttype"); |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
759 | char *cd = dav_get_string_property_ns(res, "DAV:", "creationdate"); |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
760 | char *lm = dav_get_string_property_ns(res, "DAV:", "getlastmodified"); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
761 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
762 | res->contenttype = ct; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
763 | if(cl) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
764 | char *end = NULL; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
765 | res->contentlength = strtoull(cl, &end, 0); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
766 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
767 | res->creationdate = util_parse_creationdate(cd); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
768 | res->lastmodified = util_parse_lastmodified(lm); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
769 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
770 | |
231
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
771 | int parse_resource_type(xmlNode *node) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
772 | int collection = FALSE; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
773 | xmlNode *c = node->children; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
774 | while(c) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
775 | if(c->type == XML_ELEMENT_NODE) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
776 | if(xstreq(c->ns->href, "DAV:") && xstreq(c->name, "collection")) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
777 | collection = TRUE; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
778 | break; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
779 | } |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
780 | } |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
781 | c = c->next; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
782 | } |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
783 | return collection; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
784 | } |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
785 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
786 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
787 | /* ----------------------------- PROPPATCH ----------------------------- */ |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
788 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
789 | CURLcode do_proppatch_request( |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
790 | DavSession *sn, |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
791 | char *lock, |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
792 | CxBuffer *request, |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
793 | CxBuffer *response) |
638
b3077bdb3d77
fix hash based conflict detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
609
diff
changeset
|
794 | { |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
795 | CURL *handle = sn->handle; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
796 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "PROPPATCH"); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
797 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
798 | struct curl_slist *headers = NULL; |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
799 | headers = curl_slist_append(headers, "Content-Type: text/xml"); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
800 | if(lock) { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
801 | char *url = NULL; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
802 | curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
803 | char *ltheader = cx_asprintf("If: <%s> (<%s>)", url, lock).ptr; |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
804 | headers = curl_slist_append(headers, ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
805 | free(ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
806 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
807 | } |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
808 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
809 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
810 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
811 | curl_easy_setopt(handle, CURLOPT_READFUNCTION, cxBufferRead); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
812 | curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, cxBufferSeek); |
753
8776125fd49c
fix crash when the seekfunction is used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
813 | curl_easy_setopt(handle, CURLOPT_READDATA, request); |
8776125fd49c
fix crash when the seekfunction is used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
814 | curl_easy_setopt(handle, CURLOPT_SEEKDATA, request); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
815 | curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
816 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
817 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, cxBufferWrite); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
818 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
819 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
820 | cxBufferSeek(request, 0, SEEK_SET); |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
821 | CURLcode ret = dav_session_curl_perform_buf(sn, request, response, NULL); |
74
da079dc0724c
fixed many memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
822 | curl_slist_free_all(headers); |
371
604e7e335b3b
adds support for xml properties in set-property command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
823 | |
373
dcc03142eb5f
dav info prints simplified xml values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
371
diff
changeset
|
824 | //printf("proppatch: \n%.*s\n", request->size, request->space); |
371
604e7e335b3b
adds support for xml properties in set-property command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
825 | |
74
da079dc0724c
fixed many memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
826 | return ret; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
827 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
828 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
829 | CxBuffer* create_proppatch_request(DavResourceData *data) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
830 | CxBuffer *buf = cxBufferCreate(NULL, 512, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
831 | cxstring s; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
832 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
833 | CxMap *namespaces = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8); |
816
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
834 | cxDefineDestructor(namespaces, free); |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
835 | |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
836 | { |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
837 | char prefix[8]; |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
838 | int pfxnum = 0; |
850
bbe2925eb590
revert property set/remove list changes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
848
diff
changeset
|
839 | if (data->set && cxListSize(data->set) > 0) { |
816
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
840 | CxIterator i = cxListIterator(data->set); |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
841 | cx_foreach(DavProperty*, p, i) { |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
842 | if (strcmp(p->ns->name, "DAV:")) { |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
843 | snprintf(prefix, 8, "x%d", pfxnum++); |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
844 | cxMapPut(namespaces, cx_hash_key_str(p->ns->name), strdup(prefix)); |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
845 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
846 | } |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
847 | } |
850
bbe2925eb590
revert property set/remove list changes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
848
diff
changeset
|
848 | if (data->remove && cxListSize(data->remove) > 0) { |
816
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
849 | CxIterator i = cxListIterator(data->remove); |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
850 | cx_foreach(DavProperty*, p, i) { |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
851 | if (strcmp(p->ns->name, "DAV:")) { |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
852 | snprintf(prefix, 8, "x%d", pfxnum++); |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
853 | cxMapPut(namespaces, cx_hash_key_str(p->ns->name), strdup(prefix)); |
839fefbdedc7
compatibility with UCX 3.1 plus several minor code fixes
Mike Becker <universe@uap-core.de>
parents:
753
diff
changeset
|
854 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
855 | } |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
856 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
857 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
858 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
859 | s = CX_STR("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
860 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
861 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
862 | // write root element and namespaces |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
863 | s = CX_STR("<D:propertyupdate xmlns:D=\"DAV:\""); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
864 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
865 | CxIterator mapi = cxMapIterator(namespaces); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
866 | cx_foreach(CxMapEntry*, entry, mapi) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
867 | s = CX_STR(" xmlns:"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
868 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
869 | s = cx_str(entry->value); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
870 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
871 | s = CX_STR("=\""); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
872 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
873 | s = cx_strn(entry->key->data, entry->key->len); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
874 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
875 | s = CX_STR("\""); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
876 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
877 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
878 | s = CX_STR(">\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
879 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
880 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
881 | if(data->set) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
882 | s = CX_STR("<D:set>\n<D:prop>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
883 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
884 | CxIterator i = cxListIterator(data->set); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
885 | cx_foreach(DavProperty*, property, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
886 | char *prefix = cxMapGet(namespaces, cx_hash_key_str(property->ns->name)); |
181
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
887 | if(!prefix) { |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
888 | prefix = "D"; |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
889 | } |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
890 | |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
891 | // begin tag |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
892 | s = CX_STR("<"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
893 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
894 | s = cx_str(prefix); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
895 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
896 | s = CX_STR(":"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
897 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
898 | s = cx_str(property->name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
899 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
900 | s = CX_STR(">"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
901 | cxBufferWrite(s.ptr, 1, s.length, buf); |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
902 | |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
903 | // content |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
904 | DavXmlNode *content = property->value; |
371
604e7e335b3b
adds support for xml properties in set-property command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
361
diff
changeset
|
905 | if(content->type == DAV_XML_TEXT && !content->next) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
906 | cxBufferWrite(content->content, 1, content->contentlength, buf); |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
907 | } else { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
908 | dav_print_node(buf, (cx_write_func)cxBufferWrite, namespaces, content); |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
909 | } |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
910 | |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
911 | // end tag |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
912 | s = CX_STR("</"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
913 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
914 | s = cx_str(prefix); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
915 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
916 | s = CX_STR(":"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
917 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
918 | s = cx_str(property->name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
919 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
920 | s = CX_STR(">\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
921 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
922 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
923 | s = CX_STR("</D:prop>\n</D:set>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
924 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
925 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
926 | if(data->remove) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
927 | s = CX_STR("<D:remove>\n<D:prop>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
928 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
929 | CxIterator i = cxListIterator(data->remove); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
930 | cx_foreach(DavProperty*, property, i) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
931 | char *prefix = cxMapGet(namespaces, cx_hash_key_str(property->ns->name)); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
932 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
933 | s = CX_STR("<"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
934 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
935 | s = cx_str(prefix); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
936 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
937 | s = CX_STR(":"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
938 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
939 | s = cx_str(property->name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
940 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
941 | s = CX_STR(" />\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
942 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
943 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
944 | s = CX_STR("</D:prop>\n</D:remove>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
945 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
946 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
947 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
948 | s = CX_STR("</D:propertyupdate>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
949 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
950 | |
223
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
951 | // cleanup namespace map |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
952 | cxMapDestroy(namespaces); |
181
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
953 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
954 | return buf; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
955 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
956 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
957 | CxBuffer* create_crypto_proppatch_request(DavSession *sn, DavKey *key, const char *name, const char *hash) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
958 | CxBuffer *buf = cxBufferCreate(NULL, 512, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
959 | cxstring s; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
960 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
961 | s = CX_STR("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
962 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
963 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
964 | s = CX_STR("<D:propertyupdate xmlns:D=\"DAV:\" xmlns:idav=\"" DAV_NS "\">\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
965 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
966 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
967 | s = CX_STR("<D:set>\n<D:prop>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
968 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
969 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
970 | if(DAV_ENCRYPT_NAME(sn)) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
971 | s = CX_STR("<idav:crypto-name>"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
972 | cxBufferWrite(s.ptr, 1, s.length, buf); |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
973 | char *crname = aes_encrypt(name, strlen(name), key); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
974 | cxBufferPutString(buf, crname); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
975 | free(crname); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
976 | s = CX_STR("</idav:crypto-name>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
977 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
978 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
979 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
980 | s = CX_STR("<idav:crypto-key>"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
981 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
982 | cxBufferPutString(buf, key->name); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
983 | s = CX_STR("</idav:crypto-key>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
984 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
985 | |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
986 | if(hash) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
987 | s = CX_STR("<idav:crypto-hash>"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
988 | cxBufferWrite(s.ptr, 1, s.length, buf); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
989 | cxBufferPutString(buf, hash); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
990 | s = CX_STR("</idav:crypto-hash>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
991 | cxBufferWrite(s.ptr, 1, s.length, buf); |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
992 | } |
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
993 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
994 | s = CX_STR("</D:prop>\n</D:set>\n</D:propertyupdate>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
995 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
996 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
997 | return buf; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
998 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
999 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1000 | /* ----------------------------- PUT ----------------------------- */ |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1001 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1002 | static size_t dummy_write(void *buf, size_t s, size_t n, void *data) { |
227
bf485439222a
fixed locking in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
225
diff
changeset
|
1003 | //fwrite(buf, s, n, stdout); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1004 | return s*n; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1005 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1006 | |
478
baa63fef5c5c
fixes redirects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
475
diff
changeset
|
1007 | CURLcode do_put_request(DavSession *sn, char *lock, DavBool create, void *data, dav_read_func read_func, dav_seek_func seek_func, size_t length) { |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1008 | CURL *handle = sn->handle; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1009 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, NULL); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1010 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1011 | |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1012 | // clear headers |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1013 | struct curl_slist *headers = NULL; |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1014 | if(lock) { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1015 | char *url = NULL; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1016 | curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); |
223
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1017 | char *ltheader = NULL; |
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1018 | if(create) { |
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1019 | url = util_parent_path(url); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1020 | ltheader = cx_asprintf("If: <%s> (<%s>)", url, lock).ptr; |
223
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1021 | free(url); |
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1022 | } else { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1023 | ltheader = cx_asprintf("If: <%s> (<%s>)", url, lock).ptr; |
223
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1024 | } |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1025 | headers = curl_slist_append(headers, ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1026 | free(ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1027 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1028 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1029 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1030 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1031 | CxBuffer *buf = NULL; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1032 | if(!read_func) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1033 | buf = cxBufferCreate(data, length, cxDefaultAllocator, 0); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1034 | buf->size = length; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1035 | data = buf; |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1036 | read_func = (dav_read_func)cxBufferRead; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1037 | curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)length); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1038 | } else if(length == 0) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1039 | headers = curl_slist_append(headers, "Transfer-Encoding: chunked"); |
847
61a3892a8dfb
fix PUT request with chunked transfer encoding
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
816
diff
changeset
|
1040 | curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)-1); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1041 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1042 | } else { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1043 | curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)length); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1044 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1045 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1046 | curl_easy_setopt(handle, CURLOPT_READFUNCTION, read_func); |
478
baa63fef5c5c
fixes redirects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
475
diff
changeset
|
1047 | curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, seek_func); |
753
8776125fd49c
fix crash when the seekfunction is used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
1048 | curl_easy_setopt(handle, CURLOPT_SEEKDATA, data); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1049 | curl_easy_setopt(handle, CURLOPT_READDATA, data); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1050 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1051 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1052 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1053 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1054 | CURLcode ret = dav_session_curl_perform(sn, NULL); |
74
da079dc0724c
fixed many memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
1055 | curl_slist_free_all(headers); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1056 | if(buf) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1057 | cxBufferFree(buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1058 | } |
223
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1059 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1060 | return ret; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1061 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1062 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1063 | CURLcode do_delete_request(DavSession *sn, char *lock, CxBuffer *response) { |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1064 | CURL *handle = sn->handle; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1065 | struct curl_slist *headers = NULL; |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1066 | if(lock) { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1067 | char *url = NULL; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1068 | curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1069 | char *ltheader = cx_asprintf("If: <%s> (<%s>)", url, lock).ptr; |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1070 | headers = curl_slist_append(headers, ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1071 | free(ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1072 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1073 | } else { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1074 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1075 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1076 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1077 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "DELETE"); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1078 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1079 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1080 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, cxBufferWrite); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1081 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1082 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1083 | CURLcode ret = dav_session_curl_perform(sn, NULL); |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1084 | curl_slist_free_all(headers); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1085 | return ret; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1086 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1087 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1088 | CURLcode do_mkcol_request(DavSession *sn, char *lock) { |
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1089 | CURL *handle = sn->handle; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1090 | struct curl_slist *headers = NULL; |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1091 | if(lock) { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1092 | char *url = NULL; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1093 | curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); |
223
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1094 | url = util_parent_path(url); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1095 | char *ltheader = cx_asprintf("If: <%s> (<%s>)", url, lock).ptr; |
223
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1096 | free(url); |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1097 | headers = curl_slist_append(headers, ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1098 | free(ltheader); |
227
bf485439222a
fixed locking in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
225
diff
changeset
|
1099 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1100 | } else { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1101 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1102 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1103 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1104 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "MKCOL"); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1105 | curl_easy_setopt(handle, CURLOPT_PUT, 0L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1106 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1107 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1108 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1109 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1110 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1111 | CURLcode ret = dav_session_curl_perform(sn, NULL); |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1112 | curl_slist_free_all(headers); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1113 | return ret; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1114 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1115 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1116 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1117 | CURLcode do_head_request(DavSession *sn) { |
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1118 | CURL *handle = sn->handle; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1119 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "HEAD"); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1120 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1121 | curl_easy_setopt(handle, CURLOPT_NOBODY, 1L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1122 | |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1123 | // clear headers |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1124 | struct curl_slist *headers = NULL; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1125 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1126 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1127 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1128 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1129 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1130 | CURLcode ret = dav_session_curl_perform(sn, NULL); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1131 | curl_easy_setopt(handle, CURLOPT_NOBODY, 0L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1132 | return ret; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1133 | } |
181
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1134 | |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1135 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1136 | CURLcode do_copy_move_request(DavSession *sn, char *dest, char *lock, DavBool copy, DavBool override) { |
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1137 | CURL *handle = sn->handle; |
181
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1138 | if(copy) { |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1139 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "COPY"); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1140 | } else { |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1141 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "MOVE"); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1142 | } |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1143 | curl_easy_setopt(handle, CURLOPT_PUT, 0L); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1144 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1145 | |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1146 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1147 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1148 | |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1149 | struct curl_slist *headers = NULL; |
236
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1150 | if(lock) { |
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1151 | char *url = NULL; |
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1152 | curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1153 | char *ltheader = cx_asprintf("If: <%s> (<%s>)", url, lock).ptr; |
236
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1154 | headers = curl_slist_append(headers, ltheader); |
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1155 | free(ltheader); |
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1156 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1157 | //cxstring deststr = ucx_sprintf("Destination: %s", dest); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1158 | cxmutstr deststr = cx_strcat(2, CX_STR("Destination: "), cx_str(dest)); |
181
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1159 | headers = curl_slist_append(headers, deststr.ptr); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1160 | if(override) { |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1161 | headers = curl_slist_append(headers, "Overwrite: T"); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1162 | } else { |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1163 | headers = curl_slist_append(headers, "Overwrite: F"); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1164 | } |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1165 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1166 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1167 | CURLcode ret = dav_session_curl_perform(sn, NULL); |
181
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1168 | free(deststr.ptr); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1169 | curl_slist_free_all(headers); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1170 | headers = NULL; |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1171 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1172 | return ret; |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1173 | } |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1174 | |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1175 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1176 | CxBuffer* create_lock_request(void) { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1177 | CxBuffer *buf = cxBufferCreate(NULL, 512, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1178 | cxstring s; |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1179 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1180 | s = CX_STR("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1181 | cxBufferWrite(s.ptr, 1, s.length, buf); |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1182 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1183 | s = CX_STR("<D:lockinfo xmlns:D=\"DAV:\">\n" |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1184 | "<D:lockscope><D:exclusive/></D:lockscope>\n" |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1185 | "<D:locktype><D:write/></D:locktype>\n" |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1186 | "<D:owner><D:href>http://davutils.org/libidav/</D:href></D:owner>\n"); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1187 | cxBufferWrite(s.ptr, 1, s.length, buf); |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1188 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1189 | s = CX_STR("</D:lockinfo>\n"); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1190 | cxBufferWrite(s.ptr, 1, s.length, buf); |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1191 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1192 | return buf; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1193 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1194 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1195 | int parse_lock_response(DavSession *sn, CxBuffer *response, LockDiscovery *lock) { |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1196 | lock->locktoken = NULL; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1197 | lock->timeout = NULL; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1198 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1199 | xmlDoc *doc = xmlReadMemory(response->space, response->size, NULL, NULL, 0); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1200 | if(!doc) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1201 | sn->error = DAV_ERROR; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1202 | return -1; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1203 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1204 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1205 | char *timeout = NULL; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1206 | char *locktoken = NULL; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1207 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1208 | int ret = -1; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1209 | xmlNode *xml_root = xmlDocGetRootElement(doc); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1210 | DavBool lockdiscovery = 0; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1211 | if(xml_root) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1212 | xmlNode *node = xml_root->children; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1213 | while(node) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1214 | if(node->type == XML_ELEMENT_NODE) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1215 | if(xstreq(node->name, "lockdiscovery")) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1216 | node = node->children; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1217 | lockdiscovery = 1; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1218 | continue; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1219 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1220 | |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1221 | if(xstreq(node->name, "activelock")) { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1222 | node = node->children; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1223 | continue; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1224 | } |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1225 | |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1226 | if(lockdiscovery) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1227 | if(xstreq(node->name, "timeout")) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1228 | timeout = util_xml_get_text(node); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1229 | } else if(xstreq(node->name, "locktoken")) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1230 | xmlNode *n = node->children; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1231 | while(n) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1232 | if(xstreq(n->name, "href")) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1233 | locktoken = util_xml_get_text(n); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1234 | break; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1235 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1236 | n = n->next; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1237 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1238 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1239 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1240 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1241 | node = node->next; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1242 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1243 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1244 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1245 | if(timeout && locktoken) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1246 | lock->timeout = strdup(timeout); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1247 | lock->locktoken = strdup(locktoken); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1248 | ret = 0; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1249 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1250 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1251 | xmlFreeDoc(doc); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1252 | return ret; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1253 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1254 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1255 | CURLcode do_lock_request(DavSession *sn, CxBuffer *request, CxBuffer *response, time_t timeout) { |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1256 | CURL *handle = sn->handle; |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1257 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "LOCK"); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1258 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1259 | request->pos = 0; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1260 | |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1261 | // clear headers |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1262 | struct curl_slist *headers = NULL; |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1263 | |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1264 | if(timeout != 0) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1265 | cxmutstr thdr; |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1266 | if(timeout < 0) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1267 | thdr = cx_asprintf("%s", "Timeout: Infinite"); |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1268 | } else { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1269 | thdr = cx_asprintf("Timeout: Second-%u", (unsigned int)timeout); |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1270 | } |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1271 | headers = curl_slist_append(headers, thdr.ptr); |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1272 | free(thdr.ptr); |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1273 | } |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1274 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1275 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1276 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1277 | curl_easy_setopt(handle, CURLOPT_READFUNCTION, cxBufferRead); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1278 | curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, cxBufferSeek); |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1279 | curl_easy_setopt(handle, CURLOPT_READDATA, request); |
753
8776125fd49c
fix crash when the seekfunction is used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
1280 | curl_easy_setopt(handle, CURLOPT_SEEKDATA, request); |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1281 | curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1282 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1283 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, cxBufferWrite); |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1284 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1285 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1286 | CURLcode ret = dav_session_curl_perform_buf(sn, request, response, NULL); |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1287 | |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1288 | if(headers) { |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1289 | curl_slist_free_all(headers); |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1290 | } |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1291 | |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1292 | return ret; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1293 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1294 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1295 | CURLcode do_unlock_request(DavSession *sn, char *locktoken) { |
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1296 | CURL *handle = sn->handle; |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1297 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "UNLOCK"); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1298 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1299 | |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1300 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1301 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1302 | |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1303 | // set lock-token header |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1304 | cxmutstr ltheader = cx_asprintf("Lock-Token: <%s>", locktoken); |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1305 | struct curl_slist *headers = curl_slist_append(NULL, ltheader.ptr); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1306 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1307 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1308 | CURLcode ret = dav_session_curl_perform(sn, NULL); |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1309 | curl_slist_free_all(headers); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1310 | free(ltheader.ptr); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1311 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1312 | return ret; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1313 | } |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1314 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1315 | CURLcode do_simple_request(DavSession *sn, char *method, char *locktoken) { |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1316 | CURL *handle = sn->handle; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1317 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, method); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1318 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1319 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1320 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1321 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1322 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1323 | // set lock-token header |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1324 | cxmutstr ltheader; |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1325 | struct curl_slist *headers = NULL; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1326 | if(locktoken) { |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1327 | ltheader = cx_asprintf("Lock-Token: <%s>", locktoken); |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1328 | headers = curl_slist_append(NULL, ltheader.ptr); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1329 | } |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1330 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1331 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1332 | CURLcode ret = dav_session_curl_perform(sn, NULL); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1333 | if(locktoken) { |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1334 | curl_slist_free_all(headers); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1335 | free(ltheader.ptr); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1336 | } |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1337 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1338 | return ret; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1339 | } |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1340 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1341 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1342 | CURLcode do_report_request(DavSession *sn, CxBuffer *request, CxBuffer *response) { |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1343 | CURL *handle = sn->handle; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1344 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "REPORT"); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1345 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1346 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 1); |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1347 | curl_easy_setopt(handle, CURLOPT_READFUNCTION, cxBufferRead); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1348 | curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, cxBufferSeek); |
753
8776125fd49c
fix crash when the seekfunction is used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
1349 | curl_easy_setopt(handle, CURLOPT_READDATA, request); |
8776125fd49c
fix crash when the seekfunction is used
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
747
diff
changeset
|
1350 | curl_easy_setopt(handle, CURLOPT_SEEKDATA, request); |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1351 | curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1352 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1353 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, cxBufferWrite); |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1354 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1355 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1356 | struct curl_slist *headers = NULL; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1357 | headers = curl_slist_append(headers, "Content-Type: text/xml"); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1358 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1359 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1360 | request->pos = 0; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1361 | response->size = response->pos = 0; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1362 | CURLcode ret = dav_session_curl_perform_buf(sn, request, response, NULL); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1363 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1364 | curl_slist_free_all(headers); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1365 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1366 | return ret; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1367 | } |