-2007-04-10 13:46 -0700 Brendan Cully <brendan@kublai.com> (d3e0d6c60d87)
+2007-04-10 15:32 -0700 Brendan Cully <brendan@kublai.com> (c38765da3fe8)
+
+ * imap/command.c, imap/imap.c, imap/imap_private.h, imap/util.c: Add
+ imap_hcache_del; minor cleanups
+
+ * main.c: Fix a compiler warning
* rfc3676.c: Don't use $indent_string to quote replies to flowed
messages (closes #2874).
HEADER* h;
int i, cacheno;
+#ifdef USE_HCACHE
+ imap_hcache_open (idata);
+#endif
+
for (i = 0; i < idata->ctx->msgcount; i++)
{
h = idata->ctx->hdrs[i];
}
}
+#if USE_HCACHE
+ imap_hcache_close (idata);
+#endif
+
/* We may be called on to expunge at any time. We can't rely on the caller
* to always know to rethread */
mx_update_tables (idata->ctx, 0);
ctx->hdrs = safe_calloc (count, sizeof (HEADER *));
ctx->v2r = safe_calloc (count, sizeof (int));
ctx->msgcount = 0;
-#ifdef USE_HCACHE
- idata->hcache = imap_hcache_open (idata, idata->ctx->path);
-#endif
+
if (count && (imap_read_headers (idata, 0, count-1) < 0))
{
mutt_error _("Error opening mailbox");
}
}
+#if USE_HCACHE
+ imap_hcache_open (idata);
+#endif
+
/* save messages with real (non-flag) changes */
for (n = 0; n < ctx->msgcount; n++)
{
}
}
+#if USE_HCACHE
+ imap_hcache_close (idata);
+#endif
+
/* sync +/- flags for the five flags mutt cares about */
rc = 0;
}
}
-#ifdef USE_HCACHE
- mutt_hcache_close (idata->hcache);
- idata->hcache = NULL;
-#endif
mutt_bcache_close (&idata->bcache);
return 0;
/* util.c */
#ifdef USE_HCACHE
-header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path);
+int imap_hcache_open (IMAP_DATA* idata);
+void imap_hcache_close (IMAP_DATA* idata);
HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid);
int imap_hcache_put (IMAP_DATA* idata, HEADER* h);
int imap_hcache_del (IMAP_DATA* idata, unsigned int uid);
idata->newMailCount = 0;
#if USE_HCACHE
+ imap_hcache_open (idata);
+
if (idata->hcache && !msgbegin)
{
uid_validity = mutt_hcache_fetch_raw (idata->hcache, "/UIDVALIDITY", imap_hcache_keylen);
{
if (h.data)
imap_free_header_data ((void**) (void*) &h.data);
+ imap_hcache_close (idata);
fclose (fp);
return -1;
}
{
if (h.data)
imap_free_header_data ((void**) (void*) &h.data);
+#if USE_HCACHE
+ imap_hcache_close (idata);
+#endif
fclose (fp);
return -1;
}
if (idata->uidnext > 1)
mutt_hcache_store_raw (idata->hcache, "/UIDNEXT", &idata->uidnext,
sizeof (idata->uidnext), imap_hcache_keylen);
+
+ imap_hcache_close (idata);
#endif /* USE_HCACHE */
fclose(fp);
}
#ifdef USE_HCACHE
-header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path)
+int imap_hcache_open (IMAP_DATA* idata)
{
IMAP_MBOX mx;
ciss_url_t url;
char cachepath[LONG_STRING];
- if (imap_parse_path (path, &mx) < 0)
- return NULL;
+ if (imap_parse_path (idata->ctx->path, &mx) < 0)
+ return -1;
mutt_account_tourl (&idata->conn->account, &url);
url.path = mx.mbox;
url_ciss_tostring (&url, cachepath, sizeof (cachepath), 0);
FREE (&mx.mbox);
- return mutt_hcache_open (HeaderCache, cachepath);
+ idata->hcache = mutt_hcache_open (HeaderCache, cachepath);
+
+ return idata->hcache != NULL ? 0 : -1;
+}
+
+void imap_hcache_close (IMAP_DATA* idata)
+{
+ if (!idata->hcache)
+ return;
+
+ mutt_hcache_close (idata->hcache);
+ idata->hcache = NULL;
}
HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid)