From: Richard Russon Date: Sat, 5 Jan 2019 12:50:27 +0000 (+0000) Subject: mx_mbox_open: drop path param X-Git-Tag: 2019-10-25~373^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=91f8270ebd6c75b1514443ba0cf89cf2a0be6037;p=neomutt mx_mbox_open: drop path param --- diff --git a/commands.c b/commands.c index bc2e07e82..a5e55f982 100644 --- a/commands.c +++ b/commands.c @@ -1068,7 +1068,7 @@ int mutt_save_message(struct Mailbox *m, struct EmailList *el, bool delete, bool #endif struct Mailbox *m_save = mx_path_resolve(buf); - savectx = mx_mbox_open(m_save, NULL, MUTT_APPEND); + savectx = mx_mbox_open(m_save, MUTT_APPEND); if (!savectx) { mailbox_free(&m_save); diff --git a/compose.c b/compose.c index f05cc445e..70b832373 100644 --- a/compose.c +++ b/compose.c @@ -1451,7 +1451,7 @@ int mutt_compose_menu(struct Email *msg, char *fcc, size_t fcclen, struct Email menu->redraw = REDRAW_FULL; struct Mailbox *m = mx_path_resolve(fname); - ctx = mx_mbox_open(m, NULL, MUTT_READONLY); + ctx = mx_mbox_open(m, MUTT_READONLY); if (!ctx) { mutt_error(_("Unable to open mailbox %s"), fname); diff --git a/editmsg.c b/editmsg.c index eed210915..27f385019 100644 --- a/editmsg.c +++ b/editmsg.c @@ -68,8 +68,10 @@ static int ev_message(enum EvMessage action, struct Mailbox *m, struct Email *e) enum MailboxType omagic = MboxType; MboxType = MUTT_MBOX; + struct Mailbox *m_fname = mx_path_resolve(fname); - struct Context *tmpctx = mx_mbox_open(m_fname, NULL, MUTT_NEWFOLDER); + struct Context *tmpctx = mx_mbox_open(m_fname, MUTT_NEWFOLDER); + MboxType = omagic; if (!tmpctx) @@ -171,7 +173,7 @@ static int ev_message(enum EvMessage action, struct Mailbox *m, struct Email *e) goto bail; } - tmpctx = mx_mbox_open(m, NULL, MUTT_APPEND); + tmpctx = mx_mbox_open(m, MUTT_APPEND); if (!tmpctx) { rc = -1; diff --git a/index.c b/index.c index deed43199..d4c70b5cd 100644 --- a/index.c +++ b/index.c @@ -650,7 +650,7 @@ static int main_change_folder(struct Menu *menu, int op, struct Mailbox *m, m = mx_path_resolve(buf); free_m = true; } - Context = mx_mbox_open(m, NULL, flags); + Context = mx_mbox_open(m, flags); if (Context) { menu->current = ci_first_message(); diff --git a/main.c b/main.c index 9b8d33396..7a9eef2aa 100644 --- a/main.c +++ b/main.c @@ -1209,7 +1209,7 @@ int main(int argc, char *argv[], char *envp[]) repeat_error = true; struct Mailbox *m = mx_path_resolve(folder); - Context = mx_mbox_open(m, NULL, ((flags & MUTT_RO) || ReadOnly) ? MUTT_READONLY : 0); + Context = mx_mbox_open(m, ((flags & MUTT_RO) || ReadOnly) ? MUTT_READONLY : 0); if (!Context) { mailbox_free(&m); diff --git a/mbox/mbox.c b/mbox/mbox.c index f4566117a..4df6ea10e 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -1800,7 +1800,7 @@ static int mbox_mbox_check_stats(struct Mailbox *m, int flags) if (mutt_file_stat_timespec_compare(&sb, MUTT_STAT_MTIME, &m->stats_last_checked) > 0) { - struct Context *ctx = mx_mbox_open(m, NULL, MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK); + struct Context *ctx = mx_mbox_open(m, MUTT_QUIET | MUTT_NOSORT | MUTT_PEEK); if (ctx) { m->msg_count = ctx->mailbox->msg_count; diff --git a/mutt_attach.c b/mutt_attach.c index 4f6664e90..fe89139b5 100644 --- a/mutt_attach.c +++ b/mutt_attach.c @@ -814,7 +814,7 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct if (!fgets(buf, sizeof(buf), fp)) return -1; struct Mailbox *m_att = mx_path_resolve(path); - struct Context *ctx = mx_mbox_open(m_att, NULL, MUTT_APPEND | MUTT_QUIET); + struct Context *ctx = mx_mbox_open(m_att, MUTT_APPEND | MUTT_QUIET); if (!ctx) { mailbox_free(&m_att); diff --git a/mx.c b/mx.c index f684794bf..2c50dab93 100644 --- a/mx.c +++ b/mx.c @@ -239,7 +239,6 @@ static int mx_open_mailbox_append(struct Mailbox *m, int flags) /** * mx_mbox_open - Open a mailbox and parse it * @param m Mailbox to open - * @param path Path to the mailbox * @param flags See below * @retval ptr Mailbox context * @retval NULL Error @@ -251,27 +250,13 @@ static int mx_open_mailbox_append(struct Mailbox *m, int flags) * * #MUTT_QUIET only print error messages * * #MUTT_PEEK revert atime where applicable */ -struct Context *mx_mbox_open(struct Mailbox *m, const char *path, int flags) +struct Context *mx_mbox_open(struct Mailbox *m, int flags) { - if (!m && (!path || !path[0])) + if (!m) return NULL; struct Context *ctx = mutt_mem_calloc(1, sizeof(*ctx)); ctx->mailbox = m; - if (!m) - { - m = mx_mbox_find2(path); - ctx->mailbox = m; - } - - if (!m) - { - m = mailbox_new(); - ctx->mailbox = m; - m->flags = MB_HIDDEN; - mutt_str_strfcpy(m->path, path, sizeof(m->path)); - /* int rc = */ mx_path_canon2(m, Folder); - } m->notify = ctx_mailbox_changed; m->ndata = ctx; @@ -335,7 +320,7 @@ struct Context *mx_mbox_open(struct Mailbox *m, const char *path, int flags) if (!m->magic) { - m->magic = mx_path_probe(path, NULL); + m->magic = mx_path_probe(m->path, NULL); m->mx_ops = mx_get_ops(m->magic); } @@ -345,9 +330,9 @@ struct Context *mx_mbox_open(struct Mailbox *m, const char *path, int flags) if ((m->magic == MUTT_UNKNOWN) || (m->magic == MUTT_MAILBOX_ERROR) || !m->mx_ops) { if (m->magic == MUTT_MAILBOX_ERROR) - mutt_perror(path); + mutt_perror(m->path); else if (m->magic == MUTT_UNKNOWN || !m->mx_ops) - mutt_error(_("%s is not a mailbox"), path); + mutt_error(_("%s is not a mailbox"), m->path); mx_fastclose_mailbox(m); ctx_free(&ctx); @@ -526,7 +511,7 @@ static int trash_append(struct Mailbox *m) #endif struct Mailbox *m_trash = mx_path_resolve(Trash); - struct Context *ctx_trash = mx_mbox_open(m_trash, NULL, MUTT_APPEND); + struct Context *ctx_trash = mx_mbox_open(m_trash, MUTT_APPEND); if (ctx_trash) { /* continue from initial scan above */ @@ -703,7 +688,7 @@ int mx_mbox_close(struct Context **pctx) #endif { struct Mailbox *m_read = mx_path_resolve(mbox); - struct Context *ctx_read = mx_mbox_open(m_read, NULL, MUTT_APPEND); + struct Context *ctx_read = mx_mbox_open(m_read, MUTT_APPEND); if (!ctx_read) { mailbox_free(&m_read); diff --git a/mx.h b/mx.h index a41f12e1a..20c97d3d7 100644 --- a/mx.h +++ b/mx.h @@ -271,7 +271,7 @@ struct MxOps int mx_mbox_check (struct Mailbox *m, int *index_hint); int mx_mbox_check_stats(struct Mailbox *m, int flags); int mx_mbox_close (struct Context **pctx); -struct Context *mx_mbox_open (struct Mailbox *m, const char *path, int flags); +struct Context *mx_mbox_open (struct Mailbox *m, int flags); int mx_mbox_sync (struct Mailbox *m, int *index_hint); int mx_msg_close (struct Mailbox *m, struct Message **msg); int mx_msg_commit (struct Mailbox *m, struct Message *msg); diff --git a/pop/pop.c b/pop/pop.c index cd0ed0a21..e85afaab1 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -656,7 +656,7 @@ void pop_fetch_mail(void) } struct Mailbox *m_spool = mx_path_resolve(Spoolfile); - struct Context *ctx = mx_mbox_open(m_spool, NULL, MUTT_APPEND); + struct Context *ctx = mx_mbox_open(m_spool, MUTT_APPEND); if (!ctx) { mailbox_free(&m_spool); diff --git a/postpone.c b/postpone.c index 5b13c9d68..3a99c05fc 100644 --- a/postpone.c +++ b/postpone.c @@ -171,7 +171,7 @@ int mutt_num_postponed(struct Mailbox *m, bool force) OptNews = false; #endif struct Mailbox *m_post = mx_path_resolve(Postponed); - struct Context *ctx = mx_mbox_open(m_post, NULL, MUTT_NOSORT | MUTT_QUIET); + struct Context *ctx = mx_mbox_open(m_post, MUTT_NOSORT | MUTT_QUIET); if (!ctx) { mailbox_free(&m_post); @@ -303,7 +303,7 @@ int mutt_get_postponed(struct Context *ctx, struct Email *hdr, if (ctx->mailbox == m) PostContext = ctx; else - PostContext = mx_mbox_open(m, NULL, MUTT_NOSORT); + PostContext = mx_mbox_open(m, MUTT_NOSORT); if (!PostContext) { diff --git a/sendlib.c b/sendlib.c index 08180f49f..94919b1fb 100644 --- a/sendlib.c +++ b/sendlib.c @@ -3160,7 +3160,7 @@ int mutt_write_fcc(const char *path, struct Email *e, const char *msgid, mutt_folder_hook(path, NULL); #endif struct Mailbox *m_fcc = mx_path_resolve(path); - struct Context *ctx_fcc = mx_mbox_open(m_fcc, NULL, MUTT_APPEND | MUTT_QUIET); + struct Context *ctx_fcc = mx_mbox_open(m_fcc, MUTT_APPEND | MUTT_QUIET); if (!ctx_fcc) { mutt_debug(1, "unable to open mailbox %s in append-mode, aborting.\n", path);