]> granicus.if.org Git - neomutt/commitdiff
imap: always use mdata/adata getter
authorMehdi Abaakouk <sileht@sileht.net>
Sat, 8 Dec 2018 13:34:46 +0000 (14:34 +0100)
committerRichard Russon <rich@flatcap.org>
Sat, 8 Dec 2018 14:33:50 +0000 (14:33 +0000)
imap/command.c
imap/imap.c
imap/message.c
imap/util.c

index 7cfb0bdcc22f87588d892c087479d51ad1d2696d..b9923ff4da097380d561e8b043cd6914b4f537bc 100644 (file)
@@ -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;
 
index cdf5c6adbe90a1adbd8ce658c3ad66e298a02f2d..14c9bbe4f153edb1fdeb86ac4d407e338579e2f4 100644 (file)
@@ -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))
index 868565defc16c5b42a3e53478fe6d026b40d16aa..a6ddd69124a0543ac9dc1047cd537aa0938787dd 100644 (file)
@@ -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);
index 8cf4cc1dcf724dcd5f6df26faf60ef5ce046bd07..324dd12e77446daf63962df2004cef759e65ad8b 100644 (file)
@@ -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;
 }