Skip to content

Commit

Permalink
tidy upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
flatcap committed Sep 3, 2018
1 parent 3a4af59 commit a4dc02b
Show file tree
Hide file tree
Showing 14 changed files with 297 additions and 234 deletions.
2 changes: 1 addition & 1 deletion email/parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "mutt/mutt.h"

/**
* struct ParameterList - List of parameters.
* struct ParameterList - List of parameters
*/
TAILQ_HEAD(ParameterList, Parameter);

Expand Down
4 changes: 2 additions & 2 deletions globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ WHERE bool Header; ///< Config: Include the message head
WHERE bool Help; ///< Config: Display a help line with common key bindings
#ifdef USE_IMAP
WHERE bool ImapCheckSubscribed; ///< Config: (imap) When opening a mailbox, ask the server for a list of subscribed folders
WHERE bool ImapCondStore;
WHERE bool ImapCondStore; ///< Config: (imap) Enable the CONDSTORE extension
WHERE bool ImapListSubscribed; ///< Config: (imap) When browsing a mailbox, only display subscribed folders
WHERE bool ImapPassive; ///< Config: (imap) Reuse an existing IMAP connection to check for new mail
WHERE bool ImapPeek; ///< Config: (imap) Don't mark messages as read when fetching them from the server
WHERE bool ImapQResync;
WHERE bool ImapQResync; ///< Config: (imap) Enable the QRESYNC extension
#endif
#ifdef USE_SSL
#ifndef USE_SSL_GNUTLS
Expand Down
42 changes: 22 additions & 20 deletions imap/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,29 +275,31 @@ static void cmd_parse_expunge(struct ImapData *idata, const char *s)
idata->reopen |= IMAP_EXPUNGE_PENDING;
}

