NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
mx.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include "config/lib.h"
#include "core/lib.h"
+ Include dependency graph for mx.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Message
 A local copy of an email. More...
 
struct  MxOps
 The Mailbox API. More...
 

Macros

#define MUTT_OPEN_NO_FLAGS   0
 No flags are set. More...
 
#define MUTT_NOSORT   (1 << 0)
 Do not sort the mailbox after opening it. More...
 
#define MUTT_APPEND   (1 << 1)
 Open mailbox for appending messages. More...
 
#define MUTT_READONLY   (1 << 2)
 Open in read-only mode. More...
 
#define MUTT_QUIET   (1 << 3)
 Do not print any messages. More...
 
#define MUTT_NEWFOLDER   (1 << 4)
 Create a new folder - same as MUTT_APPEND,. More...
 
#define MUTT_PEEK   (1 << 5)
 Revert atime back after taking a look (if applicable) More...
 
#define MUTT_APPENDNEW   (1 << 6)
 Set in mx_open_mailbox_append if the mailbox doesn't exist. More...
 
#define MUTT_MSG_NO_FLAGS   0
 No flags are set. More...
 
#define MUTT_ADD_FROM   (1 << 0)
 add a From_ line More...
 
#define MUTT_SET_DRAFT   (1 << 1)
 set the message draft flag More...
 

Typedefs

typedef uint8_t OpenMailboxFlags
 Flags for mutt_open_mailbox(), e.g. MUTT_NOSORT. More...
 
typedef uint8_t MsgOpenFlags
 Flags for mx_msg_open_new(), e.g. MUTT_ADD_FROM. More...
 

Enumerations

enum  MxStatus {
  MX_STATUS_ERROR = -1, MX_STATUS_OK, MX_STATUS_NEW_MAIL, MX_STATUS_LOCKED,
  MX_STATUS_REOPENED, MX_STATUS_FLAGS
}
 Return values from mx_mbox_check(), mx_mbox_sync(), and mx_mbox_close() More...
 
enum  MxOpenReturns { MX_OPEN_OK, MX_OPEN_ERROR, MX_OPEN_ABORT }
 Return values for mbox_open() More...
 

Functions

enum MxStatus mx_mbox_check (struct Mailbox *m)
 Check for new mail - Wrapper for MxOps::mbox_check() More...
 
enum MxStatus mx_mbox_check_stats (struct Mailbox *m, uint8_t flags)
 Check the statistics for a mailbox - Wrapper for MxOps::mbox_check_stats() More...
 
enum MxStatus mx_mbox_close (struct Context **ptr)
 Save changes and close mailbox. More...
 
struct Contextmx_mbox_open (struct Mailbox *m, OpenMailboxFlags flags)
 Open a mailbox and parse it. More...
 
enum MxStatus mx_mbox_sync (struct Mailbox *m)
 Save changes to mailbox. More...
 
int mx_msg_close (struct Mailbox *m, struct Message **msg)
 Close 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...
 
