summaryrefslogtreecommitdiffstats
path: root/imap
diff options
context:
space:
mode:
authorBrendan Cully <brendan@kublai.com>2007-04-02 10:48:47 -0700
committerBrendan Cully <brendan@kublai.com>2007-04-02 10:48:47 -0700
commiteb07585965b8e50270703346a7fc67d2c4f35d67 (patch)
tree13cbf36ba6e2d2832464a2fe8e6065c87ef6581e /imap
parent9cc101727c98367deb847e78c4cf360473284f57 (diff)
Add create flag to imap_mboxcache_get
Diffstat (limited to 'imap')
-rw-r--r--imap/command.c14
-rw-r--r--imap/imap.c38
-rw-r--r--imap/imap_private.h3
-rw-r--r--imap/message.c2
4 files changed, 24 insertions, 33 deletions
diff --git a/imap/command.c b/imap/command.c
index dbd76ca5..7f23a894 100644
--- a/imap/command.c
+++ b/imap/command.c
@@ -819,23 +819,15 @@ static void cmd_parse_status (IMAP_DATA* idata, char* s)
BUFFY* inc;
IMAP_MBOX mx;
int count;
- IMAP_STATUS *status, sb;
- int olduv, oldun;
+ IMAP_STATUS *status;
+ unsigned int olduv, oldun;
mailbox = imap_next_word (s);
s = imap_next_word (mailbox);
*(s - 1) = '\0';
imap_unmunge_mbox_name (mailbox);
- if (!(status = imap_mboxcache_get (idata, mailbox)))
- {
- /* ugly interface - why should I look up what I just added? */
- memset (&sb, 0, sizeof (IMAP_STATUS));
- sb.name = mailbox;
- idata->mboxcache = mutt_add_list_n (idata->mboxcache, &sb, sizeof (IMAP_STATUS));
- status = imap_mboxcache_get (idata, mailbox);
- status->name = safe_strdup (mailbox);
- }
+ status = imap_mboxcache_get (idata, mailbox, 1);
olduv = status->uidvalidity;
oldun = status->uidnext;
diff --git a/imap/imap.c b/imap/imap.c
index 8f702d68..34f292a9 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -85,7 +85,7 @@ int imap_access (const char* path, int flags)
}
FREE (&mx.mbox);
- if (imap_mboxcache_get (idata, mailbox))
+ if (imap_mboxcache_get (idata, mailbox, 0))
{
dprint (3, (debugfile, "imap_access: found %s in cache\n", mailbox));
return 0;
@@ -556,7 +556,7 @@ int imap_open_mailbox (CONTEXT* ctx)
{
CONNECTION *conn;
IMAP_DATA *idata;
- IMAP_STATUS* status, sb;
+ IMAP_STATUS* status;
char buf[LONG_STRING];
char bufout[LONG_STRING];
int count = 0;
@@ -632,14 +632,8 @@ int imap_open_mailbox (CONTEXT* ctx)
imap_cmd_start (idata, bufout);
- if (!(status = imap_mboxcache_get (idata, idata->mailbox)))
- {
- memset (&sb, 0, sizeof (IMAP_STATUS));
- sb.name = idata->mailbox;
- idata->mboxcache = mutt_add_list_n (idata->mboxcache, &sb, sizeof (IMAP_STATUS));
- status = imap_mboxcache_get (idata, idata->mailbox);
- status->name = safe_strdup (idata->mailbox);
- }
+ status = imap_mboxcache_get (idata, idata->mailbox, 1);
+
do
{
char *pc;
@@ -1570,14 +1564,14 @@ int imap_status (char* path, int queue)
imap_exec (idata, buf, 0);
queued = 0;
- if ((status = imap_mboxcache_get (idata, mbox)))
+ if ((status = imap_mboxcache_get (idata, mbox, 0)))
return status->messages;
return 0;
}
-/* return cached mailbox stats or NULL */
-IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox)
+/* return cached mailbox stats or NULL if create is 0 */
+IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox, int create)
{
LIST* cur;
IMAP_STATUS* status;
@@ -1600,6 +1594,17 @@ IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox)
}
status = NULL;
+ /* lame */
+ if (create)
+ {
+ memset (&scache, 0, sizeof (scache));
+ scache.name = (char*)mbox;
+ idata->mboxcache = mutt_add_list_n (idata->mboxcache, &scache,
+ sizeof (scache));
+ status = imap_mboxcache_get (idata, mbox, 0);
+ status->name = safe_strdup (mbox);
+ }
+
#ifdef USE_HCACHE
path = safe_strdup (idata->ctx->path);
url_parse_ciss (&url, path);
@@ -1613,13 +1618,6 @@ IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox)
uidnext = mutt_hcache_fetch_raw (hc, "/UIDNEXT", imap_hcache_keylen);
if (uidvalidity)
{
- /* lame */
- memset (&scache, 0, sizeof (scache));
- scache.name = (char*)mbox;
- idata->mboxcache = mutt_add_list_n (idata->mboxcache, &scache,
- sizeof (scache));
- status = imap_mboxcache_get (idata, mbox);
- status->name = safe_strdup (mbox);
status->uidvalidity = *uidvalidity;
status->uidnext = uidnext ? *uidnext: 0;
dprint (3, (debugfile, "mboxcache: hcache uidvalidity %d, uidnext %d\n",
diff --git a/imap/imap_private.h b/imap/imap_private.h
index 6b945933..c7a6b876 100644
--- a/imap/imap_private.h
+++ b/imap/imap_private.h
@@ -230,7 +230,8 @@ typedef struct
/* imap.c */
int imap_create_mailbox (IMAP_DATA* idata, char* mailbox);
int imap_rename_mailbox (IMAP_DATA* idata, IMAP_MBOX* mx, const char* newname);
-IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox);
+IMAP_STATUS* imap_mboxcache_get (IMAP_DATA* idata, const char* mbox,
+ int create);
void imap_mboxcache_free (IMAP_DATA* idata);
int imap_make_msg_set (IMAP_DATA* idata, BUFFER* buf, int flag, int changed,
int invert);
diff --git a/imap/message.c b/imap/message.c
index 4a48c452..5f997418 100644
--- a/imap/message.c
+++ b/imap/message.c
@@ -327,7 +327,7 @@ int imap_read_headers (IMAP_DATA* idata, int msgbegin, int msgend)
}
}
- if (maxuid && (status = imap_mboxcache_get (idata, idata->mailbox)))
+ if (maxuid && (status = imap_mboxcache_get (idata, idata->mailbox, 0)))
status->uidnext = maxuid + 1;
#if USE_HCACHE