1 /** 2 * @file 3 * API for mailboxes 4 * 5 * @authors 6 * Copyright (C) 1996-2002,2013 Michael R. Elkins <me@mutt.org> 7 * Copyright (C) 1999-2002 Thomas Roessler <roessler@does-not-exist.org> 8 * Copyright (C) 2017-2018 Richard Russon <rich@flatcap.org> 9 * 10 * @copyright 11 * This program is free software: you can redistribute it and/or modify it under 12 * the terms of the GNU General Public License as published by the Free Software 13 * Foundation, either version 2 of the License, or (at your option) any later 14 * version. 15 * 16 * This program is distributed in the hope that it will be useful, but WITHOUT 17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 19 * details. 20 * 21 * You should have received a copy of the GNU General Public License along with 22 * this program. If not, see <http://www.gnu.org/licenses/>. 23 */ 24 25 #ifndef MUTT_MX_H 26 #define MUTT_MX_H 27 28 #include <stdbool.h> 29 #include <stdint.h> 30 #include <stdio.h> 31 #include "config/lib.h" 32 #include "core/lib.h" 33 34 struct Email; 35 36 extern const struct MxOps *mx_ops[]; 37 38 extern struct EnumDef MboxTypeDef; 39 40 typedef uint8_t MsgOpenFlags; ///< Flags for mx_msg_open_new(), e.g. #MUTT_ADD_FROM 41 #define MUTT_MSG_NO_FLAGS 0 ///< No flags are set 42 #define MUTT_ADD_FROM (1 << 0) ///< add a From_ line 43 #define MUTT_SET_DRAFT (1 << 1) ///< set the message draft flag 44 45 /* Wrappers for the Mailbox API, see MxOps */ 46 enum MxStatus mx_mbox_check (struct Mailbox *m); 47 enum MxStatus mx_mbox_check_stats(struct Mailbox *m, uint8_t flags); 48 enum MxStatus mx_mbox_close (struct Mailbox *m); 49 bool mx_mbox_open (struct Mailbox *m, OpenMailboxFlags flags); 50 enum MxStatus mx_mbox_sync (struct Mailbox *m); 51 int mx_msg_close (struct Mailbox *m, struct Message **msg); 52 int mx_msg_commit (struct Mailbox *m, struct Message *msg); 53 struct Message *mx_msg_open_new (struct Mailbox *m, const struct Email *e, MsgOpenFlags flags); 54 struct Message *mx_msg_open (struct Mailbox *m, int msgno); 55 int mx_msg_padding_size(struct Mailbox *m); 56 int mx_save_hcache (struct Mailbox *m, struct Email *e); 57 int mx_path_canon (char *buf, size_t buflen, const char *folder, enum MailboxType *type); 58 int mx_path_canon2 (struct Mailbox *m, const char *folder); 59 int mx_path_parent (char *buf, size_t buflen); 60 int mx_path_pretty (char *buf, size_t buflen, const char *folder); 61 enum MailboxType mx_path_probe (const char *path); 62 struct Mailbox *mx_path_resolve (const char *path); 63 struct Mailbox *mx_resolve (const char *path_or_name); 64 int mx_tags_commit (struct Mailbox *m, struct Email *e, char *tags); 65 int mx_tags_edit (struct Mailbox *m, const char *tags, char *buf, size_t buflen); 66 enum MailboxType mx_type (struct Mailbox *m); 67 68 struct Account *mx_ac_find (struct Mailbox *m); 69 struct Mailbox *mx_mbox_find (struct Account *a, const char *path); 70 struct Mailbox *mx_mbox_find2 (const char *path); 71 bool mx_mbox_ac_link(struct Mailbox *m); 72 bool mx_ac_add (struct Account *a, struct Mailbox *m); 73 int mx_ac_remove (struct Mailbox *m); 74 75 int mx_access (const char *path, int flags); 76 void mx_alloc_memory (struct Mailbox *m); 77 int mx_path_is_empty (const char *path); 78 void mx_fastclose_mailbox(struct Mailbox *m); 79 const struct MxOps *mx_get_ops (enum MailboxType type); 80 bool mx_tags_is_supported(struct Mailbox *m); 81 int mx_toggle_write (struct Mailbox *m); 82 83 #endif /* MUTT_MX_H */ 84