indent -kr -i8 -brf -bbb -fnc -l132 -nce on all of webcit-classic
[citadel.git] / webcit / dav_report.c
1
2 /*
3  * Handles GroupDAV REPORT requests.
4  *
5  * Copyright (c) 2005-2012 by the citadel.org team
6  *
7  * This program is open source software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License version 3.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
15
16
17 /* SAMPLE QUERIES TO WORK WITH *
18
19 REPORT /groupdav/calendar/ HTTP/1.1
20 Content-type: application/xml
21 Content-length: 349
22
23 <C:calendar-query xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:D="DAV:">
24   <D:prop>
25     <D:getetag/>
26   </D:prop>
27   <C:filter>
28     <C:comp-filter name="VCALENDAR">
29       <C:comp-filter name="VEVENT">
30         <C:time-range start="20111129T231445Z" end="20120207T231445Z"/>
31       </C:comp-filter>
32     </C:comp-filter>
33   </C:filter>
34 </C:calendar-query>
35
36
37 REPORT /groupdav/calendar/ HTTP/1.1
38 Content-type: application/xml
39 Content-length: 255
40
41 <C:calendar-query xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:D="DAV:">
42   <D:prop>
43     <D:getetag/>
44   </D:prop>
45   <C:filter>
46     <C:comp-filter name="VCALENDAR">
47       <C:comp-filter name="VEVENT"/>
48     </C:comp-filter>
49   </C:filter>
50 </C:calendar-query>
51
52 */
53
54 #include "webcit.h"
55 #include "webserver.h"
56 #include "dav.h"
57
58
59 /*
60  * The pathname is always going to be /groupdav/room_name/msg_num
61  */
62 void dav_report(void) {
63         char datestring[256];
64         time_t now = time(NULL);
65
66         http_datestring(datestring, sizeof datestring, now);
67         const char *req = ChrPtr(WC->upload);
68
69         syslog(LOG_DEBUG, "REPORT: \033[31m%s\033[0m", req);
70
71         hprintf("HTTP/1.1 500 Internal Server Error\r\n");
72         dav_common_headers();
73         hprintf("Date: %s\r\n", datestring);
74         hprintf("Content-Type: text/plain\r\n");
75         wc_printf("An internal error has occurred at %s:%d.\r\n", __FILE__, __LINE__);
76         end_burst();
77         return;
78 }
79
80
81
82 extern int ParseMessageListHeaders_EUID(StrBuf * Line,
83                                         const char **pos, message_summary * Msg, StrBuf * ConversionBuffer, void **ViewSpecific);
84
85 extern int DavUIDL_GetParamsGetServerCall(SharedMessageStatus * Stat,
86                                           void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen);
87
88 extern int DavUIDL_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper);
89
90 extern int DavUIDL_Cleanup(void **ViewSpecific);
91
92
93
94 void InitModule_REPORT(void) {
95         RegisterReadLoopHandlerset(eReadEUIDS,
96                                    DavUIDL_GetParamsGetServerCall,
97                                    NULL,
98                                    NULL, ParseMessageListHeaders_EUID, NULL, DavUIDL_RenderView_or_Tail, DavUIDL_Cleanup, NULL);
99
100 }