.commit_msg = commit_message,
.open_new_msg = open_new_message,
.msg_padding_size = compress_msg_padding_size,
+ .save_to_header_cache = NULL, /* compressed doesn't support maildir/mh */
};
return rc;
}
+static int imap_save_to_header_cache (CONTEXT *ctx, HEADER *h)
+{
+ int rc = 0;
+#ifdef USE_HCACHE
+ int close_hc = 1;
+ IMAP_DATA* idata;
+
+ idata = (IMAP_DATA *)ctx->data;
+ if (idata->hcache)
+ close_hc = 0;
+ else
+ idata->hcache = imap_hcache_open (idata, NULL);
+ rc = imap_hcache_put (idata, h);
+ if (close_hc)
+ imap_hcache_close (idata);
+#endif
+ return rc;
+}
+
/* split path into (idata,mailbox name) */
static int imap_get_mailbox (const char* path, IMAP_DATA** hidata, char* buf, size_t blen)
{
.open_new_msg = imap_open_new_message,
.check = imap_check_mailbox_reopen,
.sync = NULL, /* imap syncing is handled by imap_sync_mailbox */
+ .save_to_header_cache = imap_save_to_header_cache,
};
int mx_access (const char*, int);
int mx_check_empty (const char *);
int mx_msg_padding_size (CONTEXT *);
+int mx_save_to_header_cache (CONTEXT *, HEADER *);
int mx_is_maildir (const char *);
int mx_is_mh (const char *);
.check = mbox_check_mailbox,
.sync = mbox_sync_mailbox,
.msg_padding_size = mbox_msg_padding_size,
+ .save_to_header_cache = NULL,
};
struct mx_ops mx_mmdf_ops = {
.check = mbox_check_mailbox,
.sync = mbox_sync_mailbox,
.msg_padding_size = mmdf_msg_padding_size,
+ .save_to_header_cache = NULL,
};
}
+static int maildir_save_to_header_cache (CONTEXT *ctx, HEADER *h)
+{
+ int rc = 0;
+#if USE_HCACHE
+ header_cache_t *hc;
+
+ hc = mutt_hcache_open (HeaderCache, ctx->path, NULL);
+ rc = mutt_hcache_store (hc, h->path + 3, h, 0, &maildir_hcache_keylen,
+ MUTT_GENERATE_UIDVALIDITY);
+ mutt_hcache_close (hc);
+#endif
+ return rc;
+}
+
+
+static int mh_save_to_header_cache (CONTEXT *ctx, HEADER *h)
+{
+ int rc = 0;
+#if USE_HCACHE
+ header_cache_t *hc;
+
+ hc = mutt_hcache_open (HeaderCache, ctx->path, NULL);
+ rc = mutt_hcache_store (hc, h->path, h, 0, strlen, MUTT_GENERATE_UIDVALIDITY);
+ mutt_hcache_close (hc);
+#endif
+ return rc;
+}
/*
.open_new_msg = maildir_open_new_message,
.check = maildir_check_mailbox,
.sync = mh_sync_mailbox,
+ .save_to_header_cache = maildir_save_to_header_cache,
};
struct mx_ops mx_mh_ops = {
.open_new_msg = mh_open_new_message,
.check = mh_check_mailbox,
.sync = mh_sync_mailbox,
+ .save_to_header_cache = mh_save_to_header_cache,
};
int (*commit_msg) (struct _context *, struct _message *);
int (*open_new_msg) (struct _message *, struct _context *, HEADER *);
int (*msg_padding_size) (struct _context *);
+ int (*save_to_header_cache) (struct _context *, struct header *);
};
typedef struct _context
return ctx->mx_ops->msg_padding_size (ctx);
}
+/* Writes a single header out to the header cache. */
+int mx_save_to_header_cache (CONTEXT *ctx, HEADER *h)
+{
+ if (!ctx->mx_ops || !ctx->mx_ops->save_to_header_cache)
+ return 0;
+
+ return ctx->mx_ops->save_to_header_cache (ctx, h);
+}
+
/* vim: set sw=2: */
return 0;
}
+static int pop_save_to_header_cache (CONTEXT *ctx, HEADER *h)
+{
+ int rc = 0;
+#ifdef USE_HCACHE
+ POP_DATA *pop_data;
+ header_cache_t *hc;
+
+ pop_data = (POP_DATA *)ctx->data;
+ hc = pop_hcache_open (pop_data, ctx->path);
+ rc = mutt_hcache_store (hc, h->data, h, 0, strlen, MUTT_GENERATE_UIDVALIDITY);
+ mutt_hcache_close (hc);
+#endif
+
+ return rc;
+}
+
/* Fetch messages and save them in $spoolfile */
void pop_fetch_mail (void)
{
.commit_msg = NULL,
.open_new_msg = NULL,
.sync = pop_sync_mailbox,
+ .save_to_header_cache = pop_save_to_header_cache,
};