NeoMutt  2023-03-22
Teaching an old dog new tricks
DOXYGEN
mxapi.h
Go to the documentation of this file.
1
24#ifndef MUTT_CORE_MXAPI_H
25#define MUTT_CORE_MXAPI_H
26
27#include "config.h"
28#include <stdbool.h>
29#include <stdint.h>
30#include <stdio.h>
31#include <sys/types.h>
32#include "mailbox.h"
33
34struct Account;
35struct Buffer;
36struct Email;
37struct stat;
38
42struct Message
43{
44 FILE *fp;
45 char *path;
47 bool write;
48 struct
49 {
50 bool read : 1;
51 bool flagged : 1;
52 bool replied : 1;
53 bool draft : 1;
55 time_t received;
56};
57
58
59/* flags for mutt_open_mailbox() */
60typedef uint8_t OpenMailboxFlags;
61#define MUTT_OPEN_NO_FLAGS 0
62#define MUTT_NOSORT (1 << 0)
63#define MUTT_APPEND (1 << 1)
64#define MUTT_READONLY (1 << 2)
65#define MUTT_QUIET (1 << 3)
66#define MUTT_NEWFOLDER (1 << 4)
69#define MUTT_PEEK (1 << 5)
70#define MUTT_APPENDNEW (1 << 6)
72
73typedef uint8_t CheckStatsFlags;
74#define MUTT_MAILBOX_CHECK_NO_FLAGS 0
75#define MUTT_MAILBOX_CHECK_FORCE (1 << 0)
76#define MUTT_MAILBOX_CHECK_FORCE_STATS (1 << 1)
77#define MUTT_MAILBOX_CHECK_IMMEDIATE (1 << 2)
78
84{
91};
92
97{
101};
102
111struct MxOps
112{
114 const char *name;
115 bool is_local;
116
130 bool (*ac_owns_path)(struct Account *a, const char *path);
131
145 bool (*ac_add)(struct Account *a, struct Mailbox *m);
146
157 enum MxOpenReturns (*mbox_open)(struct Mailbox *m);
158
171 bool (*mbox_open_append)(struct Mailbox *m, OpenMailboxFlags flags);
172
183 enum MxStatus (*mbox_check)(struct Mailbox *m);
184
196 enum MxStatus (*mbox_check_stats)(struct Mailbox *m, CheckStatsFlags flags);
197
208 enum MxStatus (*mbox_sync)(struct Mailbox *m);
209
220 enum MxStatus (*mbox_close)(struct Mailbox *m);
221
237 bool (*msg_open)(struct Mailbox *m, struct Message *msg, int msgno);
238
253 bool (*msg_open_new)(struct Mailbox *m, struct Message *msg, const struct Email *e);
254
268 int (*msg_commit) (struct Mailbox *m, struct Message *msg);
269
283 int (*msg_close) (struct Mailbox *m, struct Message *msg);
284
295 int (*msg_padding_size)(struct Mailbox *m);
296
310 int (*msg_save_hcache) (struct Mailbox *m, struct Email *e);
311
327 int (*tags_edit) (struct Mailbox *m, const char *tags, struct Buffer *buf);
328
344 int (*tags_commit) (struct Mailbox *m, struct Email *e, const char *buf);
345
357 enum MailboxType (*path_probe)(const char *path, const struct stat *st);
358
371 int (*path_canon) (char *buf, size_t buflen);
372
386 int (*path_pretty) (char *buf, size_t buflen, const char *folder);
387
400 int (*path_parent) (char *buf, size_t buflen);
401
414 int (*path_is_empty) (const char *path);
415};
416
417#endif /* MUTT_CORE_MXAPI_H */
Representation of a mailbox.
MailboxType
Supported mailbox formats.
Definition: mailbox.h:41
uint8_t OpenMailboxFlags
Flags for mutt_open_mailbox(), e.g. MUTT_NOSORT.
Definition: mxapi.h:60
MxOpenReturns
Return values for mbox_open()
Definition: mxapi.h:97
@ MX_OPEN_ERROR
Open failed with an error.
Definition: mxapi.h:99
@ MX_OPEN_ABORT
Open was aborted.
Definition: mxapi.h:100
@ MX_OPEN_OK
Open succeeded.
Definition: mxapi.h:98
uint8_t CheckStatsFlags
Flags for mutt_mailbox_check.
Definition: mxapi.h:73
MxStatus
Return values from mbox_check(), mbox_check_stats(), mbox_snc(), and mbox_close()
Definition: mxapi.h:84
@ MX_STATUS_LOCKED
Couldn't lock the Mailbox.
Definition: mxapi.h:88
@ MX_STATUS_ERROR
An error occurred.
Definition: mxapi.h:85
@ MX_STATUS_OK
No changes.
Definition: mxapi.h:86
@ MX_STATUS_FLAGS
Nondestructive flags change (IMAP)
Definition: mxapi.h:90
@ MX_STATUS_REOPENED
Mailbox was reopened.
Definition: mxapi.h:89
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
Definition: mxapi.h:87
A group of associated Mailboxes.
Definition: account.h:37
String manipulation buffer.
Definition: buffer.h:34
The envelope/body of an email.
Definition: email.h:37
char * path
Path of Email (for local Mailboxes)
Definition: email.h:68
A mailbox.
Definition: mailbox.h:79
A local copy of an email.
Definition: mxapi.h:43
FILE * fp
pointer to the message data
Definition: mxapi.h:44
char * path
path to temp file
Definition: mxapi.h:45
bool draft
Message has been read.
Definition: mxapi.h:53
bool replied
Message has been replied to.
Definition: mxapi.h:52
char * committed_path
the final path generated by mx_msg_commit()
Definition: mxapi.h:46
time_t received
Time at which this message was received.
Definition: mxapi.h:55
bool write
nonzero if message is open for writing
Definition: mxapi.h:47
bool flagged
Message is flagged.
Definition: mxapi.h:51
bool read
Message has been read.
Definition: mxapi.h:50
struct Message::@0 flags
Flags for the Message.
Definition: mxapi.h:112
int(* path_parent)(char *buf, size_t buflen)
Definition: mxapi.h:400
bool is_local
True, if Mailbox type has local files/dirs.
Definition: mxapi.h:115
int(* tags_commit)(struct Mailbox *m, struct Email *e, const char *buf)
Definition: mxapi.h:344
int(* path_pretty)(char *buf, size_t buflen, const char *folder)
Definition: mxapi.h:386
int(* msg_save_hcache)(struct Mailbox *m, struct Email *e)
Definition: mxapi.h:310
enum MailboxType(* path_probe)(const char *path, const struct stat *st)
Definition: mxapi.h:357
int(* path_is_empty)(const char *path)
Definition: mxapi.h:414
enum MailboxType type
Mailbox type, e.g. MUTT_IMAP.
Definition: mxapi.h:113
int(* msg_padding_size)(struct Mailbox *m)
Definition: mxapi.h:295
bool(* ac_owns_path)(struct Account *a, const char *path)
Definition: mxapi.h:130
int(* tags_edit)(struct Mailbox *m, const char *tags, struct Buffer *buf)
Definition: mxapi.h:327
int(* msg_commit)(struct Mailbox *m, struct Message *msg)
Definition: mxapi.h:268
enum MxStatus(* mbox_check_stats)(struct Mailbox *m, CheckStatsFlags flags)
Definition: mxapi.h:196
bool(* ac_add)(struct Account *a, struct Mailbox *m)
Definition: mxapi.h:145
enum MxOpenReturns(* mbox_open)(struct Mailbox *m)
Definition: mxapi.h:157
int(* msg_close)(struct Mailbox *m, struct Message *msg)
Definition: mxapi.h:283
int(* path_canon)(char *buf, size_t buflen)
Definition: mxapi.h:371
bool(* msg_open_new)(struct Mailbox *m, struct Message *msg, const struct Email *e)
Definition: mxapi.h:253
const char * name
Mailbox name, e.g. "imap".
Definition: mxapi.h:114
enum MxStatus(* mbox_close)(struct Mailbox *m)
Definition: mxapi.h:220
enum MxStatus(* mbox_sync)(struct Mailbox *m)
Definition: mxapi.h:208
bool(* mbox_open_append)(struct Mailbox *m, OpenMailboxFlags flags)
Definition: mxapi.h:171
enum MxStatus(* mbox_check)(struct Mailbox *m)
Definition: mxapi.h:183
bool(* msg_open)(struct Mailbox *m, struct Message *msg, int msgno)
Definition: mxapi.h:237