X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/19304f7c526fbe36ba0db2fb80bcaf3bd974d81d..939639fcf1dad1b8f3a85d641f41d11c49281f3c:/mx.c diff --git a/mx.c b/mx.c index d135576..7e52714 100644 --- a/mx.c +++ b/mx.c @@ -251,7 +251,7 @@ int mx_lock_file (const char *path, int fd, int excl, int dot, int timeout) int mx_unlock_file (const char *path, int fd, int dot) { #ifdef USE_FCNTL - struct flock unlockit = { F_UNLCK, 0, 0, 0 }; + struct flock unlockit = { F_UNLCK, 0, 0, 0, 0 }; memset (&unlockit, 0, sizeof (struct flock)); unlockit.l_type = F_UNLCK; @@ -370,42 +370,12 @@ int mx_get_magic (const char *path) if (S_ISDIR (st.st_mode)) { /* check for maildir-style mailbox */ - - snprintf (tmp, sizeof (tmp), "%s/cur", path); - if (stat (tmp, &st) == 0 && S_ISDIR (st.st_mode)) - return (M_MAILDIR); + if (mx_is_maildir (path)) + return M_MAILDIR; /* check for mh-style mailbox */ - - snprintf (tmp, sizeof (tmp), "%s/.mh_sequences", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - - snprintf (tmp, sizeof (tmp), "%s/.xmhcache", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - - snprintf (tmp, sizeof (tmp), "%s/.mew_cache", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - - snprintf (tmp, sizeof (tmp), "%s/.mew-cache", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - - snprintf (tmp, sizeof (tmp), "%s/.sylpheed_cache", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - - /* - * ok, this isn't an mh folder, but mh mode can be used to read - * Usenet news from the spool. ;-) - */ - - snprintf (tmp, sizeof (tmp), "%s/.overview", path); - if (access (tmp, F_OK) == 0) - return (M_MH); - + if (mx_is_mh (path)) + return M_MH; } else if (st.st_size == 0) { @@ -441,7 +411,6 @@ int mx_get_magic (const char *path) { dprint (1, (debugfile, "mx_get_magic(): unable to open file %s for reading.\n", path)); - mutt_perror (path); return (-1); } @@ -736,6 +705,10 @@ void mx_fastclose_mailbox (CONTEXT *ctx) if(!ctx) return; + /* never announce that a mailbox we've just left has new mail. #3290 + * XXX: really belongs in mx_close_mailbox, but this is a nice hook point */ + mutt_buffy_setnotified(ctx->path); + if (ctx->mx_close) ctx->mx_close (ctx); @@ -895,7 +868,8 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) if (move_messages) { - mutt_message (_("Moving read messages to %s..."), mbox); + if (!ctx->quiet) + mutt_message (_("Moving read messages to %s..."), mbox); #ifdef USE_IMAP /* try to use server-side copy first */ @@ -954,7 +928,10 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) } else if (!ctx->changed && ctx->deleted == 0) { - mutt_message _("Mailbox is unchanged."); + if (!ctx->quiet) + mutt_message _("Mailbox is unchanged."); + if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) + mbox_reset_atime (ctx, NULL); mx_fastclose_mailbox (ctx); return 0; } @@ -989,12 +966,15 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) } } - if (move_messages) - mutt_message (_("%d kept, %d moved, %d deleted."), - ctx->msgcount - ctx->deleted, read_msgs, ctx->deleted); - else - mutt_message (_("%d kept, %d deleted."), - ctx->msgcount - ctx->deleted, ctx->deleted); + if (!ctx->quiet) + { + if (move_messages) + mutt_message (_("%d kept, %d moved, %d deleted."), + ctx->msgcount - ctx->deleted, read_msgs, ctx->deleted); + else + mutt_message (_("%d kept, %d deleted."), + ctx->msgcount - ctx->deleted, ctx->deleted); + } if (ctx->msgcount == ctx->deleted && (ctx->magic == M_MMDF || ctx->magic == M_MBOX) && @@ -1118,7 +1098,8 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint) if (!ctx->changed && !ctx->deleted) { - mutt_message _("Mailbox is unchanged."); + if (!ctx->quiet) + mutt_message _("Mailbox is unchanged."); return (0); } @@ -1135,10 +1116,8 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint) { if (!ctx->changed) return 0; /* nothing to do! */ -#ifdef USE_IMAP /* let IMAP servers hold on to D flags */ if (ctx->magic != M_IMAP) -#endif { for (i = 0 ; i < ctx->msgcount ; i++) ctx->hdrs[i]->deleted = 0; @@ -1164,11 +1143,17 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint) { #ifdef USE_IMAP if (ctx->magic == M_IMAP && !purge) - mutt_message _("Mailbox checkpointed."); + { + if (!ctx->quiet) + mutt_message _("Mailbox checkpointed."); + } else #endif - mutt_message (_("%d kept, %d deleted."), msgcount - deleted, - deleted); + { + if (!ctx->quiet) + mutt_message (_("%d kept, %d deleted."), msgcount - deleted, + deleted); + } mutt_sleep (0); @@ -1190,10 +1175,8 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint) */ if (purge || (ctx->magic != M_MAILDIR && ctx->magic != M_MH)) { -#ifdef USE_IMAP /* IMAP does this automatically after handling EXPUNGE */ if (ctx->magic != M_IMAP) -#endif { mx_update_tables (ctx, 1); mutt_sort_headers (ctx, 1); /* rethread from scratch */ @@ -1218,7 +1201,7 @@ static int imap_open_new_message (MESSAGE *msg, CONTEXT *dest, HEADER *hdr) { char tmp[_POSIX_PATH_MAX]; - mutt_mktemp(tmp); + mutt_mktemp (tmp, sizeof (tmp)); if ((msg->fp = safe_fopen (tmp, "w")) == NULL) { mutt_perror (tmp); @@ -1347,7 +1330,11 @@ int mx_check_mailbox (CONTEXT *ctx, int *index_hint, int lock) #ifdef USE_IMAP case M_IMAP: - return (imap_check_mailbox (ctx, index_hint, 0)); + /* caller expects that mailbox may change */ + imap_allow_reopen (ctx); + rc = imap_check_mailbox (ctx, index_hint, 0); + imap_disallow_reopen (ctx); + return rc; #endif /* USE_IMAP */ #ifdef USE_POP @@ -1489,13 +1476,7 @@ int mx_close_message (MESSAGE **msg) int r = 0; if ((*msg)->magic == M_MH || (*msg)->magic == M_MAILDIR -#ifdef USE_IMAP - || (*msg)->magic == M_IMAP -#endif -#ifdef USE_POP - || (*msg)->magic == M_POP -#endif - ) + || (*msg)->magic == M_IMAP || (*msg)->magic == M_POP) { r = safe_fclose (&(*msg)->fp); }