]> code.citadel.org Git - citadel.git/blobdiff - webcit/msg_renderers.c
* fix preview_pane scroll memory bug
[citadel.git] / webcit / msg_renderers.c
index f6d31e90fb4c105f244d40bebaa7173f739b39ff..68655ad537c45a8cd1c247b1d43159de2822efcd 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);
@@ -354,6 +353,11 @@ int Conditional_MAIL_SUMM_RFCA(StrBuf *Target, WCTemplputParams *TP)
        message_summary *Msg = (message_summary*) CTX;
        return StrLength(Msg->Rfca) > 0;
 }
+int Conditional_MAIL_SUMM_CCCC(StrBuf *Target, WCTemplputParams *TP)
+{
+       message_summary *Msg = (message_summary*) CTX;
+       return StrLength(Msg->cccc) > 0;
+}
 
 void examine_node(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
 {
@@ -403,32 +407,28 @@ void tmplput_MAIL_SUMM_ALLRCPT(StrBuf *Target, WCTemplputParams *TP)
 
 HashList *iterate_get_mailsumm_All(StrBuf *Target, WCTemplputParams *TP)
 {
-  return WC->summ;
+       return WC->summ;
 }
 int Conditional_ROOM_DISPLAY_MSG(StrBuf *Target, WCTemplputParams *TP) {
-  //message_summary *Msg = (message_summary *) CTX;
-  wcsubst *subst;
-  wcsession *WCC = WC;
-  GetHash(WCC->vars, HKEY("ITERATE:N"), (void *)&subst);
-  long num_inset = subst->lvalue;
-  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;
+       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) {
-  wcsubst *nsubst, *n_dsubst;
-  long is_last_n;
-  
-  GetHash(WC->vars, HKEY("ITERATE:LASTN"), (void *)&nsubst);
-  is_last_n = nsubst->lvalue;
-
-  //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));
+  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)
 {
@@ -787,9 +787,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... */
@@ -871,8 +869,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);
@@ -890,7 +893,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;
@@ -1127,11 +1130,12 @@ InitModule_MSGRENDERERS
        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:CCCC"), 0, Conditional_MAIL_SUMM_CCCC,  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);