]> granicus.if.org Git - mutt/commitdiff
Real support for the Old flag on IMAP.
authorBrendan Cully <brendan@kublai.com>
Mon, 19 Dec 2005 17:15:12 +0000 (17:15 +0000)
committerBrendan Cully <brendan@kublai.com>
Mon, 19 Dec 2005 17:15:12 +0000 (17:15 +0000)
imap/auth_sasl.c
imap/browse.c
imap/imap.c
imap/imap_private.h
imap/message.c
imap/util.c
mx.c

index 6e0557c50e6d0c3d8b5166b0b987e52506835c6c..f3d2038921317ec9f2599fbb580cdb259fe80112 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2000-3 Brendan Cully <brendan@kublai.com>
+ * Copyright (C) 2000-5 Brendan Cully <brendan@kublai.com>
  * 
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
index 5e8b3820026cec95b02238e18f2404dcae785ad2..ab17be5038ea7d495676514b284c0f89f189e844 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1996-9 Brandon Long <blong@fiction.net>
- * Copyright (C) 1999-2002 Brendan Cully <brendan@kublai.com>
+ * Copyright (C) 1999-2005 Brendan Cully <brendan@kublai.com>
  * 
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
index fe2d7c118f313b19f5581b5362792586e722af7b..98e56147aed33e18924016d7b2d4c1cefc9bf8fc 100644 (file)
@@ -846,10 +846,32 @@ static void imap_set_flag (IMAP_DATA* idata, int aclbit, int flag,
   const char *str, char *flags, size_t flsize)
 {
   if (mutt_bit_isset (idata->rights, aclbit))
-    if (flag)
+    if (flag && imap_has_flag (idata->flags, str))
       safe_strcat (flags, flsize, str);
 }
 
+/* imap_has_flag: do a caseless comparison of the flag against a flag list,
+*   return 1 if found or flag list has '\*', 0 otherwise */
+int imap_has_flag (LIST* flag_list, const char* flag)
+{
+  if (!flag_list)
+    return 0;
+  
+  flag_list = flag_list->next;
+  while (flag_list)
+  {
+    if (!ascii_strncasecmp (flag_list->data, flag, strlen (flag_list->data)))
+      return 1;
+    
+    if (!ascii_strncmp (flag_list->data, "\\*", strlen (flag_list->data)))
+      return 1;
+    
+    flag_list = flag_list->next;
+  }
+  
+  return 0;
+}
+
 /* imap_make_msg_set: make an IMAP4rev1 UID message set out of a set of
  *   headers, given a flag enum to filter on.
  * Params: idata: IMAP_DATA containing context containing header set
@@ -949,6 +971,8 @@ int imap_sync_message (IMAP_DATA *idata, HEADER *hdr, BUFFER *cmd,
       
   imap_set_flag (idata, IMAP_ACL_SEEN, hdr->read, "\\Seen ",
                 flags, sizeof (flags));
+  imap_set_flag (idata, IMAP_ACL_WRITE, hdr->old,
+                 "Old ", flags, sizeof (flags));
   imap_set_flag (idata, IMAP_ACL_WRITE, hdr->flagged,
                 "\\Flagged ", flags, sizeof (flags));
   imap_set_flag (idata, IMAP_ACL_WRITE, hdr->replied,
@@ -967,6 +991,7 @@ int imap_sync_message (IMAP_DATA *idata, HEADER *hdr, BUFFER *cmd,
   if (!*flags)
   {
     imap_set_flag (idata, IMAP_ACL_SEEN, 1, "\\Seen ", flags, sizeof (flags));
+    imap_set_flag (idata, IMAP_ACL_WRITE, 1, "Old ", flags, sizeof (flags));
     imap_set_flag (idata, IMAP_ACL_WRITE, 1, "\\Flagged ", flags, sizeof (flags));
     imap_set_flag (idata, IMAP_ACL_WRITE, 1, "\\Answered ", flags, sizeof (flags));
     imap_set_flag (idata, IMAP_ACL_DELETE, 1, "\\Deleted ", flags, sizeof (flags));
index 07be8096800b3935da4d2ccf6bcdd13f0c7482d3..35b6521c5653f560eadfbbf130737e5042f18453 100644 (file)
@@ -244,6 +244,7 @@ void imap_expunge_mailbox (IMAP_DATA* idata);
 void imap_logout (IMAP_DATA* idata);
 int imap_sync_message (IMAP_DATA *idata, HEADER *hdr, BUFFER *cmd,
   int *err_continue);
+int imap_has_flag (LIST* flag_list, const char* flag);
 
 /* auth.c */
 int imap_authenticate (IMAP_DATA* idata);