/* cmd_parse_vanished: handles VANISHED (RFC 7162), which is like
* expunge, but passes a seqset of UIDs. An optional (EARLIER) argument
* specifies not to decrement subsequent MSNs. */
/**
* cmd_parse_vanished - Parse vanished command
* @param idata Server data
* @param s String containing MSN of message to expunge
*
* Handle VANISHED (RFC7162), which is like expunge, but passes a seqset of UIDs.
* An optional (EARLIER) argument specifies not to decrement subsequent MSNs.
*/
static void cmd_parse_vanished(struct ImapData *idata, char *s)
{
int earlier = 0, rc;
char *end_of_seqset;
struct SeqsetIterator *iter;
unsigned int uid, exp_msn, cur;
struct Header *h;
bool earlier = false;
int rc;
unsigned int uid = 0;

mutt_debug(2, "Handling VANISHED\n");

if (mutt_str_strncasecmp("(EARLIER)", s, 9) == 0)
{
/* The RFC says we should not decrement msns with the VANISHED EARLIER tag.
* My experimentation says that's crap. */
/* earlier = 1; */
earlier = 1;
earlier = true;
s = imap_next_word(s);
}

end_of_seqset = s;
char *end_of_seqset = s;
while (*end_of_seqset)
{
if (!strchr("0123456789:,", *end_of_seqset))
Expand All @@ -306,7 +308,7 @@ static void cmd_parse_vanished(struct ImapData *idata, char *s)
end_of_seqset++;
}

iter = mutt_seqset_iterator_new(s);
struct SeqsetIterator *iter = mutt_seqset_iterator_new(s);
if (!iter)
{
mutt_debug(2, "VANISHED: empty seqset [%s]?\n", s);
Expand All @@ -315,19 +317,19 @@ static void cmd_parse_vanished(struct ImapData *idata, char *s)

while ((rc = mutt_seqset_iterator_next(iter, &uid)) == 0)
{
h = (struct Header *) mutt_hash_int_find(idata->uid_hash, uid);
struct Header *h = mutt_hash_int_find(idata->uid_hash, uid);
if (!h)
continue;

exp_msn = HEADER_DATA(h)->msn;
unsigned int exp_msn = HEADER_DATA(h)->msn;

/* imap_expunge_mailbox() will rewrite h->index.
* It needs to resort using SORT_ORDER anyway, so setting to INT_MAX
* makes the code simpler and possibly more efficient. */
h->index = INT_MAX;
HEADER_DATA(h)->msn = 0;

if (exp_msn < 1 || exp_msn > idata->max_msn)
if ((exp_msn < 1) || (exp_msn > idata->max_msn))
{
mutt_debug(1, "VANISHED: msn for UID %u is incorrect.\n", uid);
continue;
Expand All @@ -343,7 +345,7 @@ static void cmd_parse_vanished(struct ImapData *idata, char *s)
if (!earlier)
{
/* decrement seqno of those above. */
for (cur = exp_msn; cur < idata->max_msn; cur++)
for (unsigned int cur = exp_msn; cur < idata->max_msn; cur++)
{
h = idata->msn_index[cur];
if (h)
Expand Down Expand Up @@ -467,7 +469,7 @@ static void cmd_parse_fetch(struct ImapData *idata, char *s)
SKIPWS(s);
if (*s != '(')
{
mutt_debug(1, "cmd_parse_fetch: bogus MODSEQ response: %s\n", s);
mutt_debug(1, "bogus MODSEQ response: %s\n", s);
return;
}
s++;
Expand All @@ -477,7 +479,7 @@ static void cmd_parse_fetch(struct ImapData *idata, char *s)
s++;
else
{
mutt_debug(1, "cmd_parse_fetch: Unterminated MODSEQ response: %s\n", s);
mutt_debug(1, "Unterminated MODSEQ response: %s\n", s);
return;
}
}
Expand Down Expand Up @@ -1012,7 +1014,7 @@ static int cmd_handle_untagged(struct ImapData *idata)
else if (mutt_str_strncasecmp("FETCH", s, 5) == 0)
cmd_parse_fetch(idata, pn);
}
else if ((idata->state >= IMAP_SELECTED) && mutt_str_strncasecmp("VANISHED", s, 8) == 0)
else if ((idata->state >= IMAP_SELECTED) && (mutt_str_strncasecmp("VANISHED", s, 8) == 0))
cmd_parse_vanished(idata, pn);
else if (mutt_str_strncasecmp("CAPABILITY", s, 10) == 0)
cmd_parse_capability(idata, s);
Expand Down Expand Up @@ -1332,7 +1334,7 @@ void imap_cmd_finish(struct ImapData *idata)
/* check_status: curs_main uses imap_check_mailbox to detect
* whether the index needs updating */
idata->check_status = IMAP_NEWMAIL_PENDING;
imap_read_headers(idata, idata->max_msn + 1, count, 0);
imap_read_headers(idata, idata->max_msn + 1, count, false);
}
else if (idata->reopen & IMAP_EXPUNGE_PENDING)
{
Expand Down
33 changes: 13 additions & 20 deletions imap/imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ int imap_access(const char *path)
}
FREE(&mx.mbox);

if (imap_mboxcache_get(idata, mailbox, 0))
if (imap_mboxcache_get(idata, mailbox, false))
{
mutt_debug(3, "found %s in cache\n", mailbox);
return 0;
Expand Down Expand Up @@ -1581,7 +1581,7 @@ int imap_status(const char *path, bool queue)
imap_exec(idata, buf, 0);

queued = 0;
status = imap_mboxcache_get(idata, mbox, 0);
status = imap_mboxcache_get(idata, mbox, false);
if (status)
return status->messages;

Expand All @@ -1602,13 +1602,6 @@ int imap_status(const char *path, bool queue)
struct ImapStatus *imap_mboxcache_get(struct ImapData *idata, const char *mbox, bool create)
{
struct ImapStatus *status = NULL;
#ifdef USE_HCACHE
header_cache_t *hc = NULL;
void *uidvalidity = NULL;
void *uidnext = NULL;
unsigned long long *modseq = NULL;
#endif

struct ListNode *np = NULL;
STAILQ_FOREACH(np, &idata->mboxcache, entries)
{
Expand All @@ -1625,17 +1618,17 @@ struct ImapStatus *imap_mboxcache_get(struct ImapData *idata, const char *mbox,
struct ImapStatus *scache = mutt_mem_calloc(1, sizeof(struct ImapStatus));
scache->name = (char *) mbox;
mutt_list_insert_tail(&idata->mboxcache, (char *) scache);
status = imap_mboxcache_get(idata, mbox, 0);
status = imap_mboxcache_get(idata, mbox, false);
status->name = mutt_str_strdup(mbox);
}

#ifdef USE_HCACHE
hc = imap_hcache_open(idata, mbox);
header_cache_t *hc = imap_hcache_open(idata, mbox);
if (hc)
{
uidvalidity = mutt_hcache_fetch_raw(hc, "/UIDVALIDITY", 12);
uidnext = mutt_hcache_fetch_raw(hc, "/UIDNEXT", 8);
modseq = mutt_hcache_fetch_raw(hc, "/MODSEQ", 7);
void *uidvalidity = mutt_hcache_fetch_raw(hc, "/UIDVALIDITY", 12);
void *uidnext = mutt_hcache_fetch_raw(hc, "/UIDNEXT", 8);
unsigned long long *modseq = mutt_hcache_fetch_raw(hc, "/MODSEQ", 7);
if (uidvalidity)
{
if (!status)
Expand All @@ -1644,13 +1637,13 @@ struct ImapStatus *imap_mboxcache_get(struct ImapData *idata, const char *mbox,
mutt_hcache_free(hc, &uidnext);
mutt_hcache_free(hc, (void **) &modseq);
mutt_hcache_close(hc);
return imap_mboxcache_get(idata, mbox, 1);
return imap_mboxcache_get(idata, mbox, true);
}
status->uidvalidity = *(unsigned int *) uidvalidity;
status->uidnext = uidnext ? *(unsigned int *) uidnext : 0;
status->modseq = modseq ? *modseq : 0;
mutt_debug(3, "mboxcache: hcache uidvalidity %u, uidnext %u, modseq %llu\n",
status->uidvalidity, status->uidnext, status->modseq);
mutt_debug(3, "hcache uidvalidity %u, uidnext %u, modseq %llu\n",
status->uidvalidity, status->uidnext, status->modseq);
}
mutt_hcache_free(hc, &uidvalidity);
mutt_hcache_free(hc, &uidnext);
Expand Down Expand Up @@ -2079,7 +2072,7 @@ static int imap_mbox_open(struct Context *ctx)
if (ImapCheckSubscribed)
imap_exec(idata, "LSUB \"\" \"*\"", IMAP_CMD_QUEUE);

#if USE_HCACHE
#ifdef USE_HCACHE
if (mutt_bit_isset(idata->capabilities, CONDSTORE) && ImapCondStore)
condstore = " (CONDSTORE)";
else
Expand All @@ -2093,7 +2086,7 @@ static int imap_mbox_open(struct Context *ctx)

imap_cmd_start(idata, bufout);

status = imap_mboxcache_get(idata, idata->mailbox, 1);
status = imap_mboxcache_get(idata, idata->mailbox, true);

do
{
Expand Down Expand Up @@ -2226,7 +2219,7 @@ static int imap_mbox_open(struct Context *ctx)
ctx->v2r = mutt_mem_calloc(count, sizeof(int));
ctx->msgcount = 0;

if (count && (imap_read_headers(idata, 1, count, 1) < 0))
if (count && (imap_read_headers(idata, 1, count, true) < 0))
{
mutt_error(_("Error opening mailbox"));
goto fail;
Expand Down
1 change: 1 addition & 0 deletions imap/imap.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* | imap/auth_cram.c | @subpage imap_auth_cram |
* | imap/auth_gss.c | @subpage imap_auth_gss |
* | imap/auth_login.c | @subpage imap_auth_login |
* | imap/auth_oauth.c | @subpage imap_auth_oauth |
* | imap/auth_plain.c | @subpage imap_auth_plain |
* | imap/auth_sasl.c | @subpage imap_auth_sasl |
* | imap/browse.c | @subpage imap_browse |
Expand Down
24 changes: 14 additions & 10 deletions imap/imap_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,19 @@ struct ImapData
#endif
};

/**
* struct SeqsetIterator - UID Sequence Set Iterator
*/
struct SeqsetIterator
{
char *full_seqset;
char *eostr;
int in_range;
int down;
unsigned int range_cur, range_end;
char *substr_cur, *substr_end;
unsigned int range_cur;
unsigned int range_end;
char *substr_cur;
char *substr_end;
};

/* -- private IMAP functions -- */
Expand Down Expand Up @@ -314,8 +319,7 @@ int imap_cmd_idle(struct ImapData *idata);

/* message.c */
void imap_free_header_data(struct ImapHeaderData **data);
int imap_read_headers (struct ImapData* idata, unsigned int msn_begin, unsigned int msn_end,
int initial_download);
int imap_read_headers(struct ImapData *idata, unsigned int msn_begin, unsigned int msn_end, bool initial_download);
char *imap_set_flags(struct ImapData *idata, struct Header *h, char *s, int *server_changes);
int imap_cache_del(struct ImapData *idata, struct Header *h);
int imap_cache_clean(struct ImapData *idata);
Expand All @@ -332,9 +336,9 @@ void imap_hcache_close(struct ImapData *idata);
struct Header *imap_hcache_get(struct ImapData *idata, unsigned int uid);
int imap_hcache_put(struct ImapData *idata, struct Header *h);
int imap_hcache_del(struct ImapData *idata, unsigned int uid);
int imap_hcache_store_uid_seqset (struct ImapData *idata);
int imap_hcache_clear_uid_seqset (struct ImapData *idata);
char *imap_hcache_get_uid_seqset (struct ImapData *idata);
int imap_hcache_store_uid_seqset(struct ImapData *idata);
int imap_hcache_clear_uid_seqset(struct ImapData *idata);
char *imap_hcache_get_uid_seqset(struct ImapData *idata);
#endif

int imap_continue(const char *msg, const char *resp);
Expand All @@ -352,9 +356,9 @@ void imap_quote_string(char *dest, size_t dlen, const char *src, bool quote_back
void imap_unquote_string(char *s);
void imap_munge_mbox_name(struct ImapData *idata, char *dest, size_t dlen, const char *src);
void imap_unmunge_mbox_name(struct ImapData *idata, char *s);
struct SeqsetIterator *mutt_seqset_iterator_new (const char *seqset);
int mutt_seqset_iterator_next (struct SeqsetIterator *iter, unsigned int *next);
void mutt_seqset_iterator_free (struct SeqsetIterator **p_iter);
struct SeqsetIterator *mutt_seqset_iterator_new(const char *seqset);
int mutt_seqset_iterator_next(struct SeqsetIterator *iter, unsigned int *next);
void mutt_seqset_iterator_free(struct SeqsetIterator **p_iter);
int imap_account_match(const struct Account *a1, const struct Account *a2);
void imap_get_parent(const char *mbox, char delim, char *buf, size_t buflen);

Expand Down
Loading

0 comments on commit a4dc02b

Please sign in to comment.