NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
ac_add()

Add a Mailbox to an Account. More...

+ Collaboration diagram for ac_add():

Functions

static bool comp_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to an Account - Implements MxOps::ac_add() -. More...
 
static bool imap_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to an Account - Implements MxOps::ac_add() -. More...
 
bool maildir_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to an Account - Implements MxOps::ac_add() -. More...
 
bool mh_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to an Account - Implements MxOps::ac_add() -. More...
 
static bool mbox_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to an Account - Implements MxOps::ac_add() -. More...
 
static bool nntp_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to an Account - Implements MxOps::ac_add() -. More...
 
static bool nm_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to an Account - Implements MxOps::ac_add() -. More...
 
static bool pop_ac_add (struct Account *a, struct Mailbox *m)
 Add a Mailbox to an Account - Implements MxOps::ac_add() -. More...
 

Detailed Description

Add a Mailbox to an Account.

Parameters
aAccount to add to
mMailbox to add
Return values
trueSuccess
falseError

Contract

Function Documentation

◆ comp_ac_add()

static bool comp_ac_add ( struct Account a,
struct Mailbox m 
)
static

Add a Mailbox to an Account - Implements MxOps::ac_add() -.

Definition at line 427 of file compress.c.

428 {
429  return true;
430 }

◆ imap_ac_add()

static bool imap_ac_add ( struct Account a,
struct Mailbox m 
)
static

Add a Mailbox to an Account - Implements MxOps::ac_add() -.

Definition at line 1762 of file imap.c.

1763 {
1764  struct ImapAccountData *adata = a->adata;
1765 
1766  if (!adata)
1767  {
1768  struct ConnAccount cac = { { 0 } };
1769  char mailbox[PATH_MAX];
1770 
1771  if (imap_parse_path(mailbox_path(m), &cac, mailbox, sizeof(mailbox)) < 0)
1772  return false;
1773 
1774  adata = imap_adata_new(a);
1775  adata->conn = mutt_conn_new(&cac);
1776  if (!adata->conn)
1777  {
1778  imap_adata_free((void **) &adata);
1779  return false;
1780  }
1781 
1783 
1784  if (imap_login(adata) < 0)
1785  {
1786  imap_adata_free((void **) &adata);
1787  return false;
1788  }
1789 
1790  a->adata = adata;
1792  }
1793 
1794  if (!m->mdata)
1795  {
1796  struct Url *url = url_parse(mailbox_path(m));
1797  struct ImapMboxData *mdata = imap_mdata_new(adata, url->path);
1798 
1799  /* fixup path and realpath, mainly to replace / by /INBOX */
1800  char buf[1024];
1801  imap_qualify_path(buf, sizeof(buf), &adata->conn->account, mdata->name);
1802  mutt_buffer_strcpy(&m->pathbuf, buf);
1804 
1805  m->mdata = mdata;
1807  url_free(&url);
1808  }
1809  return true;
1810 }
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:215
void imap_qualify_path(char *buf, size_t buflen, struct ConnAccount *conn_account, char *path)
Make an absolute IMAP folder target.
Definition: util.c:823
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:40
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:68
int imap_login(struct ImapAccountData *adata)
Open an IMAP connection.
Definition: imap.c:1849
int imap_parse_path(const char *path, struct ConnAccount *cac, char *mailbox, size_t mailboxlen)
Parse an IMAP mailbox name into ConnAccount, name.
Definition: util.c:483
void imap_mdata_free(void **ptr)
Free the private Mailbox data - Implements Mailbox::mdata_free()
Definition: mdata.c:40
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:84
struct ImapAccountData * imap_adata_new(struct Account *a)
Allocate and initialise a new ImapAccountData structure.
Definition: adata.c:66
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:123
struct ImapMboxData * imap_mdata_new(struct ImapAccountData *adata, const char *name)
Allocate and initialise a new ImapMboxData structure.
Definition: mdata.c:72
void(* mdata_free)(void **ptr)
Free the private data attached to the Mailbox.
Definition: mailbox.h:146
void(* adata_free)(void **ptr)
Free the private data attached to the Account.
Definition: account.h:53
void * mdata
Driver specific data.
Definition: mailbox.h:136
struct Connection * mutt_conn_new(const struct ConnAccount *cac)
Create a new Connection.
Definition: mutt_socket.c:48
void imap_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free()
Definition: adata.c:40
void mutt_account_hook(const char *url)
Perform an account hook.
Definition: hook.c:782
#define PATH_MAX
Definition: mutt.h:40
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
char * name
Mailbox name.
Definition: mdata.h:40
Login details for a remote server.
Definition: connaccount.h:51
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:312
char * path
Path.
Definition: url.h:75
IMAP-specific Account data -.
Definition: adata.h:39
IMAP-specific Mailbox data -.
Definition: mdata.h:38
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
struct Buffer pathbuf
Definition: mailbox.h:83
struct Connection * conn
Definition: adata.h:41
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:234
+ Here is the call graph for this function:

