summaryrefslogtreecommitdiffstats
path: root/imap
diff options
context:
space:
mode:
authorDamien Riegel <damien.riegel@gmail.com>2016-05-12 12:41:25 -0700
committerDamien Riegel <damien.riegel@gmail.com>2016-05-12 12:41:25 -0700
commitd22efaae6e4ec48aad0da1324278a567b5b3326a (patch)
tree0713fd46bb54780c753d34e228e0523cd10036c2 /imap
parent740c8600dbb82a03f99370dd293a026ec5d56492 (diff)
Start decoupling mailbox operations.
Introduce a dedicated structure for mailbox operations: struct mx_ops. Move the open and close operations into that structure. Assign this structure to the context in mx_open_mailbox. This is currently based on the "magic" for the mailbox type, but may be refactored in the future. Add a stub mbox_close_mailbox function. This function does nothing, the main purpose is to introduce a mx_ops structure for mbox, so its usage is similar to mh/imap/pop. We reuse the name that was made available by the previous commmit. Note that the actual closing of the descriptor is done in mx.c. To be more consistent with other mailboxes, introduce functions mh_open_mailbox and maildir_open_mailbox, and create a dedicated structure for mmdf.
Diffstat (limited to 'imap')
-rw-r--r--imap/imap.c8
-rw-r--r--imap/imap.h3
2 files changed, 8 insertions, 3 deletions
diff --git a/imap/imap.c b/imap/imap.c
index 228b3b29..e9e84191 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -554,7 +554,7 @@ static char* imap_get_flags (LIST** hflags, char* s)
return s;
}
-int imap_open_mailbox (CONTEXT* ctx)
+static int imap_open_mailbox (CONTEXT* ctx)
{
IMAP_DATA *idata;
IMAP_STATUS* status;
@@ -578,7 +578,6 @@ int imap_open_mailbox (CONTEXT* ctx)
/* once again the context is new */
ctx->data = idata;
- ctx->mx_close = imap_close_mailbox;
/* Clean up path and replace the one in the ctx */
imap_fix_path (idata, mx.mbox, buf, sizeof (buf));
@@ -2038,3 +2037,8 @@ int imap_complete(char* dest, size_t dlen, char* path) {
return -1;
}
+
+struct mx_ops mx_imap_ops = {
+ .open = imap_open_mailbox,
+ .close = imap_close_mailbox,
+};
diff --git a/imap/imap.h b/imap/imap.h
index a914b404..132ae2b9 100644
--- a/imap/imap.h
+++ b/imap/imap.h
@@ -35,7 +35,6 @@ typedef struct
int imap_access (const char*, int);
int imap_check_mailbox (CONTEXT *ctx, int *index_hint, int force);
int imap_delete_mailbox (CONTEXT* idata, IMAP_MBOX mx);
-int imap_open_mailbox (CONTEXT *ctx);
int imap_open_mailbox_append (CONTEXT *ctx);
int imap_sync_mailbox (CONTEXT *ctx, int expunge, int *index_hint);
int imap_close_mailbox (CONTEXT *ctx);
@@ -48,6 +47,8 @@ int imap_complete (char* dest, size_t dlen, char* path);
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);