Mailing list header changes (fuck you Google)
[citadel.git] / webcit / jsonview_renderer.c
1 #include "webcit.h"
2 #include "webserver.h"
3 #include "dav.h"
4
5 int json_GetParamsGetServerCall(SharedMessageStatus *Stat, 
6                                 void **ViewSpecific, 
7                                 long oper, 
8                                 char *cmd, 
9                                 long len,
10                                 char *filter,
11                                 long flen)
12 {
13         Stat->defaultsortorder = 2;
14         Stat->sortit = 1;
15         Stat->load_seen = 1;
16         /* Generally using maxmsgs|startmsg is not required
17            in mailbox view, but we have a 'safemode' for clients
18            (*cough* Exploder) that simply can't handle too many */
19         if (havebstr("maxmsgs"))  Stat->maxmsgs  = ibstr("maxmsgs");
20         else                      Stat->maxmsgs  = 9999999;
21         if (havebstr("startmsg")) Stat->startmsg = lbstr("startmsg");
22         snprintf(cmd, len, "MSGS %s|%s||1",
23                  (oper == do_search) ? "SEARCH" : "ALL",
24                  (oper == do_search) ? bstr("query") : ""
25                 );
26
27         return 200;
28 }
29 int json_MessageListHdr(SharedMessageStatus *Stat, void **ViewSpecific) 
30 {
31         /* TODO: make a generic function */
32         hprintf("HTTP/1.1 200 OK\r\n");
33         hprintf("Content-type: application/json; charset=utf-8\r\n");
34         hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
35         hprintf("Connection: close\r\n");
36         hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
37         begin_burst();
38         return 0;
39 }
40
41 int json_RenderView_or_Tail(SharedMessageStatus *Stat, 
42                             void **ViewSpecific, 
43                             long oper)
44 {
45         DoTemplate(HKEY("mailsummary_json"),NULL, NULL);
46         
47         return 0;
48 }
49
50 int json_Cleanup(void **ViewSpecific)
51 {
52         /* Note: wDumpContent() will output one additional </div> tag. */
53         /* We ought to move this out into template */
54         end_burst();
55
56         return 0;
57 }
58
59 void 
60 InitModule_JSONRENDERER
61 (void)
62 {
63         RegisterReadLoopHandlerset(
64                 VIEW_JSON_LIST,
65                 json_GetParamsGetServerCall,
66                 json_MessageListHdr,
67                 NULL, /* TODO: is this right? */
68                 ParseMessageListHeaders_Detail,
69                 NULL,
70                 json_RenderView_or_Tail,
71                 json_Cleanup,
72                 NULL);
73
74 }