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>
16 #include <lib-ui/curses.h>
17 #include <lib-ui/menu.h>
24 #include <imap/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) {
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) {
57 else if (h->deleted) {
64 h->appended = 0; /* when undeleting, also reset the appended flag */
65 /* see my comment above */
66 if (ctx->magic == M_IMAP) {
72 * If the user undeletes a message which is marked as
73 * "trash" in the maildir folder on disk, the folder has
74 * been changed, and is marked accordingly. However, we do
75 * _not_ mark the message itself changed, because trashing
76 * is checked in specific code in the maildir folder
79 if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
105 if (!mx_acl_check (ctx, ACL_SEEN))
109 if (h->read || h->old) {
138 if (!mx_acl_check (ctx, ACL_SEEN))
165 if (!mx_acl_check (ctx, ACL_SEEN))
196 if (!mx_acl_check (ctx, ACL_WRITE))
215 else if (h->replied) {
225 if (!mx_acl_check (ctx, ACL_WRITE))
238 else if (h->flagged) {
256 else if (h->tagged) {
264 mutt_set_header_color (ctx, h);
266 /* if the message status has changed, we need to invalidate the cached
267 * search results so that any future search will match the current status
268 * of this message and not what it was at the time it was last searched.
270 if (h->searched && (changed != h->changed || deleted != ctx->deleted ||
271 tagged != ctx->tagged || flagged != ctx->flagged))
276 void mutt_tag_set_flag (int flag, int bf)
280 for (j = 0; j < Context->vcount; j++)
281 if (Context->hdrs[Context->v2r[j]]->tagged)
282 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], flag, bf);
284 int mutt_thread_set_flag (HEADER * hdr, int flag, int bf, int subthread)
286 THREAD *start, *cur = hdr->thread;
288 if ((Sort & SORT_MASK) != SORT_THREADS) {
289 mutt_error _("Threading is not enabled.");
300 mutt_set_flag (Context, cur->message, flag, bf);
302 if ((cur = cur->child) == NULL)
307 mutt_set_flag (Context, cur->message, flag, bf);
325 int mutt_change_flag (HEADER * h, int bf)
330 mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
331 bf ? _("Set flag") : _("Clear flag"));
334 event = mutt_getch ();
337 CLEARLINE (LINES - 1);
341 CLEARLINE (LINES - 1);
357 mutt_set_flag (Context, h, M_READ, !bf);
359 mutt_tag_set_flag (M_READ, !bf);
382 mutt_set_flag (Context, h, flag, bf);
384 mutt_tag_set_flag (flag, bf);