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"
25 void _mutt_set_flag (CONTEXT * ctx, HEADER * h, int flag, int bf, int upd_ctx)
27 int changed = h->changed;
28 int deleted = ctx->deleted;
29 int tagged = ctx->tagged;
31 if (ctx->readonly && flag != M_TAG)
32 return; /* don't modify anything if we are read-only */
38 if (ctx && ctx->magic == M_IMAP)
39 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
40 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
46 if (!h->deleted && !ctx->readonly) {
51 /* deleted messages aren't treated as changed elsewhere so that the
52 * purge-on-sync option works correctly. This isn't applicable here */
53 if (ctx && ctx->magic == M_IMAP) {
61 else if (h->deleted) {
68 h->appended = 0; /* when undeleting, also reset the appended flag */
70 /* see my comment above */
71 if (ctx->magic == M_IMAP) {
78 * If the user undeletes a message which is marked as
79 * "trash" in the maildir folder on disk, the folder has
80 * been changed, and is marked accordingly. However, we do
81 * _not_ mark the message itself changed, because trashing
82 * is checked in specific code in the maildir folder
85 if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
112 if (ctx && ctx->magic == M_IMAP)
113 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
114 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
120 if (h->read || h->old) {
150 if (ctx && ctx->magic == M_IMAP)
151 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
152 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
182 if (ctx && ctx->magic == M_IMAP)
183 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
184 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
218 if (ctx && ctx->magic == M_IMAP)
219 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
220 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
241 else if (h->replied) {
252 if (ctx && ctx->magic == M_IMAP)
253 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
254 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
269 else if (h->flagged) {
287 else if (h->tagged) {
295 mutt_set_header_color (ctx, h);
297 /* if the message status has changed, we need to invalidate the cached
298 * search results so that any future search will match the current status
299 * of this message and not what it was at the time it was last searched.
302 && (changed != h->changed || deleted != ctx->deleted
303 || tagged != ctx->tagged))
308 void mutt_tag_set_flag (int flag, int bf)
312 for (j = 0; j < Context->vcount; j++)
313 if (Context->hdrs[Context->v2r[j]]->tagged)
314 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], flag, bf);
316 int mutt_thread_set_flag (HEADER * hdr, int flag, int bf, int subthread)
318 THREAD *start, *cur = hdr->thread;
320 if ((Sort & SORT_MASK) != SORT_THREADS) {
321 mutt_error _("Threading is not enabled.");
332 mutt_set_flag (Context, cur->message, flag, bf);
334 if ((cur = cur->child) == NULL)
339 mutt_set_flag (Context, cur->message, flag, bf);
357 int mutt_change_flag (HEADER * h, int bf)
362 mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
363 bf ? _("Set flag") : _("Clear flag"));
366 event = mutt_getch ();
369 CLEARLINE (LINES - 1);
373 CLEARLINE (LINES - 1);
389 mutt_set_flag (Context, h, M_READ, !bf);
391 mutt_tag_set_flag (M_READ, !bf);
414 mutt_set_flag (Context, h, flag, bf);
416 mutt_tag_set_flag (flag, bf);