From: Brendan Cully Date: Sat, 31 Mar 2007 02:41:27 +0000 (-0700) Subject: Add close hook for mh/maildir. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=44a2dee1f98d4491a7f12e7019c49a42678b2c7f;p=neomutt Add close hook for mh/maildir. stat the directory on open. Make IMAP close function match prototype. --- diff --git a/ChangeLog b/ChangeLog index 3b5d288b0..bed305b6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,11 @@ -2007-03-30 00:21 -0700 Brendan Cully (0cb476dc70a7) +2007-03-30 19:22 -0700 Brendan Cully (e9451c4c0092) + + * imap/imap.c, mutt.h, mx.c, pop.c: Add function pointer for close + hook in Context. Slowly inch towards function pointers instead of + switch statements. + + * imap/command.c, imap/imap.c: Use RECENT for first mailbox + check if header cache check fails * imap/command.c: Consult header cache if available for last known new mail count. This prevents mutt from announcing new mail in mailboxes diff --git a/imap/imap.c b/imap/imap.c index a4ad726ac..97844107e 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1277,7 +1277,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint) } /* imap_close_mailbox: clean up IMAP data in CONTEXT */ -void imap_close_mailbox (CONTEXT* ctx) +int imap_close_mailbox (CONTEXT* ctx) { IMAP_DATA* idata; int i; @@ -1285,7 +1285,7 @@ void imap_close_mailbox (CONTEXT* ctx) idata = (IMAP_DATA*) ctx->data; /* Check to see if the mailbox is actually open */ if (!idata) - return; + return 0; if (ctx == idata->ctx) { @@ -1325,6 +1325,8 @@ void imap_close_mailbox (CONTEXT* ctx) } mutt_bcache_close (&idata->bcache); + + return 0; } /* use the NOOP or IDLE command to poll for new mail diff --git a/imap/imap.h b/imap/imap.h index 149b5233e..9bfea6fc5 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -38,7 +38,7 @@ int imap_delete_mailbox (CONTEXT* idata, IMAP_MBOX mx); int imap_open_mailbox (CONTEXT *ctx); int imap_open_mailbox_append (CONTEXT *ctx); int imap_sync_mailbox (CONTEXT *ctx, int expunge, int *index_hint); -void imap_close_mailbox (CONTEXT *ctx); +int imap_close_mailbox (CONTEXT *ctx); int imap_buffy_check (int force); int imap_status (char *path, int queue); int imap_search (CONTEXT* ctx, const pattern_t* pat); diff --git a/mh.c b/mh.c index 1447d142f..77880db25 100644 --- a/mh.c +++ b/mh.c @@ -73,6 +73,11 @@ struct mh_sequences short *flags; }; +struct mh_data +{ + mode_t mode; /* mode of mail folder. New messages should match. */ +}; + /* mh_sequences support */ #define MH_SEQ_UNSEEN (1 << 0) @@ -1004,6 +1009,13 @@ void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md, #endif } +static int mh_close_mailbox (CONTEXT *ctx) +{ + FREE (&ctx->data); + + return 0; +} + /* Read a MH/maildir style mailbox. * * args: @@ -1016,6 +1028,8 @@ int mh_read_dir (CONTEXT * ctx, const char *subdir) struct maildir *md; struct mh_sequences mhs; struct maildir **last; + struct mh_data *data; + struct stat st; int count; char msgbuf[STRING]; progress_t progress; @@ -1047,6 +1061,23 @@ int mh_read_dir (CONTEXT * ctx, const char *subdir) maildir_delayed_parsing (ctx, md, &progress); maildir_move_to_context (ctx, &md); + + if (!ctx->data) + { + ctx->data = safe_calloc(sizeof (struct mh_data), 1); + data = (struct mh_data *)ctx->data; + if (stat (ctx->path, &st)) + { + /* shouldn't happen this late */ + dprint (1, (debugfile, "stat failed opening maildir\n")); + data->mode = 0700; + } + else + data->mode = st.st_mode; + + ctx->mx_close = mh_close_mailbox; + } + return 0; }