# HG changeset patch
# User Damien Riegel <[email protected]>
# Date 1462391862 14400
# Wed May 04 15:57:42 2016 -0400
# Node ID 693f6409278341aaa5cdb66fb50e73f5714682ac
# Parent d18cd04e3f5a07ea6c3d0c0b624c917a0024e037
create a dedicated structure for mx operations
This commit introduces a dedicated structure for mailbox operations. The
point is to avoid to clobber the context structure with additional
callbacks, and to allow each kind of mailboxes to define its own
structure.
diff -r d18cd04e3f5a -r 693f64092783 imap/imap.c
--- a/imap/imap.c Mon May 09 14:06:59 2016 -0700
+++ b/imap/imap.c Wed May 04 15:57:42 2016 -0400
@@ -554,6 +554,10 @@
return s;
}
+struct mx_ops mx_imap_ops = {
+ .close = imap_close_mailbox,
+};
+
int imap_open_mailbox (CONTEXT* ctx)
{
IMAP_DATA *idata;
@@ -578,7 +582,7 @@
/* once again the context is new */
ctx->data = idata;
- ctx->mx_close = imap_close_mailbox;
+ ctx->mx_ops = &mx_imap_ops;
/* Clean up path and replace the one in the ctx */
imap_fix_path (idata, mx.mbox, buf, sizeof (buf));
diff -r d18cd04e3f5a -r 693f64092783 mh.c
--- a/mh.c Mon May 09 14:06:59 2016 -0700
+++ b/mh.c Wed May 04 15:57:42 2016 -0400
@@ -1161,6 +1161,10 @@
return 0;
}
+struct mx_ops mx_mh_ops = {
+ .close = mh_close_mailbox,
+};
+
/* Read a MH/maildir style mailbox.
*
* args:
@@ -1188,7 +1192,7 @@
if (!ctx->data)
{
ctx->data = safe_calloc(sizeof (struct mh_data), 1);
- ctx->mx_close = mh_close_mailbox;
+ ctx->mx_ops = &mx_mh_ops;
}
data = mh_data (ctx);
diff -r d18cd04e3f5a -r 693f64092783 mutt.h
--- a/mutt.h Mon May 09 14:06:59 2016 -0700
+++ b/mutt.h Wed May 04 15:57:42 2016 -0400
@@ -868,6 +868,13 @@
RIGHTSMAX
};
+struct _context;
+
+struct mx_ops
+{
+ int (*close)(struct _context *);
+};
+
typedef struct _context
{
char *path;
@@ -909,7 +916,7 @@
/* driver hooks */
void *data; /* driver specific data */
- int (*mx_close)(struct _context *);
+ struct mx_ops *mx_ops;
} CONTEXT;
typedef struct
diff -r d18cd04e3f5a -r 693f64092783 mx.c
--- a/mx.c Mon May 09 14:06:59 2016 -0700
+++ b/mx.c Wed May 04 15:57:42 2016 -0400
@@ -709,8 +709,8 @@
* XXX: really belongs in mx_close_mailbox, but this is a nice hook point */
mutt_buffy_setnotified(ctx->path);
- if (ctx->mx_close)
- ctx->mx_close (ctx);
+ if (ctx->mx_ops)
+ ctx->mx_ops->close (ctx);
if (ctx->subj_hash)
hash_destroy (&ctx->subj_hash, NULL);
diff -r d18cd04e3f5a -r 693f64092783 pop.c
--- a/pop.c Mon May 09 14:06:59 2016 -0700
+++ b/pop.c Wed May 04 15:57:42 2016 -0400
@@ -396,6 +396,10 @@
return (new_count - old_count);
}
+struct mx_ops mx_pop_ops = {
+ .close = pop_close_mailbox,
+};
+
/* open POP mailbox - fetch only headers */
int pop_open_mailbox (CONTEXT *ctx)
{
@@ -426,7 +430,7 @@
pop_data = safe_calloc (1, sizeof (POP_DATA));
pop_data->conn = conn;
ctx->data = pop_data;
- ctx->mx_close = pop_close_mailbox;
+ ctx->mx_ops = &mx_pop_ops;
if (pop_open_connection (pop_data) < 0)
return -1;