* Re-added tiny_mce, this time with the language packs
[citadel.git] / webcit / groupdav_options.c
blob5f678c1e647b6e2485f44d8ad51ef276c2f0bab7
1 /*
2 * $Id$
4 * Handles DAV OPTIONS requests (experimental -- not required by GroupDAV)
6 */
8 #include "webcit.h"
9 #include "webserver.h"
10 #include "groupdav.h"
13 * The pathname is always going to be /groupdav/room_name/msg_num
15 void groupdav_options(StrBuf *dav_pathname) {
16 StrBuf *dav_roomname;
17 StrBuf *dav_uid;
18 long dav_msgnum = (-1);
19 char datestring[256];
20 time_t now;
22 now = time(NULL);
23 http_datestring(datestring, sizeof datestring, now);
25 dav_roomname = NewStrBuf();
26 dav_uid = NewStrBuf();
27 StrBufExtract_token(dav_roomname, dav_pathname, 2, '/');
28 StrBufExtract_token(dav_uid, dav_pathname, 3, '/');
31 * If the room name is blank, the client is doing a top-level OPTIONS.
33 if (StrLength(dav_roomname) == 0) {
34 hprintf("HTTP/1.1 200 OK\r\n");
35 groupdav_common_headers();
36 hprintf("Date: %s\r\n", datestring);
37 hprintf("DAV: 1\r\n");
38 hprintf("Allow: OPTIONS, PROPFIND\r\n");
39 hprintf("\r\n");
40 begin_burst();
41 end_burst();
42 FreeStrBuf(&dav_roomname);
43 FreeStrBuf(&dav_uid);
44 return;
47 /* Go to the correct room. */
48 if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
49 gotoroom(dav_roomname);
52 if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
53 hprintf("HTTP/1.1 404 not found\r\n");
54 groupdav_common_headers();
55 hprintf("Date: %s\r\n", datestring);
56 hprintf(
57 "Content-Type: text/plain\r\n"
58 "\r\n"
59 "There is no folder called \"%s\" on this server.\r\n",
60 ChrPtr(dav_roomname)
62 begin_burst();
63 end_burst();
64 FreeStrBuf(&dav_roomname);
65 FreeStrBuf(&dav_uid);
66 return;
69 /* If dav_uid is non-empty, client is requesting an OPTIONS on
70 * a specific item in the room.
72 if (StrLength(dav_uid) != 0) {
74 dav_msgnum = locate_message_by_uid(ChrPtr(dav_uid));
75 if (dav_msgnum < 0) {
76 hprintf("HTTP/1.1 404 not found\r\n");
77 groupdav_common_headers();
78 hprintf(
79 "Content-Type: text/plain\r\n"
80 "\r\n"
81 "Object \"%s\" was not found in the \"%s\" folder.\r\n",
82 ChrPtr(dav_uid),
83 ChrPtr(dav_roomname)
85 FreeStrBuf(&dav_roomname);
86 FreeStrBuf(&dav_uid);
87 begin_burst();end_burst();return;
90 hprintf("HTTP/1.1 200 OK\r\n");
91 groupdav_common_headers();
92 hprintf("Date: %s\r\n", datestring);
93 hprintf("DAV: 1\r\n");
94 hprintf("Allow: OPTIONS, PROPFIND, GET, PUT, DELETE\r\n");
95 hprintf("\r\n");
96 begin_burst();
97 end_burst();
98 FreeStrBuf(&dav_roomname);
99 FreeStrBuf(&dav_uid);
100 return;
103 FreeStrBuf(&dav_roomname);
104 FreeStrBuf(&dav_uid);
107 * We got to this point, which means that the client is requesting
108 * an OPTIONS on the room itself.
110 hprintf("HTTP/1.1 200 OK\r\n");
111 groupdav_common_headers();
112 hprintf("Date: %s\r\n", datestring);
113 hprintf("DAV: 1\r\n");
114 hprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n");
115 hprintf("\r\n");
116 begin_burst();
117 end_burst();