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.
10 #include <lib-lib/lib-lib.h>
12 #include <lib-ui/curses.h>
13 #include <lib-ui/menu.h>
14 #include <lib-ui/sidebar.h>
15 #include <lib-mx/mx.h>
20 #include <imap/imap_private.h>
23 void _mutt_set_flag (CONTEXT * ctx, HEADER * h, int flag, int bf, int upd_ctx)
25 int changed = h->changed;
26 int deleted = ctx->deleted;
27 int tagged = ctx->tagged;
28 int flagged = ctx->flagged;
30 if (ctx->readonly && flag != M_TAG)
31 return; /* don't modify anything if we are read-only */
36 if (!mx_acl_check (ctx, ACL_DELETE))
40 if (!h->deleted && !ctx->readonly) {
44 /* deleted messages aren't treated as changed elsewhere so that the
45 * purge-on-sync option works correctly. This isn't applicable here */
46 if (ctx && ctx->magic == M_IMAP) {
53 else if (h->deleted) {
60 h->appended = 0; /* when undeleting, also reset the appended flag */
61 /* see my comment above */
62 if (ctx->magic == M_IMAP) {
68 * If the user undeletes a message which is marked as
69 * "trash" in the maildir folder on disk, the folder has
70 * been changed, and is marked accordingly. However, we do
71 * _not_ mark the message itself changed, because trashing
72 * is checked in specific code in the maildir folder
75 if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
101 if (!mx_acl_check (ctx, ACL_SEEN))
105 if (h->read || h->old) {
134 if (!mx_acl_check (ctx, ACL_SEEN))
161 if (!mx_acl_check (ctx, ACL_SEEN))
192 if (!mx_acl_check (ctx, ACL_WRITE))
211 else if (h->replied) {
221 if (!mx_acl_check (ctx, ACL_WRITE))
234 else if (h->flagged) {
252 else if (h->tagged) {
260 mutt_set_header_color (ctx, h);
262 /* if the message status has changed, we need to invalidate the cached
263 * search results so that any future search will match the current status
264 * of this message and not what it was at the time it was last searched.
266 if (h->searched && (changed != h->changed || deleted != ctx->deleted ||
267 tagged != ctx->tagged || flagged != ctx->flagged))
272 void mutt_tag_set_flag (int flag, int bf)
276 for (j = 0; j < Context->vcount; j++)
277 if (Context->hdrs[Context->v2r[j]]->tagged)
278 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], flag, bf);
280 int mutt_thread_set_flag (HEADER * hdr, int flag, int bf, int subthread)
282 THREAD *start, *cur = hdr->thread;
284 if ((Sort & SORT_MASK) != SORT_THREADS) {
285 mutt_error _("Threading is not enabled.");
296 mutt_set_flag (Context, cur->message, flag, bf);
298 if ((cur = cur->child) == NULL)
303 mutt_set_flag (Context, cur->message, flag, bf);
321 int mutt_change_flag (HEADER * h, int bf)
326 mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
327 bf ? _("Set flag") : _("Clear flag"));
330 event = mutt_getch ();
333 CLEARLINE (LINES - 1);
337 CLEARLINE (LINES - 1);
353 mutt_set_flag (Context, h, M_READ, !bf);
355 mutt_tag_set_flag (M_READ, !bf);
378 mutt_set_flag (Context, h, flag, bf);
380 mutt_tag_set_flag (flag, bf);