/* begin everythingamundo table */
HdrToken = NewStrBuf();
- while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
+ while (!Done && StrBuf_ServGetln(Buf)>=0) {
if ( (StrLength(Buf)==3) &&
!strcmp(ChrPtr(Buf), "000"))
{
break;
case eDELETE:
CmdBuf = NewStrBuf ();
- if (WCC->wc_is_trash) { /* Delete from Trash is a real delete */
+ if ((WCC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
serv_printf("DELE %ld", msgnum);
}
else { /* Otherwise move it to Trash */
break;
case eDELETE:
CmdBuf = NewStrBuf ();
- if (WCC->wc_is_trash) { /* Delete from Trash is a real delete */
+ if ((WCC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
serv_printf("DELE %ld", msgnum);
}
else { /* Otherwise move it to Trash */
*
* servcmd: the citadel command to send to the citserver
*/
-int load_msg_ptrs(const char *servcmd, SharedMessageStatus *Stat)
+int load_msg_ptrs(const char *servcmd,
+ SharedMessageStatus *Stat,
+ load_msg_ptrs_detailheaders LH)
{
- StrBuf* FoundCharset = NULL;
wcsession *WCC = WC;
message_summary *Msg;
StrBuf *Buf, *Buf2;
if (StrLength(Buf) < 32)
skipit = 1;
}
- if (!skipit) {
- Msg->from = NewStrBufPlain(NULL, StrLength(Buf));
- StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
- if (StrLength(Buf2) != 0) {
- /* Handle senders with RFC2047 encoding */
- StrBuf_RFC822_to_Utf8(Msg->from, Buf2, WCC->DefaultCharset, FoundCharset);
- }
-
- /* node name */
- StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
- if ((StrLength(Buf2) !=0 ) &&
- ( ((WCC->room_flags & QR_NETWORK)
- || ((strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_nodename))
- && (strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_fqdn))))))))
- {
- StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
- StrBufAppendBuf(Msg->from, Buf2, 0);
- }
-
- /* Internet address (not used)
- * StrBufExtract_token(Msg->inetaddr, Buf, 4, '|');
- */
- StrBufSkip_NTokenS(Buf, &Ptr, '|', 1);
- Msg->subj = NewStrBufPlain(NULL, StrLength(Buf));
- StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
- if (StrLength(Buf2) == 0)
- StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
- else {
- StrBuf_RFC822_to_Utf8(Msg->subj, Buf2, WCC->DefaultCharset, FoundCharset);
- if ((StrLength(Msg->subj) > 75) &&
- (StrBuf_Utf8StrLen(Msg->subj) > 75)) {
- StrBuf_Utf8StrCut(Msg->subj, 72);
- StrBufAppendBufPlain(Msg->subj, HKEY("..."), 0);
- }
- }
-
- if ((StrLength(Msg->from) > 25) &&
- (StrBuf_Utf8StrLen(Msg->from) > 25)) {
- StrBuf_Utf8StrCut(Msg->from, 23);
- StrBufAppendBufPlain(Msg->from, HKEY("..."), 0);
- }
+ if ((!skipit) && (LH != NULL)) {
+ if (!LH(Buf, &Ptr, Msg, Buf2)){
+ free(Msg);
+ continue;
+ }
}
n = Msg->msgnum;
Put(WCC->summ, (const char *)&n, sizeof(n), Msg, DestroyMessageSummary);
LoadMsgFromServer_func LoadMsgFromServer;
RenderView_or_Tail_func RenderView_or_Tail;
View_Cleanup_func ViewCleanup;
+ load_msg_ptrs_detailheaders LHParse;
} RoomRenderer;
/*
* command loop for reading messages
*
- * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt"
+ * Set oper to "readnew" or "readold" or "readfwd" or "headers" or "readgt" or "readlt" or "do_search"
*/
-void readloop(long oper)
+void readloop(long oper, eCustomRoomRenderer ForceRenderer)
{
RoomRenderer *ViewMsg;
void *vViewMsg;
SharedMessageStatus Stat;
void *ViewSpecific;
- if (havebstr("is_summary") && (1 == (ibstr("is_summary"))))
- WCC->wc_view = VIEW_MAILBOX;
+ if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
+ 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;
+ }
memset(&Stat, 0, sizeof(SharedMessageStatus));
Stat.maxload = 10000;
Stat.lowest_found = (-1);
Stat.highest_found = (-1);
- GetHash(ReadLoopHandler, IKEY(WCC->wc_view), &vViewMsg);
+ if (ForceRenderer == eUseDefault)
+ GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
+ else
+ GetHash(ReadLoopHandler, IKEY(ForceRenderer), &vViewMsg);
if (vViewMsg == NULL) {
- WCC->wc_view = VIEW_BBS;
- GetHash(ReadLoopHandler, IKEY(WCC->wc_view), &vViewMsg);
+ WCC->CurRoom.view = VIEW_BBS;
+ GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
+ }
+ if (vViewMsg == NULL) {
+ return; // TODO: print message
}
- if (vViewMsg == NULL)
- return;///TODO: print message
ViewMsg = (RoomRenderer*) vViewMsg;
if (!WCC->is_ajax) {
output_headers(1, 1, 1, 0, 0, 0);
- } else if (WCC->wc_view == VIEW_MAILBOX) {
+ } else if (WCC->CurRoom.view == VIEW_MAILBOX) {
jsonMessageListHdr();
}
break;
}
if (!IsEmptyStr(cmd))
- Stat.nummsgs = load_msg_ptrs(cmd, &Stat);
+ Stat.nummsgs = load_msg_ptrs(cmd, &Stat, ViewMsg->LHParse);
if (Stat.sortit) {
CompareFunc SortIt;
if (SortIt != NULL)
SortByPayload(WCC->summ, SortIt);
}
- if (Stat.startmsg < 0)
- Stat.startmsg = (Stat.reverse) ? Stat.nummsgs - 1 : 0;
+ if (Stat.startmsg < 0) {
+ Stat.startmsg = 0;
+ }
if (Stat.load_seen) load_seen_flags();
/* Put some helpful data in vars for mailsummary_json */
svputlong("READLOOP:TOTALMSGS", Stat.nummsgs);
svputlong("READLOOP:STARTMSG", Stat.startmsg);
- svputlong("WCVIEW", WCC->wc_view);
+ svputlong("WCVIEW", WCC->CurRoom.view);
/*
* iterate over each message. if we need to load an attachment, do it here.
}
/* Only do multipart/alternative for mailboxes. BBS and Wiki rooms don't need it. */
- if (WC->wc_view == VIEW_MAILBOX) {
+ if (WC->CurRoom.view == VIEW_MAILBOX) {
include_text_alt = 1;
}
Recp = sbstr("recp");
Cc = sbstr("cc");
Bcc = sbstr("bcc");
- Wikipage = sbstr("wikipage");
+ Wikipage = sbstr("page");
my_email_addr = sbstr("my_email_addr");
CmdBuf = NewStrBufPlain(NULL,
serv_printf("Cc: %s", ChrPtr(Cc));
serv_printf("Bcc: %s", ChrPtr(Bcc));
} else {
- serv_printf("X-Citadel-Room: %s", ChrPtr(WC->wc_roomname));
+ serv_printf("X-Citadel-Room: %s", ChrPtr(WC->CurRoom.name));
}
}
post_mime_to_server();
if (save_to_drafts) {
StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been saved to Drafts.\n"), -1, 0);
- gotoroom(WCC->wc_roomname);
+ gotoroom(WCC->CurRoom.name);
display_enter();
FreeStrBuf(&Buf);
return;
lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
- if (save_to_drafts) gotoroom(WCC->wc_roomname);
+ if (save_to_drafts) gotoroom(WCC->CurRoom.name);
display_enter();
FreeStrBuf(&Buf);
return;
/*
* If we were editing a page in a wiki room, go to that page now.
*/
- else if (havebstr("wikipage")) {
- snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
+ else if (havebstr("page")) {
+ snprintf(buf, sizeof buf, "wiki?page=%s", bstr("page"));
http_redirect(buf);
}
/*
* Otherwise, just go to the "read messages" loop.
*/
else {
- readloop(readnew);
+ readloop(readnew, eUseDefault);
}
}
}
else if (buf[0] != '2') { /* Any other error means that we cannot continue */
sprintf(WCC->ImportantMessage, "%s", &buf[4]);
- readloop(readnew);
+ readloop(readnew, eUseDefault);
return;
}
* Are we perhaps in an address book view? If so, then an "enter
* message" command really means "add new entry."
*/
- if (WCC->wc_default_view == VIEW_ADDRESSBOOK) {
- do_edit_vcard(-1, "", NULL, NULL, "", ChrPtr(WCC->wc_roomname));
+ if (WCC->CurRoom.defview == VIEW_ADDRESSBOOK) {
+ do_edit_vcard(-1, "", NULL, NULL, "", ChrPtr(WCC->CurRoom.name));
return;
}
* Are we perhaps in a calendar room? If so, then an "enter
* message" command really means "add new calendar item."
*/
- if (WCC->wc_default_view == VIEW_CALENDAR) {
+ if (WCC->CurRoom.defview == VIEW_CALENDAR) {
display_edit_event();
return;
}
* Are we perhaps in a tasks view? If so, then an "enter
* message" command really means "add new task."
*/
- if (WCC->wc_default_view == VIEW_TASKS) {
+ if (WCC->CurRoom.defview == VIEW_TASKS) {
display_edit_task();
return;
}
Recp = sbstr("recp");
Cc = sbstr("cc");
Bcc = sbstr("bcc");
- Wikipage = sbstr("wikipage");
+ Wikipage = sbstr("page");
CmdBuf = NewStrBufPlain(NULL,
sizeof (CMD) +
msgid = lbstr("msgid");
- if (WC->wc_is_trash) { /* Delete from Trash is a real delete */
+ if ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0) { /* Delete from Trash is a real delete */
serv_printf("DELE %ld", msgid);
}
else { /* Otherwise move it to Trash */
serv_getln(buf, sizeof buf);
sprintf(WC->ImportantMessage, "%s", &buf[4]);
- readloop(readnew);
+ readloop(readnew, eUseDefault);
}
sprintf(WC->ImportantMessage, (_("The message was not moved.")));
}
- readloop(readnew);
+ readloop(readnew, eUseDefault);
}
void MimeLoadData(wc_mime_attachment *Mime)
{
StrBuf *Buf;
+ const char *Ptr;
off_t bytes;
/* TODO: is there a chance the content type is different from the one we know? */
+
serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum));
Buf = NewStrBuf();
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) == 6) {
- bytes = extract_long(&(ChrPtr(Buf)[4]), 0);
-
+ Ptr = &(ChrPtr(Buf)[4]);
+ bytes = StrBufExtractNext_long(Buf, &Ptr, '|');
+ StrBufSkip_NTokenS(Buf, &Ptr, '|', 3); /* filename, cbtype, mimetype */
+ if (Mime->Charset == NULL) Mime->Charset = NewStrBuf();
+ StrBufExtract_NextToken(Mime->Charset, Buf, &Ptr, '|');
+
if (Mime->Data == NULL)
Mime->Data = NewStrBufPlain(NULL, bytes);
StrBuf_ServGetBLOBBuffered(Mime->Data, bytes);
FreeStrBuf(&partnum);
}
-void h_readnew(void) { readloop(readnew);}
-void h_readold(void) { readloop(readold);}
-void h_readfwd(void) { readloop(readfwd);}
-void h_headers(void) { readloop(headers);}
-void h_do_search(void) { readloop(do_search);}
-void h_readgt(void) { readloop(readgt);}
+void h_readnew(void) { readloop(readnew, eUseDefault);}
+void h_readold(void) { readloop(readold, eUseDefault);}
+void h_readfwd(void) { readloop(readfwd, eUseDefault);}
+void h_headers(void) { readloop(headers, eUseDefault);}
+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)
{
long oper = (havebstr("query")) ? do_search : readnew;
WC->is_ajax = 1;
gotoroom(room);
- readloop(oper);
+ readloop(oper, eUseDefault);
WC->is_ajax = 0;
}
int RoomType,
GetParamsGetServerCall_func GetParamsGetServerCall,
PrintViewHeader_func PrintViewHeader,
+ load_msg_ptrs_detailheaders LH,
LoadMsgFromServer_func LoadMsgFromServer,
RenderView_or_Tail_func RenderView_or_Tail,
View_Cleanup_func ViewCleanup
Handler->LoadMsgFromServer = LoadMsgFromServer;
Handler->RenderView_or_Tail = RenderView_or_Tail;
Handler->ViewCleanup = ViewCleanup;
+ Handler->LHParse = LH;
Put(ReadLoopHandler, IKEY(RoomType), Handler, NULL);
}
WebcitAddUrlHandler(HKEY("readfwd"), "", 0, h_readfwd, NEED_URL);
WebcitAddUrlHandler(HKEY("headers"), "", 0, h_headers, NEED_URL);
WebcitAddUrlHandler(HKEY("readgt"), "", 0, h_readgt, NEED_URL);
+ WebcitAddUrlHandler(HKEY("readlt"), "", 0, h_readlt, NEED_URL);
WebcitAddUrlHandler(HKEY("do_search"), "", 0, h_do_search, 0);
WebcitAddUrlHandler(HKEY("display_enter"), "", 0, display_enter, 0);
WebcitAddUrlHandler(HKEY("post"), "", 0, post_message, 0);