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;
32 int flagged = ctx->flagged;
34 if (ctx->readonly && flag != M_TAG)
35 return; /* don't modify anything if we are read-only */
40 if (!mx_acl_check (ctx, ACL_DELETE))
44 if (!h->deleted && !ctx->readonly) {
49 /* deleted messages aren't treated as changed elsewhere so that the
50 * purge-on-sync option works correctly. This isn't applicable here */
51 if (ctx && ctx->magic == M_IMAP) {
59 else if (h->deleted) {
66 h->appended = 0; /* when undeleting, also reset the appended flag */
68 /* see my comment above */
69 if (ctx->magic == M_IMAP) {
76 * If the user undeletes a message which is marked as
77 * "trash" in the maildir folder on disk, the folder has
78 * been changed, and is marked accordingly. However, we do
79 * _not_ mark the message itself changed, because trashing
80 * is checked in specific code in the maildir folder
83 if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
109 if (!mx_acl_check (ctx, ACL_SEEN))
113 if (h->read || h->old) {
142 if (!mx_acl_check (ctx, ACL_SEEN))
169 if (!mx_acl_check (ctx, ACL_SEEN))
200 if (!mx_acl_check (ctx, ACL_WRITE))
219 else if (h->replied) {
229 if (!mx_acl_check (ctx, ACL_WRITE))
242 else if (h->flagged) {
260 else if (h->tagged) {
268 mutt_set_header_color (ctx, h);
270 /* if the message status has changed, we need to invalidate the cached
271 * search results so that any future search will match the current status
272 * of this message and not what it was at the time it was last searched.
274 if (h->searched && (changed != h->changed || deleted != ctx->deleted ||
275 tagged != ctx->tagged || flagged != ctx->flagged))
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);