Rocco Rutte:
[apps/madmutt.git] / imap / message.c
index 75089b7..e7e7a17 100644 (file)
 
 /* message parsing/updating functions */
 
-#include <stdint.h>
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <stdlib.h>
 #include <ctype.h>
 
 #include "pgp.h"
 #endif
 
+#if HAVE_STDINT_H
+#include <stdint.h>
+#elif HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
 static void flush_buffer(char* buf, size_t* len, CONNECTION* conn);
 static int msg_fetch_header (CONTEXT* ctx, IMAP_HEADER* h, char* buf,
   FILE* fp);
@@ -553,7 +562,13 @@ int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
   rewind (fp);
   
   imap_munge_mbox_name (mbox, sizeof (mbox), mailbox);
-  snprintf (buf, sizeof (buf), "APPEND %s (\\Seen) {%lu}", mbox, len);
+  snprintf (buf, sizeof (buf), "APPEND %s (%s%s%s%s%s) {%lu}", mbox,
+           msg->flags.read    ? "\\Seen"      : "",
+           msg->flags.read && (msg->flags.replied || msg->flags.flagged) ? " " : "",
+           msg->flags.replied ? "\\Answered" : "",
+           msg->flags.replied && msg->flags.flagged ? " " : "",
+           msg->flags.flagged ? "\\Flagged"  : "",
+           (unsigned long) len);
 
   imap_cmd_start (idata, buf);
 
@@ -916,7 +931,6 @@ static size_t imap_hcache_keylen (const char *fn)
 static int msg_fetch_header_fetch (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE* fp)
 {
   IMAP_DATA* idata;
-  long bytes;
   int rc = -1; /* default now is that string isn't FETCH response*/
 
   idata = (IMAP_DATA*) ctx->data;