X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fmsg_renderers.c;h=408bc97d44f7a88bb9eaa2bb76e9af3ce2e40dd8;hb=aeade41982c6c9a3e745a3b3c8262a3ec6952670;hp=6fb4af2267c7276a064cb8b1732daf9f6f8df78e;hpb=61efdb8c2ac5cd49c0d965026a45851ccef5e8dd;p=citadel.git diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index 6fb4af226..408bc97d4 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -5,7 +5,7 @@ CtxType CTX_MAILSUM = CTX_NONE; CtxType CTX_MIME_ATACH = CTX_NONE; -inline void CheckConvertBufs(struct wcsession *WCC) +static inline void CheckConvertBufs(struct wcsession *WCC) { if (WCC->ConvertBuf1 == NULL) WCC->ConvertBuf1 = NewStrBuf(); @@ -329,6 +329,7 @@ void examine_msgn(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) CheckConvertBufs(WCC); FreeStrBuf(&Msg->reply_inreplyto); Msg->reply_inreplyto = NewStrBufPlain(NULL, StrLength(HdrLine)); + Msg->reply_inreplyto_hash = ThreadIdHash(HdrLine); StrBuf_RFC822_2_Utf8(Msg->reply_inreplyto, HdrLine, WCC->DefaultCharset, @@ -355,6 +356,7 @@ void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) CheckConvertBufs(WCC); FreeStrBuf(&Msg->reply_references); Msg->reply_references = NewStrBufPlain(NULL, StrLength(HdrLine)); + Msg->reply_references_hash = ThreadIdHash(HdrLine); StrBuf_RFC822_2_Utf8(Msg->reply_references, HdrLine, WCC->DefaultCharset, @@ -877,6 +879,43 @@ void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCh } } + +int ReadOneMessageSummary(message_summary *Msg, StrBuf *FoundCharset, StrBuf *Buf) +{ + void *vHdr; + headereval *Hdr; + const char *buf; + const char *ebuf; + int nBuf; + long len; + + serv_printf("MSG0 %ld|1", Msg->msgnum); /* ask for headers only */ + + StrBuf_ServGetln(Buf); + if (GetServerStatus(Buf, NULL) != 1) { + return 0; + } + + 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(MsgHeaderHandler, buf, nBuf, &vHdr) && + (vHdr != NULL)) { + Hdr = (headereval*)vHdr; + StrBufCutLeft(Buf, nBuf + 1); + Hdr->evaluator(Msg, Buf, FoundCharset); + } + else syslog(LOG_INFO, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf)); + } + return 1; +} + void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP) { message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM); @@ -958,6 +997,7 @@ void tmplput_EDIT_WIKI_BODY(StrBuf *Target, WCTemplputParams *TP) */ if (!havebstr("attach_button")) { char *wikipage = strdup(bstr("page")); + putbstr("format", NewStrBufPlain(HKEY("plain"))); str_wiki_index(wikipage); msgnum = locate_message_by_uid(wikipage); free(wikipage); @@ -1137,6 +1177,42 @@ void render_MAIL_html(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset Mime->Data = Buf; } +#ifdef HAVE_MARKDOWN +/* +char * MarkdownHandleURL(const char* SourceURL, const int len, void* something) +{ + +} +*/ +void render_MAIL_markdown(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset) +{ +#include + wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH); + MMIOT *doc; + char *md_as_html = NULL; + const char *format; + + if (StrLength(Mime->Data) == 0) + return; + + format = bstr("format"); + + if ((format == NULL) || + strcmp(format, "plain")) + { + doc = mkd_string(ChrPtr(Mime->Data), StrLength(Mime->Data), 0); + mkd_basename(doc, "/wiki?page="); + mkd_compile(doc, 0); + if (mkd_document(doc, &md_as_html) != EOF) { + FreeStrBuf(&Mime->Data); + Mime->Data = NewStrBufPlain(md_as_html, -1); + } +// free(md_as_html); + mkd_cleanup(doc); + } +} +#endif + void render_MAIL_UNKNOWN(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset) { wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH); @@ -1598,6 +1674,9 @@ InitModule_MSGRENDERERS RegisterMimeRenderer(HKEY("text/plain"), render_MAIL_text_plain, 1, 3); RegisterMimeRenderer(HKEY("text"), render_MAIL_text_plain, 1, 1); RegisterMimeRenderer(HKEY("text/html"), render_MAIL_html, 1, 100); +#ifdef HAVE_MARKDOWN + RegisterMimeRenderer(HKEY("text/x-markdown"), render_MAIL_markdown, 1, 30); +#endif RegisterMimeRenderer(HKEY(""), render_MAIL_UNKNOWN, 0, 0); /* these headers are citserver replies to MSG4 and friends. one evaluator for each */