]> code.citadel.org Git - citadel.git/blobdiff - webcit/msg_renderers.c
* change syntax of read_message
[citadel.git] / webcit / msg_renderers.c
index 388ac50603983a31c21240b985e0e2309e40428f..cd3cd88eab6fe1b66d39563b923d0e6955794b3f 100644 (file)
@@ -101,7 +101,6 @@ void tmplput_MAIL_SUMM_FROM(StrBuf *Target, int nArgs, WCTemplateToken *Token, v
 {
        message_summary *Msg = (message_summary*) Context;
        StrBufAppendBuf(Target, Msg->from, 0);
-       lprintf(1,"%s", ChrPtr(Msg->from));
 }
 
 
@@ -111,7 +110,6 @@ void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
        FreeStrBuf(&Msg->subj);
        Msg->subj = NewStrBufPlain(NULL, StrLength(HdrLine));
        StrBuf_RFC822_to_Utf8(Msg->subj, HdrLine, WC->DefaultCharset, FoundCharset);
-       lprintf(1,"%s", ChrPtr(Msg->subj));
 }
 void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
 {/////TODO: Fwd: and RE: filter!!
@@ -267,6 +265,8 @@ void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, int nArgs, WCTemplateToken *Token
 
 void render_MAIL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
 {
+       Mime->Data = NewStrBufPlain(NULL, Mime->length);
+       read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, 0, Mime->PartNum);
 /*
        if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
                for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
@@ -503,7 +503,12 @@ int Conditional_MAIL_MIME_ATTACH(WCTemplateToken *Tokens, void *Context, int Con
 
 
 /*----------------------------------------------------------------------------*/
-
+void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+{
+       long MsgNum;
+       MsgNum = LBstr(Token->Params[0]->Start, Token->Params[0]->len);
+       read_message(Target, HKEY("view_message_replyquote"), MsgNum, 0, NULL);
+}
 
 void tmplput_MAIL_BODY(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
 {
@@ -539,6 +544,12 @@ void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *F
        iconv_t ic = (iconv_t)(-1) ;
 #endif
 
+       if ((StrLength(Mime->Data) == 0) && (Mime->length > 0)) {
+               FreeStrBuf(&Mime->Data);
+               Mime->Data = NewStrBufPlain(NULL, Mime->length);
+               read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, 0, Mime->PartNum);
+       }
+
        /* Boring old 80-column fixed format text gets handled this way... */
        if ((strcasecmp(ChrPtr(Mime->Charset), "us-ascii") == 0) &&
            (strcasecmp(ChrPtr(Mime->Charset), "UTF-8") == 0))
@@ -729,6 +740,30 @@ void tmplput_MIME_Length(StrBuf *Target, int nArgs, WCTemplateToken *Token, void
        StrBufAppendPrintf(Target, "%ld", mime->length);
 }
 
+HashList *iterate_get_registered_Attachments(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+{
+       return WC->attachments;
+}
+
+void tmplput_ATT_Length(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+{
+       wc_attachment *att = (wc_attachment*) Context;
+       StrBufAppendPrintf(Target, "%ld", att->length);
+}
+
+void tmplput_ATT_Contenttype(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+{
+       wc_attachment *att = (wc_attachment*) Context;
+       StrBufAppendBuf(Target, att->content_type, 0);
+}
+
+void tmplput_ATT_FileName(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
+{
+       wc_attachment *att = (wc_attachment*) Context;
+       StrBufAppendBuf(Target, att->filename, 0);
+}
+
+
 
 
 
@@ -753,7 +788,10 @@ InitModule_MSGRENDERERS
        RegisterNamespace("MAIL:SUMM:REFIDS", 0, 0, tmplput_MAIL_SUMM_REFIDS,  CTX_MAILSUM);
        RegisterNamespace("MAIL:SUMM:INREPLYTO", 0, 2, tmplput_MAIL_SUMM_INREPLYTO,  CTX_MAILSUM);
        RegisterNamespace("MAIL:BODY", 0, 2, tmplput_MAIL_BODY,  CTX_MAILSUM);
-
+       RegisterNamespace("MAIL:QUOTETEXT", 1, 2, tmplput_QUOTED_MAIL_BODY,  CTX_NONE);
+       RegisterNamespace("ATT:SIZE", 0, 1, tmplput_ATT_Length, CTX_ATT);
+       RegisterNamespace("ATT:TYPE", 0, 1, tmplput_ATT_Contenttype, CTX_ATT);
+       RegisterNamespace("ATT:FILENAME", 0, 1, tmplput_ATT_FileName, CTX_ATT);
 
        RegisterConditional(HKEY("COND:MAIL:SUMM:UNREAD"), 0, Conditional_MAIL_SUMM_UNREAD, CTX_MAILSUM);
        RegisterConditional(HKEY("COND:MAIL:SUMM:H_NODE"), 0, Conditional_MAIL_SUMM_H_NODE, CTX_MAILSUM);
@@ -784,7 +822,8 @@ InitModule_MSGRENDERERS
        RegisterNamespace("MAIL:MIME:LENGTH", 0, 2, tmplput_MIME_Length, CTX_MIME_ATACH);
        RegisterNamespace("MAIL:MIME:DATA", 0, 2, tmplput_MIME_Data, CTX_MIME_ATACH);
 
-
+       RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments, 
+                        NULL, NULL, CTX_ATT, CTX_NONE);
 
        RegisterMimeRenderer(HKEY("message/rfc822"), render_MAIL);
        RegisterMimeRenderer(HKEY("text/x-vcard"), render_MIME_VCard);