FILE *output_fp;
};
+
+
+/*
+ * Output the flags associated with a message. Note that this function
+ * expects an index number in the array, *not* a sequence or uid number.
+ */
+void imap_output_flags(int num) {
+ cprintf("FLAGS (");
+ if (IMAP->flags[num] & IMAP_DELETED) cprintf("\\Deleted ");
+ cprintf(")");
+}
+
+
+
/*
* Individual field functions for imap_do_fetch_msg() ...
*/
cprintf("UID %ld", IMAP->msgids[seq-1]);
}
-void imap_fetch_flags(struct CtdlMessage *msg) {
- cprintf("FLAGS ()"); /* FIXME do something here */
-}
-
void imap_fetch_internaldate(struct CtdlMessage *msg) {
char buf[SIZ];
time_t msgdate;
imap_fetch_envelope(IMAP->msgids[seq-1], msg);
}
else if (!strcasecmp(itemlist[i], "FLAGS")) {
- imap_fetch_flags(msg);
+ imap_output_flags(seq-1);
}
else if (!strcasecmp(itemlist[i], "INTERNALDATE")) {
imap_fetch_internaldate(msg);
#include "genstamp.h"
-
-
-
-
/*
* imap_do_store() calls imap_do_store_msg() to output the deta of an
* individual message, once it has been successfully loaded from disk.
*/
void imap_do_store_msg(int num, int num_items, char **itemlist) {
int i;
+ int flagbucket = 0;
+
+ /* at this point it should be down to "item (flags)" */
+ if (num_items < 2) return;
+
+ /* put together the flag bucket */
+ for (i=0; i<strlen(itemlist[1]); ++i) {
+ if (!strncasecmp(&itemlist[1][i], "\\Deleted", 8))
+ flagbucket |= IMAP_DELETED;
+ }
+
+ /*
+ * Figure out what to do and do it. Brazenly IGnore the ".SILENT"
+ * option, since it is not illegal to output the data anyway.
+ */
+ if (!strncasecmp(itemlist[0], "FLAGS", 5)) {
+ IMAP->flags[num] &= IMAP_INTERNAL_MASK;
+ IMAP->flags[num] |= flagbucket;
+ }
+
+ if (!strncasecmp(itemlist[0], "+FLAGS", 6)) {
+ IMAP->flags[num] |= flagbucket;
+ }
+
+ if (!strncasecmp(itemlist[0], "-FLAGS", 6)) {
+ IMAP->flags[num] &= ~flagbucket;
+ }
- cprintf("* <%d> ", num);
- for (i=0; i<num_items; ++i) cprintf("<%s> ", itemlist[i]);
+ /*
+ * Tell the client what happen (someone set up us the bomb!)
+ */
+ cprintf("* %d FETCH ", num+1); /* output sequence number */
+ imap_output_flags(num);
cprintf("\r\n");
}
if (IMAP->flags[i] && IMAP_SELECTED) {
imap_do_store_msg(i, num_items, itemlist);
}
- else {
- lprintf(1, "IMAP STORE internal error\n");
- }
}
}
}
return;
}
- if (imap_is_message_set(parms[2])) {
- imap_pick_range(parms[2], 0);
+ if (imap_is_message_set(parms[3])) {
+ imap_pick_range(parms[3], 1);
}
else {
cprintf("%s BAD No message set specified to STORE\r\n",
cprintf("* %d EXISTS\r\n", msgs);
cprintf("* %d RECENT\r\n", new);
cprintf("* OK [UIDVALIDITY 0] UIDs valid\r\n");
+ cprintf("* FLAGS (\\Deleted)\r\n");
cprintf("%s OK [%s] %s completed\r\n",
parms[0],
(IMAP->readonly ? "READ-ONLY" : "READ-WRITE"),