29 #include <stdio.h> |
29 #include <stdio.h> |
30 #include <stdlib.h> |
30 #include <stdlib.h> |
31 |
31 |
32 #include "../daemon/session.h" |
32 #include "../daemon/session.h" |
33 |
33 |
|
34 #include "operation.h" |
|
35 |
34 #include "multistatus.h" |
36 #include "multistatus.h" |
35 |
37 |
36 #define MULTISTATUS_BUFFER_LENGTH 2048 |
38 #define MULTISTATUS_BUFFER_LENGTH 2048 |
37 |
39 |
38 Multistatus* multistatus_response(Session *sn, Request *rq) { |
40 Multistatus* multistatus_response(Session *sn, Request *rq) { |
264 return NULL; |
266 return NULL; |
265 } |
267 } |
266 ZERO(res, sizeof(MSResponse)); |
268 ZERO(res, sizeof(MSResponse)); |
267 |
269 |
268 res->resource.addproperty = msresponse_addproperty; |
270 res->resource.addproperty = msresponse_addproperty; |
|
271 res->resource.close = msresponse_close; |
269 |
272 |
270 res->multistatus = ms; |
273 res->multistatus = ms; |
271 res->errors = NULL; |
274 res->errors = NULL; |
272 res->end = 0; |
275 res->resource.isclosed = 0; |
|
276 res->closing = 0; |
273 |
277 |
274 if(ms->current) { |
278 if(ms->current) { |
275 ms->current->end = 1; |
279 if(!ms->current->resource.isclosed) { |
|
280 msresponse_close((WebdavResource*)ms->current); |
|
281 } |
276 ms->current->next = res; |
282 ms->current->next = res; |
277 } else { |
283 } else { |
278 ms->first = res; |
284 ms->first = res; |
279 } |
285 } |
280 ms->current = res; |
286 ms->current = res; |
387 if(!errlist->begin) { |
393 if(!errlist->begin) { |
388 errlist->begin = newlistelm; |
394 errlist->begin = newlistelm; |
389 } |
395 } |
390 return 0; |
396 return 0; |
391 } |
397 } |
|
398 |
|
399 int msresponse_close(WebdavResource *res) { |
|
400 MSResponse *response = (MSResponse*)res; |
|
401 if(response->closing) { |
|
402 return 0; // close already in progress |
|
403 } |
|
404 |
|
405 int ret = REQ_PROCEED; |
|
406 WebdavOperation *op = response->multistatus->response.op; |
|
407 if(webdav_op_propfiond_close_resource(op, res)) { |
|
408 ret = REQ_ABORTED; |
|
409 } |
|
410 |
|
411 response->resource.isclosed = TRUE; |
|
412 response->closing = FALSE; |
|
413 return ret; |
|
414 } |