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"
23 #include <imap/imap_private.h>
26 void _mutt_set_flag (CONTEXT * ctx, HEADER * h, int flag, int bf, int upd_ctx)
28 int changed = h->changed;
29 int deleted = ctx->deleted;
30 int tagged = ctx->tagged;
31 int flagged = ctx->flagged;
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) {
47 /* deleted messages aren't treated as changed elsewhere so that the
48 * purge-on-sync option works correctly. This isn't applicable here */
49 if (ctx && ctx->magic == M_IMAP) {
56 else if (h->deleted) {
63 h->appended = 0; /* when undeleting, also reset the appended flag */
64 /* see my comment above */
65 if (ctx->magic == M_IMAP) {
71 * If the user undeletes a message which is marked as
72 * "trash" in the maildir folder on disk, the folder has
73 * been changed, and is marked accordingly. However, we do
74 * _not_ mark the message itself changed, because trashing
75 * is checked in specific code in the maildir folder
78 if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
104 if (!mx_acl_check (ctx, ACL_SEEN))
108 if (h->read || h->old) {
137 if (!mx_acl_check (ctx, ACL_SEEN))
164 if (!mx_acl_check (ctx, ACL_SEEN))
195 if (!mx_acl_check (ctx, ACL_WRITE))
214 else if (h->replied) {
224 if (!mx_acl_check (ctx, ACL_WRITE))
237 else if (h->flagged) {
255 else if (h->tagged) {
263 mutt_set_header_color (ctx, h);
265 /* if the message status has changed, we need to invalidate the cached
266 * search results so that any future search will match the current status
267 * of this message and not what it was at the time it was last searched.
269 if (h->searched && (changed != h->changed || deleted != ctx->deleted ||
270 tagged != ctx->tagged || flagged != ctx->flagged))
275 void mutt_tag_set_flag (int flag, int bf)
279 for (j = 0; j < Context->vcount; j++)
280 if (Context->hdrs[Context->v2r[j]]->tagged)
281 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], flag, bf);
283 int mutt_thread_set_flag (HEADER * hdr, int flag, int bf, int subthread)
285 THREAD *start, *cur = hdr->thread;
287 if ((Sort & SORT_MASK) != SORT_THREADS) {
288 mutt_error _("Threading is not enabled.");
299 mutt_set_flag (Context, cur->message, flag, bf);
301 if ((cur = cur->child) == NULL)
306 mutt_set_flag (Context, cur->message, flag, bf);
324 int mutt_change_flag (HEADER * h, int bf)
329 mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
330 bf ? _("Set flag") : _("Clear flag"));
333 event = mutt_getch ();
336 CLEARLINE (LINES - 1);
340 CLEARLINE (LINES - 1);
356 mutt_set_flag (Context, h, M_READ, !bf);
358 mutt_tag_set_flag (M_READ, !bf);
381 mutt_set_flag (Context, h, flag, bf);
383 mutt_tag_set_flag (flag, bf);