From: Richard Russon Date: Fri, 3 Aug 2018 13:41:45 +0000 (+0100) Subject: merge mailbox.h and mx.h X-Git-Tag: 2019-10-25~713^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1d86196e630d26fc6712e6af8e591f03bfdcad82;p=neomutt merge mailbox.h and mx.h --- diff --git a/browser.c b/browser.c index eafc0b471..520d6b335 100644 --- a/browser.c +++ b/browser.c @@ -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" diff --git a/buffy.c b/buffy.c index 8423b7432..e09edf209 100644 --- a/buffy.c +++ b/buffy.c @@ -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" diff --git a/commands.c b/commands.c index d33ac9330..a1cf85064 100644 --- a/commands.c +++ b/commands.c @@ -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" diff --git a/complete.c b/complete.c index 5b1f04159..484056e73 100644 --- a/complete.c +++ b/complete.c @@ -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" diff --git a/compose.c b/compose.c index 4a842738a..46c7b9cad 100644 --- a/compose.c +++ b/compose.c @@ -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" diff --git a/compress.c b/compress.c index c90957242..b78c00646 100644 --- a/compress.c +++ b/compress.c @@ -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" diff --git a/copy.c b/copy.c index d967210c3..18c22195e 100644 --- a/copy.c +++ b/copy.c @@ -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" diff --git a/curs_main.c b/curs_main.c index a5986e72d..93f40f855 100644 --- a/curs_main.c +++ b/curs_main.c @@ -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" diff --git a/editmsg.c b/editmsg.c index f3c852a9e..c18cb672e 100644 --- a/editmsg.c +++ b/editmsg.c @@ -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" diff --git a/hook.c b/hook.c index acb1327a5..9d6860628 100644 --- a/hook.c +++ b/hook.c @@ -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 diff --git a/imap/command.c b/imap/command.c index 71a1b90ff..895a1ea91 100644 --- a/imap/command.c +++ b/imap/command.c @@ -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" diff --git a/imap/imap.c b/imap/imap.c index 6fe1484d8..2fe3cd2a0 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -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" diff --git a/imap/message.c b/imap/message.c index a6dfc61a4..62d235e83 100644 --- a/imap/message.c +++ b/imap/message.c @@ -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" diff --git a/imap/util.c b/imap/util.c index 34147a532..0b0aa606d 100644 --- a/imap/util.c +++ b/imap/util.c @@ -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" diff --git a/init.c b/init.c index acf359bee..1460f4df2 100644 --- a/init.c +++ b/init.c @@ -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" diff --git a/mailbox.h b/mailbox.h deleted file mode 100644 index f1a19cdc4..000000000 --- a/mailbox.h +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @file - * Constants/structs for handling mailboxes - * - * @authors - * Copyright (C) 1996-2002 Michael R. Elkins - * - * @copyright - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 2 of the License, or (at your option) any later - * version. - * - * 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 . - */ - -#ifndef _MUTT_MAILBOX_H -#define _MUTT_MAILBOX_H - -#include -#include -#include - -struct Header; -struct Context; - -/* 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_MAILBOX_H */ diff --git a/maildir/mh.c b/maildir/mh.c index d41129dd1..451182f85 100644 --- a/maildir/mh.c +++ b/maildir/mh.c @@ -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" diff --git a/main.c b/main.c index ac5621b17..b3140a83c 100644 --- a/main.c +++ b/main.c @@ -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" diff --git a/mbox/mbox.c b/mbox/mbox.c index 030ea0be9..2222426ab 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -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" diff --git a/mutt_attach.c b/mutt_attach.c index 64c0cd36f..d3dbc24d2 100644 --- a/mutt_attach.c +++ b/mutt_attach.c @@ -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" diff --git a/mutt_lua.c b/mutt_lua.c index 170cf3bc2..0740ac627 100644 --- a/mutt_lua.c +++ b/mutt_lua.c @@ -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" /** diff --git a/mutt_parse.c b/mutt_parse.c index 186a04103..d0f678e12 100644 --- a/mutt_parse.c +++ b/mutt_parse.c @@ -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; diff --git a/muttlib.c b/muttlib.c index 04165fbec..520c38660 100644 --- a/muttlib.c +++ b/muttlib.c @@ -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" diff --git a/mx.c b/mx.c index 0cb77c4b5..3fb05e978 100644 --- a/mx.c +++ b/mx.c @@ -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" diff --git a/mx.h b/mx.h index 3add32c6f..d65f05414 100644 --- a/mx.h +++ b/mx.h @@ -26,6 +26,7 @@ #include #include +#include #include "where.h" #ifdef USE_HCACHE #include "hcache/hcache.h" @@ -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 */ diff --git a/nntp/nntp.c b/nntp/nntp.c index 1208ef279..d52f90015 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -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" diff --git a/notmuch/mutt_notmuch.c b/notmuch/mutt_notmuch.c index ed5076c01..2cb8a9bc4 100644 --- a/notmuch/mutt_notmuch.c +++ b/notmuch/mutt_notmuch.c @@ -63,7 +63,6 @@ #include "curs_lib.h" #include "curs_main.h" #include "globals.h" -#include "mailbox.h" #include "maildir/maildir.h" #include "mutt_logging.h" #include "mutt_thread.h" diff --git a/pager.c b/pager.c index 9fb8f2719..68d02b186 100644 --- a/pager.c +++ b/pager.c @@ -48,7 +48,6 @@ #include "hdrline.h" #include "hook.h" #include "keymap.h" -#include "mailbox.h" #include "menu.h" #include "mutt_attach.h" #include "mutt_curses.h" diff --git a/pattern.c b/pattern.c index c2e698df4..90ac3a584 100644 --- a/pattern.c +++ b/pattern.c @@ -45,7 +45,6 @@ #include "group.h" #include "handler.h" #include "hdrline.h" -#include "mailbox.h" #include "menu.h" #include "mutt_logging.h" #include "mutt_parse.h" diff --git a/pop/pop.c b/pop/pop.c index f943823d1..496c3cb0b 100644 --- a/pop/pop.c +++ b/pop/pop.c @@ -46,7 +46,6 @@ #include "bcache.h" #include "context.h" #include "globals.h" -#include "mailbox.h" #include "mutt_account.h" #include "mutt_header.h" #include "mutt_logging.h" diff --git a/postpone.c b/postpone.c index b7cb32607..9420373ab 100644 --- a/postpone.c +++ b/postpone.c @@ -46,7 +46,6 @@ #include "handler.h" #include "hdrline.h" #include "keymap.h" -#include "mailbox.h" #include "menu.h" #include "mutt_logging.h" #include "mutt_thread.h" diff --git a/recvattach.c b/recvattach.c index 4681fbe8b..e2b5258b5 100644 --- a/recvattach.c +++ b/recvattach.c @@ -43,7 +43,6 @@ #include "hdrline.h" #include "hook.h" #include "keymap.h" -#include "mailbox.h" #include "menu.h" #include "mutt_attach.h" #include "mutt_logging.h" diff --git a/send.c b/send.c index 5984f2302..9dfdfbd80 100644 --- a/send.c +++ b/send.c @@ -46,7 +46,6 @@ #include "globals.h" #include "hdrline.h" #include "hook.h" -#include "mailbox.h" #include "mutt_attach.h" #include "mutt_header.h" #include "mutt_logging.h" diff --git a/sendlib.c b/sendlib.c index 12956f581..cd2242860 100644 --- a/sendlib.c +++ b/sendlib.c @@ -47,7 +47,6 @@ #include "filter.h" #include "globals.h" #include "handler.h" -#include "mailbox.h" #include "mutt_parse.h" #include "mutt_window.h" #include "muttlib.h"