2 * Copyright notice from original mutt:
3 * Copyright (C) 1996-2002 Michael R. Elkins <me@mutt.org>
4 * Copyright (C) 1999-2002 Thomas Roessler <roessler@does-not-exist.org>
6 * This file is part of mutt-ng, see http://www.muttng.org/.
7 * It's licensed under the GNU General Public License,
8 * please see the file GPL in the top level source directory.
13 * when adding code dealing with folders or whatever,
14 * please use these only
23 /* supported mailbox formats
24 XXX: has to be in the same order than mxfmts in mx.c */
52 /* ugly hack to define macro once (for pager+index) */
53 #define CHECK_MX_ACL(c,f,s) if(!mx_acl_check(c,f)) \
56 mutt_error(_("%s not permitted by ACL."), s); \
61 FILE *fp; /* pointer to the message data */
62 char *path; /* path to temp file */
63 short magic; /* type of mailbox this message belongs to */
64 short write; /* nonzero if message is open for writing */
70 time_t received; /* the time at which this message was received */
76 /* may we stat() it? */
77 unsigned int local : 1;
78 /* tests if given path is of its magic */
79 int (*mx_is_magic) (const char*, struct stat*);
80 /* tests if folder is empty */
81 int (*mx_check_empty) (const char*);
83 int (*mx_access) (const char*, int);
84 /* read mailbox into ctx structure */
85 int (*mx_open_mailbox) (CONTEXT*);
86 /* open new message */
87 int (*mx_open_new_message) (MESSAGE*, CONTEXT*, HEADER*);
88 /* check ACL flags; if not implemented, always assume granted
90 int (*mx_acl_check) (CONTEXT*, int);
91 /* check for new mail; see mx_check_mailbox() below for return vals */
92 int (*mx_check_mailbox) (CONTEXT*, int*, int);
94 void (*mx_fastclose_mailbox) (CONTEXT*);
95 /* write out changes */
96 int (*mx_sync_mailbox) (CONTEXT*, int, int*);
97 /* commit a message to a folder */
98 int (*mx_commit_message) (MESSAGE*, CONTEXT*);
101 /* flags for mx_open_mailbox() */
102 #define M_NOSORT (1<<0) /* do not sort the mailbox after opening it */
103 #define M_APPEND (1<<1) /* open mailbox for appending messages */
104 #define M_READONLY (1<<2) /* open in read-only mode */
105 #define M_QUIET (1<<3) /* do not print any messages */
106 #define M_NEWFOLDER (1<<4) /* create a new folder - same as M_APPEND, but uses
107 * safe_fopen() for mbox-style folders. */
108 #define M_COUNT (1<<5) /* just do counting? needed to do speed optimizations
111 /* mx_open_new_message() */
112 #define M_ADD_FROM 1 /* add a From_ line */
114 #define MAXLOCKATTEMPT 5
116 WHERE short DefaultMagic INITVAL (M_MBOX);
119 * please use the following _ONLY_ when doing "something"
123 CONTEXT *mx_open_mailbox (const char *, int, CONTEXT *);
125 MESSAGE *mx_open_message (CONTEXT *, int);
126 MESSAGE *mx_open_new_message (CONTEXT *, HEADER *, int);
128 void mx_fastclose_mailbox (CONTEXT *);
130 int mx_close_mailbox (CONTEXT *, int *);
131 int mx_sync_mailbox (CONTEXT *, int *);
132 int mx_commit_message (MESSAGE *, CONTEXT *);
133 int mx_close_message (MESSAGE **);
135 /* determines magic for given folder */
136 int mx_get_magic (const char*);
137 /* sets/parses DefaultMagic */
138 int mx_set_magic (const char *);
139 /* tests whether given folder magic is (valid and) local */
140 int mx_is_local (int);
142 /* return values from mx_check_mailbox() */
144 M_NEW_MAIL = 1, /* new mail received in mailbox */
145 M_LOCKED, /* couldn't lock the mailbox */
146 M_REOPENED, /* mailbox was reopened */
147 M_FLAGS /* nondestructive flags change (IMAP) */
149 int mx_check_mailbox (CONTEXT *, int *, int);
151 int mx_access (const char *, int);
152 int mx_check_empty (const char *);
154 int mx_acl_check (CONTEXT*, int);
156 void mx_alloc_memory (CONTEXT *);
157 void mx_update_context (CONTEXT *, int);
158 void mx_update_tables (CONTEXT *, int);
160 int mx_lock_file (const char *, int, int, int, int);
161 int mx_unlock_file (const char *path, int fd, int dot);
163 int mx_rebuild_cache (void);
164 void mutt_parse_mime_message (CONTEXT * ctx, HEADER *);