NeoMutt  2019-12-07-60-g0cfa53
Teaching an old dog new tricks
Go to the documentation of this file.
25 #ifndef MUTT_MX_H
26 #define MUTT_MX_H
28 #include <stdbool.h>
29 #include <stdint.h>
30 #include <stdio.h>
31 #include <time.h>
32 #include "config/lib.h"
33 #include "core/lib.h"
35 struct Email;
36 struct Context;
37 struct stat;
39 /* These Config Variables are only used in mx.c */
40 extern unsigned char C_CatchupNewsgroup;
41 extern bool C_KeepFlagged;
42 extern unsigned char C_MboxType;
43 extern unsigned char C_Move;
44 extern char * C_Trash;
46 extern struct EnumDef MagicDef;
48 /* flags for mutt_open_mailbox() */
49 typedef uint8_t OpenMailboxFlags;
50 #define MUTT_OPEN_NO_FLAGS 0
51 #define MUTT_NOSORT (1 << 0)
52 #define MUTT_APPEND (1 << 1)
53 #define MUTT_READONLY (1 << 2)
54 #define MUTT_QUIET (1 << 3)
55 #define MUTT_NEWFOLDER (1 << 4)
56 #define MUTT_PEEK (1 << 5)
59 #define MUTT_APPENDNEW (1 << 6)
62 typedef uint8_t MsgOpenFlags;
63 #define MUTT_MSG_NO_FLAGS 0
64 #define MUTT_ADD_FROM (1 << 0)
65 #define MUTT_SET_DRAFT (1 << 1)
71 {
76 };
81 struct Message
82 {
83  FILE *fp;
84  char *path;
86  bool write;
87  struct
88  {
89  bool read : 1;
90  bool flagged : 1;
91  bool replied : 1;
92  bool draft : 1;
93  } flags;
94  time_t received;
95 };
103 struct MxOps
104 {
105  enum MailboxType magic;
106  const char *name;
115  struct Account *(*ac_find) (struct Account *a, const char *path);
123  int (*ac_add) (struct Account *a, struct Mailbox *m);
131  int (*mbox_open) (struct Mailbox *m);
139  int (*mbox_open_append)(struct Mailbox *m, OpenMailboxFlags flags);
147  int (*mbox_check) (struct Mailbox *m, int *index_hint);
156  int (*mbox_check_stats)(struct Mailbox *m, int flags);
164  int (*mbox_sync) (struct Mailbox *m, int *index_hint);
171  int (*mbox_close) (struct Mailbox *m);
180  int (*msg_open) (struct Mailbox *m, struct Message *msg, int msgno);
189  int (*msg_open_new) (struct Mailbox *m, struct Message *msg, struct Email *e);
197  int (*msg_commit) (struct Mailbox *m, struct Message *msg);
205  int (*msg_close) (struct Mailbox *m, struct Message *msg);
211  int (*msg_padding_size)(struct Mailbox *m);
219  int (*msg_save_hcache) (struct Mailbox *m, struct Email *e);
230  int (*tags_edit) (struct Mailbox *m, const char *tags, char *buf, size_t buflen);
239  int (*tags_commit) (struct Mailbox *m, struct Email *e, char *buf);
246  enum MailboxType (*path_probe)(const char *path, const struct stat *st);
254  int (*path_canon) (char *buf, size_t buflen);
263  int (*path_pretty) (char *buf, size_t buflen, const char *folder);
271  int (*path_parent) (char *buf, size_t buflen);
272 };
274 /* Wrappers for the Mailbox API, see MxOps */
275 int mx_mbox_check (struct Mailbox *m, int *index_hint);
276 int mx_mbox_check_stats(struct Mailbox *m, int flags);
277 int mx_mbox_close (struct Context **ptr);
278 struct Context *mx_mbox_open (struct Mailbox *m, OpenMailboxFlags flags);
279 int mx_mbox_sync (struct Mailbox *m, int *index_hint);
280 int mx_msg_close (struct Mailbox *m, struct Message **msg);
281 int mx_msg_commit (struct Mailbox *m, struct Message *msg);
282 struct Message *mx_msg_open_new (struct Mailbox *m, struct Email *e, MsgOpenFlags flags);
283 struct Message *mx_msg_open (struct Mailbox *m, int msgno);
284 int mx_msg_padding_size(struct Mailbox *m);
285 int mx_save_hcache (struct Mailbox *m, struct Email *e);
286 int mx_path_canon (char *buf, size_t buflen, const char *folder, enum MailboxType *magic);
287 int mx_path_canon2 (struct Mailbox *m, const char *folder);
288 int mx_path_parent (char *buf, size_t buflen);
289 int mx_path_pretty (char *buf, size_t buflen, const char *folder);
290 enum MailboxType mx_path_probe (const char *path, struct stat *st);
291 struct Mailbox *mx_path_resolve (const char *path);
292 int mx_tags_commit (struct Mailbox *m, struct Email *e, char *tags);
293 int mx_tags_edit (struct Mailbox *m, const char *tags, char *buf, size_t buflen);
295 struct Account *mx_ac_find (struct Mailbox *m);
296 struct Mailbox *mx_mbox_find (struct Account *a, const char *path);
297 struct Mailbox *mx_mbox_find2(const char *path);
298 int mx_ac_add (struct Account *a, struct Mailbox *m);
299 int mx_ac_remove (struct Mailbox *m);
301 int mx_access (const char *path, int flags);
302 void mx_alloc_memory (struct Mailbox *m);
303 int mx_check_empty (const char *path);
304 void mx_fastclose_mailbox(struct Mailbox *m);
305 const struct MxOps *mx_get_ops (enum MailboxType magic);
306 bool mx_tags_is_supported(struct Mailbox *m);
308 #endif /* MUTT_MX_H */
The "current" mailbox.
Definition: context.h:36
An enumeration.
Definition: enum.h:31
The envelope/body of an email.
Definition: email.h:37
int mx_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Wrapper for MxOps::msg_padding_size()
Definition: mx.c:1517
bool replied
Definition: mx.h:91
struct EnumDef MagicDef
Definition: mx.c:97
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1140
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1092
const struct MxOps * mx_get_ops(enum MailboxType magic)
Get mailbox operations.
Definition: mx.c:140
A group of associated Mailboxes.
Definition: account.h:36
int mx_path_canon(char *buf, size_t buflen, const char *folder, enum MailboxType *magic)
Canonicalise a mailbox path - Wrapper for MxOps::path_canon()
Definition: mx.c:1347
int mx_tags_commit(struct Mailbox *m, struct Email *e, char *tags)
Save tags to the Mailbox - Wrapper for MxOps::tags_commit()
Definition: mx.c:1260
struct Message * mx_msg_open_new(struct Mailbox *m, struct Email *e, MsgOpenFlags flags)
Open a new message.
Definition: mx.c:1009
unsigned char C_MboxType
Config: Default type for creating new mailboxes.
Definition: mx.c:83
int mbox_check(struct Mailbox *m, struct stat *sb, bool check_stats)
uint8_t OpenMailboxFlags
Flags for mutt_open_mailbox(), e.g. MUTT_NOSORT.
Definition: mx.h:49
unsigned char C_Move
Config: Move emails from C_Spoolfile to C_Mbox when read.
Definition: mx.c:84
Return values from mx_mbox_check()
Definition: mx.h:70
Convenience wrapper for the config headers.
int mx_mbox_sync(struct Mailbox *m, int *index_hint)
Save changes to mailbox.
Definition: mx.c:875
unsigned char C_CatchupNewsgroup
Config: (nntp) Mark all articles as read when leaving a newsgroup.
Definition: mx.c:81
int mx_access(const char *path, int flags)
Wrapper for access, checks permissions on a given mailbox.
Definition: mx.c:169
enum MailboxType magic
Mailbox type, e.g. MUTT_IMAP.
Definition: mx.h:105
Convenience wrapper for the core headers.
void mx_alloc_memory(struct Mailbox *m)
Create storage for the emails.
Definition: mx.c:1166
bool C_KeepFlagged
Config: Don&#39;t move flagged messages from C_Spoolfile to C_Mbox.
Definition: mx.c:82
int mx_ac_remove(struct Mailbox *m)
Remove a Mailbox from an Account and delete Account if empty.
Definition: mx.c:1639
int mx_mbox_check(struct Mailbox *m, int *index_hint)
Check for new mail - Wrapper for MxOps::mbox_check()
Definition: mx.c:1073
int mx_save_hcache(struct Mailbox *m, struct Email *e)
Save message to the header cache - Wrapper for MxOps::msg_save_hcache()
Definition: mx.c:1674
struct Account * mx_ac_find(struct Mailbox *m)
Find the Account owning a Mailbox.
Definition: mx.c:1531
bool flagged
Definition: mx.h:90
A local copy of an email.
Definition: mx.h:81
struct Message::@0 flags
A mailbox.
Definition: mailbox.h:80
Nondestructive flags change (IMAP)
Definition: mx.h:75
char * C_Trash
Config: Folder to put deleted emails.
Definition: mx.c:85
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
Definition: mx.c:1603
int mx_check_empty(const char *path)
Is the mailbox empty.
Definition: mx.c:1201
int mx_mbox_check_stats(struct Mailbox *m, int flags)
Check the statistics for a mailbox - Wrapper for MxOps::mbox_check_stats()
Definition: mx.c:1657
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
Find a Mailbox on an Account.
Definition: mx.c:1555
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition: mx.c:253
bool draft
Definition: mx.h:92
void mx_fastclose_mailbox(struct Mailbox *m)
free up memory associated with the Mailbox
Definition: mx.c:412
uint8_t MsgOpenFlags
Flags for mx_msg_open_new(), e.g. MUTT_ADD_FROM.
Definition: mx.h:62
int mx_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Wrapper for MxOps::ac_add()
Definition: mx.c:1623
struct Mailbox * mx_mbox_find2(const char *path)
Find a Mailbox on an Account.
Definition: mx.c:1576
bool write
nonzero if message is open for writing
Definition: mx.h:86
int mx_path_pretty(char *buf, size_t buflen, const char *folder)
Abbreviate a mailbox path - Wrapper for MxOps::path_pretty()
Definition: mx.c:1476
const char * name
Mailbox name, e.g. "imap".
Definition: mx.h:106
int mx_path_parent(char *buf, size_t buflen)
Find the parent of a mailbox path - Wrapper for MxOps::path_parent()
Definition: mx.c:1501
char * committed_path
the final path generated by mx_msg_commit()
Definition: mx.h:85
Supported mailbox formats.
Definition: mailbox.h:42
int mx_tags_edit(struct Mailbox *m, const char *tags, char *buf, size_t buflen)
start the tag editor of the mailbox
Definition: mx.c:1240
FILE * fp
pointer to the message data
Definition: mx.h:83
time_t received
the time at which this message was received
Definition: mx.h:94
Couldn&#39;t lock the Mailbox.
Definition: mx.h:73
New mail received in Mailbox.
Definition: mx.h:72
bool read
Definition: mx.h:89
Mailbox was reopened.
Definition: mx.h:74
int mx_msg_commit(struct Mailbox *m, struct Message *msg)
Commit a message to a folder - Wrapper for MxOps::msg_commit()
Definition: mx.c:1119
enum MailboxType mx_path_probe(const char *path, struct stat *st)
Find a mailbox that understands a path.
Definition: mx.c:1288
int mx_path_canon2(struct Mailbox *m, const char *folder)
Canonicalise the path to realpath.
Definition: mx.c:1448
int mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
Definition: mx.c:583
char * path
path to temp file
Definition: mx.h:84
The Mailbox API.
Definition: mx.h:103
bool mx_tags_is_supported(struct Mailbox *m)
return true if mailbox support tagging
Definition: mx.c:1277