int nm_modify_message_tags(CONTEXT *ctx, HEADER *hdr, char *buf) { struct nm_ctxdata *data = get_ctxdata(ctx); notmuch_database_t *db = NULL; notmuch_message_t *msg = NULL; int rc = -1; if (!buf || !*buf || !data) return -1; if (!(db = get_db(data, TRUE)) || !(msg = get_nm_message(db, hdr))) goto done; dprint(1, (debugfile, "nm: tags modify: '%s'\n", buf)); update_tags(msg, buf); update_header_tags(hdr, msg); mutt_set_header_color(ctx, hdr); rc = 0; hdr->changed = TRUE; done: if (!is_longrun(data)) release_db(data); if (hdr->changed) ctx->mtime = time(NULL); dprint(1, (debugfile, "nm: tags modify done [rc=%d]\n", rc)); return rc; }
static int init_header(HEADER *h, const char *path, notmuch_message_t *msg) { const char *id; if (h->data) return 0; id = notmuch_message_get_message_id(msg); h->data = safe_calloc(1, sizeof(struct nm_hdrdata)); h->free_cb = deinit_header; /* * Notmuch ensures that message Id exists (if not notmuch Notmuch will * generate an ID), so it's more safe than use mutt HEADER->env->id */ ((struct nm_hdrdata *) h->data)->virtual_id = safe_strdup( id ); dprint(2, (debugfile, "nm: initialize header data: [hdr=%p, data=%p] (%s)\n", h, h->data, id)); if (!h->env->message_id) h->env->message_id = nm2mutt_message_id( id ); if (update_message_path(h, path)) return -1; update_header_tags(h, msg); return 0; }
static int init_header(HEADER *h, const char *path, notmuch_message_t *msg) { if (h->data) return 0; h->data = safe_calloc(1, sizeof(struct nm_hdrdata)); h->free_cb = deinit_header; dprint(2, (debugfile, "nm: initialize header data: [hdr=%p, data=%p] (%s)\n", h, h->data, h->env->message_id)); if (update_message_path(h, path)) return -1; update_header_tags(h, msg); return 0; }