imap_access,
imap_open_mailbox,
imap_open_new_message,
+ imap_fetch_message,
acl_check_imap,
_imap_check_mailbox,
imap_close_mailbox,
NULL,
NULL,
NULL,
+ NULL,
};
return 0;
}
+static int mbox_open_message(MESSAGE *msg, CONTEXT *ctx, int msgno)
+{
+ msg->fp = ctx->fp;
+ return 0;
+}
+
/* prototypes */
static int mbox_reopen_mailbox (CONTEXT*, int*);
access,
mbox_open_mailbox,
mbox_open_new_message,
+ mbox_open_message,
NULL,
mbox_check_mailbox,
NULL,
return 0;
}
+static int maildir_open_message(MESSAGE *msg, CONTEXT *ctx, int msgno)
+{
+ HEADER *cur = ctx->hdrs[msgno];
+ char path[_POSIX_PATH_MAX];
+
+ snprintf (path, sizeof (path), "%s/%s", ctx->path, cur->path);
+ if ((msg->fp = fopen(path, "r")) == NULL
+ && errno == ENOENT && ctx->magic == M_MAILDIR) {
+ msg->fp = maildir_open_find_message (ctx->path, cur->path);
+ }
+
+ if (msg->fp == NULL) {
+ mutt_perror (path);
+ return -1;
+ }
+ return 0;
+}
/*
* Commit a message to a maildir folder.
access,
maildir_read_dir,
maildir_open_new_message,
+ maildir_open_message,
NULL,
maildir_check_mailbox,
NULL,
access,
mh_read_dir,
mh_open_new_message,
+ maildir_open_message,
NULL,
mh_check_mailbox,
NULL,
#define MAXLOCKATTEMPT 5
-
static mx_t const *mxfmts[] = {
&mbox_mx,
&mh_mx,
*/
MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags)
{
+
MESSAGE *msg;
address_t *p = NULL;
/* return a stream pointer for a message */
MESSAGE *mx_open_message (CONTEXT * ctx, int msgno)
{
- MESSAGE *msg;
-
- msg = p_new(MESSAGE, 1);
- switch (msg->magic = ctx->magic) {
- case M_MBOX:
- msg->fp = ctx->fp;
- break;
-
- case M_MH:
- case M_MAILDIR:
- {
- HEADER *cur = ctx->hdrs[msgno];
- char path[_POSIX_PATH_MAX];
-
- snprintf (path, sizeof (path), "%s/%s", ctx->path, cur->path);
-
- if ((msg->fp = fopen (path, "r")) == NULL && errno == ENOENT &&
- ctx->magic == M_MAILDIR)
- msg->fp = maildir_open_find_message (ctx->path, cur->path);
-
- if (msg->fp == NULL) {
- mutt_perror (path);
- p_delete(&msg);
- }
- }
- break;
+ MESSAGE *msg;
- case M_IMAP:
- {
- if (imap_fetch_message (msg, ctx, msgno) != 0)
- p_delete(&msg);
- break;
- }
+ if (!MX_IDX(ctx->magic) || !mxfmts[ctx->magic - 1]->mx_open_message)
+ return NULL;
- case M_POP:
- {
- if (pop_fetch_message (msg, ctx, msgno) != 0)
+ msg = p_new(MESSAGE, 1);
+ msg->magic = ctx->magic;
+ if (mxfmts[ctx->magic - 1]->mx_open_message(msg, ctx, msgno))
p_delete(&msg);
- break;
- }
-
- default:
- p_delete(&msg);
- break;
- }
- return msg;
+ return msg;
}
/* commit a message to a folder */
int (*mx_open_mailbox) (CONTEXT*);
/* open new message */
int (*mx_open_new_message) (MESSAGE*, CONTEXT*, HEADER*);
+ int (*mx_open_message)(MESSAGE*, CONTEXT*, int);
/* check ACL flags; if not implemented, always assume granted
* permissions */
int (*mx_acl_check) (CONTEXT*, int);
}
}
+static int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno);
+
/* }}} */
mx_t const pop_mx = {
NULL,
pop_open_mailbox,
NULL,
+ pop_fetch_message,
pop_acl_check,
pop_check_mailbox,
pop_close_mailbox,
}
/* fetch message from POP server */
-int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
+static int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
{
int ret;
void *uidl;
#include <lib-mx/mx.h>
extern mx_t const pop_mx;
-
-int pop_fetch_message(MESSAGE *, CONTEXT *, int);
void pop_fetch_mail(void);
#endif