Skip to content

Commit

Permalink
merge mailbox.h and mx.h
Browse files Browse the repository at this point in the history
  • Loading branch information
flatcap committed Aug 3, 2018
1 parent 5ad5948 commit 1d86196
Show file tree
Hide file tree
Showing 34 changed files with 80 additions and 140 deletions.
1 change: 0 additions & 1 deletion browser.c
Expand Up @@ -47,7 +47,6 @@
#include "format_flags.h"
#include "globals.h"
#include "keymap.h"
#include "mailbox.h"
#include "maildir/maildir.h"
#include "menu.h"
#include "mutt_attach.h"
Expand Down
1 change: 0 additions & 1 deletion buffy.c
Expand Up @@ -37,7 +37,6 @@
#include "buffy.h"
#include "context.h"
#include "globals.h"
#include "mailbox.h"
#include "maildir/maildir.h"
#include "menu.h"
#include "mutt_window.h"
Expand Down
1 change: 0 additions & 1 deletion commands.c
Expand Up @@ -45,7 +45,6 @@
#include "hdrline.h"
#include "hook.h"
#include "keymap.h"
#include "mailbox.h"
#include "menu.h"
#include "mutt_curses.h"
#include "mutt_logging.h"
Expand Down
2 changes: 1 addition & 1 deletion complete.c
Expand Up @@ -38,7 +38,7 @@
#include "options.h"
#ifdef USE_IMAP
#include "imap/imap.h"
#include "mailbox.h"
#include "mx.h"
#endif
#ifdef USE_NNTP
#include "nntp/nntp.h"
Expand Down
1 change: 0 additions & 1 deletion compose.c
Expand Up @@ -46,7 +46,6 @@
#include "globals.h"
#include "hook.h"
#include "keymap.h"
#include "mailbox.h"
#include "menu.h"
#include "mutt_attach.h"
#include "mutt_curses.h"
Expand Down
1 change: 0 additions & 1 deletion compress.c
Expand Up @@ -42,7 +42,6 @@
#include "format_flags.h"
#include "globals.h"
#include "hook.h"
#include "mailbox.h"
#include "mutt_curses.h"
#include "muttlib.h"
#include "mx.h"
Expand Down
1 change: 0 additions & 1 deletion copy.c
Expand Up @@ -40,7 +40,6 @@
#include "globals.h"
#include "handler.h"
#include "hdrline.h"
#include "mailbox.h"
#include "mutt_window.h"
#include "muttlib.h"
#include "mx.h"
Expand Down
1 change: 0 additions & 1 deletion curs_main.c
Expand Up @@ -45,7 +45,6 @@
#include "hdrline.h"
#include "hook.h"
#include "keymap.h"
#include "mailbox.h"
#include "menu.h"
#include "mutt_curses.h"
#include "mutt_header.h"
Expand Down
1 change: 0 additions & 1 deletion editmsg.c
Expand Up @@ -43,7 +43,6 @@
#include "copy.h"
#include "curs_lib.h"
#include "globals.h"
#include "mailbox.h"
#include "muttlib.h"
#include "mx.h"
#include "protos.h"
Expand Down
2 changes: 1 addition & 1 deletion hook.c
Expand Up @@ -40,8 +40,8 @@
#include "alias.h"
#include "globals.h"
#include "hdrline.h"
#include "mailbox.h"
#include "muttlib.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
#include "pattern.h"
#ifdef USE_COMPRESSED
Expand Down
1 change: 0 additions & 1 deletion imap/command.c
Expand Up @@ -47,7 +47,6 @@
#include "context.h"
#include "globals.h"
#include "imap/imap.h"
#include "mailbox.h"
#include "menu.h"
#include "message.h"
#include "mutt_account.h"
Expand Down
1 change: 0 additions & 1 deletion imap/imap.c
Expand Up @@ -49,7 +49,6 @@
#include "context.h"
#include "curs_lib.h"
#include "globals.h"
#include "mailbox.h"
#include "message.h"
#include "mutt_account.h"
#include "mutt_logging.h"
Expand Down
1 change: 0 additions & 1 deletion imap/message.c
Expand Up @@ -46,7 +46,6 @@
#include "curs_lib.h"
#include "globals.h"
#include "imap/imap.h"
#include "mailbox.h"
#include "mutt_account.h"
#include "mutt_curses.h"
#include "mutt_logging.h"
Expand Down
1 change: 0 additions & 1 deletion imap/util.c
Expand Up @@ -51,7 +51,6 @@
#include "curs_lib.h"
#include "globals.h"
#include "imap/imap.h"
#include "mailbox.h"
#include "message.h"
#include "mutt_account.h"
#include "mx.h"
Expand Down
1 change: 0 additions & 1 deletion init.c
Expand Up @@ -45,7 +45,6 @@
#include "group.h"
#include "hcache/hcache.h"
#include "keymap.h"
#include "mailbox.h"
#include "menu.h"
#include "mutt_curses.h"
#include "mutt_window.h"
Expand Down
108 changes: 0 additions & 108 deletions mailbox.h

