From: Mehdi Abaakouk Date: Sat, 8 Dec 2018 13:34:46 +0000 (+0100) Subject: imap: always use mdata/adata getter X-Git-Tag: 2019-10-25~454 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=adcdd1e2db6e6f0f987fadcc26eee39d1920bb16;p=neomutt imap: always use mdata/adata getter --- diff --git a/imap/command.c b/imap/command.c index 7cfb0bdcc..b9923ff4d 100644 --- a/imap/command.c +++ b/imap/command.c @@ -393,7 +393,7 @@ static void cmd_parse_fetch(struct ImapAccountData *adata, char *s) int uid_checked = 0; int server_changes = 0; - struct ImapMboxData *mdata = adata->mailbox->mdata; + struct ImapMboxData *mdata = imap_mdata_get(adata->mailbox); mutt_debug(3, "Handling FETCH\n"); @@ -822,12 +822,12 @@ static void cmd_parse_status(struct ImapAccountData *adata, char *s) url_tostring(&url, path, sizeof(path), 0); struct Mailbox *m = mx_mbox_find2(path); - if (!m || !m->mdata) + struct ImapMboxData *mdata = imap_mdata_get(m); + if (!mdata) { mutt_debug(3, "Received status for an unexpected mailbox: %s\n", mailbox); return; } - struct ImapMboxData *mdata = m->mdata; olduv = mdata->uid_validity; oldun = mdata->uid_next; diff --git a/imap/imap.c b/imap/imap.c index cdf5c6adb..14c9bbe4f 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1966,8 +1966,8 @@ static int imap_mbox_open(struct Mailbox *m, struct Context *ctx) int rc; const char *condstore = NULL; - struct ImapAccountData *adata = m->account->adata; - struct ImapMboxData *mdata = m->mdata; + struct ImapAccountData *adata = imap_adata_get(m); + struct ImapMboxData *mdata = imap_mdata_get(m); imap_qualify_path(buf, sizeof(buf), &adata->conn_account, mdata->name); mutt_str_strfcpy(m->path, buf, sizeof(m->path)); @@ -2185,15 +2185,15 @@ fail: */ static int imap_mbox_open_append(struct Mailbox *m, int flags) { - if (!m) + if (!m || !m->account) return -1; int rc; /* in APPEND mode, we appear to hijack an existing IMAP connection - * ctx is brand new and mostly empty */ - struct ImapAccountData *adata = m->account->adata; - struct ImapMboxData *mdata = m->mdata; + struct ImapAccountData *adata = imap_adata_get(m); + struct ImapMboxData *mdata = imap_mdata_get(m); rc = imap_mailbox_status(m, false); if (rc >= 0) @@ -2305,12 +2305,12 @@ static int imap_msg_open_new(struct Mailbox *m, struct Message *msg, struct Emai */ static int imap_tags_edit(struct Mailbox *m, const char *tags, char *buf, size_t buflen) { - if (!m || !m->mdata) + struct ImapMboxData *mdata = imap_mdata_get(m); + if (!mdata) return -1; char *new = NULL; char *checker = NULL; - struct ImapMboxData *mdata = m->mdata; /* Check for \* flags capability */ if (!imap_has_flag(&mdata->flags, NULL)) diff --git a/imap/message.c b/imap/message.c index 868565def..a6ddd6912 100644 --- a/imap/message.c +++ b/imap/message.c @@ -704,7 +704,7 @@ static int read_headers_normal_eval_cache(struct ImapAccountData *adata, char buf[LONG_STRING]; struct Mailbox *m = adata->mailbox; - struct ImapMboxData *mdata = m->mdata; + struct ImapMboxData *mdata = imap_mdata_get(m); int idx = m->msg_count; /* L10N: @@ -914,7 +914,7 @@ static int read_headers_condstore_qresync_updates(struct ImapAccountData *adata, unsigned int header_msn = 0; struct Mailbox *m = adata->mailbox; - struct ImapMboxData *mdata = m->mdata; + struct ImapMboxData *mdata = imap_mdata_get(m); /* L10N: Fetching IMAP flag changes, using the CONDSTORE extension */ mutt_progress_init(&progress, _("Fetching flag updates..."), @@ -1222,7 +1222,7 @@ int imap_read_headers(struct ImapAccountData *adata, unsigned int msn_begin, #endif /* USE_HCACHE */ struct Mailbox *m = adata->mailbox; - struct ImapMboxData *mdata = m->mdata; + struct ImapMboxData *mdata = imap_mdata_get(m); /* make sure context has room to hold the mailbox */ while (msn_end > m->hdrmax) @@ -1834,7 +1834,7 @@ int imap_msg_open(struct Mailbox *m, struct Message *msg, int msgno) int output_progress; struct ImapAccountData *adata = imap_adata_get(m); - struct ImapMboxData *mdata = m->mdata; + struct ImapMboxData *mdata = imap_mdata_get(m); struct Email *e = m->hdrs[msgno]; msg->fp = msg_cache_get(adata, e); diff --git a/imap/util.c b/imap/util.c index 8cf4cc1dc..324dd12e7 100644 --- a/imap/util.c +++ b/imap/util.c @@ -1133,13 +1133,10 @@ int imap_wait_keepalive(pid_t pid) */ void imap_allow_reopen(struct Mailbox *m) { - if (!m) - return; struct ImapAccountData *adata = imap_adata_get(m); - if (!adata || !adata->mailbox || adata->mailbox != m) + struct ImapMboxData *mdata = imap_mdata_get(m); + if (!adata || !adata->mailbox || adata->mailbox != m || !mdata) return; - - struct ImapMboxData *mdata = m->mdata; mdata->reopen |= IMAP_REOPEN_ALLOW; } @@ -1149,13 +1146,10 @@ void imap_allow_reopen(struct Mailbox *m) */ void imap_disallow_reopen(struct Mailbox *m) { - if (!m) - return; struct ImapAccountData *adata = imap_adata_get(m); - if (!adata || !adata->mailbox || adata->mailbox != m) + struct ImapMboxData *mdata = imap_mdata_get(m); + if (!adata || !adata->mailbox || adata->mailbox != m || !mdata) return; - - struct ImapMboxData *mdata = m->mdata; mdata->reopen &= ~IMAP_REOPEN_ALLOW; }