From: Richard Russon Date: Fri, 7 Sep 2018 19:46:12 +0000 (+0100) Subject: move Context.compress X-Git-Tag: 2019-10-25~657^2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c96edc8ccb2e552cf0344f49474f114c48bfb71;p=neomutt move Context.compress --- diff --git a/commands.c b/commands.c index f6cc68195..3269eeef8 100644 --- a/commands.c +++ b/commands.c @@ -994,7 +994,7 @@ int mutt_save_message(struct Header *h, bool delete, bool decode, bool decrypt) /* If we're saving to a compressed mailbox, the stats won't be updated * until the next open. Until then, improvise. */ struct Mailbox *cm = NULL; - if (savectx->compress_info) + if (savectx->mailbox->compress_info) { cm = mutt_find_mailbox(savectx->mailbox->realpath); } diff --git a/compress.c b/compress.c index d41376fdc..b60332efd 100644 --- a/compress.c +++ b/compress.c @@ -88,7 +88,7 @@ static int lock_realpath(struct Context *ctx, int excl) if (!ctx) return 0; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return 0; @@ -130,7 +130,7 @@ static void unlock_realpath(struct Context *ctx) if (!ctx) return; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return; @@ -204,7 +204,7 @@ static void store_size(const struct Context *ctx) if (!ctx) return; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return; @@ -252,8 +252,8 @@ static struct CompressInfo *set_compress_info(struct Context *ctx) if (!ctx || !ctx->mailbox->path) return NULL; - if (ctx->compress_info) - return ctx->compress_info; + if (ctx->mailbox->compress_info) + return ctx->mailbox->compress_info; /* Open is compulsory */ const char *o = find_hook(MUTT_OPEN_HOOK, ctx->mailbox->path); @@ -264,7 +264,7 @@ static struct CompressInfo *set_compress_info(struct Context *ctx) const char *a = find_hook(MUTT_APPEND_HOOK, ctx->mailbox->path); struct CompressInfo *ci = mutt_mem_calloc(1, sizeof(struct CompressInfo)); - ctx->compress_info = ci; + ctx->mailbox->compress_info = ci; ci->open = mutt_str_strdup(o); ci->close = mutt_str_strdup(c); @@ -281,17 +281,17 @@ static void free_compress_info(struct Context *ctx) { struct CompressInfo *ci = NULL; - if (!ctx || !ctx->compress_info) + if (!ctx || !ctx->mailbox->compress_info) return; - ci = ctx->compress_info; + ci = ctx->mailbox->compress_info; FREE(&ci->open); FREE(&ci->close); FREE(&ci->append); unlock_realpath(ctx); - FREE(&ctx->compress_info); + FREE(&ctx->mailbox->compress_info); } /** @@ -587,7 +587,7 @@ static int comp_mbox_close(struct Context *ctx) if (!ctx) return -1; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return -1; @@ -667,7 +667,7 @@ static int comp_mbox_check(struct Context *ctx, int *index_hint) if (!ctx) return -1; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return -1; @@ -702,7 +702,7 @@ static int comp_msg_open(struct Context *ctx, struct Message *msg, int msgno) if (!ctx) return -1; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return -1; @@ -722,7 +722,7 @@ static int comp_msg_close(struct Context *ctx, struct Message *msg) if (!ctx) return -1; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return -1; @@ -742,7 +742,7 @@ static int comp_msg_commit(struct Context *ctx, struct Message *msg) if (!ctx) return -1; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return -1; @@ -762,7 +762,7 @@ static int comp_msg_open_new(struct Context *ctx, struct Message *msg, struct He if (!ctx) return -1; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return -1; @@ -837,7 +837,7 @@ static int comp_mbox_sync(struct Context *ctx, int *index_hint) if (!ctx) return -1; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return -1; @@ -907,7 +907,7 @@ static int comp_msg_padding_size(struct Context *ctx) if (!ctx) return 0; - struct CompressInfo *ci = ctx->compress_info; + struct CompressInfo *ci = ctx->mailbox->compress_info; if (!ci) return 0; diff --git a/context.h b/context.h index 1e3e009dc..713c53887 100644 --- a/context.h +++ b/context.h @@ -57,10 +57,6 @@ struct Context bool collapsed : 1; /**< are all threads collapsed? */ bool peekonly : 1; /**< just taking a glance, revert atime */ -#ifdef USE_COMPRESSED - void *compress_info; /**< compressed mbox module private data */ -#endif /**< USE_COMPRESSED */ - struct Mailbox *mailbox; }; diff --git a/curs_main.c b/curs_main.c index 947cf99f2..c9ad06b65 100644 --- a/curs_main.c +++ b/curs_main.c @@ -573,7 +573,7 @@ static int main_change_folder(struct Menu *menu, int op, char *buf, int monitor_remove_rc = mutt_monitor_remove(NULL); #endif #ifdef USE_COMPRESSED - if (Context->compress_info && Context->mailbox->realpath) + if (Context->mailbox->compress_info && Context->mailbox->realpath) new_last_folder = mutt_str_strdup(Context->mailbox->realpath); else #endif diff --git a/mailbox.h b/mailbox.h index c103e900f..c8fa89e52 100644 --- a/mailbox.h +++ b/mailbox.h @@ -106,6 +106,10 @@ struct Mailbox unsigned char rights[(RIGHTSMAX + 7) / 8]; /**< ACL bits */ +#ifdef USE_COMPRESSED + void *compress_info; /**< compressed mbox module private data */ +#endif + int flags; /**< e.g. #MB_NORMAL */ }; diff --git a/status.c b/status.c index 62400872a..2d293234f 100644 --- a/status.c +++ b/status.c @@ -131,7 +131,7 @@ static const char *status_format_str(char *buf, size_t buflen, size_t col, int c else #endif #ifdef USE_COMPRESSED - if (Context && Context->compress_info && Context->mailbox->realpath) + if (Context && Context->mailbox->compress_info && Context->mailbox->realpath) { mutt_str_strfcpy(tmp, Context->mailbox->realpath, sizeof(tmp)); mutt_pretty_mailbox(tmp, sizeof(tmp));