Moved to new module init structure.
[citadel.git] / citadel / imap_fetch.c
index 5dc32135983dc5c1cbfd05286834682b440ba788..66d5b44addce658164315f1c2e25e011b42760c0 100644 (file)
@@ -38,7 +38,6 @@
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
-#include "serv_extensions.h"
 #include "room_ops.h"
 #include "user_ops.h"
 #include "policy.h"
@@ -176,7 +175,7 @@ void imap_fetch_rfc822(long msgnum, char *whichfmt) {
                CC->redirect_alloc = SIZ;
                CtdlOutputMsg(msgnum, MT_RFC822,
                        (need_body ? HEADERS_ALL : HEADERS_ONLY),
-                       0, 1);
+                       0, 1, NULL);
                if (!need_body) cprintf("\r\n");        /* extra trailing newline */
                IMAP->cached_rfc822_data = CC->redirect_buffer;
                IMAP->cached_rfc822_len = CC->redirect_len;
@@ -252,8 +251,7 @@ void imap_fetch_rfc822(long msgnum, char *whichfmt) {
 /*
  * Load a specific part of a message into the temp file to be output to a
  * client.  FIXME we can handle parts like "2" and "2.1" and even "2.MIME"
- * but we still can't handle "2.HEADER" (which might not be a problem, because
- * we currently don't have the ability to break out nested RFC822's anyway).
+ * but we still can't handle "2.HEADER" (which might not be a problem).
  *
  * Note: mime_parser() was called with dont_decode set to 1, so we have the
  * luxury of simply spewing without having to re-encode.
@@ -875,6 +873,14 @@ void imap_fetch_bodystructure (long msgnum, char *item,
        char buf[SIZ];
        int lines = 0;
 
+       /* Handle NULL message gracefully */
+       if (msg == NULL) {
+               cprintf("BODYSTRUCTURE (\"TEXT\" \"PLAIN\" "
+                       "(\"CHARSET\" \"US-ASCII\") NIL NIL "
+                       "\"7BIT\" 0 0)");
+               return;
+       }
+
        /* For non-RFC822 (ordinary Citadel) messages, this is short and
         * sweet...
         */
@@ -1025,6 +1031,15 @@ void imap_do_fetch(int num_items, char **itemlist) {
 
        if (IMAP->num_msgs > 0) {
                for (i = 0; i < IMAP->num_msgs; ++i) {
+
+                       /* Abort the fetch loop if the session breaks.
+                        * This is important for users who keep mailboxes
+                        * that are too big *and* are too impatient to
+                        * let them finish loading.  :)
+                        */
+                       if (CC->kill_me) return;
+
+                       /* Get any message marked for fetch. */
                        if (IMAP->flags[i] & IMAP_SELECTED) {
                                imap_do_fetch_msg(i+1, num_items, itemlist);
                        }