◆ maildir_ac_add()

bool maildir_ac_add ( struct Account a,
struct Mailbox m 
)

Add a Mailbox to an Account - Implements MxOps::ac_add() -.

Definition at line 1084 of file maildir.c.

1085 {
1086  return true;
1087 }

◆ mh_ac_add()

bool mh_ac_add ( struct Account a,
struct Mailbox m 
)

Add a Mailbox to an Account - Implements MxOps::ac_add() -.

Definition at line 834 of file mh.c.

835 {
836  return true;
837 }

◆ mbox_ac_add()

static bool mbox_ac_add ( struct Account a,
struct Mailbox m 
)
static

Add a Mailbox to an Account - Implements MxOps::ac_add() -.

Definition at line 887 of file mbox.c.

888 {
889  return true;
890 }

◆ nntp_ac_add()

static bool nntp_ac_add ( struct Account a,
struct Mailbox m 
)
static

Add a Mailbox to an Account - Implements MxOps::ac_add() -.

Definition at line 2299 of file nntp.c.

2300 {
2301  return true;
2302 }

◆ nm_ac_add()

static bool nm_ac_add ( struct Account a,
struct Mailbox m 
)
static

Add a Mailbox to an Account - Implements MxOps::ac_add() -.

Definition at line 2029 of file notmuch.c.

2030 {
2031  if (a->adata)
2032  return true;
2033 
2034  struct NmAccountData *adata = nm_adata_new();
2035  a->adata = adata;
2037 
2038  return true;
2039 }
struct NmAccountData * nm_adata_new(void)
Allocate and initialise a new NmAccountData structure.
Definition: adata.c:55
void(* adata_free)(void **ptr)
Free the private data attached to the Account.
Definition: account.h:53
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
void nm_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free()
Definition: adata.c:39
Notmuch-specific Account data -.
Definition: adata.h:34
+ Here is the call graph for this function:

◆ pop_ac_add()

static bool pop_ac_add ( struct Account a,
struct Mailbox m 
)
static

Add a Mailbox to an Account - Implements MxOps::ac_add() -.

Definition at line 717 of file pop.c.

718 {
719  if (a->adata)
720  return true;
721 
722  struct ConnAccount cac = { { 0 } };
723  struct PopAccountData *adata = pop_adata_new();
724  a->adata = adata;
726 
727  if (pop_parse_path(mailbox_path(m), &cac))
728  {
729  mutt_error(_("%s is an invalid POP path"), mailbox_path(m));
730  return false;
731  }
732 
733  adata->conn = mutt_conn_new(&cac);
734  if (!adata->conn)
735  {
736  pop_adata_free((void **) &adata);
737  return false;
738  }
739 
740  return true;
741 }
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox&#39;s path string.
Definition: mailbox.h:215
int pop_parse_path(const char *path, struct ConnAccount *cac)
Parse a POP mailbox name.
Definition: lib.c:83
#define mutt_error(...)
Definition: logging.h:88
#define _(a)
Definition: message.h:28
struct Connection * conn
Definition: adata.h:38
struct PopAccountData * pop_adata_new(void)
Create a new PopAccountData object.
Definition: adata.c:54
void(* adata_free)(void **ptr)
Free the private data attached to the Account.
Definition: account.h:53
struct Connection * mutt_conn_new(const struct ConnAccount *cac)
Create a new Connection.
Definition: mutt_socket.c:48
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
void pop_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free()
Definition: adata.c:40
Login details for a remote server.
Definition: connaccount.h:51
POP-specific Account data -.
Definition: adata.h:36
+ Here is the call graph for this function: