* migrate message creation to templates (citing still missing)
[citadel.git] / webcit / msg_renderers.c
index 388ac50603983a31c21240b985e0e2309e40428f..ca9b264fd45672d158ec91256e9161aa7e060494 100644 (file)
@@ -729,6 +729,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);
+}
+
+
 
 
 
@@ -754,6 +778,9 @@ InitModule_MSGRENDERERS
        RegisterNamespace("MAIL:SUMM:INREPLYTO", 0, 2, tmplput_MAIL_SUMM_INREPLYTO,  CTX_MAILSUM);
        RegisterNamespace("MAIL:BODY", 0, 2, tmplput_MAIL_BODY,  CTX_MAILSUM);
 
+       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 +811,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);