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;
33 if (ctx->readonly && flag != M_TAG)
34 return; /* don't modify anything if we are read-only */
40 if (ctx && ctx->magic == M_IMAP)
41 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
42 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
48 if (!h->deleted && !ctx->readonly) {
53 /* deleted messages aren't treated as changed elsewhere so that the
54 * purge-on-sync option works correctly. This isn't applicable here */
55 if (ctx && ctx->magic == M_IMAP) {
63 else if (h->deleted) {
70 h->appended = 0; /* when undeleting, also reset the appended flag */
72 /* see my comment above */
73 if (ctx->magic == M_IMAP) {
80 * If the user undeletes a message which is marked as
81 * "trash" in the maildir folder on disk, the folder has
82 * been changed, and is marked accordingly. However, we do
83 * _not_ mark the message itself changed, because trashing
84 * is checked in specific code in the maildir folder
87 if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
114 if (ctx && ctx->magic == M_IMAP)
115 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
116 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
122 if (h->read || h->old) {
152 if (ctx && ctx->magic == M_IMAP)
153 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
154 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
184 if (ctx && ctx->magic == M_IMAP)
185 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
186 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
220 if (ctx && ctx->magic == M_IMAP)
221 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
222 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
243 else if (h->replied) {
254 if (ctx && ctx->magic == M_IMAP)
255 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
256 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
271 else if (h->flagged) {
289 else if (h->tagged) {
297 mutt_set_header_color (ctx, h);
299 /* if the message status has changed, we need to invalidate the cached
300 * search results so that any future search will match the current status
301 * of this message and not what it was at the time it was last searched.
304 && (changed != h->changed || deleted != ctx->deleted
305 || tagged != ctx->tagged))
310 void mutt_tag_set_flag (int flag, int bf)
314 for (j = 0; j < Context->vcount; j++)
315 if (Context->hdrs[Context->v2r[j]]->tagged)
316 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], flag, bf);
318 int mutt_thread_set_flag (HEADER * hdr, int flag, int bf, int subthread)
320 THREAD *start, *cur = hdr->thread;
322 if ((Sort & SORT_MASK) != SORT_THREADS) {
323 mutt_error _("Threading is not enabled.");
334 mutt_set_flag (Context, cur->message, flag, bf);
336 if ((cur = cur->child) == NULL)
341 mutt_set_flag (Context, cur->message, flag, bf);
359 int mutt_change_flag (HEADER * h, int bf)
364 mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
365 bf ? _("Set flag") : _("Clear flag"));
368 event = mutt_getch ();
371 CLEARLINE (LINES - 1);
375 CLEARLINE (LINES - 1);
391 mutt_set_flag (Context, h, M_READ, !bf);
393 mutt_tag_set_flag (M_READ, !bf);
416 mutt_set_flag (Context, h, flag, bf);
418 mutt_tag_set_flag (flag, bf);