- we now use the context stacking mechanism, so contexts are transparent through several levels of mime and other renderers
- remove other parameters to harmonize the interface.
-void render_MIME_ICS_TPL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+void render_MIME_ICS_TPL(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
{
+ wc_mime_attachment *Mime = CTX(CTX_MIME_ATACH);
icalproperty_method the_method = ICAL_METHOD_NONE;
icalproperty *method = NULL;
icalcomponent *cal;
icalcomponent *c;
WCTemplputParams SubTP;
WCTemplputParams SuperTP;
+
static int divcount = 0;
if (StrLength(Mime->Data) == 0) {
}
putlbstr("divname", ++divcount);
+
+
putbstr("cal_partnum", NewStrBufDup(Mime->PartNum));
putlbstr("msgnum", Mime->msgnum);
the_method = icalproperty_get_method(method);
}
- SuperTP.Context = &the_method;
- SuperTP.Filter.ContextType = CTX_ICALMETHOD,
+ StackContext (TP,
+ &SuperTP,
+ &the_method,
+ CTX_ICALMETHOD,
+ 0,
+ TP->Tokens);
StackContext (&SuperTP,
&SubTP,
"EnableOrDisableCheckButton(); \n"
);
+ UnStackContext(&SuperTP);
UnStackContext(&SubTP);
icalcomponent_free(cal);
}
-
-
-
-
void tmplput_Conflict(StrBuf *Target, WCTemplputParams *TP)
{}
}
-
void
InitModule_ICAL_SUBST
(void)
void *vHdr;
long len;
const char *Key;
+ WCTemplputParams SuperTP;
WCTemplputParams SubTP;
StrBuf *Error = NULL;
StrBufTrim(Buf);
StrBufLowerCase(Buf);
- /* Locate a renderer capable of converting this MIME part into HTML */
- if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
- (vHdr != NULL)) {
- RenderMimeFuncStruct *Render;
- Render = (RenderMimeFuncStruct*)vHdr;
- Render->f(Msg->MsgBody, NULL, FoundCharset);
- }
-
- if (StrLength(Msg->reply_references)> 0) {
- /* Trim down excessively long lists of thread references. We eliminate the
- * second one in the list so that the thread root remains intact.
- */
- int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
- int rrlen = StrLength(Msg->reply_references);
- if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
- StrBufRemove_token(Msg->reply_references, 1, '|');
+ StackContext(NULL, &SuperTP, Msg, CTX_MAILSUM, 0, NULL);
+ {
+ /* Locate a renderer capable of converting this MIME part into HTML */
+ if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
+ (vHdr != NULL)) {
+ WCTemplputParams SubTP;
+ RenderMimeFuncStruct *Render;
+
+ StackContext(&SuperTP, &SubTP, Msg->MsgBody, CTX_MIME_ATACH, 0, NULL);
+ {
+ Render = (RenderMimeFuncStruct*)vHdr;
+ Render->f(Target, &SubTP, FoundCharset);
+ }
+ UnStackContext(&SubTP);
+ }
+
+ if (StrLength(Msg->reply_references)> 0) {
+ /* Trim down excessively long lists of thread references. We eliminate the
+ * second one in the list so that the thread root remains intact.
+ */
+ int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
+ int rrlen = StrLength(Msg->reply_references);
+ if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
+ StrBufRemove_token(Msg->reply_references, 1, '|');
+ }
}
- }
- /* now check if we need to translate some mimeparts, and remove the duplicate */
- it = GetNewHashPos(Msg->AllAttach, 0);
- while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
- (vMime != NULL)) {
- wc_mime_attachment *Mime = (wc_mime_attachment*) vMime;
- evaluate_mime_part(Msg, Mime);
- }
- DeleteHashPos(&it);
- StackContext(NULL, &SubTP, Msg, CTX_MAILSUM, 0, NULL);
- {
- *OutMime = DoTemplate(tmpl, tmpllen, Target, &SubTP);
+ /* now check if we need to translate some mimeparts, and remove the duplicate */
+ it = GetNewHashPos(Msg->AllAttach, 0);
+ while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
+ (vMime != NULL)) {
+ StackContext(&SuperTP, &SubTP, vMime, CTX_MIME_ATACH, 0, NULL);
+ {
+ evaluate_mime_part(Target, &SubTP);
+ }
+ UnStackContext(&SubTP);
+ }
+ DeleteHashPos(&it);
+ *OutMime = DoTemplate(tmpl, tmpllen, Target, &SuperTP);
}
- UnStackContext(&SubTP);
+ UnStackContext(&SuperTP);
DestroyMessageSummary(Msg);
FreeStrBuf(&FoundCharset);
extern CtxType CTX_MAILSUM;
+extern CtxType CTX_MIME_ATACH;
extern HashList *MsgHeaderHandler;
extern HashList *MimeRenderHandler;
extern HashList *ReadLoopHandler;
typedef struct wc_mime_attachment wc_mime_attachment;
-typedef void (*RenderMimeFunc)(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset);
+typedef void (*RenderMimeFunc)(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset);
typedef struct _RenderMimeFuncStruct {
RenderMimeFunc f;
} RenderMimeFuncStruct;
typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
-void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime);
+void evaluate_mime_part(StrBuf *Target, WCTemplputParams *TP);
typedef enum _eCustomRoomRenderer {
-void render_MAIL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+void render_MAIL(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
{
+ wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
const StrBuf *TemplateMime;
if (Mime->Data == NULL)
*/
}
-void render_MIME_VCard(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
{
+ wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
wcsession *WCC = WC;
if (StrLength(Mime->Data) == 0)
MimeLoadData(Mime);
}
-void render_MIME_ICS(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+void render_MIME_ICS(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
{
+ wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
if (StrLength(Mime->Data) == 0) {
MimeLoadData(Mime);
}
}
-void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime)
+void evaluate_mime_part(StrBuf *Target, WCTemplputParams *TP)
{
+ message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
+ wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
void *vMimeRenderer;
/* just print the root-node */
}
-void render_MAIL_variformat(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+void render_MAIL_variformat(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
{
/* Messages in legacy Citadel variformat get handled thusly... */
- StrBuf *Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
- FmOut(Target, "JUSTIFY", Mime->Data);
+ wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
+ StrBuf *TTarget = NewStrBufPlain(NULL, StrLength(Mime->Data));
+ FmOut(TTarget, "JUSTIFY", Mime->Data);
FreeStrBuf(&Mime->Data);
- Mime->Data = Target;
+ Mime->Data = TTarget;
}
-void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+void render_MAIL_text_plain(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
{
+ wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
const char *ptr, *pte;
const char *BufPtr = NULL;
StrBuf *Line;
StrBuf *Line1;
StrBuf *Line2;
- StrBuf *Target;
+ StrBuf *TTarget;
long Linecount;
long nEmptyLines;
int bn = 0;
Line = NewStrBufPlain(NULL, SIZ);
Line1 = NewStrBufPlain(NULL, SIZ);
Line2 = NewStrBufPlain(NULL, SIZ);
- Target = NewStrBufPlain(NULL, StrLength(Mime->Data));
+ TTarget = NewStrBufPlain(NULL, StrLength(Mime->Data));
Linecount = 0;
nEmptyLines = 0;
if (StrLength(Mime->Data) > 0)
if (StrLength(Line) == 0) {
if (Linecount == 0)
continue;
- StrBufAppendBufPlain(Target, HKEY("<tt></tt><br>\n"), 0);
+ StrBufAppendBufPlain(TTarget, HKEY("<tt></tt><br>\n"), 0);
nEmptyLines ++;
continue;
}
nEmptyLines = 0;
for (i = bn; i < bq; i++)
- StrBufAppendBufPlain(Target, HKEY("<blockquote>"), 0);
+ StrBufAppendBufPlain(TTarget, HKEY("<blockquote>"), 0);
for (i = bq; i < bn; i++)
- StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
+ StrBufAppendBufPlain(TTarget, HKEY("</blockquote>"), 0);
#ifdef HAVE_ICONV
if (ConvertIt) {
StrBufConvert(Line, Line1, &ic);
}
#endif
- StrBufAppendBufPlain(Target, HKEY("<tt>"), 0);
+ StrBufAppendBufPlain(TTarget, HKEY("<tt>"), 0);
UrlizeText(Line1, Line, Line2);
- StrEscAppend(Target, Line1, NULL, 0, 0);
- StrBufAppendBufPlain(Target, HKEY("</tt><br>\n"), 0);
+ StrEscAppend(TTarget, Line1, NULL, 0, 0);
+ StrBufAppendBufPlain(TTarget, HKEY("</tt><br>\n"), 0);
bn = bq;
Linecount ++;
}
(BufPtr != NULL));
if (nEmptyLines > 0)
- StrBufCutRight(Target, nEmptyLines * (sizeof ("<tt></tt><br>\n") - 1));
+ StrBufCutRight(TTarget, nEmptyLines * (sizeof ("<tt></tt><br>\n") - 1));
for (i = 0; i < bn; i++)
- StrBufAppendBufPlain(Target, HKEY("</blockquote>"), 0);
+ StrBufAppendBufPlain(TTarget, HKEY("</blockquote>"), 0);
- StrBufAppendBufPlain(Target, HKEY("</i><br>"), 0);
+ StrBufAppendBufPlain(TTarget, HKEY("</i><br>"), 0);
#ifdef HAVE_ICONV
if (ic != (iconv_t)(-1) ) {
iconv_close(ic);
#endif
FreeStrBuf(&Mime->Data);
- Mime->Data = Target;
+ Mime->Data = TTarget;
FlushStrBuf(Mime->ContentType);
StrBufAppendBufPlain(Mime->ContentType, HKEY("text/html"), 0);
FlushStrBuf(Mime->Charset);
FreeStrBuf(&Line2);
}
-void render_MAIL_html(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+void render_MAIL_html(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
{
+ wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
StrBuf *Buf;
if (StrLength(Mime->Data) == 0)
Mime->Data = Buf;
}
-void render_MAIL_UNKNOWN(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+void render_MAIL_UNKNOWN(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
{
+ wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
/* Unknown weirdness */
FlushStrBuf(Mime->Data);
StrBufAppendBufPlain(Mime->Data, _("I don't know how to display "), -1, 0);
{
wc_mime_attachment *mime = (wc_mime_attachment*) CTX(CTX_MIME_ATACH);
if (mime->Renderer != NULL)
- mime->Renderer->f(mime, NULL, NULL);
+ mime->Renderer->f(Target, TP, NULL);
StrBufAppendTemplate(Target, TP, mime->Data, 0);
/* TODO: check whether we need to load it now? */
}
-
-
-
-
-void render_QUEUE(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+void render_QUEUE(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
{
+ wc_mime_attachment *Mime = CTX(CTX_MIME_ATACH);
WCTemplputParams SubTP;
+ OneQueItem* Context;
+
+ Context = DeserializeQueueItem(Mime->Data, Mime->msgnum);
+ StackContext(TP, &SubTP, Context, CTX_MAILQITEM, 0, TP->Tokens);
+ {
+ DoTemplate(HKEY("view_mailq_message"), NULL, &SubTP);
+ }
+ UnStackContext(&SubTP);
- memset(&SubTP, 0, sizeof(WCTemplputParams));
- SubTP.Filter.ContextType = CTX_MAILQITEM;
- SubTP.Context = DeserializeQueueItem(Mime->Data, Mime->msgnum);
- DoTemplate(HKEY("view_mailq_message"),NULL, &SubTP);
- FreeQueItem ((OneQueItem**)&SubTP.Context);
+ FreeQueItem (&Context);
}
void