]> granicus.if.org Git - neomutt/commitdiff
add close_msg to struct mx_ops
authorDamien Riegel <damien.riegel@gmail.com>
Sat, 18 Jun 2016 19:41:45 +0000 (12:41 -0700)
committerDamien Riegel <damien.riegel@gmail.com>
Sat, 18 Jun 2016 19:41:45 +0000 (12:41 -0700)
imap/imap.c
imap/imap_private.h
imap/message.c
mbox.c
mh.c
mutt.h
mx.c
pop.c

index 87a9ed59e1b51840c2c3937889753e2bb9cca6f6..ef9c46855f25fd79c22600f7ac3371b05811a848 100644 (file)
@@ -2075,6 +2075,7 @@ struct mx_ops mx_imap_ops = {
   .open = imap_open_mailbox,
   .close = imap_close_mailbox,
   .open_msg = imap_fetch_message,
+  .close_msg = imap_close_message,
   .open_new_msg = imap_open_new_message,
   .check = imap_check_mailbox_reopen,
 };
index f5dd83f301c898164ac19c192077b31e9498115a..8cd610adf22c7cddd1fe9b3ad5379a32b7a3e56c 100644 (file)
@@ -269,6 +269,7 @@ int imap_cache_del (IMAP_DATA* idata, HEADER* h);
 int imap_cache_clean (IMAP_DATA* idata);
 
 int imap_fetch_message (CONTEXT *ctx, MESSAGE *msg, int msgno);
+int imap_close_message (CONTEXT *ctx, MESSAGE *msg);
 
 /* util.c */
 #ifdef USE_HCACHE
index f6316171525e120d3ad9c29bd5e378b9b7a028a3..917e98773d3ce580c8bd4a1079bdbf13eb331485 100644 (file)
@@ -595,6 +595,11 @@ bail:
   return -1;
 }
 
+int imap_close_message (CONTEXT *ctx, MESSAGE *msg)
+{
+  return safe_fclose (&msg->fp);
+}
+
 int imap_append_message (CONTEXT *ctx, MESSAGE *msg)
 {
   IMAP_DATA* idata;
diff --git a/mbox.c b/mbox.c
index 5d9235fb25baf0f5aea48e39819a486d9d746055..e0b79a1ae5ee22c1fc02e71bcda9f17116473036 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -454,6 +454,13 @@ static int mbox_open_message (CONTEXT *ctx,  MESSAGE *msg, int msgno)
   return 0;
 }
 
+static int mbox_close_message (CONTEXT *ctx, MESSAGE *msg)
+{
+  msg->fp = NULL;
+
+  return 0;
+}
+
 static int mbox_open_new_message (MESSAGE *msg, CONTEXT *dest, HEADER *hdr)
 {
   msg->fp = dest->fp;
@@ -1282,6 +1289,7 @@ struct mx_ops mx_mbox_ops = {
   .open = mbox_open_mailbox,
   .close = mbox_close_mailbox,
   .open_msg = mbox_open_message,
+  .close_msg = mbox_close_message,
   .open_new_msg = mbox_open_new_message,
   .check = mbox_check_mailbox,
 };
@@ -1290,6 +1298,7 @@ struct mx_ops mx_mmdf_ops = {
   .open = mbox_open_mailbox,
   .close = mbox_close_mailbox,
   .open_msg = mbox_open_message,
+  .close_msg = mbox_close_message,
   .open_new_msg = mbox_open_new_message,
   .check = mbox_check_mailbox,
 };
diff --git a/mh.c b/mh.c
index 45496508ee58a4b90f677eacc1481952d456f21e..417957134819e7da327d91fea5d81e0aa709f385 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -1369,6 +1369,11 @@ static int mh_open_message (CONTEXT *ctx, MESSAGE *msg, int msgno)
   return maildir_mh_open_message (ctx, msg, msgno, 0);
 }
 
+static int mh_close_message (CONTEXT *ctx, MESSAGE *msg)
+{
+  return safe_fclose (&msg->fp);
+}
+
 /*
  * Open a new (temporary) message in a maildir folder.
  * 
@@ -2445,6 +2450,7 @@ struct mx_ops mx_maildir_ops = {
   .open = maildir_open_mailbox,
   .close = mh_close_mailbox,
   .open_msg = maildir_open_message,
+  .close_msg = mh_close_message,
   .open_new_msg = maildir_open_new_message,
   .check = maildir_check_mailbox,
 };
@@ -2453,6 +2459,7 @@ struct mx_ops mx_mh_ops = {
   .open = mh_open_mailbox,
   .close = mh_close_mailbox,
   .open_msg = mh_open_message,
+  .close_msg = mh_close_message,
   .open_new_msg = mh_open_new_message,
   .check = mh_check_mailbox,
 };
diff --git a/mutt.h b/mutt.h
index 74cede3254bc3a3ea634bcf446c140714f323c35..8b2d9eae308389a973e9fe168c5c1d9e1cef981a 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -895,6 +895,7 @@ struct mx_ops
   int (*close)(struct _context *);
   int (*check) (struct _context *ctx, int *index_hint);
   int (*open_msg) (struct _context *, struct _message *, int msgno);
+  int (*close_msg) (struct _context *, struct _message *);
   int (*open_new_msg) (struct _message *, struct _context *, HEADER *);
 };
 
diff --git a/mx.c b/mx.c
index e6760a768eac3647183aa98551538f596f00a5e1..01ac627e7a05969ca63170c2099e38b8455b9c99 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -1389,20 +1389,16 @@ int mx_commit_message (MESSAGE *msg, CONTEXT *ctx)
 /* close a pointer to a message */
 int mx_close_message (CONTEXT *ctx, MESSAGE **msg)
 {
+  struct mx_ops *ops = mx_get_ops (ctx->magic);
   int r = 0;
 
-  if (ctx->magic == MUTT_MH || ctx->magic == MUTT_MAILDIR
-      || ctx->magic == MUTT_IMAP || ctx->magic == MUTT_POP)
-  {
-    r = safe_fclose (&(*msg)->fp);
-  }
-  else
-    (*msg)->fp = NULL;
+  if (ops && ops->close_msg)
+    r = ops->close_msg (ctx, *msg);
 
   if ((*msg)->path)
   {
     dprint (1, (debugfile, "mx_close_message (): unlinking %s\n",
-               (*msg)->path));
+            (*msg)->path));
     unlink ((*msg)->path);
     FREE (&(*msg)->path);
   }
diff --git a/pop.c b/pop.c
index bccdc9b9039c48e41322f48c5c6c950c450ec118..9e0a14597cd9659d0b0e70c05221ae0d182a867a 100644 (file)
--- a/pop.c
+++ b/pop.c
@@ -656,6 +656,11 @@ static int pop_fetch_message (CONTEXT* ctx, MESSAGE* msg, int msgno)
   return 0;
 }
 
+static int pop_close_message (CONTEXT *ctx, MESSAGE *msg)
+{
+  return safe_fclose (&msg->fp);
+}
+
 /* update POP mailbox - delete messages from server */
 int pop_sync_mailbox (CONTEXT *ctx, int *index_hint)
 {
@@ -932,5 +937,6 @@ struct mx_ops mx_pop_ops = {
   .open = pop_open_mailbox,
   .close = pop_close_mailbox,
   .open_msg = pop_fetch_message,
+  .close_msg = pop_close_message,
   .check = pop_check_mailbox,
 };