From: Mehdi Abaakouk Date: Thu, 20 Dec 2018 07:50:59 +0000 (+0100) Subject: imap: Move Context to ImapMboxData X-Git-Tag: 2019-10-25~429 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a8c78964d94ccccdcc3a20f6471a94465d33f46f;p=neomutt imap: Move Context to ImapMboxData --- diff --git a/imap/command.c b/imap/command.c index 0299cea7e..a7a2f67f2 100644 --- a/imap/command.c +++ b/imap/command.c @@ -165,7 +165,7 @@ static void cmd_handle_fatal(struct ImapAccountData *adata) if (adata->state >= IMAP_SELECTED && (mdata->reopen & IMAP_REOPEN_ALLOW)) { - mx_fastclose_mailbox(adata->ctx); + mx_fastclose_mailbox(mdata->ctx); mutt_socket_close(adata->conn); mutt_error(_("Mailbox %s@%s closed"), adata->conn->account.user, adata->conn->account.host); diff --git a/imap/imap.c b/imap/imap.c index 8efc3c915..09cbab5df 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -793,7 +793,7 @@ void imap_expunge_mailbox(struct Mailbox *m) old_sort = Sort; Sort = SORT_ORDER; - mutt_sort_headers(adata->ctx, false); + mutt_sort_headers(mdata->ctx, false); for (int i = 0; i < m->msg_count; i++) { @@ -853,9 +853,9 @@ void imap_expunge_mailbox(struct Mailbox *m) /* We may be called on to expunge at any time. We can't rely on the caller * to always know to rethread */ - mx_update_tables(adata->ctx, false); + mx_update_tables(mdata->ctx, false); Sort = old_sort; - mutt_sort_headers(adata->ctx, true); + mutt_sort_headers(mdata->ctx, true); } /** @@ -1980,11 +1980,11 @@ static int imap_mbox_open(struct Mailbox *m, struct Context *ctx) struct ImapMboxData *mdata = imap_mdata_get(m); // NOTE(sileht): looks like we have two not obvious loop here - // ctx->mailbox->account->adata->ctx + // ctx->mailbox->account->mdata->ctx // mailbox->account->adata->mailbox // this is used only by imap_mbox_close() to detect if the // adata/mailbox is a normal or append one, looks a bit dirty - adata->ctx = ctx; + mdata->ctx = ctx; adata->mailbox = m; /* clear mailbox status */ @@ -2251,20 +2251,21 @@ static int imap_mbox_close(struct Context *ctx) struct Mailbox *m = ctx->mailbox; struct ImapAccountData *adata = imap_adata_get(m); + struct ImapMboxData *mdata = imap_mdata_get(m); /* Check to see if the mailbox is actually open */ - if (!adata) + if (!adata || !mdata) return 0; /* imap_mbox_open_append() borrows the struct ImapAccountData temporarily, - * just for the connection, but does not set adata->ctx to the + * just for the connection, but does not set mdata->ctx to the * open-append ctx. * * So when these are equal, it means we are actually closing the * mailbox and should clean up adata. Otherwise, we don't want to * touch adata - it's still being used. */ - if (ctx == adata->ctx) + if (ctx == mdata->ctx) { if (adata->status != IMAP_FATAL && adata->state >= IMAP_SELECTED) { @@ -2279,7 +2280,7 @@ static int imap_mbox_close(struct Context *ctx) } adata->mailbox = NULL; - adata->ctx = NULL; + mdata->ctx = NULL; imap_mdata_cache_reset(m->mdata); } diff --git a/imap/imap_private.h b/imap/imap_private.h index 384ab15b8..599f962ca 100644 --- a/imap/imap_private.h +++ b/imap/imap_private.h @@ -214,7 +214,6 @@ struct ImapAccountData struct Buffer *cmdbuf; char delim; - struct Context *ctx; struct Mailbox *mailbox; /* Current selected mailbox */ }; @@ -250,6 +249,8 @@ struct ImapMboxData unsigned int max_msn; /**< the largest MSN fetched so far */ struct BodyCache *bcache; + struct Context *ctx; + #ifdef USE_HCACHE header_cache_t *hcache; #endif diff --git a/imap/message.c b/imap/message.c index 0434f6789..8bd7dae04 100644 --- a/imap/message.c +++ b/imap/message.c @@ -1817,7 +1817,7 @@ char *imap_set_flags(struct Mailbox *m, struct Email *e, char *s, int *server_ch m->readonly = false; /* This is redundant with the following two checks. Removing: - * mutt_set_flag (adata->ctx, e, MUTT_NEW, !(edata->read || edata->old)); + * mutt_set_flag (m, e, MUTT_NEW, !(edata->read || edata->old)); */ set_changed_flag(m, e, local_changes, server_changes, MUTT_OLD, old_edata.old, edata->old, e->old);