This file was deleted.

1 change: 0 additions & 1 deletion maildir/mh.c
Expand Up @@ -51,7 +51,6 @@
#include "context.h"
#include "copy.h"
#include "globals.h"
#include "mailbox.h"
#include "maildir.h"
#include "mutt_thread.h"
#include "muttlib.h"
Expand Down
1 change: 0 additions & 1 deletion main.c
Expand Up @@ -55,7 +55,6 @@
#include "globals.h"
#include "hook.h"
#include "keymap.h"
#include "mailbox.h"
#include "menu.h"
#include "mutt_curses.h"
#include "mutt_history.h"
Expand Down
1 change: 0 additions & 1 deletion mbox/mbox.c
Expand Up @@ -45,7 +45,6 @@
#include "context.h"
#include "copy.h"
#include "globals.h"
#include "mailbox.h"
#include "mutt_header.h"
#include "mutt_thread.h"
#include "muttlib.h"
Expand Down
1 change: 0 additions & 1 deletion mutt_attach.c
Expand Up @@ -41,7 +41,6 @@
#include "filter.h"
#include "globals.h"
#include "handler.h"
#include "mailbox.h"
#include "muttlib.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
Expand Down
2 changes: 1 addition & 1 deletion mutt_lua.c
Expand Up @@ -34,10 +34,10 @@
#include "mutt.h"
#include "mutt_lua.h"
#include "globals.h"
#include "mailbox.h"
#include "mutt_commands.h"
#include "mutt_options.h"
#include "muttlib.h"
#include "mx.h"
#include "myvar.h"

/**
Expand Down
2 changes: 1 addition & 1 deletion mutt_parse.c
Expand Up @@ -29,7 +29,7 @@
#include "mutt.h"
#include "mutt_parse.h"
#include "globals.h"
#include "mailbox.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"

struct Context;
Expand Down
1 change: 0 additions & 1 deletion muttlib.c
Expand Up @@ -47,7 +47,6 @@
#include "format_flags.h"
#include "globals.h"
#include "hook.h"
#include "mailbox.h"
#include "mutt_window.h"
#include "mx.h"
#include "ncrypt/ncrypt.h"
Expand Down
1 change: 0 additions & 1 deletion mx.c
Expand Up @@ -47,7 +47,6 @@
#include "globals.h"
#include "hook.h"
#include "keymap.h"
#include "mailbox.h"
#include "maildir/maildir.h"
#include "mbox/mbox.h"
#include "mutt_header.h"
Expand Down
76 changes: 76 additions & 0 deletions mx.h
Expand Up @@ -26,6 +26,7 @@

#include <stdbool.h>
#include <stdio.h>
#include <time.h>
#include "where.h"
#ifdef USE_HCACHE
#include "hcache/hcache.h"
Expand Down Expand Up @@ -163,4 +164,79 @@ struct MxOps *mx_get_ops(int magic);
/* This variable is backing for a config item */
WHERE short MboxType; ///< Config: Default type for creating new mailboxes

