X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fmessages.c;h=2915ce1480d5b623c2320395ee8e7cad63830c56;hb=7ba7f73f95cad7f4ecd7f986e12095e9bb546126;hp=b123b8c5a51ebc8de229ec891226e627a5662268;hpb=275bbb751736a849fcda6da0e8b6d1ab3eee06d4;p=citadel.git
diff --git a/webcit/messages.c b/webcit/messages.c
index b123b8c5a..2915ce148 100644
--- a/webcit/messages.c
+++ b/webcit/messages.c
@@ -1,13 +1,27 @@
/*
- * $Id$
- *
* Functions which deal with the fetching and displaying of messages.
*
+ * Copyright (c) 1996-2011 by the citadel.org team
+ *
+ * This program is open source software. You can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "webcit.h"
#include "webserver.h"
-#include "groupdav.h"
+#include "dav.h"
+#include "calendar.h"
HashList *MsgHeaderHandler = NULL;
HashList *MsgEvaluators = NULL;
@@ -33,7 +47,6 @@ int load_message(message_summary *Msg,
StrBuf *FoundCharset,
StrBuf **Error)
{
- wcsession *WCC = WC;
StrBuf *Buf;
StrBuf *HdrToken;
headereval *Hdr;
@@ -43,7 +56,6 @@ int load_message(message_summary *Msg,
int state=0;
Buf = NewStrBuf();
- lprintf(9, "MSG4 %ld|%s\n", Msg->msgnum, ChrPtr(Msg->PartNum));
if (Msg->PartNum != NULL) {
serv_printf("MSG4 %ld|%s", Msg->msgnum, ChrPtr(Msg->PartNum));
}
@@ -56,26 +68,25 @@ int load_message(message_summary *Msg,
*Error = NewStrBuf();
StrBufAppendPrintf(*Error, "");
StrBufAppendPrintf(*Error, _("ERROR:"));
- StrBufAppendPrintf(*Error, " %s
\n", &buf[4]);
+ StrBufAppendPrintf(*Error, " %s
\n", &buf[4]);
FreeStrBuf(&Buf);
return 0;
}
/* 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"))
{
Done = 1;
if (state < 2) {
- lprintf(1, _("unexpected end of message"));
if (Msg->MsgBody->Data == NULL)
Msg->MsgBody->Data = NewStrBuf();
Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/html"));
StrBufAppendPrintf(Msg->MsgBody->Data, "
");
- StrBufAppendPrintf(Msg->MsgBody->Data, _("unexpected end of message"));
- StrBufAppendPrintf(Msg->MsgBody->Data, " (1)
\n");
+ StrBufAppendPrintf(Msg->MsgBody->Data, _("Empty message"));
+ StrBufAppendPrintf(Msg->MsgBody->Data, "
\n");
StrBufAppendPrintf(Msg->MsgBody->Data, "
\n");
}
break;
@@ -89,9 +100,6 @@ int load_message(message_summary *Msg,
StrBufExtract_token(HdrToken, Buf, 0, '=');
StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
-#ifdef TECH_PREVIEW
- if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
-#endif
/* look up one of the examine_* functions to parse the content */
if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
(vHdr != NULL)) {
@@ -120,9 +128,6 @@ int load_message(message_summary *Msg,
StrBufExtract_token(HdrToken, Buf, 0, ':');
if (StrLength(HdrToken) > 0) {
StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
-#ifdef TECH_PREVIEW
- if (dbg_analyze_msg) lprintf(1, ":: [%s] = [%s]\n", ChrPtr(HdrToken), ChrPtr(Buf));
-#endif
/* the examine*'s know how to do with mime headers too... */
if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
(vHdr != NULL)) {
@@ -156,38 +161,6 @@ int load_message(message_summary *Msg,
/* now we put the body mimepart we read above into the mimelist */
Put(Msg->AllAttach, SKEY(Msg->MsgBody->PartNum), Msg->MsgBody, DestroyMime);
- /* Generate a reply-to address */
- if (StrLength(Msg->Rfca) > 0) {
- if (Msg->reply_to == NULL)
- Msg->reply_to = NewStrBuf();
- if (StrLength(Msg->from) > 0) {
- StrBufPrintf(Msg->reply_to, "%s <%s>", ChrPtr(Msg->from), ChrPtr(Msg->Rfca));
- }
- else {
- FlushStrBuf(Msg->reply_to);
- StrBufAppendBuf(Msg->reply_to, Msg->Rfca, 0);
- }
- }
- else
- {
- if ((StrLength(Msg->OtherNode)>0) &&
- (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_nodename))) &&
- (strcasecmp(ChrPtr(Msg->OtherNode), ChrPtr(WCC->serv_info->serv_humannode)) ))
- {
- if (Msg->reply_to == NULL)
- Msg->reply_to = NewStrBuf();
- StrBufPrintf(Msg->reply_to,
- "%s @ %s",
- ChrPtr(Msg->from),
- ChrPtr(Msg->OtherNode));
- }
- else {
- if (Msg->reply_to == NULL)
- Msg->reply_to = NewStrBuf();
- FlushStrBuf(Msg->reply_to);
- StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
- }
- }
FreeStrBuf(&Buf);
FreeStrBuf(&HdrToken);
return 1;
@@ -230,11 +203,12 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
FreeStrBuf(&Error);
}
- /* strip the bare contenttype, so we ommit charset etc. */
+ /* Extract just the content-type (omit attributes such as "charset") */
StrBufExtract_token(Buf, Msg->MsgBody->ContentType, 0, ';');
StrBufTrim(Buf);
StrBufLowerCase(Buf);
- /* look up the renderer, that will convert this mimeitem into the htmlized form */
+
+ /* Locate a renderer capable of converting this MIME part into HTML */
if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
(vHdr != NULL)) {
RenderMimeFuncStruct *Render;
@@ -273,7 +247,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
}
-void
+long
HttpStatus(long CitadelStatus)
{
long httpstatus = 502;
@@ -338,7 +312,7 @@ HttpStatus(long CitadelStatus)
break;
}
-
+ return httpstatus;
}
/*
@@ -381,16 +355,14 @@ void handle_one_message(void)
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 */
serv_printf("MOVE %ld|_TRASH_|0", msgnum);
}
StrBuf_ServGetln(CmdBuf);
- FlushStrBuf(WCC->ImportantMsg);
- StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
- GetServerStatus(CmdBuf, &CitStatus);
+ GetServerStatusMsg(CmdBuf, &CitStatus, 1, 0);
HttpStatus(CitStatus);
break;
case eCOPY:
@@ -401,8 +373,7 @@ void handle_one_message(void)
Destination = (StrBuf*) vLine;
serv_printf("MOVE %ld|%s|%d", msgnum, ChrPtr(Destination), CopyMessage);
StrBuf_ServGetln(CmdBuf);
- FlushStrBuf(WCC->ImportantMsg);
- StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
+ GetServerStatusMsg(CmdBuf, NULL, 1, 0);
GetServerStatus(CmdBuf, &CitStatus);
HttpStatus(CitStatus);
}
@@ -428,6 +399,8 @@ void embed_message(void) {
StrBuf *CmdBuf = NULL;
msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
+ if (msgnum <= 0) return;
+
switch (WCC->Hdr->HR.eReqType)
{
case eGET:
@@ -441,15 +414,14 @@ void embed_message(void) {
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 */
serv_printf("MOVE %ld|_TRASH_|0", msgnum);
}
StrBuf_ServGetln(CmdBuf);
- FlushStrBuf(WCC->ImportantMsg);
- StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
+ GetServerStatusMsg(CmdBuf, NULL, 1, 0);
break;
default:
break;
@@ -479,22 +451,6 @@ void print_message(void) {
wDumpContent(0);
}
-/*
- * Mobile browser view of message
- */
-void mobile_message_view(void)
-{
- long msgnum = 0L;
- const StrBuf *Mime;
-
- msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
- output_headers(1, 0, 0, 0, 0, 1);
- begin_burst();
- do_template("msgcontrols", NULL);
- read_message(WC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
- wDumpContent(0);
-}
-
/*
* Display a message's headers
*/
@@ -515,7 +471,7 @@ void display_headers(void) {
serv_getln(buf, sizeof buf);
if (buf[0] == '1') {
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- wprintf("%s\n", buf);
+ wc_printf("%s\n", buf);
}
}
@@ -547,8 +503,10 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu
Msg = (message_summary*)malloc(sizeof(message_summary));
memset(Msg, 0, sizeof(message_summary));
while (len = StrBuf_ServGetln(Buf),
+ (len >= 0) &&
((len != 3) ||
- strcmp(ChrPtr(Buf), "000")== 0)){
+ strcmp(ChrPtr(Buf), "000")))
+ {
buf = ChrPtr(Buf);
ebuf = strchr(ChrPtr(Buf), '=');
nBuf = ebuf - buf;
@@ -557,7 +515,7 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu
StrBufCutLeft(Buf, nBuf + 1);
Eval->f(Msg, Buf);
}
- else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
+ else syslog(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
}
return Msg;
}
@@ -571,9 +529,10 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu
*
* 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;
@@ -598,7 +557,10 @@ int load_msg_ptrs(const char *servcmd, SharedMessageStatus *Stat)
return (Stat->nummsgs);
}
Buf2 = NewStrBuf();
- while (len = StrBuf_ServGetln(Buf), ((len != 3) || strcmp(ChrPtr(Buf), "000")!= 0))
+ while (len = StrBuf_ServGetln(Buf),
+ ((len >= 0) &&
+ ((len != 3) ||
+ strcmp(ChrPtr(Buf), "000")!= 0)))
{
if (Stat->nummsgs < Stat->maxload) {
skipit = 0;
@@ -632,47 +594,11 @@ int load_msg_ptrs(const char *servcmd, SharedMessageStatus *Stat)
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);
@@ -685,29 +611,41 @@ int load_msg_ptrs(const char *servcmd, SharedMessageStatus *Stat)
}
-inline message_summary* GetMessagePtrAt(int n, HashList *Summ)
+
+/**
+ * \brief sets FlagToSet for each of ScanMe that appears in MatchMSet
+ * \param ScanMe List of BasicMsgStruct to be searched it MatchSet
+ * \param MatchMSet MSet we want to flag
+ * \param FlagToSet Flag to set on each BasicMsgStruct->Flags if in MSet
+ */
+void SetFlagsFromMSet(HashList *ScanMe, MSet *MatchMSet, int FlagToSet, int Reverse)
{
- const char *Key;
+ const char *HashKey;
long HKLen;
+ HashPos *at;
void *vMsg;
+ message_summary *Msg;
- if (Summ == NULL)
- return NULL;
- GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
- return (message_summary*) vMsg;
+ at = GetNewHashPos(ScanMe, 0);
+ while (GetNextHashPos(ScanMe, at, &HKLen, &HashKey, &vMsg)) {
+ /* Are you a new message, or an old message? */
+ Msg = (message_summary*) vMsg;
+ if (Reverse && IsInMSetList(MatchMSet, Msg->msgnum)) {
+ Msg->Flags = Msg->Flags | FlagToSet;
+ }
+ else if (!Reverse && !IsInMSetList(MatchMSet, Msg->msgnum)) {
+ Msg->Flags = Msg->Flags | FlagToSet;
+ }
+ }
+ DeleteHashPos(&at);
}
-
void load_seen_flags(void)
{
- message_summary *Msg;
- const char *HashKey;
- long HKLen;
- HashPos *at;
- void *vMsg;
StrBuf *OldMsg;
wcsession *WCC = WC;
+ MSet *MatchMSet;
OldMsg = NewStrBuf();
serv_puts("GTSN");
@@ -719,19 +657,13 @@ void load_seen_flags(void)
FreeStrBuf(&OldMsg);
return;
}
- at = GetNewHashPos(WCC->summ, 0);
- while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
- /* Are you a new message, or an old message? */
- Msg = (message_summary*) vMsg;
- if (is_msg_in_mset(ChrPtr(OldMsg), Msg->msgnum)) {
- Msg->is_new = 0;
- }
- else {
- Msg->is_new = 1;
- }
+
+ if (ParseMSet(&MatchMSet, OldMsg))
+ {
+ SetFlagsFromMSet(WCC->summ, MatchMSet, MSGFLAG_READ, 0);
}
+ DeleteMSet(&MatchMSet);
FreeStrBuf(&OldMsg);
- DeleteHashPos(&at);
}
extern readloop_struct rlid[];
@@ -744,22 +676,23 @@ typedef struct _RoomRenderer{
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;
void *vMsg;
message_summary *Msg;
char cmd[256] = "";
- int i;
+ int i, r;
wcsession *WCC = WC;
HashPos *at;
const char *HashKey;
@@ -768,33 +701,58 @@ void readloop(long oper)
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;
+ }
+
+ if (WCC->CurRoom.view == VIEW_WIKI) {
+ http_redirect("wiki?page=home");
+ 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->CurRoom.view = VIEW_BBS;
+ GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
+ }
if (vViewMsg == NULL) {
- WCC->wc_view = VIEW_BBS;
- GetHash(ReadLoopHandler, IKEY(WCC->wc_view), &vViewMsg);
+ 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();
}
- switch(ViewMsg->GetParamsGetServerCall(
+ if (ViewMsg->GetParamsGetServerCall != NULL) {
+ r = ViewMsg->GetParamsGetServerCall(
&Stat,
&ViewSpecific,
oper,
- cmd, sizeof(cmd)))
+ cmd, sizeof(cmd)
+ );
+ } else {
+ r = 0;
+ }
+ switch(r)
{
case 400:
case 404:
@@ -807,20 +765,21 @@ void readloop(long oper)
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;
memset(&SubTP, 0, sizeof(WCTemplputParams));
- SubTP.Filter.ContextType = CTX_NONE;
+ SubTP.Filter.ContextType = CTX_MAILSUM;
SubTP.Context = NULL;
SortIt = RetrieveSort(&SubTP, NULL, 0,
HKEY("date"), Stat.defaultsortorder);
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();
@@ -835,9 +794,15 @@ void readloop(long oper)
WCC->num_displayed = 0;
/* Put some helpful data in vars for mailsummary_json */
- svputlong("READLOOP:TOTALMSGS", Stat.nummsgs);
- svputlong("READLOOP:STARTMSG", Stat.startmsg);
- svputlong("WCVIEW", WCC->wc_view);
+ {
+ StrBuf *Foo;
+
+ Foo = NewStrBuf ();
+ StrBufPrintf(Foo, "%ld", Stat.nummsgs);
+ PutBstr(HKEY("__READLOOP:TOTALMSGS"), NewStrBufDup(Foo));
+ StrBufPrintf(Foo, "%ld", Stat.startmsg);
+ PutBstr(HKEY("__READLOOP:STARTMSG"), Foo);
+ }
/*
* iterate over each message. if we need to load an attachment, do it here.
@@ -851,7 +816,11 @@ void readloop(long oper)
while ( GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
Msg = (message_summary*) vMsg;
if ((Msg->msgnum >= Stat.startmsg) && (Stat.num_displayed <= Stat.maxmsgs)) {
- ViewMsg->LoadMsgFromServer(&Stat, &ViewSpecific, Msg, Msg->is_new, i);
+ ViewMsg->LoadMsgFromServer(&Stat,
+ &ViewSpecific,
+ Msg,
+ (Msg->Flags & MSGFLAG_READ) != 0,
+ i);
}
i++;
}
@@ -890,6 +859,7 @@ void post_mime_to_server(void) {
size_t encoded_length;
size_t encoded_strlen;
char *txtmail = NULL;
+ int include_text_alt = 0; /* Set to nonzero to include multipart/alternative text/plain */
sprintf(top_boundary, "Citadel--Multipart--%s--%04x--%04x",
ChrPtr(WCC->serv_info->serv_fqdn),
@@ -911,6 +881,11 @@ void post_mime_to_server(void) {
is_multipart = 1;
}
+ /* Only do multipart/alternative for mailboxes. BBS and Wiki rooms don't need it. */
+ if (WC->CurRoom.view == VIEW_MAILBOX) {
+ include_text_alt = 1;
+ }
+
if (is_multipart) {
/* Remember, serv_printf() appends an extra newline */
serv_printf("Content-type: multipart/mixed; boundary=\"%s\"\n", top_boundary);
@@ -919,19 +894,21 @@ void post_mime_to_server(void) {
}
/* Remember, serv_printf() appends an extra newline */
- serv_printf("Content-type: multipart/alternative; "
- "boundary=\"%s\"\n", alt_boundary);
- serv_printf("This is a multipart message in MIME format.\n");
- serv_printf("--%s", alt_boundary);
+ if (include_text_alt) {
+ serv_printf("Content-type: multipart/alternative; "
+ "boundary=\"%s\"\n", alt_boundary);
+ serv_printf("This is a multipart message in MIME format.\n");
+ serv_printf("--%s", alt_boundary);
- serv_puts("Content-type: text/plain; charset=utf-8");
- serv_puts("Content-Transfer-Encoding: quoted-printable");
- serv_puts("");
- txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
- text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
- free(txtmail);
+ serv_puts("Content-type: text/plain; charset=utf-8");
+ serv_puts("Content-Transfer-Encoding: quoted-printable");
+ serv_puts("");
+ txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
+ text_to_server_qp(txtmail); /* Transmit message in quoted-printable encoding */
+ free(txtmail);
- serv_printf("--%s", alt_boundary);
+ serv_printf("\n--%s", alt_boundary);
+ }
serv_puts("Content-type: text/html; charset=utf-8");
serv_puts("Content-Transfer-Encoding: quoted-printable");
@@ -940,7 +917,9 @@ void post_mime_to_server(void) {
text_to_server_qp(bstr("msgtext")); /* Transmit message in quoted-printable encoding */
serv_puts("