NeoMutt  2018-07-16 +952-a2da0a
Teaching an old dog new tricks
DOXYGEN
mx.c File Reference

Mailbox multiplexor. More...

#include "config.h"
#include <errno.h>
#include <limits.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include <utime.h>
#include "mutt/mutt.h"
#include "email/lib.h"
#include "mutt.h"
#include "mx.h"
#include "account.h"
#include "alias.h"
#include "context.h"
#include "copy.h"
#include "globals.h"
#include "hook.h"
#include "keymap.h"
#include "mailbox.h"
#include "maildir/lib.h"
#include "mbox/mbox.h"
#include "mutt_header.h"
#include "mutt_logging.h"
#include "mutt_thread.h"
#include "muttlib.h"
#include "ncrypt/ncrypt.h"
#include "opcodes.h"
#include "options.h"
#include "pattern.h"
#include "protos.h"
#include "score.h"
#include "sort.h"
#include "sidebar.h"
#include "compress.h"
#include "imap/imap.h"
#include "pop/pop.h"
#include "nntp/nntp.h"
#include "notmuch/mutt_notmuch.h"
#include <libintl.h>
+ Include dependency graph for mx.c:

Go to the source code of this file.

Functions

const struct MxOpsmx_get_ops (enum MailboxType magic)
 Get mailbox operations. More...
 
static bool mutt_is_spool (const char *str)
 Is this the spoolfile? More...
 
int mx_access (const char *path, int flags)
 Wrapper for access, checks permissions on a given mailbox. More...
 
static int mx_open_mailbox_append (struct Mailbox *m, int flags)
 Open a mailbox for appending. More...
 
struct Contextmx_mbox_open (struct Mailbox *m, const char *path, int flags)
 Open a mailbox and parse it. More...
 
void mx_fastclose_mailbox (struct Context *ctx)
 free up memory associated with the mailbox context More...
 
static int sync_mailbox (struct Context *ctx, int *index_hint)
 save changes to disk More...
 
static int trash_append (struct Mailbox *m)
 move deleted mails to the trash folder More...
 
int mx_mbox_close (struct Context **pctx, int *index_hint)
 Save changes and close mailbox. More...
 
void mx_update_tables (struct Context *ctx, bool committing)
 Update a Context structure's internal tables. More...
 
int mx_mbox_sync (struct Context *ctx, int *index_hint)
 Save changes to mailbox. More...
 
struct Messagemx_msg_open_new (struct Mailbox *m, struct Email *e, int flags)
 Open a new message. More...
 
int mx_mbox_check (struct Context *ctx, int *index_hint)
 Check for new mail - Wrapper for MxOps::mbox_check() More...
 
struct Messagemx_msg_open (struct Mailbox *m, int msgno)
 return a stream pointer for a message More...
 
int mx_msg_commit (struct Mailbox *m, struct Message *msg)
 Commit a message to a folder - Wrapper for MxOps::msg_commit() More...
 
int mx_msg_close (struct Mailbox *m, struct Message **msg)
 Close a message. More...
 
void mx_alloc_memory (struct Mailbox *m)
 Create storage for the emails. More...
 
void mx_update_context (struct Context *ctx)
 Update the Context's message counts. More...
 
int mx_check_empty (const char *path)
 Is the mailbox empty. More...
 
int mx_tags_edit (struct Mailbox *m, const char *tags, char *buf, size_t buflen)
 start the tag editor of the mailbox More...
 
int mx_tags_commit (struct Mailbox *m, struct Email *e, char *tags)
 Save tags to the Mailbox - Wrapper for MxOps::tags_commit() More...
 
bool mx_tags_is_supported (struct Mailbox *m)
 return true if mailbox support tagging More...
 
enum MailboxType mx_path_probe (const char *path, struct stat *st)
 Find a mailbox that understands a path. More...
 
int mx_path_canon (char *buf, size_t buflen, const char *folder, enum MailboxType *magic)
 Canonicalise a mailbox path - Wrapper for MxOps::path_canon. More...
 
int mx_path_canon2 (struct Mailbox *m, const char *folder)
 XXX canonicalise the path to realpath. More...
 
int mx_path_pretty (char *buf, size_t buflen, const char *folder)
 Abbreviate a mailbox path - Wrapper for MxOps::path_pretty. More...
 
int mx_path_parent (char *buf, size_t buflen)
 Find the parent of a mailbox path - Wrapper for MxOps::path_parent. More...
 
int mx_msg_padding_size (struct Mailbox *m)
 Bytes of padding between messages - Wrapper for MxOps::msg_padding_size. More...
 
struct Accountmx_ac_find (struct Mailbox *m)
 XXX. More...
 
struct Mailboxmx_mbox_find (struct Account *a, const char *path)
 XXX. More...
 
struct Mailboxmx_mbox_find2 (const char *path)
 XXX. More...
 
int mx_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to an Account - Wrapper for MxOps::ac_add. More...
 
int mx_ac_remove (struct Mailbox *m)
 Remove a Mailbox from an Account and delete Account if empty. More...
 
void mx_cleanup_context (struct Context *ctx)
 Release memory and initialize a Context object. More...
 
int mx_mbox_check_stats (struct Mailbox *m, int flags)
 Check the statistics for a mailbox - Wrapper for MxOps::mbox_check_stats. More...
 

Variables

unsigned char CatchupNewsgroup
 Config: (nntp) Mark all articles as read when leaving a newsgroup. More...
 
bool KeepFlagged
 Config: Don't move flagged messages from Spoolfile to Mbox. More...
 
short MboxType
 Config: Default type for creating new mailboxes. More...
 
unsigned char Move
 Config: Move emails from Spoolfile to Mbox when read. More...
 
char * Trash
 Config: Folder to put deleted emails. More...
 
static const struct MxOpsmx_ops []
 All the Mailbox backends. More...
 

Detailed Description

Mailbox multiplexor.

Authors
  • Michael R. Elkins
  • Thomas Roessler
  • 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 mx.c.

Function Documentation

const struct MxOps* mx_get_ops ( enum MailboxType  magic)

Get mailbox operations.

Parameters
magicMailbox magic number
Return values
ptrMailbox function
NULLError

Definition at line 133 of file mx.c.

134 {
135  for (const struct MxOps **ops = mx_ops; *ops; ops++)
136  if ((*ops)->magic == magic)
137  return *ops;
138 
139  return NULL;
140 }
static const struct MxOps * mx_ops[]
All the Mailbox backends.
Definition: mx.c:99
The Mailbox API.
Definition: mx.h:103

+ Here is the caller graph for this function:

static bool mutt_is_spool ( const char *  str)
static

Is this the spoolfile?

Parameters
strName to check
Return values
trueIt is the spoolfile

Definition at line 147 of file mx.c.

148 {
149  return mutt_str_strcmp(Spoolfile, str) == 0;
150 }
WHERE char * Spoolfile
Config: Inbox.
Definition: globals.h:147
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_access ( const char *  path,
int  flags 
)

Wrapper for access, checks permissions on a given mailbox.

Parameters
pathPath of mailbox
flagsFlags, e.g. W_OK
Return values
0Success, allowed
<0Failure, not allowed

We may be interested in using ACL-style flags at some point, currently we use the normal access() flags.

Definition at line 162 of file mx.c.

163 {
164 #ifdef USE_IMAP
165  if (imap_path_probe(path, NULL) == MUTT_IMAP)
166  return imap_access(path);
167 #endif
168 
169  return access(path, flags);
170 }
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2479
&#39;IMAP&#39; Mailbox type
Definition: magic.h:42
int imap_access(const char *path)
Check permissions on an IMAP mailbox with a new connection.
Definition: imap.c:592

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int mx_open_mailbox_append ( struct Mailbox m,
int  flags 
)
static

Open a mailbox for appending.

Parameters
mMailbox
flagsFlags, e.g. MUTT_READONLY
Return values
0Success
-1Failure

Definition at line 179 of file mx.c.

180 {
181  if (!m)
182  return -1;
183 
184  struct stat sb;
185 
186  m->append = true;
187  if ((m->magic == MUTT_UNKNOWN) || (m->magic == MUTT_MAILBOX_ERROR))
188  {
189  m->magic = mx_path_probe(m->path, NULL);
190 
191  if (m->magic == MUTT_UNKNOWN)
192  {
193  if (flags & (MUTT_APPEND | MUTT_NEWFOLDER))
194  {
196  }
197  else
198  {
199  mutt_error(_("%s is not a mailbox"), m->path);
200  return -1;
201  }
202  }
203 
204  if (m->magic == MUTT_MAILBOX_ERROR)
205  {
206  if (stat(m->path, &sb) == -1)
207  {
208  if (errno == ENOENT)
209  {
210 #ifdef USE_COMPRESSED
211  if (mutt_comp_can_append(m))
212  m->magic = MUTT_COMPRESSED;
213  else
214 #endif
215  m->magic = MboxType;
216  flags |= MUTT_APPENDNEW;
217  }
218  else
219  {
220  mutt_perror(m->path);
221  return -1;
222  }
223  }
224  else
225  return -1;
226  }
227 
228  m->mx_ops = mx_get_ops(m->magic);
229  }
230 
231  if (!m->mx_ops || !m->mx_ops->mbox_open_append)
232  return -1;
233 
234  int rc = m->mx_ops->mbox_open_append(m, flags);
235  m->opened++;
236  return rc;
237 }
#define MUTT_APPEND
open mailbox for appending messages
Definition: mx.h:50
#define MUTT_APPENDNEW
set in mx_open_mailbox_append if the mailbox doesn&#39;t exist.
Definition: mx.h:59
#define mutt_perror(...)
Definition: logging.h:89
#define _(a)
Definition: message.h:28
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
int opened
number of times mailbox is opened
Definition: mailbox.h:126
int(* mbox_open_append)(struct Mailbox *m, int flags)
Open a mailbox for appending.
Definition: mx.h:140
bool append
mailbox is opened in append mode
Definition: mailbox.h:107
Error occurred examining mailbox.
Definition: magic.h:35
const struct MxOps * mx_ops
Definition: mailbox.h:105
bool mutt_comp_can_append(struct Mailbox *m)
Can we append to this path?
Definition: compress.c:406
char path[PATH_MAX]
Definition: mailbox.h:78
Mailbox wasn&#39;t recognised.
Definition: magic.h:36
const struct MxOps * mx_get_ops(enum MailboxType magic)
Get mailbox operations.
Definition: mx.c:133
#define mutt_error(...)
Definition: logging.h:88
Compressed file Mailbox type.
Definition: magic.h:45
#define MUTT_NEWFOLDER
create a new folder - same as MUTT_APPEND, but uses mutt_file_fopen() with mode "w" for mbox-style fo...
Definition: mx.h:53
short MboxType
Config: Default type for creating new mailboxes.
Definition: mx.c:92
enum MailboxType mx_path_probe(const char *path, struct stat *st)
Find a mailbox that understands a path.
Definition: mx.c:1438

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

struct Context* mx_mbox_open ( struct Mailbox m,
const char *  path,
int  flags 
)

Open a mailbox and parse it.

Parameters
mMailbox to open
pathPath to the mailbox
flagsSee below
Return values
ptrMailbox context
NULLError

flags:

Definition at line 254 of file mx.c.

