Readloop remove special cases
[citadel.git] / webcit / dav_report.c
1 /*
2  * Handles GroupDAV REPORT requests.
3  *
4  * Copyright (c) 2005-2012 by the citadel.org team
5  *
6  * This program is open source software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License version 3.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
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 {
64         char datestring[256];
65         time_t now = time(NULL);
66
67         http_datestring(datestring, sizeof datestring, now);
68         const char *req = ChrPtr(WC->upload);
69
70         syslog(LOG_DEBUG, "REPORT: \033[31m%s\033[0m", req);
71
72         hprintf("HTTP/1.1 500 Internal Server Error\r\n");
73         dav_common_headers();
74         hprintf("Date: %s\r\n", datestring);
75         hprintf("Content-Type: text/plain\r\n");
76         wc_printf("An internal error has occurred at %s:%d.\r\n", __FILE__ , __LINE__ );
77         end_burst();
78         return;
79 }
80
81
82
83 extern int ParseMessageListHeaders_EUID(StrBuf *Line, 
84                                  const char **pos, 
85                                  message_summary *Msg, 
86                                  StrBuf *ConversionBuffer);
87
88 extern int DavUIDL_GetParamsGetServerCall(SharedMessageStatus *Stat, 
89                                           void **ViewSpecific, 
90                                           long oper, 
91                                           char *cmd, 
92                                           long len,
93                                           char *filter,
94                                           long flen);
95
96 extern int DavUIDL_RenderView_or_Tail(SharedMessageStatus *Stat, 
97                                 void **ViewSpecific, 
98                                 long oper);
99
100 extern int DavUIDL_Cleanup(void **ViewSpecific);
101
102
103
104 void 
105 InitModule_REPORT
106 (void)
107 {
108         RegisterReadLoopHandlerset(
109                 eReadEUIDS,
110                 DavUIDL_GetParamsGetServerCall,
111                 NULL,
112                 NULL,
113                 ParseMessageListHeaders_EUID,
114                 NULL,
115                 DavUIDL_RenderView_or_Tail,
116                 DavUIDL_Cleanup
117         );
118
119 }