diff options
author | Kevin McCarthy <kevin@8t8.us> | 2018-12-25 19:24:08 -0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2018-12-29 14:11:57 -0800 |
commit | 7f603dd66a28d0c02c09bbd6636fc659e69b480d (patch) | |
tree | 481d7ccd0da5f5b191a6a1b975200f893cc46c7f | |
parent | a5b64f6c919a736b0d4cf0043a782b87c9d08a57 (diff) |
Create envelope->changed to mark all field changes.
In subsequent commits, we're going to add the x-label and subject
headers changed flags into the envelope. To avoid the list of checks
exploding everywhere, just use a single field to check and reset those
values.
Several places in the code are checking for a null header->env. I
wasn't aware this was possible, so I've added todo notes to track down
when this occurs.
-rw-r--r-- | copy.c | 6 | ||||
-rw-r--r-- | imap/imap.c | 5 | ||||
-rw-r--r-- | mh.c | 14 | ||||
-rw-r--r-- | mutt.h | 7 | ||||
-rw-r--r-- | muttlib.c | 4 | ||||
-rw-r--r-- | mx.c | 3 | ||||
-rw-r--r-- | thread.c | 13 |
7 files changed, 37 insertions, 15 deletions
@@ -354,9 +354,9 @@ mutt_copy_header (FILE *in, HEADER *h, FILE *out, int flags, const char *prefix) char *temp_hdr = NULL; if (h->env) - flags |= (h->env->irt_changed ? CH_UPDATE_IRT : 0) - | (h->env->refs_changed ? CH_UPDATE_REFS : 0); - + flags |= ((h->env->changed & MUTT_ENV_CHANGED_IRT) ? CH_UPDATE_IRT : 0) + | ((h->env->changed & MUTT_ENV_CHANGED_REFS) ? CH_UPDATE_REFS : 0); + if (mutt_copy_hdr (in, out, h->offset, h->content->offset, flags, prefix) == -1) return -1; diff --git a/imap/imap.c b/imap/imap.c index c7ff117a..736e399e 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -1321,7 +1321,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint) /* if the message has been rethreaded or attachments have been deleted * we delete the message and reupload it. * This works better if we're expunging, of course. */ - if ((h->env && (h->env->refs_changed || h->env->irt_changed)) || + if ((h->env && h->env->changed) || h->attach_del || h->xlabel_changed) { /* NOTE and TODO: @@ -1356,6 +1356,9 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int* index_hint) dprint (1, (debugfile, "imap_sync_mailbox: Error opening mailbox in append mode\n")); else _mutt_save_message (h, appendctx, 1, 0, 0); + /* TODO: why the check for h->env? Is this possible? */ + if (h->env) + h->env->changed = 0; h->xlabel_changed = 0; #if USE_HCACHE idata->hcache = imap_hcache_open (idata, NULL); @@ -1878,10 +1878,16 @@ static int mh_sync_message (CONTEXT * ctx, int msgno) { HEADER *h = ctx->hdrs[msgno]; + /* TODO: why the h->env check? */ if (h->attach_del || h->xlabel_changed || - (h->env && (h->env->refs_changed || h->env->irt_changed))) + (h->env && h->env->changed)) + { if (mh_rewrite_message (ctx, msgno) != 0) return -1; + /* TODO: why the env check? */ + if (h->env) + h->env->changed = 0; + } return 0; } @@ -1897,12 +1903,16 @@ static int maildir_sync_message (CONTEXT * ctx, int msgno) char *p; int rc = 0; + /* TODO: why the h->env check? */ if (h->attach_del || h->xlabel_changed || - (h->env && (h->env->refs_changed || h->env->irt_changed))) + (h->env && h->env->changed)) { /* when doing attachment deletion/rethreading, fall back to the MH case. */ if (mh_rewrite_message (ctx, msgno) != 0) return (-1); + /* TODO: why the env check? */ + if (h->env) + h->env->changed = 0; } else { @@ -656,6 +656,9 @@ typedef struct alias short num; } ALIAS; +#define MUTT_ENV_CHANGED_IRT (1<<0) /* In-Reply-To changed to link/break threads */ +#define MUTT_ENV_CHANGED_REFS (1<<1) /* References changed to break thread */ + typedef struct envelope { ADDRESS *return_path; @@ -679,8 +682,8 @@ typedef struct envelope LIST *in_reply_to; /* in-reply-to header content */ LIST *userhdrs; /* user defined headers */ - unsigned int irt_changed : 1; /* In-Reply-To changed to link/break threads */ - unsigned int refs_changed : 1; /* References changed to break thread */ + unsigned char changed; /* The MUTT_ENV_CHANGED_* flags specify which + * fields are modified */ } ENVELOPE; typedef struct parameter @@ -801,11 +801,11 @@ void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra) MOVE_ELEM(supersedes); MOVE_ELEM(date); MOVE_ELEM(x_label); - if (!base->refs_changed) + if (!(base->changed & MUTT_ENV_CHANGED_REFS)) { MOVE_ELEM(references); } - if (!base->irt_changed) + if (!(base->changed & MUTT_ENV_CHANGED_IRT)) { MOVE_ELEM(in_reply_to); } @@ -1088,7 +1088,10 @@ void mx_update_tables(CONTEXT *ctx, int committing) } if (committing) + { ctx->hdrs[j]->changed = 0; + ctx->hdrs[j]->env->changed = 0; + } else if (ctx->hdrs[j]->changed) ctx->changed = 1; @@ -1396,7 +1396,8 @@ static void clean_references (THREAD *brk, THREAD *cur) /* clearing the References: header from obsolete Message-ID(s) */ mutt_free_list (&ref->next); - h->env->refs_changed = h->changed = 1; + h->changed = 1; + h->env->changed |= MUTT_ENV_CHANGED_REFS; } } } @@ -1405,7 +1406,8 @@ void mutt_break_thread (HEADER *hdr) { mutt_free_list (&hdr->env->in_reply_to); mutt_free_list (&hdr->env->references); - hdr->env->irt_changed = hdr->env->refs_changed = hdr->changed = 1; + hdr->changed = 1; + hdr->env->changed |= (MUTT_ENV_CHANGED_IRT | MUTT_ENV_CHANGED_REFS); clean_references (hdr->thread, hdr->thread->child); } @@ -1419,10 +1421,11 @@ static int link_threads (HEADER *parent, HEADER *child, CONTEXT *ctx) child->env->in_reply_to = mutt_new_list (); child->env->in_reply_to->data = safe_strdup (parent->env->message_id); - + mutt_set_flag (ctx, child, MUTT_TAG, 0); - - child->env->irt_changed = child->changed = 1; + + child->changed = 1; + child->env->changed |= MUTT_ENV_CHANGED_IRT; return 1; } |