]> code.citadel.org Git - citadel.git/commitdiff
* Started working on part fetches
authorArt Cancro <ajc@citadel.org>
Thu, 2 Nov 2000 20:20:45 +0000 (20:20 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 2 Nov 2000 20:20:45 +0000 (20:20 +0000)
citadel/imap_fetch.c
citadel/serv_imap.h

index 627849e1bac76c72448c6ec7f974aa1b03a093e2..9f4a242c83852911c84240302d054ed659a087dc 100644 (file)
@@ -36,6 +36,7 @@
 #include "msgbase.h"
 #include "tools.h"
 #include "internet_addressing.h"
+#include "mime_parser.h"
 #include "serv_imap.h"
 #include "imap_tools.h"
 #include "imap_fetch.h"
@@ -154,10 +155,29 @@ void imap_fetch_rfc822(int msgnum, char *whichfmt) {
 }
 
 
+
+/*
+ * FIXME this is TOTALLY BROKEN!!!
+ */
+void imap_fetch_part(char *name, char *filename, char *partnum, char *disp,
+                   void *content, char *cbtype, size_t length)
+{
+
+       if (!strcasecmp(partnum, IMAP->desired_part)) {
+               cprintf("part=%s|%s|%s|%s|%s|%d\r\n",
+                       name, filename, partnum, disp, cbtype, length);
+       }
+}
+
+
+
+
+
 /*
  * Implements the BODY and BODY.PEEK fetch items
  */
-void imap_fetch_body(long msgnum, char *item, int is_peek) {
+void imap_fetch_body(long msgnum, char *item, int is_peek,
+               struct CtdlMessage *msg) {
        char section[1024];
        char partial[1024];
        int is_partial = 0;
@@ -216,6 +236,15 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) {
                fprintf(tmp, "\r\n");   /* add the trailing newline */
        }
 
+       /*
+        * Anything else must be a part specifier.
+        */
+       else {
+               safestrncpy(IMAP->desired_part, section,
+                               sizeof(IMAP->desired_part));
+               mime_parser(msg->cm_fields['M'], NULL, *imap_fetch_part);
+       }
+
 
        fseek(tmp, 0L, SEEK_END);
        bytes_remaining = ftell(tmp);
@@ -265,10 +294,10 @@ void imap_do_fetch_msg(int seq, struct CtdlMessage *msg,
        for (i=0; i<num_items; ++i) {
 
                if (!strncasecmp(itemlist[i], "BODY[", 5)) {
-                       imap_fetch_body(IMAP->msgids[seq-1], itemlist[i], 0);
+                       imap_fetch_body(IMAP->msgids[seq-1], itemlist[i], 0, msg);
                }
                else if (!strncasecmp(itemlist[i], "BODY.PEEK[", 10)) {
-                       imap_fetch_body(IMAP->msgids[seq-1], itemlist[i], 1);
+                       imap_fetch_body(IMAP->msgids[seq-1], itemlist[i], 1, msg);
                }
                else if (!strcasecmp(itemlist[i], "BODYSTRUCTURE")) {
                        /* FIXME do something here */
index 217b62f6f9ccd05a522071d7e6d918f249b7465d..74769536c298d7f93681b32bfede4852ee5050d3 100644 (file)
@@ -17,6 +17,7 @@ struct citimap {
        int num_msgs;           /* Number of messages being mapped */
        long *msgids;
        unsigned int *flags;
+       char desired_part[256]; /* for part fetches */
 };
 
 /*