From: Wilfried Göesgens Date: Fri, 7 Nov 2008 20:57:16 +0000 (+0000) Subject: * display attachments in messages as view/download links X-Git-Tag: v7.86~1809 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=d7aea431d4802bd466ff10032eb54b9177c02366;p=citadel.git * display attachments in messages as view/download links --- diff --git a/webcit/messages.c b/webcit/messages.c index d05d988ef..baa2255d8 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -361,6 +361,11 @@ void tmplput_MAIL_SUMM_INREPLYTO(StrBuf *Target, int nArgs, WCTemplateToken *Tok StrBufAppendBuf(Target, Msg->reply_inreplyto, 0); } +int Conditional_MAIL_SUMM_UNREAD(WCTemplateToken *Tokens, void *Context, int ContextType) +{ + message_summary *Msg = (message_summary*) Context; + return Msg->is_new != 0; +} void examine_wefw(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) { @@ -657,10 +662,29 @@ void tmplput_MAIL_SUMM_N(StrBuf *Target, int nArgs, WCTemplateToken *Token, void } -int Conditional_MAIL_SUMM_UNREAD(WCTemplateToken *Tokens, void *Context, int ContextType) + +int Conditional_MAIL_MIME_ALL(WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - return Msg->is_new != 0; + return GetCount(Msg->Attachments) > 0; +} + +int Conditional_MAIL_MIME_SUBMESSAGES(WCTemplateToken *Tokens, void *Context, int ContextType) +{ + message_summary *Msg = (message_summary*) Context; + return GetCount(Msg->Submessages) > 0; +} + +int Conditional_MAIL_MIME_ATTACHLINKS(WCTemplateToken *Tokens, void *Context, int ContextType) +{ + message_summary *Msg = (message_summary*) Context; + return GetCount(Msg->AttachLinks) > 0; +} + +int Conditional_MAIL_MIME_ATTACH(WCTemplateToken *Tokens, void *Context, int ContextType) +{ + message_summary *Msg = (message_summary*) Context; + return GetCount(Msg->AllAttach) > 0; } @@ -814,7 +838,7 @@ void render_MAIL_UNKNOWN(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *Foun HashList *iterate_get_mime_All(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { message_summary *Msg = (message_summary*) Context; - return Msg->AllAttach; + return Msg->Attachments; } HashList *iterate_get_mime_Submessages(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) { @@ -832,12 +856,59 @@ HashList *iterate_get_mime_Attachments(StrBuf *Target, int nArgs, WCTemplateToke return Msg->AllAttach; } +void tmplput_MIME_Name(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +{ + wc_mime_attachment *mime = (wc_mime_attachment*) Context; + StrBufAppendBuf(Target, mime->Name, 0); +} + +void tmplput_MIME_FileName(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +{ + wc_mime_attachment *mime = (wc_mime_attachment*) Context; + StrBufAppendBuf(Target, mime->FileName, 0); +} -void tmplput_MIME_ATTACH(StrBuf *TemplBuffer, void *Context, WCTemplateToken *Token) +void tmplput_MIME_PartNum(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) { + wc_mime_attachment *mime = (wc_mime_attachment*) Context; + StrBufAppendBuf(Target, mime->PartNum, 0); } +void tmplput_MIME_MsgNum(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +{ + wc_mime_attachment *mime = (wc_mime_attachment*) Context; + StrBufAppendPrintf(Target, "%ld", mime->msgnum); +} +void tmplput_MIME_Disposition(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +{ + wc_mime_attachment *mime = (wc_mime_attachment*) Context; + StrBufAppendBuf(Target, mime->Disposition, 0); +} + +void tmplput_MIME_ContentType(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +{ + wc_mime_attachment *mime = (wc_mime_attachment*) Context; + StrBufAppendBuf(Target, mime->ContentType, 0); +} + +void tmplput_MIME_Charset(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +{ + wc_mime_attachment *mime = (wc_mime_attachment*) Context; + StrBufAppendBuf(Target, mime->Charset, 0); +} + +void tmplput_MIME_Data(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +{ + wc_mime_attachment *mime = (wc_mime_attachment*) Context; + StrBufAppendBuf(Target, mime->Data, 0); /// TODO: check whether we need to load it now? +} + +void tmplput_MIME_Length(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType) +{ + wc_mime_attachment *mime = (wc_mime_attachment*) Context; + StrBufAppendPrintf(Target, "%ld", mime->length); +} @@ -3911,15 +3982,32 @@ InitModule_MSG RegisterConditional(HKEY("COND:MAIL:SUMM:H_NODE"), 0, Conditional_MAIL_SUMM_H_NODE, CTX_MAILSUM); RegisterConditional(HKEY("COND:MAIL:SUMM:OTHERNODE"), 0, Conditional_MAIL_SUMM_OTHERNODE, CTX_MAILSUM); + RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH"), 0, Conditional_MAIL_MIME_ALL, CTX_MAILSUM); + RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:SUBMESSAGES"), 0, Conditional_MAIL_MIME_SUBMESSAGES, CTX_MAILSUM); + RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:LINKS"), 0, Conditional_MAIL_MIME_ATTACHLINKS, CTX_MAILSUM); + RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH:ATT"), 0, Conditional_MAIL_MIME_ATTACH, CTX_MAILSUM); + RegisterIterator("MAIL:MIME:ATTACH", 0, NULL, iterate_get_mime_All, - tmplput_MIME_ATTACH, NULL, CTX_MIME_ATACH, CTX_MAILSUM); + NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM); RegisterIterator("MAIL:MIME:ATTACH:SUBMESSAGES", 0, NULL, iterate_get_mime_Submessages, - tmplput_MIME_ATTACH, NULL, CTX_MIME_ATACH, CTX_MAILSUM); + NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM); RegisterIterator("MAIL:MIME:ATTACH:LINKS", 0, NULL, iterate_get_mime_AttachLinks, - tmplput_MIME_ATTACH, NULL, CTX_MIME_ATACH, CTX_MAILSUM); + NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM); RegisterIterator("MAIL:MIME:ATTACH:ATT", 0, NULL, iterate_get_mime_Attachments, - tmplput_MIME_ATTACH, NULL, CTX_MIME_ATACH, CTX_MAILSUM); + NULL, NULL, CTX_MIME_ATACH, CTX_MAILSUM); + + RegisterNamespace("MAIL:MIME:NAME", 0, 2, tmplput_MIME_Name, CTX_MIME_ATACH); + RegisterNamespace("MAIL:MIME:FILENAME", 0, 2, tmplput_MIME_FileName, CTX_MIME_ATACH); + RegisterNamespace("MAIL:MIME:PARTNUM", 0, 2, tmplput_MIME_PartNum, CTX_MIME_ATACH); + RegisterNamespace("MAIL:MIME:MSGNUM", 0, 2, tmplput_MIME_MsgNum, CTX_MIME_ATACH); + RegisterNamespace("MAIL:MIME:DISPOSITION", 0, 2, tmplput_MIME_Disposition, CTX_MIME_ATACH); + RegisterNamespace("MAIL:MIME:CONTENTTYPE", 0, 2, tmplput_MIME_ContentType, CTX_MIME_ATACH); + RegisterNamespace("MAIL:MIME:CHARSET", 0, 2, tmplput_MIME_Charset, CTX_MIME_ATACH); + RegisterNamespace("MAIL:MIME:LENGTH", 0, 2, tmplput_MIME_Length, CTX_MIME_ATACH); + RegisterNamespace("MAIL:MIME:DATA", 0, 2, tmplput_MIME_Data, CTX_MIME_ATACH); + + RegisterMimeRenderer(HKEY("text/x-citadel-variformat"), render_MAIL_variformat); RegisterMimeRenderer(HKEY("text/plain"), render_MAIL_text_plain); diff --git a/webcit/static/t/view_message.html b/webcit/static/t/view_message.html index 29040b7ce..9a43a3a20 100644 --- a/webcit/static/t/view_message.html +++ b/webcit/static/t/view_message.html @@ -25,4 +25,8 @@ onMouseOut=document.getElementById("msg").style.visibility="hidden
+ + + +
diff --git a/webcit/static/t/view_message_list_attach.html b/webcit/static/t/view_message_list_attach.html new file mode 100644 index 000000000..e15d40d1c --- /dev/null +++ b/webcit/static/t/view_message_list_attach.html @@ -0,0 +1,4 @@ +" border=0 align=middle> + (, bytes) +[ " target="wc.."> | + "> ]
diff --git a/webcit/webcit.h b/webcit/webcit.h index 0848579da..bbc026eba 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -337,14 +337,14 @@ void RegisterConditional(const char *Name, long len, typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context, WCTemplateToken *Token); typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType); typedef void (*HashDestructorFunc) (HashList **KillMe); -void RegisterITERATOR(const char *Name, long len, - int AdditionalParams, - HashList *StaticList, - RetrieveHashlistFunc GetHash, - SubTemplFunc DoSubTempl, - HashDestructorFunc Destructor, - int ContextType, - int XPectContextType); +void RegisterITERATOR(const char *Name, long len, /* Our identifier */ + int AdditionalParams, /* doe we use more parameters? */ + HashList *StaticList, /* pointer to webcit lifetime hashlists */ + RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */ + SubTemplFunc DoSubTempl, /* call this function on each iteration for svput & friends */ + HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */ + int ContextType, /* which context do we provide to the subtemplate? */ + int XPectContextType); /* which context do we expct to be called in? */ #define RegisterIterator(a, b, c, d, e, f, g, h) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h) void SVPut(char *keyname, size_t keylen, int keytype, char *Data);