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.
7 #include <lib-lib/lib-lib.h>
10 #include "imap_private.h"
15 int imap_is_magic (const char* path, struct stat* st __attribute__ ((unused))) {
19 s = url_check_scheme (NONULL (path));
20 return ((s == U_IMAP || s == U_IMAPS) ? M_IMAP : -1);
23 static int acl_check_imap (CONTEXT* ctx, int bit) {
24 return (!mutt_bit_isset (((IMAP_DATA*) ctx->data)->capabilities, ACL) ||
25 mutt_bit_isset (((IMAP_DATA*) ctx->data)->rights, bit));
28 static int imap_open_new_message (MESSAGE * msg,
29 CONTEXT * dest __attribute__ ((unused)),
30 HEADER * hdr __attribute__ ((unused)))
32 char tmp[_POSIX_PATH_MAX];
35 if ((msg->fp = safe_fopen (tmp, "w")) == NULL) {
39 msg->path = m_strdup(tmp);
43 /* this ugly kludge is required since the last int to
44 * imap_check_mailbox() doesn't mean 'lock' but 'force'... */
45 static int _imap_check_mailbox (CONTEXT* ctx,
47 int lock __attribute__ ((unused))) {
48 return (imap_check_mailbox (ctx, index_hint, 0));
51 static int imap_commit_message (MESSAGE* msg, CONTEXT* ctx) {
54 if ((r = safe_fclose (&msg->fp)) == 0)
55 r = imap_append_message (ctx, msg);
59 mx_t* imap_reg_mx (void) {
60 mx_t* fmt = p_new(mx_t, 1);
62 /* make up mx_t record... */
64 fmt->mx_is_magic = imap_is_magic;
65 fmt->mx_access = imap_access;
66 fmt->mx_open_mailbox = imap_open_mailbox;
67 fmt->mx_open_new_message = imap_open_new_message;
68 fmt->mx_acl_check = acl_check_imap;
69 fmt->mx_fastclose_mailbox = imap_close_mailbox;
70 fmt->mx_sync_mailbox = imap_sync_mailbox;
71 fmt->mx_check_mailbox = _imap_check_mailbox;
72 fmt->mx_commit_message = imap_commit_message;