]> granicus.if.org Git - neomutt/commitdiff
mx_mbox_open: drop path param
authorRichard Russon <rich@flatcap.org>
Sat, 5 Jan 2019 12:50:27 +0000 (12:50 +0000)
committerRichard Russon <rich@flatcap.org>
Fri, 8 Feb 2019 16:29:35 +0000 (16:29 +0000)
12 files changed:
commands.c
compose.c
editmsg.c
index.c
main.c
mbox/mbox.c
mutt_attach.c
mx.c
mx.h
pop/pop.c
postpone.c
sendlib.c

index bc2e07e822427290a9e348dc7558b8bbe1a8d334..a5e55f982fa4bfa0c244f6e69ea80bbc3a3a8977 100644 (file)
@@ -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);
index f05cc445e621f0c75098c7dab939300970d95605..70b832373960aa7e0be71b1aef1c84a7d1fe3be4 100644 (file)
--- 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);
index eed210915b8069312348be36b4cab07f669c76d1..27f385019a6f815d2a98c6d77354461d5514c3a3 100644 (file)
--- 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 deed4319916c9a471a959f27060dfb39bb08fa67..d4c70b5cd5605cb279029c77cc3d0808d39c2ac9 100644 (file)
--- 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 9b8d33396821a02f3928444d9461f1ae1b18ff70..7a9eef2aa92df3af5ebd9d73cb21fbd406c239c8 100644 (file)
--- 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);
index f4566117a365b14e1b66a8987719ccf9afefabbc..4df6ea10e2e978a60c87c5c3a412a593d5ee8dbf 100644 (file)
@@ -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;
index 4f6664e9098fd6e4fad967913acb42d8f551dd68..fe89139b58a43adfaa249c3c5ebde28d33ae158a 100644 (file)
@@ -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 f684794bf0616c02ec6ccef5cabb907c8ef9b710..2c50dab9349bd94f181797196023d04f7af5a7ed 100644 (file)
--- 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 a41f12e1a187e970313e458326fcb7ef57da31f5..20c97d3d7d03925de6ece7894e0ffd68ac0174cc 100644 (file)
--- 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);
index cd0ed0a21aff430ba7998cd1bd4fe8531958bef4..e85afaab1457e7d4908d505f5f2ff325ff54adcc 100644 (file)
--- 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);
index 5b13c9d68586037314a77a3a1406eb2a9651d601..3a99c05fcf8e2ca0c38cea55fe34802d84860147 100644 (file)
@@ -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)
   {
index 08180f49fc0138d01c3831908ccb6a5f7789a9ee..94919b1fba3c4850f9976578d1f5a8dbeeca58b7 100644 (file)
--- 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);