From 4b4dc864ede7c5d8d956febe4a0afb422b78e7c4 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 18 Feb 2012 17:21:44 +0100 Subject: [PATCH] Readloop remove special cases - add handler for initializing the page - add parameter to handler GetParamsGetServerCall() so clients can register a list filter to MSG4 - Json-view: use new initialisation handler to output the headers for the JSon-reply - Json-view: don't need the extra member on the session anymore. - Json-View: split functions into wrapper page and json list - wiki-view: register empty header output handler, since the sub-calls do this later. - wiki-view: use the GetParamsGetServerCall()-Callback to hook in our logic instead of tainting readloop() with special code. --- libcitadel/lib/libcitadel.h | 3 +- webcit/bbsview_renderer.c | 5 +- webcit/blogview_renderer.c | 5 +- webcit/calendar.c | 2 + webcit/calendar.h | 4 +- webcit/calendar_view.c | 4 +- webcit/dav_propfind.c | 11 ++-- webcit/dav_report.c | 11 ++-- webcit/feed_generator.c | 2 +- webcit/messages.c | 73 ++++++++++++----------- webcit/messages.h | 25 +++++++- webcit/mk_module_init.sh | 32 ++++++++++ webcit/msg_renderers.c | 114 ++++++++++++++++++++++++------------ webcit/notes.c | 5 +- webcit/siteconfig.c | 46 ++++++--------- webcit/sitemap.c | 6 +- webcit/summary.c | 10 +++- webcit/tasks.c | 5 +- webcit/useredit.c | 2 +- webcit/vcard_edit.c | 5 +- webcit/webcit.h | 1 - webcit/webserver.c | 1 + webcit/wiki.c | 26 +++++++- 23 files changed, 272 insertions(+), 126 deletions(-) diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index a0a70305a..d520eae4c 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -99,7 +99,8 @@ typedef enum _room_views { VIEW_DRAFTS = 9, /* Drafts view */ VIEW_BLOG = 10, /* Blog view */ VIEW_QUEUE = 11, /* SMTP/... QUEUE rooms */ - VIEW_MAX + VIEW_MAX, + VIEW_JSON_LIST, } ROOM_VIEWS; #define BLOG_EUIDBUF_SIZE 40 diff --git a/webcit/bbsview_renderer.c b/webcit/bbsview_renderer.c index 1406e83c1..8bed3af37 100644 --- a/webcit/bbsview_renderer.c +++ b/webcit/bbsview_renderer.c @@ -81,7 +81,9 @@ int bbsview_GetParamsGetServerCall(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, - long len) + long len, + char *filter, + long flen) { struct bbsview *BBS = malloc(sizeof(struct bbsview)); memset(BBS, 0, sizeof(struct bbsview)); @@ -417,6 +419,7 @@ InitModule_BBSVIEWRENDERERS VIEW_BBS, bbsview_GetParamsGetServerCall, NULL, + NULL, NULL, bbsview_LoadMsgFromServer, bbsview_RenderView_or_Tail, diff --git a/webcit/blogview_renderer.c b/webcit/blogview_renderer.c index 60faa8974..70fa908ae 100644 --- a/webcit/blogview_renderer.c +++ b/webcit/blogview_renderer.c @@ -104,7 +104,9 @@ int blogview_GetParamsGetServerCall(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, - long len) + long len, + char *filter, + long flen) { HashList *BLOG = NewHash(1, NULL); *ViewSpecific = BLOG; @@ -345,6 +347,7 @@ InitModule_BLOGVIEWRENDERERS VIEW_BLOG, blogview_GetParamsGetServerCall, NULL, + NULL, NULL, blogview_LoadMsgFromServer, blogview_render, diff --git a/webcit/calendar.c b/webcit/calendar.c index 84493f90f..2897ba201 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -915,6 +915,7 @@ InitModule_CALENDAR calendar_GetParamsGetServerCall, NULL, NULL, + NULL, calendar_LoadMsgFromServer, calendar_RenderView_or_Tail, calendar_Cleanup); @@ -924,6 +925,7 @@ InitModule_CALENDAR calendar_GetParamsGetServerCall, NULL, NULL, + NULL, calendar_LoadMsgFromServer, calendar_RenderView_or_Tail, calendar_Cleanup); diff --git a/webcit/calendar.h b/webcit/calendar.h index 755d93101..b71786396 100644 --- a/webcit/calendar.h +++ b/webcit/calendar.h @@ -62,7 +62,9 @@ int calendar_GetParamsGetServerCall(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, - long len); + long len, + char *filter, + long flen); int calendar_Cleanup(void **ViewSpecific); int __calendar_Cleanup(void **ViewSpecific); diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index 6cde0748e..c8820b22c 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -1429,7 +1429,9 @@ int calendar_GetParamsGetServerCall(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, - long len) + long len, + char *filter, + long flen) { wcsession *WCC = WC; calview *c; diff --git a/webcit/dav_propfind.c b/webcit/dav_propfind.c index 80efafca4..66b2063e9 100644 --- a/webcit/dav_propfind.c +++ b/webcit/dav_propfind.c @@ -782,10 +782,12 @@ int ParseMessageListHeaders_EUID(StrBuf *Line, } int DavUIDL_GetParamsGetServerCall(SharedMessageStatus *Stat, - void **ViewSpecific, - long oper, - char *cmd, - long len) + void **ViewSpecific, + long oper, + char *cmd, + long len, + char *filter, + long flen) { Stat->defaultsortorder = 0; Stat->sortit = 0; @@ -825,6 +827,7 @@ InitModule_PROPFIND RegisterReadLoopHandlerset( eReadEUIDS, DavUIDL_GetParamsGetServerCall, + NULL, NULL, /// TODO: is this right? ParseMessageListHeaders_EUID, NULL, //// "" diff --git a/webcit/dav_report.c b/webcit/dav_report.c index 33d168342..9574a5a66 100644 --- a/webcit/dav_report.c +++ b/webcit/dav_report.c @@ -86,10 +86,12 @@ extern int ParseMessageListHeaders_EUID(StrBuf *Line, StrBuf *ConversionBuffer); extern int DavUIDL_GetParamsGetServerCall(SharedMessageStatus *Stat, - void **ViewSpecific, - long oper, - char *cmd, - long len); + void **ViewSpecific, + long oper, + char *cmd, + long len, + char *filter, + long flen); extern int DavUIDL_RenderView_or_Tail(SharedMessageStatus *Stat, void **ViewSpecific, @@ -107,6 +109,7 @@ InitModule_REPORT eReadEUIDS, DavUIDL_GetParamsGetServerCall, NULL, + NULL, ParseMessageListHeaders_EUID, NULL, DavUIDL_RenderView_or_Tail, diff --git a/webcit/feed_generator.c b/webcit/feed_generator.c index 3c0e06919..34b721bdd 100644 --- a/webcit/feed_generator.c +++ b/webcit/feed_generator.c @@ -155,7 +155,7 @@ void feed_rss_do_messages(void) { Stat.maxload = INT_MAX; Stat.lowest_found = (-1); Stat.highest_found = (-1); - num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL); + num_msgs = load_msg_ptrs("MSGS ALL", NULL, &Stat, NULL); if (num_msgs < 1) return; i = num_msgs; /* convention is to feed newest-to-oldest */ diff --git a/webcit/messages.c b/webcit/messages.c index 2915ce148..6af7002b5 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -529,7 +529,8 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu * * servcmd: the citadel command to send to the citserver */ -int load_msg_ptrs(const char *servcmd, +int load_msg_ptrs(const char *servcmd, + const char *filter, SharedMessageStatus *Stat, load_msg_ptrs_detailheaders LH) { @@ -540,6 +541,7 @@ int load_msg_ptrs(const char *servcmd, int n; int skipit; const char *Ptr = NULL; + int StatMajor; Stat->lowest_found = LONG_MAX; Stat->highest_found = LONG_MIN; @@ -552,7 +554,21 @@ int load_msg_ptrs(const char *servcmd, Buf = NewStrBuf(); serv_puts(servcmd); StrBuf_ServGetln(Buf); - if (GetServerStatus(Buf, NULL) != 1) { + StatMajor = GetServerStatus(Buf, NULL); + switch (StatMajor) { + case 1: + break; + case 8: + if (filter != NULL) { + serv_puts(filter); + serv_puts("000"); + break; + } + /* fall back to empty filter in case of we were fooled... */ + serv_puts(""); + serv_puts("000"); + break; + default: FreeStrBuf(&Buf); return (Stat->nummsgs); } @@ -672,6 +688,8 @@ typedef struct _RoomRenderer{ int RoomType; GetParamsGetServerCall_func GetParamsGetServerCall; + + PrintViewHeader_func PrintPageHeader; PrintViewHeader_func PrintViewHeader; LoadMsgFromServer_func LoadMsgFromServer; RenderView_or_Tail_func RenderView_or_Tail; @@ -692,6 +710,7 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) void *vMsg; message_summary *Msg; char cmd[256] = ""; + char filter[256] = ""; int i, r; wcsession *WCC = WC; HashPos *at; @@ -705,18 +724,8 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) WCC->CurRoom.view = VIEW_MAILBOX; } - if (havebstr("is_ajax") && (1 == (ibstr("is_ajax")))) { - WCC->is_ajax = 1; - } - - if ((oper == do_search) && (WCC->CurRoom.view == VIEW_WIKI)) { - display_wiki_pagelist(); - return; - } - - if (WCC->CurRoom.view == VIEW_WIKI) { - http_redirect("wiki?page=home"); - return; + if (havebstr("view")) { + WCC->CurRoom.view = ibstr("view"); } memset(&Stat, 0, sizeof(SharedMessageStatus)); @@ -736,22 +745,23 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) } ViewMsg = (RoomRenderer*) vViewMsg; - if (!WCC->is_ajax) { + if (ViewMsg->PrintPageHeader == NULL) output_headers(1, 1, 1, 0, 0, 0); - } else if (WCC->CurRoom.view == VIEW_MAILBOX) { - jsonMessageListHdr(); - } + else + ViewMsg->PrintPageHeader(&Stat, ViewSpecific); if (ViewMsg->GetParamsGetServerCall != NULL) { r = ViewMsg->GetParamsGetServerCall( &Stat, &ViewSpecific, oper, - cmd, sizeof(cmd) + cmd, sizeof(cmd), + filter, sizeof(filter) ); } else { r = 0; } + switch(r) { case 400: @@ -764,8 +774,12 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) default: break; } - if (!IsEmptyStr(cmd)) - Stat.nummsgs = load_msg_ptrs(cmd, &Stat, ViewMsg->LHParse); + if (!IsEmptyStr(cmd)) { + const char *p = NULL; + if (!IsEmptyStr(filter)) + p = filter; + Stat.nummsgs = load_msg_ptrs(cmd, p, &Stat, ViewMsg->LHParse); + } if (Stat.sortit) { CompareFunc SortIt; @@ -1894,31 +1908,23 @@ void h_do_search(void) { readloop(do_search, eUseDefault);} void h_readgt(void) { readloop(readgt, eUseDefault);} void h_readlt(void) { readloop(readlt, eUseDefault);} -void jsonMessageListHdr(void) -{ - /* TODO: make a generic function */ - hprintf("HTTP/1.1 200 OK\r\n"); - hprintf("Content-type: application/json; charset=utf-8\r\n"); - hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)); - hprintf("Connection: close\r\n"); - hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n"); - begin_burst(); -} /* Output message list in JSON format */ void jsonMessageList(void) { + StrBuf *View = NewStrBuf(); const StrBuf *room = sbstr("room"); long oper = (havebstr("query")) ? do_search : readnew; - WC->is_ajax = 1; + StrBufPrintf(View, "%d", VIEW_JSON_LIST); + putbstr("view", View);; gotoroom(room); readloop(oper, eUseDefault); - WC->is_ajax = 0; } void RegisterReadLoopHandlerset( int RoomType, GetParamsGetServerCall_func GetParamsGetServerCall, + PrintViewHeader_func PrintPageHeader, PrintViewHeader_func PrintViewHeader, load_msg_ptrs_detailheaders LH, LoadMsgFromServer_func LoadMsgFromServer, @@ -1932,6 +1938,7 @@ void RegisterReadLoopHandlerset( Handler->RoomType = RoomType; Handler->GetParamsGetServerCall = GetParamsGetServerCall; + Handler->PrintPageHeader = PrintPageHeader; Handler->PrintViewHeader = PrintViewHeader; Handler->LoadMsgFromServer = LoadMsgFromServer; Handler->RenderView_or_Tail = RenderView_or_Tail; diff --git a/webcit/messages.h b/webcit/messages.h index d7eefbda6..a063170e0 100644 --- a/webcit/messages.h +++ b/webcit/messages.h @@ -147,7 +147,8 @@ typedef struct _SharedMessageStatus { } SharedMessageStatus; -int load_msg_ptrs(const char *servcmd, +int load_msg_ptrs(const char *servcmd, + const char *filter, SharedMessageStatus *Stat, load_msg_ptrs_detailheaders LH); @@ -155,7 +156,9 @@ typedef int (*GetParamsGetServerCall_func)(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, - long len); + long len, + char *filter, + long flen); typedef int (*PrintViewHeader_func)(SharedMessageStatus *Stat, void **ViewSpecific); @@ -188,6 +191,13 @@ void RegisterReadLoopHandlerset( */ GetParamsGetServerCall_func GetParamsGetServerCall, + /** + * PrintpageHeader prints the surrounding information like iconbar, header etc. + * by default, output_headers() is called. + * + */ + PrintViewHeader_func PrintPageHeader, + /** * PrintViewHeader is here to print informations infront of your messages. * The message list is already loaded & sorted (if) so you can evaluate @@ -245,3 +255,14 @@ int ParseMessageListHeaders_Detail(StrBuf *Line, +/** + * @brief function to register the availability to render a specific message + * @param HeaderName Mimetype we know howto display + * @param HdrNLen length... + * @param InlineRenderable Should we announce to citserver that we want to receive these mimeparts immediately? + * @param Priority if multipart/alternative; which mimepart/Renderer should be prefered? (only applies if InlineRenderable) + */ +void RegisterMimeRenderer(const char *HeaderName, long HdrNLen, + RenderMimeFunc MimeRenderer, + int InlineRenderable, + int Priority); diff --git a/webcit/mk_module_init.sh b/webcit/mk_module_init.sh index 95325dcb2..ae1cd3751 100755 --- a/webcit/mk_module_init.sh +++ b/webcit/mk_module_init.sh @@ -34,6 +34,7 @@ rm -f $C_FILE $H_FILE # server lifetime: START_FUNCS=`grep ServerStartModule_ *.c |sed "s;.*:;;" |sort -u` INIT_FUNCS=`grep InitModule_ *.c |sed "s;.*:;;" |sort -u` +INIT2_FUNCS=`grep InitModule2_ *.c |sed "s;.*:;;" |sort -u` FINALIZE_FUNCS=`grep FinalizeModule_ *.c |sed "s;.*:;;" |sort -u` SHUTDOWN_FUNCS=`grep ServerShutdownModule_ *.c |sed "s;.*:;;" |sort -u` @@ -68,6 +69,7 @@ extern size_t nSizErrmsg; * server lifetime: */ void initialise_modules (void); +void initialise2_modules (void); void start_modules (void); void shutdown_modules (void); @@ -197,6 +199,36 @@ extern void $HOOK(void); EOF done +#******************************************************************************** +# server module ******** initialisation ******** second stage. +#******************************************************************************** +cat <> $H_FILE + +/* Server Init Hooks: */ +EOF + +cat <>$C_FILE +} + + +void initialise2_modules (void) +{ + +EOF +for HOOK in $INIT2_FUNCS; do + HOOKNAME=`echo $HOOK |sed "s;InitModule2_;;"` +# Add this entry point to the .c file + cat <> $C_FILE +#ifdef DBG_PRINNT_HOOKS_AT_START + syslog(CTDL_INFO, "Initializing $HOOKNAME\n"); +#endif + $HOOK(); +EOF +# Add this entry point to the .h file + cat <> $H_FILE +extern void $HOOK(void); +EOF +done diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index 8255449ca..c5af54492 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -1367,59 +1367,83 @@ int ParseMessageListHeaders_Detail(StrBuf *Line, return 1; } -/* Spit out the new summary view. This is basically a static page, so clients can cache the layout, all the dirty work is javascript :) */ -void new_summary_view(void) { - DoTemplate(HKEY("msg_listview"),NULL,&NoCtx); -} - int mailview_GetParamsGetServerCall(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, - long len) -{ - if (!WC->is_ajax) { - new_summary_view(); - return 200; - } else { - Stat->defaultsortorder = 2; - Stat->sortit = 1; - Stat->load_seen = 1; - /* Generally using maxmsgs|startmsg is not required - in mailbox view, but we have a 'safemode' for clients - (*cough* Exploder) that simply can't handle too many */ - if (havebstr("maxmsgs")) Stat->maxmsgs = ibstr("maxmsgs"); - else Stat->maxmsgs = 9999999; - if (havebstr("startmsg")) Stat->startmsg = lbstr("startmsg"); - snprintf(cmd, len, "MSGS %s|%s||1", - (oper == do_search) ? "SEARCH" : "ALL", - (oper == do_search) ? bstr("query") : "" - ); - } + long len, + char *filter, + long flen) +{ + DoTemplate(HKEY("msg_listview"),NULL,&NoCtx); + return 200; } -int mailview_RenderView_or_Tail(SharedMessageStatus *Stat, +int mailview_Cleanup(void **ViewSpecific) +{ + /* Note: wDumpContent() will output one additional tag. */ + /* We ought to move this out into template */ + wDumpContent(1); + + return 0; +} + + +int json_GetParamsGetServerCall(SharedMessageStatus *Stat, void **ViewSpecific, - long oper) + long oper, + char *cmd, + long len, + char *filter, + long flen) +{ + Stat->defaultsortorder = 2; + Stat->sortit = 1; + Stat->load_seen = 1; + /* Generally using maxmsgs|startmsg is not required + in mailbox view, but we have a 'safemode' for clients + (*cough* Exploder) that simply can't handle too many */ + if (havebstr("maxmsgs")) Stat->maxmsgs = ibstr("maxmsgs"); + else Stat->maxmsgs = 9999999; + if (havebstr("startmsg")) Stat->startmsg = lbstr("startmsg"); + snprintf(cmd, len, "MSGS %s|%s||1", + (oper == do_search) ? "SEARCH" : "ALL", + (oper == do_search) ? bstr("query") : "" + ); + + return 200; +} +int json_MessageListHdr(SharedMessageStatus *Stat, void **ViewSpecific) +{ + /* TODO: make a generic function */ + hprintf("HTTP/1.1 200 OK\r\n"); + hprintf("Content-type: application/json; charset=utf-8\r\n"); + hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)); + hprintf("Connection: close\r\n"); + hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n"); + begin_burst(); + return 0; +} + +int json_RenderView_or_Tail(SharedMessageStatus *Stat, + void **ViewSpecific, + long oper) { WCTemplputParams SubTP; - if (WC->is_ajax) - DoTemplate(HKEY("mailsummary_json"),NULL, &SubTP); + memset(&SubTP, 0, sizeof(WCTemplputParams)); + DoTemplate(HKEY("mailsummary_json"),NULL, &SubTP); return 0; } -int mailview_Cleanup(void **ViewSpecific) +int json_Cleanup(void **ViewSpecific) { /* Note: wDumpContent() will output one additional tag. */ /* We ought to move this out into template */ - if (WC->is_ajax) - end_burst(); - else - wDumpContent(1); + end_burst(); return 0; } @@ -1434,11 +1458,22 @@ InitModule_MSGRENDERERS VIEW_MAILBOX, mailview_GetParamsGetServerCall, NULL, /* TODO: is this right? */ + NULL, ParseMessageListHeaders_Detail, NULL, - mailview_RenderView_or_Tail, + NULL, mailview_Cleanup); + RegisterReadLoopHandlerset( + VIEW_JSON_LIST, + json_GetParamsGetServerCall, + json_MessageListHdr, + NULL, /* TODO: is this right? */ + ParseMessageListHeaders_Detail, + NULL, + json_RenderView_or_Tail, + json_Cleanup); + RegisterSortFunc(HKEY("date"), NULL, 0, summcmp_date, @@ -1540,8 +1575,6 @@ InitModule_MSGRENDERERS RegisterMimeRenderer(HKEY("text"), render_MAIL_text_plain, 1, 1); RegisterMimeRenderer(HKEY("text/html"), render_MAIL_html, 1, 100); RegisterMimeRenderer(HKEY(""), render_MAIL_UNKNOWN, 0, 0); - /* and finalize the anouncement to the server... */ - CreateMimeStr(); /* these headers are citserver replies to MSG4 and friends. one evaluator for each */ RegisterMsgHdr(HKEY("nhdr"), examine_nhdr, 0); @@ -1572,6 +1605,13 @@ InitModule_MSGRENDERERS RegisterMsgHdr(HKEY("path"), examine_path, 0); } +void +InitModule2_MSGRENDERERS +(void) +{ + /* and finalize the anouncement to the server... */ + CreateMimeStr(); +} void ServerStartModule_MSGRENDERERS (void) diff --git a/webcit/notes.c b/webcit/notes.c index 31000fd7e..d9d0ebf65 100644 --- a/webcit/notes.c +++ b/webcit/notes.c @@ -416,7 +416,9 @@ int notes_GetParamsGetServerCall(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, - long len) + long len, + char *filter, + long flen) { strcpy(cmd, "MSGS ALL"); Stat->maxmsgs = 32767; @@ -441,6 +443,7 @@ InitModule_NOTES notes_GetParamsGetServerCall, NULL, NULL, + NULL, notes_LoadMsgFromServer, NULL, notes_Cleanup); diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c index 2f3d91cb5..bdc3cc205 100644 --- a/webcit/siteconfig.c +++ b/webcit/siteconfig.c @@ -209,6 +209,7 @@ CfgMapping ServerConfig[] = { }; + /* * display all configuration items */ @@ -218,7 +219,7 @@ void load_siteconfig(void) StrBuf *Buf; HashList *Cfg; long len; - int i; + int i, j; if (WCC->ServCfg == NULL) WCC->ServCfg = NewHash(1, NULL); @@ -233,40 +234,29 @@ void load_siteconfig(void) AppendImportantMessage(SKEY(Buf)); FreeStrBuf(&Buf); return; + } - - i = 0; + j = i = 0; while (len = StrBuf_ServGetln(Buf), - (len >= 0) - && (i < (sizeof(ServerConfig) / sizeof(CfgMapping))) - && ((len != 3) || strcmp(ChrPtr(Buf), "000")) - ) { - Put(Cfg, - ServerConfig[i].Key, - ServerConfig[i].len, - Buf, - HFreeStrBuf - ); - i++; - if (i <= sizeof(ServerConfig) / sizeof(CfgMapping)) { + (len >= 0) && + ((len != 3) || strcmp(ChrPtr(Buf), "000"))) + { + if (i < (sizeof(ServerConfig) / sizeof(CfgMapping))) + { + Put(Cfg, + ServerConfig[i].Key, + ServerConfig[i].len, + Buf, + HFreeStrBuf); + i++; Buf = NewStrBuf(); } else { - Buf = NULL; + if (j == 0) + AppendImportantMessage(_("WARNING: Failed to parse Server Config; do you run a to new citserver?"), -1); + j++; } } - - if (strcmp(ChrPtr(Buf), "000") != 0) - { - /* Discard config lines which we don't yet support */ - while ( (len = StrBuf_ServGetln(Buf), - strcmp(ChrPtr(Buf), "000")) - ) { - } - AppendImportantMessage(_("WARNING: Failed to parse Server Config; do you run a to new citserver?"), -1); - FreeStrBuf(&Buf); - return; - } FreeStrBuf(&Buf); LoadExpirePolicy(sitepolicy); diff --git a/webcit/sitemap.c b/webcit/sitemap.c index b704ca692..cab60d43e 100644 --- a/webcit/sitemap.c +++ b/webcit/sitemap.c @@ -36,7 +36,7 @@ void sitemap_do_bbs(void) { Stat.maxload = INT_MAX; Stat.lowest_found = (-1); Stat.highest_found = (-1); - num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL); + num_msgs = load_msg_ptrs("MSGS ALL", NULL, &Stat, NULL); if (num_msgs < 1) return; for (i=0; i 0) { @@ -142,6 +142,7 @@ void tasks_section(void) { */ void calendar_section(void) { char cmd[SIZ]; + char filter[SIZ]; int num_msgs = 0; HashPos *at; const char *HashKey; @@ -165,13 +166,16 @@ void calendar_section(void) { num_msgs = 0; } else { - num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL); + num_msgs = load_msg_ptrs("MSGS ALL", NULL, &Stat, NULL); } calendar_GetParamsGetServerCall(&Stat, &v, readnew, cmd, - sizeof(cmd)); + sizeof(cmd), + filter, + sizeof(filter)); + if (num_msgs > 0) { at = GetNewHashPos(WCC->summ, 0); diff --git a/webcit/tasks.c b/webcit/tasks.c index e0d5a5571..adf758378 100644 --- a/webcit/tasks.c +++ b/webcit/tasks.c @@ -720,7 +720,9 @@ int tasks_GetParamsGetServerCall(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, - long len) + long len, + char *filter, + long flen) { strcpy(cmd, "MSGS ALL"); Stat->maxmsgs = 32767; @@ -747,6 +749,7 @@ InitModule_TASKS tasks_GetParamsGetServerCall, NULL, NULL, + NULL, tasks_LoadMsgFromServer, tasks_RenderView_or_Tail, tasks_Cleanup); diff --git a/webcit/useredit.c b/webcit/useredit.c index ef72b6e20..ef1be72b6 100644 --- a/webcit/useredit.c +++ b/webcit/useredit.c @@ -531,7 +531,7 @@ TRYAGAIN: Stat.lowest_found = (-1); Stat.highest_found = (-1); /* Search for the user's vCard */ - if (load_msg_ptrs("MSGS ALL||||1", &Stat, NULL) > 0) { + if (load_msg_ptrs("MSGS ALL||||1", NULL, &Stat, NULL) > 0) { at = GetNewHashPos(WCC->summ, 0); while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) { Msg = (message_summary*) vMsg; diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index 3b9629d64..9c8bd3b0c 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -1417,7 +1417,9 @@ int vcard_GetParamsGetServerCall(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, - long len) + long len, + char *filter, + long flen) { vcardview_struct *VS; @@ -1514,6 +1516,7 @@ InitModule_VCARD VIEW_ADDRESSBOOK, vcard_GetParamsGetServerCall, NULL, + NULL, NULL, vcard_LoadMsgFromServer, vcard_RenderView_or_Tail, diff --git a/webcit/webcit.h b/webcit/webcit.h index 6611a9275..e713e75bb 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -487,7 +487,6 @@ struct wcsession { time_t lastreq; /* Timestamp of most recent HTTP */ time_t last_pager_check; /* last time we polled for instant msgs */ ServInfo *serv_info; /* Information about the citserver we're connected to */ - int is_ajax; /* are we doing an ajax request? */ StrBuf *PushedDestination; /* Where to go after login, registration, etc. */ /* Request local Members */ diff --git a/webcit/webserver.c b/webcit/webserver.c index 803fe4c72..3a896b472 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -250,6 +250,7 @@ int main(int argc, char **argv) /* initialize various subsystems */ initialise_modules(); + initialise2_modules(); InitTemplateCache(); if (DumpTemplateI18NStrings) { FILE *fd; diff --git a/webcit/wiki.c b/webcit/wiki.c index 56ad06d02..ef1a44412 100644 --- a/webcit/wiki.c +++ b/webcit/wiki.c @@ -365,13 +365,37 @@ int ConditionalHavewikiType(StrBuf *Target, WCTemplputParams *TP) } +int wiki_PrintHeaderPage(SharedMessageStatus *Stat, void **ViewSpecific) +{ + /* this function was intentionaly left empty. */ + return 0; +} + +int wiki_GetParamsGetServerCall(SharedMessageStatus *Stat, + void **ViewSpecific, + long oper, + char *cmd, + long len, + char *filter, + long flen) +{ + if (oper == do_search) + display_wiki_pagelist(); + else + http_redirect("wiki?page=home"); + + return 300; +} + + void InitModule_WIKI (void) { RegisterReadLoopHandlerset( VIEW_WIKI, - NULL, + wiki_GetParamsGetServerCall, + wiki_PrintHeaderPage, NULL, NULL, NULL, -- 2.30.2