return ops->msg_padding_size(m);
}
+/**
+ * comp_msg_save_hcache - Save message to the header cache - Implements MxOps::msg_save_hcache()
+ */
+static int comp_msg_save_hcache(struct Mailbox *m, struct Email *e)
+{
+ if (!m || !m->compress_info)
+ return 0;
+
+ struct CompressInfo *ci = m->compress_info;
+
+ const struct MxOps *ops = ci->child_ops;
+ if (!ops || !ops->msg_save_hcache)
+ return 0;
+
+ return ops->msg_save_hcache(m, e);
+}
+
/**
* comp_tags_edit - Implements MxOps::tags_edit()
*/
.msg_commit = comp_msg_commit,
.msg_close = comp_msg_close,
.msg_padding_size = comp_msg_padding_size,
+ .msg_save_hcache = comp_msg_save_hcache,
.tags_edit = comp_tags_edit,
.tags_commit = comp_tags_commit,
.path_probe = comp_path_probe,
.msg_commit = imap_msg_commit,
.msg_close = imap_msg_close,
.msg_padding_size = NULL,
+ .msg_save_hcache = imap_msg_save_hcache,
.tags_edit = imap_tags_edit,
.tags_commit = imap_tags_commit,
.path_probe = imap_path_probe,
int imap_msg_open(struct Mailbox *m, struct Message *msg, int msgno);
int imap_msg_close(struct Mailbox *m, struct Message *msg);
int imap_msg_commit(struct Mailbox *m, struct Message *msg);
+int imap_msg_save_hcache(struct Mailbox *m, struct Email *e);
/* util.c */
struct ImapAccountData *imap_adata_get(struct Mailbox *m);
{
return mutt_file_fclose(&msg->fp);
}
+
+/**
+ * imap_msg_save_hcache - Save message to the header cache - Implements MxOps::msg_save_hcache()
+ */
+int imap_msg_save_hcache(struct Mailbox *m, struct Email *e)
+{
+ int rc = 0;
+#ifdef USE_HCACHE
+ bool close_hc = true;
+ struct ImapAccountData *adata = imap_adata_get(m);
+ struct ImapMboxData *mdata = imap_mdata_get(m);
+ if (mdata->hcache)
+ close_hc = false;
+ else
+ mdata->hcache = imap_hcache_open(adata, NULL);
+ rc = imap_hcache_put(mdata, e);
+ if (close_hc)
+ imap_hcache_close(mdata);
+#endif
+ return rc;
+}
return md_commit_message(m, msg, NULL);
}
+/**
+ * maildir_msg_save_hcache - Save message to the header cache - Implements MxOps::msg_save_hcache()
+ */
+static int maildir_msg_save_hcache(struct Mailbox *m, struct Email *e)
+{
+ int rc = 0;
+#ifdef USE_HCACHE
+ header_cache_t *hc = mutt_hcache_open(HeaderCache, m->path, NULL);
+ char *key = e->path + 3;
+ int keylen = maildir_hcache_keylen(key);
+ rc = mutt_hcache_store(hc, key, keylen, e, 0);
+ mutt_hcache_close(hc);
+#endif
+ return rc;
+}
+
/**
* maildir_path_probe - Is this a Maildir mailbox? - Implements MxOps::path_probe()
*/
.msg_commit = maildir_msg_commit,
.msg_close = mh_msg_close,
.msg_padding_size = NULL,
+ .msg_save_hcache = maildir_msg_save_hcache,
.tags_edit = NULL,
.tags_commit = NULL,
.path_probe = maildir_path_probe,
int mh_mbox_close (struct Mailbox *m);
int mh_mbox_sync (struct Mailbox *m, int *index_hint);
int mh_msg_close (struct Mailbox *m, struct Message *msg);
+int mh_msg_save_hcache (struct Mailbox *m, struct Email *e);
/* Maildir/MH shared functions */
void maildir_canon_filename (struct Buffer *dest, const char *src);
void maildir_delayed_parsing(struct Mailbox *m, struct Maildir **md, struct Progress *progress);
+size_t maildir_hcache_keylen (const char *fn);
struct MaildirMboxData *maildir_mdata_get (struct Mailbox *m);
int maildir_mh_open_message(struct Mailbox *m, struct Message *msg, int msgno, bool is_maildir);
int maildir_move_to_context(struct Mailbox *m, struct Maildir **md);
.msg_commit = mh_msg_commit,
.msg_close = mh_msg_close,
.msg_padding_size = NULL,
+ .msg_save_hcache = mh_msg_save_hcache,
.tags_edit = NULL,
.tags_commit = NULL,
.path_probe = mh_path_probe,
*
* @note This length excludes the flags, which will vary
*/
-static size_t maildir_hcache_keylen(const char *fn)
+size_t maildir_hcache_keylen(const char *fn)
{
const char *p = strrchr(fn, ':');
return p ? (size_t)(p - fn) : mutt_str_strlen(fn);
{
return mutt_file_fclose(&msg->fp);
}
+
+/**
+ * mh_msg_save_hcache - Save message to the header cache - Implements MxOps::msg_save_hcache()
+ */
+int mh_msg_save_hcache(struct Mailbox *m, struct Email *e)
+{
+ int rc = 0;
+#ifdef USE_HCACHE
+ header_cache_t *hc = mutt_hcache_open(HeaderCache, m->path, NULL);
+ rc = mutt_hcache_store(hc, e->path, strlen(e->path), e, 0);
+ mutt_hcache_close(hc);
+#endif
+ return rc;
+}
.msg_commit = mbox_msg_commit,
.msg_close = mbox_msg_close,
.msg_padding_size = mbox_msg_padding_size,
+ .msg_save_hcache = NULL,
.tags_edit = NULL,
.tags_commit = NULL,
.path_probe = mbox_path_probe,
.msg_commit = mmdf_msg_commit,
.msg_close = mbox_msg_close,
.msg_padding_size = mmdf_msg_padding_size,
+ .msg_save_hcache = NULL,
.tags_edit = NULL,
.tags_commit = NULL,
.path_probe = mbox_path_probe,
return m->mx_ops->mbox_check_stats(m, flags);
}
+
+/**
+ * mx_save_to_header_cache - Save message to the header cache - Wrapper for MxOps::msg_save_hcache()
+ * @param m Mailbox
+ * @param e Email
+ * @retval 0 Success
+ * @retval -1 Failure
+ *
+ * Write a single header out to the header cache.
+ */
+int mx_save_hcache(struct Mailbox *m, struct Email *e)
+{
+ if (!m->mx_ops || !m->mx_ops->msg_save_hcache)
+ return 0;
+
+ return m->mx_ops->msg_save_hcache(m, e);
+}
* @retval num Bytes of padding
*/
int (*msg_padding_size)(struct Mailbox *m);
+ /**
+ * msg_save_hcache - Save message to the header cache
+ * @param m Mailbox
+ * @param e Email
+ * @retval 0 Success
+ * @retval -1 Failure
+ */
+ int (*msg_save_hcache) (struct Mailbox *m, struct Email *e);
/**
* tags_edit - Prompt and validate new messages tags
* @param m Mailbox
struct Message *mx_msg_open_new (struct Mailbox *m, struct Email *e, int flags);
struct Message *mx_msg_open (struct Mailbox *m, int msgno);
int mx_msg_padding_size(struct Mailbox *m);
+int mx_save_hcache (struct Mailbox *m, struct Email *e);
int mx_path_canon (char *buf, size_t buflen, const char *folder, int *magic);
int mx_path_canon2 (struct Mailbox *m, const char *folder);
int mx_path_parent (char *buf, size_t buflen);
.msg_commit = NULL,
.msg_close = nntp_msg_close,
.msg_padding_size = NULL,
+ .msg_save_hcache = NULL,
.tags_edit = NULL,
.tags_commit = NULL,
.path_probe = nntp_path_probe,
.msg_commit = nm_msg_commit,
.msg_close = nm_msg_close,
.msg_padding_size = NULL,
+ .msg_save_hcache = NULL,
.tags_edit = nm_tags_edit,
.tags_commit = nm_tags_commit,
.path_probe = nm_path_probe,
return mutt_file_fclose(&msg->fp);
}
+/**
+ * pop_msg_save_hcache - Save message to the header cache - Implements MxOps::msg_save_hcache()
+ */
+static int pop_msg_save_hcache(struct Mailbox *m, struct Email *e)
+{
+ int rc = 0;
+#ifdef USE_HCACHE
+ struct PopAccountData *adata = pop_get_adata(m);
+ struct PopEmailData *edata = e->edata;
+ header_cache_t *hc = pop_hcache_open(adata, m->path);
+ rc = mutt_hcache_store(hc, edata->uid, strlen(edata->uid), e, 0);
+ mutt_hcache_close(hc);
+#endif
+
+ return rc;
+}
+
/**
* pop_path_probe - Is this a POP mailbox? - Implements MxOps::path_probe()
*/
.msg_commit = NULL,
.msg_close = pop_msg_close,
.msg_padding_size = NULL,
+ .msg_save_hcache = pop_msg_save_hcache,
.tags_edit = NULL,
.tags_commit = NULL,
.path_probe = pop_path_probe,