NeoMutt  2018-07-16 +2481-68dcde
Teaching an old dog new tricks
DOXYGEN
mx.h
Go to the documentation of this file.
1 
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 <time.h>
32 #include "config/lib.h"
33 #include "core/lib.h"
34 
35 struct Email;
36 struct Context;
37 struct stat;
38 
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;
45 
46 extern struct EnumDef MagicDef;
47 
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)
60 
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)
66 
67 
71 {
76 };
77 
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 };
96 
103 struct MxOps
104 {
105  enum MailboxType magic;
106  const char *name;
107 
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);
155  int (*mbox_check_stats)(struct Mailbox *m, int flags);
163  int (*mbox_sync) (struct Mailbox *m, int *index_hint);
170  int (*mbox_close) (struct Mailbox *m);
179  int (*msg_open) (struct Mailbox *m, struct Message *msg, int msgno);
188  int (*msg_open_new) (struct Mailbox *m, struct Message *msg, struct Email *e);
196  int (*msg_commit) (struct Mailbox *m, struct Message *msg);
204  int (*msg_close) (struct Mailbox *m, struct Message *msg);
210  int (*msg_padding_size)(struct Mailbox *m);
218  int (*msg_save_hcache) (struct Mailbox *m, struct Email *e);
229  int (*tags_edit) (struct Mailbox *m, const char *tags, char *buf, size_t buflen);
238  int (*tags_commit) (struct Mailbox *m, struct Email *e, char *buf);
245  enum MailboxType (*path_probe)(const char *path, const struct stat *st);
253  int (*path_canon) (char *buf, size_t buflen);
262  int (*path_pretty) (char *buf, size_t buflen, const char *folder);
270  int (*path_parent) (char *buf, size_t buflen);
271 };
272 
273 /* Wrappers for the Mailbox API, see MxOps */
274 int mx_mbox_check (struct Mailbox *m, int *index_hint);
275 int mx_mbox_check_stats(struct Mailbox *m, int flags);
276 int mx_mbox_close (struct Context **ptr);
277 struct Context *mx_mbox_open (struct Mailbox *m, OpenMailboxFlags flags);
278 int mx_mbox_sync (struct Mailbox *m, int *index_hint);
279 int mx_msg_close (struct Mailbox *m, struct Message **msg);
280 int mx_msg_commit (struct Mailbox *m, struct Message *msg);
281 struct Message *mx_msg_open_new (struct Mailbox *m, struct Email *e, MsgOpenFlags flags);
282 struct Message *mx_msg_open (struct Mailbox *m, int msgno);
283 int mx_msg_padding_size(struct Mailbox *m);
284 int mx_save_hcache (struct Mailbox *m, struct Email *e);
285 int mx_path_canon (char *buf, size_t buflen, const char *folder, enum MailboxType *magic);
286 int mx_path_canon2 (struct Mailbox *m, const char *folder);
287 int mx_path_parent (char *buf, size_t buflen);
288 int mx_path_pretty (char *buf, size_t buflen, const char *folder);
289 enum MailboxType mx_path_probe (const char *path, struct stat *st);
290 struct Mailbox *mx_path_resolve (const char *path);
291 int mx_tags_commit (struct Mailbox *m, struct Email *e, char *tags);
292 int mx_tags_edit (struct Mailbox *m, const char *tags, char *buf, size_t buflen);
293 
294 struct Account *mx_ac_find (struct Mailbox *m);
295 struct Mailbox *mx_mbox_find (struct Account *a, const char *path);
296 struct Mailbox *mx_mbox_find2(const char *path);
297 int mx_ac_add (struct Account *a, struct Mailbox *m);
298 int mx_ac_remove (struct Mailbox *m);
299 
300 int mx_access (const char *path, int flags);
301 void mx_alloc_memory (struct Mailbox *m);
302 int mx_check_empty (const char *path);
303 void mx_fastclose_mailbox(struct Mailbox *m);
304 const struct MxOps *mx_get_ops (enum MailboxType magic);
305 bool mx_tags_is_supported(struct Mailbox *m);
306 
307 #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:39
int mx_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Wrapper for MxOps::msg_padding_size.
Definition: mx.c:1462
bool replied
Definition: mx.h:91
struct EnumDef MagicDef
Definition: mx.c:98
int mx_msg_close(struct Mailbox *m, struct Message **msg)
Close a message.
Definition: mx.c:1087
struct Message * mx_msg_open(struct Mailbox *m, int msgno)
return a stream pointer for a message
Definition: mx.c:1039
const struct MxOps * mx_get_ops(enum MailboxType magic)
Get mailbox operations.
Definition: mx.c:141
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:1295
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:1208
struct Message * mx_msg_open_new(struct Mailbox *m, struct Email *e, MsgOpenFlags flags)
Open a new message.
Definition: mx.c:956
unsigned char C_MboxType
Config: Default type for creating new mailboxes.
Definition: mx.c:84
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:85
MxCheckReturns
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:825
unsigned char C_CatchupNewsgroup
Config: (nntp) Mark all articles as read when leaving a newsgroup.
Definition: mx.c:82
int mx_access(const char *path, int flags)
Wrapper for access, checks permissions on a given mailbox.
Definition: mx.c:170
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:1113
bool C_KeepFlagged
Config: Don&#39;t move flagged messages from C_Spoolfile to C_Mbox.
Definition: mx.c:83
int mx_ac_remove(struct Mailbox *m)
Remove a Mailbox from an Account and delete Account if empty.
Definition: mx.c:1575
int mx_mbox_check(struct Mailbox *m, int *index_hint)
Check for new mail - Wrapper for MxOps::mbox_check()
Definition: mx.c:1020
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:1608
struct Account * mx_ac_find(struct Mailbox *m)
XXX.
Definition: mx.c:1473
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:92
Nondestructive flags change (IMAP)
Definition: mx.h:75
char * C_Trash
Config: Folder to put deleted emails.
Definition: mx.c:86
struct Mailbox * mx_path_resolve(const char *path)
XXX.
Definition: mx.c:1539
int mx_check_empty(const char *path)
Is the mailbox empty.
Definition: mx.c:1148
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:1591
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
XXX.
Definition: mx.c:1496
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition: mx.c:254
bool draft
Definition: mx.h:92
void mx_fastclose_mailbox(struct Mailbox *m)
free up memory associated with the Mailbox
Definition: mx.c:392
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:1559
struct Mailbox * mx_mbox_find2(const char *path)
XXX.
Definition: mx.c:1516
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:1421
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:1446
char * committed_path
the final path generated by mx_msg_commit()
Definition: mx.h:85
MailboxType
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:1188
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:1066
enum MailboxType mx_path_probe(const char *path, struct stat *st)
Find a mailbox that understands a path.
Definition: mx.c:1236
int mx_path_canon2(struct Mailbox *m, const char *folder)
XXX canonicalise the path to realpath.
Definition: mx.c:1393
int mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
Definition: mx.c:558
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:1225