NeoMutt  2024-10-02-37-gfa9146
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
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#include "lib.h"
37
44{
45 if (nc->event_type != NT_TIMEOUT)
46 return 0;
47 if (!nc->global_data)
48 return -1;
49
50 struct ImapAccountData *adata = nc->global_data;
51 mutt_debug(LL_DEBUG5, "imap timeout start\n");
52
53 time_t now = mutt_date_now();
54 const short c_imap_keep_alive = cs_subset_number(NeoMutt->sub, "imap_keep_alive");
55
56 if ((adata->state >= IMAP_AUTHENTICATED) && (now >= (adata->lastread + c_imap_keep_alive)))
57 {
58 mutt_debug(LL_DEBUG5, "imap_keep_alive\n");
59 imap_check_mailbox(adata->mailbox, true);
60 }
61
62 mutt_debug(LL_DEBUG5, "imap timeout done\n");
63 return 0;
64}
65
69void imap_adata_free(void **ptr)
70{
71 if (!ptr || !*ptr)
72 return;
73
74 struct ImapAccountData *adata = *ptr;
75
77
78 FREE(&adata->capstr);
79 buf_dealloc(&adata->cmdbuf);
80 FREE(&adata->buf);
81 FREE(&adata->cmds);
82
83 if (adata->conn)
84 {
85 if (adata->conn->close)
86 adata->conn->close(adata->conn);
87 FREE(&adata->conn);
88 }
89
90 FREE(ptr);
91}
92
99{
100 struct ImapAccountData *adata = mutt_mem_calloc(1, sizeof(struct ImapAccountData));
101 adata->account = a;
102
103 static unsigned char new_seqid = 'a';
104
105 adata->seqid = new_seqid;
106 const short c_imap_pipeline_depth = cs_subset_number(NeoMutt->sub, "imap_pipeline_depth");
107 adata->cmdslots = c_imap_pipeline_depth + 2;
108 adata->cmds = mutt_mem_calloc(adata->cmdslots, sizeof(*adata->cmds));
109
110 if (++new_seqid > 'z')
111 new_seqid = 'a';
112
114
115 return adata;
116}
117
124{
125 if (!m || (m->type != MUTT_IMAP) || !m->account)
126 return NULL;
127 return m->account->adata;
128}
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:377
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:143
Convenience wrapper for the config headers.
Connection Library.
Convenience wrapper for the core headers.
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:50
void imap_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free() -.
Definition: adata.c:69
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
static int imap_timeout_observer(struct NotifyCallback *nc)
Notification that a timeout has occurred - Implements observer_t -.
Definition: adata.c:43
struct ImapAccountData * imap_adata_new(struct Account *a)
Allocate and initialise a new ImapAccountData structure.
Definition: adata.c:98
struct ImapAccountData * imap_adata_get(struct Mailbox *m)
Get the Account data for this mailbox.
Definition: adata.c:123
@ IMAP_AUTHENTICATED
Connection is authenticated.
Definition: private.h:107
enum MxStatus imap_check_mailbox(struct Mailbox *m, bool force)
Use the NOOP or IDLE command to poll for new mail.
Definition: imap.c:1032
@ LL_DEBUG5
Log at debug level 5.
Definition: logging2.h:47
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
Definition: memory.c:51
#define FREE(x)
Definition: memory.h:45
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:456
Convenience wrapper for the library headers.
bool notify_observer_remove(struct Notify *notify, const observer_t callback, const void *global_data)
Remove an observer from an object.
Definition: notify.c:230
bool notify_observer_add(struct Notify *notify, enum NotifyType type, observer_t callback, void *global_data)
Add an observer to an object.
Definition: notify.c:191
@ NT_TIMEOUT
Timeout has occurred.
Definition: notify_type.h:56
Pop-specific Account data.
GUI display the mailboxes in a side panel.
Key value store.
A group of associated Mailboxes.
Definition: account.h:36
void * adata
Private data (for Mailbox backends)
Definition: account.h:42
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:42
struct Notify * notify_timeout
Timeout notifications handler.
Definition: neomutt.h:45
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:46
Data passed to a notification function.
Definition: observer.h:34
enum NotifyType event_type
Send: Event type, e.g. NT_ACCOUNT.
Definition: observer.h:36
void * global_data
Data from notify_observer_add()
Definition: observer.h:39