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.
14 #include <lib-lib/macros.h>
17 #include "mutt_curses.h"
18 #include "mutt_menu.h"
24 #include "imap_private.h"
28 void _mutt_set_flag (CONTEXT * ctx, HEADER * h, int flag, int bf, int upd_ctx)
30 int changed = h->changed;
31 int deleted = ctx->deleted;
32 int tagged = ctx->tagged;
33 int flagged = ctx->flagged;
35 if (ctx->readonly && flag != M_TAG)
36 return; /* don't modify anything if we are read-only */
41 if (!mx_acl_check (ctx, ACL_DELETE))
45 if (!h->deleted && !ctx->readonly) {
50 /* deleted messages aren't treated as changed elsewhere so that the
51 * purge-on-sync option works correctly. This isn't applicable here */
52 if (ctx && ctx->magic == M_IMAP) {
60 else if (h->deleted) {
67 h->appended = 0; /* when undeleting, also reset the appended flag */
69 /* see my comment above */
70 if (ctx->magic == M_IMAP) {
77 * If the user undeletes a message which is marked as
78 * "trash" in the maildir folder on disk, the folder has
79 * been changed, and is marked accordingly. However, we do
80 * _not_ mark the message itself changed, because trashing
81 * is checked in specific code in the maildir folder
84 if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
110 if (!mx_acl_check (ctx, ACL_SEEN))
114 if (h->read || h->old) {
143 if (!mx_acl_check (ctx, ACL_SEEN))
170 if (!mx_acl_check (ctx, ACL_SEEN))
201 if (!mx_acl_check (ctx, ACL_WRITE))
220 else if (h->replied) {
230 if (!mx_acl_check (ctx, ACL_WRITE))
243 else if (h->flagged) {
261 else if (h->tagged) {
269 mutt_set_header_color (ctx, h);
271 /* if the message status has changed, we need to invalidate the cached
272 * search results so that any future search will match the current status
273 * of this message and not what it was at the time it was last searched.
275 if (h->searched && (changed != h->changed || deleted != ctx->deleted ||
276 tagged != ctx->tagged || flagged != ctx->flagged))
281 void mutt_tag_set_flag (int flag, int bf)
285 for (j = 0; j < Context->vcount; j++)
286 if (Context->hdrs[Context->v2r[j]]->tagged)
287 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], flag, bf);
289 int mutt_thread_set_flag (HEADER * hdr, int flag, int bf, int subthread)
291 THREAD *start, *cur = hdr->thread;
293 if ((Sort & SORT_MASK) != SORT_THREADS) {
294 mutt_error _("Threading is not enabled.");
305 mutt_set_flag (Context, cur->message, flag, bf);
307 if ((cur = cur->child) == NULL)
312 mutt_set_flag (Context, cur->message, flag, bf);
330 int mutt_change_flag (HEADER * h, int bf)
335 mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
336 bf ? _("Set flag") : _("Clear flag"));
339 event = mutt_getch ();
342 CLEARLINE (LINES - 1);
346 CLEARLINE (LINES - 1);
362 mutt_set_flag (Context, h, M_READ, !bf);
364 mutt_tag_set_flag (M_READ, !bf);
387 mutt_set_flag (Context, h, flag, bf);
389 mutt_tag_set_flag (flag, bf);