Maildir local mailbox type. More...
#include "config.h"
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <utime.h>
#include "private.h"
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "lib.h"
#include "progress/lib.h"
#include "copy.h"
#include "edata.h"
#include "mdata.h"
#include "mdemail.h"
#include "mutt_globals.h"
#include "mx.h"
#include "monitor.h"
#include "hcache/lib.h"
#include "notmuch/lib.h"
Go to the source code of this file.
Macros | |
#define | MMC_NO_DIRS 0 |
No directories changed. More... | |
#define | MMC_NEW_DIR (1 << 0) |
'new' directory changed More... | |
#define | MMC_CUR_DIR (1 << 1) |
'cur' directory changed More... | |
Functions | |
static void | maildir_check_dir (struct Mailbox *m, const char *dir_name, bool check_new, bool check_stats) |
Check for new mail / mail counts. More... | |
static int | ch_compare (const void *a, const void *b) |
qsort() callback to sort characters More... | |
void | maildir_gen_flags (char *dest, size_t destlen, struct Email *e) |
Generate the Maildir flags for an email. More... | |
int | maildir_commit_message (struct Mailbox *m, struct Message *msg, struct Email *e) |
Commit a message to a maildir folder. More... | |
int | maildir_rewrite_message (struct Mailbox *m, int msgno) |
Sync a message in an MH folder. More... | |
int | maildir_sync_message (struct Mailbox *m, int msgno) |
Sync an email to a Maildir folder. More... | |
void | maildir_update_mtime (struct Mailbox *m) |
Update our record of the Maildir modification time. More... | |
static int | maildir_cmp_inode (const void *a, const void *b) |
Compare two Maildirs by inode number - Implements sort_t -. More... | |
int | maildir_parse_dir (struct Mailbox *m, struct MdEmailArray *mda, const char *subdir, struct Progress *progress) |
Read a Maildir mailbox. More... | |
size_t | maildir_hcache_keylen (const char *fn) |
Calculate the length of the Maildir path. More... | |
void | maildir_delayed_parsing (struct Mailbox *m, struct MdEmailArray *mda, struct Progress *progress) |
This function does the second parsing pass. More... | |
int | maildir_read_dir (struct Mailbox *m, const char *subdir) |
Read a Maildir style mailbox. More... | |
void | maildir_canon_filename (struct Buffer *dest, const char *src) |
Generate the canonical filename for a Maildir folder. More... | |
static FILE * | maildir_open_find_message_dir (const char *folder, const char *unique, const char *subfolder, char **newname) |
Find a message in a maildir folder. More... | |
void | maildir_parse_flags (struct Email *e, const char *path) |
Parse Maildir file flags. More... | |
struct Email * | maildir_parse_stream (enum MailboxType type, FILE *fp, const char *fname, bool is_old, struct Email *e) |
Parse a Maildir message. More... | |
struct Email * | maildir_parse_message (enum MailboxType type, const char *fname, bool is_old, struct Email *e) |
Actually parse a maildir message. More... | |
bool | maildir_sync_mailbox_message (struct Mailbox *m, int msgno, struct HeaderCache *hc) |
Save changes to the mailbox. More... | |
FILE * | maildir_open_find_message (const char *folder, const char *msg, char **newname) |
Find a new. More... | |
int | maildir_check_empty (const char *path) |
Is the mailbox empty. More... | |
bool | maildir_ac_owns_path (struct Account *a, const char *path) |
Check whether an Account own a Mailbox path - Implements MxOps::ac_owns_path() -. More... | |
bool | maildir_ac_add (struct Account *a, struct Mailbox *m) |
Add a Mailbox to an Account - Implements MxOps::ac_add() -. More... | |
static enum MxOpenReturns | maildir_mbox_open (struct Mailbox *m) |
Open a Mailbox - Implements MxOps::mbox_open() -. More... | |
static bool | maildir_mbox_open_append (struct Mailbox *m, OpenMailboxFlags flags) |
Open a Mailbox for appending - Implements MxOps::mbox_open_append() -. More... | |
enum MxStatus | maildir_mbox_check (struct Mailbox *m) |
Check for new mail - Implements MxOps::mbox_check() -. More... | |
static enum MxStatus | maildir_mbox_check_stats (struct Mailbox *m, uint8_t flags) |
Check the Mailbox statistics - Implements MxOps::mbox_check_stats() -. More... | |
enum MxStatus | maildir_mbox_sync (struct Mailbox *m) |
Save changes to the Mailbox - Implements MxOps::mbox_sync() -. More... | |
enum MxStatus | maildir_mbox_close (struct Mailbox *m) |
Close a Mailbox - Implements MxOps::mbox_close() -. More... | |
static bool | maildir_msg_open (struct Mailbox *m, struct Message *msg, int msgno) |
Open an email message in a Mailbox - Implements MxOps::msg_open() -. More... | |
bool | maildir_msg_open_new (struct Mailbox *m, struct Message *msg, const struct Email *e) |
Open a new message in a Mailbox - Implements MxOps::msg_open_new() -. More... | |
static int | maildir_msg_commit (struct Mailbox *m, struct Message *msg) |
Save changes to an email - Implements MxOps::msg_commit() -. More... | |
int | maildir_msg_close (struct Mailbox *m, struct Message *msg) |
Close an email - Implements MxOps::msg_close() -. More... | |
static int | maildir_msg_save_hcache (struct Mailbox *m, struct Email *e) |
Save message to the header cache - Implements MxOps::msg_save_hcache() -. More... | |
int | maildir_path_canon (char *buf, size_t buflen) |
Canonicalise a Mailbox path - Implements MxOps::path_canon() -. More... | |
int | maildir_path_parent (char *buf, size_t buflen) |
Find the parent of a Mailbox path - Implements MxOps::path_parent() -. More... | |
int | maildir_path_pretty (char *buf, size_t buflen, const char *folder) |
Abbreviate a Mailbox path - Implements MxOps::path_pretty() -. More... | |
static enum MailboxType | maildir_path_probe (const char *path, const struct stat *st) |
Is this a Maildir Mailbox? - Implements MxOps::path_probe() -. More... | |
Variables | |
struct MxOps | MxMaildirOps |
Maildir Mailbox - Implements MxOps -. More... | |
Maildir local mailbox type.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file maildir.c.
|
static |
Check for new mail / mail counts.
m | Mailbox to check |
dir_name | Path to Mailbox |
check_new | if true, check for new mail |
check_stats | if true, count total, new, and flagged messages |
Checks the specified maildir subdir (cur or new) for new mail or mail counts.
Definition at line 86 of file maildir.c.
|
static |
void maildir_gen_flags | ( | char * | dest, |
size_t | destlen, | ||
struct Email * | e | ||
) |
Generate the Maildir flags for an email.
Definition at line 186 of file maildir.c.
Commit a message to a maildir folder.
0 | Success |
-1 | Failure |
msg->path contains the file name of a file in tmp/. We take the flags from this file's name.
m is the mail folder we commit to.
e is a header structure to which we write the message's new file name. This is used in the mh and maildir folder sync routines. When this routine is invoked from mx_msg_commit(), e is NULL.
msg->path looks like this:
tmp/{cur,new}.neomutt-HOSTNAME-PID-COUNTER:flags
See also maildir_msg_open_new().
Definition at line 237 of file maildir.c.
int maildir_rewrite_message | ( | struct Mailbox * | m, |
int | msgno | ||
) |
Sync a message in an MH folder.
m | Mailbox |
msgno | Index number |
0 | Success |
-1 | Error |
Definition at line 330 of file maildir.c.
int maildir_sync_message | ( | struct Mailbox * | m, |
int | msgno | ||
) |
Sync an email to a Maildir folder.
m | Mailbox |
msgno | Index number |
0 | Success |
-1 | Error |
Definition at line 387 of file maildir.c.
void maildir_update_mtime | ( | struct Mailbox * | m | ) |
Update our record of the Maildir modification time.
m | Mailbox |
Definition at line 477 of file maildir.c.
int maildir_parse_dir | ( | struct Mailbox * | m, |
struct MdEmailArray * | mda, | ||
const char * | subdir, | ||
struct Progress * | progress | ||
) |
Read a Maildir mailbox.
[in] | m | Mailbox |
[out] | mda | Array for results |
[in] | subdir | Subdirectory, e.g. 'new' |
[in] | progress | Progress bar |
0 | Success |
-1 | Error |
-2 | Aborted |
Definition at line 513 of file maildir.c.
size_t maildir_hcache_keylen | ( | const char * | fn | ) |
Calculate the length of the Maildir path.
fn | File name |
num | Length in bytes |
Definition at line 585 of file maildir.c.
void maildir_delayed_parsing | ( | struct Mailbox * | m, |
struct MdEmailArray * | mda, | ||
struct Progress * | progress | ||
) |
This function does the second parsing pass.
[in] | m | Mailbox |
[out] | mda | Maildir array to parse |
[in] | progress | Progress bar |
Definition at line 597 of file maildir.c.
int maildir_read_dir | ( | struct Mailbox * | m, |
const char * | subdir | ||
) |
Read a Maildir style mailbox.
m | Mailbox |
subdir | Subdir of the maildir mailbox to read from |
0 | Success |
-1 | Failure |
Definition at line 671 of file maildir.c.
void maildir_canon_filename | ( | struct Buffer * | dest, |
const char * | src | ||
) |
Generate the canonical filename for a Maildir folder.
Definition at line 725 of file maildir.c.
|
static |
Find a message in a maildir folder.
[in] | folder | Base folder |
[in] | unique | Unique part of filename |
[in] | subfolder | Subfolder to search, e.g. 'cur' |
[out] | newname | File's new name |
ptr | File handle |
These functions try to find a message in a maildir folder when it has moved under our feet. Note that this code is rather expensive, but then again, it's called rarely.
Definition at line 755 of file maildir.c.
void maildir_parse_flags | ( | struct Email * | e, |
const char * | path | ||
) |
Parse Maildir file flags.
e | |
path | Path to email file |
Definition at line 809 of file maildir.c.
struct Email* maildir_parse_stream | ( | enum MailboxType | type, |
FILE * | fp, | ||
const char * | fname, | ||
bool | is_old, | ||
struct Email * | e | ||
) |
Parse a Maildir message.
type | Mailbox type, e.g. MUTT_MAILDIR |
fp | Message file handle |
fname | Message filename |
is_old | true, if the email is old (read) |
e |
ptr | Populated Email |
NULL | on error |
Actually parse a maildir message. This may also be used to fill out a fake header structure generated by lazy maildir parsing.
Definition at line 881 of file maildir.c.
struct Email* maildir_parse_message | ( | enum MailboxType | type, |
const char * | fname, | ||
bool | is_old, | ||
struct Email * | e | ||
) |
Actually parse a maildir message.
type | Mailbox type, e.g. MUTT_MAILDIR |
fname | Message filename |
is_old | true, if the email is old (read) |
e | Email to populate (OPTIONAL) |
ptr | Populated Email |
This may also be used to fill out a fake header structure generated by lazy maildir parsing.
Definition at line 928 of file maildir.c.
bool maildir_sync_mailbox_message | ( | struct Mailbox * | m, |
int | msgno, | ||
struct HeaderCache * | hc | ||
) |
Save changes to the mailbox.
m | Mailbox |
msgno | Index number |
hc | Header cache handle |
true | Success |
false | Error |
Definition at line 948 of file maildir.c.
FILE* maildir_open_find_message | ( | const char * | folder, |
const char * | msg, | ||
char ** | newname | ||
) |
Find a new.
[in] | folder | Maildir path |
[in] | msg | Email path |
[out] | newname | New name, if it has moved |
ptr | File handle |
Definition at line 995 of file maildir.c.