NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mailbox.h
Go to the documentation of this file.
1
23
24#ifndef MUTT_CORE_MAILBOX_H
25#define MUTT_CORE_MAILBOX_H
26
27#include <stdbool.h>
28#include <stdint.h>
29#include <sys/types.h>
30#include <time.h>
31#include "mutt/lib.h"
32
33struct ConfigSubset;
34struct Email;
35
54
59{
61 MUTT_ACL_ADMIN = 1U << 0,
62 MUTT_ACL_CREATE = 1U << 1,
63 MUTT_ACL_DELETE = 1U << 2,
64 MUTT_ACL_DELMX = 1U << 3,
65 MUTT_ACL_EXPUNGE = 1U << 4,
66 MUTT_ACL_INSERT = 1U << 5,
67 MUTT_ACL_LOOKUP = 1U << 6,
68 MUTT_ACL_POST = 1U << 7,
69 MUTT_ACL_READ = 1U << 8,
70 MUTT_ACL_SEEN = 1U << 9,
71 MUTT_ACL_WRITE = 1U << 10,
72};
73typedef uint16_t AclFlags;
74
75#define MUTT_ACL_ALL ((1 << 11) - 1)
76
80struct Mailbox
81{
82 struct Buffer pathbuf;
83 char *realpath;
84 char *name;
85 struct ConfigSubset *sub;
86 off_t size;
87 bool has_new;
88
89 // These next three are only set when $mail_check_stats is set
93
94 int msg_new;
97
98 struct Email **emails;
100 int *v2r;
101 int vcount;
102
103 bool notified;
106 struct timespec last_visited;
108
109 const struct MxOps *mx_ops;
110
111 bool append : 1;
112 bool changed : 1;
113 bool dontwrite : 1;
115 bool notify_user : 1;
116 bool peekonly : 1;
117 bool poll_new_mail : 1;
118 bool readonly : 1;
119 bool verbose : 1;
120
122
124
128
129 struct Account *account;
130 int opened;
131
132 bool visible;
133
134 void *mdata;
135
145 void (*mdata_free)(void **ptr);
146
147 struct Notify *notify;
148
149 int gen;
150};
151ARRAY_HEAD(MailboxArray, struct Mailbox *);
152
164
174{
179
180 /* These don't really belong here as they are tied to GUI operations.
181 * Eventually, they'll be eliminated. */
186};
187
192{
193 struct Mailbox *mailbox;
194};
195
196void mailbox_changed (struct Mailbox *m, enum NotifyMailbox action);
197struct Mailbox *mailbox_find (const char *path);
198struct Mailbox *mailbox_find_name (const char *name);
199void mailbox_free (struct Mailbox **ptr);
200int mailbox_gen (void);
201struct Mailbox *mailbox_new (void);
202bool mailbox_set_subset(struct Mailbox *m, struct ConfigSubset *sub);
203void mailbox_size_add (struct Mailbox *m, const struct Email *e);
204void mailbox_size_sub (struct Mailbox *m, const struct Email *e);
205void mailbox_update (struct Mailbox *m);
206void mailbox_gc_add (struct Email *e);
207void mailbox_gc_run (void);
208
209const char *mailbox_get_type_name(enum MailboxType type);
210
216static inline const char *mailbox_path(const struct Mailbox *m) // LCOV_EXCL_LINE
217{
218 return buf_string(&m->pathbuf); // LCOV_EXCL_LINE
219}
220
221#endif /* MUTT_CORE_MAILBOX_H */
#define ARRAY_HEAD(name, T)
Define a named struct for arrays of elements of a certain type.
Definition array.h:47
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
NotifyMailbox
Types of Mailbox Event.
Definition mailbox.h:174
@ NT_MAILBOX_UNTAG
Clear the 'last-tagged' pointer.
Definition mailbox.h:185
@ NT_MAILBOX_CHANGE
Mailbox has been changed.
Definition mailbox.h:178
@ NT_MAILBOX_RESORT
Email list needs resorting.
Definition mailbox.h:183
@ NT_MAILBOX_DELETE
Mailbox is about to be deleted.
Definition mailbox.h:176
@ NT_MAILBOX_INVALID
Email list was changed.
Definition mailbox.h:182
@ NT_MAILBOX_DELETE_ALL
All Mailboxes are about to be deleted.
Definition mailbox.h:177
@ NT_MAILBOX_UPDATE
Update internal tables.
Definition mailbox.h:184
@ NT_MAILBOX_ADD
Mailbox has been added.
Definition mailbox.h:175
bool mailbox_set_subset(struct Mailbox *m, struct ConfigSubset *sub)
Set a Mailbox's Config Subset.
Definition mailbox.c:269
void mailbox_gc_run(void)
Run the garbage-collection.
Definition mailbox.c:311
void mailbox_size_add(struct Mailbox *m, const struct Email *e)
Add an email's size to the total size of a Mailbox.
Definition mailbox.c:248
void mailbox_size_sub(struct Mailbox *m, const struct Email *e)
Subtract an email's size from the total size of a Mailbox.
Definition mailbox.c:258
ExpandoDataMailbox
Expando UIDs for Mailboxes.
Definition mailbox.h:159
@ ED_MBX_MESSAGE_COUNT
Mailbox.msg_count.
Definition mailbox.h:161
@ ED_MBX_PERCENTAGE
EmailFormatInfo.pager_progress.
Definition mailbox.h:162
@ ED_MBX_MAILBOX_NAME
Mailbox, mailbox_path()
Definition mailbox.h:160
AclFlag
Mailbox ACL rights.
Definition mailbox.h:59
@ MUTT_ACL_WRITE
Write to a message (for flagging or linking threads)
Definition mailbox.h:71
@ MUTT_ACL_INSERT
Add/copy into the mailbox (used when editing a message)
Definition mailbox.h:66
@ MUTT_ACL_DELMX
Delete a mailbox.
Definition mailbox.h:64
@ MUTT_ACL_ADMIN
Administer the account (get/set permissions)
Definition mailbox.h:61
@ MUTT_ACL_READ
Read the mailbox.
Definition mailbox.h:69
@ MUTT_ACL_POST
Post (submit messages to the server)
Definition mailbox.h:68
@ MUTT_ACL_CREATE
Create a mailbox.
Definition mailbox.h:62
@ MUTT_ACL_NONE
No flags are set.
Definition mailbox.h:60
@ MUTT_ACL_DELETE
Delete a message.
Definition mailbox.h:63
@ MUTT_ACL_EXPUNGE
Expunge messages.
Definition mailbox.h:65
@ MUTT_ACL_SEEN
Change the 'seen' status of a message.
Definition mailbox.h:70
@ MUTT_ACL_LOOKUP
Lookup mailbox (visible to 'list')
Definition mailbox.h:67
int mailbox_gen(void)
Get the next generation number.
Definition mailbox.c:59
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition mailbox.h:216
uint16_t AclFlags
Definition mailbox.h:73
struct Mailbox * mailbox_new(void)
Create a new Mailbox.
Definition mailbox.c:69
void mailbox_gc_add(struct Email *e)
Add an Email to the garbage-collection set.
Definition mailbox.c:297
void mailbox_update(struct Mailbox *m)
Get the mailbox's current size.
Definition mailbox.c:214
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition mailbox.c:90
struct Mailbox * mailbox_find_name(const char *name)
Find the mailbox with a given name.
Definition mailbox.c:187
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
Definition mailbox.c:232
MailboxType
Supported mailbox formats.
Definition mailbox.h:40
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition mailbox.h:50
@ MUTT_MMDF
'mmdf' Mailbox type
Definition mailbox.h:45
@ MUTT_MAILBOX_ERROR
Error occurred examining Mailbox.
Definition mailbox.h:42
@ MUTT_POP
'POP3' Mailbox type
Definition mailbox.h:51
@ MUTT_MH
'MH' Mailbox type
Definition mailbox.h:46
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition mailbox.h:48
@ MUTT_IMAP
'IMAP' Mailbox type
Definition mailbox.h:49
@ MUTT_MBOX
'mbox' Mailbox type
Definition mailbox.h:44
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
Definition mailbox.h:41
@ MUTT_COMPRESSED
Compressed file Mailbox type.
Definition mailbox.h:52
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition mailbox.h:43
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition mailbox.h:47
const char * mailbox_get_type_name(enum MailboxType type)
Get the type of a Mailbox.
Definition mailbox.c:325
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
Definition mailbox.c:151
Convenience wrapper for the library headers.
A group of associated Mailboxes.
Definition account.h:36
String manipulation buffer.
Definition buffer.h:36
A set of inherited config items.
Definition subset.h:46
The envelope/body of an email.
Definition email.h:39
An Event that happened to a Mailbox.
Definition mailbox.h:192
struct Mailbox * mailbox
The Mailbox this Event relates to.
Definition mailbox.h:193
A Hash Table.
Definition hash.h:99
A mailbox.
Definition mailbox.h:81
void(* mdata_free)(void **ptr)
Definition mailbox.h:145
int vcount
The number of virtual messages.
Definition mailbox.h:101
bool changed
Mailbox has been modified.
Definition mailbox.h:112
bool has_new
Mailbox has new mail.
Definition mailbox.h:87
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition mailbox.h:83
bool append
Mailbox is opened in append mode.
Definition mailbox.h:111
int * v2r
Mapping from virtual to real msgno.
Definition mailbox.h:100
const struct MxOps * mx_ops
MXAPI callback functions.
Definition mailbox.h:109
int msg_new
Number of new messages.
Definition mailbox.h:94
time_t last_checked
Last time we checked this mailbox for new mail.
Definition mailbox.h:107
int msg_count
Total number of messages.
Definition mailbox.h:90
bool first_check_stats_done
True when the check have been done at least one time.
Definition mailbox.h:114
AclFlags rights
ACL bits, see AclFlags.
Definition mailbox.h:121
int email_max
Size of emails array.
Definition mailbox.h:99
enum MailboxType type
Mailbox type.
Definition mailbox.h:104
bool newly_created
Mbox or mmdf just popped into existence.
Definition mailbox.h:105
bool poll_new_mail
Check for new mail.
Definition mailbox.h:117
void * mdata
Driver specific data.
Definition mailbox.h:134
struct HashTable * subj_hash
Hash Table: "Subject" -> Email.
Definition mailbox.h:126
struct Email ** emails
Array of Emails.
Definition mailbox.h:98
char * name
A short name for the Mailbox.
Definition mailbox.h:84
struct Notify * notify
Notifications: NotifyMailbox, EventMailbox.
Definition mailbox.h:147
bool notify_user
Notify the user of new mail.
Definition mailbox.h:115
struct HashTable * id_hash
Hash Table: "Message-ID" -> Email.
Definition mailbox.h:125
struct Buffer pathbuf
Path of the Mailbox.
Definition mailbox.h:82
bool peekonly
Just taking a glance, revert atime.
Definition mailbox.h:116
int msg_deleted
Number of deleted messages.
Definition mailbox.h:95
struct Account * account
Account that owns this Mailbox.
Definition mailbox.h:129
bool dontwrite
Don't write the mailbox on close.
Definition mailbox.h:113
bool notified
User has been notified.
Definition mailbox.h:103
off_t size
Size of the Mailbox.
Definition mailbox.h:86
struct HashTable * label_hash
Hash Table: "X-Label" -> Email.
Definition mailbox.h:127
bool visible
True if a result of "mailboxes".
Definition mailbox.h:132
int msg_flagged
Number of flagged messages.
Definition mailbox.h:92
int opened
Number of times mailbox is opened.
Definition mailbox.h:130
void * compress_info
Compressed mbox module private data.
Definition mailbox.h:123
struct timespec last_visited
Time of last exit from this mailbox.
Definition mailbox.h:106
bool readonly
Don't allow changes to the mailbox.
Definition mailbox.h:118
int msg_tagged
How many messages are tagged?
Definition mailbox.h:96
bool verbose
Display status messages?
Definition mailbox.h:119
int msg_unread
Number of unread messages.
Definition mailbox.h:91
int gen
Generation number, for sorting.
Definition mailbox.h:149
struct ConfigSubset * sub
Inherited config items.
Definition mailbox.h:85
Definition mxapi.h:98
Notification API.
Definition notify.c:53