struct Messagemx_msg_open_new (struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
 Open a new message. More...
 
struct Messagemx_msg_open (struct Mailbox *m, int msgno)
 return a stream pointer for a message More...
 
int mx_msg_padding_size (struct Mailbox *m)
 Bytes of padding between messages - Wrapper for MxOps::msg_padding_size() More...
 
int mx_save_hcache (struct Mailbox *m, struct Email *e)
 Save message to the header cache - Wrapper for MxOps::msg_save_hcache() More...
 
int mx_path_canon (char *buf, size_t buflen, const char *folder, enum MailboxType *type)
 Canonicalise a mailbox path - Wrapper for MxOps::path_canon() More...
 
int mx_path_canon2 (struct Mailbox *m, const char *folder)
 Canonicalise the path to realpath. 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_path_pretty (char *buf, size_t buflen, const char *folder)
 Abbreviate a mailbox path - Wrapper for MxOps::path_pretty() More...
 
enum MailboxType mx_path_probe (const char *path)
 Find a mailbox that understands a path. More...
 
struct Mailboxmx_path_resolve (const char *path)
 Get a Mailbox for a path. More...
 
struct Mailboxmx_resolve (const char *path_or_name)
 Get a Mailbox from either a path or name. More...
 
int mx_tags_commit (struct Mailbox *m, struct Email *e, char *tags)
 Save tags to the Mailbox - Wrapper for MxOps::tags_commit() More...
 
int mx_tags_edit (struct Mailbox *m, const char *tags, char *buf, size_t buflen)
 start the tag editor of the mailbox More...
 
struct Accountmx_ac_find (struct Mailbox *m)
 Find the Account owning a Mailbox. More...
 
struct Mailboxmx_mbox_find (struct Account *a, const char *path)
 Find a Mailbox on an Account. More...
 
struct Mailboxmx_mbox_find2 (const char *path)
 Find a Mailbox on an Account. More...
 
bool mx_mbox_ac_link (struct Mailbox *m)
 Link a Mailbox to an existing or new Account. More...
 
bool 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...
 
int mx_access (const char *path, int flags)
 Wrapper for access, checks permissions on a given mailbox. More...
 
void mx_alloc_memory (struct Mailbox *m)
 Create storage for the emails. More...
 
int mx_path_is_empty (const char *path)
 Is the mailbox empty. More...
 
void mx_fastclose_mailbox (struct Mailbox *m)
 free up memory associated with the Mailbox More...
 
const struct MxOpsmx_get_ops (enum MailboxType type)
 Get mailbox operations. More...
 
bool mx_tags_is_supported (struct Mailbox *m)
 return true if mailbox support tagging More...
 

Variables

const struct MxOpsmx_ops []
 All the Mailbox backends. More...
 
bool C_KeepFlagged
 Config: Don't move flagged messages from $spool_file to $mbox More...
 
unsigned char C_MboxType
 Config: Default type for creating new mailboxes. More...
 
unsigned char C_Move
 Config: Move emails from $spool_file to $mbox when read. More...
 
char * C_Trash
 Config: Folder to put deleted emails. More...
 
struct EnumDef MboxTypeDef
 

Detailed Description

API for mailboxes

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.h.

Macro Definition Documentation

◆ MUTT_OPEN_NO_FLAGS

#define MUTT_OPEN_NO_FLAGS   0

No flags are set.

Definition at line 51 of file mx.h.

◆ MUTT_NOSORT

#define MUTT_NOSORT   (1 << 0)

Do not sort the mailbox after opening it.

Definition at line 52 of file mx.h.

◆ MUTT_APPEND

#define MUTT_APPEND   (1 << 1)

Open mailbox for appending messages.

Definition at line 53 of file mx.h.

◆ MUTT_READONLY

#define MUTT_READONLY   (1 << 2)

Open in read-only mode.

Definition at line 54 of file mx.h.

◆ MUTT_QUIET

#define MUTT_QUIET   (1 << 3)

Do not print any messages.

Definition at line 55 of file mx.h.

◆ MUTT_NEWFOLDER

#define MUTT_NEWFOLDER   (1 << 4)

Create a new folder - same as MUTT_APPEND,.

but uses mutt_file_fopen() with mode "w" for mbox-style folders. This will truncate an existing file.

Definition at line 56 of file mx.h.

◆ MUTT_PEEK

#define MUTT_PEEK   (1 << 5)

Revert atime back after taking a look (if applicable)

Definition at line 59 of file mx.h.

◆ MUTT_APPENDNEW

#define MUTT_APPENDNEW   (1 << 6)

Set in mx_open_mailbox_append if the mailbox doesn't exist.

Used by maildir/mh to create the mailbox.

Definition at line 60 of file mx.h.

◆ MUTT_MSG_NO_FLAGS

#define MUTT_MSG_NO_FLAGS   0

No flags are set.

Definition at line 64 of file mx.h.

◆ MUTT_ADD_FROM

#define MUTT_ADD_FROM   (1 << 0)

add a From_ line

Definition at line 65 of file mx.h.

◆ MUTT_SET_DRAFT

#define MUTT_SET_DRAFT   (1 << 1)

set the message draft flag

Definition at line 66 of file mx.h.

Typedef Documentation

◆ OpenMailboxFlags

typedef uint8_t OpenMailboxFlags

Flags for mutt_open_mailbox(), e.g. MUTT_NOSORT.

Definition at line 50 of file mx.h.

◆ MsgOpenFlags

typedef uint8_t MsgOpenFlags

Flags for mx_msg_open_new(), e.g. MUTT_ADD_FROM.

Definition at line 63 of file mx.h.

Enumeration Type Documentation

◆ MxStatus

enum MxStatus

Return values from mx_mbox_check(), mx_mbox_sync(), and mx_mbox_close()

Enumerator
MX_STATUS_ERROR 

An error occurred.

MX_STATUS_OK 

No changes.

MX_STATUS_NEW_MAIL 

New mail received in Mailbox.

MX_STATUS_LOCKED 

Couldn't lock the Mailbox.

MX_STATUS_REOPENED 

Mailbox was reopened.

MX_STATUS_FLAGS 

Nondestructive flags change (IMAP)

Definition at line 71 of file mx.h.

◆ MxOpenReturns

Return values for mbox_open()

Enumerator
MX_OPEN_OK 

Open succeeded.

MX_OPEN_ERROR 

Open failed with an error.

MX_OPEN_ABORT 

Open was aborted.

Definition at line 84 of file mx.h.

85 {
86  MX_OPEN_OK,
89 };

Function Documentation

◆ mx_mbox_check()

enum MxStatus mx_mbox_check ( struct Mailbox m)

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

Parameters
mMailbox
Return values
enumMxStatus

Definition at line 1137 of file mx.c.

1138 {
1139  if (!m || !m->mx_ops)
1140  return MX_STATUS_ERROR;
1141 
1142  enum MxStatus rc = m->mx_ops->mbox_check(m);
1143  if ((rc == MX_STATUS_NEW_MAIL) || (rc == MX_STATUS_REOPENED))
1144  {
1146  }
1147 
1148  return rc;
1149 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_mbox_check_stats()

enum MxStatus mx_mbox_check_stats ( struct Mailbox m,
uint8_t  flags 
)

Check the statistics for a mailbox - Wrapper for MxOps::mbox_check_stats()

Definition at line 1798 of file mx.c.

1799 {
1800  if (!m)
1801  return MX_STATUS_ERROR;
1802 
1803  return m->mx_ops->mbox_check_stats(m, flags);
1804 }
+ Here is the caller graph for this function:

◆ mx_mbox_close()

enum MxStatus mx_mbox_close ( struct Context **  ptr)

Save changes and close mailbox.

Parameters
[out]ptrMailbox
Return values
enumMxStatus
Note
The flag retvals come from a call to a backend sync function
Context will be freed after it's closed
It's very important to ensure the mailbox is properly closed before free'ing the context. For selected mailboxes, IMAP will cache the context inside connection->adata until imap_close_mailbox() removes it. Readonly, dontwrite, and append mailboxes are guaranteed to call mx_fastclose_mailbox(), so for most of NeoMutt's code you won't see return value checks for temporary contexts.

Definition at line 632 of file mx.c.

633 {
634  if (!ptr || !*ptr)
635  return MX_STATUS_OK;
636 
637  struct Context *ctx = *ptr;
638  if (!ctx || !ctx->mailbox)
639  return MX_STATUS_ERROR;
640 
641  struct Mailbox *m = ctx->mailbox;
642 
643  if (C_MailCheckRecent && !m->peekonly)
644  m->has_new = false;
645 
646  if (m->readonly || m->dontwrite || m->append || m->peekonly)
647  {
649  ctx_free(ptr);
650  return 0;
651  }
652 
653  int i, read_msgs = 0;
654  enum MxStatus rc = MX_STATUS_ERROR;
655  enum QuadOption move_messages = MUTT_NO;
656  enum QuadOption purge = MUTT_YES;
657  struct Buffer *mbox = NULL;
658  struct Buffer *buf = mutt_buffer_pool_get();
659 
660 #ifdef USE_NNTP
661  if ((m->msg_unread != 0) && (m->type == MUTT_NNTP))
662  {
663  struct NntpMboxData *mdata = m->mdata;
664 
665  if (mdata && mdata->adata && mdata->group)
666  {
667  enum QuadOption ans =
668  query_quadoption(C_CatchupNewsgroup, _("Mark all articles read?"));
669  if (ans == MUTT_ABORT)
670  goto cleanup;
671  if (ans == MUTT_YES)
672  mutt_newsgroup_catchup(m, mdata->adata, mdata->group);
673  }
674  }
675 #endif
676 
677  for (i = 0; i < m->msg_count; i++)
678  {
679  struct Email *e = m->emails[i];
680  if (!e)
681  break;
682 
683  if (!e->deleted && e->read && !(e->flagged && C_KeepFlagged))
684  read_msgs++;
685  }
686 
687 #ifdef USE_NNTP
688  /* don't need to move articles from newsgroup */
689  if (m->type == MUTT_NNTP)
690  read_msgs = 0;
691 #endif
692 
693  if ((read_msgs != 0) && (C_Move != MUTT_NO))
694  {
695  bool is_spool;
696  mbox = mutt_buffer_pool_get();
697 
699  if (p)
700  {
701  is_spool = true;
702  mutt_buffer_strcpy(mbox, p);
703  }
704  else
705  {
706  mutt_buffer_strcpy(mbox, C_Mbox);
707  is_spool = mutt_is_spool(mailbox_path(m)) &&
709  }
710 
711  if (is_spool && !mutt_buffer_is_empty(mbox))
712  {
714  mutt_buffer_printf(buf,
715  /* L10N: The first argument is the number of read messages to be
716  moved, the second argument is the target mailbox. */
717  ngettext("Move %d read message to %s?",
718  "Move %d read messages to %s?", read_msgs),
719  read_msgs, mutt_buffer_string(mbox));
720  move_messages = query_quadoption(C_Move, mutt_buffer_string(buf));
721  if (move_messages == MUTT_ABORT)
722  goto cleanup;
723  }
724  }
725 
726  /* There is no point in asking whether or not to purge if we are
727  * just marking messages as "trash". */
728  if ((m->msg_deleted != 0) && !((m->type == MUTT_MAILDIR) && C_MaildirTrash))
729  {
730  mutt_buffer_printf(buf,
731  ngettext("Purge %d deleted message?",
732  "Purge %d deleted messages?", m->msg_deleted),
733  m->msg_deleted);
735  if (purge == MUTT_ABORT)
736  goto cleanup;
737  }
738 
739  if (C_MarkOld && !m->peekonly)
740  {
741  for (i = 0; i < m->msg_count; i++)
742  {
743  struct Email *e = m->emails[i];
744  if (!e)
745  break;
746  if (!e->deleted && !e->old && !e->read)
747  mutt_set_flag(m, e, MUTT_OLD, true);
748  }
749  }
750 
751  if (move_messages)
752  {
753  if (m->verbose)
754  mutt_message(_("Moving read messages to %s..."), mutt_buffer_string(mbox));
755 
756 #ifdef USE_IMAP
757  /* try to use server-side copy first */
758  i = 1;
759 
760  if ((m->type == MUTT_IMAP) && (imap_path_probe(mutt_buffer_string(mbox), NULL) == MUTT_IMAP))
761  {
762  /* add messages for moving, and clear old tags, if any */
763  struct EmailList el = STAILQ_HEAD_INITIALIZER(el);
764  for (i = 0; i < m->msg_count; i++)
765  {
766  struct Email *e = m->emails[i];
767  if (!e)
768  break;
769 
770  if (e->read && !e->deleted && !(e->flagged && C_KeepFlagged))
771  {
772  e->tagged = true;
773  emaillist_add_email(&el, e);
774  }
775  else
776  e->tagged = false;
777  }
778 
780  emaillist_clear(&el);
781  }
782 
783  if (i == 0) /* success */
785  else if (i == -1) /* horrible error, bail */
786  goto cleanup;
787  else /* use regular append-copy mode */
788 #endif
789  {
790  struct Mailbox *m_read = mx_path_resolve(mutt_buffer_string(mbox));
791  struct Context *ctx_read = mx_mbox_open(m_read, MUTT_APPEND);
792  if (!ctx_read)
793  {
794  mailbox_free(&m_read);
795  goto cleanup;
796  }
797 
798  for (i = 0; i < m->msg_count; i++)
799  {
800  struct Email *e = m->emails[i];
801  if (!e)
802  break;
803  if (e->read && !e->deleted && !(e->flagged && C_KeepFlagged))
804  {
805  if (mutt_append_message(ctx_read->mailbox, ctx->mailbox, e,
807  {
808  mutt_set_flag(m, e, MUTT_DELETE, true);
809  mutt_set_flag(m, e, MUTT_PURGE, true);
810  }
811  else
812  {
813  mx_mbox_close(&ctx_read);
814  goto cleanup;
815  }
816  }
817  }
818 
819  mx_mbox_close(&ctx_read);
820  }
821  }
822  else if (!m->changed && (m->msg_deleted == 0))
823  {
824  if (m->verbose)
825  mutt_message(_("Mailbox is unchanged"));
826  if ((m->type == MUTT_MBOX) || (m->type == MUTT_MMDF))
827  mbox_reset_atime(m, NULL);
829  ctx_free(ptr);
830  rc = MX_STATUS_OK;
831  goto cleanup;
832  }
833 
834  /* copy mails to the trash before expunging */
835  const struct Mailbox *m_trash = mx_mbox_find(m->account, C_Trash);
836  if (purge && (m->msg_deleted != 0) && (m != m_trash))
837  {
838  if (trash_append(ctx->mailbox) != 0)
839  goto cleanup;
840  }
841 
842 #ifdef USE_IMAP
843  /* allow IMAP to preserve the deleted flag across sessions */
844  if (m->type == MUTT_IMAP)
845  {
846  const enum MxStatus check = imap_sync_mailbox(ctx->mailbox, (purge != MUTT_NO), true);
847  if (check == MX_STATUS_ERROR)
848  {
849  rc = check;
850  goto cleanup;
851  }
852  }
853  else
854 #endif
855  {
856  if (purge == MUTT_NO)
857  {
858  for (i = 0; i < m->msg_count; i++)
859  {
860  struct Email *e = m->emails[i];
861  if (!e)
862  break;
863 
864  e->deleted = false;
865  e->purge = false;
866  }
867  m->msg_deleted = 0;
868  }
869 
870  if (m->changed || (m->msg_deleted != 0))
871  {
872  enum MxStatus check = sync_mailbox(ctx->mailbox);
873  if (check != MX_STATUS_OK)
874  {
875  rc = check;
876  goto cleanup;
877  }
878  }
879  }
880 
881  if (m->verbose)
882  {
883  if (move_messages)
884  {
885  mutt_message(_("%d kept, %d moved, %d deleted"),
886  m->msg_count - m->msg_deleted, read_msgs, m->msg_deleted);
887  }
888  else
889  mutt_message(_("%d kept, %d deleted"), m->msg_count - m->msg_deleted, m->msg_deleted);
890  }
891 
892  if ((m->msg_count == m->msg_deleted) &&
893  ((m->type == MUTT_MMDF) || (m->type == MUTT_MBOX)) &&
895  {
897  }
898 
899 #ifdef USE_SIDEBAR
900  if ((purge == MUTT_YES) && (m->msg_deleted != 0))
901  {
902  for (i = 0; i < m->msg_count; i++)
903  {
904  struct Email *e = m->emails[i];
905  if (!e)
906  break;
907  if (e->deleted && !e->read)
908  {
909  m->msg_unread--;
910  if (!e->old)
911  m->msg_new--;
912  }
913  if (e->deleted && e->flagged)
914  m->msg_flagged--;
915  }
916  }
917 #endif
918 
920  ctx_free(ptr);
921 
922  rc = MX_STATUS_OK;
923 
924 cleanup:
927  return rc;
928 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_mbox_open()

struct Context* mx_mbox_open ( struct Mailbox m,
OpenMailboxFlags  flags 
)

Open a mailbox and parse it.

Parameters
mMailbox to open
flagsFlags, see OpenMailboxFlags
Return values
ptrMailbox context
NULLError

Definition at line 309 of file mx.c.

310 {
311  if (!m)
312  return NULL;
313 
314  struct Context *ctx = ctx_new(m);
315 
316  struct EventContext ev_ctx = { ctx };
317  notify_send(ctx->notify, NT_CONTEXT, NT_CONTEXT_OPEN, &ev_ctx);
318 
319  // If the Mailbox is closed, Context->mailbox must be set to NULL
321 
322  if ((m->type == MUTT_UNKNOWN) && (flags & (MUTT_NEWFOLDER | MUTT_APPEND)))
323  {
324  m->type = C_MboxType;
325  m->mx_ops = mx_get_ops(m->type);
326  }
327 
328  const bool newly_linked_account = !m->account;
329  if (newly_linked_account)
330  {
331  if (!mx_mbox_ac_link(m))
332  {
333  ctx_free(&ctx);
334  return NULL;
335  }
336  }
337 
338  ctx->msg_in_pager = -1;
339  ctx->collapsed = false;
340 
341  m->verbose = !(flags & MUTT_QUIET);
342  if (flags & MUTT_READONLY)
343  m->readonly = true;
344  m->peekonly = (flags & MUTT_PEEK);
345 
346  if (flags & (MUTT_APPEND | MUTT_NEWFOLDER))
347  {
348  if (!mx_open_mailbox_append(ctx->mailbox, flags))
349  {
350  goto error;
351  }
352  return ctx;
353  }
354 
355  if (m->opened > 0)
356  {
357  m->opened++;
358  return ctx;
359  }
360 
361  m->size = 0;
362  m->msg_unread = 0;
363  m->msg_flagged = 0;
364  m->rights = MUTT_ACL_ALL;
365 
366  if (m->type == MUTT_UNKNOWN)
367  {
369  m->mx_ops = mx_get_ops(m->type);
370  }
371 
372  if ((m->type == MUTT_UNKNOWN) || (m->type == MUTT_MAILBOX_ERROR) || !m->mx_ops)
373  {
374  if (m->type == MUTT_MAILBOX_ERROR)
376  else if ((m->type == MUTT_UNKNOWN) || !m->mx_ops)
377  mutt_error(_("%s is not a mailbox"), mailbox_path(m));
378  goto error;
379  }
380 
382 
383  /* if the user has a 'push' command in their .neomuttrc, or in a folder-hook,
384  * it will cause the progress messages not to be displayed because
385  * mutt_refresh() will think we are in the middle of a macro. so set a
386  * flag to indicate that we should really refresh the screen. */
387  OptForceRefresh = true;
388 
389  if (m->verbose)
390  mutt_message(_("Reading %s..."), mailbox_path(m));
391 
392  // Clear out any existing emails
393  for (int i = 0; i < m->email_max; i++)
394  {
395  email_free(&m->emails[i]);
396  }
397 
398  m->msg_count = 0;
399  m->msg_unread = 0;
400  m->msg_flagged = 0;
401  m->msg_new = 0;
402  m->msg_deleted = 0;
403  m->msg_tagged = 0;
404  m->vcount = 0;
405 
406  enum MxOpenReturns rc = m->mx_ops->mbox_open(ctx->mailbox);
407  m->opened++;
408  if (rc == MX_OPEN_OK)
409  ctx_update(ctx);
410 
411  if ((rc == MX_OPEN_OK) || (rc == MX_OPEN_ABORT))
412  {
413  if ((flags & MUTT_NOSORT) == 0)
414  {
415  /* avoid unnecessary work since the mailbox is completely unthreaded
416  * to begin with */
417  OptSortSubthreads = false;
418  OptNeedRescore = false;
419  }
420  if (m->verbose)
422  if (rc == MX_OPEN_ABORT)
423  {
424  mutt_error(_("Reading from %s interrupted..."), mailbox_path(m));
425  mutt_sort_headers(ctx->mailbox, ctx->threads, true, &ctx->vsize);
426  }
427  }
428  else
429  {
430  goto error;
431  }
432 
433  if (!m->peekonly)
434  m->has_new = false;
435  OptForceRefresh = false;
436 
437  return ctx;
438 
439 error:
441  if (newly_linked_account)
443  ctx_free(&ctx);
444  return NULL;
445 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_mbox_sync()

enum MxStatus mx_mbox_sync ( struct Mailbox m)

Save changes to mailbox.

Parameters
[in]mMailbox
Return values
enumMxStatus
Note
The flag retvals come from a call to a backend sync function

Definition at line 937 of file mx.c.

938 {
939  if (!m)
940  return MX_STATUS_ERROR;
941 
942  enum MxStatus rc = MX_STATUS_OK;
943  int purge = 1;
944  int msgcount, deleted;
945 
946  if (m->dontwrite)
947  {
948  char buf[256], tmp[256];
949  if (km_expand_key(buf, sizeof(buf), km_find_func(MENU_MAIN, OP_TOGGLE_WRITE)))
950  snprintf(tmp, sizeof(tmp), _(" Press '%s' to toggle write"), buf);
951  else
952  mutt_str_copy(tmp, _("Use 'toggle-write' to re-enable write"), sizeof(tmp));
953 
954  mutt_error(_("Mailbox is marked unwritable. %s"), tmp);
955  return MX_STATUS_ERROR;
956  }
957  else if (m->readonly)
958  {
959  mutt_error(_("Mailbox is read-only"));
960  return MX_STATUS_ERROR;
961  }
962 
963  if (!m->changed && (m->msg_deleted == 0))
964  {
965  if (m->verbose)
966  mutt_message(_("Mailbox is unchanged"));
967  return MX_STATUS_OK;
968  }
969 
970  if (m->msg_deleted != 0)
971  {
972  char buf[128];
973 
974  snprintf(buf, sizeof(buf),
975  ngettext("Purge %d deleted message?", "Purge %d deleted messages?", m->msg_deleted),
976  m->msg_deleted);
977  purge = query_quadoption(C_Delete, buf);
978  if (purge == MUTT_ABORT)
979  return MX_STATUS_ERROR;
980  if (purge == MUTT_NO)
981  {
982  if (!m->changed)
983  return MX_STATUS_OK; /* nothing to do! */
984  /* let IMAP servers hold on to D flags */
985  if (m->type != MUTT_IMAP)
986  {
987  for (int i = 0; i < m->msg_count; i++)
988  {
989  struct Email *e = m->emails[i];
990  if (!e)
991  break;
992  e->deleted = false;
993  e->purge = false;
994  }
995  m->msg_deleted = 0;
996  }
997  }
999  }
1000 
1001  /* really only for IMAP - imap_sync_mailbox results in a call to
1002  * ctx_update_tables, so m->msg_deleted is 0 when it comes back */
1003  msgcount = m->msg_count;
1004  deleted = m->msg_deleted;
1005 
1006  const struct Mailbox *m_trash = mx_mbox_find(m->account, C_Trash);
1007  if (purge && (m->msg_deleted != 0) && (m != m_trash))
1008  {
1009  if (trash_append(m) != 0)
1010  return MX_STATUS_OK;
1011  }
1012 
1013 #ifdef USE_IMAP
1014  if (m->type == MUTT_IMAP)
1015  rc = imap_sync_mailbox(m, purge, false);
1016  else
1017 #endif
1018  rc = sync_mailbox(m);
1019  if (rc != MX_STATUS_ERROR)
1020  {
1021 #ifdef USE_IMAP
1022  if ((m->type == MUTT_IMAP) && !purge)
1023  {
1024  if (m->verbose)
1025  mutt_message(_("Mailbox checkpointed"));
1026  }
1027  else
1028 #endif
1029  {
1030  if (m->verbose)
1031  mutt_message(_("%d kept, %d deleted"), msgcount - deleted, deleted);
1032  }
1033 
1034  mutt_sleep(0);
1035 
1036  if ((m->msg_count == m->msg_deleted) &&
1037  ((m->type == MUTT_MBOX) || (m->type == MUTT_MMDF)) &&
1039  {
1040  unlink(mailbox_path(m));
1042  return MX_STATUS_OK;
1043  }
1044 
1045  /* if we haven't deleted any messages, we don't need to resort */
1046  /* ... except for certain folder formats which need "unsorted"
1047  * sort order in order to synchronize folders.
1048  *
1049  * MH and maildir are safe. mbox-style seems to need re-sorting,
1050  * at least with the new threading code. */
1051  if (purge || ((m->type != MUTT_MAILDIR) && (m->type != MUTT_MH)))
1052  {
1053  /* IMAP does this automatically after handling EXPUNGE */
1054  if (m->type != MUTT_IMAP)
1055  {
1058  }
1059  }
1060  }
1061 
1062  return rc;
1063 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_msg_close()

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

Close a message.

Parameters
[in]mMailbox
[out]msgMessage to close
Return values
0Success
-1Failure

Definition at line 1204 of file mx.c.

1205 {
1206  if (!m || !msg || !*msg)
1207  return 0;
1208 
1209  int rc = 0;
1210 
1211  if (m->mx_ops && m->mx_ops->msg_close)
1212  rc = m->mx_ops->msg_close(m, *msg);
1213 
1214  if ((*msg)->path)
1215  {
1216  mutt_debug(LL_DEBUG1, "unlinking %s\n", (*msg)->path);
1217  unlink((*msg)->path);
1218  FREE(&(*msg)->path);
1219  }
1220 
1221  FREE(&(*msg)->committed_path);
1222  FREE(msg);
1223  return rc;
1224 }
+ Here is the caller graph for this function:

◆ mx_msg_commit()

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 1183 of file mx.c.

1184 {
1185  if (!m || !m->mx_ops || !m->mx_ops->msg_commit || !msg)
1186  return -1;
1187 
1188  if (!(msg->write && m->append))
1189  {
1190  mutt_debug(LL_DEBUG1, "msg->write = %d, m->append = %d\n", msg->write, m->append);
1191  return -1;
1192  }
1193 
1194  return m->mx_ops->msg_commit(m, msg);
1195 }
+ Here is the caller graph for this function:

◆ mx_msg_open_new()

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

Open a new message.

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

Definition at line 1072 of file mx.c.

1073 {
1074  if (!m)
1075  return NULL;
1076 
1077  struct Address *p = NULL;
1078  struct Message *msg = NULL;
1079 
1080  if (!m->mx_ops || !m->mx_ops->msg_open_new)
1081  {
1082  mutt_debug(LL_DEBUG1, "function unimplemented for mailbox type %d\n", m->type);
1083  return NULL;
1084  }
1085 
1086  msg = mutt_mem_calloc(1, sizeof(struct Message));
1087  msg->write = true;
1088 
1089  if (e)
1090  {
1091  msg->flags.flagged = e->flagged;
1092  msg->flags.replied = e->replied;
1093  msg->flags.read = e->read;
1094  msg->flags.draft = (flags & MUTT_SET_DRAFT);
1095  msg->received = e->received;
1096  }
1097 
1098  if (msg->received == 0)
1099  msg->received = mutt_date_epoch();
1100 
1101  if (m->mx_ops->msg_open_new(m, msg, e))
1102  {
1103  if (m->type == MUTT_MMDF)
1104  fputs(MMDF_SEP, msg->fp);
1105 
1106  if (((m->type == MUTT_MBOX) || (m->type == MUTT_MMDF)) && (flags & MUTT_ADD_FROM))
1107  {
1108  if (e)
1109  {
1110  p = TAILQ_FIRST(&e->env->return_path);
1111  if (!p)
1112  p = TAILQ_FIRST(&e->env->sender);
1113  if (!p)
1114  p = TAILQ_FIRST(&e->env->from);
1115  }
1116 
1117  // Force a 'C' locale for the date, so that day/month names are in English
1118  locale_t loc = newlocale(LC_TIME_MASK, "C", 0);
1119  char buf[64] = { 0 };
1120  struct tm tm = mutt_date_localtime(msg->received);
1121  strftime_l(buf, sizeof(buf), "%a %b %e %H:%M:%S %Y", &tm, loc);
1122  freelocale(loc);
1123  fprintf(msg->fp, "From %s %s\n", p ? p->mailbox : NONULL(Username), buf);
1124  }
1125  }
1126  else
1127  FREE(&msg);
1128 
1129  return msg;
1130 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_msg_open()

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 1158 of file mx.c.

1159 {
1160  if (!m || !m->emails || (msgno < 0) || (msgno >= m->msg_count))
1161  return NULL;
1162 
1163  if (!m->mx_ops || !m->mx_ops->msg_open)
1164  {
1165  mutt_debug(LL_DEBUG1, "function not implemented for mailbox type %d\n", m->type);
1166  return NULL;
1167  }
1168 
1169  struct Message *msg = mutt_mem_calloc(1, sizeof(struct Message));
1170  if (!m->mx_ops->msg_open(m, msg, msgno))
1171  FREE(&msg);
1172 
1173  return msg;
1174 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_msg_padding_size()

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 1554 of file mx.c.

1555 {
1556  if (!m || !m->mx_ops || !m->mx_ops->msg_padding_size)
1557  return 0;
1558 
1559  return m->mx_ops->msg_padding_size(m);
1560 }
+ Here is the caller graph for this function:

◆ mx_save_hcache()

int mx_save_hcache ( struct Mailbox m,
struct Email e 
)

Save message to the header cache - Wrapper for MxOps::msg_save_hcache()

Parameters
mMailbox
eEmail
Return values
0Success
-1Failure

Write a single header out to the header cache.

Definition at line 1815 of file mx.c.

1816 {
1817  if (!m || !m->mx_ops || !m->mx_ops->msg_save_hcache || !e)
1818  return 0;
1819 
1820  return m->mx_ops->msg_save_hcache(m, e);
1821 }
+ Here is the caller graph for this function:

◆ mx_path_canon()

int mx_path_canon ( char *  buf,
size_t  buflen,
const char *  folder,
enum MailboxType type 
)

Canonicalise a mailbox path - Wrapper for MxOps::path_canon()

Definition at line 1381 of file mx.c.

1382 {
1383  if (!buf)
1384  return -1;
1385 
1386  for (size_t i = 0; i < 3; i++)
1387  {
1388  /* Look for !! ! - < > or ^ followed by / or NUL */
1389  if ((buf[0] == '!') && (buf[1] == '!'))
1390  {
1391  if (((buf[2] == '/') || (buf[2] == '\0')))
1392  {
1393  mutt_str_inline_replace(buf, buflen, 2, LastFolder);
1394  }
1395  }
1396  else if ((buf[0] == '+') || (buf[0] == '='))
1397  {
1398  size_t folder_len = mutt_str_len(folder);
1399  if ((folder_len > 0) && (folder[folder_len - 1] != '/'))
1400  {
1401  buf[0] = '/';
1402  mutt_str_inline_replace(buf, buflen, 0, folder);
1403  }
1404  else
1405  {
1406  mutt_str_inline_replace(buf, buflen, 1, folder);
1407  }
1408  }
1409  else if ((buf[1] == '/') || (buf[1] == '\0'))
1410  {
1411  if (buf[0] == '!')
1412  {
1413  mutt_str_inline_replace(buf, buflen, 1, C_SpoolFile);
1414  }
1415  else if (buf[0] == '-')
1416  {
1417  mutt_str_inline_replace(buf, buflen, 1, LastFolder);
1418  }
1419  else if (buf[0] == '<')
1420  {
1421  mutt_str_inline_replace(buf, buflen, 1, C_Record);
1422  }
1423  else if (buf[0] == '>')
1424  {
1425  mutt_str_inline_replace(buf, buflen, 1, C_Mbox);
1426  }
1427  else if (buf[0] == '^')
1428  {
1429  mutt_str_inline_replace(buf, buflen, 1, CurrentFolder);
1430  }
1431  else if (buf[0] == '~')
1432  {
1433  mutt_str_inline_replace(buf, buflen, 1, HomeDir);
1434  }
1435  }
1436  else if (buf[0] == '@')
1437  {
1438  /* elm compatibility, @ expands alias to user name */
1439  struct AddressList *al = alias_lookup(buf + 1);
1440  if (!al || TAILQ_EMPTY(al))
1441  break;
1442 
1443  struct Email *e = email_new();
1444  e->env = mutt_env_new();
1445  mutt_addrlist_copy(&e->env->from, al, false);
1446  mutt_addrlist_copy(&e->env->to, al, false);
1447  mutt_default_save(buf, buflen, e);
1448  email_free(&e);
1449  break;
1450  }
1451  else
1452  {
1453  break;
1454  }
1455  }
1456 
1457  // if (!folder) //XXX - use inherited version, or pass NULL to backend?
1458  // return -1;
1459 
1460  enum MailboxType type2 = mx_path_probe(buf);
1461  if (type)
1462  *type = type2;
1463  const struct MxOps *ops = mx_get_ops(type2);
1464  if (!ops || !ops->path_canon)
1465  return -1;
1466 
1467  if (ops->path_canon(buf, buflen) < 0)
1468  {
1469  mutt_path_canon(buf, buflen, HomeDir, true);
1470  }
1471 
1472  return 0;
1473 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_path_canon2()

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

Canonicalise the path to realpath.

Parameters
mMailbox
folderPath to canonicalise
Return values
0Success
-1Failure

Definition at line 1482 of file mx.c.

1483 {
1484  if (!m)
1485  return -1;
1486 
1487  char buf[PATH_MAX];
1488 
1489  if (m->realpath)
1490  mutt_str_copy(buf, m->realpath, sizeof(buf));
1491  else
1492  mutt_str_copy(buf, mailbox_path(m), sizeof(buf));
1493 
1494  int rc = mx_path_canon(buf, sizeof(buf), folder, &m->type);
1495 
1496  mutt_str_replace(&m->realpath, buf);
1497 
1498  if (rc >= 0)
1499  {
1500  m->mx_ops = mx_get_ops(m->type);
1502  }
1503 
1504  return rc;
1505 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_path_parent()

int mx_path_parent ( char *  buf,
size_t  buflen 
)

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

Definition at line 1538 of file mx.c.

1539 {
1540  if (!buf)
1541  return -1;
1542 
1543  return 0;
1544 }

◆ mx_path_pretty()

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

Abbreviate a mailbox path - Wrapper for MxOps::path_pretty()

Definition at line 1510 of file mx.c.

1511 {
1512  if (!buf)
1513  return -1;
1514 
1515  enum MailboxType type = mx_path_probe(buf);
1516  const struct MxOps *ops = mx_get_ops(type);
1517  if (!ops)
1518  return -1;
1519 
1520  if (!ops->path_canon)
1521  return -1;
1522 
1523  if (ops->path_canon(buf, buflen) < 0)
1524  return -1;
1525 
1526  if (!ops->path_pretty)
1527  return -1;
1528 
1529  if (ops->path_pretty(buf, buflen, folder) < 0)
1530  return -1;
1531 
1532  return 0;
1533 }
+ Here is the call graph for this function:

◆ mx_path_probe()

enum MailboxType mx_path_probe ( const char *  path)

Find a mailbox that understands a path.

Parameters
pathPath to examine
Return values
numType, e.g. MUTT_IMAP

Definition at line 1335 of file mx.c.

1336 {
1337  if (!path)
1338  return MUTT_UNKNOWN;
1339 
1340  enum MailboxType rc = MUTT_UNKNOWN;
1341 
1342  // First, search the non-local Mailbox types (is_local == false)
1343  for (const struct MxOps **ops = mx_ops; *ops; ops++)
1344  {
1345  if ((*ops)->is_local)
1346  continue;
1347  rc = (*ops)->path_probe(path, NULL);
1348  if (rc != MUTT_UNKNOWN)
1349  return rc;
1350  }
1351 
1352  struct stat st = { 0 };
1353  if (stat(path, &st) != 0)
1354  {
1355  mutt_debug(LL_DEBUG1, "unable to stat %s: %s (errno %d)\n", path, strerror(errno), errno);
1356  return MUTT_UNKNOWN;
1357  }
1358 
1359  if (S_ISFIFO(st.st_mode))
1360  {
1361  mutt_error(_("Can't open %s: it is a pipe"), path);
1362  return MUTT_UNKNOWN;
1363  }
1364 
1365  // Next, search the local Mailbox types (is_local == true)
1366  for (const struct MxOps **ops = mx_ops; *ops; ops++)
1367  {
1368  if (!(*ops)->is_local)
1369  continue;
1370  rc = (*ops)->path_probe(path, &st);
1371  if (rc != MUTT_UNKNOWN)
1372  return rc;
1373  }
1374 
1375  return rc;
1376 }
+ Here is the caller graph for this function:

◆ mx_path_resolve()

struct Mailbox* mx_path_resolve ( const char *  path)

Get a Mailbox for a path.

Parameters
pathMailbox path
Return values
ptrMailbox

If there isn't a Mailbox for the path, one will be created.

Definition at line 1681 of file mx.c.

1682 {
1683  if (!path)
1684  return NULL;
1685 
1686  struct Mailbox *m = mx_mbox_find2(path);
1687  if (m)
1688  return m;
1689 
1690  m = mailbox_new();
1691  m->flags = MB_HIDDEN;
1692  mutt_buffer_strcpy(&m->pathbuf, path);
1694 
1695  return m;
1696 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_resolve()

struct Mailbox* mx_resolve ( const char *  path_or_name)

Get a Mailbox from either a path or name.

Parameters
path_or_nameMailbox path or name
Return values
ptrMailbox

Order of resolving:

  1. Name
  2. Path

Definition at line 1750 of file mx.c.

1751 {
1752  if (!path_or_name)
1753  return NULL;
1754 
1755  // Order is name first because you can create a Mailbox from
1756  // a path, but can't from a name. So fallback behavior creates
1757  // a new Mailbox for us.
1758  struct Mailbox *m = mx_mbox_find_by_name(path_or_name);
1759  if (!m)
1760  m = mx_path_resolve(path_or_name);
1761 
1762  return m;
1763 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_tags_commit()

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 1308 of file mx.c.

1309 {
1310  if (!m || !e || !tags)
1311  return -1;
1312 
1313  if (m->mx_ops->tags_commit)
1314  return m->mx_ops->tags_commit(m, e, tags);
1315 
1316  mutt_message(_("Folder doesn't support tagging, aborting"));
1317  return -1;
1318 }
+ Here is the caller graph for this function:

◆ mx_tags_edit()

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 1288 of file mx.c.

1289 {
1290  if (!m || !buf)
1291  return -1;
1292 
1293  if (m->mx_ops->tags_edit)
1294  return m->mx_ops->tags_edit(m, tags, buf, buflen);
1295 
1296  mutt_message(_("Folder doesn't support tagging, aborting"));
1297  return -1;
1298 }
+ Here is the caller graph for this function:

◆ mx_ac_find()

struct Account* mx_ac_find ( struct Mailbox m)

Find the Account owning a Mailbox.

Parameters
mMailbox
Return values
ptrAccount
NULLNone found

Definition at line 1568 of file mx.c.

1569 {
1570  if (!m || !m->mx_ops || !m->realpath)
1571  return NULL;
1572 
1573  struct Account *np = NULL;
1574  TAILQ_FOREACH(np, &NeoMutt->accounts, entries)
1575  {
1576  if (np->type != m->type)
1577  continue;
1578 
1579  if (m->mx_ops->ac_owns_path(np, m->realpath))
1580  return np;
1581  }
1582 
1583  return NULL;
1584 }
+ Here is the caller graph for this function:

◆ mx_mbox_find()

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

Find a Mailbox on an Account.

Parameters
aAccount to search
pathPath to find
Return values
ptrMailbox

Definition at line 1592 of file mx.c.

1593 {
1594  if (!a || !path)
1595  return NULL;
1596 
1597  struct MailboxNode *np = NULL;
1598  struct Url *url_p = NULL;
1599  struct Url *url_a = NULL;
1600 
1601  const bool use_url = (a->type == MUTT_IMAP);
1602  if (use_url)
1603  {
1604  url_p = url_parse(path);
1605  if (!url_p)
1606  goto done;
1607  }
1608 
1609  STAILQ_FOREACH(np, &a->mailboxes, entries)
1610  {
1611  if (!use_url)
1612  {
1613  if (mutt_str_equal(np->mailbox->realpath, path))
1614  return np->mailbox;
1615  continue;
1616  }
1617 
1618  url_free(&url_a);
1619  url_a = url_parse(np->mailbox->realpath);
1620  if (!url_a)
1621  continue;
1622 
1623  if (!mutt_istr_equal(url_a->host, url_p->host))
1624  continue;
1625  if (url_p->user && !mutt_istr_equal(url_a->user, url_p->user))
1626  continue;
1627  if (a->type == MUTT_IMAP)
1628  {
1629  if (imap_mxcmp(url_a->path, url_p->path) == 0)
1630  break;
1631  }
1632  else
1633  {
1634  if (mutt_str_equal(url_a->path, url_p->path))
1635  break;
1636  }
1637  }
1638 
1639 done:
1640  url_free(&url_p);
1641  url_free(&url_a);
1642 
1643  if (!np)
1644  return NULL;
1645  return np->mailbox;
1646 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_mbox_find2()

struct Mailbox* mx_mbox_find2 ( const char *  path)

Find a Mailbox on an Account.

Parameters
pathPath to find
Return values
ptrMailbox
NULLNo match

Definition at line 1654 of file mx.c.

1655 {
1656  if (!path)
1657  return NULL;
1658 
1659  char buf[PATH_MAX];
1660  mutt_str_copy(buf, path, sizeof(buf));
1661  mx_path_canon(buf, sizeof(buf), C_Folder, NULL);
1662 
1663  struct Account *np = NULL;
1664  TAILQ_FOREACH(np, &NeoMutt->accounts, entries)
1665  {
1666  struct Mailbox *m = mx_mbox_find(np, buf);
1667  if (m)
1668  return m;
1669  }
1670 
1671  return NULL;
1672 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_mbox_ac_link()

bool mx_mbox_ac_link ( struct Mailbox m)

Link a Mailbox to an existing or new Account.

Parameters
mMailbox to link
Return values
trueSuccess
falseFailure

Definition at line 272 of file mx.c.

273 {
274  if (!m)
275  return false;
276 
277  if (m->account)
278  return true;
279 
280  struct Account *a = mx_ac_find(m);
281  const bool new_account = !a;
282  if (new_account)
283  {
284  a = account_new(NULL, NeoMutt->sub);
285  a->type = m->type;
286  }
287  if (!mx_ac_add(a, m))
288  {
289  if (new_account)
290  {
291  FREE(&a);
292  }
293  return false;
294  }
295  if (new_account)
296  {
298  }
299  return true;
300 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_ac_add()

bool mx_ac_add ( struct Account a,
struct Mailbox m 
)

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

Definition at line 1768 of file mx.c.

1769 {
1770  if (!a || !m || !m->mx_ops || !m->mx_ops->ac_add)
1771  return false;
1772 
1773  return m->mx_ops->ac_add(a, m) && account_mailbox_add(a, m);
1774 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_ac_remove()

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 1780 of file mx.c.

1781 {
1782  if (!m || !m->account)
1783  return -1;
1784 
1785  struct Account *a = m->account;
1787  mailbox_free(&m);
1788  if (STAILQ_EMPTY(&a->mailboxes))
1789  {
1791  }
1792  return 0;
1793 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_access()

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 189 of file mx.c.

190 {
191 #ifdef USE_IMAP
192  if (imap_path_probe(path, NULL) == MUTT_IMAP)
193  return imap_access(path);
194 #endif
195 
196  return access(path, flags);
197 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_alloc_memory()

void mx_alloc_memory ( struct Mailbox m)

Create storage for the emails.

Parameters
mMailbox

Definition at line 1230 of file mx.c.

1231 {
1232  size_t s = MAX(sizeof(struct Email *), sizeof(int));
1233 
1234  if ((m->email_max + 25) * s < m->email_max * s)
1235  {
1236  mutt_error(_("Out of memory"));
1237  mutt_exit(1);
1238  }
1239 
1240  m->email_max += 25;
1241  if (m->emails)
1242  {
1243  mutt_mem_realloc(&m->emails, sizeof(struct Email *) * m->email_max);
1244  mutt_mem_realloc(&m->v2r, sizeof(int) * m->email_max);
1245  }
1246  else
1247  {
1248  m->emails = mutt_mem_calloc(m->email_max, sizeof(struct Email *));
1249  m->v2r = mutt_mem_calloc(m->email_max, sizeof(int));
1250  }
1251  for (int i = m->email_max - 25; i < m->email_max; i++)
1252  {
1253  m->emails[i] = NULL;
1254  m->v2r[i] = -1;
1255  }
1256 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_path_is_empty()

int mx_path_is_empty ( const char *  path)

Is the mailbox empty.

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

Definition at line 1265 of file mx.c.

1266 {
1267  if (!path || (*path == '\0'))
1268  return -1;
1269 
1270  enum MailboxType type = mx_path_probe(path);
1271  const struct MxOps *ops = mx_get_ops(type);
1272  if (!ops || !ops->path_is_empty)
1273  return -1;
1274 
1275  return ops->path_is_empty(path);
1276 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_fastclose_mailbox()

void mx_fastclose_mailbox ( struct Mailbox m)

free up memory associated with the Mailbox

Parameters
mMailbox

Definition at line 451 of file mx.c.

452 {
453  if (!m)
454  return;
455 
456  m->opened--;
457  if (m->opened != 0)
458  return;
459 
460  /* never announce that a mailbox we've just left has new mail.
461  * TODO: really belongs in mx_mbox_close, but this is a nice hook point */
462  if (!m->peekonly)
464 
465  if (m->mx_ops)
466  m->mx_ops->mbox_close(m);
467 
469  mutt_hash_free(&m->id_hash);
471 
472  if (m->emails)
473  {
474  for (int i = 0; i < m->msg_count; i++)
475  {
476  if (!m->emails[i])
477  break;
478  email_free(&m->emails[i]);
479  }
480  }
481 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mx_get_ops()

const struct MxOps* mx_get_ops ( enum MailboxType  type)

Get mailbox operations.

Parameters
typeMailbox type
Return values
ptrMailbox function
NULLError

Definition at line 147 of file mx.c.

148 {
149  for (const struct MxOps **ops = mx_ops; *ops; ops++)
150  if ((*ops)->type == type)
151  return *ops;
152 
153  return NULL;
154 }
+ Here is the caller graph for this function:

◆ mx_tags_is_supported()

bool mx_tags_is_supported ( struct Mailbox m)

return true if mailbox support tagging

Parameters
mMailbox
Return values
trueTagging is supported

Definition at line 1325 of file mx.c.

1326 {
1327  return m && m->mx_ops->tags_commit && m->mx_ops->tags_edit;
1328 }
+ Here is the caller graph for this function:

Variable Documentation

◆ mx_ops

const struct MxOps* mx_ops[]

All the Mailbox backends.

Definition at line 113 of file mx.c.

◆ C_KeepFlagged

bool C_KeepFlagged

Config: Don't move flagged messages from $spool_file to $mbox

Definition at line 89 of file mx.c.

◆ C_MboxType

unsigned char C_MboxType

Config: Default type for creating new mailboxes.

Definition at line 90 of file mx.c.

◆ C_Move

unsigned char C_Move

Config: Move emails from $spool_file to $mbox when read.

Definition at line 91 of file mx.c.

◆ C_Trash

char* C_Trash

Config: Folder to put deleted emails.

Definition at line 92 of file mx.c.

◆ MboxTypeDef

struct EnumDef MboxTypeDef

Definition at line 104 of file mx.c.

ctx_free
void ctx_free(struct Context **ptr)
Free a Context.
Definition: context.c:50
Mailbox::subj_hash
struct HashTable * subj_hash
Hash Table by subject.
Definition: mailbox.h:128
MX_STATUS_LOCKED
@ MX_STATUS_LOCKED
Couldn't lock the Mailbox.
Definition: mx.h:76
MxOps::msg_padding_size
int(* msg_padding_size)(struct Mailbox *m)
Bytes of padding between messages.
Definition: mx.h:274
Message::flags
struct Message::@1 flags
MUTT_PEEK
#define MUTT_PEEK
Revert atime back after taking a look (if applicable)
Definition: mx.h:59
Mailbox::rights
AclFlags rights
ACL bits, see AclFlags.
Definition: mailbox.h:121
C_SaveEmpty
WHERE bool C_SaveEmpty
Config: (mbox,mmdf) Preserve empty mailboxes.
Definition: mutt_globals.h:158
MUTT_READONLY
#define MUTT_READONLY
Open in read-only mode.
Definition: mx.h:54
Mailbox::mx_ops
const struct MxOps * mx_ops
MXAPI callback functions.
Definition: mailbox.h:111
mx_path_canon
int mx_path_canon(char *buf, size_t buflen, const char *folder, enum MailboxType *type)
Canonicalise a mailbox path - Wrapper for MxOps::path_canon()
Definition: mx.c:1381
MxOps::mbox_check_stats
enum MxStatus(* mbox_check_stats)(struct Mailbox *m, uint8_t flags)
Check the Mailbox statistics.
Definition: mx.h:189
QuadOption
QuadOption
Possible values for a quad-option.
Definition: quad.h:36
MUTT_MMDF
@ MUTT_MMDF
'mmdf' Mailbox type
Definition: mailbox.h:49
MxStatus
MxStatus
Return values from mx_mbox_check(), mx_mbox_sync(), and mx_mbox_close()
Definition: mx.h:71
MailboxNode
List of Mailboxes.
Definition: mailbox.h:152
mutt_mem_calloc
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
MxOps::tags_edit
int(* tags_edit)(struct Mailbox *m, const char *tags, char *buf, size_t buflen)
Prompt and validate new messages tags.
Definition: mx.h:303
NeoMutt::accounts
struct AccountList accounts
List of all Accounts.
Definition: neomutt.h:40
MxOps::type
enum MailboxType type
Mailbox type, e.g. MUTT_IMAP.
Definition: mx.h:118
_
#define _(a)
Definition: message.h:28
NONULL
#define NONULL(x)
Definition: string2.h:37
Mailbox
A mailbox.
Definition: mailbox.h:81
Mailbox::v2r
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:101
Mailbox::emails
struct Email ** emails
Array of Emails.
Definition: mailbox.h:99
Mailbox::append
bool append
Mailbox is opened in append mode.
Definition: mailbox.h:113
MUTT_MBOX_HOOK
#define MUTT_MBOX_HOOK
mbox-hook: move messages after reading them
Definition: hook.h:46
MxOps::msg_open_new
bool(* msg_open_new)(struct Mailbox *m, struct Message *msg, const struct Email *e)
Open a new message in a Mailbox.
Definition: mx.h:238
NT_MAILBOX_INVALID
@ NT_MAILBOX_INVALID
Email list was changed.
Definition: mailbox.h:173
Buffer
String manipulation buffer.
Definition: buffer.h:33
Account::type
enum MailboxType type
Type of Mailboxes this Account contains.
Definition: account.h:38
mx_ops
const struct MxOps * mx_ops[]
All the Mailbox backends.
Definition: mx.c:113
mbox_reset_atime
void mbox_reset_atime(struct Mailbox *m, struct stat *st)
Reset the access time on the mailbox file.
Definition: mbox.c:833
EventContext
An Event that happened to an Context.
Definition: context.h:68
Mailbox::msg_deleted
int msg_deleted
Number of deleted messages.
Definition: mailbox.h:96
MxOps::msg_save_hcache
int(* msg_save_hcache)(struct Mailbox *m, struct Email *e)
Save message to the header cache.
Definition: mx.h:287
mx_open_mailbox_append
static bool mx_open_mailbox_append(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox for appending.
Definition: mx.c:206
mutt_buffer_is_empty
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
Mailbox::notify
struct Notify * notify
Notifications handler.
Definition: mailbox.h:144
mx_mbox_find_by_name
static struct Mailbox * mx_mbox_find_by_name(const char *name)
Find a Mailbox with given name.
Definition: mx.c:1725
MxOpenReturns
MxOpenReturns
Return values for mbox_open()
Definition: mx.h:84
MxOps::msg_close
int(* msg_close)(struct Mailbox *m, struct Message *msg)
Close an email.
Definition: mx.h:264
Context::vsize
off_t vsize
Size (in bytes) of the messages shown.
Definition: context.h:40
MxOps
The Mailbox API.
Definition: mx.h:116
Context::notify
struct Notify * notify
Notifications handler.
Definition: context.h:51
TAILQ_EMPTY
#define TAILQ_EMPTY(head)
Definition: queue.h:714
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
MUTT_YES
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
Definition: quad.h:40
mx_ac_find
struct Account * mx_ac_find(struct Mailbox *m)
Find the Account owning a Mailbox.
Definition: mx.c:1568
MUTT_NEWFOLDER
#define MUTT_NEWFOLDER
Create a new folder - same as MUTT_APPEND,.
Definition: mx.h:56
Context
The "current" mailbox.
Definition: context.h:38
NT_MAILBOX_UNTAG
@ NT_MAILBOX_UNTAG
Clear the 'last-tagged' pointer.
Definition: mailbox.h:177
Message::received
time_t received
the time at which this message was received
Definition: mx.h:107
LL_DEBUG1
@ LL_DEBUG1
Log at debug level 1.
Definition: logging.h:40
Mailbox::flags
uint8_t flags
e.g. MB_NORMAL
Definition: mailbox.h:134
Mailbox::size
off_t size
Size of the Mailbox.
Definition: mailbox.h:87
Mailbox::has_new
bool has_new
Mailbox has new mail.
Definition: mailbox.h:88
SAVE_MOVE
@ SAVE_MOVE
Move message to another mailbox, removing the original.
Definition: commands.h:62
FREE
#define FREE(x)
Definition: memory.h:40
mutt_perror
#define mutt_perror(...)
Definition: logging.h:85
MX_OPEN_OK
@ MX_OPEN_OK
Open succeeded.
Definition: mx.h:86
MxOps::ac_add
bool(* ac_add)(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account.
Definition: mx.h:146
mutt_path_canon
bool mutt_path_canon(char *buf, size_t buflen, const char *homedir, bool is_dir)
Create the canonical version of a path.
Definition: path.c:285
MUTT_MAILBOX_ERROR
@ MUTT_MAILBOX_ERROR
Error occurred examining Mailbox.
Definition: mailbox.h:46
mx_mbox_find
struct Mailbox * mx_mbox_find(struct Account *a, const char *path)
Find a Mailbox on an Account.
Definition: mx.c:1592
PATH_MAX
#define PATH_MAX
Definition: mutt.h:44
MailboxNode::mailbox
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:154
imap_copy_messages
int imap_copy_messages(struct Mailbox *m, struct EmailList *el, const char *dest, enum MessageSaveOpt save_opt)
Server COPY messages to another folder.
Definition: message.c:1623
MUTT_ABORT
@ MUTT_ABORT
User aborted the question (with Ctrl-G)
Definition: quad.h:38
mx_get_ops
const struct MxOps * mx_get_ops(enum MailboxType type)
Get mailbox operations.
Definition: mx.c:147
mutt_sleep
void mutt_sleep(short s)
Sleep for a while.
Definition: muttlib.c:1448
mutt_buffer_pool_release
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
STAILQ_EMPTY
#define STAILQ_EMPTY(head)
Definition: queue.h:345
Username
WHERE char * Username
User's login name.
Definition: mutt_globals.h:52
mailbox_free
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
Definition: mailbox.c:71
mx_path_probe
enum MailboxType mx_path_probe(const char *path)
Find a mailbox that understands a path.
Definition: mx.c:1335
email_new
struct Email * email_new(void)
Create a new Email.
Definition: email.c:72
url_parse
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:234
mx_path_resolve
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
Definition: mx.c:1681
STAILQ_FOREACH
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:349
Mailbox::label_hash
struct HashTable * label_hash
Hash Table for x-labels.
Definition: mailbox.h:129
MxOps::path_pretty
int(* path_pretty)(char *buf, size_t buflen, const char *folder)
Abbreviate a Mailbox path.
Definition: mx.h:354
Mailbox::vcount
int vcount
The number of virtual messages.
Definition: mailbox.h:102
MX_STATUS_REOPENED
@ MX_STATUS_REOPENED
Mailbox was reopened.
Definition: mx.h:77
notify_send
bool notify_send(struct Notify *notify, enum NotifyType event_type, int event_subtype, void *event_data)
Send out a notification message.
Definition: notify.c:152
OptNeedRescore
WHERE bool OptNeedRescore
(pseudo) set when the 'score' command is used
Definition: options.h:42
Context::msg_in_pager
int msg_in_pager
Message currently shown in the pager.
Definition: context.h:44
Context::threads
struct ThreadsContext * threads
Threads context.
Definition: context.h:43
mutt_istr_equal
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
ctx_new
struct Context * ctx_new(struct Mailbox *m)
Create a new Context.
Definition: context.c:76
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
MX_STATUS_NEW_MAIL
@ MX_STATUS_NEW_MAIL
New mail received in Mailbox.
Definition: mx.h:75
C_KeepFlagged
bool C_KeepFlagged
Config: Don't move flagged messages from $spool_file to $mbox
Definition: mx.c:89
mutt_sort_headers
void mutt_sort_headers(struct Mailbox *m, struct ThreadsContext *threads, bool init, off_t *vsize)
Sort emails by their headers.
Definition: sort.c:367
imap_access
int imap_access(const char *path)
Check permissions on an IMAP mailbox with a new connection.
Definition: imap.c:473
MB_HIDDEN
#define MB_HIDDEN
Definition: mailbox.h:38
Mailbox::dontwrite
bool dontwrite
Don't write the mailbox on close.
Definition: mailbox.h:115
Email::old
bool old
Email is seen, but unread.
Definition: email.h:50
Email::received
time_t received
Time when the message was placed in the mailbox.
Definition: email.h:83
MUTT_PURGE
@ MUTT_PURGE
Messages to be purged (bypass trash)
Definition: mutt.h:100
TAILQ_FIRST
#define TAILQ_FIRST(head)
Definition: queue.h:716
NT_MAILBOX
@ NT_MAILBOX
Mailbox has changed, NotifyMailbox, EventMailbox.
Definition: notify_type.h:42
query_quadoption
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: curs_lib.c:518
mutt_buffer_pool_get
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
MUTT_NNTP
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition: mailbox.h:52
MxOps::mbox_close
enum MxStatus(* mbox_close)(struct Mailbox *m)
Close a Mailbox.
Definition: mx.h:209
Mailbox::type
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
Mailbox::mdata
void * mdata
Driver specific data.
Definition: mailbox.h:136
NT_MAILBOX_UPDATE
@ NT_MAILBOX_UPDATE
Update internal tables.
Definition: mailbox.h:176
km_find_func
struct Keymap * km_find_func(enum MenuType menu, int func)
Find a function's mapping in a Menu.
Definition: keymap.c:939
Account
A group of associated Mailboxes.
Definition: account.h:36
C_Folder
WHERE char * C_Folder
Config: Base folder for a set of mailboxes.
Definition: mutt_globals.h:96
OptForceRefresh
WHERE bool OptForceRefresh
(pseudo) refresh even during macros
Definition: options.h:37
Email::tagged
bool tagged
Email is tagged.
Definition: email.h:44
Message::write
bool write
nonzero if message is open for writing
Definition: mx.h:99
MxOps::msg_commit
int(* msg_commit)(struct Mailbox *m, struct Message *msg)
Save changes to an email.
Definition: mx.h:251
mx_mbox_close
enum MxStatus mx_mbox_close(struct Context **ptr)
Save changes and close mailbox.
Definition: mx.c:632
Mailbox::changed
bool changed
Mailbox has been modified.
Definition: mailbox.h:114
Url
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:67
MUTT_CM_NO_FLAGS
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
Mailbox::account
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:131
Message::draft
bool draft
Definition: mx.h:105
Account::mailboxes
struct MailboxList mailboxes
List of Mailboxes.
Definition: account.h:41
mutt_date_localtime
struct tm mutt_date_localtime(time_t t)
Converts calendar time to a broken-down time structure expressed in user timezone.
Definition: date.c:643
url_free
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:123
Mailbox::msg_count
int msg_count
Total number of messages.
Definition: mailbox.h:91
Message::read
bool read
Definition: mx.h:102
LastFolder
WHERE char * LastFolder
Previously selected mailbox.
Definition: mutt_globals.h:55
MxOps::msg_open
bool(* msg_open)(struct Mailbox *m, struct Message *msg, int msgno)
Open an email message in a Mailbox.
Definition: mx.h:224
mutt_clear_error
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
Definition: mutt_logging.c:113
MUTT_UNKNOWN
@ MUTT_UNKNOWN
Mailbox wasn't recognised.
Definition: mailbox.h:47
MAX
#define MAX(a, b)
Definition: memory.h:30
imap_mxcmp
int imap_mxcmp(const char *mx1, const char *mx2)
Compare mailbox names, giving priority to INBOX.
Definition: util.c:554
km_expand_key
int km_expand_key(char *s, size_t len, struct Keymap *map)
Get the key string bound to a Keymap.
Definition: keymap.c:911
MUTT_IMAP
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:53
mutt_default_save
void mutt_default_save(char *path, size_t pathlen, struct Email *e)
Find the default save path for an email.
Definition: hook.c:655
Envelope::to
struct AddressList to
Email's 'To' list.
Definition: envelope.h:58
MUTT_NOSORT
#define MUTT_NOSORT
Do not sort the mailbox after opening it.
Definition: mx.h:52
C_Trash
char * C_Trash
Config: Folder to put deleted emails.
Definition: mx.c:92
mutt_exit
void mutt_exit(int code)
Leave NeoMutt NOW.
Definition: main.c:140
Context::mailbox
struct Mailbox * mailbox
Definition: context.h:50
MxOps::tags_commit
int(* tags_commit)(struct Mailbox *m, struct Email *e, char *buf)
Save the tags to a message.
Definition: mx.h:318
NT_CONTEXT_OPEN
@ NT_CONTEXT_OPEN
The Context has been opened.
Definition: context.h:61
mutt_mem_realloc
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
emaillist_add_email
int emaillist_add_email(struct EmailList *el, struct Email *e)
Add an Email to a list.
Definition: email.c:151
MUTT_MH
@ MUTT_MH
'MH' Mailbox type
Definition: mailbox.h:50
Email::env
struct Envelope * env
Envelope information.
Definition: email.h:90
mutt_debug
#define mutt_debug(LEVEL,...)
Definition: logging.h:81
Mailbox::email_max
int email_max
Number of pointers in emails.
Definition: mailbox.h:100
MUTT_NO
@ MUTT_NO
User answered 'No', or assume 'No'.
Definition: quad.h:39
Email::purge
bool purge
Skip trash folder when deleting.
Definition: email.h:46
Context::collapsed
bool collapsed
Are all threads collapsed?
Definition: context.h:48
MUTT_ADD_FROM
#define MUTT_ADD_FROM
add a From_ line
Definition: mx.h:65
notify_observer_add
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:169
ctx_update
void ctx_update(struct Context *ctx)
Update the Context's message counts.
Definition: context.c:112
Message::replied
bool replied
Definition: mx.h:104
mailbox_new
struct Mailbox * mailbox_new(void)
Create a new Mailbox.
Definition: mailbox.c:52
Mailbox::msg_flagged
int msg_flagged
Number of flagged messages.
Definition: mailbox.h:93
Mailbox::realpath
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:84
mutt_buffer_expand_path
void mutt_buffer_expand_path(struct Buffer *buf)
Create the canonical path.
Definition: muttlib.c:323
Message::fp
FILE * fp
pointer to the message data
Definition: mx.h:96
MX_STATUS_ERROR
@ MX_STATUS_ERROR
An error occurred.
Definition: mx.h:73
MUTT_QUIET
#define MUTT_QUIET
Do not print any messages.
Definition: mx.h:55
Email::flagged
bool flagged
Marked important?
Definition: email.h:43
mutt_append_message
int mutt_append_message(struct Mailbox *dest, struct Mailbox *src, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags)
Append a message.
Definition: copy.c:905
mutt_str_len
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:631
mutt_find_hook
char * mutt_find_hook(HookFlags type, const char *pat)
Find a matching hook.
Definition: hook.c:553
Url::user
char * user
Username.
Definition: url.h:70
mutt_buffer_string
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
Mailbox::opened
int opened
Number of times mailbox is opened.
Definition: mailbox.h:132
Mailbox::verbose
bool verbose
Display status messages?
Definition: mailbox.h:118
account_new
struct Account * account_new(const char *name, struct ConfigSubset *sub)
Create a new Account.
Definition: account.c:43
mutt_env_new
struct Envelope * mutt_env_new(void)
Create a new Envelope.
Definition: envelope.c:42
mutt_date_epoch
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:416
mx_path_canon2
int mx_path_canon2(struct Mailbox *m, const char *folder)
Canonicalise the path to realpath.
Definition: mx.c:1482
mutt_str_replace
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
MUTT_OLD
@ MUTT_OLD
Old messages.
Definition: mutt.h:94
C_Record
WHERE char * C_Record
Config: Folder to save 'sent' messages.
Definition: mutt_globals.h:98
Address::mailbox
char * mailbox
Mailbox and host address.
Definition: address.h:37
neomutt_account_remove
bool neomutt_account_remove(struct NeoMutt *n, struct Account *a)
Remove an Account from the global list.
Definition: neomutt.c:105
Message::flagged
bool flagged
Definition: mx.h:103
Email::deleted
bool deleted
Email is deleted.
Definition: email.h:45
STAILQ_HEAD_INITIALIZER
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:321
Mailbox::readonly
bool readonly
Don't allow changes to the mailbox.
Definition: mailbox.h:119
Envelope::from
struct AddressList from
Email's 'From' list.
Definition: envelope.h:57
MUTT_DELETE
@ MUTT_DELETE
Messages to be deleted.
Definition: mutt.h:98
HomeDir
char * HomeDir
User's home directory.
Definition: mutt_globals.h:49
C_MailCheckRecent
WHERE bool C_MailCheckRecent
Config: Notify the user about new mail since the last time the mailbox was opened.
Definition: mutt_globals.h:150
MMDF_SEP
#define MMDF_SEP
Definition: lib.h:64
alias_lookup
struct AddressList * alias_lookup(const char *name)
Find an Alias.
Definition: alias.c:276
MxOps::path_canon
int(* path_canon)(char *buf, size_t buflen)
Canonicalise a Mailbox path.
Definition: mx.h:341
MENU_MAIN
@ MENU_MAIN
Index panel (list of emails)
Definition: keymap.h:80
C_SpoolFile
WHERE char * C_SpoolFile
Config: Inbox.
Definition: mutt_globals.h:108
NeoMutt
Container for Accounts, Notifications.
Definition: neomutt.h:36
account_mailbox_add
bool account_mailbox_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account.
Definition: account.c:66
C_Delete
WHERE unsigned char C_Delete
Config: Really delete messages, when the mailbox is closed.
Definition: mutt_globals.h:125
OptSortSubthreads
WHERE bool OptSortSubthreads
(pseudo) used when $sort_aux changes
Definition: options.h:54
mx_mbox_open
struct Context * mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
Definition: mx.c:309
NT_CONTEXT
@ NT_CONTEXT
Context has changed, NotifyContext, EventContext.
Definition: notify_type.h:38
mutt_is_spool
static bool mutt_is_spool(const char *str)
Is this the spool_file?
Definition: mx.c:161
C_Mbox
WHERE char * C_Mbox
Config: Folder that receives read emails (see Move)
Definition: mutt_globals.h:94
Url::host
char * host
Host.
Definition: url.h:72
mailbox_changed
void mailbox_changed(struct Mailbox *m, enum NotifyMailbox action)
Notify observers of a change to a Mailbox.
Definition: mailbox.c:186
imap_path_probe
enum MailboxType imap_path_probe(const char *path, const struct stat *st)
Is this an IMAP Mailbox? - Implements MxOps::path_probe()
Definition: imap.c:2372
C_MaildirTrash
bool C_MaildirTrash
Config: Use the maildir 'trashed' flag, rather than deleting.
Definition: config.c:42
MX_OPEN_ABORT
@ MX_OPEN_ABORT
Open was aborted.
Definition: mx.h:88
MailboxType
MailboxType
Supported mailbox formats.
Definition: mailbox.h:43
MxOps::ac_owns_path
bool(* ac_owns_path)(struct Account *a, const char *path)
Check whether an Account owns a Mailbox path.
Definition: mx.h:133
C_MarkOld
bool C_MarkOld
Config: Mark new emails as old when leaving the mailbox.
Definition: globals.c:36
sync_mailbox
static enum MxStatus sync_mailbox(struct Mailbox *m)
save changes to disk
Definition: mx.c:488
mx_ac_add
bool mx_ac_add(struct Account *a, struct Mailbox *m)
Add a Mailbox to an Account - Wrapper for MxOps::ac_add()
Definition: mx.c:1768
NeoMutt::sub
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
CurrentFolder
WHERE char * CurrentFolder
Currently selected mailbox.
Definition: mutt_globals.h:54
MxOps::path_is_empty
int(* path_is_empty)(const char *path)
Is the Mailbox empty?
Definition: mx.h:378
email_free
void email_free(struct Email **ptr)
Free an Email.
Definition: email.c:43
Mailbox::msg_unread
int msg_unread
Number of unread messages.
Definition: mailbox.h:92
Mailbox::msg_tagged
int msg_tagged
How many messages are tagged?
Definition: mailbox.h:97
Envelope::return_path
struct AddressList return_path
Return path for the Email.
Definition: envelope.h:56
MUTT_MAILDIR
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition: mailbox.h:51
Url::path
char * path
Path.
Definition: url.h:74
neomutt_account_add
bool neomutt_account_add(struct NeoMutt *n, struct Account *a)
Add an Account to the global list.
Definition: neomutt.c:84
imap_sync_mailbox
enum MxStatus imap_sync_mailbox(struct Mailbox *m, bool expunge, bool close)
Sync all the changes to the server.
Definition: imap.c:1514
MX_STATUS_FLAGS
@ MX_STATUS_FLAGS
Nondestructive flags change (IMAP)
Definition: mx.h:78
MUTT_APPEND
#define MUTT_APPEND
Open mailbox for appending messages.
Definition: mx.h:53
mailbox_path
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:206
mx_fastclose_mailbox
void mx_fastclose_mailbox(struct Mailbox *m)
free up memory associated with the Mailbox
Definition: mx.c:451
account_mailbox_remove
bool account_mailbox_remove(struct Account *a, struct Mailbox *m)
Remove a Mailbox from an Account.
Definition: account.c:94
MUTT_ACL_ALL
#define MUTT_ACL_ALL
Definition: mailbox.h:76
ctx_mailbox_observer
int ctx_mailbox_observer(struct NotifyCallback *nc)
Watch for changes affecting the Context - Implements observer_t.
Definition: context.c:298
Email::replied
bool replied
Email has been replied to.
Definition: email.h:54
Email
The envelope/body of an email.
Definition: email.h:37
mutt_str_inline_replace
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:1013
MUTT_SET_DRAFT
#define MUTT_SET_DRAFT
set the message draft flag
Definition: mx.h:66
mutt_message
#define mutt_message(...)
Definition: logging.h:83
mutt_set_flag
#define mutt_set_flag(m, e, flag, bf)
Definition: protos.h:67
Mailbox::msg_new
int msg_new
Number of new messages.
Definition: mailbox.h:95
mutt_file_unlink_empty
void mutt_file_unlink_empty(const char *path)
Delete a file if it's empty.
Definition: file.c:1311
MX_OPEN_ERROR
@ MX_OPEN_ERROR
Open failed with an error.
Definition: mx.h:87
MxOps::mbox_open
enum MxOpenReturns(* mbox_open)(struct Mailbox *m)
Open a Mailbox.
Definition: mx.h:156
emaillist_clear
void emaillist_clear(struct EmailList *el)
Drop a private list of Emails.
Definition: email.c:130
mutt_buffer_printf
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
trash_append
static int trash_append(struct Mailbox *m)
move deleted mails to the trash folder
Definition: mx.c:519
C_CatchupNewsgroup
unsigned char C_CatchupNewsgroup
Config: (nntp) Mark all articles as read when leaving a newsgroup.
Definition: config.c:37
mutt_addrlist_copy
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:737
mutt_mailbox_set_notified
void mutt_mailbox_set_notified(struct Mailbox *m)
Note when the user was last notified of new mail.
Definition: mutt_mailbox.c:289
C_Move
unsigned char C_Move
Config: Move emails from $spool_file to $mbox when read.
Definition: mx.c:91
mx_mbox_ac_link
bool mx_mbox_ac_link(struct Mailbox *m)
Link a Mailbox to an existing or new Account.
Definition: mx.c:272
NT_MAILBOX_RESORT
@ NT_MAILBOX_RESORT
Email list needs resorting.
Definition: mailbox.h:174
CH_UPDATE_LEN
#define CH_UPDATE_LEN
Update Lines: and Content-Length:
Definition: copy.h:61
mutt_newsgroup_catchup
struct NntpMboxData * mutt_newsgroup_catchup(struct Mailbox *m, struct NntpAccountData *adata, char *group)
Catchup newsgroup.
Definition: newsrc.c:1297
Email::read
bool read
Email is read.
Definition: email.h:51
MUTT_MBOX
@ MUTT_MBOX
'mbox' Mailbox type
Definition: mailbox.h:48
Envelope::sender
struct AddressList sender
Email's sender.
Definition: envelope.h:61
mutt_make_label_hash
void mutt_make_label_hash(struct Mailbox *m)
Create a Hash Table to store the labels.
Definition: mutt_header.c:368
C_MboxType
unsigned char C_MboxType
Config: Default type for creating new mailboxes.
Definition: mx.c:90
mutt_buffer_strcpy
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
Mailbox::id_hash
struct HashTable * id_hash
Hash Table by msg id.
Definition: mailbox.h:127
Mailbox::peekonly
bool peekonly
Just taking a glance, revert atime.
Definition: mailbox.h:117
mutt_hash_free
void mutt_hash_free(struct HashTable **ptr)
Free a hash table.
Definition: hash.c:447
Mailbox::pathbuf
struct Buffer pathbuf
Definition: mailbox.h:83
Address
An email address.
Definition: address.h:34
NntpMboxData
NNTP-specific Mailbox data -.
Definition: mdata.h:31
Message
A local copy of an email.
Definition: mx.h:94
mx_mbox_find2
struct Mailbox * mx_mbox_find2(const char *path)
Find a Mailbox on an Account.
Definition: mx.c:1654
MxOps::mbox_check
enum MxStatus(* mbox_check)(struct Mailbox *m)
Check for new mail.
Definition: mx.h:178
MX_STATUS_OK
@ MX_STATUS_OK
No changes.
Definition: mx.h:74
mutt_error
#define mutt_error(...)
Definition: logging.h:84
mutt_str_copy
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:716