NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
mdata.c
Go to the documentation of this file.
1
29#include "config.h"
30#include "private.h"
31#include "core/lib.h"
32#include "mdata.h"
33#include "hcache/lib.h"
34#include "adata.h"
35
39void imap_mdata_free(void **ptr)
40{
41 if (!ptr || !*ptr)
42 return;
43
44 struct ImapMboxData *mdata = *ptr;
45
47 mutt_list_free(&mdata->flags);
48 FREE(&mdata->name);
49 FREE(&mdata->real_name);
50 FREE(&mdata->munge_name);
51
52 FREE(ptr);
53}
54
61{
62 if (!m || (m->type != MUTT_IMAP) || !m->mdata)
63 return NULL;
64 return m->mdata;
65}
66
73struct ImapMboxData *imap_mdata_new(struct ImapAccountData *adata, const char *name)
74{
75 char buf[1024] = { 0 };
76 struct ImapMboxData *mdata = mutt_mem_calloc(1, sizeof(struct ImapMboxData));
77
78 mdata->real_name = mutt_str_dup(name);
79
80 imap_fix_path(adata->delim, name, buf, sizeof(buf));
81 if (buf[0] == '\0')
82 mutt_str_copy(buf, "INBOX", sizeof(buf));
83 mdata->name = mutt_str_dup(buf);
84
85 imap_munge_mbox_name(adata->unicode, buf, sizeof(buf), mdata->name);
86 mdata->munge_name = mutt_str_dup(buf);
87
88 mdata->reopen &= IMAP_REOPEN_ALLOW;
89
90 STAILQ_INIT(&mdata->flags);
91
92#ifdef USE_HCACHE
93 imap_hcache_open(adata, mdata);
94 if (mdata->hcache)
95 {
96 if (hcache_fetch_raw_obj(mdata->hcache, "UIDVALIDITY", 11, &mdata->uidvalidity))
97 {
98 hcache_fetch_raw_obj(mdata->hcache, "UIDNEXT", 7, &mdata->uid_next);
99 hcache_fetch_raw_obj(mdata->hcache, "MODSEQ", 6, &mdata->modseq);
100 mutt_debug(LL_DEBUG3, "hcache uidvalidity %u, uidnext %u, modseq %llu\n",
101 mdata->uidvalidity, mdata->uid_next, mdata->modseq);
102 }
104 }
105#endif
106
107 return mdata;
108}
Convenience wrapper for the core headers.
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:50
#define mutt_debug(LEVEL,...)
Definition: logging2.h:89
void imap_mdata_free(void **ptr)
Free the private Mailbox data - Implements Mailbox::mdata_free() -.
Definition: mdata.c:39
Header cache multiplexor.
#define hcache_fetch_raw_obj(hc, key, keylen, dst)
Definition: lib.h:161
struct ImapMboxData * imap_mdata_new(struct ImapAccountData *adata, const char *name)
Allocate and initialise a new ImapMboxData structure.
Definition: mdata.c:73
struct ImapMboxData * imap_mdata_get(struct Mailbox *m)
Get the Mailbox data for this mailbox.
Definition: mdata.c:60
#define IMAP_REOPEN_ALLOW
Allow re-opening a folder upon expunge.
Definition: private.h:64
void imap_mdata_cache_reset(struct ImapMboxData *mdata)
Release and clear cache data of ImapMboxData structure.
Definition: util.c:107
char * imap_fix_path(char delim, const char *mailbox, char *path, size_t plen)
Fix up the imap path.
Definition: util.c:679
void imap_hcache_close(struct ImapMboxData *mdata)
Close the header cache.
Definition: util.c:340
void imap_munge_mbox_name(bool unicode, char *dest, size_t dlen, const char *src)
Quote awkward characters in a mailbox name.
Definition: util.c:921
void imap_hcache_open(struct ImapAccountData *adata, struct ImapMboxData *mdata)
Open a header cache.
Definition: util.c:299
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
@ LL_DEBUG3
Log at debug level 3.
Definition: logging2.h:45
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:45
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:253
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:575
Notmuch-specific Mailbox data.
Pop-specific Account data.
#define STAILQ_INIT(head)
Definition: queue.h:372
GUI display the mailboxes in a side panel.
IMAP-specific Account data -.
Definition: adata.h:40
char delim
Path delimiter.
Definition: adata.h:75
bool unicode
If true, we can send UTF-8, and the server will use UTF8 rather than mUTF7.
Definition: adata.h:62
IMAP-specific Mailbox data -.
Definition: mdata.h:40
char * name
Mailbox name.
Definition: mdata.h:41
A mailbox.
Definition: mailbox.h:79
enum MailboxType type
Mailbox type.
Definition: mailbox.h:102
void * mdata
Driver specific data.
Definition: mailbox.h:132