NeoMutt  2024-11-14-34-g5aaf0d
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 <stdbool.h>
31#include "private.h"
32#include "core/lib.h"
33#include "mdata.h"
34#include "hcache/lib.h"
35#include "adata.h"
36
40void imap_mdata_free(void **ptr)
41{
42 if (!ptr || !*ptr)
43 return;
44
45 struct ImapMboxData *mdata = *ptr;
46
48 mutt_list_free(&mdata->flags);
49 FREE(&mdata->name);
50 FREE(&mdata->real_name);
51 FREE(&mdata->munge_name);
52
53 FREE(ptr);
54}
55
62{
63 if (!m || (m->type != MUTT_IMAP) || !m->mdata)
64 return NULL;
65 return m->mdata;
66}
67
74struct ImapMboxData *imap_mdata_new(struct ImapAccountData *adata, const char *name)
75{
76 char buf[1024] = { 0 };
78
79 imap_fix_path_with_delim(adata->delim, name, buf, sizeof(buf));
80 if (buf[0] == '\0')
81 {
82 mutt_str_copy(buf, "INBOX", sizeof(buf));
83 mdata->real_name = mutt_str_dup(name);
84 }
85 else
86 {
87 mdata->real_name = mutt_str_dup(buf);
88 }
89 mdata->name = mutt_str_dup(buf);
90
91 imap_munge_mbox_name(adata->unicode, buf, sizeof(buf), mdata->name);
92 mdata->munge_name = mutt_str_dup(buf);
93
94 mdata->reopen &= IMAP_REOPEN_ALLOW;
95
96 STAILQ_INIT(&mdata->flags);
97
98#ifdef USE_HCACHE
99 imap_hcache_open(adata, mdata, false);
100 if (mdata->hcache)
101 {
102 if (hcache_fetch_raw_obj(mdata->hcache, "UIDVALIDITY", 11, &mdata->uidvalidity))
103 {
104 hcache_fetch_raw_obj(mdata->hcache, "UIDNEXT", 7, &mdata->uid_next);
105 hcache_fetch_raw_obj(mdata->hcache, "MODSEQ", 6, &mdata->modseq);
106 mutt_debug(LL_DEBUG3, "hcache uidvalidity %u, uidnext %u, modseq %llu\n",
107 mdata->uidvalidity, mdata->uid_next, mdata->modseq);
108 }
110 }
111#endif
112
113 return mdata;
114}
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:40
Header cache multiplexor.
#define hcache_fetch_raw_obj(hc, key, keylen, dst)
Definition: lib.h:162
struct ImapMboxData * imap_mdata_new(struct ImapAccountData *adata, const char *name)
Allocate and initialise a new ImapMboxData structure.
Definition: mdata.c:74
struct ImapMboxData * imap_mdata_get(struct Mailbox *m)
Get the Mailbox data for this mailbox.
Definition: mdata.c:61
void imap_hcache_open(struct ImapAccountData *adata, struct ImapMboxData *mdata, bool create)
Open a header cache.
Definition: util.c:303
#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:110
void imap_hcache_close(struct ImapMboxData *mdata)
Close the header cache.
Definition: util.c:344
char * imap_fix_path_with_delim(char delim, const char *mailbox, char *path, size_t plen)
Fix up the imap path.
Definition: util.c:714
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:961
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:123
@ LL_DEBUG3
Log at debug level 3.
Definition: logging2.h:45
#define FREE(x)
Definition: memory.h:55
#define MUTT_MEM_CALLOC(n, type)
Definition: memory.h:40
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:581
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