# HG changeset patch
# User Damien Riegel <[email protected]>
# Date 1462391862 14400
# Wed May 04 15:57:42 2016 -0400
# Node ID eb3c1cd64366352abc9f182d7269ac24298533d0
# 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 eb3c1cd64366 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
@@ -578,7 +578,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));
@@ -2038,3 +2038,7 @@
return -1;
}
+
+struct mx_ops mx_imap_ops = {
+ .close = imap_close_mailbox,
+};
diff -r d18cd04e3f5a -r eb3c1cd64366 imap/imap.h
--- a/imap/imap.h Mon May 09 14:06:59 2016 -0700
+++ b/imap/imap.h Wed May 04 15:57:42 2016 -0400
@@ -48,6 +48,8 @@
void imap_allow_reopen (CONTEXT *ctx);
void imap_disallow_reopen (CONTEXT *ctx);
+extern struct mx_ops mx_imap_ops;
+
/* browse.c */
int imap_browse (char* path, struct browser_state* state);
int imap_mailbox_state (const char* path, struct mailbox_state* state);
diff -r d18cd04e3f5a -r eb3c1cd64366 mh.c
--- a/mh.c Mon May 09 14:06:59 2016 -0700
+++ b/mh.c Wed May 04 15:57:42 2016 -0400
@@ -1188,7 +1188,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);
@@ -2348,3 +2348,7 @@
return 0;
}
+
+struct mx_ops mx_mh_ops = {
+ .close = mh_close_mailbox,
+};
diff -r d18cd04e3f5a -r eb3c1cd64366 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 eb3c1cd64366 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 eb3c1cd64366 mx.h
--- a/mx.h Mon May 09 14:06:59 2016 -0700
+++ b/mx.h Wed May 04 15:57:42 2016 -0400
@@ -82,5 +82,6 @@
int mx_lock_file (const char *, int, int, int, int);
int mx_unlock_file (const char *path, int fd, int dot);
+extern struct mx_ops mx_mh_ops;
#endif
diff -r d18cd04e3f5a -r eb3c1cd64366 pop.c
--- a/pop.c Mon May 09 14:06:59 2016 -0700
+++ b/pop.c Wed May 04 15:57:42 2016 -0400
@@ -426,7 +426,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;
@@ -928,3 +928,7 @@
mutt_socket_close (conn);
FREE (&pop_data);
}
+
+struct mx_ops mx_pop_ops = {
+ .close = pop_close_mailbox,
+};
diff -r d18cd04e3f5a -r eb3c1cd64366 pop.h
--- a/pop.h Mon May 09 14:06:59 2016 -0700
+++ b/pop.h Wed May 04 15:57:42 2016 -0400
@@ -112,4 +112,6 @@
int pop_close_mailbox (CONTEXT *);
void pop_fetch_mail (void);
+extern struct mx_ops mx_pop_ops;
+
#endif