]> code.citadel.org Git - citadel.git/commitdiff
* Wrote a bit of the IMAP STORE command
authorArt Cancro <ajc@citadel.org>
Sat, 24 Feb 2001 06:06:28 +0000 (06:06 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 24 Feb 2001 06:06:28 +0000 (06:06 +0000)
citadel/ChangeLog
citadel/imap_fetch.c
citadel/imap_fetch.h
citadel/imap_store.c
citadel/serv_imap.c
citadel/serv_imap.h

index a17f67b61cde98d7f47807e7fe53c1ad86cdc59d..8122a266f852f43cc3c8a246dc3ca2043a2042ac 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 573.99  2001/02/24 06:06:28  ajc
+ * Wrote a bit of the IMAP STORE command
+
  Revision 573.98  2001/02/24 04:43:13  brian
  * Fixed my listing in developers.txt (finally!  :)
 
@@ -2468,4 +2471,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index 9355a8d2b9494c325ab2829cda111fca5b3a8cac..f31ed7eb0aa3afecee4d4f0b1442ae8829d6b01a 100644 (file)
@@ -49,6 +49,20 @@ struct imap_fetch_part {
        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() ...
  */
@@ -59,10 +73,6 @@ void imap_fetch_uid(int seq) {
        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;
@@ -633,7 +643,7 @@ void imap_do_fetch_msg(int seq, struct CtdlMessage *msg,
                        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);
index b3f80dfc91d7c3eef12993df4177b170229875f7..fdc2a6a8c0bf0f31840ab77565053aa7f62cae98 100644 (file)
@@ -7,3 +7,4 @@ void imap_pick_range(char *range, int is_uid);
 void imap_fetch(int num_parms, char *parms[]);
 void imap_uidfetch(int num_parms, char *parms[]);
 int imap_extract_data_items(char **argv, char *items);
+void imap_output_flags(int num);
index 800af909966a4aaa04b49bbe9c8a244b5d1410bd..dade924ba41f365b6eaa6a272bc494d44fb040ad 100644 (file)
 #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");
 }
 
@@ -72,9 +98,6 @@ void imap_do_store(int num_items, char **itemlist, int is_uid) {
                        if (IMAP->flags[i] && IMAP_SELECTED) {
                                imap_do_store_msg(i, num_items, itemlist);
                        }
-               else {
-                       lprintf(1, "IMAP STORE internal error\n");
-                       }
                }
        }
 }
@@ -133,8 +156,8 @@ void imap_uidstore(int num_parms, char *parms[]) {
                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",
index ff90b82d3ab051002ebd7b7cc5e0b467ffb047c0..bf241aa903c0b78e22e55d91c9d695ae50641cdd 100644 (file)
@@ -365,6 +365,7 @@ void imap_select(int num_parms, char *parms[]) {
        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"),
index 6899c04d47b52fe2374aafe9cc34b4651ef4d132..21b33ce00feb8908ec4aedf28775dd69c5b375e2 100644 (file)
@@ -36,6 +36,10 @@ enum {
 #define IMAP_DELETED   4
 #define IMAP_DRAFT     8
 #define IMAP_SEEN      16
+
+#define IMAP_SETABLE_MASK      0x1f
+#define IMAP_INTERNAL_MASK     (~IMAP_SETABLE_MASK)
+
 #define IMAP_SELECTED  32      /* internal */
 #define IMAP_EXPUNGED  64      /* internal */