4 * Handles GroupDAV PROPFIND requests.
14 #include <sys/types.h>
16 #include <sys/socket.h>
25 #include "webserver.h"
30 * The pathname is always going to be /groupdav/room_name/msg_num
32 void groupdav_propfind(char *dav_pathname) {
33 char dav_roomname[SIZ];
36 /* First, break off the "/groupdav/" prefix */
37 remove_token(dav_pathname, 0, '/');
38 remove_token(dav_pathname, 0, '/');
40 /* What's left is the room name. Remove trailing slashes. */
41 if (dav_pathname[strlen(dav_pathname)-1] == '/') {
42 dav_pathname[strlen(dav_pathname)-1] = 0;
44 strcpy(dav_roomname, dav_pathname);
46 /* Go to the correct room. */
47 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
48 gotoroom(dav_roomname);
50 if (strcasecmp(WC->wc_roomname, dav_roomname)) {
51 wprintf("HTTP/1.1 404 not found\n");
52 groupdav_common_headers();
54 "Content-Type: text/plain\n"
56 "There is no folder called \"%s\" on this server.\n",
63 * Be rude. Completely ignore the XML request and simply send them
64 * everything we know about (which is going to simply be the ETag and
65 * nothing else). Let the client-side parser sort it out.
67 wprintf("HTTP/1.0 207 Multi-Status\n");
68 groupdav_common_headers();
69 wprintf("Content-type: text/xml\n"
71 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
72 "<D:multistatus xmlns:D=\"DAV:\">\n"
75 serv_puts("MSGS ALL");
77 if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
78 wprintf(" <D:response>\n");
79 wprintf(" <D:href>%s/groupdav/Calendar/%s</D:href>\n", WC->http_host, buf);
80 wprintf(" <D:propstat>\n");
81 wprintf(" <D:status>HTTP/1.1 200 OK</D:status>\n");
82 wprintf(" <D:prop><D:getetag>\"%s\"</D:getetag></D:prop>\n", buf);
83 wprintf(" </D:propstat>\n");
84 wprintf(" </D:response>\n");
87 wprintf("</D:multistatus>\n");