Commit 0517ca03 0517ca033b3222afc09f5b70626c38280c749c14 by Paul Vojta Committed by Sergey Poznyakoff

Fix the way mail accounts for the status of messages.

* mail/mail.h (MAIL_ATTRIBUTE_PRESERVED)
(MAIL_ATTRIBUTE_TOUCHED): New define.
* mail/from.c (mail_from0): Mark with 'R' only those messages that
have been read in this mail session.
* mail/hold.c (hold0): Set MAIL_ATTRIBUTE_PRESERVED
* mail/mbox.c (mbox0): Don't mark message as read.
* mail/quit.c (mail_mbox_commit): Force keepsave on
not system mailboxes.
* mail/touch.c: Use MAIL_ATTRIBUTE_TOUCHED
* mail/undelete.c: Clear MAIL_ATTRIBUTE_PRESERVED and
MAIL_ATTRIBUTE_MBOXED bits.
* mail/testsuite/mail/write.exp: Account for the above changes.
1 parent 1184b4a5
...@@ -98,16 +98,18 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data) ...@@ -98,16 +98,18 @@ mail_from0 (msgset_t *mspec, mu_message_t msg, void *data)
98 98
99 if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_MBOXED)) 99 if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_MBOXED))
100 cflag = 'M'; 100 cflag = 'M';
101 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED))
102 cflag = 'P';
101 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED)) 103 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED))
102 cflag = '*'; 104 cflag = '*';
103 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_TAGGED)) 105 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_TAGGED))
104 cflag = 'T'; 106 cflag = 'T';
105 else if (mu_attribute_is_read (attr)) 107 else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SHOWN))
106 cflag = 'R'; 108 cflag = 'R';
107 else if (mu_attribute_is_seen (attr))
108 cflag = 'U';
109 else if (mu_attribute_is_recent (attr)) 109 else if (mu_attribute_is_recent (attr))
110 cflag = 'N'; 110 cflag = 'N';
111 else if (!mu_attribute_is_read (attr))
112 cflag = 'U';
111 else 113 else
112 cflag = ' '; 114 cflag = ' ';
113 115
......
...@@ -30,6 +30,7 @@ hold0 (msgset_t *mspec, mu_message_t msg, void *data) ...@@ -30,6 +30,7 @@ hold0 (msgset_t *mspec, mu_message_t msg, void *data)
30 30
31 mu_message_get_attribute (msg, &attr); 31 mu_message_get_attribute (msg, &attr);
32 mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED); 32 mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
33 mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_PRESERVED);
33 34
34 set_cursor (mspec->msg_part[0]); 35 set_cursor (mspec->msg_part[0]);
35 36
......
...@@ -427,9 +427,11 @@ extern char *readline (char *prompt); ...@@ -427,9 +427,11 @@ extern char *readline (char *prompt);
427 427
428 /* Message attributes */ 428 /* Message attributes */
429 #define MAIL_ATTRIBUTE_MBOXED 0x0001 429 #define MAIL_ATTRIBUTE_MBOXED 0x0001
430 #define MAIL_ATTRIBUTE_SAVED 0x0002 430 #define MAIL_ATTRIBUTE_PRESERVED 0x0002
431 #define MAIL_ATTRIBUTE_TAGGED 0x0004 431 #define MAIL_ATTRIBUTE_SAVED 0x0004
432 #define MAIL_ATTRIBUTE_SHOWN 0x0008 432 #define MAIL_ATTRIBUTE_TAGGED 0x0008
433 #define MAIL_ATTRIBUTE_SHOWN 0x0010
434 #define MAIL_ATTRIBUTE_TOUCHED 0x0020
433 435
434 extern void ml_attempted_completion_over (void); 436 extern void ml_attempted_completion_over (void);
435 437
......
...@@ -28,8 +28,8 @@ mbox0 (msgset_t *mspec, mu_message_t msg, void *data) ...@@ -28,8 +28,8 @@ mbox0 (msgset_t *mspec, mu_message_t msg, void *data)
28 mu_attribute_t attr; 28 mu_attribute_t attr;
29 29
30 mu_message_get_attribute (msg, &attr); 30 mu_message_get_attribute (msg, &attr);
31 mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_PRESERVED);
31 mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED); 32 mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
32 util_mark_read (msg);
33 33
34 set_cursor (mspec->msg_part[0]); 34 set_cursor (mspec->msg_part[0]);
35 35
......
...@@ -87,6 +87,7 @@ mail_mbox_commit () ...@@ -87,6 +87,7 @@ mail_mbox_commit ()
87 /* The mailbox we are closing is not a system one (%). Raise 87 /* The mailbox we are closing is not a system one (%). Raise
88 hold flag */ 88 hold flag */
89 hold = 1; 89 hold = 1;
90 keepsave = 1;
90 } 91 }
91 mu_mailbox_destroy (&mb); 92 mu_mailbox_destroy (&mb);
92 } 93 }
...@@ -102,7 +103,12 @@ mail_mbox_commit () ...@@ -102,7 +103,12 @@ mail_mbox_commit ()
102 && (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_MBOXED) 103 && (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_MBOXED)
103 || (!hold 104 || (!hold
104 && !mu_attribute_is_deleted (attr) 105 && !mu_attribute_is_deleted (attr)
105 && mu_attribute_is_read (attr)))) 106 && !mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED)
107 && ((mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED)
108 && keepsave)
109 || (!mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED)
110 && (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SHOWN)
111 || mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_TOUCHED)))))))
106 { 112 {
107 int status; 113 int status;
108 114
...@@ -136,7 +142,9 @@ mail_mbox_commit () ...@@ -136,7 +142,9 @@ mail_mbox_commit ()
136 } 142 }
137 else if (mu_attribute_is_deleted (attr)) 143 else if (mu_attribute_is_deleted (attr))
138 /* Skip this one */; 144 /* Skip this one */;
139 else if (!keepsave && mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED)) 145 else if (!keepsave
146 && !mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED)
147 && mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED))
140 mu_attribute_set_deleted (attr); 148 mu_attribute_set_deleted (attr);
141 else if (mu_attribute_is_read (attr)) 149 else if (mu_attribute_is_read (attr))
142 mu_attribute_set_seen (attr); 150 mu_attribute_set_seen (attr);
......
1 # -*- tcl -*- 1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite. 2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007 Free Software Foundation 3 # Copyright (C) 2002, 2007, 2009 Free Software Foundation
4 # 4 #
5 # This program is free software; you can redistribute it and/or modify 5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by 6 # it under the terms of the GNU General Public License as published by
...@@ -74,7 +74,7 @@ mail_test "headers" \ ...@@ -74,7 +74,7 @@ mail_test "headers" \
74 " * 2 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky" 74 " * 2 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky"
75 75
76 mail_test -noprompt "quit" \ 76 mail_test -noprompt "quit" \
77 "Held 0 messages in $MU_SPOOL_DIR/mbox" 77 "Held 2 messages in $MU_SPOOL_DIR/mbox"
78 78
79 # Examine its contents 79 # Examine its contents
80 mail_start -reuse-spool "--file=$MU_FOLDER_DIR/three" 80 mail_start -reuse-spool "--file=$MU_FOLDER_DIR/three"
...@@ -88,7 +88,7 @@ mail_test "Save" \ ...@@ -88,7 +88,7 @@ mail_test "Save" \
88 "\"$MU_FOLDER_DIR/gray\" 12/425" 88 "\"$MU_FOLDER_DIR/gray\" 12/425"
89 89
90 mail_test "file \"$MU_FOLDER_DIR/gray\"" \ 90 mail_test "file \"$MU_FOLDER_DIR/gray\"" \
91 "Held 1 message in $MU_FOLDER_DIR/three" 91 "Held 2 messages in $MU_FOLDER_DIR/three"
92 92
93 mail_test "headers" \ 93 mail_test "headers" \
94 ">N 1 Sergey Poznyakoff Tue Jul 16 12:11 12/425 MBOX" 94 ">N 1 Sergey Poznyakoff Tue Jul 16 12:11 12/425 MBOX"
......
...@@ -30,11 +30,7 @@ touch0 (msgset_t *mspec, mu_message_t msg, void *data) ...@@ -30,11 +30,7 @@ touch0 (msgset_t *mspec, mu_message_t msg, void *data)
30 mu_attribute_t attr = NULL; 30 mu_attribute_t attr = NULL;
31 31
32 mu_message_get_attribute (msg, &attr); 32 mu_message_get_attribute (msg, &attr);
33 if (!mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED)) 33 mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_TOUCHED);
34 {
35 mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
36 util_mark_read (msg);
37 }
38 34
39 set_cursor (mspec->msg_part[0]); 35 set_cursor (mspec->msg_part[0]);
40 return 0; 36 return 0;
......
...@@ -29,6 +29,8 @@ undelete0 (msgset_t *mspec, mu_message_t msg, void *data) ...@@ -29,6 +29,8 @@ undelete0 (msgset_t *mspec, mu_message_t msg, void *data)
29 29
30 mu_message_get_attribute (msg, &attr); 30 mu_message_get_attribute (msg, &attr);
31 mu_attribute_unset_deleted (attr); 31 mu_attribute_unset_deleted (attr);
32 mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_PRESERVED);
33 mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
32 util_mark_read (msg); 34 util_mark_read (msg);
33 cond_page_invalidate (mspec->msg_part[0]); 35 cond_page_invalidate (mspec->msg_part[0]);
34 36
......