/* flags for mutt_open_mailbox() */
#define MUTT_NOSORT (1 << 0) /**< do not sort the mailbox after opening it */
#define MUTT_APPEND (1 << 1) /**< open mailbox for appending messages */
#define MUTT_READONLY (1 << 2) /**< open in read-only mode */
#define MUTT_QUIET (1 << 3) /**< do not print any messages */
#define MUTT_NEWFOLDER (1 << 4) /**< create a new folder - same as MUTT_APPEND, but uses
* mutt_file_fopen() with mode "w" for mbox-style folders.
* This will truncate an existing file. */
#define MUTT_PEEK (1 << 5) /**< revert atime back after taking a look (if applicable) */
#define MUTT_APPENDNEW (1 << 6) /**< set in mx_open_mailbox_append if the mailbox doesn't
* exist. used by maildir/mh to create the mailbox. */

/* mx_msg_open_new() */
#define MUTT_ADD_FROM (1 << 0) /**< add a From_ line */
#define MUTT_SET_DRAFT (1 << 1) /**< set the message draft flag */

/**
* enum MxCheckReturns - Return values from mx_mbox_check()
*/
enum MxCheckReturns
{
MUTT_NEW_MAIL = 1, /**< new mail received in mailbox */
MUTT_LOCKED, /**< couldn't lock the mailbox */
MUTT_REOPENED, /**< mailbox was reopened */
MUTT_FLAGS /**< nondestructive flags change (IMAP) */
};

/**
* struct Message - A local copy of an email
*/
struct Message
{
FILE *fp; /**< pointer to the message data */
char *path; /**< path to temp file */
char *committed_path; /**< the final path generated by mx_msg_commit() */
bool write; /**< nonzero if message is open for writing */
struct
{
bool read : 1;
bool flagged : 1;
bool replied : 1;
bool draft : 1;
} flags;
time_t received; /**< the time at which this message was received */
};

/* The Mailbox API, see MxOps */
struct Context *mx_mbox_open (const char *path, int flags, struct Context *pctx);
int mx_mbox_check (struct Context *ctx, int *index_hint);
int mx_mbox_sync (struct Context *ctx, int *index_hint);
int mx_mbox_close (struct Context *ctx, int *index_hint);
struct Message *mx_msg_open (struct Context *ctx, int msgno);
struct Message *mx_msg_open_new(struct Context *ctx, struct Header *hdr, int flags);
int mx_msg_commit (struct Context *ctx, struct Message *msg);
int mx_msg_close (struct Context *ctx, struct Message **msg);
int mx_tags_edit (struct Context *ctx, const char *tags, char *buf, size_t buflen);
int mx_tags_commit (struct Context *ctx, struct Header *hdr, char *tags);

void mx_fastclose_mailbox(struct Context *ctx);

int mx_get_magic(const char *path);
int mx_check_mailbox(struct Context *ctx, int *index_hint);
#ifdef USE_IMAP
bool mx_is_imap(const char *p);
#endif
#ifdef USE_POP
bool mx_is_pop(const char *p);
#endif
#ifdef USE_NNTP
bool mx_is_nntp(const char *p);
#endif

int mx_access(const char *path, int flags);
int mx_check_empty(const char *path);

#endif /* _MUTT_MX_H */
1 change: 0 additions & 1 deletion nntp/nntp.c
Expand Up @@ -45,7 +45,6 @@
#include "context.h"
#include "curs_lib.h"
#include "globals.h"
#include "mailbox.h"
#include "mutt_account.h"
#include "mutt_logging.h"
#include "mutt_parse.h"
Expand Down

0 comments on commit 1d86196

Please sign in to comment.