switch (flag)
{
case MUTT_DELETED:
- if (emails[n]->deleted != IMAP_EDATA(emails[n])->deleted)
+ if (emails[n]->deleted != imap_edata_get(emails[n])->deleted)
match = invert ^ emails[n]->deleted;
break;
case MUTT_FLAG:
- if (emails[n]->flagged != IMAP_EDATA(emails[n])->flagged)
+ if (emails[n]->flagged != imap_edata_get(emails[n])->flagged)
match = invert ^ emails[n]->flagged;
break;
case MUTT_OLD:
- if (emails[n]->old != IMAP_EDATA(emails[n])->old)
+ if (emails[n]->old != imap_edata_get(emails[n])->old)
match = invert ^ emails[n]->old;
break;
case MUTT_READ:
- if (emails[n]->read != IMAP_EDATA(emails[n])->read)
+ if (emails[n]->read != imap_edata_get(emails[n])->read)
match = invert ^ emails[n]->read;
break;
case MUTT_REPLIED:
- if (emails[n]->replied != IMAP_EDATA(emails[n])->replied)
+ if (emails[n]->replied != imap_edata_get(emails[n])->replied)
match = invert ^ emails[n]->replied;
break;
case MUTT_TAG:
count++;
if (setstart == 0)
{
- setstart = IMAP_EDATA(emails[n])->uid;
+ setstart = imap_edata_get(emails[n])->uid;
if (!started)
{
- mutt_buffer_add_printf(buf, "%u", IMAP_EDATA(emails[n])->uid);
+ mutt_buffer_add_printf(buf, "%u", imap_edata_get(emails[n])->uid);
started = true;
}
else
- mutt_buffer_add_printf(buf, ",%u", IMAP_EDATA(emails[n])->uid);
+ mutt_buffer_add_printf(buf, ",%u", imap_edata_get(emails[n])->uid);
}
/* tie up if the last message also matches */
else if (n == adata->mailbox->msg_count - 1)
- mutt_buffer_add_printf(buf, ":%u", IMAP_EDATA(emails[n])->uid);
+ mutt_buffer_add_printf(buf, ":%u", imap_edata_get(emails[n])->uid);
}
/* End current set if message doesn't match or we've reached the end
* of the mailbox via inactive messages following the last match. */
else if (setstart && (emails[n]->active || n == adata->mailbox->msg_count - 1))
{
- if (IMAP_EDATA(emails[n - 1])->uid > setstart)
- mutt_buffer_add_printf(buf, ":%u", IMAP_EDATA(emails[n - 1])->uid);
+ if (imap_edata_get(emails[n - 1])->uid > setstart)
+ mutt_buffer_add_printf(buf, ":%u", imap_edata_get(emails[n - 1])->uid);
setstart = 0;
}
}
/**
* compile_search - Convert NeoMutt pattern to IMAP search
- * @param mailbox Mailbox
- * @param pat Pattern to convert
- * @param buf Buffer for result
+ * @param m Mailbox
+ * @param pat Pattern to convert
+ * @param buf Buffer for result
* @retval 0 Success
* @retval -1 Failure
*
* that require full-text search (neomutt already has what it needs for most
* match types, and does a better job (eg server doesn't support regexes).
*/
-static int compile_search(struct Mailbox *mailbox, const struct Pattern *pat,
- struct Buffer *buf)
+static int compile_search(struct Mailbox *m, const struct Pattern *pat, struct Buffer *buf)
{
if (do_search(pat, 0) == 0)
return 0;
mutt_buffer_addstr(buf, "OR ");
clauses--;
- if (compile_search(mailbox, clause, buf) < 0)
+ if (compile_search(m, clause, buf) < 0)
return -1;
if (clauses)
break;
case MUTT_SERVERSEARCH:
{
- struct ImapAccountData *adata = imap_get_adata(mailbox);
+ struct ImapAccountData *adata = imap_adata_get(m);
if (!mutt_bit_isset(adata->capabilities, X_GM_EXT1))
{
mutt_error(_("Server-side custom search not supported: %s"), pat->p.str);
/**
* imap_delete_mailbox - Delete a mailbox
- * @param mailbox Mailbox
- * @param mx Mailbox to delete
+ * @param m Mailbox
+ * @param im Mailbox to delete
* @retval 0 Success
* @retval -1 Failure
*/
-int imap_delete_mailbox(struct Mailbox *mailbox, struct ImapMbox *mx)
+int imap_delete_mailbox(struct Mailbox *m, struct ImapMbox *im)
{
char buf[PATH_MAX], mbox[PATH_MAX];
- struct ImapAccountData *adata = imap_get_adata(mailbox);
+ struct ImapAccountData *adata = imap_adata_get(m);
- if (!mailbox || !adata)
+ if (!m || !adata)
{
- adata = imap_conn_find(&mx->account, ImapPassive ? MUTT_IMAP_CONN_NONEW : 0);
+ adata = imap_conn_find(&im->account, ImapPassive ? MUTT_IMAP_CONN_NONEW : 0);
if (!adata)
{
- FREE(&mx->mbox);
+ FREE(&im->mbox);
return -1;
}
}
else
{
- adata = mailbox->mdata;
+ adata = m->mdata;
}
- imap_munge_mbox_name(adata, mbox, sizeof(mbox), mx->mbox);
+ imap_munge_mbox_name(adata, mbox, sizeof(mbox), im->mbox);
snprintf(buf, sizeof(buf), "DELETE %s", mbox);
if (imap_exec(adata, buf, 0) != 0)
if (e->index == INT_MAX)
{
- mutt_debug(2, "Expunging message UID %u.\n", IMAP_EDATA(e)->uid);
+ mutt_debug(2, "Expunging message UID %u.\n", imap_edata_get(e)->uid);
e->active = false;
adata->mailbox->size -= e->content->length;
imap_cache_del(adata, e);
#ifdef USE_HCACHE
- imap_hcache_del(adata, IMAP_EDATA(e)->uid);
+ imap_hcache_del(adata, imap_edata_get(e)->uid);
#endif
/* free cached body from disk, if necessary */
- cacheno = IMAP_EDATA(e)->uid % IMAP_CACHE_LEN;
- if (adata->cache[cacheno].uid == IMAP_EDATA(e)->uid &&
+ cacheno = imap_edata_get(e)->uid % IMAP_CACHE_LEN;
+ if (adata->cache[cacheno].uid == imap_edata_get(e)->uid &&
adata->cache[cacheno].path)
{
unlink(adata->cache[cacheno].path);
FREE(&adata->cache[cacheno].path);
}
- mutt_hash_int_delete(adata->uid_hash, IMAP_EDATA(e)->uid, e);
+ mutt_hash_int_delete(adata->uid_hash, imap_edata_get(e)->uid, e);
- imap_free_emaildata((void **) &e->edata);
+ imap_edata_free((void **) &e->edata);
}
else
{
if (!compare_flags_for_copy(e))
{
- if (e->deleted == IMAP_EDATA(e)->deleted)
+ if (e->deleted == imap_edata_get(e)->deleted)
e->changed = false;
return 0;
}
- snprintf(uid, sizeof(uid), "%u", IMAP_EDATA(e)->uid);
+ snprintf(uid, sizeof(uid), "%u", imap_edata_get(e)->uid);
cmd->dptr = cmd->data;
mutt_buffer_addstr(cmd, "UID STORE ");
mutt_buffer_addstr(cmd, uid);
set_flag(adata, MUTT_ACL_WRITE, e->old, "Old ", flags, sizeof(flags));
set_flag(adata, MUTT_ACL_WRITE, e->flagged, "\\Flagged ", flags, sizeof(flags));
set_flag(adata, MUTT_ACL_WRITE, e->replied, "\\Answered ", flags, sizeof(flags));
- set_flag(adata, MUTT_ACL_DELETE, IMAP_EDATA(e)->deleted, "\\Deleted ", flags,
- sizeof(flags));
+ set_flag(adata, MUTT_ACL_DELETE, imap_edata_get(e)->deleted, "\\Deleted ",
+ flags, sizeof(flags));
if (mutt_bit_isset(adata->mailbox->rights, MUTT_ACL_WRITE))
{
/* restore system flags */
- if (IMAP_EDATA(e)->flags_system)
- mutt_str_strcat(flags, sizeof(flags), IMAP_EDATA(e)->flags_system);
+ if (imap_edata_get(e)->flags_system)
+ mutt_str_strcat(flags, sizeof(flags), imap_edata_get(e)->flags_system);
/* set custom flags */
tags = driver_tags_get_with_hidden(&e->tags);
if (tags)
set_flag(adata, MUTT_ACL_WRITE, 1, "Old ", flags, sizeof(flags));
set_flag(adata, MUTT_ACL_WRITE, 1, "\\Flagged ", flags, sizeof(flags));
set_flag(adata, MUTT_ACL_WRITE, 1, "\\Answered ", flags, sizeof(flags));
- set_flag(adata, MUTT_ACL_DELETE, !IMAP_EDATA(e)->deleted, "\\Deleted ",
+ set_flag(adata, MUTT_ACL_DELETE, !imap_edata_get(e)->deleted, "\\Deleted ",
flags, sizeof(flags));
/* erase custom flags */
- if (mutt_bit_isset(adata->mailbox->rights, MUTT_ACL_WRITE) && IMAP_EDATA(e)->flags_remote)
- mutt_str_strcat(flags, sizeof(flags), IMAP_EDATA(e)->flags_remote);
+ if (mutt_bit_isset(adata->mailbox->rights, MUTT_ACL_WRITE) &&
+ imap_edata_get(e)->flags_remote)
+ mutt_str_strcat(flags, sizeof(flags), imap_edata_get(e)->flags_remote);
mutt_str_remove_trailing_ws(flags);
}
/* server have now the updated flags */
- FREE(&IMAP_EDATA(e)->flags_remote);
- IMAP_EDATA(e)->flags_remote = driver_tags_get_with_hidden(&e->tags);
+ FREE(&imap_edata_get(e)->flags_remote);
+ imap_edata_get(e)->flags_remote = driver_tags_get_with_hidden(&e->tags);
e->active = true;
- if (e->deleted == IMAP_EDATA(e)->deleted)
+ if (e->deleted == imap_edata_get(e)->deleted)
e->changed = false;
return 0;
/**
* imap_check_mailbox - use the NOOP or IDLE command to poll for new mail
- * @param mailbox Mailbox
- * @param force Don't wait
+ * @param m Mailbox
+ * @param force Don't wait
* @retval #MUTT_REOPENED mailbox has been externally modified
* @retval #MUTT_NEW_MAIL new mail has arrived
* @retval 0 no change
* @retval -1 error
*/
-int imap_check_mailbox(struct Mailbox *mailbox, bool force)
+int imap_check_mailbox(struct Mailbox *m, bool force)
{
- struct ImapAccountData *adata = imap_get_adata(mailbox);
+ struct ImapAccountData *adata = imap_adata_get(m);
return imap_check(adata, force);
}
/**
* imap_search - Find a matching mailbox
- * @param mailbox Mailbox
+ * @param m Mailbox
* @param pat Pattern to match
* @retval 0 Success
* @retval -1 Failure
*/
-int imap_search(struct Mailbox *mailbox, const struct Pattern *pat)
+int imap_search(struct Mailbox *m, const struct Pattern *pat)
{
struct Buffer buf;
- struct ImapAccountData *adata = imap_get_adata(mailbox);
- for (int i = 0; i < mailbox->msg_count; i++)
- mailbox->hdrs[i]->matched = false;
+ struct ImapAccountData *adata = imap_adata_get(m);
+ for (int i = 0; i < m->msg_count; i++)
+ m->hdrs[i]->matched = false;
if (do_search(pat, 1) == 0)
return 0;
mutt_buffer_init(&buf);
mutt_buffer_addstr(&buf, "UID SEARCH ");
- if (compile_search(mailbox, pat, &buf) < 0)
+ if (compile_search(m, pat, &buf) < 0)
{
FREE(&buf.data);
return -1;
/**
* imap_fast_trash - Use server COPY command to copy deleted messages to trash
- * @param mailbox Mailbox
- * @param dest Mailbox to move to
+ * @param m Mailbox
+ * @param dest Mailbox to move to
* @retval -1 Error
* @retval 0 Success
* @retval 1 Non-fatal error - try fetch/append
*/
-int imap_fast_trash(struct Mailbox *mailbox, char *dest)
+int imap_fast_trash(struct Mailbox *m, char *dest)
{
char mbox[LONG_STRING];
char mmbox[LONG_STRING];
struct Buffer *sync_cmd = NULL;
int err_continue = MUTT_NO;
- struct ImapAccountData *adata = imap_get_adata(mailbox);
+ struct ImapAccountData *adata = imap_adata_get(m);
if (imap_parse_path(dest, &mx))
{
/* check that the save-to folder is in the same account */
if (!mutt_account_match(&(adata->conn->account), &(mx.account)))
{
- mutt_debug(3, "%s not same server as %s\n", dest, mailbox->path);
+ mutt_debug(3, "%s not same server as %s\n", dest, m->path);
return 1;
}
imap_munge_mbox_name(adata, mmbox, sizeof(mmbox), mbox);
sync_cmd = mutt_buffer_new();
- for (int i = 0; i < mailbox->msg_count; i++)
+ for (int i = 0; i < m->msg_count; i++)
{
- if (mailbox->hdrs[i]->active && mailbox->hdrs[i]->changed &&
- mailbox->hdrs[i]->deleted && !mailbox->hdrs[i]->purge)
+ if (m->hdrs[i]->active && m->hdrs[i]->changed && m->hdrs[i]->deleted &&
+ !m->hdrs[i]->purge)
{
- rc = imap_sync_message_for_copy(adata, mailbox->hdrs[i], sync_cmd, &err_continue);
+ rc = imap_sync_message_for_copy(adata, m->hdrs[i], sync_cmd, &err_continue);
if (rc < 0)
{
mutt_debug(1, "could not sync\n");
int oldsort;
int rc;
- struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
if (adata->state < IMAP_SELECTED)
{
{
imap_cache_del(adata, e);
#ifdef USE_HCACHE
- imap_hcache_del(adata, IMAP_EDATA(e)->uid);
+ imap_hcache_del(adata, imap_edata_get(e)->uid);
#endif
}
* there is no need to mutate the hcache after flag-only changes. */
for (int i = 0; i < ctx->mailbox->msg_count; i++)
{
- IMAP_EDATA(ctx->mailbox->hdrs[i])->deleted = ctx->mailbox->hdrs[i]->deleted;
- IMAP_EDATA(ctx->mailbox->hdrs[i])->flagged = ctx->mailbox->hdrs[i]->flagged;
- IMAP_EDATA(ctx->mailbox->hdrs[i])->old = ctx->mailbox->hdrs[i]->old;
- IMAP_EDATA(ctx->mailbox->hdrs[i])->read = ctx->mailbox->hdrs[i]->read;
- IMAP_EDATA(ctx->mailbox->hdrs[i])->replied = ctx->mailbox->hdrs[i]->replied;
+ imap_edata_get(ctx->mailbox->hdrs[i])->deleted = ctx->mailbox->hdrs[i]->deleted;
+ imap_edata_get(ctx->mailbox->hdrs[i])->flagged = ctx->mailbox->hdrs[i]->flagged;
+ imap_edata_get(ctx->mailbox->hdrs[i])->old = ctx->mailbox->hdrs[i]->old;
+ imap_edata_get(ctx->mailbox->hdrs[i])->read = ctx->mailbox->hdrs[i]->read;
+ imap_edata_get(ctx->mailbox->hdrs[i])->replied = ctx->mailbox->hdrs[i]->replied;
ctx->mailbox->hdrs[i]->changed = false;
}
ctx->mailbox->changed = false;
(void) index_hint;
imap_allow_reopen(ctx->mailbox);
- struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
int rc = imap_check(adata, false);
/* NOTE - ctx might have been changed at this point. In particular,
* ctx->mailbox could be NULL. Beware. */
*/
static int imap_mbox_close(struct Context *ctx)
{
- struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
/* Check to see if the mailbox is actually open */
if (!adata)
return 0;
{
char *new = NULL;
char *checker = NULL;
- struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
/* Check for \* flags capability */
if (!imap_has_flag(&adata->flags, NULL))
struct Buffer *cmd = NULL;
char uid[11];
- struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
if (*buf == '\0')
buf = NULL;
if (!mutt_bit_isset(adata->mailbox->rights, MUTT_ACL_WRITE))
return 0;
- snprintf(uid, sizeof(uid), "%u", IMAP_EDATA(e)->uid);
+ snprintf(uid, sizeof(uid), "%u", imap_edata_get(e)->uid);
/* Remove old custom flags */
- if (IMAP_EDATA(e)->flags_remote)
+ if (imap_edata_get(e)->flags_remote)
{
cmd = mutt_buffer_new();
if (!cmd)
mutt_buffer_addstr(cmd, "UID STORE ");
mutt_buffer_addstr(cmd, uid);
mutt_buffer_addstr(cmd, " -FLAGS.SILENT (");
- mutt_buffer_addstr(cmd, IMAP_EDATA(e)->flags_remote);
+ mutt_buffer_addstr(cmd, imap_edata_get(e)->flags_remote);
mutt_buffer_addstr(cmd, ")");
/* Should we return here, or we are fine and we could
/* We are good sync them */
mutt_debug(1, "NEW TAGS: %d\n", buf);
driver_tags_replace(&e->tags, buf);
- FREE(&IMAP_EDATA(e)->flags_remote);
- IMAP_EDATA(e)->flags_remote = driver_tags_get_with_hidden(&e->tags);
+ FREE(&imap_edata_get(e)->flags_remote);
+ imap_edata_get(e)->flags_remote = driver_tags_get_with_hidden(&e->tags);
return 0;
}
char *ImapHeaders; ///< Config: (imap) Additional email headers to download when getting index
/**
- * new_emaildata - Create a new ImapEmailData
+ * imap_edata_free - free ImapHeader structure
+ * @retval ptr Private Email data
+ */
+void imap_edata_free(void **ptr)
+{
+ if (!ptr || !*ptr)
+ return;
+
+ struct ImapEmailData *edata = *ptr;
+ /* this should be safe even if the list wasn't used */
+ FREE(&edata->flags_system);
+ FREE(&edata->flags_remote);
+ FREE(ptr);
+}
+
+/**
+ * imap_edata_new - Create a new ImapEmailData
* @retval ptr New ImapEmailData
*/
-static struct ImapEmailData *new_emaildata(void)
+static struct ImapEmailData *imap_edata_new(void)
{
return mutt_mem_calloc(1, sizeof(struct ImapEmailData));
}
+/**
+ * imap_edata_get - Get the private data for this Email
+ * @retval ptr Private Email data
+ */
+struct ImapEmailData *imap_edata_get(struct Email *e)
+{
+ if (!e)
+ return NULL;
+ return e->edata;
+}
+
/**
* msg_cache_open - Open a message cache
* @param adata Imap Account data
adata->bcache = msg_cache_open(adata);
char id[64];
- snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, IMAP_EDATA(e)->uid);
+ snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, imap_edata_get(e)->uid);
return mutt_bcache_get(adata->bcache, id);
}
adata->bcache = msg_cache_open(adata);
char id[64];
- snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, IMAP_EDATA(e)->uid);
+ snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, imap_edata_get(e)->uid);
return mutt_bcache_put(adata->bcache, id);
}
adata->bcache = msg_cache_open(adata);
char id[64];
- snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, IMAP_EDATA(e)->uid);
+ snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, imap_edata_get(e)->uid);
return mutt_bcache_commit(adata->bcache, id);
}
/**
* msg_fetch_header - import IMAP FETCH response into an ImapHeader
- * @param mailbox Mailbox
- * @param h ImapHeader
- * @param buf Server string containing FETCH response
- * @param fp Connection to server
+ * @param m Mailbox
+ * @param ih ImapHeader
+ * @param buf Server string containing FETCH response
+ * @param fp Connection to server
* @retval 0 Success
* @retval -1 String is not a fetch response
* @retval -2 String is a corrupt fetch response
*
* Expects string beginning with * n FETCH.
*/
-static int msg_fetch_header(struct Mailbox *mailbox, struct ImapHeader *h,
- char *buf, FILE *fp)
+static int msg_fetch_header(struct Mailbox *m, struct ImapHeader *ih, char *buf, FILE *fp)
{
unsigned int bytes;
int rc = -1; /* default now is that string isn't FETCH response */
int parse_rc;
- struct ImapAccountData *adata = imap_get_adata(mailbox);
+ struct ImapAccountData *adata = imap_adata_get(m);
if (buf[0] != '*')
return rc;
/* skip to message number */
buf = imap_next_word(buf);
- if (mutt_str_atoui(buf, &h->data->msn) < 0)
+ if (mutt_str_atoui(buf, &ih->data->msn) < 0)
return rc;
/* find FETCH tag */
/* FIXME: current implementation - call msg_parse_fetch - if it returns -2,
* read header lines and call it again. Silly. */
- parse_rc = msg_parse_fetch(h, buf);
+ parse_rc = msg_parse_fetch(ih, buf);
if (!parse_rc)
return 0;
if (parse_rc != -2 || !fp)
if (imap_cmd_step(adata) != IMAP_CMD_CONTINUE)
return rc;
- if (msg_parse_fetch(h, adata->buf) == -1)
+ if (msg_parse_fetch(ih, adata->buf) == -1)
return rc;
}
/* subtract headers from message size - unfortunately only the subset of
* headers we've requested. */
- h->content_length -= bytes;
+ ih->content_length -= bytes;
return rc;
}
mutt_progress_update(&progress, msgno, -1);
memset(&h, 0, sizeof(h));
- h.data = new_emaildata();
+ h.data = imap_edata_new();
do
{
rc = imap_cmd_step(adata);
}
} while (mfhrc == -1);
- imap_free_emaildata((void **) &h.data);
+ imap_edata_free((void **) &h.data);
if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK)))
return -1;
if (ctx->mailbox->msg_count >= ctx->mailbox->hdrmax)
mx_alloc_memory(ctx->mailbox);
- struct ImapEmailData *edata = new_emaildata();
+ struct ImapEmailData *edata = imap_edata_new();
e->edata = edata;
- e->free_edata = imap_free_emaildata;
+ e->free_edata = imap_edata_free;
e->index = ctx->mailbox->msg_count;
e->active = true;
rewind(fp);
memset(&h, 0, sizeof(h));
- h.data = new_emaildata();
+ h.data = imap_edata_new();
/* this DO loop does two things:
* 1. handles untagged messages, so we can try again on the same msg
idx++;
} while (mfhrc == -1);
- imap_free_emaildata((void **) &h.data);
+ imap_edata_free((void **) &h.data);
if ((mfhrc < -1) || ((rc != IMAP_CMD_CONTINUE) && (rc != IMAP_CMD_OK)))
goto bail;
struct ImapMbox mx;
int rc;
- struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
if (imap_parse_path(ctx->mailbox->path, &mx))
return -1;
int err_continue = MUTT_NO;
int triedcreate = 0;
- struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
if (imap_parse_path(dest, &mx))
{
else
{
mutt_message(_("Copying message %d to %s..."), e->index + 1, mbox);
- mutt_buffer_add_printf(&cmd, "UID COPY %u %s", IMAP_EDATA(e)->uid, mmbox);
+ mutt_buffer_add_printf(&cmd, "UID COPY %u %s", imap_edata_get(e)->uid, mmbox);
if (e->active && e->changed)
{
adata->bcache = msg_cache_open(adata);
char id[64];
- snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, IMAP_EDATA(e)->uid);
+ snprintf(id, sizeof(id), "%u-%u", adata->uid_validity, imap_edata_get(e)->uid);
return mutt_bcache_del(adata->bcache, id);
}
return 0;
}
-/**
- * imap_free_emaildata - free ImapHeader structure
- * @param data Header data to free
- */
-void imap_free_emaildata(void **data)
-{
- if (!data || !*data)
- return;
-
- struct ImapEmailData *edata = *data;
- /* this should be safe even if the list wasn't used */
- FREE(&edata->flags_system);
- FREE(&edata->flags_remote);
- FREE(data);
-}
-
/**
* imap_set_flags - fill the message header according to the server flags
* @param[in] adata Imap Account data
bool fetched = false;
int output_progress;
- struct ImapAccountData *adata = imap_get_adata(ctx->mailbox);
+ struct ImapAccountData *adata = imap_adata_get(ctx->mailbox);
struct Email *e = ctx->mailbox->hdrs[msgno];
msg->fp = msg_cache_get(adata, e);
if (msg->fp)
{
- if (IMAP_EDATA(e)->parsed)
+ if (imap_edata_get(e)->parsed)
return 0;
else
goto parsemsg;
/* we still do some caching even if imap_cachedir is unset */
/* see if we already have the message in our cache */
- cacheno = IMAP_EDATA(e)->uid % IMAP_CACHE_LEN;
+ cacheno = imap_edata_get(e)->uid % IMAP_CACHE_LEN;
cache = &adata->cache[cacheno];
if (cache->path)
{
/* don't treat cache errors as fatal, just fall back. */
- if (cache->uid == IMAP_EDATA(e)->uid && (msg->fp = fopen(cache->path, "r")))
+ if (cache->uid == imap_edata_get(e)->uid && (msg->fp = fopen(cache->path, "r")))
return 0;
else
{
msg->fp = msg_cache_put(adata, e);
if (!msg->fp)
{
- cache->uid = IMAP_EDATA(e)->uid;
+ cache->uid = imap_edata_get(e)->uid;
mutt_mktemp(path, sizeof(path));
cache->path = mutt_str_strdup(path);
msg->fp = mutt_file_fopen(path, "w+");
* command handler */
e->active = false;
- snprintf(buf, sizeof(buf), "UID FETCH %u %s", IMAP_EDATA(e)->uid,
+ snprintf(buf, sizeof(buf), "UID FETCH %u %s", imap_edata_get(e)->uid,
(mutt_bit_isset(adata->capabilities, IMAP4REV1) ?
(ImapPeek ? "BODY.PEEK[]" : "BODY[]") :
"RFC822"));
pc = imap_next_word(pc);
if (mutt_str_atoui(pc, &uid) < 0)
goto bail;
- if (uid != IMAP_EDATA(e)->uid)
+ if (uid != imap_edata_get(e)->uid)
{
mutt_error(_(
"The message index is incorrect. Try reopening the mailbox."));
mutt_clear_error();
rewind(msg->fp);
- IMAP_EDATA(e)->parsed = true;
+ imap_edata_get(e)->parsed = true;
/* retry message parse if cached message is empty */
if (!retried && ((e->lines == 0) || (e->content->length == 0)))
short ImapPipelineDepth; ///< Config: (imap) Number of IMAP commands that may be queued up
/**
- * imap_get_adata - Get the Account data for this mailbox
+ * imap_adata_free - Release and clear storage in an ImapAccountData structure
+ * @param ptr Imap Account data
+ */
+void imap_adata_free(void **ptr)
+{
+ if (!ptr || !*ptr)
+ return;
+
+ struct ImapAccountData *adata = *ptr;
+
+ FREE(&adata->capstr);
+ mutt_list_free(&adata->flags);
+ imap_mboxcache_free(adata);
+ mutt_buffer_free(&adata->cmdbuf);
+ FREE(&adata->buf);
+ mutt_bcache_close(&adata->bcache);
+ FREE(&adata->cmds);
+ FREE(ptr);
+}
+
+/**
+ * imap_adata_new - Allocate and initialise a new ImapAccountData structure
+ * @retval ptr New ImapAccountData
+ */
+struct ImapAccountData *imap_adata_new(void)
+{
+ struct ImapAccountData *adata = mutt_mem_calloc(1, sizeof(struct ImapAccountData));
+
+ adata->cmdbuf = mutt_buffer_new();
+ adata->cmdslots = ImapPipelineDepth + 2;
+ adata->cmds = mutt_mem_calloc(adata->cmdslots, sizeof(*adata->cmds));
+
+ STAILQ_INIT(&adata->flags);
+ STAILQ_INIT(&adata->mboxcache);
+
+ return adata;
+}
+
+/**
+ * imap_adata_get - Get the Account data for this mailbox
*/
-struct ImapAccountData *imap_get_adata(struct Mailbox *m)
+struct ImapAccountData *imap_adata_get(struct Mailbox *m)
{
if (!m || (m->magic != MUTT_IMAP))
return NULL;
if (msn <= adata->max_msn)
{
struct Email *cur_header = adata->msn_index[msn - 1];
- cur_uid = cur_header ? IMAP_EDATA(cur_header)->uid : 0;
+ cur_uid = cur_header ? imap_edata_get(cur_header)->uid : 0;
if (!state || (cur_uid && ((cur_uid - 1) == last_uid)))
match = true;
last_uid = cur_uid;
if (!adata->hcache)
return -1;
- sprintf(key, "/%u", IMAP_EDATA(e)->uid);
+ sprintf(key, "/%u", imap_edata_get(e)->uid);
return mutt_hcache_store(adata->hcache, key, imap_hcache_keylen(key), e, adata->uid_validity);
}
mutt_error("%s [%s]\n", where, msg);
}
-/**
- * imap_adata_new - Allocate and initialise a new ImapAccountData structure
- * @retval ptr New ImapAccountData
- */
-struct ImapAccountData *imap_adata_new(void)
-{
- struct ImapAccountData *adata = mutt_mem_calloc(1, sizeof(struct ImapAccountData));
-
- adata->cmdbuf = mutt_buffer_new();
- adata->cmdslots = ImapPipelineDepth + 2;
- adata->cmds = mutt_mem_calloc(adata->cmdslots, sizeof(*adata->cmds));
-
- STAILQ_INIT(&adata->flags);
- STAILQ_INIT(&adata->mboxcache);
-
- return adata;
-}
-
-/**
- * imap_adata_free - Release and clear storage in an ImapAccountData structure
- * @param ptr Imap Account data
- */
-void imap_adata_free(void **ptr)
-{
- if (!ptr || !*ptr)
- return;
-
- struct ImapAccountData *adata = *ptr;
-
- FREE(&adata->capstr);
- mutt_list_free(&adata->flags);
- imap_mboxcache_free(adata);
- mutt_buffer_free(&adata->cmdbuf);
- FREE(&adata->buf);
- mutt_bcache_close(&adata->bcache);
- FREE(&adata->cmds);
- FREE(ptr);
-}
-
/**
* imap_fix_path - Fix up the imap path
* @param adata Imap Account data
{
if (!m)
return;
- struct ImapAccountData *adata = imap_get_adata(m);
+ struct ImapAccountData *adata = imap_adata_get(m);
if (!adata)
return;
{
if (!m)
return;
- struct ImapAccountData *adata = imap_get_adata(m);
+ struct ImapAccountData *adata = imap_adata_get(m);
if (!adata)
return;