return -1;
}
- mutt_mailbox_check(0);
+ mutt_mailbox_check(Context->mailbox, 0);
dp = opendir(d);
if (!dp)
if (STAILQ_EMPTY(&AllMailboxes))
return -1;
- mutt_mailbox_check(0);
+ mutt_mailbox_check(Context ? Context->mailbox : NULL, 0);
struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &AllMailboxes, entries)
if (mailbox)
{
menu->is_mailbox_list = true;
- snprintf(title, titlelen, _("Mailboxes [%d]"), mutt_mailbox_check(0));
+ snprintf(title, titlelen, _("Mailboxes [%d]"), mutt_mailbox_check(Context ? Context->mailbox : NULL, 0));
}
else
{
if ((rc != 0) || WaitKey)
mutt_any_key_to_continue(NULL);
- mutt_mailbox_check(MUTT_MAILBOX_CHECK_FORCE);
+ mutt_mailbox_check(Context->mailbox, MUTT_MAILBOX_CHECK_FORCE);
}
/**
*/
void mutt_check_stats(void)
{
- mutt_mailbox_check(MUTT_MAILBOX_CHECK_FORCE | MUTT_MAILBOX_CHECK_FORCE_STATS);
+ mutt_mailbox_check(Context->mailbox, MUTT_MAILBOX_CHECK_FORCE | MUTT_MAILBOX_CHECK_FORCE_STATS);
}
case MBN_RESORT:
mutt_sort_headers(ctx, true);
break;
+ case MBN_UNTAG:
+ if (ctx->last_tag && ctx->last_tag->deleted)
+ ctx->last_tag = NULL;
+ break;
}
}
#include "mutt.h"
#include "alias.h"
#include "browser.h"
+#include "context.h"
#include "curs_lib.h"
#include "enter_state.h"
#include "globals.h"
{
first = 1; /* clear input if user types a real key later */
mutt_mb_wcstombs(buf, buflen, state->wbuf, state->curpos);
- mutt_mailbox(buf, buflen);
+ mutt_mailbox(Context ? Context->mailbox : NULL, buf, buflen);
state->curpos = state->lastchar =
mutt_mb_mbstowcs(&state->wbuf, &state->wbuflen, 0, buf);
break;
#endif
mutt_clear_error();
- mutt_mailbox_check(MUTT_MAILBOX_CHECK_FORCE); /* force the mailbox check after we have changed the folder */
+ mutt_mailbox_check(Context ? Context->mailbox : NULL, MUTT_MAILBOX_CHECK_FORCE); /* force the mailbox check after we have changed the folder */
menu->redraw = REDRAW_FULL;
OptSearchInvalid = true;
if (!attach_msg)
{
/* force the mailbox check after we enter the folder */
- mutt_mailbox_check(MUTT_MAILBOX_CHECK_FORCE);
+ mutt_mailbox_check(Context ? Context->mailbox : NULL, MUTT_MAILBOX_CHECK_FORCE);
}
#ifdef USE_INOTIFY
mutt_monitor_add(NULL);
{
/* check for new mail in the incoming folders */
oldcount = newcount;
- newcount = mutt_mailbox_check(0);
+ newcount = mutt_mailbox_check(Context ? Context->mailbox : NULL, 0);
if (newcount != oldcount)
menu->redraw |= REDRAW_STATUS;
if (do_mailbox_notify)
{
- if (mutt_mailbox_notify())
+ if (mutt_mailbox_notify(Context ? Context->mailbox : NULL))
{
menu->redraw |= REDRAW_STATUS;
if (BeepNew)
{
mutt_str_strfcpy(buf, Context->mailbox->path, sizeof(buf));
mutt_pretty_mailbox(buf, sizeof(buf));
- mutt_mailbox(buf, sizeof(buf));
+ mutt_mailbox(Context ? Context->mailbox : NULL, buf, sizeof(buf));
if (!buf[0])
{
mutt_error(_("No mailboxes have new mail"));
{
/* By default, fill buf with the next mailbox that contains unread
* mail */
- mutt_mailbox(buf, sizeof(buf));
+ mutt_mailbox(Context ? Context->mailbox : NULL, buf, sizeof(buf));
}
if (mutt_enter_fname(cp, buf, sizeof(buf), 1) == -1)
/**
* mailbox_check - Check a mailbox for new mail
- * @param m Mailbox to check
- * @param ctx_sb stat() info for the current mailbox (Context)
+ * @param m_cur Current Mailbox
+ * @param m_check Mailbox to check
+ * @param ctx_sb stat() info for the current Mailbox
* @param check_stats If true, also count the total, new and flagged messages
*/
-static void mailbox_check(struct Mailbox *m, struct stat *ctx_sb, bool check_stats)
+static void mailbox_check(struct Mailbox *m_cur, struct Mailbox *m_check, struct stat *ctx_sb, bool check_stats)
{
struct stat sb = { 0 };
#ifdef USE_SIDEBAR
- short orig_new = m->has_new;
- int orig_count = m->msg_count;
- int orig_unread = m->msg_unread;
- int orig_flagged = m->msg_flagged;
+ short orig_new = m_check->has_new;
+ int orig_count = m_check->msg_count;
+ int orig_unread = m_check->msg_unread;
+ int orig_flagged = m_check->msg_flagged;
#endif
- enum MailboxType mb_magic = mx_path_probe(m->path, NULL);
+ enum MailboxType mb_magic = mx_path_probe(m_check->path, NULL);
switch (mb_magic)
{
case MUTT_NOTMUCH:
case MUTT_IMAP:
if (mb_magic != MUTT_IMAP)
- m->has_new = false;
- m->magic = mb_magic;
+ m_check->has_new = false;
+ m_check->magic = mb_magic;
break;
default:
- m->has_new = false;
+ m_check->has_new = false;
- if (stat(m->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
- ((m->magic == MUTT_UNKNOWN) && (m->magic = mx_path_probe(m->path, NULL)) <= 0))
+ if (stat(m_check->path, &sb) != 0 || (S_ISREG(sb.st_mode) && sb.st_size == 0) ||
+ ((m_check->magic == MUTT_UNKNOWN) && (m_check->magic = mx_path_probe(m_check->path, NULL)) <= 0))
{
/* if the mailbox still doesn't exist, set the newly created flag to be
* ready for when it does. */
- m->newly_created = true;
- m->magic = MUTT_UNKNOWN;
- m->size = 0;
+ m_check->newly_created = true;
+ m_check->magic = MUTT_UNKNOWN;
+ m_check->size = 0;
return;
}
break; // kept for consistency.
}
/* check to see if the folder is the currently selected folder before polling */
- if (!Context || (Context->mailbox->path[0] == '\0') ||
- ((m->magic == MUTT_IMAP || m->magic == MUTT_NNTP ||
- m->magic == MUTT_NOTMUCH || m->magic == MUTT_POP) ?
- (mutt_str_strcmp(m->path, Context->mailbox->path) != 0) :
+ if (!m_cur || (m_cur->path[0] == '\0') ||
+ ((m_check->magic == MUTT_IMAP || m_check->magic == MUTT_NNTP ||
+ m_check->magic == MUTT_NOTMUCH || m_check->magic == MUTT_POP) ?
+ (mutt_str_strcmp(m_check->path, m_cur->path) != 0) :
(sb.st_dev != ctx_sb->st_dev || sb.st_ino != ctx_sb->st_ino)))
{
- switch (m->magic)
+ switch (m_check->magic)
{
case MUTT_IMAP:
case MUTT_MBOX:
case MUTT_MAILDIR:
case MUTT_MH:
case MUTT_NOTMUCH:
- if (mx_mbox_check_stats(m, 0) == 0)
+ if (mx_mbox_check_stats(m_check, 0) == 0)
MailboxCount++;
break;
default:; /* do nothing */
}
}
- else if (CheckMboxSize && Context && (Context->mailbox->path[0] != '\0'))
- m->size = (off_t) sb.st_size; /* update the size of current folder */
+ else if (CheckMboxSize && m_cur && (m_cur->path[0] != '\0'))
+ m_check->size = (off_t) sb.st_size; /* update the size of current folder */
#ifdef USE_SIDEBAR
- if ((orig_new != m->has_new) || (orig_count != m->msg_count) ||
- (orig_unread != m->msg_unread) || (orig_flagged != m->msg_flagged))
+ if ((orig_new != m_check->has_new) || (orig_count != m_check->msg_count) ||
+ (orig_unread != m_check->msg_unread) || (orig_flagged != m_check->msg_flagged))
{
mutt_menu_set_current_redraw(REDRAW_SIDEBAR);
}
#endif
- if (!m->has_new)
- m->notified = false;
- else if (!m->notified)
+ if (!m_check->has_new)
+ m_check->notified = false;
+ else if (!m_check->notified)
MailboxNotify++;
}
/**
* mutt_mailbox_check - Check all AllMailboxes for new mail
+ * @param m_cur Current Mailbox
* @param force Force flags, see below
* @retval num Number of mailboxes with new mail
*
*
* Check all AllMailboxes for new mail and total/new/flagged messages
*/
-int mutt_mailbox_check(int force)
+int mutt_mailbox_check(struct Mailbox *m_cur, int force)
{
struct stat contex_sb;
time_t t;
MailboxNotify = 0;
/* check device ID and serial number instead of comparing paths */
- if (!Context || !Context->mailbox || (Context->mailbox->magic == MUTT_IMAP) ||
- (Context->mailbox->magic == MUTT_POP)
+ if (!m_cur || (m_cur->magic == MUTT_IMAP) ||
+ (m_cur->magic == MUTT_POP)
#ifdef USE_NNTP
- || (Context->mailbox->magic == MUTT_NNTP)
+ || (m_cur->magic == MUTT_NNTP)
#endif
- || stat(Context->mailbox->path, &contex_sb) != 0)
+ || stat(m_cur->path, &contex_sb) != 0)
{
contex_sb.st_dev = 0;
contex_sb.st_ino = 0;
struct MailboxNode *np = NULL;
STAILQ_FOREACH(np, &AllMailboxes, entries)
{
- mailbox_check(np->m, &contex_sb,
+ mailbox_check(m_cur, np->m, &contex_sb,
check_stats || (!np->m->first_check_stats_done && MailCheckStats));
np->m->first_check_stats_done = true;
}
/**
* mutt_mailbox_notify - Notify the user if there's new mail
+ * @param m_cur Current Mailbox
* @retval true If there is new mail
*/
-bool mutt_mailbox_notify(void)
+bool mutt_mailbox_notify(struct Mailbox *m_cur)
{
- if (mutt_mailbox_check(0) && MailboxNotify)
+ if (mutt_mailbox_check(m_cur, 0) && MailboxNotify)
{
return mutt_mailbox_list();
}
/**
* mutt_mailbox - incoming folders completion routine
- * @param s Buffer containing name of current mailbox
- * @param slen Buffer length
+ * @param m_cur Current Mailbox
+ * @param s Buffer containing name of current mailbox
+ * @param slen Buffer length
*
* Given a folder name, find the next incoming folder with new mail.
*/
-void mutt_mailbox(char *s, size_t slen)
+void mutt_mailbox(struct Mailbox *m_cur, char *s, size_t slen)
{
mutt_expand_path(s, slen);
- if (mutt_mailbox_check(0))
+ if (mutt_mailbox_check(m_cur, 0))
{
int found = 0;
for (int pass = 0; pass < 2; pass++)
}
}
- mutt_mailbox_check(MUTT_MAILBOX_CHECK_FORCE); /* mailbox was wrong - resync things */
+ mutt_mailbox_check(m_cur, MUTT_MAILBOX_CHECK_FORCE); /* mailbox was wrong - resync things */
}
/* no folders with new mail */
MBN_INVALID, ///< Email list was changed
MBN_RESORT, ///< Email list needs resorting
MBN_UPDATE, ///< Update internal tables
+ MBN_UNTAG, ///< Clear the 'last-tagged' pointer
};
/**
#define MUTT_MAILBOX_CHECK_FORCE (1 << 0)
#define MUTT_MAILBOX_CHECK_FORCE_STATS (1 << 1)
-void mutt_mailbox(char *s, size_t slen);
+void mutt_mailbox(struct Mailbox *m_cur, char *s, size_t slen);
bool mutt_mailbox_list(void);
-int mutt_mailbox_check(int force);
-bool mutt_mailbox_notify(void);
+int mutt_mailbox_check(struct Mailbox *m_cur, int force);
+bool mutt_mailbox_notify(struct Mailbox *m_cur);
enum CommandResult mutt_parse_mailboxes(struct Buffer *path, struct Buffer *s, unsigned long data, struct Buffer *err);
enum CommandResult mutt_parse_unmailboxes(struct Buffer *path, struct Buffer *s, unsigned long data, struct Buffer *err);
void mutt_mailbox_changed(struct Mailbox *m, enum MailboxNotification action);
bool passive = ImapPassive;
ImapPassive = false;
#endif
- if (mutt_mailbox_check(0) == 0)
+ if (mutt_mailbox_check(Context ? Context->mailbox : NULL, 0) == 0)
{
mutt_message(_("No mailbox with new mail"));
goto main_curses; // TEST37: neomutt -Z (no new mail)
}
folder[0] = '\0';
- mutt_mailbox(folder, sizeof(folder));
+ mutt_mailbox(Context ? Context->mailbox : NULL, folder, sizeof(folder));
#ifdef USE_IMAP
ImapPassive = passive;
#endif
}
#ifdef USE_IMAP
- if (Context->mailbox->magic == MUTT_IMAP && (imap_path_probe(Trash, NULL) == MUTT_IMAP))
+ if (m->magic == MUTT_IMAP && (imap_path_probe(Trash, NULL) == MUTT_IMAP))
{
- if (imap_fast_trash(Context->mailbox, Trash) == 0)
+ if (imap_fast_trash(m, Trash) == 0)
return 0;
}
#endif
/**
* mx_mbox_sync - Save changes to mailbox
* @param[in] ctx Context
- * @param[out] index_hint Currently selected mailbox
+ * @param[out] index_hint Currently selected Email
* @retval 0 Success
* @retval -1 Error
*/
return 0;
}
- if (m->msg_deleted)
+ if (m->msg_deleted != 0)
{
char buf[SHORT_STRING];
m->msg_deleted = 0;
}
}
- else if (ctx->last_tag && ctx->last_tag->deleted)
- ctx->last_tag = NULL; /* reset last tagged msg now useless */
+ mutt_mailbox_changed(m, MBN_UNTAG);
}
/* really only for IMAP - imap_sync_mailbox results in a call to
if (purge && m->msg_deleted && (mutt_str_strcmp(m->path, Trash) != 0))
{
- if (trash_append(ctx->mailbox) != 0)
+ if (trash_append(m) != 0)
return -1;
}
#ifdef USE_IMAP
if (m->magic == MUTT_IMAP)
- rc = imap_sync_mailbox(ctx->mailbox, purge, false);
+ rc = imap_sync_mailbox(m, purge, false);
else
#endif
- rc = sync_mailbox(ctx->mailbox, index_hint);
+ rc = sync_mailbox(m, index_hint);
if (rc == 0)
{
#ifdef USE_IMAP
}
}
- if (mutt_mailbox_notify() || do_new_mail)
+ if (mutt_mailbox_notify(Context ? Context->mailbox : NULL) || do_new_mail)
{
if (BeepNew)
beep();
if (!optional)
{
snprintf(fmt, sizeof(fmt), "%%%sd", prec);
- snprintf(buf, buflen, fmt, mutt_mailbox_check(0));
+ snprintf(buf, buflen, fmt, mutt_mailbox_check(Context ? Context->mailbox : NULL, 0));
}
- else if (mutt_mailbox_check(0) == 0)
+ else if (mutt_mailbox_check(Context ? Context->mailbox : NULL, 0) == 0)
optional = 0;
break;