]> code.citadel.org Git - citadel.git/blobdiff - citadel/imap_fetch.c
* More IMAP tweaks
[citadel.git] / citadel / imap_fetch.c
index 895a03feed44b704c792fba51fd1be2b0b3c0c83..5bfc50520eaa31101c884c8d98a108456466a49c 100644 (file)
@@ -108,6 +108,9 @@ void imap_fetch_rfc822(int msgnum, char *whichfmt, struct CtdlMessage *msg) {
        CtdlRedirectOutput(tmp, -1);
        CtdlOutputPreLoadedMsg(msg, msgnum, MT_RFC822, 0, 0, 1);
        CtdlRedirectOutput(NULL, -1);
+       if (!is_valid_message(msg)) {
+               lprintf(1, "WARNING: output clobbered the message!\n");
+       }
 
        /*
         * Now figure out where the headers/text break is.  IMAP considers the
@@ -255,7 +258,7 @@ void imap_output_envelope_from(struct CtdlMessage *msg) {
 void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) {
        char datestringbuf[256];
        time_t msgdate;
-
+       char *fieldptr = NULL;
 
        /* Parse the message date into an IMAP-format date string */
        if (msg->cm_fields['T'] != NULL) {
@@ -273,21 +276,32 @@ void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) {
         */
        cprintf("ENVELOPE (");
 
-       /* date */
+       /* Date */
        imap_strout(datestringbuf);
        cprintf(" ");
 
-       /* subject */
+       /* Subject */
        imap_strout(msg->cm_fields['U']);
        cprintf(" ");
 
-       /* from */
+       /* From */
        imap_output_envelope_from(msg);
 
-       /* Sender (always in the RFC822 header) */
-       cprintf("NIL ");
+       /* Sender */
+       if (0) {
+               /* FIXME ... check for a *real* Sender: field */
+       }
+       else {
+               imap_output_envelope_from(msg);
+       }
 
-       cprintf("NIL ");        /* reply-to */
+       /* Reply-to */
+       if (0) {
+               /* FIXME ... check for a *real* Reply-to: field */
+       }
+       else {
+               imap_output_envelope_from(msg);
+       }
 
        cprintf("NIL ");        /* to */
 
@@ -295,8 +309,11 @@ void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) {
 
        cprintf("NIL ");        /* bcc */
 
-       cprintf("NIL ");        /* in-reply-to */
-
+       /* In-reply-to */
+       fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "In-reply-to");
+       imap_strout(fieldptr);
+       cprintf(" ");
+       if (fieldptr != NULL) phree(fieldptr);
 
        /* message ID */
        imap_strout(msg->cm_fields['I']);