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
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));
VIEW_BBS,
bbsview_GetParamsGetServerCall,
NULL,
+ NULL,
NULL,
bbsview_LoadMsgFromServer,
bbsview_RenderView_or_Tail,
void **ViewSpecific,
long oper,
char *cmd,
- long len)
+ long len,
+ char *filter,
+ long flen)
{
HashList *BLOG = NewHash(1, NULL);
*ViewSpecific = BLOG;
VIEW_BLOG,
blogview_GetParamsGetServerCall,
NULL,
+ NULL,
NULL,
blogview_LoadMsgFromServer,
blogview_render,
calendar_GetParamsGetServerCall,
NULL,
NULL,
+ NULL,
calendar_LoadMsgFromServer,
calendar_RenderView_or_Tail,
calendar_Cleanup);
calendar_GetParamsGetServerCall,
NULL,
NULL,
+ NULL,
calendar_LoadMsgFromServer,
calendar_RenderView_or_Tail,
calendar_Cleanup);
void **ViewSpecific,
long oper,
char *cmd,
- long len);
+ long len,
+ char *filter,
+ long flen);
int calendar_Cleanup(void **ViewSpecific);
int __calendar_Cleanup(void **ViewSpecific);
void **ViewSpecific,
long oper,
char *cmd,
- long len)
+ long len,
+ char *filter,
+ long flen)
{
wcsession *WCC = WC;
calview *c;
}
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;
RegisterReadLoopHandlerset(
eReadEUIDS,
DavUIDL_GetParamsGetServerCall,
+ NULL,
NULL, /// TODO: is this right?
ParseMessageListHeaders_EUID,
NULL, //// ""
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,
eReadEUIDS,
DavUIDL_GetParamsGetServerCall,
NULL,
+ NULL,
ParseMessageListHeaders_EUID,
NULL,
DavUIDL_RenderView_or_Tail,
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 */
*
* 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)
{
int n;
int skipit;
const char *Ptr = NULL;
+ int StatMajor;
Stat->lowest_found = LONG_MAX;
Stat->highest_found = LONG_MIN;
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);
}
int RoomType;
GetParamsGetServerCall_func GetParamsGetServerCall;
+
+ PrintViewHeader_func PrintPageHeader;
PrintViewHeader_func PrintViewHeader;
LoadMsgFromServer_func LoadMsgFromServer;
RenderView_or_Tail_func RenderView_or_Tail;
void *vMsg;
message_summary *Msg;
char cmd[256] = "";
+ char filter[256] = "";
int i, r;
wcsession *WCC = WC;
HashPos *at;
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));
}
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:
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;
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,
Handler->RoomType = RoomType;
Handler->GetParamsGetServerCall = GetParamsGetServerCall;
+ Handler->PrintPageHeader = PrintPageHeader;
Handler->PrintViewHeader = PrintViewHeader;
Handler->LoadMsgFromServer = LoadMsgFromServer;
Handler->RenderView_or_Tail = RenderView_or_Tail;
} 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);
void **ViewSpecific,
long oper,
char *cmd,
- long len);
+ long len,
+ char *filter,
+ long flen);
typedef int (*PrintViewHeader_func)(SharedMessageStatus *Stat, void **ViewSpecific);
*/
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
+/**
+ * @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);
# 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`
* server lifetime:
*/
void initialise_modules (void);
+void initialise2_modules (void);
void start_modules (void);
void shutdown_modules (void);
EOF
done
+#********************************************************************************
+# server module ******** initialisation ******** second stage.
+#********************************************************************************
+cat <<EOF >> $H_FILE
+
+/* Server Init Hooks: */
+EOF
+
+cat <<EOF >>$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 <<EOF >> $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 <<EOF >> $H_FILE
+extern void $HOOK(void);
+EOF
+done
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 </div> 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 </div> tag. */
/* We ought to move this out into template */
- if (WC->is_ajax)
- end_burst();
- else
- wDumpContent(1);
+ end_burst();
return 0;
}
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,
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);
RegisterMsgHdr(HKEY("path"), examine_path, 0);
}
+void
+InitModule2_MSGRENDERERS
+(void)
+{
+ /* and finalize the anouncement to the server... */
+ CreateMimeStr();
+}
void
ServerStartModule_MSGRENDERERS
(void)
void **ViewSpecific,
long oper,
char *cmd,
- long len)
+ long len,
+ char *filter,
+ long flen)
{
strcpy(cmd, "MSGS ALL");
Stat->maxmsgs = 32767;
notes_GetParamsGetServerCall,
NULL,
NULL,
+ NULL,
notes_LoadMsgFromServer,
NULL,
notes_Cleanup);
};
+
/*
* display all configuration items
*/
StrBuf *Buf;
HashList *Cfg;
long len;
- int i;
+ int i, j;
if (WCC->ServCfg == NULL)
WCC->ServCfg = NewHash(1, NULL);
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);
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<num_msgs; i+=20) {
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<num_msgs; ++i) {
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<num_msgs; ++i) {
num_msgs = 0;
}
else {
- num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
+ num_msgs = load_msg_ptrs("MSGS ALL", NULL, &Stat, NULL);
}
if (num_msgs > 0) {
*/
void calendar_section(void) {
char cmd[SIZ];
+ char filter[SIZ];
int num_msgs = 0;
HashPos *at;
const char *HashKey;
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);
void **ViewSpecific,
long oper,
char *cmd,
- long len)
+ long len,
+ char *filter,
+ long flen)
{
strcpy(cmd, "MSGS ALL");
Stat->maxmsgs = 32767;
tasks_GetParamsGetServerCall,
NULL,
NULL,
+ NULL,
tasks_LoadMsgFromServer,
tasks_RenderView_or_Tail,
tasks_Cleanup);
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;
void **ViewSpecific,
long oper,
char *cmd,
- long len)
+ long len,
+ char *filter,
+ long flen)
{
vcardview_struct *VS;
VIEW_ADDRESSBOOK,
vcard_GetParamsGetServerCall,
NULL,
+ NULL,
NULL,
vcard_LoadMsgFromServer,
vcard_RenderView_or_Tail,
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 */
/* initialize various subsystems */
initialise_modules();
+ initialise2_modules();
InitTemplateCache();
if (DumpTemplateI18NStrings) {
FILE *fd;
}
+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,