index f0323bf0941dc0a13232613505b8084eed2b0a00..40c35c71cf7e4cf9662c993127b0c346be803661 100644 (file)
@@ -39,7 +39,6 @@
 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);
-static int msg_has_flag (LIST* flag_list, const char* flag);
 static int msg_parse_fetch (IMAP_HEADER* h, char* s);
 static char* msg_parse_flags (IMAP_HEADER* h, char* s);
 
@@ -815,7 +814,7 @@ void imap_add_keywords (char* s, HEADER* h, LIST* mailbox_flags, size_t slen)
 
   while (keywords)
   {
-    if (msg_has_flag (mailbox_flags, keywords->data))
+    if (imap_has_flag (mailbox_flags, keywords->data))
     {
       safe_strcat (s, slen, keywords->data);
       safe_strcat (s, slen, " ");
@@ -987,26 +986,6 @@ static int msg_fetch_header_fetch (CONTEXT* ctx, IMAP_HEADER* h, char* buf, FILE
 }
 #endif /* USE_HCACHE */
 
-
-/* msg_has_flag: do a caseless comparison of the flag against a flag list,
- *   return 1 if found or flag list has '\*', 0 otherwise */
-static int msg_has_flag (LIST* flag_list, const char* flag)
-{
-  if (!flag_list)
-    return 0;
-
-  flag_list = flag_list->next;
-  while (flag_list)
-  {
-    if (!ascii_strncasecmp (flag_list->data, flag, strlen (flag_list->data)))
-      return 1;
-
-    flag_list = flag_list->next;
-  }
-
-  return 0;
-}
-
 /* msg_parse_fetch: handle headers returned from header fetch */
 static int msg_parse_fetch (IMAP_HEADER *h, char *s)
 {
@@ -1131,6 +1110,11 @@ static char* msg_parse_flags (IMAP_HEADER* h, char* s)
       s += 7;
       recent = 1;
     }
+    else if (ascii_strncasecmp ("old", s, 3) == 0)
+    {
+      s += 3;
+      h->old = 1;
+    }
     else
     {
       /* store custom flags as well */
@@ -1153,9 +1137,6 @@ static char* msg_parse_flags (IMAP_HEADER* h, char* s)
   /* wrap up, or note bad flags response */
   if (*s == ')')
   {
-    /* if a message is neither seen nor recent, it is OLD. */
-    if (option (OPTMARKOLD) && !recent && !(h->read))
-      h->old = 1;
     s++;
   }
   else
index 1814ac327519bc94529b38e564d6b21584259e01..da42d2f4d3b97c4d250d865fe6d7f224593cb6f1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 1996-8 Michael R. Elkins <me@mutt.org>
  * Copyright (C) 1996-9 Brandon Long <blong@fiction.net>
- * Copyright (C) 1999-2002 Brendan Cully <brendan@kublai.com>
+ * Copyright (C) 1999-2005 Brendan Cully <brendan@kublai.com>
  * 
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
diff --git a/mx.c b/mx.c
index 473c927ddef24c7dbce428e2d45d56d0d8482f69..bb7566e0299bcf860c6dbbe76442faba72e3ebfa 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -900,10 +900,6 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
     }
   }
 
-#ifdef USE_IMAP
-  /* IMAP servers manage the OLD flag themselves */
-  if (ctx->magic != M_IMAP)
-#endif
   if (option (OPTMARKOLD))
   {
     for (i = 0; i < ctx->msgcount; i++)