#include "imap_fetch.h"
+/*
+ * imap_do_fetch() calls imap_do_fetch_msg() to output the deta of an
+ * individual message, once it has been successfully loaded from disk.
+ */
+void imap_do_fetch_msg(int seq, struct CtdlMessage *msg,
+ int num_items, char **itemlist) {
+
+ cprintf("* %d FETCH ", seq);
+ /* FIXME obviously we must do something here */
+ cprintf("\r\n");
+}
+
+
/*
- * Back end function.
+ * imap_fetch() calls imap_do_fetch() to do its actual work, once it's
+ * validated and boiled down the request a bit.
*/
void imap_do_fetch(int lo, int hi, int num_items, char **itemlist) {
int i;
+ struct CtdlMessage *msg;
- cprintf("* imap_do_fetch() lo=%d hi=%d num_items=%d\r\n",
- lo, hi, num_items);
-
- for (i=0; i<num_items; ++i) {
+ /*for (i=0; i<num_items; ++i) {
cprintf("* item[%d] = <%s>\r\n", i, itemlist[i]);
+ }*/
+
+ for (i = lo; i <= hi; ++i) {
+ msg = CtdlFetchMessage(IMAP->msgids[i-1]);
+ if (msg != NULL) {
+ imap_do_fetch_msg(i, msg, num_items, itemlist);
+ CtdlFreeMessage(msg);
+ }
+ else {
+ cprintf("* %d FETCH <internal error>\r\n", i);
+ }
}
}
-
-
/*
* Break out the data items requested, possibly a parenthesized list.
* Returns the number of data items, or -1 if the list is invalid.