]> code.citadel.org Git - citadel.git/blobdiff - webcit/msg_renderers.c
* load inline texts with DLAT not MSG4
[citadel.git] / webcit / msg_renderers.c
index c8f367627aaaeb326a8a739a5551c1d1ea9e3194..ec367e380421f798f91f8bf974535dce29118bf1 100644 (file)
@@ -239,7 +239,6 @@ int Conditional_ANONYMOUS_MESSAGE(StrBuf *Target, WCTemplputParams *TP)
        return Msg->nhdr != 0;
 }
 
-
 void examine_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
 {
        Msg->format_type = StrToi(HdrLine);
@@ -405,7 +404,26 @@ HashList *iterate_get_mailsumm_All(StrBuf *Target, WCTemplputParams *TP)
 {
        return WC->summ;
 }
-
+int Conditional_ROOM_DISPLAY_MSG(StrBuf *Target, WCTemplputParams *TP) {
+       wcsession *WCC = WC;
+       IterateStruct *ITC = CCTX;
+       int num_inset = ITC->n;
+       if ((num_inset >= WC->startmsg) && (WCC->num_displayed <= WCC->maxmsgs)) {
+       WCC->num_displayed = WCC->num_displayed+1;
+       return 1; /* Pass GO, collect $200 */
+       } 
+       return 0;
+}
+int Conditional_MAIL_SUMM_LASTMSG(StrBuf *Target, WCTemplputParams *TP) {
+  IterateStruct *ITC = CCTX;
+       int is_last_n = ITC->LastN;
+/*
+       //GetHash(WC->vars, HKEY("ITERATE:N"), (void *)&n_dsubst);
+       //num_inset = n_dsubst->lvalue;
+       */
+       /* Is the num_displayed higher than maxmsgs? OR last in iterator */
+       return ((WC->num_displayed > WC->maxmsgs) || (is_last_n == 1));
+}
 void examine_time(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
 {
        Msg->date = StrTol(HdrLine);
@@ -622,7 +640,6 @@ void examine_msg4_partnum(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCh
        StrBufTrim(Msg->MsgBody->PartNum);
 }
 
-
 void examine_content_lengh(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
 {
        Msg->MsgBody->length = StrTol(HdrLine);
@@ -717,7 +734,7 @@ int Conditional_MAIL_MIME_ATTACH(StrBuf *Target, WCTemplputParams *TP)
 /*----------------------------------------------------------------------------*/
 void tmplput_QUOTED_MAIL_BODY(StrBuf *Target, WCTemplputParams *TP)
 {
-       long MsgNum;
+        long MsgNum;
        StrBuf *Buf;
 
        MsgNum = LBstr(TKEY(0));
@@ -764,9 +781,7 @@ void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *F
 
        if ((StrLength(Mime->Data) == 0) && (Mime->length > 0)) {
                FreeStrBuf(&Mime->Data);
-               Mime->Data = NewStrBufPlain(NULL, Mime->length);
-               if (!read_message(Mime->Data, HKEY("view_submessage"), Mime->msgnum, 0, Mime->PartNum))
-                       return;
+               MimeLoadData(Mime);
        }
 
        /* Boring old 80-column fixed format text gets handled this way... */
@@ -848,8 +863,13 @@ void render_MAIL_text_plain(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *F
                iconv_close(ic);
        }
 #endif
+
        FreeStrBuf(&Mime->Data);
        Mime->Data = Target;
+       FlushStrBuf(Mime->ContentType);
+       StrBufAppendBufPlain(Mime->ContentType, HKEY("text/html"), 0);
+       FlushStrBuf(Mime->Charset);
+       StrBufAppendBufPlain(Mime->Charset, HKEY("UTF-8"), 0);
        FreeStrBuf(&Line);
        FreeStrBuf(&Line1);
        FreeStrBuf(&Line2);
@@ -867,7 +887,7 @@ void render_MAIL_html(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCh
        /* HTML is fun, but we've got to strip it first */
        output_html(ChrPtr(Mime->Charset), 
                    (WC->wc_view == VIEW_WIKI ? 1 : 0), 
-                   StrToi(Mime->PartNum), 
+                   Mime->msgnum,
                    Mime->Data, Buf);
        FreeStrBuf(&Mime->Data);
        Mime->Data = Buf;
@@ -1083,7 +1103,6 @@ InitModule_MSGRENDERERS
        RegisterIterator("MAIL:SUMM:MSGS", 0, NULL, iterate_get_mailsumm_All,
                         NULL,NULL, CTX_MAILSUM, CTX_NONE, IT_NOFLAG);
 
-       /* render parts of the message struct */
        RegisterNamespace("MAIL:SUMM:DATEBRIEF", 0, 0, tmplput_MAIL_SUMM_DATE_BRIEF, CTX_MAILSUM);
        RegisterNamespace("MAIL:SUMM:DATEFULL", 0, 0, tmplput_MAIL_SUMM_DATE_FULL, CTX_MAILSUM);
        RegisterNamespace("MAIL:SUMM:DATENO",  0, 0, tmplput_MAIL_SUMM_DATE_NO,  CTX_MAILSUM);
@@ -1102,13 +1121,14 @@ 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("MAIL:QUOTETEXT", 1, 2, tmplput_QUOTED_MAIL_BODY,  CTX_NONE);
-
+       RegisterConditional(HKEY("COND:ROOM:DISPLAYMSG"), 0, Conditional_ROOM_DISPLAY_MSG, CTX_MAILSUM);
+       RegisterConditional(HKEY("COND:MAIL:SUMM:LASTMSG"), 0, Conditional_MAIL_SUMM_LASTMSG, CTX_MAILSUM);
        RegisterConditional(HKEY("COND:MAIL:SUMM:RFCA"), 0, Conditional_MAIL_SUMM_RFCA,  CTX_MAILSUM);
        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);
        RegisterConditional(HKEY("COND:MAIL:SUMM:OTHERNODE"), 0, Conditional_MAIL_SUMM_OTHERNODE, CTX_MAILSUM);
        RegisterConditional(HKEY("COND:MAIL:ANON"), 0, Conditional_ANONYMOUS_MESSAGE, CTX_MAILSUM);
-
+       
 
        /* do we have mimetypes to iterate over? */
        RegisterConditional(HKEY("COND:MAIL:MIME:ATTACH"), 0, Conditional_MAIL_MIME_ALL, CTX_MAILSUM);