Allow to stack contexts into message renderers.
authorWilfried Goesgens <willi@arangodb.com>
Sun, 13 Dec 2015 15:26:18 +0000 (16:26 +0100)
committerWilfried Goesgens <willi@arangodb.com>
Sun, 13 Dec 2015 15:26:18 +0000 (16:26 +0100)
libcitadel/tests/testdata/emailaddresses/email_recipientstrings.txt
webcit/bbsview_renderer.c
webcit/blogview_renderer.c
webcit/messages.c
webcit/messages.h
webcit/msg_renderers.c
webcit/smtpqueue.c
webcit/vcard_edit.c
webcit/wiki.c

index f7877dd91b7d30edd721ed1507abbc339622670a..d4dcc0c4bc4065c450cdc6581ddec0ca86a55544 100644 (file)
@@ -6,3 +6,5 @@ Art Cancro <ajc@uncensored.citadel.org>, Art Cancro <ajc@uncensored.citadel.org>
 Hüttemann Detlef
 "Hüttemann Detlef"<somebody@cosmocode.de>,Wilfried Goesgens <me.in@o3sis.com>, Lang Adrian <somebodyelse@cosmocode.de>, Gohr Andreas <da_splitbaiin@cosmocode.de>
 Holger Müller
+=?utf-8?Q?voycontigo_-_5_Jahre_Barfu=C3=9Fschuhexperten!?= <info@voycontigo.de>.
+=?utf-8?B?6LS56bqf5Y2T?= <ygfyy@st.net>.
index aefcccf955c39148f23b8e406c6470922617fc1b..d9f255ac0f51cad49969fb08db53039f8a6904fa 100644 (file)
@@ -285,7 +285,7 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat,
                                        }
                                }
                                if (BBS->msgs[i] > 0L) {
-                                       read_message(WC->WBuf, HKEY("view_message"), BBS->msgs[i], NULL, &Mime);
+                                       read_message(WC->WBuf, HKEY("view_message"), BBS->msgs[i], NULL, &Mime, NULL);
                                }
                                if (
                                        (i == (BBS->num_msgs - 1))
index 0a0510a295af2128adbfdfdc070e5115f4618fd3..d727650bf937a8e222a07d2d85486b7662c10f77 100644 (file)
@@ -111,19 +111,19 @@ void tmplput_blog_comment_unread_count(StrBuf *Target, WCTemplputParams *TP) {
 /*
  * Render a single blog post and (optionally) its comments
  */
-void blogpost_render(blogpost *bp, int with_comments)
+void blogpost_render(blogpost *bp, int with_comments, WCTemplputParams *TP)
 {
        wcsession *WCC = WC;
        WCTemplputParams SubTP;
        const StrBuf *Mime;
        int i;
 
-        memset(&SubTP, 0, sizeof(WCTemplputParams));    
-       StackContext(NULL, &SubTP, bp, CTX_BLOGPOST, 0, NULL);
+        memset(&SubTP, 0, sizeof(WCTemplputParams));
+       StackContext(TP, &SubTP, bp, CTX_BLOGPOST, 0, NULL);
 
        /* Always show the top level post, unless we somehow ended up with an empty list */
        if (bp->num_msgs > 0) {
-               read_message(WC->WBuf, HKEY("view_blog_post"), bp->msgs[0], NULL, &Mime);
+               read_message(WC->WBuf, HKEY("view_blog_post"), bp->msgs[0], NULL, &Mime, TP);
        }
 
        if (with_comments) {
@@ -131,7 +131,7 @@ void blogpost_render(blogpost *bp, int with_comments)
                DoTemplate(HKEY("view_blog_show_commentlink"), WCC->WBuf, &SubTP);
 
                for (i=1; i<bp->num_msgs; ++i) {
-                       read_message(WC->WBuf, HKEY("view_blog_comment"), bp->msgs[i], NULL, &Mime);
+                       read_message(WC->WBuf, HKEY("view_blog_comment"), bp->msgs[i], NULL, &Mime, &SubTP);
                }
                DoTemplate(HKEY("view_blog_comment_box"), WCC->WBuf, &SubTP);
        }
@@ -297,9 +297,11 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
        int firstp = 0;
        int maxp = 0;
        WCTemplputParams SubTP;
+       WCTemplputParams StopSubTP;
        blogpost oneBP;
 
         memset(&SubTP, 0, sizeof(WCTemplputParams));    
+        memset(&StopSubTP, 0, sizeof(WCTemplputParams));    
        memset(&oneBP, 0, sizeof(blogpost));
 
        /* Comments are shown if we are only viewing a single blog post */
@@ -327,7 +329,7 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
                        }
                }
                if (unread_count == 1) {
-                       blogpost_render(unread_bp, 1);
+                       blogpost_render(unread_bp, 1, NULL);/// TODO other than null?
 
                        DeleteHashPos(&it);
                        return 0;
@@ -370,22 +372,22 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
 
                /* Now go through the list and render what we've got */
                for (i=start_here; i<num_blogposts; ++i) {
+                       int j = i - maxp;
+                       if (j < 0) j = 0;
+                       StackContext(NULL, &SubTP, &blogposts[j], CTX_BLOGPOST, 0, NULL);
                        if ((i > 0) && (i == start_here)) {
-                               int j = i - maxp;
-                               if (j < 0) j = 0;
-
                                StackContext(NULL, &SubTP, &blogposts[j], CTX_BLOGPOST, 0, NULL);
                                DoTemplate(HKEY("view_blog_post_start"), WCC->WBuf, &SubTP);
-                               UnStackContext(&SubTP);
                        }
                        if (i < (start_here + maxp)) {
-                               blogpost_render(blogposts[i], with_comments);
+                               blogpost_render(blogposts[i], with_comments, &SubTP);
                        }
                        else if (i == (start_here + maxp)) {
-                               StackContext(NULL, &SubTP, &blogposts[i], CTX_BLOGPOST, 0, NULL);
+                               StackContext(&SubTP, &StopSubTP, &blogposts[i], CTX_BLOGPOST, 0, NULL);
                                DoTemplate(HKEY("view_blog_post_stop"), WCC->WBuf, &SubTP);
-                               UnStackContext(&SubTP);
+                               UnStackContext(&StopSubTP);
                        }
+                       UnStackContext(&SubTP);
                }
 
                /* Done.  We are only freeing the array of pointers; the data itself
index 405656eab269ec22794ea6c7c5b5d080fc9726c1..7ac906d62f6e5a673990cdeca684c58e1778d50f 100644 (file)
@@ -171,7 +171,7 @@ int load_message(message_summary *Msg,
  * printable_view      Nonzero to display a printable view
  * section             Optional for encapsulated message/rfc822 submessage
  */
-int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime) 
+int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *PartNum, const StrBuf **OutMime, WCTemplputParams *TP
 {
        StrBuf *Buf;
        StrBuf *FoundCharset;
@@ -208,7 +208,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
        StrBufTrim(Buf);
        StrBufLowerCase(Buf);
 
-       StackContext(NULL, &SuperTP, Msg, CTX_MAILSUM, 0, NULL);
+       StackContext(TP, &SuperTP, Msg, CTX_MAILSUM, 0, NULL);
        {
                /* Locate a renderer capable of converting this MIME part into HTML */
                if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
@@ -357,9 +357,9 @@ void handle_one_message(void)
        case ePOST:
                Tmpl = sbstr("template");
                if (StrLength(Tmpl) > 0) 
-                       read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
+                       read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime, NULL);
                else 
-                       read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
+                       read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
                http_transmit_thing(ChrPtr(Mime), 0);
                break;
        case eDELETE:
@@ -416,9 +416,9 @@ void embed_message(void) {
        case ePOST:
                Tmpl = sbstr("template");
                if (StrLength(Tmpl) > 0) 
-                       read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime);
+                       read_message(WCC->WBuf, SKEY(Tmpl), msgnum, NULL, &Mime, NULL);
                else 
-                       read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
+                       read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
                http_transmit_thing(ChrPtr(Mime), 0);
                break;
        case eDELETE:
@@ -455,7 +455,7 @@ void print_message(void) {
 
        begin_burst();
 
-       read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime);
+       read_message(WC->WBuf, HKEY("view_message_print"), msgnum, NULL, &Mime, NULL);
 
        wDumpContent(0);
 }
index eb014f43852f55452d9afab34c491feccb266abf..d81bdea7ba47a13a2916fe33b4ec8ff255897995 100644 (file)
@@ -139,7 +139,8 @@ int read_message(StrBuf *Target,
                 const char *tmpl, long tmpllen, 
                 long msgnum, 
                 const StrBuf *section, 
-                const StrBuf **OutMime);
+                const StrBuf **OutMime,
+                WCTemplputParams *TP);
 int load_message(message_summary *Msg, 
                 StrBuf *FoundCharset,
                 StrBuf **Error);
