| 101 * => try with depth 0 next time, it's not a collection |
101 * => try with depth 0 next time, it's not a collection |
| 102 * 2. Other cases |
102 * 2. Other cases |
| 103 * => the server handled our request and we can stop requesting |
103 * => the server handled our request and we can stop requesting |
| 104 */ |
104 */ |
| 105 char *msdavexterror; |
105 char *msdavexterror; |
| 106 msdavexterror = cxMapGet(respheaders, cx_hash_key_str("x-msdavext_error")); |
106 msdavexterror = cxMapGet(respheaders, "x-msdavext_error"); |
| 107 int iishack = depth == 1 && |
107 int iishack = depth == 1 && |
| 108 msdavexterror && !strncmp(msdavexterror, "589831;", 7); |
108 msdavexterror && !strncmp(msdavexterror, "589831;", 7); |
| 109 |
109 |
| 110 if(iishack) { |
110 if(iishack) { |
| 111 depth = 0; |
111 depth = 0; |
| 164 CxMap *namespaces = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8); |
164 CxMap *namespaces = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 8); |
| 165 if(properties) { |
165 if(properties) { |
| 166 CxIterator i = cxListIterator(properties); |
166 CxIterator i = cxListIterator(properties); |
| 167 cx_foreach(DavProperty*, p, i) { |
167 cx_foreach(DavProperty*, p, i) { |
| 168 if(strcmp(p->ns->name, "DAV:")) { |
168 if(strcmp(p->ns->name, "DAV:")) { |
| 169 cxMapPut(namespaces, cx_hash_key_str(p->ns->prefix), p->ns); |
169 cxMapPut(namespaces, p->ns->prefix, p->ns); |
| 170 } |
170 } |
| 171 |
171 |
| 172 // if the properties list contains the idav properties crypto-name |
172 // if the properties list contains the idav properties crypto-name |
| 173 // and crypto-key, mark them as existent |
173 // and crypto-key, mark them as existent |
| 174 if(!strcmp(p->ns->name, DAV_NS)) { |
174 if(!strcmp(p->ns->name, DAV_NS)) { |
| 188 |
188 |
| 189 DavNamespace idav_ns; |
189 DavNamespace idav_ns; |
| 190 if(add_crypto_name && add_crypto_key && DAV_CRYPTO(sn) && !nocrypt) { |
190 if(add_crypto_name && add_crypto_key && DAV_CRYPTO(sn) && !nocrypt) { |
| 191 idav_ns.prefix = "idav"; |
191 idav_ns.prefix = "idav"; |
| 192 idav_ns.name = DAV_NS; |
192 idav_ns.name = DAV_NS; |
| 193 cxMapPut(namespaces, cx_hash_key_str("idav"), &idav_ns); |
193 cxMapPut(namespaces, "idav", &idav_ns); |
| 194 } |
194 } |
| 195 |
195 |
| 196 cxBufferPutString(buf, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
196 cxBufferPutString(buf, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"); |
| 197 |
197 |
| 198 // write root element and namespaces |
198 // write root element and namespaces |
| 802 if (data->set && cxListSize(data->set) > 0) { |
802 if (data->set && cxListSize(data->set) > 0) { |
| 803 CxIterator i = cxListIterator(data->set); |
803 CxIterator i = cxListIterator(data->set); |
| 804 cx_foreach(DavProperty*, p, i) { |
804 cx_foreach(DavProperty*, p, i) { |
| 805 if (strcmp(p->ns->name, "DAV:")) { |
805 if (strcmp(p->ns->name, "DAV:")) { |
| 806 snprintf(prefix, 8, "x%d", pfxnum++); |
806 snprintf(prefix, 8, "x%d", pfxnum++); |
| 807 cxMapPut(namespaces, cx_hash_key_str(p->ns->name), strdup(prefix)); |
807 cxMapPut(namespaces, p->ns->name, strdup(prefix)); |
| 808 } |
808 } |
| 809 } |
809 } |
| 810 } |
810 } |
| 811 if (data->remove && cxListSize(data->remove) > 0) { |
811 if (data->remove && cxListSize(data->remove) > 0) { |
| 812 CxIterator i = cxListIterator(data->remove); |
812 CxIterator i = cxListIterator(data->remove); |
| 813 cx_foreach(DavProperty*, p, i) { |
813 cx_foreach(DavProperty*, p, i) { |
| 814 if (strcmp(p->ns->name, "DAV:")) { |
814 if (strcmp(p->ns->name, "DAV:")) { |
| 815 snprintf(prefix, 8, "x%d", pfxnum++); |
815 snprintf(prefix, 8, "x%d", pfxnum++); |
| 816 cxMapPut(namespaces, cx_hash_key_str(p->ns->name), strdup(prefix)); |
816 cxMapPut(namespaces, p->ns->name, strdup(prefix)); |
| 817 } |
817 } |
| 818 } |
818 } |
| 819 } |
819 } |
| 820 } |
820 } |
| 821 |
821 |
| 835 |
835 |
| 836 if(data->set) { |
836 if(data->set) { |
| 837 cxBufferPutString(buf, "<D:set>\n<D:prop>\n"); |
837 cxBufferPutString(buf, "<D:set>\n<D:prop>\n"); |
| 838 CxIterator i = cxListIterator(data->set); |
838 CxIterator i = cxListIterator(data->set); |
| 839 cx_foreach(DavProperty*, property, i) { |
839 cx_foreach(DavProperty*, property, i) { |
| 840 char *prefix = cxMapGet(namespaces, cx_hash_key_str(property->ns->name)); |
840 char *prefix = cxMapGet(namespaces, property->ns->name); |
| 841 if(!prefix) { |
841 if(!prefix) { |
| 842 prefix = "D"; |
842 prefix = "D"; |
| 843 } |
843 } |
| 844 |
844 |
| 845 // begin tag |
845 // begin tag |
| 868 } |
868 } |
| 869 if(data->remove) { |
869 if(data->remove) { |
| 870 cxBufferPutString(buf, "<D:remove>\n<D:prop>\n"); |
870 cxBufferPutString(buf, "<D:remove>\n<D:prop>\n"); |
| 871 CxIterator i = cxListIterator(data->remove); |
871 CxIterator i = cxListIterator(data->remove); |
| 872 cx_foreach(DavProperty*, property, i) { |
872 cx_foreach(DavProperty*, property, i) { |
| 873 char *prefix = cxMapGet(namespaces, cx_hash_key_str(property->ns->name)); |
873 char *prefix = cxMapGet(namespaces, property->ns->name); |
| 874 |
874 |
| 875 cxBufferPutString(buf, "<"); |
875 cxBufferPutString(buf, "<"); |
| 876 cxBufferPutString(buf, prefix); |
876 cxBufferPutString(buf, prefix); |
| 877 cxBufferPutString(buf, ":"); |
877 cxBufferPutString(buf, ":"); |
| 878 cxBufferPutString(buf, property->name); |
878 cxBufferPutString(buf, property->name); |