f30dbbd088a7dd620b0f9b7e4cfaccd5b21aa402
[apps/madmutt.git] / pop / mx_pop.c
1 /*
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.
5  */
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif
9
10 #include <sys/stat.h>
11
12 #include <lib-lib/mem.h>
13 #include <lib-lib/str.h>
14 #include <lib-lib/url.h>
15
16 #include "mutt.h"
17 #include "pop.h"
18
19 #include "mx.h"
20 #include "mx_pop.h"
21
22 static int pop_is_magic (const char* path, struct stat* st) {
23   url_scheme_t s = url_check_scheme (NONULL (path));
24   return ((s == U_POP || s == U_POPS) ? M_POP : -1);
25 }
26
27 static int acl_check_pop (CONTEXT* ctx, int bit) {
28   switch (bit) {
29     case ACL_INSERT:    /* editing messages */
30     case ACL_WRITE:     /* change importance */
31       return (0);
32     case ACL_DELETE:    /* (un)deletion */
33     case ACL_SEEN:      /* mark as read */
34       return (1);
35     default:
36       return (0);
37   }
38 }
39
40 mx_t* pop_reg_mx (void) {
41   mx_t* fmt = p_new(mx_t, 1);
42
43   /* make up mx_t record... */
44   fmt->type = M_POP;
45   fmt->mx_is_magic = pop_is_magic;
46   fmt->mx_open_mailbox = pop_open_mailbox;
47   fmt->mx_acl_check = acl_check_pop;
48   fmt->mx_fastclose_mailbox = pop_close_mailbox;
49   fmt->mx_sync_mailbox = pop_sync_mailbox;
50   fmt->mx_check_mailbox = pop_check_mailbox;
51   return (fmt);
52 }