NeoMutt  2022-04-29-247-gc6aae8
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 430 of file compress.c.

431{
432 return true;
433}

◆ 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 1761 of file imap.c.

1762{
1763 struct ImapAccountData *adata = a->adata;
1764
1765 if (!adata)
1766 {
1767 struct ConnAccount cac = { { 0 } };
1768 char mailbox[PATH_MAX] = { 0 };
1769
1770 if (imap_parse_path(mailbox_path(m), &cac, mailbox, sizeof(mailbox)) < 0)
1771 return false;
1772
1773 adata = imap_adata_new(a);
1774 adata->conn = mutt_conn_new(&cac);
1775 if (!adata->conn)
1776 {
1777 imap_adata_free((void **) &adata);
1778 return false;
1779 }
1780
1782
1783 if (imap_login(adata) < 0)
1784 {
1785 imap_adata_free((void **) &adata);
1786 return false;
1787 }
1788
1789 a->adata = adata;
1791 }
1792
1793 if (!m->mdata)
1794 {
1795 struct Url *url = url_parse(mailbox_path(m));
1796 struct ImapMboxData *mdata = imap_mdata_new(adata, url->path);
1797
1798 /* fixup path and realpath, mainly to replace / by /INBOX */
1799 char buf[1024] = { 0 };
1800 imap_qualify_path(buf, sizeof(buf), &adata->conn->account, mdata->name);
1801 mutt_buffer_strcpy(&m->pathbuf, buf);
1803
1804 m->mdata = mdata;
1806 url_free(&url);
1807 }
1808 return true;
1809}
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:327
void mutt_account_hook(const char *url)
Perform an account hook.
Definition: hook.c:843
void imap_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free()
Definition: adata.c:40
struct ImapAccountData * imap_adata_new(struct Account *a)
Allocate and initialise a new ImapAccountData structure.
Definition: adata.c:66
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:482
struct ImapMboxData * imap_mdata_new(struct ImapAccountData *adata, const char *name)
Allocate and initialise a new ImapMboxData structure.
Definition: mdata.c:73
void imap_mdata_free(void **ptr)
Free the private Mailbox data - Implements Mailbox::mdata_free()
Definition: mdata.c:40
void imap_qualify_path(char *buf, size_t buflen, struct ConnAccount *conn_account, char *path)
Make an absolute IMAP folder target.
Definition: util.c:820
int imap_login(struct ImapAccountData *adata)
Open an IMAP connection.
Definition: imap.c:1848
static const char * mailbox_path(const struct Mailbox *m)
Get the Mailbox's path string.
Definition: mailbox.h:210
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:326
#define PATH_MAX
Definition: mutt.h:40
struct Connection * mutt_conn_new(const struct ConnAccount *cac)
Create a new Connection.
Definition: mutt_socket.c:48
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
Login details for a remote server.
Definition: connaccount.h:53
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:50
IMAP-specific Account data -.
Definition: adata.h:40
struct Connection * conn
Connection to IMAP server.
Definition: adata.h:41
IMAP-specific Mailbox data -.
Definition: mdata.h:39
void(* mdata_free)(void **ptr)
Free the private data attached to the Mailbox.
Definition: mailbox.h:142
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:81
void * mdata
Driver specific data.
Definition: mailbox.h:132
struct Buffer pathbuf
Path of the Mailbox.
Definition: mailbox.h:80
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:69
char * path
Path.
Definition: url.h:75
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:234
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:123
+ 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 1085 of file maildir.c.

1086{
1087 return true;
1088}

◆ 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 841 of file mh.c.

842{
843 return true;
844}

◆ 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 2290 of file nntp.c.

2291{
2292 return true;
2293}

◆ 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 2003 of file notmuch.c.

2004{
2005 if (a->adata)
2006 return true;
2007
2008 struct NmAccountData *adata = nm_adata_new();
2009 a->adata = adata;
2011
2012 return true;
2013}
struct NmAccountData * nm_adata_new(void)
Allocate and initialise a new NmAccountData structure.
Definition: adata.c:55
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:35
+ 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 711 of file pop.c.

712{
713 if (a->adata)
714 return true;
715
716 struct ConnAccount cac = { { 0 } };
718 a->adata = adata;
720
721 if (pop_parse_path(mailbox_path(m), &cac))
722 {
723 mutt_error(_("%s is an invalid POP path"), mailbox_path(m));
724 return false;
725 }
726
727 adata->conn = mutt_conn_new(&cac);
728 if (!adata->conn)
729 {
730 pop_adata_free((void **) &adata);
731 return false;
732 }
733
734 return true;
735}
#define mutt_error(...)
Definition: logging.h:87
#define _(a)
Definition: message.h:28
struct PopAccountData * pop_adata_new(void)
Create a new PopAccountData object.
Definition: adata.c:54
void pop_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free()
Definition: adata.c:40
int pop_parse_path(const char *path, struct ConnAccount *cac)
Parse a POP mailbox name.
Definition: lib.c:82
POP-specific Account data -.
Definition: adata.h:37
+ Here is the call graph for this function: