#include "calendar.h"
HashList *MsgHeaderHandler = NULL;
-HashList *MsgEvaluators = NULL;
HashList *MimeRenderHandler = NULL;
HashList *ReadLoopHandler = NULL;
int dbg_analyze_msg = 0;
void display_enter(void);
-typedef void (*MsgPartEvaluatorFunc)(message_summary *Sum, StrBuf *Buf);
-
-typedef struct _MsgPartEvaluatorStruct {
- MsgPartEvaluatorFunc f;
-} MsgPartEvaluatorStruct;
-
void fixview()
{
/* workaround for json listview; its not useable directly */
* 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);
}
PACKAGE_STRING);
begin_burst();
- serv_printf("MSG2 %ld|3", msgnum);
+ serv_printf("MSG2 %ld|1", msgnum);
serv_getln(buf, sizeof buf);
if (buf[0] == '1') {
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
}
-message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum)
-{
- void *vEval;
- MsgPartEvaluatorStruct *Eval;
- message_summary *Msg;
- StrBuf *Buf;
- const char *buf;
- const char *ebuf;
- int nBuf;
- long len;
-
- Buf = NewStrBuf();
-
- serv_printf("MSG0 %ld|1", MsgNum); /* ask for headers only */
-
- StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) == 1) {
- FreeStrBuf(&Buf);
- return NULL;
- }
-
- 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")))
- {
- buf = ChrPtr(Buf);
- ebuf = strchr(ChrPtr(Buf), '=');
- nBuf = ebuf - buf;
- if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) {
- Eval = (MsgPartEvaluatorStruct*) vEval;
- StrBufCutLeft(Buf, nBuf + 1);
- Eval->f(Msg, Buf);
- }
- else syslog(LOG_INFO, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
- }
- return Msg;
-}
-
-
-
-
/*
* load message pointers from the server for a "read messages" operation
long HKLen;
WCTemplputParams SubTP;
SharedMessageStatus Stat;
- void *ViewSpecific;
+ void *ViewSpecific = NULL;
if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
WCC->CurRoom.view = VIEW_MAILBOX;
att->length = WCC->upload_length;
att->ContentType = NewStrBufPlain(WCC->upload_content_type, -1);
att->FileName = NewStrBufDup(WCC->upload_filename);
- UID = SBSTR("qquuid");
+ UID = sbstr("qquuid");
if (UID)
att->PartNum = NewStrBufDup(UID);
int i = 0;
long replying_to;
+ int prefer_md;
+
+ get_pref_yesno("markdown", &prefer_md, 0);
+
if (havebstr("force_room")) {
gotoroom(sbstr("force_room"));
}
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_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);