255 {
256  if (!m && (!path || !path[0]))
257  return NULL;
258 
259  struct Context *ctx = mutt_mem_calloc(1, sizeof(*ctx));
260  ctx->mailbox = m;
261  if (!m)
262  {
263  m = mx_mbox_find2(path);
264  ctx->mailbox = m;
265  }
266 
267  if (!m)
268  {
269  m = mailbox_new();
270  ctx->mailbox = m;
271  m->flags = MB_HIDDEN;
272  mutt_str_strfcpy(m->path, path, sizeof(m->path));
273  /* int rc = */ mx_path_canon2(m, Folder);
274  }
275 
276  if (!m->account)
277  m->account = mx_ac_find(m);
278 
279  if (!m->account)
280  {
281  struct Account *a = account_new();
282  m->account = a;
283  a->magic = m->magic;
284  TAILQ_INSERT_TAIL(&AllAccounts, a, entries);
285  mx_ac_add(a, m);
286  }
287 
288 #if 0
289  if (!realpath(m->path, m->realpath))
290  {
292  sizeof(m->realpath));
293  }
294 #endif
295 
296  ctx->msgnotreadyet = -1;
297  ctx->collapsed = false;
298 
299  m->msg_unread = 0;
300  m->msg_flagged = 0;
301 
302  for (int i = 0; i < MUTT_ACL_MAX; i++)
303  mutt_bit_set(m->rights, i);
304 
305  if (flags & MUTT_QUIET)
306  m->quiet = true;
307  if (flags & MUTT_READONLY)
308  m->readonly = true;
309  if (flags & MUTT_PEEK)
310  m->peekonly = true;
311 
312  if (flags & (MUTT_APPEND | MUTT_NEWFOLDER))
313  {
314  if (mx_open_mailbox_append(ctx->mailbox, flags) != 0)
315  {
317  mutt_context_free(&ctx);
318  return NULL;
319  }
320  return ctx;
321  }
322 
323  if (!m->magic)
324  {
325  m->magic = mx_path_probe(path, NULL);
326  m->mx_ops = mx_get_ops(m->magic);
327  }
328 
329  // if (m->path[0] == '\0')
330  // mutt_str_strfcpy(m->path, path, sizeof(m->path));
331 
332  if ((m->magic == MUTT_UNKNOWN) || (m->magic == MUTT_MAILBOX_ERROR) || !m->mx_ops)
333  {
334  if (m->magic == MUTT_MAILBOX_ERROR)
335  mutt_perror(path);
336  else if (m->magic == MUTT_UNKNOWN || !m->mx_ops)
337  mutt_error(_("%s is not a mailbox"), path);
338 
340  mutt_context_free(&ctx);
341  return NULL;
342  }
343 
344  if (!m->account)
345  {
346  struct Account *a = account_new();
347  a->magic = m->magic;
348  TAILQ_INSERT_TAIL(&AllAccounts, a, entries);
349 
350  if (mx_ac_add(a, m) < 0)
351  {
352  //error
353  mailbox_free(&m);
354  return NULL;
355  }
356  }
357 
359 
360  /* if the user has a `push' command in their .neomuttrc, or in a folder-hook,
361  * it will cause the progress messages not to be displayed because
362  * mutt_refresh() will think we are in the middle of a macro. so set a
363  * flag to indicate that we should really refresh the screen.
364  */
365  OptForceRefresh = true;
366 
367  if (!m->quiet)
368  mutt_message(_("Reading %s..."), m->path);
369 
370  int rc = m->mx_ops->mbox_open(ctx->mailbox, ctx);
371  m->opened++;
372  if (rc == 0)
373  mx_update_context(ctx);
374 
375  if ((rc == 0) || (rc == -2))
376  {
377  if ((flags & MUTT_NOSORT) == 0)
378  {
379  /* avoid unnecessary work since the mailbox is completely unthreaded
380  to begin with */
381  OptSortSubthreads = false;
382  OptNeedRescore = false;
383  mutt_sort_headers(ctx, true);
384  }
385  if (!m->quiet)
387  if (rc == -2)
388  mutt_error(_("Reading from %s interrupted..."), m->path);
389  }
390  else
391  {
393  mutt_context_free(&ctx);
394  }
395 
396  OptForceRefresh = false;
397  return ctx;
398 }
#define MUTT_APPEND
open mailbox for appending messages
Definition: mx.h:50
The "current" mailbox.
Definition: context.h:36
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
#define mutt_perror(...)
Definition: logging.h:89
int msg_unread
number of unread messages
Definition: mailbox.h:87
int mx_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Wrapper for MxOps::ac_add.
Definition: mx.c:1737
int mx_path_canon2(struct Mailbox *m, const char *folder)
XXX canonicalise the path to realpath.
Definition: mx.c:1597
#define mutt_message(...)
Definition: logging.h:87
unsigned char rights[(MUTT_ACL_MAX+7)/8]
ACL bits.
Definition: mailbox.h:115
int msg_flagged
number of flagged messages
Definition: mailbox.h:88
bool peekonly
just taking a glance, revert atime
Definition: mailbox.h:111
static int mx_open_mailbox_append(struct Mailbox *m, int flags)
Open a mailbox for appending.
Definition: mx.c:179
int msgnotreadyet
which msg "new" in pager, -1 if none
Definition: context.h:44
int(* mbox_open)(struct Mailbox *m, struct Context *ctx)
Open a mailbox.
Definition: mx.h:132
XXX.
Definition: account.h:36
#define _(a)
Definition: message.h:28
#define MUTT_READONLY
open in read-only mode
Definition: mx.h:51
struct Mailbox * mx_mbox_find2(const char *path)
XXX.
Definition: mx.c:1714
WHERE bool OptNeedRescore
(pseudo) set when the `score&#39; command is used
Definition: options.h:39
struct Account * mx_ac_find(struct Mailbox *m)
XXX.
Definition: mx.c:1671
void mx_update_context(struct Context *ctx)
Update the Context&#39;s message counts.
Definition: mx.c:1247
struct AccountList AllAccounts
List of all Accounts.
Definition: account.c:33
struct Mailbox * mailbox
Definition: context.h:50
#define MUTT_PEEK
revert atime back after taking a look (if applicable)
Definition: mx.h:58
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
bool readonly
don&#39;t allow changes to the mailbox
Definition: mailbox.h:113
int opened
number of times mailbox is opened
Definition: mailbox.h:126
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:141
int flags
e.g.
Definition: mailbox.h:128
WHERE bool OptForceRefresh
(pseudo) refresh even during macros
Definition: options.h:34
A folder/dir in the browser.
Definition: browser.h:47
#define MB_HIDDEN
Definition: mailbox.h:50
void mutt_sort_headers(struct Context *ctx, bool init)
Sort emails by their headers.
Definition: sort.c:360
enum MailboxType magic
Definition: account.h:38
#define MUTT_NOSORT
do not sort the mailbox after opening it
Definition: mx.h:49
void mx_fastclose_mailbox(struct Context *ctx)
free up memory associated with the mailbox context
Definition: mx.c:404
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:742
#define TAILQ_INSERT_TAIL(head, elm, field)
Definition: queue.h:803
Error occurred examining mailbox.
Definition: magic.h:35
const struct MxOps * mx_ops
Definition: mailbox.h:105
bool quiet
inhibit status messages?
Definition: mailbox.h:112
#define MUTT_QUIET
do not print any messages
Definition: mx.h:52
char path[PATH_MAX]
Definition: mailbox.h:78
void mutt_make_label_hash(struct Mailbox *m)
Create a Hash Table to store the labels.
Definition: mutt_header.c:377
struct Mailbox * mailbox_new(void)
Create a new Mailbox.
Definition: mailbox.c:91
struct Account * account
Definition: mailbox.h:125
Mailbox wasn&#39;t recognised.
Definition: magic.h:36
const struct MxOps * mx_get_ops(enum MailboxType magic)
Get mailbox operations.
Definition: mx.c:133
bool collapsed
are all threads collapsed?
Definition: context.h:48
#define mutt_error(...)
Definition: logging.h:88
WHERE bool OptSortSubthreads
(pseudo) used when $sort_aux changes
Definition: options.h:51
void mailbox_free(struct Mailbox **m)
Free a Mailbox.
Definition: mailbox.c:109
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
#define MUTT_NEWFOLDER
create a new folder - same as MUTT_APPEND, but uses mutt_file_fopen() with mode "w" for mbox-style fo...
Definition: mx.h:53
struct Account * account_new(void)
Create a new Account.
Definition: account.c:39
enum MailboxType mx_path_probe(const char *path, struct stat *st)
Find a mailbox that understands a path.
Definition: mx.c:1438
#define mutt_bit_set(v, n)
Definition: memory.h:36
void mutt_context_free(struct Context **ctx)
Free a Context.
Definition: mailbox.c:730

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mx_fastclose_mailbox ( struct Context ctx)

free up memory associated with the mailbox context

Parameters
ctxMailbox

Definition at line 404 of file mx.c.

405 {
406  if (!ctx || !ctx->mailbox)
407  return;
408 
409  struct Mailbox *m = ctx->mailbox;
410 
411  m->opened--;
412  if (m->opened != 0)
413  return;
414 
415  /* never announce that a mailbox we've just left has new mail. #3290
416  * TODO: really belongs in mx_mbox_close, but this is a nice hook point */
417  if (!m->peekonly)
419 
420  if (m->mx_ops)
421  m->mx_ops->mbox_close(ctx);
422 
426  if (m->hdrs)
427  {
428  mutt_clear_threads(ctx);
429  for (int i = 0; i < m->msg_count; i++)
430  mutt_email_free(&m->hdrs[i]);
431  FREE(&m->hdrs);
432  }
433  FREE(&m->v2r);
434  mx_cleanup_context(ctx);
435 }
int msg_count
total number of messages
Definition: mailbox.h:86
bool peekonly
just taking a glance, revert atime
Definition: mailbox.h:111
int(* mbox_close)(struct Context *ctx)
Close a mailbox.
Definition: mx.h:171
void mutt_mailbox_setnotified(struct Mailbox *m)
Note when the user was last notified of new mail.
Definition: mailbox.c:659
void mutt_hash_destroy(struct Hash **ptr)
Destroy a hash table.
Definition: hash.c:458
struct Email ** hdrs
Definition: mailbox.h:93
struct Mailbox * mailbox
Definition: context.h:50
int opened
number of times mailbox is opened
Definition: mailbox.h:126
A mailbox.
Definition: mailbox.h:76
const struct MxOps * mx_ops
Definition: mailbox.h:105
void mutt_email_free(struct Email **e)
Free an Email.
Definition: email.c:41
void mutt_clear_threads(struct Context *ctx)
Clear the threading of message in a mailbox.
Definition: mutt_thread.c:598
int * v2r
mapping from virtual to real msgno
Definition: mailbox.h:95
void mx_cleanup_context(struct Context *ctx)
Release memory and initialize a Context object.
Definition: mx.c:1762
struct Hash * subj_hash
hash table by subject
Definition: mailbox.h:122
#define FREE(x)
Definition: memory.h:46
struct Hash * label_hash
hash table for x-labels
Definition: mailbox.h:123
struct Hash * id_hash
hash table by msg id
Definition: mailbox.h:121

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int sync_mailbox ( struct Context ctx,
int *  index_hint 
)
static

save changes to disk

Parameters
ctxMailbox
index_hintCurrent email
Return values
0Success
-1Failure

Definition at line 444 of file mx.c.

445 {
446  if (!ctx || !ctx->mailbox || !ctx->mailbox->mx_ops || !ctx->mailbox->mx_ops->mbox_sync)
447  return -1;
448 
449  struct Mailbox *m = ctx->mailbox;
450 
451  if (!m->quiet)
452  {
453  /* L10N: Displayed before/as a mailbox is being synced */
454  mutt_message(_("Writing %s..."), m->path);
455  }
456 
457  int rc = m->mx_ops->mbox_sync(ctx, index_hint);
458  if ((rc != 0) && !m->quiet)
459  {
460  /* L10N: Displayed if a mailbox sync fails */
461  mutt_error(_("Unable to write %s"), m->path);
462  }
463 
464  return rc;
465 }
int(* mbox_sync)(struct Context *ctx, int *index_hint)
Save changes to the mailbox.
Definition: mx.h:164
#define mutt_message(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
struct Mailbox * mailbox
Definition: context.h:50
A mailbox.
Definition: mailbox.h:76
const struct MxOps * mx_ops
Definition: mailbox.h:105
bool quiet
inhibit status messages?
Definition: mailbox.h:112
char path[PATH_MAX]
Definition: mailbox.h:78
#define mutt_error(...)
Definition: logging.h:88

+ Here is the caller graph for this function:

static int trash_append ( struct Mailbox m)
static

move deleted mails to the trash folder

Parameters
mMailbox
Return values
0Success
-1Failure

Definition at line 473 of file mx.c.

474 {
475  if (!m)
476  return -1;
477 
478  int i;
479  struct stat st, stc;
480  int opt_confappend, rc;
481 
482  if (!Trash || !m->msg_deleted || (m->magic == MUTT_MAILDIR && MaildirTrash))
483  {
484  return 0;
485  }
486 
487  int delmsgcount = 0;
488  int first_del = -1;
489  for (i = 0; i < m->msg_count; i++)
490  {
491  if (m->hdrs[i]->deleted && (!m->hdrs[i]->purge))
492  {
493  if (first_del < 0)
494  first_del = i;
495  delmsgcount++;
496  }
497  }
498 
499  if (delmsgcount == 0)
500  return 0; /* nothing to be done */
501 
502  /* avoid the "append messages" prompt */
503  opt_confappend = Confirmappend;
504  if (opt_confappend)
505  Confirmappend = false;
506  rc = mutt_save_confirm(Trash, &st);
507  if (opt_confappend)
508  Confirmappend = true;
509  if (rc != 0)
510  {
511  /* L10N: Although we know the precise number of messages, we do not show it to the user.
512  So feel free to use a "generic plural" as plural translation if your language has one.
513  */
514  mutt_error(ngettext("message not deleted", "messages not deleted", delmsgcount));
515  return -1;
516  }
517 
518  if (lstat(m->path, &stc) == 0 && stc.st_ino == st.st_ino &&
519  stc.st_dev == st.st_dev && stc.st_rdev == st.st_rdev)
520  {
521  return 0; /* we are in the trash folder: simple sync */
522  }
523 
524 #ifdef USE_IMAP
525  if (Context->mailbox->magic == MUTT_IMAP && (imap_path_probe(Trash, NULL) == MUTT_IMAP))
526  {
527  if (imap_fast_trash(Context->mailbox, Trash) == 0)
528  return 0;
529  }
530 #endif
531 
532  struct Context *ctx_trash = mx_mbox_open(NULL, Trash, MUTT_APPEND);
533  if (ctx_trash)
534  {
535  /* continue from initial scan above */
536  for (i = first_del; i < m->msg_count; i++)
537  {
538  if (m->hdrs[i]->deleted && (!m->hdrs[i]->purge))
539  {
540  if (mutt_append_message(ctx_trash->mailbox, m, m->hdrs[i], 0, 0) == -1)
541  {
542  mx_mbox_close(&ctx_trash, NULL);
543  return -1;
544  }
545  }
546  }
547 
548  mx_mbox_close(&ctx_trash, NULL);
549  }
550  else
551  {
552  mutt_error(_("Can't open trash folder"));
553  return -1;
554  }
555 
556  return 0;
557 }
#define MUTT_APPEND
open mailbox for appending messages
Definition: mx.h:50
The "current" mailbox.
Definition: context.h:36
int msg_count
total number of messages
Definition: mailbox.h:86
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2479
int msg_deleted
number of deleted messages
Definition: mailbox.h:90
&#39;Maildir&#39; Mailbox type
Definition: magic.h:40
#define _(a)
Definition: message.h:28
&#39;IMAP&#39; Mailbox type
Definition: magic.h:42
struct Email ** hdrs
Definition: mailbox.h:93
WHERE bool MaildirTrash
Config: Use the maildir &#39;trashed&#39; flag, rather than deleting.
Definition: globals.h:242
int mutt_save_confirm(const char *s, struct stat *st)
Ask the user to save.
Definition: muttlib.c:1383
struct Context * mx_mbox_open(struct Mailbox *m, const char *path, int flags)
Open a mailbox and parse it.
Definition: mx.c:254
struct Mailbox * mailbox
Definition: context.h:50
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
int mx_mbox_close(struct Context **pctx, int *index_hint)
Save changes and close mailbox.
Definition: mx.c:568
bool purge
skip trash folder when deleting
Definition: email.h:44
char path[PATH_MAX]
Definition: mailbox.h:78
WHERE bool Confirmappend
Config: Confirm before appending emails to a mailbox.
Definition: globals.h:209
char * Trash
Config: Folder to put deleted emails.
Definition: mx.c:94
bool deleted
Definition: email.h:43
#define mutt_error(...)
Definition: logging.h:88
int imap_fast_trash(struct Mailbox *m, char *dest)
Use server COPY command to copy deleted messages to trash.
Definition: imap.c:1527
int mutt_append_message(struct Mailbox *dest, struct Mailbox *src, struct Email *e, int cmflags, int chflags)
Append a message.
Definition: copy.c:862

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_mbox_close ( struct Context **  pctx,
int *  index_hint 
)

Save changes and close mailbox.

Parameters
pctxMailbox
index_hintCurrent email
Return values
0Success
-1Failure
Note
Context will be freed after it's closed

Definition at line 568 of file mx.c.

569 {
570  if (!pctx || !*pctx)
571  return 0;
572 
573  struct Context *ctx = *pctx;
574  if (!ctx || !ctx->mailbox)
575  return -1;
576 
577  struct Mailbox *m = ctx->mailbox;
578 
579  int i, move_messages = 0, purge = 1, read_msgs = 0;
580  char mbox[PATH_MAX];
581  char buf[PATH_MAX + 64];
582 
583  if (m->readonly || m->dontwrite || m->append)
584  {
586  FREE(pctx);
587  return 0;
588  }
589 
590 #ifdef USE_NNTP
591  if (m->msg_unread && m->magic == MUTT_NNTP)
592  {
593  struct NntpMboxData *mdata = m->mdata;
594 
595  if (mdata && mdata->adata && mdata->group)
596  {
597  int rc = query_quadoption(CatchupNewsgroup, _("Mark all articles read?"));
598  if (rc == MUTT_ABORT)
599  return -1;
600  else if (rc == MUTT_YES)
602  }
603  }
604 #endif
605 
606  for (i = 0; i < m->msg_count; i++)
607  {
608  if (!m->hdrs[i])
609  break;
610  if (!m->hdrs[i]->deleted && m->hdrs[i]->read && !(m->hdrs[i]->flagged && KeepFlagged))
611  {
612  read_msgs++;
613  }
614  }
615 
616 #ifdef USE_NNTP
617  /* don't need to move articles from newsgroup */
618  if (m->magic == MUTT_NNTP)
619  read_msgs = 0;
620 #endif
621 
622  if (read_msgs && Move != MUTT_NO)
623  {
624  int is_spool;
625  char *p = mutt_find_hook(MUTT_MBOX_HOOK, m->path);
626  if (p)
627  {
628  is_spool = 1;
629  mutt_str_strfcpy(mbox, p, sizeof(mbox));
630  }
631  else
632  {
633  mutt_str_strfcpy(mbox, Mbox, sizeof(mbox));
634  is_spool = mutt_is_spool(m->path) && !mutt_is_spool(mbox);
635  }
636 
637  if (is_spool && *mbox)
638  {
639  mutt_expand_path(mbox, sizeof(mbox));
640  snprintf(buf, sizeof(buf),
641  /* L10N: The first argument is the number of read messages to be
642  moved, the second argument is the target mailbox. */
643  ngettext("Move %d read message to %s?", "Move %d read messages to %s?", read_msgs),
644  read_msgs, mbox);
645  move_messages = query_quadoption(Move, buf);
646  if (move_messages == MUTT_ABORT)
647  return -1;
648  }
649  }
650 
651  /* There is no point in asking whether or not to purge if we are
652  * just marking messages as "trash".
653  */
654  if (m->msg_deleted && !(m->magic == MUTT_MAILDIR && MaildirTrash))
655  {
656  snprintf(buf, sizeof(buf),
657  ngettext("Purge %d deleted message?", "Purge %d deleted messages?", m->msg_deleted),
658  m->msg_deleted);
659  purge = query_quadoption(Delete, buf);
660  if (purge == MUTT_ABORT)
661  return -1;
662  }
663 
664  if (MarkOld)
665  {
666  for (i = 0; i < m->msg_count; i++)
667  {
668  if (!m->hdrs[i]->deleted && !m->hdrs[i]->old && !m->hdrs[i]->read)
669  mutt_set_flag(m, m->hdrs[i], MUTT_OLD, 1);
670  }
671  }
672 
673  if (move_messages)
674  {
675  if (!m->quiet)
676  mutt_message(_("Moving read messages to %s..."), mbox);
677 
678 #ifdef USE_IMAP
679  /* try to use server-side copy first */
680  i = 1;
681 
682  if ((m->magic == MUTT_IMAP) && (imap_path_probe(mbox, NULL) == MUTT_IMAP))
683  {
684  /* tag messages for moving, and clear old tags, if any */
685  for (i = 0; i < m->msg_count; i++)
686  {
687  if (m->hdrs[i]->read && !m->hdrs[i]->deleted && !(m->hdrs[i]->flagged && KeepFlagged))
688  {
689  m->hdrs[i]->tagged = true;
690  }
691  else
692  {
693  m->hdrs[i]->tagged = false;
694  }
695  }
696 
697  i = imap_copy_messages(ctx, NULL, mbox, true);
698  }
699 
700  if (i == 0) /* success */
702  else if (i == -1) /* horrible error, bail */
703  return -1;
704  else /* use regular append-copy mode */
705 #endif
706  {
707  struct Context *f = mx_mbox_open(NULL, mbox, MUTT_APPEND);
708  if (!f)
709  return -1;
710 
711  for (i = 0; i < m->msg_count; i++)
712  {
713  if (m->hdrs[i]->read && !m->hdrs[i]->deleted && !(m->hdrs[i]->flagged && KeepFlagged))
714  {
715  if (mutt_append_message(f->mailbox, ctx->mailbox, m->hdrs[i], 0, CH_UPDATE_LEN) == 0)
716  {
717  mutt_set_flag(m, m->hdrs[i], MUTT_DELETE, 1);
718  mutt_set_flag(m, m->hdrs[i], MUTT_PURGE, 1);
719  }
720  else
721  {
722  mx_mbox_close(&f, NULL);
723  return -1;
724  }
725  }
726  }
727 
728  mx_mbox_close(&f, NULL);
729  }
730  }
731  else if (!m->changed && m->msg_deleted == 0)
732  {
733  if (!m->quiet)
734  mutt_message(_("Mailbox is unchanged"));
735  if (m->magic == MUTT_MBOX || m->magic == MUTT_MMDF)
736  mbox_reset_atime(m, NULL);
738  FREE(pctx);
739  return 0;
740  }
741 
742  /* copy mails to the trash before expunging */
743  if (purge && m->msg_deleted && (mutt_str_strcmp(m->path, Trash) != 0))
744  {
745  if (trash_append(ctx->mailbox) != 0)
746  return -1;
747  }
748 
749 #ifdef USE_IMAP
750  /* allow IMAP to preserve the deleted flag across sessions */
751  if (m->magic == MUTT_IMAP)
752  {
753  int check = imap_sync_mailbox(ctx, (purge != MUTT_NO), true);
754  if (check != 0)
755  return check;
756  }
757  else
758 #endif
759  {
760  if (!purge)
761  {
762  for (i = 0; i < m->msg_count; i++)
763  {
764  m->hdrs[i]->deleted = false;
765  m->hdrs[i]->purge = false;
766  }
767  m->msg_deleted = 0;
768  }
769 
770  if (m->changed || m->msg_deleted)
771  {
772  int check = sync_mailbox(ctx, index_hint);
773  if (check != 0)
774  return check;
775  }
776  }
777 
778  if (!m->quiet)
779  {
780  if (move_messages)
781  {
782  mutt_message(_("%d kept, %d moved, %d deleted"),
783  m->msg_count - m->msg_deleted, read_msgs, m->msg_deleted);
784  }
785  else
786  mutt_message(_("%d kept, %d deleted"), m->msg_count - m->msg_deleted, m->msg_deleted);
787  }
788 
789  if (m->msg_count == m->msg_deleted && (m->magic == MUTT_MMDF || m->magic == MUTT_MBOX) &&
790  !mutt_is_spool(m->path) && !SaveEmpty)
791  {
793  }
794 
795 #ifdef USE_SIDEBAR
796  if (purge && m->msg_deleted)
797  {
798  for (i = 0; i < m->msg_count; i++)
799  {
800  if (m->hdrs[i]->deleted && !m->hdrs[i]->read)
801  {
802  m->msg_unread--;
803  if (!m->hdrs[i]->old)
804  m->msg_new--;
805  }
806  if (m->hdrs[i]->deleted && m->hdrs[i]->flagged)
807  m->msg_flagged--;
808  }
809  }
810 #endif
811 
813  FREE(pctx);
814 
815  return 0;
816 }
#define MUTT_APPEND
open mailbox for appending messages
Definition: mx.h:50
The "current" mailbox.
Definition: context.h:36
int msg_count
total number of messages
Definition: mailbox.h:86
void mutt_file_unlink_empty(const char *path)
Delete a file if it&#39;s empty.
Definition: file.c:1206
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition: newsrc.c:1286
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2479
int msg_deleted
number of deleted messages
Definition: mailbox.h:90
int msg_unread
number of unread messages
Definition: mailbox.h:87
&#39;NNTP&#39; (Usenet) Mailbox type
Definition: magic.h:41
User aborted the question (with Ctrl-G)
Definition: quad.h:37
#define mutt_message(...)
Definition: logging.h:87
int msg_flagged
number of flagged messages
Definition: mailbox.h:88
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
static int trash_append(struct Mailbox *m)
move deleted mails to the trash folder
Definition: mx.c:473
&#39;Maildir&#39; Mailbox type
Definition: magic.h:40
Messages to be deleted.
Definition: mutt.h:118
struct NntpAccountData * adata
Definition: nntp.h:154
Old messages.
Definition: mutt.h:114
&#39;mmdf&#39; Mailbox type
Definition: magic.h:38
#define _(a)
Definition: message.h:28
&#39;IMAP&#39; Mailbox type
Definition: magic.h:42
struct Email ** hdrs
Definition: mailbox.h:93
WHERE bool MaildirTrash
Config: Use the maildir &#39;trashed&#39; flag, rather than deleting.
Definition: globals.h:242
bool MarkOld
Config: Mark new emails as old when leaving the mailbox.
Definition: email_globals.c:34
WHERE bool SaveEmpty
Config: (mbox,mmdf) Preserve empty mailboxes.
Definition: globals.h:251
char * mutt_expand_path(char *buf, size_t buflen)
Create the canonical path.
Definition: muttlib.c:157
bool tagged
Definition: email.h:42
bool read
Definition: email.h:49
char * mutt_find_hook(int type, const char *pat)
Find a matching hook.
Definition: hook.c:417
struct Context * mx_mbox_open(struct Mailbox *m, const char *path, int flags)
Open a mailbox and parse it.
Definition: mx.c:254
struct Mailbox * mailbox
Definition: context.h:50
bool old
Definition: email.h:48
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
bool readonly
don&#39;t allow changes to the mailbox
Definition: mailbox.h:113
char * group
Definition: nntp.h:141
int imap_copy_messages(struct Context *ctx, struct Email *e, char *dest, bool delete)
Server COPY messages to another folder.
Definition: message.c:1518
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:141
void * mdata
driver specific data
Definition: mailbox.h:130
WHERE char * Mbox
Config: Folder that receives read emails (see Move)
Definition: globals.h:117
#define MUTT_MBOX_HOOK
Definition: hook.h:42
unsigned char Move
Config: Move emails from Spoolfile to Mbox when read.
Definition: mx.c:93
int mx_mbox_close(struct Context **pctx, int *index_hint)
Save changes and close mailbox.
Definition: mx.c:568
&#39;mbox&#39; Mailbox type
Definition: magic.h:37
A mailbox.
Definition: mailbox.h:76
#define PATH_MAX
Definition: mutt.h:46
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
int query_quadoption(int opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3227
void mx_fastclose_mailbox(struct Context *ctx)
free up memory associated with the mailbox context
Definition: mx.c:404
Messages to be purged (bypass trash)
Definition: mutt.h:120
bool dontwrite
don&#39;t write the mailbox on close
Definition: mailbox.h:109
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:742
bool append
mailbox is opened in append mode
Definition: mailbox.h:107
#define mutt_set_flag(a, b, c, d)
Definition: protos.h:54
bool quiet
inhibit status messages?
Definition: mailbox.h:112
bool purge
skip trash folder when deleting
Definition: email.h:44
#define CH_UPDATE_LEN
update Lines: and Content-Length:
Definition: copy.h:57
int imap_sync_mailbox(struct Context *ctx, bool expunge, bool close)
Sync all the changes to the server.
Definition: imap.c:1634
NNTP-specific Mailbox data -.
Definition: nntp.h:139
bool KeepFlagged
Config: Don&#39;t move flagged messages from Spoolfile to Mbox.
Definition: mx.c:91
char path[PATH_MAX]
Definition: mailbox.h:78
WHERE unsigned char Delete
Config: Really delete messages, when the mailbox is closed.
Definition: globals.h:187
unsigned char CatchupNewsgroup
Config: (nntp) Mark all articles as read when leaving a newsgroup.
Definition: mx.c:90
bool flagged
marked important?
Definition: email.h:41
char * Trash
Config: Folder to put deleted emails.
Definition: mx.c:94
int msg_new
number of new messages
Definition: mailbox.h:89
bool deleted
Definition: email.h:43
void mbox_reset_atime(struct Mailbox *m, struct stat *st)
Reset the access time on the mailbox file.
Definition: mbox.c:869
#define FREE(x)
Definition: memory.h:46
bool changed
mailbox has been modified
Definition: mailbox.h:108
int mutt_append_message(struct Mailbox *dest, struct Mailbox *src, struct Email *e, int cmflags, int chflags)
Append a message.
Definition: copy.c:862
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612
static bool mutt_is_spool(const char *str)
Is this the spoolfile?
Definition: mx.c:147
static int sync_mailbox(struct Context *ctx, int *index_hint)
save changes to disk
Definition: mx.c:444

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mx_update_tables ( struct Context ctx,
bool  committing 
)

Update a Context structure's internal tables.

Parameters
ctxMailbox
committingCommit the changes?

Definition at line 823 of file mx.c.

824 {
825  if (!ctx || !ctx->mailbox)
826  return;
827 
828  struct Mailbox *m = ctx->mailbox;
829 
830  int i, j, padding;
831 
832  /* update memory to reflect the new state of the mailbox */
833  m->vcount = 0;
834  ctx->vsize = 0;
835  m->msg_tagged = 0;
836  m->msg_deleted = 0;
837  m->msg_new = 0;
838  m->msg_unread = 0;
839  m->changed = false;
840  m->msg_flagged = 0;
841  padding = mx_msg_padding_size(m);
842  for (i = 0, j = 0; i < m->msg_count; i++)
843  {
844  if (!m->hdrs[i]->quasi_deleted &&
845  ((committing && (!m->hdrs[i]->deleted || (m->magic == MUTT_MAILDIR && MaildirTrash))) ||
846  (!committing && m->hdrs[i]->active)))
847  {
848  if (i != j)
849  {
850  m->hdrs[j] = m->hdrs[i];
851  m->hdrs[i] = NULL;
852  }
853  m->hdrs[j]->msgno = j;
854  if (m->hdrs[j]->virtual != -1)
855  {
856  m->v2r[m->vcount] = j;
857  m->hdrs[j]->virtual = m->vcount++;
858  struct Body *b = m->hdrs[j]->content;
859  ctx->vsize += b->length + b->offset - b->hdr_offset + padding;
860  }
861 
862  if (committing)
863  m->hdrs[j]->changed = false;
864  else if (m->hdrs[j]->changed)
865  m->changed = true;
866 
867  if (!committing || (m->magic == MUTT_MAILDIR && MaildirTrash))
868  {
869  if (m->hdrs[j]->deleted)
870  m->msg_deleted++;
871  }
872 
873  if (m->hdrs[j]->tagged)
874  m->msg_tagged++;
875  if (m->hdrs[j]->flagged)
876  m->msg_flagged++;
877  if (!m->hdrs[j]->read)
878  {
879  m->msg_unread++;
880  if (!m->hdrs[j]->old)
881  m->msg_new++;
882  }
883 
884  j++;
885  }
886  else
887  {
888  if (m->magic == MUTT_MH || m->magic == MUTT_MAILDIR)
889  {
890  m->size -= (m->hdrs[i]->content->length + m->hdrs[i]->content->offset -
891  m->hdrs[i]->content->hdr_offset);
892  }
893  /* remove message from the hash tables */
894  if (m->subj_hash && m->hdrs[i]->env->real_subj)
895  mutt_hash_delete(m->subj_hash, m->hdrs[i]->env->real_subj, m->hdrs[i]);
896  if (m->id_hash && m->hdrs[i]->env->message_id)
897  mutt_hash_delete(m->id_hash, m->hdrs[i]->env->message_id, m->hdrs[i]);
898  mutt_label_hash_remove(m, m->hdrs[i]);
899  /* The path mx_mbox_check() -> imap_check_mailbox() ->
900  * imap_expunge_mailbox() -> mx_update_tables()
901  * can occur before a call to mx_mbox_sync(), resulting in
902  * last_tag being stale if it's not reset here.
903  */
904  if (ctx->last_tag == m->hdrs[i])
905  ctx->last_tag = NULL;
906  mutt_email_free(&m->hdrs[i]);
907  }
908  }
909  m->msg_count = j;
910 }
void mutt_hash_delete(struct Hash *table, const char *strkey, const void *data)
Remove an element from a Hash table.
Definition: hash.c:434
int msg_count
total number of messages
Definition: mailbox.h:86
off_t size
Definition: mailbox.h:82
int msg_deleted
number of deleted messages
Definition: mailbox.h:90
int msg_unread
number of unread messages
Definition: mailbox.h:87
int msg_flagged
number of flagged messages
Definition: mailbox.h:88
&#39;Maildir&#39; Mailbox type
Definition: magic.h:40
int virtual
virtual message number
Definition: email.h:89
struct Body * content
list of MIME parts
Definition: email.h:92
LOFF_T offset
offset where the actual data begins
Definition: body.h:45
char * real_subj
offset of the real subject
Definition: envelope.h:45
bool changed
Definition: email.h:46
void mutt_label_hash_remove(struct Mailbox *m, struct Email *e)
Rmove a message&#39;s labels from the Hash Table.
Definition: mutt_header.c:403
struct Email ** hdrs
Definition: mailbox.h:93
WHERE bool MaildirTrash
Config: Use the maildir &#39;trashed&#39; flag, rather than deleting.
Definition: globals.h:242
int vcount
the number of virtual messages
Definition: mailbox.h:96
The body of an email.
Definition: body.h:33
bool tagged
Definition: email.h:42
bool read
Definition: email.h:49
char * message_id
Definition: envelope.h:47
struct Mailbox * mailbox
Definition: context.h:50
bool old
Definition: email.h:48
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
struct Envelope * env
envelope information
Definition: email.h:91
bool quasi_deleted
deleted from neomutt, but not modified on disk
Definition: email.h:45
off_t vsize
Definition: context.h:38
bool active
message is not to be removed
Definition: email.h:57
LOFF_T length
length (in bytes) of attachment
Definition: body.h:46
A mailbox.
Definition: mailbox.h:76
int msg_tagged
how many messages are tagged?
Definition: mailbox.h:91
void mutt_email_free(struct Email **e)
Free an Email.
Definition: email.c:41
int * v2r
mapping from virtual to real msgno
Definition: mailbox.h:95
bool flagged
marked important?
Definition: email.h:41
int msg_new
number of new messages
Definition: mailbox.h:89
struct Hash * subj_hash
hash table by subject
Definition: mailbox.h:122
bool deleted
Definition: email.h:43
&#39;MH&#39; Mailbox type
Definition: magic.h:39
bool changed
mailbox has been modified
Definition: mailbox.h:108
int mx_msg_padding_size(struct Mailbox *m)
Bytes of padding between messages - Wrapper for MxOps::msg_padding_size.
Definition: mx.c:1660
long hdr_offset
offset in stream where the headers begin.
Definition: body.h:41
struct Hash * id_hash
hash table by msg id
Definition: mailbox.h:121
struct Email * last_tag
last tagged msg.
Definition: context.h:41
int msgno
number displayed to the user
Definition: email.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_mbox_sync ( struct Context ctx,
int *  index_hint 
)

Save changes to mailbox.

Parameters
[in]ctxContext
[out]index_hintCurrently selected mailbox
Return values
0Success
-1Error

Definition at line 919 of file mx.c.

920 {
921  if (!ctx || !ctx->mailbox)
922  return -1;
923 
924  struct Mailbox *m = ctx->mailbox;
925 
926  int rc;
927  int purge = 1;
928  int msgcount, deleted;
929 
930  if (m->dontwrite)
931  {
932  char buf[STRING], tmp[STRING];
933  if (km_expand_key(buf, sizeof(buf), km_find_func(MENU_MAIN, OP_TOGGLE_WRITE)))
934  snprintf(tmp, sizeof(tmp), _(" Press '%s' to toggle write"), buf);
935  else
936  mutt_str_strfcpy(tmp, _("Use 'toggle-write' to re-enable write"), sizeof(tmp));
937 
938  mutt_error(_("Mailbox is marked unwritable. %s"), tmp);
939  return -1;
940  }
941  else if (m->readonly)
942  {
943  mutt_error(_("Mailbox is read-only"));
944  return -1;
945  }
946 
947  if (!m->changed && !m->msg_deleted)
948  {
949  if (!m->quiet)
950  mutt_message(_("Mailbox is unchanged"));
951  return 0;
952  }
953 
954  if (m->msg_deleted)
955  {
956  char buf[SHORT_STRING];
957 
958  snprintf(buf, sizeof(buf),
959  ngettext("Purge %d deleted message?", "Purge %d deleted messages?", m->msg_deleted),
960  m->msg_deleted);
961  purge = query_quadoption(Delete, buf);
962  if (purge == MUTT_ABORT)
963  return -1;
964  else if (purge == MUTT_NO)
965  {
966  if (!m->changed)
967  return 0; /* nothing to do! */
968  /* let IMAP servers hold on to D flags */
969  if (m->magic != MUTT_IMAP)
970  {
971  for (int i = 0; i < m->msg_count; i++)
972  {
973  m->hdrs[i]->deleted = false;
974  m->hdrs[i]->purge = false;
975  }
976  m->msg_deleted = 0;
977  }
978  }
979  else if (ctx->last_tag && ctx->last_tag->deleted)
980  ctx->last_tag = NULL; /* reset last tagged msg now useless */
981  }
982 
983  /* really only for IMAP - imap_sync_mailbox results in a call to
984  * mx_update_tables, so m->msg_deleted is 0 when it comes back */
985  msgcount = m->msg_count;
986  deleted = m->msg_deleted;
987 
988  if (purge && m->msg_deleted && (mutt_str_strcmp(m->path, Trash) != 0))
989  {
990  if (trash_append(ctx->mailbox) != 0)
991  return -1;
992  }
993 
994 #ifdef USE_IMAP
995  if (m->magic == MUTT_IMAP)
996  rc = imap_sync_mailbox(ctx, purge, false);
997  else
998 #endif
999  rc = sync_mailbox(ctx, index_hint);
1000  if (rc == 0)
1001  {
1002 #ifdef USE_IMAP
1003  if (m->magic == MUTT_IMAP && !purge)
1004  {
1005  if (!m->quiet)
1006  mutt_message(_("Mailbox checkpointed"));
1007  }
1008  else
1009 #endif
1010  {
1011  if (!m->quiet)
1012  mutt_message(_("%d kept, %d deleted"), msgcount - deleted, deleted);
1013  }
1014 
1015  mutt_sleep(0);
1016 
1017  if (m->msg_count == m->msg_deleted && (m->magic == MUTT_MBOX || m->magic == MUTT_MMDF) &&
1018  !mutt_is_spool(m->path) && !SaveEmpty)
1019  {
1020  unlink(m->path);
1021  mx_fastclose_mailbox(ctx);
1022  return 0;
1023  }
1024 
1025  /* if we haven't deleted any messages, we don't need to resort */
1026  /* ... except for certain folder formats which need "unsorted"
1027  * sort order in order to synchronize folders.
1028  *
1029  * MH and maildir are safe. mbox-style seems to need re-sorting,
1030  * at least with the new threading code.
1031  */
1032  if (purge || (m->magic != MUTT_MAILDIR && m->magic != MUTT_MH))
1033  {
1034  /* IMAP does this automatically after handling EXPUNGE */
1035  if (m->magic != MUTT_IMAP)
1036  {
1037  mx_update_tables(ctx, true);
1038  mutt_sort_headers(ctx, true); /* rethread from scratch */
1039  }
1040  }
1041  }
1042 
1043  return rc;
1044 }
int msg_count
total number of messages
Definition: mailbox.h:86
#define SHORT_STRING
Definition: string2.h:34
int msg_deleted
number of deleted messages
Definition: mailbox.h:90
User aborted the question (with Ctrl-G)
Definition: quad.h:37
#define mutt_message(...)
Definition: logging.h:87
static int trash_append(struct Mailbox *m)
move deleted mails to the trash folder
Definition: mx.c:473
&#39;Maildir&#39; Mailbox type
Definition: magic.h:40
&#39;mmdf&#39; Mailbox type
Definition: magic.h:38
#define _(a)
Definition: message.h:28
&#39;IMAP&#39; Mailbox type
Definition: magic.h:42
struct Keymap * km_find_func(int menu, int func)
Find a function&#39;s mapping in a Menu.
Definition: keymap.c:798
struct Email ** hdrs
Definition: mailbox.h:93
WHERE bool SaveEmpty
Config: (mbox,mmdf) Preserve empty mailboxes.
Definition: globals.h:251
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1478
struct Mailbox * mailbox
Definition: context.h:50
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
bool readonly
don&#39;t allow changes to the mailbox
Definition: mailbox.h:113
void mx_update_tables(struct Context *ctx, bool committing)
Update a Context structure&#39;s internal tables.
Definition: mx.c:823
void mutt_sort_headers(struct Context *ctx, bool init)
Sort emails by their headers.
Definition: sort.c:360
&#39;mbox&#39; Mailbox type
Definition: magic.h:37
A mailbox.
Definition: mailbox.h:76
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:38
int query_quadoption(int opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3227
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
Definition: keymap.c:770
void mx_fastclose_mailbox(struct Context *ctx)
free up memory associated with the mailbox context
Definition: mx.c:404
bool dontwrite
don&#39;t write the mailbox on close
Definition: mailbox.h:109
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:742
bool quiet
inhibit status messages?
Definition: mailbox.h:112
bool purge
skip trash folder when deleting
Definition: email.h:44
int imap_sync_mailbox(struct Context *ctx, bool expunge, bool close)
Sync all the changes to the server.
Definition: imap.c:1634
char path[PATH_MAX]
Definition: mailbox.h:78
WHERE unsigned char Delete
Config: Really delete messages, when the mailbox is closed.
Definition: globals.h:187
#define STRING
Definition: string2.h:35
char * Trash
Config: Folder to put deleted emails.
Definition: mx.c:94
bool deleted
Definition: email.h:43
#define mutt_error(...)
Definition: logging.h:88
&#39;MH&#39; Mailbox type
Definition: magic.h:39
bool changed
mailbox has been modified
Definition: mailbox.h:108
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612
static bool mutt_is_spool(const char *str)
Is this the spoolfile?
Definition: mx.c:147
Index panel (list of emails)
Definition: keymap.h:73
struct Email * last_tag
last tagged msg.
Definition: context.h:41
static int sync_mailbox(struct Context *ctx, int *index_hint)
save changes to disk
Definition: mx.c:444

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

struct Message* mx_msg_open_new ( struct Mailbox m,
struct Email e,
int  flags 
)

Open a new message.

Parameters
mDestination mailbox
eMessage being copied (required for maildir support, because the filename depends on the message flags)
flagsFlags, e.g. MUTT_SET_DRAFT
Return values
ptrNew Message

Definition at line 1053 of file mx.c.

1054 {
1055  if (!m)
1056  return NULL;
1057 
1058  struct Address *p = NULL;
1059  struct Message *msg = NULL;
1060 
1061  if (!m->mx_ops || !m->mx_ops->msg_open_new)
1062  {
1063  mutt_debug(1, "function unimplemented for mailbox type %d.\n", m->magic);
1064  return NULL;
1065  }
1066 
1067  msg = mutt_mem_calloc(1, sizeof(struct Message));
1068  msg->write = true;
1069 
1070  if (e)
1071  {
1072  msg->flags.flagged = e->flagged;
1073  msg->flags.replied = e->replied;
1074  msg->flags.read = e->read;
1075  msg->flags.draft = (flags & MUTT_SET_DRAFT) ? true : false;
1076  msg->received = e->received;
1077  }
1078 
1079  if (msg->received == 0)
1080  time(&msg->received);
1081 
1082  if (m->mx_ops->msg_open_new(m, msg, e) == 0)
1083  {
1084  if (m->magic == MUTT_MMDF)
1085  fputs(MMDF_SEP, msg->fp);
1086 
1087  if ((m->magic == MUTT_MBOX || m->magic == MUTT_MMDF) && flags & MUTT_ADD_FROM)
1088  {
1089  if (e)
1090  {
1091  if (e->env->return_path)
1092  p = e->env->return_path;
1093  else if (e->env->sender)
1094  p = e->env->sender;
1095  else
1096  p = e->env->from;
1097  }
1098 
1099  fprintf(msg->fp, "From %s %s", p ? p->mailbox : NONULL(Username),
1100  ctime(&msg->received));
1101  }
1102  }
1103  else
1104  FREE(&msg);
1105 
1106  return msg;
1107 }
WHERE char * Username
User&#39;s login name.
Definition: globals.h:50
#define NONULL(x)
Definition: string2.h:39
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
bool replied
Definition: mx.h:91
&#39;mmdf&#39; Mailbox type
Definition: magic.h:38
An email address.
Definition: address.h:32
char * mailbox
mailbox and host address
Definition: address.h:35
struct Address * sender
Definition: envelope.h:39
#define MUTT_SET_DRAFT
set the message draft flag
Definition: mx.h:65
int(* msg_open_new)(struct Mailbox *m, struct Message *msg, struct Email *e)
Open a new message in a mailbox.
Definition: mx.h:189
bool read
Definition: email.h:49
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
struct Envelope * env
envelope information
Definition: email.h:91
struct Address * from
Definition: envelope.h:35
&#39;mbox&#39; Mailbox type
Definition: magic.h:37
bool flagged
Definition: mx.h:90
A local copy of an email.
Definition: mx.h:81
struct Message::@0 flags
const struct MxOps * mx_ops
Definition: mailbox.h:105
bool draft
Definition: mx.h:92
bool write
nonzero if message is open for writing
Definition: mx.h:86
bool flagged
marked important?
Definition: email.h:41
struct Address * return_path
Definition: envelope.h:34
bool replied
Definition: email.h:52
FILE * fp
pointer to the message data
Definition: mx.h:83
#define FREE(x)
Definition: memory.h:46
time_t received
the time at which this message was received
Definition: mx.h:94
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
bool read
Definition: mx.h:89
#define MUTT_ADD_FROM
add a From_ line
Definition: mx.h:64
time_t received
time when the message was placed in the mailbox
Definition: email.h:84
#define MMDF_SEP
Definition: mbox.h:57

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_mbox_check ( struct Context ctx,
int *  index_hint 
)

Check for new mail - Wrapper for MxOps::mbox_check()

Parameters
ctxMailbox
index_hintCurrent email
Return values
>0Success, e.g. MUTT_NEW_MAIL
0Success, no change
-1Failure

Definition at line 1117 of file mx.c.

1118 {
1119  if (!ctx || !ctx->mailbox || !ctx->mailbox->mx_ops)
1120  return -1;
1121 
1122  struct Mailbox *m = ctx->mailbox;
1123  int rc = m->mx_ops->mbox_check(ctx, index_hint);
1124  if (rc == MUTT_NEW_MAIL || rc == MUTT_REOPENED)
1125  {
1126  mx_update_context(ctx);
1127  }
1128 
1129  return rc;
1130 }
void mx_update_context(struct Context *ctx)
Update the Context&#39;s message counts.
Definition: mx.c:1247
struct Mailbox * mailbox
Definition: context.h:50
A mailbox.
Definition: mailbox.h:76
const struct MxOps * mx_ops
Definition: mailbox.h:105
int(* mbox_check)(struct Context *ctx, int *index_hint)
Check for new mail.
Definition: mx.h:148
new mail received in mailbox
Definition: mx.h:72
mailbox was reopened
Definition: mx.h:74

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

struct Message* mx_msg_open ( struct Mailbox m,
int  msgno 
)

return a stream pointer for a message

Parameters
mMailbox
msgnoMessage number
Return values
ptrMessage
NULLError

Definition at line 1139 of file mx.c.

1140 {
1141  if (!m)
1142  return NULL;
1143 
1144  struct Message *msg = NULL;
1145 
1146  if (!m->mx_ops || !m->mx_ops->msg_open)
1147  {
1148  mutt_debug(1, "function not implemented for mailbox type %d.\n", m->magic);
1149  return NULL;
1150  }
1151 
1152  msg = mutt_mem_calloc(1, sizeof(struct Message));
1153  if (m->mx_ops->msg_open(m, msg, msgno) < 0)
1154  FREE(&msg);
1155 
1156  return msg;
1157 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
A local copy of an email.
Definition: mx.h:81
int(* msg_open)(struct Mailbox *m, struct Message *msg, int msgno)
Open an email message in mailbox.
Definition: mx.h:180
const struct MxOps * mx_ops
Definition: mailbox.h:105
#define FREE(x)
Definition: memory.h:46
#define mutt_debug(LEVEL,...)
Definition: logging.h:85

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_msg_commit ( struct Mailbox m,
struct Message msg 
)

Commit a message to a folder - Wrapper for MxOps::msg_commit()

Parameters
mMailbox
msgMessage to commit
Return values
0Success
-1Failure

Definition at line 1166 of file mx.c.

1167 {
1168  if (!m || !m->mx_ops || !m->mx_ops->msg_commit)
1169  return -1;
1170 
1171  if (!(msg->write && m->append))
1172  {
1173  mutt_debug(1, "msg->write = %d, m->append = %d\n", msg->write, m->append);
1174  return -1;
1175  }
1176 
1177  return m->mx_ops->msg_commit(m, msg);
1178 }
int(* msg_commit)(struct Mailbox *m, struct Message *msg)
Save changes to an email.
Definition: mx.h:197
bool append
mailbox is opened in append mode
Definition: mailbox.h:107
const struct MxOps * mx_ops
Definition: mailbox.h:105
bool write
nonzero if message is open for writing
Definition: mx.h:86
#define mutt_debug(LEVEL,...)
Definition: logging.h:85

+ Here is the caller graph for this function:

int mx_msg_close ( struct Mailbox m,
struct Message **  msg 
)

Close a message.

Parameters
mMailbox
msgMessage to close
Return values
0Success
-1Failure

Definition at line 1187 of file mx.c.

1188 {
1189  if (!m || !msg || !*msg)
1190  return 0;
1191 
1192  int r = 0;
1193 
1194  if (m->mx_ops && m->mx_ops->msg_close)
1195  r = m->mx_ops->msg_close(m, *msg);
1196 
1197  if ((*msg)->path)
1198  {
1199  mutt_debug(1, "unlinking %s\n", (*msg)->path);
1200  unlink((*msg)->path);
1201  FREE(&(*msg)->path);
1202  }
1203 
1204  FREE(&(*msg)->committed_path);
1205  FREE(msg);
1206  return r;
1207 }
const struct MxOps * mx_ops
Definition: mailbox.h:105
#define FREE(x)
Definition: memory.h:46
int(* msg_close)(struct Mailbox *m, struct Message *msg)
Close an email.
Definition: mx.h:205
#define mutt_debug(LEVEL,...)
Definition: logging.h:85

+ Here is the caller graph for this function:

void mx_alloc_memory ( struct Mailbox m)

Create storage for the emails.

Parameters
mMailbox

Definition at line 1213 of file mx.c.

1214 {
1215  size_t s = MAX(sizeof(struct Email *), sizeof(int));
1216 
1217  if ((m->hdrmax + 25) * s < m->hdrmax * s)
1218  {
1219  mutt_error(_("Out of memory"));
1220  mutt_exit(1);
1221  }
1222 
1223  m->hdrmax += 25;
1224  if (m->hdrs)
1225  {
1226  mutt_mem_realloc(&m->hdrs, sizeof(struct Email *) * m->hdrmax);
1227  mutt_mem_realloc(&m->v2r, sizeof(int) * m->hdrmax);
1228  }
1229  else
1230  {
1231  m->hdrs = mutt_mem_calloc(m->hdrmax, sizeof(struct Email *));
1232  m->v2r = mutt_mem_calloc(m->hdrmax, sizeof(int));
1233  }
1234  for (int i = m->msg_count; i < m->hdrmax; i++)
1235  {
1236  m->hdrs[i] = NULL;
1237  m->v2r[i] = -1;
1238  }
1239 }
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
int msg_count
total number of messages
Definition: mailbox.h:86
The envelope/body of an email.
Definition: email.h:35
#define _(a)
Definition: message.h:28
struct Email ** hdrs
Definition: mailbox.h:93
#define MAX(a, b)
Definition: memory.h:30
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:124
void mutt_exit(int code)
Leave NeoMutt NOW.
Definition: main.c:197
int * v2r
mapping from virtual to real msgno
Definition: mailbox.h:95
#define mutt_error(...)
Definition: logging.h:88
int hdrmax
number of pointers in hdrs
Definition: mailbox.h:94

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mx_update_context ( struct Context ctx)

Update the Context's message counts.

Parameters
ctxMailbox

this routine is called to update the counts in the context structure

Definition at line 1247 of file mx.c.

1248 {
1249  if (!ctx || !ctx->mailbox)
1250  return;
1251 
1252  struct Mailbox *m = ctx->mailbox;
1253 
1254  if (!m)
1255  return;
1256 
1257  if (m->subj_hash)
1258  {
1260  }
1261  m->subj_hash = NULL;
1262 
1263  if (m->id_hash)
1264  {
1266  }
1267  m->id_hash = NULL;
1268 
1269  /* reset counters */
1270  m->msg_unread = 0;
1271  m->msg_flagged = 0;
1272  m->msg_new = 0;
1273  m->msg_deleted = 0;
1274  m->msg_tagged = 0;
1275  m->vcount = 0;
1276  m->changed = false;
1277 
1278  mutt_clear_threads(ctx);
1279 
1280  struct Email *e = NULL;
1281  for (int msgno = 0; msgno < m->msg_count; msgno++)
1282  {
1283  e = m->hdrs[msgno];
1284 
1285  if (WithCrypto)
1286  {
1287  /* NOTE: this _must_ be done before the check for mailcap! */
1288  e->security = crypt_query(e->content);
1289  }
1290 
1291  if (!ctx->pattern)
1292  {
1293  m->v2r[m->vcount] = msgno;
1294  e->virtual = m->vcount++;
1295  }
1296  else
1297  e->virtual = -1;
1298  e->msgno = msgno;
1299 
1300  if (e->env->supersedes)
1301  {
1302  struct Email *e2 = NULL;
1303 
1304  if (!m->id_hash)
1305  m->id_hash = mutt_make_id_hash(m);
1306 
1307  e2 = mutt_hash_find(m->id_hash, e->env->supersedes);
1308  if (e2)
1309  {
1310  e2->superseded = true;
1311  if (Score)
1312  mutt_score_message(ctx->mailbox, e2, true);
1313  }
1314  }
1315 
1316  /* add this message to the hash tables */
1317  if (m->id_hash && e->env->message_id)
1318  mutt_hash_insert(m->id_hash, e->env->message_id, e);
1319  if (m->subj_hash && e->env->real_subj)
1321  mutt_label_hash_add(m, e);
1322 
1323  if (Score)
1324  mutt_score_message(ctx->mailbox, e, false);
1325 
1326  if (e->changed)
1327  m->changed = true;
1328  if (e->flagged)
1329  m->msg_flagged++;
1330  if (e->deleted)
1331  m->msg_deleted++;
1332  if (!e->read)
1333  {
1334  m->msg_unread++;
1335  if (!e->old)
1336  m->msg_new++;
1337  }
1338  }
1339 
1340  mutt_sort_headers(ctx, true); /* rethread from scratch */
1341 }
int msg_count
total number of messages
Definition: mailbox.h:86
The envelope/body of an email.
Definition: email.h:35
int msg_deleted
number of deleted messages
Definition: mailbox.h:90
int msg_unread
number of unread messages
Definition: mailbox.h:87
char * supersedes
Definition: envelope.h:48
int msg_flagged
number of flagged messages
Definition: mailbox.h:88
unsigned int security
bit 0-8: flags, bit 9,10: application.
Definition: email.h:37
int virtual
virtual message number
Definition: email.h:89
struct Body * content
list of MIME parts
Definition: email.h:92
void * mutt_hash_find(const struct Hash *table, const char *strkey)
Find the HashElem data in a Hash table element using a key.
Definition: hash.c:374
void mutt_score_message(struct Mailbox *m, struct Email *e, bool upd_mbox)
Apply scoring to an email.
Definition: score.c:171
char * real_subj
offset of the real subject
Definition: envelope.h:45
bool changed
Definition: email.h:46
void mutt_label_hash_add(struct Mailbox *m, struct Email *e)
Add a message&#39;s labels to the Hash Table.
Definition: mutt_header.c:390
void mutt_hash_destroy(struct Hash **ptr)
Destroy a hash table.
Definition: hash.c:458
struct Email ** hdrs
Definition: mailbox.h:93
int vcount
the number of virtual messages
Definition: mailbox.h:96
bool read
Definition: email.h:49
char * message_id
Definition: envelope.h:47
struct Mailbox * mailbox
Definition: context.h:50
bool old
Definition: email.h:48
struct Envelope * env
envelope information
Definition: email.h:91
bool superseded
got superseded?
Definition: email.h:51
void mutt_sort_headers(struct Context *ctx, bool init)
Sort emails by their headers.
Definition: sort.c:360
A mailbox.
Definition: mailbox.h:76
int msg_tagged
how many messages are tagged?
Definition: mailbox.h:91
Scoring rule for email.
Definition: score.c:55
struct Hash * mutt_make_id_hash(struct Mailbox *m)
Create a Hash Table for message-ids.
Definition: mutt_thread.c:1439
void mutt_clear_threads(struct Context *ctx)
Clear the threading of message in a mailbox.
Definition: mutt_thread.c:598
int * v2r
mapping from virtual to real msgno
Definition: mailbox.h:95
int crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:647
bool flagged
marked important?
Definition: email.h:41
int msg_new
number of new messages
Definition: mailbox.h:89
struct Hash * subj_hash
hash table by subject
Definition: mailbox.h:122
bool deleted
Definition: email.h:43
bool changed
mailbox has been modified
Definition: mailbox.h:108
struct HashElem * mutt_hash_insert(struct Hash *table, const char *strkey, void *data)
Add a new element to the Hash table (with string keys)
Definition: hash.c:349
char * pattern
limit pattern string
Definition: context.h:39
#define WithCrypto
Definition: ncrypt.h:154
struct Hash * id_hash
hash table by msg id
Definition: mailbox.h:121
int msgno
number displayed to the user
Definition: email.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_check_empty ( const char *  path)

Is the mailbox empty.

Parameters
pathMailbox to check
Return values
1Mailbox is empty
0Mailbox contains mail
-1Error

Definition at line 1350 of file mx.c.

1351 {
1352  switch (mx_path_probe(path, NULL))
1353  {
1354  case MUTT_MBOX:
1355  case MUTT_MMDF:
1356  return mutt_file_check_empty(path);
1357  case MUTT_MH:
1358  return mh_check_empty(path);
1359  case MUTT_MAILDIR:
1360  return maildir_check_empty(path);
1361 #ifdef USE_IMAP
1362  case MUTT_IMAP:
1363  {
1364  int rc = imap_path_status(path, false);
1365  if (rc < 0)
1366  return -1;
1367  else if (rc == 0)
1368  return 1;
1369  else
1370  return 0;
1371  }
1372 #endif
1373  default:
1374  errno = EINVAL;
1375  return -1;
1376  }
1377  /* not reached */
1378 }
int imap_path_status(const char *path, bool queue)
Refresh the number of total and new messages.
Definition: imap.c:1318
&#39;Maildir&#39; Mailbox type
Definition: magic.h:40
&#39;mmdf&#39; Mailbox type
Definition: magic.h:38
&#39;IMAP&#39; Mailbox type
Definition: magic.h:42
&#39;mbox&#39; Mailbox type
Definition: magic.h:37
int maildir_check_empty(const char *path)
Is the mailbox empty.
Definition: shared.c:1625
&#39;MH&#39; Mailbox type
Definition: magic.h:39
char * path
Definition: email.h:93
enum MailboxType mx_path_probe(const char *path, struct stat *st)
Find a mailbox that understands a path.
Definition: mx.c:1438
int mutt_file_check_empty(const char *path)
Is the mailbox empty.
Definition: file.c:1304
int mh_check_empty(const char *path)
Is mailbox empty.
Definition: shared.c:1666

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_tags_edit ( struct Mailbox m,
const char *  tags,
char *  buf,
size_t  buflen 
)

start the tag editor of the mailbox

Parameters
mMailbox
tagsExisting tags
bufBuffer for the results
buflenLength of the buffer
Return values
-1Error
0No valid user input
1Buffer set

Definition at line 1390 of file mx.c.

1391 {
1392  if (!m)
1393  return -1;
1394 
1395  if (m->mx_ops->tags_edit)
1396  return m->mx_ops->tags_edit(m, tags, buf, buflen);
1397 
1398  mutt_message(_("Folder doesn't support tagging, aborting"));
1399  return -1;
1400 }
#define mutt_message(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
struct TagHead tags
for drivers that support server tagging
Definition: email.h:109
int(* tags_edit)(struct Mailbox *m, const char *tags, char *buf, size_t buflen)
Prompt and validate new messages tags.
Definition: mx.h:222
const struct MxOps * mx_ops
Definition: mailbox.h:105

+ Here is the caller graph for this function:

int mx_tags_commit ( struct Mailbox m,
struct Email e,
char *  tags 
)

Save tags to the Mailbox - Wrapper for MxOps::tags_commit()

Parameters
mMailbox
eEmail
tagsTags to save
Return values
0Success
-1Failure

Definition at line 1410 of file mx.c.

1411 {
1412  if (!m)
1413  return -1;
1414 
1415  if (m->mx_ops->tags_commit)
1416  return m->mx_ops->tags_commit(m, e, tags);
1417 
1418  mutt_message(_("Folder doesn't support tagging, aborting"));
1419  return -1;
1420 }
#define mutt_message(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
struct TagHead tags
for drivers that support server tagging
Definition: email.h:109
const struct MxOps * mx_ops
Definition: mailbox.h:105
int(* tags_commit)(struct Mailbox *m, struct Email *e, char *buf)
Save the tags to a message.
Definition: mx.h:231

+ Here is the caller graph for this function:

bool mx_tags_is_supported ( struct Mailbox m)

return true if mailbox support tagging

Parameters
mMailbox
Return values
trueTagging is supported

Definition at line 1427 of file mx.c.

1428 {
1429  return m && m->mx_ops->tags_commit && m->mx_ops->tags_edit;
1430 }
int(* tags_edit)(struct Mailbox *m, const char *tags, char *buf, size_t buflen)
Prompt and validate new messages tags.
Definition: mx.h:222
const struct MxOps * mx_ops
Definition: mailbox.h:105
int(* tags_commit)(struct Mailbox *m, struct Email *e, char *buf)
Save the tags to a message.
Definition: mx.h:231

+ Here is the caller graph for this function:

enum MailboxType mx_path_probe ( const char *  path,
struct stat *  st 
)

Find a mailbox that understands a path.

Parameters
[in]pathPath to examine
[out]ststat buffer (OPTIONAL, for local mailboxes)
Return values
numType, e.g. MUTT_IMAP

Definition at line 1438 of file mx.c.

1439 {
1440  if (!path)
1441  return MUTT_UNKNOWN;
1442 
1443  static const struct MxOps *no_stat[] = {
1444 #ifdef USE_IMAP
1445  &MxImapOps,
1446 #endif
1447 #ifdef USE_NOTMUCH
1448  &MxNotmuchOps,
1449 #endif
1450 #ifdef USE_POP
1451  &MxPopOps,
1452 #endif
1453 #ifdef USE_NNTP
1454  &MxNntpOps,
1455 #endif
1456  };
1457 
1458  static const struct MxOps *with_stat[] = {
1460 #ifdef USE_COMPRESSED
1461  &MxCompOps,
1462 #endif
1463  };
1464 
1465  enum MailboxType rc;
1466 
1467  for (size_t i = 0; i < mutt_array_size(no_stat); i++)
1468  {
1469  rc = no_stat[i]->path_probe(path, NULL);
1470  if (rc != MUTT_UNKNOWN)
1471  return rc;
1472  }
1473 
1474  struct stat st2 = { 0 };
1475  if (!st)
1476  st = &st2;
1477 
1478  if (stat(path, st) != 0)
1479  {
1480  mutt_debug(1, "unable to stat %s: %s (errno %d).\n", path, strerror(errno), errno);
1481  return MUTT_UNKNOWN;
1482  }
1483 
1484  for (size_t i = 0; i < mutt_array_size(with_stat); i++)
1485  {
1486  rc = with_stat[i]->path_probe(path, st);
1487  if (rc != MUTT_UNKNOWN)
1488  return rc;
1489  }
1490 
1491  return rc;
1492 }
struct MxOps MxMhOps
MH mailbox - Implements MxOps.
Definition: mh.c:804
enum MailboxType(* path_probe)(const char *path, const struct stat *st)
Does this mailbox type recognise this path?
Definition: mx.h:238
struct MxOps MxMaildirOps
Maildir mailbox - Implements MxOps.
Definition: maildir.c:684
struct MxOps MxPopOps
POP mailbox - Implements MxOps.
Definition: pop.c:1281
struct MxOps MxMboxOps
Mbox mailbox - Implements MxOps.
Definition: mbox.c:1840
#define mutt_array_size(x)
Definition: memory.h:33
struct MxOps MxCompOps
Compressed mailbox - Implements MxOps.
Definition: compress.c:995
struct MxOps MxImapOps
IMAP mailbox - Implements MxOps.
Definition: imap.c:2544
struct MxOps MxNntpOps
NNTP mailbox - Implements MxOps.
Definition: nntp.c:2894
MailboxType
Supported mailbox formats.
Definition: magic.h:33
struct MxOps MxMmdfOps
MMDF mailbox - Implements MxOps.
Definition: mbox.c:1867
Mailbox wasn&#39;t recognised.
Definition: magic.h:36
char * path
Definition: email.h:93
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
The Mailbox API.
Definition: mx.h:103
struct MxOps MxNotmuchOps
Notmuch mailbox - Implements MxOps.

+ Here is the caller graph for this function:

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 at line 1497 of file mx.c.

1498 {
1499  if (!buf)
1500  return -1;
1501 
1502  for (size_t i = 0; i < 3; i++)
1503  {
1504  /* Look for !! ! - < > or ^ followed by / or NUL */
1505  if ((buf[0] == '!') && (buf[1] == '!'))
1506  {
1507  if (((buf[2] == '/') || (buf[2] == '\0')))
1508  {
1509  mutt_str_inline_replace(buf, buflen, 2, LastFolder);
1510  }
1511  }
1512  else if ((buf[0] == '+') || (buf[0] == '='))
1513  {
1514  size_t folder_len = mutt_str_strlen(Folder);
1515  if ((folder_len > 0) && (Folder[folder_len - 1] != '/'))
1516  {
1517  buf[0] = '/';
1518  mutt_str_inline_replace(buf, buflen, 0, Folder);
1519  }
1520  else
1521  {
1522  mutt_str_inline_replace(buf, buflen, 1, Folder);
1523  }
1524  }
1525  else if ((buf[1] == '/') || (buf[1] == '\0'))
1526  {
1527  if (buf[0] == '!')
1528  {
1529  mutt_str_inline_replace(buf, buflen, 1, Spoolfile);
1530  }
1531  else if (buf[0] == '-')
1532  {
1533  mutt_str_inline_replace(buf, buflen, 1, LastFolder);
1534  }
1535  else if (buf[0] == '<')
1536  {
1537  mutt_str_inline_replace(buf, buflen, 1, Record);
1538  }
1539  else if (buf[0] == '>')
1540  {
1541  mutt_str_inline_replace(buf, buflen, 1, Mbox);
1542  }
1543  else if (buf[0] == '^')
1544  {
1545  mutt_str_inline_replace(buf, buflen, 1, CurrentFolder);
1546  }
1547  else if (buf[0] == '~')
1548  {
1549  mutt_str_inline_replace(buf, buflen, 1, HomeDir);
1550  }
1551  }
1552  else if (buf[0] == '@')
1553  {
1554  /* elm compatibility, @ expands alias to user name */
1555  struct Address *alias = mutt_alias_lookup(buf + 1);
1556  if (!alias)
1557  break;
1558 
1559  struct Email *e = mutt_email_new();
1560  e->env = mutt_env_new();
1561  e->env->from = alias;
1562  e->env->to = alias;
1563  mutt_default_save(buf, buflen, e);
1564  e->env->from = NULL;
1565  e->env->to = NULL;
1566  mutt_email_free(&e);
1567  break;
1568  }
1569  else
1570  {
1571  break;
1572  }
1573  }
1574 
1575  // if (!folder) //XXX - use inherited version, or pass NULL to backend?
1576  // return -1;
1577 
1578  enum MailboxType magic2 = mx_path_probe(buf, NULL);
1579  if (magic)
1580  *magic = magic2;
1581  const struct MxOps *ops = mx_get_ops(magic2);
1582  if (!ops || !ops->path_canon)
1583  return -1;
1584 
1585  if (ops->path_canon(buf, buflen) < 0)
1586  {
1587  mutt_path_canon(buf, buflen, HomeDir);
1588  }
1589 
1590  return 0;
1591 }
The envelope/body of an email.
Definition: email.h:35
struct Address * to
Definition: envelope.h:36
An email address.
Definition: address.h:32
WHERE char * LastFolder
Previously selected mailbox.
Definition: globals.h:53
struct Email * mutt_email_new(void)
Create a new Email.
Definition: email.c:63
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:663
struct Address * mutt_alias_lookup(const char *s)
Find an Alias.
Definition: alias.c:277
void mutt_default_save(char *path, size_t pathlen, struct Email *e)
Find the default save path for an email.
Definition: hook.c:523
int(* path_canon)(char *buf, size_t buflen)
Canonicalise a mailbox path.
Definition: mx.h:246
struct Envelope * env
envelope information
Definition: email.h:91
WHERE char * HomeDir
User&#39;s home directory.
Definition: globals.h:47
WHERE char * CurrentFolder
Currently selected mailbox.
Definition: globals.h:52
struct Address * from
Definition: envelope.h:35
struct Envelope * mutt_env_new(void)
Create a new Envelope.
Definition: envelope.c:40
WHERE char * Mbox
Config: Folder that receives read emails (see Move)
Definition: globals.h:117
A folder/dir in the browser.
Definition: browser.h:47
MailboxType
Supported mailbox formats.
Definition: magic.h:33
WHERE char * Record
Config: Folder to save &#39;sent&#39; messages.
Definition: globals.h:134
bool mutt_path_canon(char *buf, size_t buflen, const char *homedir)
Create the canonical version of a path.
Definition: path.c:219
void mutt_email_free(struct Email **e)
Free an Email.
Definition: email.c:41
const struct MxOps * mx_get_ops(enum MailboxType magic)
Get mailbox operations.
Definition: mx.c:133
WHERE char * Spoolfile
Config: Inbox.
Definition: globals.h:147
bool mutt_str_inline_replace(char *buf, size_t buflen, size_t xlen, const char *rstr)
Replace the beginning of a string.
Definition: string.c:1071
enum MailboxType mx_path_probe(const char *path, struct stat *st)
Find a mailbox that understands a path.
Definition: mx.c:1438
The Mailbox API.
Definition: mx.h:103

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_path_canon2 ( struct Mailbox m,
const char *  folder 
)

XXX canonicalise the path to realpath.

Definition at line 1597 of file mx.c.

1598 {
1599  if (!m)
1600  return -1;
1601 
1602  if (m->realpath[0] == '\0')
1603  mutt_str_strfcpy(m->realpath, m->path, sizeof(m->realpath));
1604 
1605  int rc = mx_path_canon(m->realpath, sizeof(m->realpath), folder, &m->magic);
1606  if (rc >= 0)
1607  {
1608  m->mx_ops = mx_get_ops(m->magic);
1609  // temp?
1610  mutt_str_strfcpy(m->path, m->realpath, sizeof(m->path));
1611  }
1612 
1613  return rc;
1614 }
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:1497
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:742
const struct MxOps * mx_ops
Definition: mailbox.h:105
char path[PATH_MAX]
Definition: mailbox.h:78
const struct MxOps * mx_get_ops(enum MailboxType magic)
Get mailbox operations.
Definition: mx.c:133
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_path_pretty ( char *  buf,
size_t  buflen,
const char *  folder 
)

Abbreviate a mailbox path - Wrapper for MxOps::path_pretty.

Definition at line 1619 of file mx.c.

1620 {
1621  enum MailboxType magic = mx_path_probe(buf, NULL);
1622  const struct MxOps *ops = mx_get_ops(magic);
1623  if (!ops)
1624  return -1;
1625 
1626  if (!ops->path_canon)
1627  return -1;
1628 
1629  if (ops->path_canon(buf, buflen) < 0)
1630  return -1;
1631 
1632  if (!ops->path_pretty)
1633  return -1;
1634 
1635  if (ops->path_pretty(buf, buflen, folder) < 0)
1636  return -1;
1637 
1638  return 0;
1639 }
int(* path_canon)(char *buf, size_t buflen)
Canonicalise a mailbox path.
Definition: mx.h:246
enum MailboxType magic
Mailbox type, e.g. MUTT_IMAP.
Definition: mx.h:105
MailboxType
Supported mailbox formats.
Definition: magic.h:33
const struct MxOps * mx_get_ops(enum MailboxType magic)
Get mailbox operations.
Definition: mx.c:133
int(* path_pretty)(char *buf, size_t buflen, const char *folder)
Abbreviate a mailbox path.
Definition: mx.h:255
enum MailboxType mx_path_probe(const char *path, struct stat *st)
Find a mailbox that understands a path.
Definition: mx.c:1438
The Mailbox API.
Definition: mx.h:103

+ Here is the call graph for this function:

int mx_path_parent ( char *  buf,
size_t  buflen 
)

Find the parent of a mailbox path - Wrapper for MxOps::path_parent.

Definition at line 1644 of file mx.c.

1645 {
1646  if (!buf)
1647  return -1;
1648 
1649  return 0;
1650 }
int mx_msg_padding_size ( struct Mailbox m)

Bytes of padding between messages - Wrapper for MxOps::msg_padding_size.

Parameters
mMailbox
Return values
numNumber of bytes of padding

mmdf and mbox add separators, which leads a small discrepancy when computing vsize for a limited view.

Definition at line 1660 of file mx.c.

1661 {
1662  if (!m || !m->mx_ops || !m->mx_ops->msg_padding_size)
1663  return 0;
1664 
1665  return m->mx_ops->msg_padding_size(m);
1666 }
int(* msg_padding_size)(struct Mailbox *m)
Bytes of padding between messages.
Definition: mx.h:211
const struct MxOps * mx_ops
Definition: mailbox.h:105

+ Here is the caller graph for this function:

struct Account* mx_ac_find ( struct Mailbox m)

XXX.

Definition at line 1671 of file mx.c.

1672 {
1673  if (!m || !m->mx_ops)
1674  return NULL;
1675 
1676  struct Account *np = NULL;
1677  TAILQ_FOREACH(np, &AllAccounts, entries)
1678  {
1679  if (np->magic != m->magic)
1680  continue;
1681 
1682  if (m->mx_ops->ac_find(np, m->realpath))
1683  return np;
1684  }
1685 
1686  return NULL;
1687 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
XXX.
Definition: account.h:36
struct AccountList AllAccounts
List of all Accounts.
Definition: account.c:33
enum MailboxType magic
mailbox type
Definition: mailbox.h:99
enum MailboxType magic
Definition: account.h:38
const struct MxOps * mx_ops
Definition: mailbox.h:105
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
struct Account *(* ac_find)(struct Account *a, const char *path)
Find an Account for a Mailbox path.
Definition: mx.h:115

+ Here is the caller graph for this function:

struct Mailbox* mx_mbox_find ( struct Account a,
const char *  path 
)

XXX.

find a mailbox on an account

Definition at line 1694 of file mx.c.

1695 {
1696  if (!a || !path)
1697  return NULL;
1698 
1699  struct MailboxNode *np = NULL;
1700  STAILQ_FOREACH(np, &a->mailboxes, entries)
1701  {
1702  if (mutt_str_strcmp(np->m->realpath, path) == 0)
1703  return np->m;
1704  }
1705 
1706  return NULL;
1707 }
struct MailboxList mailboxes
Definition: account.h:39
struct Mailbox * m
Definition: mailbox.h:139
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
List of Mailboxes.
Definition: mailbox.h:137
char realpath[PATH_MAX]
used for duplicate detection, context comparison, and the sidebar
Definition: mailbox.h:79
int mutt_str_strcmp(const char *a, const char *b)
Compare two strings, safely.
Definition: string.c:612

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

struct Mailbox* mx_mbox_find2 ( const char *  path)

XXX.

find a mailbox on an account

Definition at line 1714 of file mx.c.

1715 {
1716  if (!path)
1717  return NULL;
1718 
1719  char buf[PATH_MAX];
1720  mutt_str_strfcpy(buf, path, sizeof(buf));
1721  mx_path_canon(buf, sizeof(buf), Folder, NULL);
1722 
1723  struct Account *np = NULL;
1724  TAILQ_FOREACH(np, &AllAccounts, entries)
1725  {
1726  struct Mailbox *m = mx_mbox_find(np, buf);
1727  if (m)
1728  return m;
1729  }
1730 
1731  return NULL;
1732 }
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:719
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:1497
XXX.
Definition: account.h:36
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
XXX.
Definition: mx.c:1694
struct AccountList AllAccounts
List of all Accounts.
Definition: account.c:33
A folder/dir in the browser.
Definition: browser.h:47
A mailbox.
Definition: mailbox.h:76
#define PATH_MAX
Definition: mutt.h:46
size_t mutt_str_strfcpy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:742

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_ac_add ( struct Account a,
struct Mailbox m 
)

Add a Mailbox to an Account - Wrapper for MxOps::ac_add.

Definition at line 1737 of file mx.c.

1738 {
1739  if (!a || !m || !m->mx_ops || !m->mx_ops->ac_add)
1740  return -1;
1741 
1742  return m->mx_ops->ac_add(a, m);
1743 }
int(* ac_add)(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account.
Definition: mx.h:123
const struct MxOps * mx_ops
Definition: mailbox.h:105

+ Here is the caller graph for this function:

int mx_ac_remove ( struct Mailbox m)

Remove a Mailbox from an Account and delete Account if empty.

Parameters
mMailbox to remove

Definition at line 1749 of file mx.c.

1750 {
1751  if (!m || !m->account)
1752  return -1;
1753 
1755  return 0;
1756 }
void account_remove_mailbox(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
Definition: account.c:52
struct Account * account
Definition: mailbox.h:125

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void mx_cleanup_context ( struct Context ctx)

Release memory and initialize a Context object.

Parameters
ctxContext to cleanup

Definition at line 1762 of file mx.c.

1763 {
1764  FREE(&ctx->pattern);
1765  if (ctx->limit_pattern)
1767  memset(ctx, 0, sizeof(struct Context));
1768 }
The "current" mailbox.
Definition: context.h:36
void mutt_pattern_free(struct Pattern **pat)
Free a Pattern.
Definition: pattern.c:1248
struct Pattern * limit_pattern
compiled limit pattern
Definition: context.h:40
#define FREE(x)
Definition: memory.h:46
char * pattern
limit pattern string
Definition: context.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mx_mbox_check_stats ( struct Mailbox m,
int  flags 
)

Check the statistics for a mailbox - Wrapper for MxOps::mbox_check_stats.

Definition at line 1773 of file mx.c.

1774 {
1775  if (!m)
1776  return -1;
1777 
1778  return m->mx_ops->mbox_check_stats(m, flags);
1779 }
int(* mbox_check_stats)(struct Mailbox *m, int flags)
Check the mailbox statistics.
Definition: mx.h:156
int flags
e.g.
Definition: mailbox.h:128
const struct MxOps * mx_ops
Definition: mailbox.h:105

+ Here is the caller graph for this function:

Variable Documentation

unsigned char CatchupNewsgroup

Config: (nntp) Mark all articles as read when leaving a newsgroup.

Definition at line 90 of file mx.c.

bool KeepFlagged

Config: Don't move flagged messages from Spoolfile to Mbox.

Definition at line 91 of file mx.c.

short MboxType

Config: Default type for creating new mailboxes.

Definition at line 92 of file mx.c.

unsigned char Move

Config: Move emails from Spoolfile to Mbox when read.

Definition at line 93 of file mx.c.

char* Trash

Config: Folder to put deleted emails.

Definition at line 94 of file mx.c.

const struct MxOps* mx_ops[]
static
Initial value:
= {
NULL,
}
struct MxOps MxMhOps
MH mailbox - Implements MxOps.
Definition: mh.c:804
struct MxOps MxMaildirOps
Maildir mailbox - Implements MxOps.
Definition: maildir.c:684
struct MxOps MxPopOps
POP mailbox - Implements MxOps.
Definition: pop.c:1281
struct MxOps MxMboxOps
Mbox mailbox - Implements MxOps.
Definition: mbox.c:1840
struct MxOps MxCompOps
Compressed mailbox - Implements MxOps.
Definition: compress.c:995
struct MxOps MxImapOps
IMAP mailbox - Implements MxOps.
Definition: imap.c:2544
struct MxOps MxNntpOps
NNTP mailbox - Implements MxOps.
Definition: nntp.c:2894
struct MxOps MxMmdfOps
MMDF mailbox - Implements MxOps.
Definition: mbox.c:1867
struct MxOps MxNotmuchOps
Notmuch mailbox - Implements MxOps.

All the Mailbox backends.

Definition at line 99 of file mx.c.