NeoMutt  2021-02-05-666-ge300cd
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 }
struct ImapCommand * cmds
Definition: adata.h:69
enum MailboxType type
Mailbox type.
Definition: mailbox.h:105
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:50
A group of associated Mailboxes.
Definition: account.h:36
char * capstr
Definition: adata.h:54
struct ImapAccountData * imap_adata_new(struct Account *a)
Allocate and initialise a new ImapAccountData structure.
Definition: adata.c:66
Imap-specific Account data.
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
Container for Accounts, Notifications.
Definition: neomutt.h:36
Convenience wrapper for the config headers.
unsigned char seqid
tag sequence prefix
Definition: adata.h:56
struct Buffer cmdbuf
Definition: adata.h:73
Convenience wrapper for the core headers.
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
Shared constants/structs that are private to IMAP.
int(* close)(struct Connection *conn)
Definition: connection.h:119
struct Account * account
Parent Account.
Definition: adata.h:78
void imap_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free()
Definition: adata.c:40
A mailbox.
Definition: mailbox.h:81
void * adata
Private data (for Mailbox backends)
Definition: account.h:43
int cmdslots
Definition: adata.h:70
struct ImapAccountData * imap_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: adata.c:90
IMAP-specific Account data -.
Definition: adata.h:39
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:131
char * buf
Definition: adata.h:59
Connection Library.
#define FREE(x)
Definition: memory.h:40
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
Convenience wrapper for the library headers.
'IMAP' Mailbox type
Definition: mailbox.h:53
struct Connection * conn
Definition: adata.h:41