#include "config.h"
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "mailbox.h"
#include "progress/lib.h"
#include "edata.h"
#include "hcache.h"
#include "mdata.h"
#include "mdemail.h"
#include "mx.h"
#include "shared.h"
#include "sort.h"
#include "monitor.h"
Go to the source code of this file.
Macros | |
#define | MMC_NO_DIRS 0 |
No directories changed. | |
#define | MMC_NEW_DIR (1 << 0) |
'new' directory changed | |
#define | MMC_CUR_DIR (1 << 1) |
'cur' directory changed | |
Functions | |
struct Email * | maildir_email_new (void) |
Create a Maildir Email. | |
void | maildir_parse_flags (struct Email *e, const char *path) |
Parse Maildir file flags. | |
bool | maildir_parse_stream (FILE *fp, const char *fname, bool is_old, struct Email *e) |
Parse a Maildir message. | |
bool | maildir_parse_message (const char *fname, bool is_old, struct Email *e) |
Actually parse a maildir message. | |
static int | maildir_move_to_mailbox (struct Mailbox *m, const struct MdEmailArray *mda) |
Copy the Maildir list to the Mailbox. | |
static int | maildir_sort_inode (const void *a, const void *b, void *sdata) |
Compare two Maildirs by inode number - Implements sort_t -. | |
static int | maildir_parse_dir (struct Mailbox *m, struct MdEmailArray *mda, const char *subdir, struct Progress *progress) |
Read a Maildir mailbox. | |
static void | maildir_delayed_parsing (struct Mailbox *m, struct MdEmailArray *mda, struct Progress *progress) |
This function does the second parsing pass. | |
static void | maildir_check_dir (struct Mailbox *m, const char *dir_name, bool check_new, bool check_stats) |
Check for new mail / mail counts. | |
static int | maildir_read_dir (struct Mailbox *m, const char *subdir) |
Read a Maildir style mailbox. | |
static enum MxStatus | maildir_check (struct Mailbox *m) |
Check for new mail. | |
void | maildir_update_mtime (struct Mailbox *m) |
Update our record of the Maildir modification time. | |
enum MxOpenReturns | maildir_mbox_open (struct Mailbox *m) |
Open a Mailbox - Implements MxOps::mbox_open() -. | |
bool | maildir_mbox_open_append (struct Mailbox *m, OpenMailboxFlags flags) |
Open a Mailbox for appending - Implements MxOps::mbox_open_append() -. | |
enum MxStatus | maildir_mbox_check (struct Mailbox *m) |
Check for new mail - Implements MxOps::mbox_check() -. | |
enum MxStatus | maildir_mbox_check_stats (struct Mailbox *m, uint8_t flags) |
Check the Mailbox statistics - Implements MxOps::mbox_check_stats() -. | |
enum MxStatus | maildir_mbox_sync (struct Mailbox *m) |
Save changes to the Mailbox - Implements MxOps::mbox_sync() -. | |
enum MxStatus | maildir_mbox_close (struct Mailbox *m) |
Close a Mailbox - Implements MxOps::mbox_close() -. | |
Maildir Mailbox.
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 mailbox.c.
struct Email * maildir_email_new | ( | void | ) |
Create a Maildir Email.
ptr | Newly created Email |
Create a new Email and attach MaildirEmailData.
Definition at line 68 of file mailbox.c.
void maildir_parse_flags | ( | struct Email * | e, |
const char * | path | ||
) |
Parse Maildir file flags.
e | |
path | Path to email file |
Definition at line 82 of file mailbox.c.
bool maildir_parse_stream | ( | FILE * | fp, |
const char * | fname, | ||
bool | is_old, | ||
struct Email * | e | ||
) |
Parse a Maildir message.
fp | Message file handle |
fname | Message filename |
is_old | true, if the email is old (read) |
e |
true | Success |
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 153 of file mailbox.c.
bool maildir_parse_message | ( | const char * | fname, |
bool | is_old, | ||
struct Email * | e | ||
) |
Actually parse a maildir message.
true | Success |
This may also be used to fill out a fake header structure generated by lazy maildir parsing.
Definition at line 190 of file mailbox.c.
|
static |
Copy the Maildir list to the Mailbox.
[in] | m | Mailbox |
[out] | mda | Maildir array to copy, then free |
num | Number of new emails |
0 | Error |
Definition at line 211 of file mailbox.c.
|
static |
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 269 of file mailbox.c.
|
static |
This function does the second parsing pass.
[in] | m | Mailbox |
[out] | mda | Maildir array to parse |
[in] | progress | Progress bar |
Definition at line 334 of file mailbox.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 385 of file mailbox.c.
|
static |
Read a Maildir style mailbox.
m | Mailbox |
subdir | Subdir of the maildir mailbox to read from |
0 | Success |
-1 | Failure |
Definition at line 481 of file mailbox.c.
Check for new mail.
m | Mailbox |
enum | MxStatus |
This function handles arrival of new mail and reopening of maildir folders. The basic idea here is we check to see if either the new or cur subdirectories have changed, and if so, we scan them for the list of files. We check for newly added messages, and then merge the flags messages we already knew about. We don't treat either subdirectory differently, as mail could be copied directly into the cur directory from another agent.
Definition at line 539 of file mailbox.c.
void maildir_update_mtime | ( | struct Mailbox * | m | ) |
Update our record of the Maildir modification time.
m | Mailbox |
Definition at line 716 of file mailbox.c.