]> granicus.if.org Git - neomutt/commitdiff
mbox_open: factor out Context
authorRichard Russon <rich@flatcap.org>
Mon, 24 Dec 2018 11:23:23 +0000 (11:23 +0000)
committerRichard Russon <rich@flatcap.org>
Sat, 5 Jan 2019 14:44:35 +0000 (14:44 +0000)
compress.c
imap/imap.c
maildir/maildir.c
maildir/mh.c
mbox/mbox.c
mx.c
mx.h
nntp/nntp.c
notmuch/mutt_notmuch.c
pop/pop.c

index 32d0f660db2fa2d827cd6afab5137e132458d29d..c1f9af83b61aadfe147a992a7cb9d5aa4b3a107d 100644 (file)
@@ -456,9 +456,9 @@ int comp_ac_add(struct Account *a, struct Mailbox *m)
  * Then determine the type of the mailbox so we can delegate the handling of
  * messages.
  */
-static int comp_mbox_open(struct Mailbox *m, struct Context *ctx)
+static int comp_mbox_open(struct Mailbox *m)
 {
-  if (!ctx || !ctx->mailbox || (ctx->mailbox->magic != MUTT_COMPRESSED))
+  if (!m || (m->magic != MUTT_COMPRESSED))
     return -1;
 
   struct CompressInfo *ci = set_compress_info(m);
@@ -500,7 +500,7 @@ static int comp_mbox_open(struct Mailbox *m, struct Context *ctx)
   }
 
   m->account->magic = m->magic;
-  return ci->child_ops->mbox_open(m, ctx);
+  return ci->child_ops->mbox_open(m);
 
 cmo_fail:
   /* remove the partial uncompressed file */
index 86fae0bef18a0ad6cce12e0562b9cc69ce641187..28f10e8922441b9521d6b1d725d9ba303ddd8856 100644 (file)
@@ -1947,7 +1947,7 @@ int imap_login(struct ImapAccountData *adata)
 /**
  * imap_mbox_open - Implements MxOps::mbox_open()
  */
