add new token MSG:NATTACH to output the number of currently uploaded attachments
authorWilfried Goesgens <dothebart@citadel.org>
Mon, 2 May 2011 19:50:04 +0000 (19:50 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 20:13:49 +0000 (20:13 +0000)
webcit/msg_renderers.c

index 60f569ad5f8216a9fb474bb2a733d2e03b3a2e76..7d21cf7a15f619a6da5493932fa2e40a55c03c20 100644 (file)
@@ -1221,6 +1221,11 @@ HashList *iterate_get_registered_Attachments(StrBuf *Target, WCTemplputParams *T
        return WC->attachments;
 }
 
+void get_registered_Attachments_Count(StrBuf *Target, WCTemplputParams *TP)
+{
+       StrBufAppendPrintf(Target, "%ld", GetCount (WC->attachments));
+}
+
 void servcmd_do_search(char *buf, long bufsize)
 {
        snprintf(buf, bufsize, "MSGS SEARCH|%s", bstr("query"));
@@ -1498,6 +1503,8 @@ InitModule_MSGRENDERERS
        RegisterIterator("MSG:ATTACHNAMES", 0, NULL, iterate_get_registered_Attachments, 
                         NULL, NULL, CTX_MIME_ATACH, CTX_NONE, IT_NOFLAG);
 
+       RegisterNamespace("MSG:NATTACH", 0, 0, get_registered_Attachments_Count,  NULL, CTX_NONE);
+
        /* mime renderers translate an attachment into webcit viewable html text */
        RegisterMimeRenderer(HKEY("message/rfc822"), render_MAIL, 0, 150);
        RegisterMimeRenderer(HKEY("text/vnote"), render_MIME_VNote, 1, 300);