NeoMutt  2025-12-11-911-gd8d604
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mailbox.h File Reference

Maildir Mailbox. More...

#include <stdbool.h>
#include <stdint.h>
#include "core/lib.h"
+ Include dependency graph for mailbox.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

enum MxStatus maildir_mbox_check (struct Mailbox *m)
 Check for new mail - Implements MxOps::mbox_check() -.
 
enum MxStatus maildir_mbox_check_stats (struct Mailbox *m, uint8_t flags)
 Check the Mailbox statistics - Implements MxOps::mbox_check_stats() -.
 
enum MxStatus maildir_mbox_close (struct Mailbox *m)
 Close a Mailbox - Implements MxOps::mbox_close() -.
 
enum MxOpenReturns maildir_mbox_open (struct Mailbox *m)
 Open a Mailbox - Implements MxOps::mbox_open() -.
 
bool maildir_mbox_open_append (struct Mailbox *m, OpenMailboxFlags flags)
 Open a Mailbox for appending - Implements MxOps::mbox_open_append() -.
 
enum MxStatus maildir_mbox_sync (struct Mailbox *m)
 Save changes to the Mailbox - Implements MxOps::mbox_sync() -.
 
void maildir_parse_flags (struct Email *e, const char *path)
 Parse Maildir file flags.
 

Detailed Description

Maildir Mailbox.

Authors
  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file mailbox.h.

Function Documentation

◆ maildir_parse_flags()

void maildir_parse_flags ( struct Email * e,
const char * path )

Parse Maildir file flags.

Parameters
eEmail
pathPath to email file

Definition at line 82 of file mailbox.c.

83{
84 char *q = NULL;
85
86 e->flagged = false;
87 e->read = false;
88 e->replied = false;
89
91 if (!edata)
92 {
95 edata = e->edata;
96 }
97
98 const char c_maildir_field_delimiter = *cc_maildir_field_delimiter();
99 const char *p = strrchr(path, c_maildir_field_delimiter);
100 if (p && mutt_str_startswith(p + 1, "2,"))
101 {
102 p += 3;
103
104 mutt_str_replace(&edata->custom_flags, p);
105 q = edata->custom_flags;
106
107 while (*p)
108 {
109 switch (*p)
110 {
111 case 'F': // Flagged
112 e->flagged = true;
113 break;
114
115 case 'R': // Replied
116 e->replied = true;
117 break;
118
119 case 'S': // Seen
120 e->read = true;
121 break;
122
123 case 'T': // Trashed
124 {
125 const bool c_flag_safe = cs_subset_bool(NeoMutt->sub, "flag_safe");
126 if (!e->flagged || !c_flag_safe)
127 {
128 e->trash = true;
129 e->deleted = true;
130 }
131 break;
132 }
133
134 default:
135 *q++ = *p;
136 break;
137 }
138 p++;
139 }
140 }
141
142 if (q == edata->custom_flags)
143 FREE(&edata->custom_flags);
144 else if (q)
145 *q = '\0';
146}
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Definition helpers.c:47
const char * cc_maildir_field_delimiter(void)
Get the cached value of $maildir_field_delimiter.
void maildir_edata_free(void **ptr)
Free the private Email data - Implements Email::edata_free() -.
Definition edata.c:38
struct MaildirEmailData * maildir_edata_get(struct Email *e)
Get the private data for this Email.
Definition edata.c:63
struct MaildirEmailData * maildir_edata_new(void)
Create a new MaildirEmailData object.
Definition edata.c:53
#define FREE(x)
Free memory and set the pointer to NULL.
Definition memory.h:68
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition string.c:234
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition string.c:284
bool read
Email is read.
Definition email.h:50
void * edata
Driver-specific data.
Definition email.h:74
void(* edata_free)(void **ptr)
Definition email.h:90
bool flagged
Marked important?
Definition email.h:47
bool replied
Email has been replied to.
Definition email.h:51
char * path
Path of Email (for local Mailboxes)
Definition email.h:70
bool deleted
Email is deleted.
Definition email.h:78
bool trash
Message is marked as trashed on disk (used by the maildir_trash option)
Definition email.h:53
Maildir-specific Email data -.
Definition edata.h:32
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49