index d68911edcec5adc16cc0cb6e675f47734f6f7566..13451c169c1fd43c50b98e47eec70fb3826b999f 100644 (file)
@@ -598,7 +598,7 @@ void render_MAIL(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
                Mime->Data = NewStrBufPlain(NULL, Mime->length);
        else 
                FlushStrBuf(Mime->Data);
-       read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, Mime->PartNum, &TemplateMime);
+       read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, Mime->PartNum, &TemplateMime, TP);
 /*
        if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
                for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
@@ -948,7 +948,7 @@ void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
 
        MsgNum = LBstr(TKEY(0));
        Buf = NewStrBuf();
-       read_message(Buf, HKEY("view_message_replyquote"), MsgNum, NULL, &Mime);
+       read_message(Buf, HKEY("view_message_replyquote"), MsgNum, NULL, &Mime, TP);
        StrBufAppendTemplate(Target, TP, Buf, 1);
        FreeStrBuf(&Buf);
 }
@@ -961,7 +961,7 @@ void tmplput_EDIT_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
 
        MsgNum = LBstr(TKEY(0));
        Buf = NewStrBuf();
-       read_message(Buf, HKEY("view_message_edit"), MsgNum, NULL, &Mime);
+       read_message(Buf, HKEY("view_message_edit"), MsgNum, NULL, &Mime, TP);
        StrBufAppendTemplate(Target, TP, Buf, 1);
        FreeStrBuf(&Buf);
 }
@@ -984,7 +984,7 @@ void tmplput_EDIT_WIKI_BODY(StrBuf *Target, WCTemplputParams *TP)
                free(wikipage);
                if (msgnum >= 0L) {
                        Buf = NewStrBuf();
-                       read_message(Buf, HKEY("view_message_wikiedit"), msgnum, NULL, &Mime);
+                       read_message(Buf, HKEY("view_message_wikiedit"), msgnum, NULL, &Mime, TP);
                        StrBufAppendTemplate(Target, TP, Buf, 1);
                        FreeStrBuf(&Buf);
                }
index ff9e9dc8e536ae677b6831b09a780db6c5f4ccaf..b9b6de783afd66bd9dae70c8ebc9141860cbb515 100644 (file)
@@ -373,7 +373,7 @@ int qview_LoadMsgFromServer(SharedMessageStatus *Stat,
        const StrBuf *Mime;
 
         /* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */
