Sun, 21 May 2023 11:52:06 +0200
fix dav-sync crash
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); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | curl_easy_setopt(handle, CURLOPT_READDATA, request); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
73 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
74 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, cxBufferWrite); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | 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
|
76 | CxMap *respheaders = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 32); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
77 | respheaders->simple_destructor = free; |
170
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
78 | util_capture_header(handle, respheaders); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | |
171
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
80 | for(int i=0;i<maxretry;i++) { |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
81 | if (depth == 1) { |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
82 | headers = curl_slist_append(headers, "Depth: 1"); |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
83 | } else if (depth == -1) { |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
84 | headers = curl_slist_append(headers, "Depth: infinity"); |
163
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
85 | } else { |
171
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
86 | headers = curl_slist_append(headers, "Depth: 0"); |
163
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
87 | } |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
88 | 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
|
89 | 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
|
90 | |
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 | // 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
|
92 | 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
|
93 | response->size = response->pos = 0; |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
94 | 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
|
95 | curl_slist_free_all(headers); |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
96 | headers = NULL; |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
97 | |
170
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
98 | /* |
171
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
99 | * Handle two cases: |
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
100 | * 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
|
101 | * => 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
|
102 | * 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
|
103 | * => 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
|
104 | */ |
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
105 | 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
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | |
171
254326cbc1bc
simplified do_propfind_request
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
170
diff
changeset
|
110 | if(iishack) { |
170
cf054cded046
added depth header workaround for Microsoft IIS (tested with sharepoint)
Mike Becker <universe@uap-core.de>
parents:
166
diff
changeset
|
111 | depth = 0; |
163
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
112 | } else { |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
113 | break; |
c6d05f646b59
reimplemented redirects for propfind requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
162
diff
changeset
|
114 | } |
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 | |
176
747f3796eddd
improved util_capture_header when deactivating the capturing
Mike Becker <universe@uap-core.de>
parents:
172
diff
changeset
|
117 | // 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
|
118 | 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
|
119 | cxMapDestroy(respheaders); |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
120 | |
74
da079dc0724c
fixed many memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
121 | return ret; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
124 | 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
|
125 | 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
|
126 | cxstring s; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
128 | 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
|
129 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
131 | 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
|
132 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
134 | 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
|
135 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | return buf; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
140 | 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
|
141 | 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
|
142 | cxstring s; |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
143 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
144 | 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
|
145 | cxBufferWrite(s.ptr, 1, s.length, buf); |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
146 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
147 | 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
|
148 | cxBufferWrite(s.ptr, 1, s.length, buf); |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
149 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
150 | 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
|
151 | cxBufferWrite(s.ptr, 1, s.length, buf); |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
152 | |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
153 | return buf; |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
154 | } |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
155 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
156 | 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
|
157 | 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
|
158 | cxstring s; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
160 | int add_crypto_name = 1; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
161 | int add_crypto_key = 1; |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
162 | int add_crypto_hash = 1; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
163 | 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
|
164 | 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
|
165 | 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
|
166 | 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
|
167 | 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
|
168 | 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
|
169 | 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
|
170 | } |
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 | // 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
|
173 | // 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
|
174 | 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
|
175 | 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
|
176 | 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
|
177 | 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
|
178 | } 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
|
179 | 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
|
180 | 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
|
181 | } 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
|
182 | 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
|
183 | 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
|
184 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
185 | } |
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 | DavNamespace idav_ns; |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
190 | 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
|
191 | idav_ns.prefix = "idav"; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
192 | 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
|
193 | 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
|
194 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
195 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
196 | 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
|
197 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
198 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | // 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
|
200 | 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
|
201 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
202 | 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
|
203 | 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
|
204 | 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
|
205 | 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
|
206 | 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
|
207 | 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
|
208 | 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
|
209 | 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
|
210 | 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
|
211 | 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
|
212 | 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
|
213 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
215 | 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
|
216 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
217 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | // 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
|
219 | 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
|
220 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
221 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
222 | 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
|
223 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
224 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
225 | 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
|
226 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
227 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
228 | 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
|
229 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
230 | |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
231 | // crypto properties |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
232 | if(DAV_CRYPTO(sn) && !nocrypt) { |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
233 | 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
|
234 | 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
|
235 | 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
|
236 | 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
|
237 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
238 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
239 | 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
|
240 | 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
|
241 | 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
|
242 | 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
|
243 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
244 | } |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
245 | 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
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | cxBufferWrite(s.ptr, 1, s.length, buf); |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
250 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
251 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
252 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
253 | // 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
|
254 | 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
|
255 | 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
|
256 | 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
|
257 | 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
|
258 | 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
|
259 | 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
|
260 | 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
|
261 | 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
|
262 | 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
|
263 | 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
|
264 | 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
|
265 | 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
|
266 | 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
|
267 | } |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
268 | } |
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 | // 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
|
271 | 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
|
272 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
273 | cxMapDestroy(namespaces); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
274 | return buf; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
275 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
276 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
277 | 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
|
278 | 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
|
279 | cxstring s; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
280 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
281 | 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
|
282 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
283 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
284 | 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
|
285 | 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
|
286 | 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
|
287 | 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
|
288 | 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
|
289 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
290 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
291 | // 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
|
292 | 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
|
293 | 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
|
294 | 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
|
295 | 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
|
296 | 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
|
297 | 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
|
298 | 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
|
299 | 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
|
300 | 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
|
301 | 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
|
302 | 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
|
303 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
304 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
305 | // 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
|
306 | 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
|
307 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
308 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
309 | return buf; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
310 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
311 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
312 | 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
|
313 | 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
|
314 | if(!parser) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
315 | return NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
316 | } |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
317 | 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
|
318 | parser->current = NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
319 | if(parser->document) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
320 | 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
|
321 | if(xml_root) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
322 | 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
|
323 | while(node) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
324 | // find first response tag |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
325 | 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
|
326 | 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
|
327 | parser->current = node; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
328 | break; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
329 | } |
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 | node = node->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
332 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
333 | return parser; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
334 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
335 | xmlFreeDoc(parser->document); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
336 | } |
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 | free(parser); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
339 | return NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
340 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
341 | |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
342 | void destroy_propfind_parser(PropfindParser *parser) { |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
343 | if(parser->document) { |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
344 | xmlFreeDoc(parser->document); |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
345 | } |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
346 | free(parser); |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
347 | } |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
348 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
349 | 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
|
350 | if(parser->current == NULL) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
351 | return 0; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
352 | } |
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 | char *href = NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
355 | int iscollection = 0; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
356 | 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
|
357 | char *crypto_key = NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
358 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
359 | 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
|
360 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
361 | 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
|
362 | while(node) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
363 | 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
|
364 | 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
|
365 | 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
|
366 | 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
|
367 | // error |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
368 | return -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
369 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
370 | 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
|
371 | } 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
|
372 | xmlNode *n = node->children; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
373 | xmlNode *prop_node = NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
374 | int ok = 0; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
375 | // get the status code |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
376 | while(n) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
377 | 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
|
378 | 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
|
379 | prop_node = n; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
380 | } 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
|
381 | 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
|
382 | 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
|
383 | // error |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
384 | return -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
385 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
386 | 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
|
387 | 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
|
388 | // error |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
389 | return -1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
390 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
391 | 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
|
392 | 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
|
393 | ok = 1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
394 | } |
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 | n = n->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
398 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
399 | // 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
|
400 | if(ok) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
401 | n = prop_node->children; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
402 | while(n) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
403 | 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
|
404 | 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
|
405 | if(xstreq(n->name, "resourcetype")) { |
231
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
406 | if(parse_resource_type(n)) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
407 | iscollection = TRUE; |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
408 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
409 | } 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
|
410 | 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
|
411 | 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
|
412 | } 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
|
413 | 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
|
414 | } |
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 | n = n->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
418 | } |
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 | node = node->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
423 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
424 | |
156 | 425 | 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
|
426 | result->iscollection = iscollection; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
427 | 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
|
428 | 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
|
429 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
430 | // find next response tag |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
431 | 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
|
432 | while(next) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
433 | 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
|
434 | 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
|
435 | break; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
436 | } |
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 | next = next->next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
439 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
440 | parser->current = next; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
441 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
442 | return 1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
443 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
444 | |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
445 | void cleanup_response(ResponseTag *result) { |
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
446 | 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
|
447 | cxListDestroy(result->properties); |
148
f21ee22170bf
fixed many davql exec memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
448 | } |
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 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
451 | 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
|
452 | 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
|
453 | 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
|
454 | 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
|
455 | 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
|
456 | ret = 1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
457 | } 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
|
458 | 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
|
459 | 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
|
460 | 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
|
461 | ret = 1; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
462 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
463 | } |
141
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
464 | } else if(href_r.length == href_s.length + 1) { |
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
465 | if(href_r.ptr[href_r.length-1] == '/') { |
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
466 | 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
|
467 | 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
|
468 | ret = 1; |
b0c44be83276
fixed href comparison bug
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
137
diff
changeset
|
469 | } |
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 | } |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
472 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
473 | free(href_s.ptr); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
474 | free(href_r.ptr); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
475 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
476 | return ret; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
477 | } |
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 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
480 | 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
|
481 | char *url = NULL; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
482 | 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
|
483 | if(!root) { |
225
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
484 | printf("methods.c: TODO: remove\n"); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
485 | 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
|
486 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
487 | |
62
3b813c57c106
added property-set and property-get command
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
60
diff
changeset
|
488 | //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
|
489 | 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
|
490 | if(!doc) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
491 | // TODO: free stuff |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
492 | sn->error = DAV_ERROR; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
493 | return NULL; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
494 | } |
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 | xmlNode *xml_root = xmlDocGetRootElement(doc); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
497 | xmlNode *node = xml_root->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
498 | while(node) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
499 | if(node->type == XML_ELEMENT_NODE) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
500 | if(xstreq(node->name, "response")) { |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
501 | parse_response_tag(root, node); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
502 | } |
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 | node = node->next; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
505 | } |
74
da079dc0724c
fixed many memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
506 | xmlFreeDoc(doc); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
507 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
508 | return root; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
509 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
510 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
511 | 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
|
512 | // create resource |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
513 | 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
|
514 | 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
|
515 | 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
|
516 | if(!response->crypto_key) { |
225
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
517 | sn->error = DAV_ERROR; |
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
518 | 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
|
519 | return NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
520 | } |
147
458a8dc68048
added password based keys and fixed crash when keys are missing
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
141
diff
changeset
|
521 | 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
|
522 | if(!name) { |
225
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
523 | sn->error = DAV_ERROR; |
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
524 | 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
|
525 | return NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
526 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
527 | } 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
|
528 | 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
|
529 | int nlen = 0; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
530 | 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
|
531 | sn->handle, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
532 | resname.ptr, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
533 | resname.length, |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
534 | &nlen); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
535 | 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
|
536 | curl_free(uname); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
537 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
538 | |
137
01cb9aabff05
fixed horrible bugs, davql hopefully just works now (without order by yet)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
135
diff
changeset
|
539 | 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
|
540 | DavResource *res = NULL; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
541 | if(parent_path) { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
542 | 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
|
543 | } else { |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
544 | 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
|
545 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
546 | 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
|
547 | |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
548 | add_properties(res, response); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
549 | return res; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
550 | } |
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 | 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
|
553 | res->iscollection = response->iscollection; |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
554 | |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
555 | int decrypt_props = DAV_ENCRYPT_PROPERTIES(res->session); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
556 | xmlNode *crypto_prop = NULL; |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
557 | char *crypto_key = NULL; |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
558 | |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
559 | // 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
|
560 | 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
|
561 | 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
|
562 | 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
|
563 | 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
|
564 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
565 | 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
|
566 | 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
|
567 | 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
|
568 | 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
|
569 | { |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
570 | 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
|
571 | 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
|
572 | } 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
|
573 | 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
|
574 | } |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
575 | } |
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 | if(crypto_prop && crypto_key) { |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
580 | char *crypto_prop_content = util_xml_get_text(crypto_prop); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
581 | 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
|
582 | 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
|
583 | 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
|
584 | resource_set_crypto_properties(res, cprops); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
585 | } |
128
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
586 | } |
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 | set_davprops(res); |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
589 | } |
649eb328674a
implemented minimal executor features and added missing ucx files
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
590 | |
135
664aeaec8d25
replaced old davql (still buggy)
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
128
diff
changeset
|
591 | int parse_response_tag(DavResource *resource, xmlNode *node) { |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
592 | DavSession *sn = resource->session; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
593 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
594 | //DavResource *res = resource; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
595 | 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
|
596 | 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
|
597 | CxList *properties = cxLinkedListCreateSimple(CX_STORE_POINTERS); // xmlNode list |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
598 | 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
|
599 | char *crypto_key = NULL; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
600 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
601 | int iscollection = 0; // TODO: remove |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
602 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
603 | node = node->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
604 | while(node) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
605 | if(node->type == XML_ELEMENT_NODE) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
606 | if(xstreq(node->name, "href")) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
607 | xmlNode *href_node = node->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
608 | if(href_node->type != XML_TEXT_NODE) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
609 | // error |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
610 | sn->error = DAV_ERROR; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
611 | return 1; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
612 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
613 | //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
|
614 | 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
|
615 | |
164
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
616 | 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
|
617 | 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
|
618 | |
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
619 | if(hrefeq(sn, href_s, href_r)) { |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
620 | res = resource; |
164
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
621 | } |
66 | 622 | |
164
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
623 | free(href_s); |
4c204e40ef52
fixed href comparison in parse_response_tag
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
163
diff
changeset
|
624 | free(href_r); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
625 | } else if(xstreq(node->name, "propstat")) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
626 | xmlNode *n = node->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
627 | xmlNode *prop_node = NULL; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
628 | int ok = 0; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
629 | // get the status code |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
630 | while(n) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
631 | if(n->type == XML_ELEMENT_NODE) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
632 | if(xstreq(n->name, "prop")) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
633 | prop_node = n; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
634 | } else if(xstreq(n->name, "status")) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
635 | xmlNode *status_node = n->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
636 | if(status_node->type != XML_TEXT_NODE) { |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
637 | sn->error = DAV_ERROR; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
638 | return 1; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
639 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
640 | 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
|
641 | if(status_str.length < 13) { |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
642 | sn->error = DAV_ERROR; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
643 | return 1; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
644 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
645 | 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
|
646 | 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
|
647 | ok = 1; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
648 | } |
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 | n = n->next; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
652 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
653 | // if status is ok, get all properties |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
654 | if(ok) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
655 | n = prop_node->children; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
656 | while(n) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
657 | 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
|
658 | cxListAdd(properties, n); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
659 | if(xstreq(n->name, "resourcetype")) { |
231
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
660 | if(parse_resource_type(n)) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
661 | iscollection = TRUE; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
662 | } |
743
716f6bf04c30
fix crash if the server sends a response with elements without namespaces
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
638
diff
changeset
|
663 | } 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
|
664 | if(xstreq(n->name, "crypto-name")) { |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
665 | crypto_name = util_xml_get_text(n); |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
666 | } else if(xstreq(n->name, "crypto-key")) { |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
667 | crypto_key = util_xml_get_text(n); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
668 | } |
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 | n = n->next; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
672 | } |
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 | node = node->next; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
678 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
679 | |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
680 | if(!res) { |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
681 | // create new resource object |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
682 | char *name = NULL; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
683 | if(DAV_DECRYPT_NAME(sn) && crypto_name) { |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
684 | if(!crypto_key) { |
225
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
685 | sn->error = DAV_ERROR; |
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
686 | 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
|
687 | return -1; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
688 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
689 | name = util_decrypt_str(sn, crypto_name, crypto_key); |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
690 | if(!name) { |
225
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
691 | sn->error = DAV_ERROR; |
a297c2e28fa1
improved error handling in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
223
diff
changeset
|
692 | 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
|
693 | return -1; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
694 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
695 | } 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
|
696 | cxstring resname = cx_str(util_resource_name(href)); |
44
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
697 | int nlen = 0; |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
698 | char *uname = curl_easy_unescape( |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
699 | sn->handle, |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
700 | resname.ptr, |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
701 | resname.length, |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
702 | &nlen); |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
703 | name = dav_session_strdup(sn, uname); |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
704 | curl_free(uname); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
705 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
706 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
707 | 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
|
708 | 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
|
709 | |
e4e23a88d4de
added missing url decode
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
43
diff
changeset
|
710 | dav_session_free(sn, name); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
711 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
712 | res->iscollection = iscollection; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
713 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
714 | // add properties |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
715 | int decrypt_props = DAV_ENCRYPT_PROPERTIES(res->session); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
716 | xmlNode *crypto_prop = NULL; |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
717 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
718 | 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
|
719 | 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
|
720 | 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
|
721 | continue; |
716f6bf04c30
fix crash if the server sends a response with elements without namespaces
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
638
diff
changeset
|
722 | } |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
723 | 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
|
724 | |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
725 | if (decrypt_props && |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
726 | prop->children && |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
727 | prop->children->type == XML_TEXT_NODE && |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
728 | xstreq(prop->ns->href, DAV_NS)) |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
729 | { |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
730 | if(xstreq(prop->name, "crypto-prop")) { |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
731 | crypto_prop = prop; |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
732 | } |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
733 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
734 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
735 | cxListDestroy(properties); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
736 | |
609
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
737 | if(crypto_prop && crypto_key) { |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
738 | char *crypto_prop_content = util_xml_get_text(crypto_prop); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
739 | 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
|
740 | 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
|
741 | 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
|
742 | resource_set_crypto_properties(res, cprops); |
dc3d70848c7c
implement encrypted properties
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
517
diff
changeset
|
743 | } |
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 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
747 | set_davprops(res); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
748 | if(res != resource) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
749 | resource_add_child(resource, res); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
750 | } |
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 | return 0; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
753 | } |
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 | 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
|
756 | 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
|
757 | 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
|
758 | 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
|
759 | 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
|
760 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
761 | res->contenttype = ct; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
762 | if(cl) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
763 | char *end = NULL; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
764 | res->contentlength = strtoull(cl, &end, 0); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
765 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
766 | res->creationdate = util_parse_creationdate(cd); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
767 | res->lastmodified = util_parse_lastmodified(lm); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
768 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
769 | |
231
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
770 | int parse_resource_type(xmlNode *node) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
771 | int collection = FALSE; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
772 | xmlNode *c = node->children; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
773 | while(c) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
774 | if(c->type == XML_ELEMENT_NODE) { |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
775 | 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
|
776 | collection = TRUE; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
777 | break; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
778 | } |
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 | c = c->next; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
781 | } |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
782 | return collection; |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
783 | } |
f3119e749549
fixed lazy propfind parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
227
diff
changeset
|
784 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
785 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
786 | /* ----------------------------- PROPPATCH ----------------------------- */ |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
787 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
788 | CURLcode do_proppatch_request( |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
789 | DavSession *sn, |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
790 | 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
|
791 | 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
|
792 | CxBuffer *response) |
638
b3077bdb3d77
fix hash based conflict detection
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
609
diff
changeset
|
793 | { |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
794 | CURL *handle = sn->handle; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
795 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "PROPPATCH"); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
796 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
797 | struct curl_slist *headers = NULL; |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
798 | 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
|
799 | if(lock) { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
800 | char *url = NULL; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
801 | 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
|
802 | 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
|
803 | headers = curl_slist_append(headers, ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
804 | free(ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
805 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
806 | } |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
807 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
808 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
809 | 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
|
810 | 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
|
811 | curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, cxBufferSeek); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
812 | curl_easy_setopt(handle, CURLOPT_READDATA, request); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
813 | curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
814 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
815 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, cxBufferWrite); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
816 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
817 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
818 | cxBufferSeek(request, 0, SEEK_SET); |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
819 | 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
|
820 | 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
|
821 | |
373
dcc03142eb5f
dav info prints simplified xml values
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
371
diff
changeset
|
822 | //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
|
823 | |
74
da079dc0724c
fixed many memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
824 | return ret; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
825 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
826 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
827 | 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
|
828 | 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
|
829 | cxstring s; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
830 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
831 | 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
|
832 | namespaces->simple_destructor = free; |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
833 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
834 | char prefix[8]; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
835 | int pfxnum = 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
|
836 | if(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
|
837 | 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
|
838 | 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
|
839 | 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
|
840 | snprintf(prefix, 8, "x%d", pfxnum++); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
841 | cxMapPut(namespaces, cx_hash_key_str(p->ns->name), strdup(prefix)); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
842 | } |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
843 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
844 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
845 | if(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
|
846 | 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
|
847 | 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
|
848 | 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
|
849 | snprintf(prefix, 8, "x%d", pfxnum++); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
850 | cxMapPut(namespaces, cx_hash_key_str(p->ns->name), strdup(prefix)); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
851 | } |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
852 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
853 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
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 | 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
|
856 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
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 | // 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
|
859 | 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
|
860 | 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
|
861 | 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
|
862 | 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
|
863 | 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
|
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 | 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
|
866 | 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
|
867 | 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
|
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_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
|
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); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
873 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
874 | 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
|
875 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
876 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
877 | 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
|
878 | 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
|
879 | 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
|
880 | 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
|
881 | 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
|
882 | 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
|
883 | if(!prefix) { |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
884 | prefix = "D"; |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
885 | } |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
886 | |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
887 | // 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
|
888 | 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
|
889 | 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
|
890 | 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
|
891 | 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
|
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(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
|
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); |
331
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
898 | |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
899 | // content |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
900 | 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
|
901 | 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
|
902 | 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
|
903 | } 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
|
904 | 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
|
905 | } |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
906 | |
9ca1e4706acc
adds initial support for xml properties in libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
315
diff
changeset
|
907 | // 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
|
908 | 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
|
909 | 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
|
910 | 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
|
911 | 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
|
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(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
|
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(">\n"); |
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); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
918 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
919 | 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
|
920 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
921 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
922 | 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
|
923 | 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
|
924 | 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
|
925 | 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
|
926 | 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
|
927 | 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
|
928 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
929 | 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
|
930 | 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
|
931 | 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
|
932 | 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
|
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(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
|
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(" />\n"); |
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); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
939 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
940 | 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
|
941 | cxBufferWrite(s.ptr, 1, s.length, buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
942 | } |
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: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
|
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 | |
223
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
947 | // 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
|
948 | cxMapDestroy(namespaces); |
181
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
949 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
950 | return buf; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
951 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
952 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
953 | 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
|
954 | 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
|
955 | cxstring s; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
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 | 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
|
958 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
959 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
960 | 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
|
961 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
962 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
963 | 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
|
964 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
965 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
966 | 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
|
967 | 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
|
968 | cxBufferWrite(s.ptr, 1, s.length, buf); |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
969 | 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
|
970 | cxBufferPutString(buf, crname); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
971 | 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
|
972 | 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
|
973 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
974 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
975 | |
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-key>"); |
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); |
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
978 | 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
|
979 | 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
|
980 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
981 | |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
982 | 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
|
983 | 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
|
984 | 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
|
985 | 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
|
986 | 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
|
987 | cxBufferWrite(s.ptr, 1, s.length, buf); |
150
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
988 | } |
37fb12574acd
added checksums for encrypted resources
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
148
diff
changeset
|
989 | |
747
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("</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
|
991 | cxBufferWrite(s.ptr, 1, s.length, buf); |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
992 | |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
993 | return buf; |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
994 | } |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
995 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
996 | /* ----------------------------- PUT ----------------------------- */ |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
997 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
998 | 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
|
999 | //fwrite(buf, s, n, stdout); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1000 | return s*n; |
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 | |
478
baa63fef5c5c
fixes redirects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
475
diff
changeset
|
1003 | 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
|
1004 | CURL *handle = sn->handle; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1005 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, NULL); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1006 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1007 | |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1008 | // clear headers |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1009 | struct curl_slist *headers = NULL; |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1010 | if(lock) { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1011 | char *url = NULL; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1012 | 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
|
1013 | char *ltheader = NULL; |
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1014 | if(create) { |
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1015 | 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
|
1016 | 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
|
1017 | free(url); |
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1018 | } 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
|
1019 | 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
|
1020 | } |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1021 | headers = curl_slist_append(headers, ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1022 | free(ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1023 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1024 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1025 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1026 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1027 | CxBuffer *buf = NULL; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1028 | 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
|
1029 | buf = cxBufferCreate(data, length, cxDefaultAllocator, 0); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1030 | buf->size = length; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1031 | 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
|
1032 | read_func = (dav_read_func)cxBufferRead; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1033 | 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
|
1034 | } else if(length == 0) { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1035 | headers = curl_slist_append(headers, "Transfer-Encoding: chunked"); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1036 | curl_easy_setopt(handle, CURLOPT_INFILESIZE_LARGE, (curl_off_t)1); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1037 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1038 | } else { |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1039 | 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
|
1040 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1041 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1042 | curl_easy_setopt(handle, CURLOPT_READFUNCTION, read_func); |
478
baa63fef5c5c
fixes redirects
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
475
diff
changeset
|
1043 | curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, seek_func); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1044 | curl_easy_setopt(handle, CURLOPT_READDATA, data); |
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_WRITEFUNCTION, dummy_write); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1047 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1048 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1049 | CURLcode ret = dav_session_curl_perform(sn, NULL); |
74
da079dc0724c
fixed many memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
66
diff
changeset
|
1050 | curl_slist_free_all(headers); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1051 | 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
|
1052 | cxBufferFree(buf); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1053 | } |
223
cbbdf207e67e
fixed some bugs in dav_create() and dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
208
diff
changeset
|
1054 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1055 | return ret; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1056 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1057 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1058 | 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
|
1059 | CURL *handle = sn->handle; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1060 | struct curl_slist *headers = NULL; |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1061 | if(lock) { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1062 | char *url = NULL; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1063 | 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
|
1064 | 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
|
1065 | headers = curl_slist_append(headers, ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1066 | free(ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1067 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1068 | } else { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1069 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1070 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1071 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1072 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "DELETE"); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1073 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1074 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1075 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, cxBufferWrite); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1076 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1077 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1078 | 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
|
1079 | curl_slist_free_all(headers); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1080 | return ret; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1081 | } |
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 do_mkcol_request(DavSession *sn, char *lock) { |
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1084 | CURL *handle = sn->handle; |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1085 | struct curl_slist *headers = NULL; |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1086 | if(lock) { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1087 | char *url = NULL; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1088 | 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
|
1089 | 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
|
1090 | 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
|
1091 | free(url); |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1092 | headers = curl_slist_append(headers, ltheader); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1093 | free(ltheader); |
227
bf485439222a
fixed locking in dav-sync push
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
225
diff
changeset
|
1094 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1095 | } else { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1096 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, NULL); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1097 | } |
43
03076907b58a
added file name encryption
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
38
diff
changeset
|
1098 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1099 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "MKCOL"); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1100 | curl_easy_setopt(handle, CURLOPT_PUT, 0L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1101 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1102 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1103 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1104 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1105 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1106 | 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
|
1107 | curl_slist_free_all(headers); |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1108 | return ret; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1109 | } |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1110 | |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1111 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1112 | CURLcode do_head_request(DavSession *sn) { |
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1113 | CURL *handle = sn->handle; |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1114 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "HEAD"); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1115 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1116 | curl_easy_setopt(handle, CURLOPT_NOBODY, 1L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1117 | |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1118 | // clear headers |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1119 | struct curl_slist *headers = NULL; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1120 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1121 | |
33
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1122 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1123 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1124 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1125 | 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
|
1126 | curl_easy_setopt(handle, CURLOPT_NOBODY, 0L); |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1127 | return ret; |
0bbbb0341606
some code cleanup and bug fixes
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1128 | } |
181
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1129 | |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1130 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1131 | 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
|
1132 | CURL *handle = sn->handle; |
181
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1133 | if(copy) { |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1134 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "COPY"); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1135 | } else { |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1136 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "MOVE"); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1137 | } |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1138 | curl_easy_setopt(handle, CURLOPT_PUT, 0L); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1139 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1140 | |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1141 | 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
|
1142 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1143 | |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1144 | struct curl_slist *headers = NULL; |
236
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1145 | if(lock) { |
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1146 | char *url = NULL; |
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1147 | 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
|
1148 | 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
|
1149 | headers = curl_slist_append(headers, ltheader); |
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1150 | free(ltheader); |
6b4ce32d0c4e
copy/move with lock tokens works now
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
231
diff
changeset
|
1151 | } |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1152 | //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
|
1153 | 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
|
1154 | headers = curl_slist_append(headers, deststr.ptr); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1155 | if(override) { |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1156 | headers = curl_slist_append(headers, "Overwrite: T"); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1157 | } else { |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1158 | headers = curl_slist_append(headers, "Overwrite: F"); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1159 | } |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1160 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1161 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1162 | 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
|
1163 | free(deststr.ptr); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1164 | curl_slist_free_all(headers); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1165 | headers = NULL; |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1166 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1167 | return ret; |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1168 | } |
a8f8cdbf85df
implemented webdav copy and move method
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
176
diff
changeset
|
1169 | |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1170 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1171 | 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
|
1172 | 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
|
1173 | cxstring s; |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1174 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1175 | 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
|
1176 | 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
|
1177 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1178 | 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
|
1179 | "<D:lockscope><D:exclusive/></D:lockscope>\n" |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1180 | "<D:locktype><D:write/></D:locktype>\n" |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1181 | "<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
|
1182 | 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
|
1183 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1184 | 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
|
1185 | 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
|
1186 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1187 | return buf; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1188 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1189 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1190 | 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
|
1191 | lock->locktoken = NULL; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1192 | lock->timeout = NULL; |
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 | 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
|
1195 | if(!doc) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1196 | sn->error = DAV_ERROR; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1197 | return -1; |
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 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1200 | char *timeout = NULL; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1201 | char *locktoken = NULL; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1202 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1203 | int ret = -1; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1204 | xmlNode *xml_root = xmlDocGetRootElement(doc); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1205 | DavBool lockdiscovery = 0; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1206 | if(xml_root) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1207 | xmlNode *node = xml_root->children; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1208 | while(node) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1209 | if(node->type == XML_ELEMENT_NODE) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1210 | if(xstreq(node->name, "lockdiscovery")) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1211 | node = node->children; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1212 | lockdiscovery = 1; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1213 | continue; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1214 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1215 | |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1216 | if(xstreq(node->name, "activelock")) { |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1217 | node = node->children; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1218 | continue; |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1219 | } |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1220 | |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1221 | if(lockdiscovery) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1222 | if(xstreq(node->name, "timeout")) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1223 | timeout = util_xml_get_text(node); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1224 | } else if(xstreq(node->name, "locktoken")) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1225 | xmlNode *n = node->children; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1226 | while(n) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1227 | if(xstreq(n->name, "href")) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1228 | locktoken = util_xml_get_text(n); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1229 | break; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1230 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1231 | n = n->next; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1232 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1233 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1234 | } |
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 | node = node->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 | if(timeout && locktoken) { |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1241 | lock->timeout = strdup(timeout); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1242 | lock->locktoken = strdup(locktoken); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1243 | ret = 0; |
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 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1246 | xmlFreeDoc(doc); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1247 | return ret; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1248 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1249 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1250 | 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
|
1251 | CURL *handle = sn->handle; |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1252 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "LOCK"); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1253 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 1L); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1254 | request->pos = 0; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1255 | |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1256 | // clear headers |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1257 | struct curl_slist *headers = NULL; |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1258 | |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1259 | 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
|
1260 | cxmutstr thdr; |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1261 | 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
|
1262 | thdr = cx_asprintf("%s", "Timeout: Infinite"); |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1263 | } 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
|
1264 | thdr = cx_asprintf("Timeout: Second-%u", (unsigned int)timeout); |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1265 | } |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1266 | headers = curl_slist_append(headers, thdr.ptr); |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1267 | free(thdr.ptr); |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1268 | } |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1269 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1270 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1271 | 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
|
1272 | 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
|
1273 | 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
|
1274 | curl_easy_setopt(handle, CURLOPT_READDATA, request); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1275 | 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
|
1276 | |
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_WRITEFUNCTION, cxBufferWrite); |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1278 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1279 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1280 | 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
|
1281 | |
315
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1282 | if(headers) { |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1283 | curl_slist_free_all(headers); |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1284 | } |
7db4dbf4e6f9
adds lock timeout
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
236
diff
changeset
|
1285 | |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1286 | return ret; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1287 | } |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1288 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1289 | 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
|
1290 | CURL *handle = sn->handle; |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1291 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "UNLOCK"); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1292 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1293 | |
208
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1294 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1295 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
1fb26aca5093
added API for webdav locking
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
207
diff
changeset
|
1296 | |
207
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1297 | // 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
|
1298 | 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
|
1299 | 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
|
1300 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1301 | |
354
067ea2315a8a
moves auth prompt functionality to libidav
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
331
diff
changeset
|
1302 | 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
|
1303 | curl_slist_free_all(headers); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1304 | free(ltheader.ptr); |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1305 | |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1306 | return ret; |
de23f8881e9f
fixed hash verification and head requests
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
185
diff
changeset
|
1307 | } |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1308 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1309 | 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
|
1310 | CURL *handle = sn->handle; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1311 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, method); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1312 | curl_easy_setopt(handle, CURLOPT_UPLOAD, 0L); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1313 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1314 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, dummy_write); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1315 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, NULL); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1316 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1317 | // 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
|
1318 | cxmutstr ltheader; |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1319 | struct curl_slist *headers = NULL; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1320 | 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
|
1321 | ltheader = cx_asprintf("Lock-Token: <%s>", locktoken); |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1322 | headers = curl_slist_append(NULL, ltheader.ptr); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1323 | } |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1324 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1325 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1326 | CURLcode ret = dav_session_curl_perform(sn, NULL); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1327 | if(locktoken) { |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1328 | curl_slist_free_all(headers); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1329 | free(ltheader.ptr); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1330 | } |
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 | return ret; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1333 | } |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1334 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1335 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1336 | 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
|
1337 | CURL *handle = sn->handle; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1338 | curl_easy_setopt(handle, CURLOPT_CUSTOMREQUEST, "REPORT"); |
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 | 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
|
1341 | 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
|
1342 | curl_easy_setopt(handle, CURLOPT_SEEKFUNCTION, cxBufferSeek); |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1343 | curl_easy_setopt(handle, CURLOPT_READDATA, request); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1344 | curl_easy_setopt(handle, CURLOPT_INFILESIZE, request->size); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1345 | |
747
efbd59642577
ucx 3 update, basic dav commands work, most stuff is still broken
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
743
diff
changeset
|
1346 | curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, cxBufferWrite); |
475
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1347 | curl_easy_setopt(handle, CURLOPT_WRITEDATA, response); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1348 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1349 | struct curl_slist *headers = NULL; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1350 | headers = curl_slist_append(headers, "Content-Type: text/xml"); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1351 | curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1352 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1353 | request->pos = 0; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1354 | response->size = response->pos = 0; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1355 | 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
|
1356 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1357 | curl_slist_free_all(headers); |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1358 | |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1359 | return ret; |
52e4171d42ce
adds minimal deltav implementation
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
373
diff
changeset
|
1360 | } |