NeoMutt  2023-03-22-27-g3cb248
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
40void 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 = cs_subset_number(NeoMutt->sub, "imap_pipeline_depth");
75 adata->cmdslots = c_imap_pipeline_depth + 2;
76 adata->cmds = mutt_mem_calloc(adata->cmdslots, sizeof(*adata->cmds));
77
78 if (++new_seqid > 'z')
79 new_seqid = 'a';
80
81 return adata;
82}
83
90{
91 if (!m || (m->type != MUTT_IMAP) || !m->account)
92 return NULL;
93 return m->account->adata;
94}
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:347
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
Convenience wrapper for the config headers.
Connection Library.
Convenience wrapper for the core headers.
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
struct ImapAccountData * imap_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: adata.c:89
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:50
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:43
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:79
enum MailboxType type
Mailbox type.
Definition: mailbox.h:102
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:127
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39