NeoMutt  2022-04-29-145-g9b6a0e
Teaching an old dog new tricks
DOXYGEN
mailbox.h
Go to the documentation of this file.
1 
24 #ifndef MUTT_CORE_MAILBOX_H
25 #define MUTT_CORE_MAILBOX_H
26 
27 #include "config.h"
28 #include <stdbool.h>
29 #include <stdint.h>
30 #include <sys/types.h>
31 #include <time.h>
32 #include "mutt/lib.h"
33 
34 struct ConfigSubset;
35 struct Email;
36 
41 {
54 };
55 
59 typedef uint16_t AclFlags;
60 #define MUTT_ACL_NO_FLAGS 0
61 #define MUTT_ACL_ADMIN (1 << 0)
62 #define MUTT_ACL_CREATE (1 << 1)
63 #define MUTT_ACL_DELETE (1 << 2)
64 #define MUTT_ACL_DELMX (1 << 3)
65 #define MUTT_ACL_EXPUNGE (1 << 4)
66 #define MUTT_ACL_INSERT (1 << 5)
67 #define MUTT_ACL_LOOKUP (1 << 6)
68 #define MUTT_ACL_POST (1 << 7)
69 #define MUTT_ACL_READ (1 << 8)
70 #define MUTT_ACL_SEEN (1 << 9)
71 #define MUTT_ACL_WRITE (1 << 10)
72 
73 #define MUTT_ACL_ALL ((1 << 11) - 1)
74 
78 struct Mailbox
79 {
80  struct Buffer pathbuf;
81  char *realpath;
82  char *name;
83  struct ConfigSubset *sub;
84  off_t size;
85  bool has_new;
86 
87  // These next three are only set when MailCheckStats is set
88  int msg_count;
89  int msg_unread;
91 
92  int msg_new;
94  int msg_tagged;
95 
96  struct Email **emails;
97  int email_max;
98  int *v2r;
99  int vcount;
100 
101  bool notified;
102  enum MailboxType type;
104  struct timespec mtime;
105  struct timespec last_visited;
107 
108  const struct MxOps *mx_ops;
109 
110  bool append : 1;
111  bool changed : 1;
112  bool dontwrite : 1;
114  bool peekonly : 1;
115  bool verbose : 1;
116  bool readonly : 1;
117 
119 
120 #ifdef USE_COMP_MBOX
122 #endif
123 
124  struct HashTable *id_hash;
127 
128  struct Account *account;
129  int opened;
130 
131  bool visible;
132 
133  void *mdata;
134 
143  void (*mdata_free)(void **ptr);
144 
145  struct Notify *notify;
146 
147  int gen;
148 };
149 
154 {
155  struct Mailbox *mailbox;
157 };
158 STAILQ_HEAD(MailboxList, MailboxNode);
159 
169 {
174 
175  /* These don't really belong here as they are tied to GUI operations.
176  * Eventually, they'll be eliminated. */
181 };
182 
187 {
188  struct Mailbox *mailbox;
189 };
190 
191 void mailbox_changed (struct Mailbox *m, enum NotifyMailbox action);
192 struct Mailbox *mailbox_find (const char *path);
193 struct Mailbox *mailbox_find_name (const char *name);
194 void mailbox_free (struct Mailbox **ptr);
195 int mailbox_gen (void);
196 struct Mailbox *mailbox_new (void);
197 bool mailbox_set_subset(struct Mailbox *m, struct ConfigSubset *sub);
198 void mailbox_size_add (struct Mailbox *m, const struct Email *e);
199 void mailbox_size_sub (struct Mailbox *m, const struct Email *e);
200 void mailbox_update (struct Mailbox *m);
201 void mailbox_gc_add (struct Email *e);
202 void mailbox_gc_run (void);
203 
204 const char *mailbox_get_type_name(enum MailboxType type);
205 
211 static inline const char *mailbox_path(const struct Mailbox *m) // LCOV_EXCL_LINE
212 {
213  return mutt_buffer_string(&m->pathbuf); // LCOV_EXCL_LINE
214 }
215 
216 #endif /* MUTT_CORE_MAILBOX_H */
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
struct Mailbox * mailbox_new(void)
Create a new Mailbox.
Definition: mailbox.c:68
NotifyMailbox
Types of Mailbox Event.
Definition: mailbox.h:169
@ NT_MAILBOX_UNTAG
Clear the 'last-tagged' pointer.
Definition: mailbox.h:180
@ NT_MAILBOX_CHANGE
Mailbox has been changed.
Definition: mailbox.h:173
@ NT_MAILBOX_RESORT
Email list needs resorting.
Definition: mailbox.h:178
@ NT_MAILBOX_DELETE
Mailbox is about to be deleted.
Definition: mailbox.h:171
@ NT_MAILBOX_INVALID
Email list was changed.
Definition: mailbox.h:177
@ NT_MAILBOX_DELETE_ALL
All Mailboxes are about to be deleted.
Definition: mailbox.h:172
@ NT_MAILBOX_UPDATE
Update internal tables.
Definition: mailbox.h:179
@ NT_MAILBOX_ADD
Mailbox has been added.
Definition: mailbox.h:170
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:211
bool mailbox_set_subset(struct Mailbox *m, struct ConfigSubset *sub)
Set a Mailbox's Config Subset.
Definition: mailbox.c:258
void mailbox_gc_run(void)
Run the garbage-collection.
Definition: mailbox.c:296
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:237
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:247
int mailbox_gen(void)
Get the next generation number.
Definition: mailbox.c:58
uint16_t AclFlags
ACL Rights - These show permission to...
Definition: mailbox.h:59
void mailbox_gc_add(struct Email *e)
Add an Email to the garbage-collection set.
Definition: mailbox.c:282
void mailbox_update(struct Mailbox *m)
Get the mailbox's current size.
Definition: mailbox.c:204
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:87
const char * mailbox_get_type_name(enum MailboxType type)
Get the type of a Mailbox.
Definition: mailbox.c:310
STAILQ_HEAD(MailboxList, MailboxNode)
struct Mailbox * mailbox_find_name(const char *name)
Find the mailbox with a given name.
Definition: mailbox.c:176
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
Definition: mailbox.c:222
struct Mailbox * mailbox_find(const char *path)
Find the mailbox with a given path.
Definition: mailbox.c:139
MailboxType
Supported mailbox formats.
Definition: mailbox.h:41
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition: mailbox.h:51
@ MUTT_MMDF
'mmdf' Mailbox type
Definition: mailbox.h:46
@ MUTT_MAILBOX_ERROR
Error occurred examining Mailbox.
Definition: mailbox.h:43
@ MUTT_POP
'POP3' Mailbox type
Definition: mailbox.h:52
@ MUTT_MH
'MH' Mailbox type
Definition: mailbox.h:47
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition: mailbox.h:49
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:50
@ MUTT_MBOX
'mbox' Mailbox type
Definition: mailbox.h:45
@ MUTT_MAILBOX_ANY
Match any Mailbox type.
Definition: mailbox.h:42
@ MUTT_COMPRESSED
Compressed file Mailbox type.
Definition: mailbox.h:53
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition: mailbox.h:44
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition: mailbox.h:48
Convenience wrapper for the library headers.
A group of associated Mailboxes.
Definition: account.h:37
String manipulation buffer.
Definition: buffer.h:34
A set of inherited config items.
Definition: subset.h:47
The envelope/body of an email.
Definition: email.h:37
An Event that happened to a Mailbox.
Definition: mailbox.h:187
struct Mailbox * mailbox
The Mailbox this Event relates to.
Definition: mailbox.h:188
A Hash Table.
Definition: hash.h:97
List of Mailboxes.
Definition: mailbox.h:154
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:155
STAILQ_ENTRY(MailboxNode) entries
Linked list.
A mailbox.
Definition: mailbox.h:79
void(* mdata_free)(void **ptr)
Free the private data attached to the Mailbox.
Definition: mailbox.h:143
int vcount
The number of virtual messages.
Definition: mailbox.h:99
bool changed
Mailbox has been modified.
Definition: mailbox.h:111
bool has_new
Mailbox has new mail.
Definition: mailbox.h:85
struct timespec mtime
Time Mailbox was last changed.
Definition: mailbox.h:104
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:81
bool append
Mailbox is opened in append mode.
Definition: mailbox.h:110
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:98
const struct MxOps * mx_ops
MXAPI callback functions.
Definition: mailbox.h:108
int msg_new
Number of new messages.
Definition: mailbox.h:92
int msg_count
Total number of messages.
Definition: mailbox.h:88
bool first_check_stats_done
True when the check have been done at least on time.
Definition: mailbox.h:113
AclFlags rights
ACL bits, see AclFlags.
Definition: mailbox.h:118
int email_max
Number of pointers in emails.
Definition: mailbox.h:97
enum MailboxType type
Mailbox type.
Definition: mailbox.h:102
bool newly_created
Mbox or mmdf just popped into existence.
Definition: mailbox.h:103
void * mdata
Driver specific data.
Definition: mailbox.h:133
struct HashTable * subj_hash
Hash Table by subject.
Definition: mailbox.h:125
struct Email ** emails
Array of Emails.
Definition: mailbox.h:96
char * name
A short name for the Mailbox.
Definition: mailbox.h:82
struct Notify * notify
Notifications: NotifyMailbox, EventMailbox.
Definition: mailbox.h:145
struct HashTable * id_hash
Hash Table by msg id.
Definition: mailbox.h:124
struct Buffer pathbuf
Path of the Mailbox.
Definition: mailbox.h:80
bool peekonly
Just taking a glance, revert atime.
Definition: mailbox.h:114
int msg_deleted
Number of deleted messages.
Definition: mailbox.h:93
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:128
bool dontwrite
Don't write the mailbox on close.
Definition: mailbox.h:112
bool notified
User has been notified.
Definition: mailbox.h:101
off_t size
Size of the Mailbox.
Definition: mailbox.h:84
struct HashTable * label_hash
Hash Table for x-labels.
Definition: mailbox.h:126
bool visible
True if a result of "mailboxes".
Definition: mailbox.h:131
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:90
int opened
Number of times mailbox is opened.
Definition: mailbox.h:129
void * compress_info
Compressed mbox module private data.
Definition: mailbox.h:121
struct timespec last_visited
Time of last exit from this mailbox.
Definition: mailbox.h:105
bool readonly
Don't allow changes to the mailbox.
Definition: mailbox.h:116
struct timespec stats_last_checked
Mtime of mailbox the last time stats where checked.
Definition: mailbox.h:106
int msg_tagged
How many messages are tagged?
Definition: mailbox.h:94
bool verbose
Display status messages?
Definition: mailbox.h:115
int msg_unread
Number of unread messages.
Definition: mailbox.h:89
int gen
Generation number, for sorting.
Definition: mailbox.h:147
struct ConfigSubset * sub
Inherited config items.
Definition: mailbox.h:83
Definition: mxapi.h:112
Notification API.
Definition: notify.c:51
Time value with nanosecond precision.
Definition: file.h:49