final touches on dkim test harness
[citadel.git] / webcit / messages.c
index 1024e0657885d03a657cbcc9f6c675214c9d7d4e..ec6306ecc57c960fce531c7b212c216651aba8da 100644 (file)
@@ -17,7 +17,7 @@
 // GNU General Public License for more details.
 
 #include "webcit.h"
-#include "webserver.h"
+
 #include "dav.h"
 #include "calendar.h"
 
@@ -181,7 +181,6 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
        Msg = (message_summary *)malloc(sizeof(message_summary));
        if (!Msg) {
                syslog(LOG_DEBUG, "malloc() error");
-               TRACE;
        }
        memset(Msg, 0, sizeof(message_summary));
        Msg->msgnum = msgnum;
@@ -189,7 +188,6 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
        Msg->MsgBody =  (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
        if (!Msg->MsgBody) {
                syslog(LOG_DEBUG, "malloc() error");
-               TRACE;
        }
        memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
        Msg->MsgBody->msgnum = msgnum;
@@ -307,7 +305,7 @@ long HttpStatus(long CitadelStatus) {
        default:
        case BINARY_FOLLOWS:
        case SEND_BINARY:
-       case START_CHAT_MODE:
+       case SEND_THEN_RECV:
        case ASYNC_MSG:
        case MORE_DATA:
        case SEND_LISTING:
@@ -544,7 +542,6 @@ int load_msg_ptrs(const char *servcmd,
                        Msg = (message_summary*)malloc(sizeof(message_summary));
                        if (!Msg) {
                                syslog(LOG_DEBUG, "malloc() error");
-                               TRACE;
                        }
                        memset(Msg, 0, sizeof(message_summary));
 
@@ -851,10 +848,8 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) {
 }
 
 
-/*
- * Back end for post_message()
- * ... this is where the actual message gets transmitted to the server.
- */
+// Back end for post_message()
+// This is where the actual message gets transmitted to the server.
 void post_mime_to_server(void) {
        char top_boundary[SIZ];
        char alt_boundary[SIZ];
@@ -903,15 +898,14 @@ void post_mime_to_server(void) {
        /* Remember, serv_printf() appends an extra newline */
        if (include_text_alt) {
                StrBuf *Buf;
-               serv_printf("Content-type: multipart/alternative; "
-                       "boundary=\"%s\"\n", alt_boundary);
+               serv_printf("Content-type: multipart/alternative; boundary=\"%s\"\n", alt_boundary);
                serv_printf("This is a multipart message in MIME format.\n");
                serv_printf("--%s", alt_boundary);
 
                serv_puts("Content-type: text/plain; charset=utf-8");
                serv_puts("Content-Transfer-Encoding: quoted-printable");
                serv_puts("");
-               txtmail = html_to_ascii(bstr("msgtext"), 0, 80);
+               txtmail = html_to_ascii(bstr("msgtext"), 0, 80, 0);
                Buf = NewStrBufPlain(txtmail, -1);
                free(txtmail);
 
@@ -924,7 +918,9 @@ void post_mime_to_server(void) {
        serv_puts("Content-Transfer-Encoding: quoted-printable");
        serv_puts("");
        serv_puts("<html><body>\r\n");
-       text_to_server_qp(sbstr("msgtext"));    /* Transmit message in quoted-printable encoding */
+       if (havebstr("msgtext")) {
+               text_to_server_qp(sbstr("msgtext"));    /* Transmit message in quoted-printable encoding */
+       }
        serv_puts("</body></html>\r\n");
 
        if (include_text_alt) {
@@ -951,7 +947,7 @@ void post_mime_to_server(void) {
                                break;
                        }
                        syslog(LOG_DEBUG, "Attachment: raw len %d", StrLength(att->Data));
-                       encoded_strlen = CtdlEncodeBase64(encoded, ChrPtr(att->Data), StrLength(att->Data), 1);
+                       encoded_strlen = CtdlEncodeBase64(encoded, ChrPtr(att->Data), StrLength(att->Data), BASE64_YES_LINEBREAKS);
                        syslog(LOG_DEBUG, "Attachment: encoded len %d", encoded_strlen);
 
                        serv_printf("--%s", top_boundary);
@@ -1232,7 +1228,6 @@ void upload_attachment(void) {
        att = (wc_mime_attachment*)malloc(sizeof(wc_mime_attachment));
        if (!att) {
                syslog(LOG_DEBUG, "malloc() error");
-               TRACE;
        }
        memset(att, 0, sizeof(wc_mime_attachment ));
        att->length = WC->upload_length;
@@ -1543,7 +1538,7 @@ void display_enter(void) {
                                        case eXclusivID:
                                        case eJournal:
                                        case eListID:
-                                       case eMesageText:
+                                       case eMessageText:
                                        case eMessagePath:
                                        case eSpecialField:
                                        case eTimestamp:
@@ -1798,14 +1793,13 @@ void postpart(StrBuf *partnum, StrBuf *filename, int force_download) {
 }
 
 
-/*
- * Generic function to output an arbitrary MIME part from an arbitrary
- * message number on the server.
- *
- * msgnum              message number on the citadel server
- * partnum             MIME part number to be output
- * force_download      Nonzero to force set the Content-Type: header to "application/octet-stream"
- */
+// Generic function to output an arbitrary MIME part from an arbitrary
+// message number on the server.
+//
+// msgnum              message number on the citadel server
+// partnum             MIME part number to be output
+// force_download      Nonzero to force set the Content-Type: header to "application/octet-stream"
+
 void view_or_download_mimepart(int force_download) {
        long msgnum;
        off_t bytes;