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)
if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_MBOXED))
cflag = 'M';
else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED))
cflag = 'P';
else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED))
cflag = '*';
else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_TAGGED))
cflag = 'T';
else if (mu_attribute_is_read (attr))
else if (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SHOWN))
cflag = 'R';
else if (mu_attribute_is_seen (attr))
cflag = 'U';
else if (mu_attribute_is_recent (attr))
cflag = 'N';
else if (!mu_attribute_is_read (attr))
cflag = 'U';
else
cflag = ' ';
......
......@@ -30,6 +30,7 @@ hold0 (msgset_t *mspec, mu_message_t msg, void *data)
mu_message_get_attribute (msg, &attr);
mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_PRESERVED);
set_cursor (mspec->msg_part[0]);
......
......@@ -427,9 +427,11 @@ extern char *readline (char *prompt);
/* Message attributes */
#define MAIL_ATTRIBUTE_MBOXED 0x0001
#define MAIL_ATTRIBUTE_SAVED 0x0002
#define MAIL_ATTRIBUTE_TAGGED 0x0004
#define MAIL_ATTRIBUTE_SHOWN 0x0008
#define MAIL_ATTRIBUTE_PRESERVED 0x0002
#define MAIL_ATTRIBUTE_SAVED 0x0004
#define MAIL_ATTRIBUTE_TAGGED 0x0008
#define MAIL_ATTRIBUTE_SHOWN 0x0010
#define MAIL_ATTRIBUTE_TOUCHED 0x0020
extern void ml_attempted_completion_over (void);
......
......@@ -28,8 +28,8 @@ mbox0 (msgset_t *mspec, mu_message_t msg, void *data)
mu_attribute_t attr;
mu_message_get_attribute (msg, &attr);
mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_PRESERVED);
mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
util_mark_read (msg);
set_cursor (mspec->msg_part[0]);
......
......@@ -87,6 +87,7 @@ mail_mbox_commit ()
/* The mailbox we are closing is not a system one (%). Raise
hold flag */
hold = 1;
keepsave = 1;
}
mu_mailbox_destroy (&mb);
}
......@@ -102,7 +103,12 @@ mail_mbox_commit ()
&& (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_MBOXED)
|| (!hold
&& !mu_attribute_is_deleted (attr)
&& mu_attribute_is_read (attr))))
&& !mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED)
&& ((mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED)
&& keepsave)
|| (!mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED)
&& (mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SHOWN)
|| mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_TOUCHED)))))))
{
int status;
......@@ -136,7 +142,9 @@ mail_mbox_commit ()
}
else if (mu_attribute_is_deleted (attr))
/* Skip this one */;
else if (!keepsave && mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED))
else if (!keepsave
&& !mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_PRESERVED)
&& mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED))
mu_attribute_set_deleted (attr);
else if (mu_attribute_is_read (attr))
mu_attribute_set_seen (attr);
......
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007 Free Software Foundation
# Copyright (C) 2002, 2007, 2009 Free Software Foundation
#
# 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
......@@ -74,7 +74,7 @@ mail_test "headers" \
" * 2 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky"
mail_test -noprompt "quit" \
"Held 0 messages in $MU_SPOOL_DIR/mbox"
"Held 2 messages in $MU_SPOOL_DIR/mbox"
# Examine its contents
mail_start -reuse-spool "--file=$MU_FOLDER_DIR/three"
......@@ -88,7 +88,7 @@ mail_test "Save" \
"\"$MU_FOLDER_DIR/gray\" 12/425"
mail_test "file \"$MU_FOLDER_DIR/gray\"" \
"Held 1 message in $MU_FOLDER_DIR/three"
"Held 2 messages in $MU_FOLDER_DIR/three"
mail_test "headers" \
">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)
mu_attribute_t attr = NULL;
mu_message_get_attribute (msg, &attr);
if (!mu_attribute_is_userflag (attr, MAIL_ATTRIBUTE_SAVED))
{
mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
util_mark_read (msg);
}
mu_attribute_set_userflag (attr, MAIL_ATTRIBUTE_TOUCHED);
set_cursor (mspec->msg_part[0]);
return 0;
......
......@@ -29,6 +29,8 @@ undelete0 (msgset_t *mspec, mu_message_t msg, void *data)
mu_message_get_attribute (msg, &attr);
mu_attribute_unset_deleted (attr);
mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_PRESERVED);
mu_attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
util_mark_read (msg);
cond_page_invalidate (mspec->msg_part[0]);
......