]> granicus.if.org Git - neomutt/commitdiff
mbox_sync: factor out Context
authorRichard Russon <rich@flatcap.org>
Wed, 26 Dec 2018 18:14:46 +0000 (18:14 +0000)
committerRichard Russon <rich@flatcap.org>
Sat, 5 Jan 2019 14:44:35 +0000 (14:44 +0000)
compress.c
maildir/maildir_private.h
maildir/shared.c
mbox/mbox.c
mx.c
mx.h
nntp/nntp.c
notmuch/mutt_notmuch.c
pop/pop.c

index 638f0e3f06a697dc02319e5eed3f9a9d05b613f1..861884631cead6b4f1a76c594c8e36c28e136114 100644 (file)
@@ -639,12 +639,11 @@ static int comp_mbox_check(struct Mailbox *m, int *index_hint)
  * Changes in NeoMutt only affect the tmp file.
  * Calling comp_mbox_sync() will commit them to the compressed file.
  */
-static int comp_mbox_sync(struct Context *ctx, int *index_hint)
+static int comp_mbox_sync(struct Mailbox *m, int *index_hint)
 {
-  if (!ctx || !ctx->mailbox || !ctx->mailbox->compress_info)
+  if (!m || !m->compress_info)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
   struct CompressInfo *ci = m->compress_info;
 
   if (!ci->close)
@@ -667,7 +666,7 @@ static int comp_mbox_sync(struct Context *ctx, int *index_hint)
   if (rc != 0)
     goto sync_cleanup;
 
-  rc = ops->mbox_sync(ctx, index_hint);
+  rc = ops->mbox_sync(m, index_hint);
   if (rc != 0)
     goto sync_cleanup;
 
index d304f1d3c85c965f16f9ae84e4b801ae53efbf3b..5efcb9ec9d4ea4b5fb532c16b35346a37b80ad82 100644 (file)
@@ -80,7 +80,7 @@ int             maildir_path_parent(char *buf, size_t buflen);
 int             maildir_path_pretty(char *buf, size_t buflen, const char *folder);
 int             mh_mbox_check      (struct Mailbox *m, int *index_hint);
 int             mh_mbox_close      (struct Mailbox *m);
-int             mh_mbox_sync       (struct Context *ctx, int *index_hint);
+int             mh_mbox_sync       (struct Mailbox *m, int *index_hint);
 int             mh_msg_close       (struct Mailbox *m, struct Message *msg);
 
 /* Maildir/MH shared functions */
index e042a6bb9678ff0a4d0c160c980c12cf05a5758b..d2248e129f6e75e8ff072ca63ee56de777026703 100644 (file)
@@ -1757,13 +1757,11 @@ int maildir_path_parent(char *buf, size_t buflen)
 /**
  * mh_mbox_sync - Implements MxOps::mbox_sync()
  */
-int mh_mbox_sync(struct Context *ctx, int *index_hint)
+int mh_mbox_sync(struct Mailbox *m, int *index_hint)
 {
-  if (!ctx || !ctx->mailbox)
+  if (!m)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
-
   int i, j;
 #ifdef USE_HCACHE
   header_cache_t *hc = NULL;
index f865df460b9480c6fc86dc13f339bc83da815fcd..e31e0543878faabe1d462884cbc05b59b1dd613d 100644 (file)
@@ -1128,13 +1128,11 @@ static int mbox_mbox_check(struct Mailbox *m, int *index_hint)
 /**
  * mbox_mbox_sync - Implements MxOps::mbox_sync()
  */
-static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
+static int mbox_mbox_sync(struct Mailbox *m, int *index_hint)
 {
-  if (!ctx || !ctx->mailbox)
+  if (!m)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
-
   struct MboxAccountData *adata = mbox_adata_get(m);
   if (!adata)
     return -1;
@@ -1288,7 +1286,7 @@ static int mbox_mbox_sync(struct Context *ctx, int *index_hint)
        */
       new_offset[i - first].hdr = ftello(fp) + offset;
 
-      if (mutt_copy_message_ctx(fp, ctx->mailbox, m->emails[i], MUTT_CM_UPDATE,
+      if (mutt_copy_message_ctx(fp, m, m->emails[i], MUTT_CM_UPDATE,
                                 CH_FROM | CH_UPDATE | CH_UPDATE_LEN) != 0)
       {
         mutt_perror(tempfile);
diff --git a/mx.c b/mx.c
index 563717faf0f8e706e8d53f3c48489caddbb001ce..023016bbbf64af8fe2467639bfa8775ad95c4ba6 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -481,7 +481,7 @@ static int sync_mailbox(struct Context *ctx, int *index_hint)
     mutt_message(_("Writing %s..."), m->path);
   }
 
-  int rc = m->mx_ops->mbox_sync(ctx, index_hint);
+  int rc = m->mx_ops->mbox_sync(m, index_hint);
   if ((rc != 0) && !m->quiet)
   {
     /* L10N: Displayed if a mailbox sync fails */
diff --git a/mx.h b/mx.h
index 5796bf7b7d7604856dbbdebfc3c48dbabb25abe8..08260b7854edb446b53f83d0f67132ffb28b08b4 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -152,12 +152,12 @@ struct MxOps
   int (*mbox_check_stats)(struct Mailbox *m, int flags);
   /**
    * mbox_sync - Save changes to the mailbox
-   * @param ctx        Mailbox to sync
+   * @param m          Mailbox to sync
    * @param index_hint Remember our place in the index
    * @retval  0 Success
    * @retval -1 Failure
    */
-  int (*mbox_sync)       (struct Context *ctx, int *index_hint);
+  int (*mbox_sync)       (struct Mailbox *m, int *index_hint);
   /**
    * mbox_close - Close a mailbox
    * @param m Mailbox to close
index 29ad5aab1602832f73b18195dc95d51ccbac32ca..ba9f59edb71e2fd72304ef2922c33c45c7814c5f 100644 (file)
@@ -2606,13 +2606,11 @@ static int nntp_mbox_check(struct Mailbox *m, int *index_hint)
  *
  * @note May also return values from check_mailbox()
  */
-static int nntp_mbox_sync(struct Context *ctx, int *index_hint)
+static int nntp_mbox_sync(struct Mailbox *m, int *index_hint)
 {
-  if (!ctx || !ctx->mailbox)
+  if (!m)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
-
   struct NntpMboxData *mdata = m->mdata;
   int rc;
 #ifdef USE_HCACHE
@@ -2662,7 +2660,7 @@ static int nntp_mbox_sync(struct Context *ctx, int *index_hint)
 #endif
 
   /* save .newsrc entries */
-  nntp_newsrc_gen_entries(ctx->mailbox);
+  nntp_newsrc_gen_entries(m);
   nntp_newsrc_update(mdata->adata);
   nntp_newsrc_close(mdata->adata);
   return 0;
index bea00dec8c4418d1eeba421aaf0857bd432798e6..424a60837beb727866f06ad1ec31f00e458e195d 100644 (file)
@@ -2296,13 +2296,11 @@ done:
 /**
  * nm_mbox_sync - Implements MxOps::mbox_sync()
  */
-static int nm_mbox_sync(struct Context *ctx, int *index_hint)
+static int nm_mbox_sync(struct Mailbox *m, int *index_hint)
 {
-  if (!ctx || !ctx->mailbox)
+  if (!m)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
-
   struct NmMboxData *mdata = nm_mdata_get(m);
   if (!mdata)
     return -1;
index 92d494e500a32928a43900e0ebfc50edb77521f1..71acc00f9cf09839d7e94583c8c56781345cf3c3 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -931,13 +931,11 @@ static int pop_mbox_check(struct Mailbox *m, int *index_hint)
  *
  * Update POP mailbox, delete messages from server
  */
-static int pop_mbox_sync(struct Context *ctx, int *index_hint)
+static int pop_mbox_sync(struct Mailbox *m, int *index_hint)
 {
-  if (!ctx || !ctx->mailbox)
+  if (!m)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
-
   int i, j, ret = 0;
   char buf[LONG_STRING];
   struct PopAccountData *adata = pop_get_adata(m);