2 * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 #include "mutt_curses.h"
25 #include "mutt_menu.h"
31 #include "imap_private.h"
34 void _mutt_set_flag (CONTEXT * ctx, HEADER * h, int flag, int bf, int upd_ctx)
36 int changed = h->changed;
37 int deleted = ctx->deleted;
38 int tagged = ctx->tagged;
40 if (ctx->readonly && flag != M_TAG)
41 return; /* don't modify anything if we are read-only */
47 if (ctx && ctx->magic == M_IMAP)
48 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
49 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
55 if (!h->deleted && !ctx->readonly) {
60 /* deleted messages aren't treated as changed elsewhere so that the
61 * purge-on-sync option works correctly. This isn't applicable here */
62 if (ctx && ctx->magic == M_IMAP) {
70 else if (h->deleted) {
77 h->appended = 0; /* when undeleting, also reset the appended flag */
79 /* see my comment above */
80 if (ctx->magic == M_IMAP) {
87 * If the user undeletes a message which is marked as
88 * "trash" in the maildir folder on disk, the folder has
89 * been changed, and is marked accordingly. However, we do
90 * _not_ mark the message itself changed, because trashing
91 * is checked in specific code in the maildir folder
94 if (ctx->magic == M_MAILDIR && upd_ctx && h->trash)
121 if (ctx && ctx->magic == M_IMAP)
122 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
123 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
129 if (h->read || h->old) {
159 if (ctx && ctx->magic == M_IMAP)
160 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
161 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
191 if (ctx && ctx->magic == M_IMAP)
192 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
193 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
227 if (ctx && ctx->magic == M_IMAP)
228 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
229 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
250 else if (h->replied) {
261 if (ctx && ctx->magic == M_IMAP)
262 if (mutt_bit_isset (((IMAP_DATA *) ctx->data)->capabilities, ACL)
263 && !mutt_bit_isset (((IMAP_DATA *) ctx->data)->rights,
278 else if (h->flagged) {
296 else if (h->tagged) {
304 mutt_set_header_color (ctx, h);
306 /* if the message status has changed, we need to invalidate the cached
307 * search results so that any future search will match the current status
308 * of this message and not what it was at the time it was last searched.
311 && (changed != h->changed || deleted != ctx->deleted
312 || tagged != ctx->tagged))
317 void mutt_tag_set_flag (int flag, int bf)
321 for (j = 0; j < Context->vcount; j++)
322 if (Context->hdrs[Context->v2r[j]]->tagged)
323 mutt_set_flag (Context, Context->hdrs[Context->v2r[j]], flag, bf);
325 int mutt_thread_set_flag (HEADER * hdr, int flag, int bf, int subthread)
327 THREAD *start, *cur = hdr->thread;
329 if ((Sort & SORT_MASK) != SORT_THREADS) {
330 mutt_error _("Threading is not enabled.");
341 mutt_set_flag (Context, cur->message, flag, bf);
343 if ((cur = cur->child) == NULL)
348 mutt_set_flag (Context, cur->message, flag, bf);
366 int mutt_change_flag (HEADER * h, int bf)
371 mvprintw (LINES - 1, 0, "%s? (D/N/O/r/*/!): ",
372 bf ? _("Set flag") : _("Clear flag"));
375 event = mutt_getch ();
378 CLEARLINE (LINES - 1);
382 CLEARLINE (LINES - 1);
398 mutt_set_flag (Context, h, M_READ, !bf);
400 mutt_tag_set_flag (M_READ, !bf);
423 mutt_set_flag (Context, h, flag, bf);
425 mutt_tag_set_flag (flag, bf);