-static int imap_mbox_open(struct Mailbox *m, struct Context *ctx)
+static int imap_mbox_open(struct Mailbox *m)
 {
   if (!m || !m->account || !m->mdata)
     return -1;
index cbe3546466e47ea2d0dc28cbb51bc1ee2b3a8ad2..65003edf7a7b8ddf8e011eab6def31a393b7e1f5 100644 (file)
@@ -292,7 +292,7 @@ cleanup:
 /**
  * maildir_mbox_open - Implements MxOps::mbox_open()
  */
-static int maildir_mbox_open(struct Mailbox *m, struct Context *ctx)
+static int maildir_mbox_open(struct Mailbox *m)
 {
   return maildir_read_dir(m);
 }
index ac20e5e03856ac97002f90241c6c1333b8db7714..72aba93b31696757ae815b76a659e1e03997d2ac 100644 (file)
@@ -541,7 +541,7 @@ int mh_sync_message(struct Mailbox *m, int msgno)
 /**
  * mh_mbox_open - Implements MxOps::mbox_open()
  */
-static int mh_mbox_open(struct Mailbox *m, struct Context *ctx)
+static int mh_mbox_open(struct Mailbox *m)
 {
   return mh_read_dir(m, NULL);
 }
index 3f1f749951f7d23d81f810aaba02b2933cf8edaa..bd133d96dc8f12706bcfd4a862acfbe0aec2e199 100644 (file)
@@ -923,7 +923,7 @@ int mbox_ac_add(struct Account *a, struct Mailbox *m)
 /**
  * mbox_mbox_open - Implements MxOps::mbox_open()
  */
-static int mbox_mbox_open(struct Mailbox *m, struct Context *ctx)
+static int mbox_mbox_open(struct Mailbox *m)
 {
   if (init_mailbox(m) != 0)
     return -1;
@@ -1016,7 +1016,7 @@ static int mbox_mbox_check(struct Context *ctx, int *index_hint)
 
   if (!adata->fp)
   {
-    if (mbox_mbox_open(m, NULL) < 0)
+    if (mbox_mbox_open(m) < 0)
       return -1;
     mx_update_context(ctx);
   }
diff --git a/mx.c b/mx.c
index f5d559421a77784c564b48fa7795e84a3b7db919..522a2b5990fa65b0f62af52c7ea65d532f4b93bd 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -395,7 +395,7 @@ struct Context *mx_mbox_open(struct Mailbox *m, const char *path, int flags)
   if (!m->quiet)
     mutt_message(_("Reading %s..."), m->path);
 
-  int rc = m->mx_ops->mbox_open(ctx->mailbox, ctx);
+  int rc = m->mx_ops->mbox_open(ctx->mailbox);
   m->opened++;
   if (rc == 0)
     mx_update_context(ctx);
diff --git a/mx.h b/mx.h
index 2224767c7b3084160d085df2a13089db42d3c49f..a9a860722f354d56ac173ac16a5f5dbcf34f9141 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -120,13 +120,12 @@ struct MxOps
   int             (*ac_add)   (struct Account *a, struct Mailbox *m);
   /**
    * mbox_open - Open a mailbox
-   * @param m   Mailbox to open
-   * @param ctx Mailbox to open
+   * @param m Mailbox to open
    * @retval  0 Success
    * @retval -1 Error
    * @retval -2 Aborted
    */
-  int (*mbox_open)       (struct Mailbox *m, struct Context *ctx);
+  int (*mbox_open)       (struct Mailbox *m);
   /**
    * mbox_open_append - Open a mailbox for appending
    * @param m     Mailbox to open
index af8b50566db0a2ebfccc73405ff9dce3072f67fb..bced2fe5156b05de1c5d3701c1711d7f0b091ac8 100644 (file)
@@ -2427,7 +2427,7 @@ int nntp_ac_add(struct Account *a, struct Mailbox *m)
 /**
  * nntp_mbox_open - Implements MxOps::mbox_open()
  */
-static int nntp_mbox_open(struct Mailbox *m, struct Context *ctx)
+static int nntp_mbox_open(struct Mailbox *m)
 {
   if (!m || !m->account)
     return -1;
index 29d836d40bdd7114a00d94313ce51fcd5fe2c931..4f2a7b7ea085dbd957a124b6bf28458c05c58ece 100644 (file)
@@ -2110,7 +2110,7 @@ int nm_ac_add(struct Account *a, struct Mailbox *m)
 /**
  * nm_mbox_open - Implements MxOps::mbox_open()
  */
-static int nm_mbox_open(struct Mailbox *m, struct Context *ctx)
+static int nm_mbox_open(struct Mailbox *m)
 {
   if (init_mailbox(m) != 0)
     return -1;
index 594c81d3a938402b2bd15675dfc1d401aaad8af2..3ec37eeeb1dbcd34e7bb91f1e549e5e42b5f2b97 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -371,19 +371,17 @@ static header_cache_t *pop_hcache_open(struct PopAccountData *adata, const char
 
 /**
  * pop_fetch_headers - Read headers
- * @param ctx Mailbox
+ * @param m Mailbox
  * @retval  0 Success
  * @retval -1 Connection lost
  * @retval -2 Invalid command or execution error
  * @retval -3 Error writing to tempfile
  */
-static int pop_fetch_headers(struct Context *ctx)
+static int pop_fetch_headers(struct Mailbox *m)
 {
-  if (!ctx || !ctx->mailbox)
+  if (!m)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
-
   struct PopAccountData *adata = pop_get_adata(m);
   struct Progress progress;
 
@@ -813,7 +811,7 @@ int pop_ac_add(struct Account *a, struct Mailbox *m)
  *
  * Fetch only headers
  */
-static int pop_mbox_open(struct Mailbox *m, struct Context *ctx)
+static int pop_mbox_open(struct Mailbox *m)
 {
   if (!m || !m->account)
     return -1;
@@ -879,7 +877,7 @@ static int pop_mbox_open(struct Mailbox *m, struct Context *ctx)
 
     mutt_message(_("Fetching list of messages..."));
 
-    const int ret = pop_fetch_headers(ctx);
+    const int ret = pop_fetch_headers(m);
 
     if (ret >= 0)
       return 0;
@@ -916,7 +914,7 @@ static int pop_mbox_check(struct Context *ctx, int *index_hint)
   mutt_message(_("Checking for new messages..."));
 
   int old_msg_count = m->msg_count;
-  int ret = pop_fetch_headers(ctx);
+  int ret = pop_fetch_headers(m);
   pop_clear_cache(adata);
   if (m->msg_count > old_msg_count)
     mx_update_context(ctx);