NeoMutt  2021-10-29-220-g2b1eec
Teaching an old dog new tricks
DOXYGEN
adata.c
Go to the documentation of this file.
1 
29 #include "config.h"
30 #include "private.h"
31 #include "mutt/lib.h"
32 #include "config/lib.h"
33 #include "core/lib.h"
34 #include "conn/lib.h"
35 #include "adata.h"
36 
40 void imap_adata_free(void **ptr)
41 {
42  if (!ptr || !*ptr)
43  return;
44 
45  struct ImapAccountData *adata = *ptr;
46 
47  FREE(&adata->capstr);
48  mutt_buffer_dealloc(&adata->cmdbuf);
49  FREE(&adata->buf);
50  FREE(&adata->cmds);
51 
52  if (adata->conn)
53  {
54  if (adata->conn->close)
55  adata->conn->close(adata->conn);
56  FREE(&adata->conn);
57  }
58 
59  FREE(ptr);
60 }
61 
67 {
68  struct ImapAccountData *adata = mutt_mem_calloc(1, sizeof(struct ImapAccountData));
69  adata->account = a;
70 
71  static unsigned char new_seqid = 'a';
72 
73  adata->seqid = new_seqid;
74  const short c_imap_pipeline_depth =
75  cs_subset_number(NeoMutt->sub, "imap_pipeline_depth");
76  adata->cmdslots = c_imap_pipeline_depth + 2;
77  adata->cmds = mutt_mem_calloc(adata->cmdslots, sizeof(*adata->cmds));
78 
79  if (++new_seqid > 'z')
80  new_seqid = 'a';
81 
82  return adata;
83 }
84 
91 {
92  if (!m || (m->type != MUTT_IMAP) || !m->account)
93  return NULL;
94  return m->account->adata;
95 }
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
Convenience wrapper for the config headers.
Connection Library.
Convenience wrapper for the core headers.
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
struct ImapAccountData * imap_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: adata.c:90
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
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:53
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
#define FREE(x)
Definition: memory.h:40
Convenience wrapper for the library headers.
Pop-specific Account data.
GUI display the mailboxes in a side panel.
A group of associated Mailboxes.
Definition: account.h:37
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
IMAP-specific Account data -.
Definition: adata.h:40
A mailbox.
Definition: mailbox.h:82
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:131
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39