2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
5 * This file is part of mutt-ng, see http://www.muttng.org/.
6 * It's licensed under the GNU General Public License,
7 * please see the file GPL in the top level source directory.
15 #include "mutt_curses.h"
16 #include "mutt_menu.h"
22 #include "imap_private.h"
27 void _mutt_set_flag (CONTEXT * ctx, HEADER * h, int flag, int bf, int upd_ctx)
29 int changed = h->changed;
30 int deleted = ctx->deleted;
31 int tagged = ctx->tagged;
33 if (ctx->readonly && flag != M_TAG)
34 return; /* don't modify anything if we are read-only */
39 if (!mx_acl_check (ctx, ACL_DELETE))
43 if (!h->deleted && !ctx->readonly) {
48 /* deleted messages aren't treated as changed elsewhere so that the
49 * purge-on-sync option works correctly. This isn't applicable here */
50 if (ctx && ctx->magic == M_IMAP) {
58 else if (h->deleted) {
65 h->appended = 0; /* when undeleting, also reset the appended flag */
67 /* see my comment above */
68 if (ctx->magic == M_IMAP) {
75 * If the user undeletes a message which is marked as
76 * "trash" in the maildir folder on disk, the folder has
77 * been changed, and is marked accordingly. However, we do
78 * _not_ mark the message itself changed, because trashing
79 * is checked in specific code in the maildir folder
82 if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
108 if (!mx_acl_check (ctx, ACL_SEEN))
112 if (h->read || h->old) {
141 if (!mx_acl_check (ctx, ACL_SEEN))
168 if (!mx_acl_check (ctx, ACL_SEEN))
199 if (!mx_acl_check (ctx, ACL_WRITE))
218 else if (h->replied) {
228 if (!mx_acl_check (ctx, ACL_WRITE))
241 else if (h->flagged) {
259 else if (h->tagged) {
267 mutt_set_header_color (ctx, h);
269 /* if the message status has changed, we need to invalidate the cached
270 * search results so that any future search will match the current status
271 * of this message and not what it was at the time it was last searched.
274 && (changed != h->changed || deleted != ctx->deleted
275 || tagged != ctx->tagged))
280 void mutt_tag_set_flag (int flag, int bf)
284 for (j = 0; j < Context->vcount; j++)
285 if (Context->hdrs[Context->v2r[j]]->tagged)
286 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], flag, bf);
288 int mutt_thread_set_flag (HEADER * hdr, int flag, int bf, int subthread)
290 THREAD *start, *cur = hdr->thread;
292 if ((Sort & SORT_MASK) != SORT_THREADS) {
293 mutt_error _("Threading is not enabled.");
304 mutt_set_flag (Context, cur->message, flag, bf);
306 if ((cur = cur->child) == NULL)
311 mutt_set_flag (Context, cur->message, flag, bf);
329 int mutt_change_flag (HEADER * h, int bf)
334 mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
335 bf ? _("Set flag") : _("Clear flag"));
338 event = mutt_getch ();
341 CLEARLINE (LINES - 1);
345 CLEARLINE (LINES - 1);
361 mutt_set_flag (Context, h, M_READ, !bf);
363 mutt_tag_set_flag (M_READ, !bf);
386 mutt_set_flag (Context, h, flag, bf);
388 mutt_tag_set_flag (flag, bf);