Mailing list header changes (fuck you Google)
[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 /* SAMPLE QUERIES TO WORK WITH *
17
18 REPORT /groupdav/calendar/ HTTP/1.1
19 Content-type: application/xml
20 Content-length: 349
21
22 <C:calendar-query xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:D="DAV:">
23   <D:prop>
24     <D:getetag/>
25   </D:prop>
26   <C:filter>
27     <C:comp-filter name="VCALENDAR">
28       <C:comp-filter name="VEVENT">
29         <C:time-range start="20111129T231445Z" end="20120207T231445Z"/>
30       </C:comp-filter>
31     </C:comp-filter>
32   </C:filter>
33 </C:calendar-query>
34
35
36 REPORT /groupdav/calendar/ HTTP/1.1
37 Content-type: application/xml
38 Content-length: 255
39
40 <C:calendar-query xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:D="DAV:">
41   <D:prop>
42     <D:getetag/>
43   </D:prop>
44   <C:filter>
45     <C:comp-filter name="VCALENDAR">
46       <C:comp-filter name="VEVENT"/>
47     </C:comp-filter>
48   </C:filter>
49 </C:calendar-query>
50
51 */
52
53 #include "webcit.h"
54 #include "webserver.h"
55 #include "dav.h"
56
57
58 /*
59  * The pathname is always going to be /groupdav/room_name/msg_num
60  */
61 void dav_report(void) 
62 {
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, 
84                                         message_summary *Msg, 
85                                         StrBuf *ConversionBuffer,
86                                         void **ViewSpecific);
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                 NULL
118         );
119
120 }