-       read_message(WCC->WBuf, HKEY("view_mailq_message_bearer"), Msg->msgnum, NULL, &Mime);
+       read_message(WCC->WBuf, HKEY("view_mailq_message_bearer"), Msg->msgnum, NULL, &Mime, NULL);
 
         return 0;
 }
index d5cbe0b3553be8e6a546dc8dee9bb4ac57be689d..608d74025c5c943b7e4d3ab1d88d229adadc2175 100644 (file)
@@ -1030,7 +1030,7 @@ int vcard_RenderView_or_Tail(SharedMessageStatus *Stat, void **ViewSpecific, lon
 
        VS = (vcardview_struct*) *ViewSpecific;
        if (VS->is_singlecard)
-               read_message(WC->WBuf, HKEY("view_message"), lbstr("startmsg"), NULL, &Mime);
+               read_message(WC->WBuf, HKEY("view_message"), lbstr("startmsg"), NULL, &Mime, NULL);
        else
                do_addrbook_view(VS);   /* Render the address book */
        return 0;
index ec746fe86baf6b1a1c177efec02a96be9e24c9b5..0ea7dd120083b2837ae4913b7a8e08c496cfb2c6 100644 (file)
@@ -76,7 +76,7 @@ void display_wiki_page_backend(char *pagename, char *rev, int do_revert)
        }
 
        if (msgnum >= 0L) {
-               read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime);
+               read_message(WCC->WBuf, HKEY("view_message"), msgnum, NULL, &Mime, NULL);
                return;
        }