---
imap/imap.c | 1 +
imap/imap_private.h | 1 +
imap/message.c | 5 +++++
mbox.c | 9 +++++++++
mh.c | 7 +++++++
mutt.h | 1 +
mx.c | 12 ++++--------
pop.c | 6 ++++++
8 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/imap/imap.c b/imap/imap.c
index ce802b1..5d59769 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -2071,6 +2071,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,
};
diff --git a/imap/imap_private.h b/imap/imap_private.h
index f5dd83f..8cd610a 100644
--- a/imap/imap_private.h
+++ b/imap/imap_private.h
@@ -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
diff --git a/imap/message.c b/imap/message.c
index f631617..917e987 100644
--- a/imap/message.c
+++ b/imap/message.c
@@ -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 fb3f5b5..270d79e 100644
--- a/mbox.c
+++ b/mbox.c
@@ -458,6 +458,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;
@@ -1286,6 +1293,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,
};
@@ -1294,6 +1302,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 6a00cab..90549ba 100644
--- a/mh.c
+++ b/mh.c
@@ -1363,6 +1363,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.
*
@@ -2439,6 +2444,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,
};
@@ -2447,6 +2453,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 9e728b2..afe7132 100644
--- a/mutt.h
+++ b/mutt.h
@@ -894,6 +894,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 b2887eb..af95ec6 100644
--- a/mx.c
+++ b/mx.c
@@ -1392,20 +1392,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 bccdc9b..9e0a145 100644
--- 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,
};
--
2.8.3