mutt_bit_isset (((IMAP_DATA*) ctx->data)->rights, bit));
}
+static int imap_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
+{
+ char tmp[_POSIX_PATH_MAX];
+
+ mutt_mktemp (tmp);
+ if ((msg->fp = safe_fopen (tmp, "w")) == NULL)
+ return (-1);
+ msg->path = safe_strdup (tmp);
+ return 0;
+}
+
mx_t* imap_reg_mx (void) {
mx_t* fmt = safe_calloc (1, sizeof (mx_t));
fmt->mx_is_magic = imap_is_magic;
fmt->mx_access = imap_access;
fmt->mx_open_mailbox = imap_open_mailbox;
+ fmt->mx_open_new_message = imap_open_new_message;
fmt->mx_acl_check = acl_check_imap;
fmt->mx_fastclose_mailbox = imap_close_mailbox;
fmt->mx_sync_mailbox = imap_sync_mailbox;
};
-int mbox_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
+static int mbox_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
{
msg->fp = dest->fp;
return 0;
fmt->mx_is_magic = mbox_is_magic;
fmt->mx_access = access;
fmt->mx_open_mailbox = mbox_open_mailbox;
+ fmt->mx_open_new_message = mbox_open_new_message;
fmt->mx_sync_mailbox = mbox_sync_mailbox;
return (fmt);
}
int mbox_check_empty (const char *);
int mbox_is_magic (const char*, struct stat*);
int mbox_strict_cmp_headers (const HEADER *, const HEADER *);
-int mbox_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr);
mx_t* mbox_reg_mx (void);
mx_t* mmdf_reg_mx (void);
* Open a new (temporary) message in an MH folder.
*/
-int mh_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
+static int mh_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
{
return mh_mkstemp (dest, &msg->fp, &msg->path);
}
*
*/
-int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
+static int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
{
int fd;
char path[_POSIX_PATH_MAX];
fmt->mx_check_empty = mh_check_empty;
fmt->mx_is_magic = mh_is_magic;
fmt->mx_open_mailbox = mh_read_dir;
+ fmt->mx_open_new_message = mh_open_new_message;
return (fmt);
}
fmt->mx_check_empty = maildir_check_empty;
fmt->mx_is_magic = maildir_is_magic;
fmt->mx_open_mailbox = maildir_read_dir;
+ fmt->mx_open_new_message = maildir_open_new_message;
return (fmt);
}
int mh_check_mailbox (CONTEXT *, int *);
int mh_buffy (const char *);
int mh_commit_message (CONTEXT *, MESSAGE *, HEADER *);
-int mh_open_new_message (MESSAGE *, CONTEXT *, HEADER *);
int maildir_check_mailbox (CONTEXT *, int *);
int maildir_commit_message (CONTEXT *, MESSAGE *, HEADER *);
-int maildir_open_new_message (MESSAGE *, CONTEXT *, HEADER *);
FILE *maildir_open_find_message (const char *, const char *);
mx_t* maildir_reg_mx (void);
return (rc);
}
-#ifdef USE_IMAP
-int imap_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
-{
- char tmp[_POSIX_PATH_MAX];
-
- mutt_mktemp (tmp);
- if ((msg->fp = safe_fopen (tmp, "w")) == NULL)
- return (-1);
- msg->path = safe_strdup (tmp);
- return 0;
-}
-#endif
-
/* args:
* dest destintation mailbox
* hdr message being copied (required for maildir support, because
MESSAGE *mx_open_new_message (CONTEXT * dest, HEADER * hdr, int flags)
{
MESSAGE *msg;
- int (*func) (MESSAGE *, CONTEXT *, HEADER *);
ADDRESS *p = NULL;
- switch (dest->magic) {
- case M_MMDF:
- case M_MBOX:
- func = mbox_open_new_message;
- break;
- case M_MAILDIR:
- func = maildir_open_new_message;
- break;
- case M_MH:
- func = mh_open_new_message;
- break;
-#ifdef USE_IMAP
- case M_IMAP:
- func = imap_open_new_message;
- break;
-#endif
- default:
- dprint (1,
- (debugfile,
- "mx_open_new_message(): function unimplemented for mailbox type %d.\n",
- dest->magic));
+ if (!MX_IDX(dest->magic-1)) {
+ dprint (1, (debugfile, "mx_open_new_message(): function "
+ "unimplemented for mailbox type %d.\n", dest->magic));
return (NULL);
}
if (msg->received == 0)
time (&msg->received);
- if (func (msg, dest, hdr) == 0) {
+ if (MX_COMMAND(dest->magic-1,mx_open_new_message)(msg, dest, hdr) == 0) {
if (dest->magic == M_MMDF)
fputs (MMDF_SEP, msg->fp);
break; \
}
+typedef struct {
+ FILE *fp; /* pointer to the message data */
+ char *path; /* path to temp file */
+ short magic; /* type of mailbox this message belongs to */
+ short write; /* nonzero if message is open for writing */
+ struct {
+ unsigned read:1;
+ unsigned flagged:1;
+ unsigned replied:1;
+ } flags;
+ time_t received; /* the time at which this message was received */
+} MESSAGE;
+
typedef struct {
/* folder magic */
int type;
int (*mx_access) (const char*, int);
/* read mailbox into ctx structure */
int (*mx_open_mailbox) (CONTEXT*);
+ /* open new message */
+ int (*mx_open_new_message) (MESSAGE*, CONTEXT*, HEADER*);
/* check ACL flags; if not implemented, always assume granted
* permissions */
int (*mx_acl_check) (CONTEXT*, int);
M_FLAGS /* nondestructive flags change (IMAP) */
};
-typedef struct {
- FILE *fp; /* pointer to the message data */
- char *path; /* path to temp file */
- short magic; /* type of mailbox this message belongs to */
- short write; /* nonzero if message is open for writing */
- struct {
- unsigned read:1;
- unsigned flagged:1;
- unsigned replied:1;
- } flags;
- time_t received; /* the time at which this message was received */
-} MESSAGE;
-
WHERE short DefaultMagic INITVAL (M_MBOX);
/*