#include "dav.h"
#include "calendar.h"
-HashList *MsgHeaderHandler = NULL;
HashList *MimeRenderHandler = NULL;
HashList *ReadLoopHandler = NULL;
int dbg_analyze_msg = 0;
{
StrBuf *Buf;
StrBuf *HdrToken;
- headereval *Hdr;
- void *vHdr;
char buf[SIZ];
int Done = 0;
int state=0;
-
+ int rc;
+
Buf = NewStrBuf();
if (Msg->PartNum != NULL) {
serv_printf("MSG4 %ld|%s", Msg->msgnum, ChrPtr(Msg->PartNum));
StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
/* look up one of the examine_* functions to parse the content */
- if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
- (vHdr != NULL)) {
- Hdr = (headereval*)vHdr;
- Hdr->evaluator(Msg, Buf, FoundCharset);
- if (Hdr->Type == 1) {
- state++;
- }
- }/* TODO:
+ rc = EvaluateMsgHdr(SKEY(HdrToken), Msg, Buf, FoundCharset);
+ if (rc == 1) {
+ state++;
+ }
+ /* TODO:
else LogError(Target,
__FUNCTION__,
"don't know how to handle message header[%s]\n",
if (StrLength(HdrToken) > 0) {
StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
/* the examine*'s know how to do with mime headers too... */
- if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
- (vHdr != NULL)) {
- Hdr = (headereval*)vHdr;
- Hdr->evaluator(Msg, Buf, FoundCharset);
- }
+ EvaluateMsgHdr(SKEY(HdrToken), Msg, Buf, FoundCharset);
+
break;
}
}
* printable_view Nonzero to display a printable view
* section Optional for encapsulated message/rfc822 submessage
*/
-int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime)
+int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime, WCTemplputParams *TP)
{
StrBuf *Buf;
StrBuf *FoundCharset;
StrBufTrim(Buf);
StrBufLowerCase(Buf);
- StackContext(NULL, &SuperTP, Msg, CTX_MAILSUM, 0, NULL);
+ StackContext(TP, &SuperTP, Msg, CTX_MAILSUM, 0, NULL);
{
/* Locate a renderer capable of converting this MIME part into HTML */
if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
case ePOST:
Tmpl = sbstr("template");
if (StrLength(Tmpl) > 0)
- read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
+ read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime, NULL);
else
- read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
+ read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
http_transmit_thing(ChrPtr(Mime), 0);
break;
case eDELETE:
case ePOST:
Tmpl = sbstr("template");
if (StrLength(Tmpl) > 0)
- read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
+ read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime, NULL);
else
- read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
+ read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
http_transmit_thing(ChrPtr(Mime), 0);
break;
case eDELETE:
begin_burst();
- read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime);
+ read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime, NULL);
wDumpContent(0);
}
Foo = NewStrBuf ();
StrBufPrintf(Foo, "%ld", Stat.nummsgs);
- PutBstr(HKEY("__READLOOP:TOTALMSGS"), NewStrBufDup(Foo)); // keep Foo!
+ PutBstr(HKEY("__READLOOP:TOTALMSGS"), NewStrBufDup(Foo)); /* keep Foo! */
StrBufPrintf(Foo, "%ld", Stat.numNewmsgs);
- PutBstr(HKEY("__READLOOP:NEWMSGS"), NewStrBufDup(Foo)); // keep Foo!
+ PutBstr(HKEY("__READLOOP:NEWMSGS"), NewStrBufDup(Foo)); /* keep Foo! */
StrBufPrintf(Foo, "%ld", Stat.startmsg);
- PutBstr(HKEY("__READLOOP:STARTMSG"), Foo); // store Foo elsewhere, descope it here.
+ PutBstr(HKEY("__READLOOP:STARTMSG"), Foo); /* store Foo elsewhere, descope it here. */
}
/*
}
-long FourHash(const char *key, long length)
-{
- int i;
- long ret = 0;
- const unsigned char *ptr = (const unsigned char*)key;
-
- for (i = 0; i < 4; i++, ptr ++)
- ret = (ret << 8) |
- ( ((*ptr >= 'a') &&
- (*ptr <= 'z'))?
- *ptr - 'a' + 'A':
- *ptr);
-
- return ret;
-}
-
-long l_subj;
-long l_wefw;
-long l_msgn;
-long l_from;
-long l_rcpt;
-long l_cccc;
-long l_replyto;
-long l_node;
-long l_rfca;
-long l_nvto;
-
const char *ReplyToModeStrings [3] = {
"reply",
"replyall",
int i = 0;
long replying_to;
+ int prefer_md;
+
+ get_pref_yesno("markdown", &prefer_md, 0);
+
if (havebstr("force_room")) {
gotoroom(sbstr("force_room"));
}
((len != 3) ||
strcmp(ChrPtr(Line), "000")))
{
- long which = 0;
+ eMessageField which;
if ((StrLength(Line) > 4) &&
- (ChrPtr(Line)[4] == '='))
- which = FourHash(ChrPtr(Line), 4);
-
- if (which == l_subj)
- {
- StrBuf *subj = NewStrBuf();
- StrBuf *FlatSubject;
-
- if (ReplyMode == eForward) {
- if (strncasecmp(ChrPtr(Line) + 5, "Fw:", 3)) {
- StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
+ (ChrPtr(Line)[4] == '=') &&
+ GetFieldFromMnemonic(&which, ChrPtr(Line)))
+ switch (which) {
+ case eMsgSubject: {
+ StrBuf *subj = NewStrBuf();
+ StrBuf *FlatSubject;
+
+ if (ReplyMode == eForward) {
+ if (strncasecmp(ChrPtr(Line) + 5, "Fw:", 3)) {
+ StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
+ }
}
- }
- else {
- if (strncasecmp(ChrPtr(Line) + 5, "Re:", 3)) {
- StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+ else {
+ if (strncasecmp(ChrPtr(Line) + 5, "Re:", 3)) {
+ StrBufAppendBufPlain(subj, HKEY("Re: "), 0);
+ }
}
- }
- StrBufAppendBufPlain(subj,
- ChrPtr(Line) + 5,
- StrLength(Line) - 5, 0);
- FlatSubject = NewStrBufPlain(NULL, StrLength(subj));
- StrBuf_RFC822_to_Utf8(FlatSubject, subj, NULL, NULL);
+ StrBufAppendBufPlain(subj,
+ ChrPtr(Line) + 5,
+ StrLength(Line) - 5, 0);
+ FlatSubject = NewStrBufPlain(NULL, StrLength(subj));
+ StrBuf_RFC822_to_Utf8(FlatSubject, subj, NULL, NULL);
- PutBstr(HKEY("subject"), FlatSubject);
- }
+ PutBstr(HKEY("subject"), FlatSubject);
+ }
+ break;
- else if (which == l_wefw)
- {
- int rrtok;
- int rrlen;
+ case eWeferences:
+ {
+ int rrtok;
+ int rrlen;
- wefw = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ wefw = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
- /* Trim down excessively long lists of thread references. We eliminate the
- * second one in the list so that the thread root remains intact.
- */
- rrtok = num_tokens(ChrPtr(wefw), '|');
- rrlen = StrLength(wefw);
- if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
- StrBufRemove_token(wefw, 1, '|');
+ /* Trim down excessively long lists of thread references. We eliminate the
+ * second one in the list so that the thread root remains intact.
+ */
+ rrtok = num_tokens(ChrPtr(wefw), '|');
+ rrlen = StrLength(wefw);
+ if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
+ StrBufRemove_token(wefw, 1, '|');
+ }
+ break;
}
- }
-
- else if (which == l_msgn) {
- msgn = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
- }
- else if (which == l_from) {
- StrBuf *FlatFrom;
- from = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
- FlatFrom = NewStrBufPlain(NULL, StrLength(from));
- StrBuf_RFC822_to_Utf8(FlatFrom, from, NULL, NULL);
- FreeStrBuf(&from);
- from = FlatFrom;
- for (i=0; i<StrLength(from); ++i) {
- if (ChrPtr(from)[i] == ',')
- StrBufPeek(from, NULL, i, ' ');
+ case emessageId:
+ msgn = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ break;
+
+ case eAuthor: {
+ StrBuf *FlatFrom;
+ from = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ FlatFrom = NewStrBufPlain(NULL, StrLength(from));
+ StrBuf_RFC822_to_Utf8(FlatFrom, from, NULL, NULL);
+ FreeStrBuf(&from);
+ from = FlatFrom;
+ for (i=0; i<StrLength(from); ++i) {
+ if (ChrPtr(from)[i] == ',')
+ StrBufPeek(from, NULL, i, ' ');
+ }
+ break;
}
- }
- else if (which == l_rcpt) {
- rcpt = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
- }
+ case eRecipient:
+ rcpt = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ break;
+
- else if (which == l_cccc) {
- cccc = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
- }
+ case eCarbonCopY:
+ cccc = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ break;
+
- else if (which == l_node) {
- node = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
- }
- else if (which == l_replyto) {
- replyto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
- }
- else if (which == l_rfca) {
- StrBuf *FlatRFCA;
- rfca = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
- FlatRFCA = NewStrBufPlain(NULL, StrLength(rfca));
- StrBuf_RFC822_to_Utf8(FlatRFCA, rfca, NULL, NULL);
- FreeStrBuf(&rfca);
- rfca = FlatRFCA;
- }
- else if (which == l_nvto) {
- nvto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
- putbstr("nvto", nvto);
- }
+ case eNodeName:
+ node = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ break;
+ case eReplyTo:
+ replyto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ break;
+ case erFc822Addr: {
+ StrBuf *FlatRFCA;
+ rfca = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ FlatRFCA = NewStrBufPlain(NULL, StrLength(rfca));
+ StrBuf_RFC822_to_Utf8(FlatRFCA, rfca, NULL, NULL);
+ FreeStrBuf(&rfca);
+ rfca = FlatRFCA;
+ break;
+ }
+ case eenVelopeTo:
+ nvto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+ putbstr("nvto", nvto);
+ break;
+ case eXclusivID:
+ case eHumanNode:
+ case eJournal:
+ case eListID:
+ case eMesageText:
+ case eOriginalRoom:
+ case eMessagePath:
+ case eSpecialField:
+ case eTimestamp:
+ break;
+
+ }
}
begin_burst();
output_headers(1, 0, 0, 0, 1, 0);
- if (WCC->CurRoom.defview == VIEW_WIKIMD)
+ if ((WCC->CurRoom.defview == VIEW_WIKIMD) || prefer_md)
DoTemplate(HKEY("edit_markdown_epic"), NULL, &NoCtx);
else
DoTemplate(HKEY("edit_message"), NULL, &NoCtx);
PRF_YESNO,
NULL);
RegisterPreference("signature", _("Use this signature:"), PRF_QP_STRING, NULL);
- RegisterPreference("default_header_charset",
+ RegisterPreference("default_header_charset",
_("Default character set for email headers:"),
PRF_STRING,
NULL);
PRF_STRING,
NULL);
RegisterPreference("mailbox",_("Mailbox view mode"), PRF_STRING, NULL);
+ RegisterPreference("markdown",_("Prefer markdown editing"), PRF_YESNO, NULL);
+
WebcitAddUrlHandler(HKEY("readnew"), "", 0, h_readnew, ANONYMOUS|NEED_URL);
WebcitAddUrlHandler(HKEY("readold"), "", 0, h_readold, ANONYMOUS|NEED_URL);
/* json */
WebcitAddUrlHandler(HKEY("roommsgs"), "", 0, jsonMessageList,0);
-
- l_subj = FourHash("subj", 4);
- l_wefw = FourHash("wefw", 4);
- l_msgn = FourHash("msgn", 4);
- l_from = FourHash("from", 4);
- l_rcpt = FourHash("rcpt", 4);
- l_cccc = FourHash("cccc", 4);
- l_replyto = FourHash("rep2", 4);
- l_node = FourHash("node", 4);
- l_rfca = FourHash("rfca", 4);
- l_nvto = FourHash("nvto", 4);
-
- return ;
}
void