From: Richard Russon Date: Fri, 28 Dec 2018 14:16:29 +0000 (+0000) Subject: imap tidy X-Git-Tag: 2019-10-25~399^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=daaf9eaacb1b0c8cc8d171703881f842e6ab0062;p=neomutt imap tidy --- diff --git a/imap/imap.c b/imap/imap.c index 38699564e..db2f4d775 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -591,7 +591,7 @@ int imap_create_mailbox(struct ImapAccountData *adata, char *mailbox) * @retval <0 Failure * * TODO: ACL checks. Right now we assume if it exists we can mess with it. - * TODO: This method should take a Context as parameter to be able to reuse the + * TODO: This method should take a Mailbox as parameter to be able to reuse the * existing connection. */ int imap_access(const char *path) @@ -1614,15 +1614,15 @@ out: /** * imap_sync_mailbox - Sync all the changes to the server - * @param ctx Mailbox + * @param m Mailbox * @param expunge if true do expunge * @param close if true we move imap state to CLOSE * @retval 0 Success * @retval -1 Error */ -int imap_sync_mailbox(struct Context *ctx, bool expunge, bool close) +int imap_sync_mailbox(struct Mailbox *m, bool expunge, bool close) { - if (!ctx || !ctx->mailbox) + if (!m) return -1; struct Email *e = NULL; @@ -1630,8 +1630,6 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge, bool close) int oldsort; int rc; - struct Mailbox *m = ctx->mailbox; - struct ImapAccountData *adata = imap_adata_get(m); struct ImapMboxData *mdata = imap_mdata_get(m); @@ -1705,7 +1703,7 @@ int imap_sync_mailbox(struct Context *ctx, bool expunge, bool close) mutt_message(ngettext("Saving changed message... [%d/%d]", "Saving changed messages... [%d/%d]", m->msg_count), i + 1, m->msg_count); - mutt_save_message_ctx(e, true, false, false, ctx->mailbox); + mutt_save_message_ctx(e, true, false, false, m); e->xlabel_changed = false; } } diff --git a/imap/imap.h b/imap/imap.h index 921feab47..444684228 100644 --- a/imap/imap.h +++ b/imap/imap.h @@ -55,7 +55,6 @@ #include "mx.h" struct BrowserState; -struct Context; struct Email; struct Pattern; @@ -79,7 +78,7 @@ extern short ImapPipelineDepth; int imap_access(const char *path); int imap_check_mailbox(struct Mailbox *m, bool force); int imap_delete_mailbox(struct Mailbox *m, char *path); -int imap_sync_mailbox(struct Context *ctx, bool expunge, bool close); +int imap_sync_mailbox(struct Mailbox *m, bool expunge, bool close); int imap_path_status(const char *path, bool queue); int imap_mailbox_status(struct Mailbox *m, bool queue); int imap_search(struct Mailbox *m, const struct Pattern *pat); diff --git a/mutt_parse.c b/mutt_parse.c index c858e612c..cc130afce 100644 --- a/mutt_parse.c +++ b/mutt_parse.c @@ -44,34 +44,32 @@ struct Context; /** * mutt_parse_mime_message - Parse a MIME email - * @param m Mailbox - * @param cur Email + * @param m Mailbox + * @param e Email */ -void mutt_parse_mime_message(struct Mailbox *m, struct Email *cur) +void mutt_parse_mime_message(struct Mailbox *m, struct Email *e) { - struct Message *msg = NULL; - do { - if (cur->content->type != TYPE_MESSAGE && cur->content->type != TYPE_MULTIPART) + if ((e->content->type != TYPE_MESSAGE) && (e->content->type != TYPE_MULTIPART)) break; /* nothing to do */ - if (cur->content->parts) + if (e->content->parts) break; /* The message was parsed earlier. */ - msg = mx_msg_open(m, cur->msgno); + struct Message *msg = mx_msg_open(m, e->msgno); if (msg) { - mutt_parse_part(msg->fp, cur->content); + mutt_parse_part(msg->fp, e->content); if (WithCrypto) - cur->security = crypt_query(cur->content); + e->security = crypt_query(e->content); mx_msg_close(m, &msg); } } while (false); - cur->attach_valid = false; + e->attach_valid = false; } /** diff --git a/mx.c b/mx.c index 46a677373..2afe4ef50 100644 --- a/mx.c +++ b/mx.c @@ -434,18 +434,16 @@ void mx_fastclose_mailbox(struct Mailbox *m) /** * sync_mailbox - save changes to disk - * @param ctx Mailbox + * @param m Mailbox * @param index_hint Current email * @retval 0 Success * @retval -1 Failure */ -static int sync_mailbox(struct Context *ctx, int *index_hint) +static int sync_mailbox(struct Mailbox *m, int *index_hint) { - if (!ctx || !ctx->mailbox || !ctx->mailbox->mx_ops || !ctx->mailbox->mx_ops->mbox_sync) + if (!m || !m->mx_ops || !m->mx_ops->mbox_sync) return -1; - struct Mailbox *m = ctx->mailbox; - if (!m->quiet) { /* L10N: Displayed before/as a mailbox is being synced */ @@ -749,7 +747,7 @@ int mx_mbox_close(struct Context **pctx) /* allow IMAP to preserve the deleted flag across sessions */ if (m->magic == MUTT_IMAP) { - int check = imap_sync_mailbox(ctx, (purge != MUTT_NO), true); + int check = imap_sync_mailbox(ctx->mailbox, (purge != MUTT_NO), true); if (check != 0) return check; } @@ -768,7 +766,7 @@ int mx_mbox_close(struct Context **pctx) if (m->changed || (m->msg_deleted != 0)) { - int check = sync_mailbox(ctx, NULL); + int check = sync_mailbox(ctx->mailbox, NULL); if (check != 0) return check; } @@ -898,10 +896,10 @@ int mx_mbox_sync(struct Context *ctx, int *index_hint) #ifdef USE_IMAP if (m->magic == MUTT_IMAP) - rc = imap_sync_mailbox(ctx, purge, false); + rc = imap_sync_mailbox(ctx->mailbox, purge, false); else #endif - rc = sync_mailbox(ctx, index_hint); + rc = sync_mailbox(ctx->mailbox, index_hint); if (rc == 0) { #ifdef USE_IMAP