]> granicus.if.org Git - neomutt/commitdiff
factor out Context from mx_msg_commit()
authorRichard Russon <rich@flatcap.org>
Wed, 21 Nov 2018 15:18:16 +0000 (15:18 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 22 Nov 2018 13:45:24 +0000 (13:45 +0000)
copy.c
editmsg.c
mutt_attach.c
mx.c
mx.h
pop/pop.c
sendlib.c

diff --git a/copy.c b/copy.c
index 4b37f7f0ebf1303263996ff04f663ebce37b7d33..36210e84b66af090ff530981527cce528c8572c6 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -837,7 +837,7 @@ static int append_message(struct Context *dest, FILE *fpin, struct Context *src,
     chflags |= CH_FROM | CH_FORCE_FROM;
   chflags |= (dest->mailbox->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
   r = mutt_copy_message_fp(msg->fp, fpin, e, flags, chflags);
-  if (mx_msg_commit(dest, msg) != 0)
+  if (mx_msg_commit(dest->mailbox, msg) != 0)
     r = -1;
 
 #ifdef USE_NOTMUCH
index 9037250ebe9c353e8166a363c49231ec9b42e043..bf6b0cf63121500e2a39c0748e10dd413f391929 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -233,7 +233,7 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Email
     mutt_file_copy_stream(fp, msg->fp);
   }
 
-  rc = mx_msg_commit(tmpctx, msg);
+  rc = mx_msg_commit(tmpctx->mailbox, msg);
   mx_msg_close(tmpctx->mailbox, &msg);
 
   mx_mbox_close(&tmpctx, NULL);
index ba63a59069fe5eb7cc3e933aceb7786a2cc715cc..6ce8ad86d5c26cfa2975f90ab7aab79608d931f2 100644 (file)
@@ -822,7 +822,7 @@ int mutt_save_attachment(FILE *fp, struct Body *m, char *path, int flags, struct
         chflags = CH_FROM | CH_UPDATE_LEN;
       chflags |= (ctx->mailbox->magic == MUTT_MAILDIR ? CH_NOSTATUS : CH_UPDATE);
       if ((mutt_copy_message_fp(msg->fp, fp, en, 0, chflags) == 0) &&
-          (mx_msg_commit(ctx, msg) == 0))
+          (mx_msg_commit(ctx->mailbox, msg) == 0))
       {
         r = 0;
       }
diff --git a/mx.c b/mx.c
index 0a9a95f9ccf52d6ad09dfca38c813bfa3aa8393f..113ce66634ee71e7242e7ecc922ceb05170340b5 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1144,19 +1144,17 @@ struct Message *mx_msg_open(struct Mailbox *m, int msgno)
 }
 
 /**
- * mx_msg_commit - commit a message to a folder
+ * mx_msg_commit - Commit a message to a folder - Wrapper for MxOps::msg_commit()
+ * @param m   Mailbox
  * @param msg Message to commit
- * @param ctx Mailbox
  * @retval  0 Success
  * @retval -1 Failure
  */
-int mx_msg_commit(struct Context *ctx, struct Message *msg)
+int mx_msg_commit(struct Mailbox *m, struct Message *msg)
 {
-  if (!ctx || !ctx->mailbox || !ctx->mailbox->mx_ops || !ctx->mailbox->mx_ops->msg_commit)
+  if (!m || !m->mx_ops || !m->mx_ops->msg_commit)
     return -1;
 
-  struct Mailbox *m = ctx->mailbox;
-
   if (!(msg->write && m->append))
   {
     mutt_debug(1, "msg->write = %d, m->append = %d\n", msg->write, m->append);
diff --git a/mx.h b/mx.h
index 1bedef7212308d1362587a7c1e4986d809227d49..7b92eac9cb72a75ee6ce12f59b081adbc89c77be 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -256,7 +256,7 @@ int             mx_mbox_close      (struct Context **pctx, int *index_hint);
 struct Context *mx_mbox_open       (struct Mailbox *m, const char *path, int flags);
 int             mx_mbox_sync       (struct Context *ctx, int *index_hint);
 int             mx_msg_close       (struct Mailbox *m, struct Message **msg);
-int             mx_msg_commit      (struct Context *ctx, struct Message *msg);
+int             mx_msg_commit      (struct Mailbox *m, struct Message *msg);
 struct Message *mx_msg_open_new    (struct Mailbox *m, struct Email *e, int flags);
 struct Message *mx_msg_open        (struct Mailbox *m, int msgno);
 int             mx_msg_padding_size(struct Mailbox *m);
index ed92076d2379302ea9a9b1ffe86aa0a928508e4b..6a05bc82f65df9617e0a2a08c70172adc6561d9e 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -684,7 +684,7 @@ void pop_fetch_mail(void)
       if (ret == -3)
         rset = 1;
 
-      if (ret == 0 && mx_msg_commit(ctx, msg) != 0)
+      if (ret == 0 && mx_msg_commit(ctx->mailbox, msg) != 0)
       {
         rset = 1;
         ret = -3;
index 52bdaf17230196fedda4937e384e3f98f26184a9..1eeb64e6022741a93e3cb3d1b2660ea3ccf373e0 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -3326,7 +3326,7 @@ int mutt_write_fcc(const char *path, struct Email *e, const char *msgid,
       mutt_debug(1, "%s: write failed.\n", tempfile);
       mutt_file_fclose(&tempfp);
       unlink(tempfile);
-      mx_msg_commit(f, msg); /* XXX really? */
+      mx_msg_commit(f->mailbox, msg); /* XXX really? */
       mx_msg_close(f->mailbox, &msg);
       mx_mbox_close(&f, NULL);
       goto done;
@@ -3354,7 +3354,7 @@ int mutt_write_fcc(const char *path, struct Email *e, const char *msgid,
     rc = mutt_write_mime_body(e->content, msg->fp);
   }
 
-  if (mx_msg_commit(f, msg) != 0)
+  if (mx_msg_commit(f->mailbox, msg) != 0)
     rc = -1;
   else if (finalpath)
     *finalpath = mutt_str_strdup(msg->committed_path);