2 * This file is part of mutt-ng, see http://www.muttng.org/.
3 * It's licensed under the GNU General Public License,
4 * please see the file GPL in the top level source directory.
12 #include <lib-lib/mem.h>
13 #include <lib-lib/str.h>
16 #include "imap_private.h"
24 int imap_is_magic (const char* path, struct stat* st) {
28 s = url_check_scheme (NONULL (path));
29 return ((s == U_IMAP || s == U_IMAPS) ? M_IMAP : -1);
32 static int acl_check_imap (CONTEXT* ctx, int bit) {
33 return (!mutt_bit_isset (((IMAP_DATA*) ctx->data)->capabilities, ACL) ||
34 mutt_bit_isset (((IMAP_DATA*) ctx->data)->rights, bit));
37 static int imap_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
39 char tmp[_POSIX_PATH_MAX];
42 if ((msg->fp = safe_fopen (tmp, "w")) == NULL) {
46 msg->path = m_strdup(tmp);
50 /* this ugly kludge is required since the last int to
51 * imap_check_mailbox() doesn't mean 'lock' but 'force'... */
52 static int _imap_check_mailbox (CONTEXT* ctx, int* index_hint, int lock) {
53 return (imap_check_mailbox (ctx, index_hint, 0));
56 static int imap_commit_message (MESSAGE* msg, CONTEXT* ctx) {
59 if ((r = safe_fclose (&msg->fp)) == 0)
60 r = imap_append_message (ctx, msg);
64 mx_t* imap_reg_mx (void) {
65 mx_t* fmt = p_new(mx_t, 1);
67 /* make up mx_t record... */
69 fmt->mx_is_magic = imap_is_magic;
70 fmt->mx_access = imap_access;
71 fmt->mx_open_mailbox = imap_open_mailbox;
72 fmt->mx_open_new_message = imap_open_new_message;
73 fmt->mx_acl_check = acl_check_imap;
74 fmt->mx_fastclose_mailbox = imap_close_mailbox;
75 fmt->mx_sync_mailbox = imap_sync_mailbox;
76 fmt->mx_check_mailbox = _imap_check_mailbox;
77 fmt->mx_commit_message = imap_commit_message;